| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955 |
- package cn.com.lzt.sysmsg.controller;
- import java.io.IOException;
- import java.net.URI;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.Set;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.validation.ConstraintViolation;
- import javax.validation.Validator;
- import org.apache.commons.lang.StringUtils;
- import org.apache.log4j.Logger;
- import org.jeecgframework.core.beanvalidator.BeanValidators;
- import org.jeecgframework.core.common.controller.BaseController;
- import org.jeecgframework.core.common.exception.BusinessException;
- import org.jeecgframework.core.common.model.json.AjaxJson;
- import org.jeecgframework.core.common.model.json.DataGrid;
- import org.jeecgframework.core.common.service.CommonService;
- import org.jeecgframework.core.constant.Globals;
- import org.jeecgframework.core.util.ExceptionUtil;
- import org.jeecgframework.core.util.JeecgDataAutorUtils;
- import org.jeecgframework.core.util.MyBeanUtils;
- import org.jeecgframework.core.util.ResourceUtil;
- import org.jeecgframework.core.util.StringUtil;
- import org.jeecgframework.minidao.pojo.MiniDaoPage;
- import org.jeecgframework.poi.excel.ExcelImportUtil;
- import org.jeecgframework.poi.excel.entity.ExportParams;
- import org.jeecgframework.poi.excel.entity.ImportParams;
- import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
- import org.jeecgframework.tag.core.easyui.TagUtil;
- import org.jeecgframework.web.system.pojo.base.DictEntity;
- import org.jeecgframework.web.system.pojo.base.TSUser;
- import org.jeecgframework.web.system.service.SystemService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.http.HttpHeaders;
- import org.springframework.http.HttpStatus;
- import org.springframework.http.MediaType;
- import org.springframework.http.ResponseEntity;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.ModelMap;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.ResponseBody;
- import org.springframework.web.bind.annotation.ResponseStatus;
- import org.springframework.web.multipart.MultipartFile;
- import org.springframework.web.multipart.MultipartHttpServletRequest;
- import org.springframework.web.servlet.ModelAndView;
- import org.springframework.web.util.UriComponentsBuilder;
- import cn.com.lzt.sysmsg.dto.SysMsgDto;
- import cn.com.lzt.sysmsg.entity.SysMsgEntity;
- import cn.com.lzt.sysmsg.service.SysMsgServiceI;
- import cn.com.lzt.sysmsgdetail.entity.SysMsgDetailEntity;
- import com.alibaba.fastjson.JSONObject;
- /**
- * @Title: Controller
- * @Description: 系统消息
- * @author onlineGenerator
- * @date 2017-11-29 19:56:16
- * @version V1.0
- *
- */
- @Controller
- @RequestMapping("/sysMsgController")
- public class SysMsgController extends BaseController {
- /**
- * Logger for this class
- */
- private static final Logger logger = Logger.getLogger(SysMsgController.class);
- @Autowired
- private SysMsgServiceI sysMsgService;
- @Autowired
- private SystemService systemService;
- @Autowired
- private Validator validator;
-
- //公共方法类
- @Autowired
- private CommonService commonService;
-
- /**
- * 系统消息列表 页面跳转
- *
- * @return
- */
- @RequestMapping(params = "list")
- public ModelAndView list(HttpServletRequest request) {
- return new ModelAndView("cn/com/lzt/sysmsg/sysMsgList");
- }
- /**
- * easyui AJAX请求数据
- *
- * @param request
- * @param response
- * @param dataGrid
- */
- @RequestMapping(params = "datagrid")
- public void datagrid(SysMsgDto sysMsgDto,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
-
-
- String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
- MiniDaoPage<SysMsgDto> sysMsgDtoList = sysMsgService.getSysMsgDtoPage(sysMsgDto, dataGrid.getPage(), dataGrid.getRows(),authSql);
- //获取数据字典中消息标题
- List<DictEntity> msgTitleList=systemService.queryDict(null, "process", null);
- Map<String, String> msgTitleMap=new HashMap<String, String>();
- for (int i = 0; i < msgTitleList.size(); i++) {
- msgTitleMap.put(msgTitleList.get(i).getTypecode(), msgTitleList.get(i).getTypename());
- }
- for (int i = 0; i < sysMsgDtoList.getResults().size(); i++) {
- if(msgTitleMap.containsKey(sysMsgDtoList.getResults().get(i).getMsgTitle())
- &&msgTitleMap.get(sysMsgDtoList.getResults().get(i).getMsgTitle()).length()!=0){
- sysMsgDtoList.getResults().get(i).setMsgTitle(msgTitleMap.get(sysMsgDtoList.getResults().get(i).getMsgTitle()));
- }
- }
- dataGrid.setTotal(sysMsgDtoList.getTotal());
- dataGrid.setResults(sysMsgDtoList.getResults());
- TagUtil.datagrid(response, dataGrid);
-
-
- /*CriteriaQuery cq = new CriteriaQuery(SysMsgEntity.class, dataGrid);
- //查询条件组装器
- org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, sysMsg, request.getParameterMap());
- try{
- //自定义追加查询条件
- //排序
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("sendStatus", "asc");
- cq.setOrder(map);
-
- }catch (Exception e) {
- throw new BusinessException(e.getMessage());
- }
- cq.add();
- this.sysMsgService.getDataGridReturn(cq, true);
- TagUtil.datagrid(response, dataGrid);*/
- }
- /**
- * 删除系统消息
- *
- * @return
- */
- @RequestMapping(params = "doDel")
- @ResponseBody
- public AjaxJson doDel(SysMsgEntity sysMsg, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- sysMsg = systemService.getEntity(SysMsgEntity.class, sysMsg.getId());
- message = "系统消息删除成功";
- try{
- sysMsgService.delete(sysMsg);
- systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
- }catch(Exception e){
- e.printStackTrace();
- message = "系统消息删除失败";
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
-
- /**
- * 批量删除系统消息
- *
- * @return
- */
- @RequestMapping(params = "doBatchDel")
- @ResponseBody
- public AjaxJson doBatchDel(String ids,HttpServletRequest request){
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "系统消息删除成功";
- try{
- for(String id:ids.split(",")){
- SysMsgEntity sysMsg = systemService.getEntity(SysMsgEntity.class,
- id
- );
- sysMsgService.delete(sysMsg);
- systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
- }
- }catch(Exception e){
- e.printStackTrace();
- message = "系统消息删除失败";
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
- /**
- * 添加系统消息
- *
- * @return
- */
- @RequestMapping(params = "doAdd")
- @ResponseBody
- public AjaxJson doAdd(SysMsgEntity sysMsg, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "系统消息添加成功";
- try{
- sysMsg.setSendStatus(Globals.send_status_0);
- sysMsgService.save(sysMsg);
- systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
- }catch(Exception e){
- e.printStackTrace();
- message = "系统消息添加失败";
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
-
- /**
- * 更新系统消息
- *
- * @return
- */
- @RequestMapping(params = "doUpdate")
- @ResponseBody
- public AjaxJson doUpdate(SysMsgEntity sysMsg, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "系统消息更新成功";
- SysMsgEntity t = sysMsgService.get(SysMsgEntity.class, sysMsg.getId());
- try {
- MyBeanUtils.copyBeanNotNull2Bean(sysMsg, t);
- sysMsgService.saveOrUpdate(t);
- systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
- } catch (Exception e) {
- e.printStackTrace();
- message = "系统消息更新失败";
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
-
- /**
- * 系统消息新增页面跳转
- *
- * @return
- */
- @RequestMapping(params = "goAdd")
- public ModelAndView goAdd(SysMsgEntity sysMsg, HttpServletRequest req) {
- if (StringUtil.isNotEmpty(sysMsg.getId())) {
- sysMsg = sysMsgService.getEntity(SysMsgEntity.class, sysMsg.getId());
- req.setAttribute("sysMsgPage", sysMsg);
- }
- return new ModelAndView("cn/com/lzt/sysmsg/sysMsg-add");
- }
- /**
- * 系统消息编辑页面跳转
- *
- * @return
- */
- @RequestMapping(params = "goUpdate")
- public ModelAndView goUpdate(SysMsgEntity sysMsg, HttpServletRequest req) {
- if (StringUtil.isNotEmpty(sysMsg.getId())) {
- sysMsg = sysMsgService.getEntity(SysMsgEntity.class, sysMsg.getId());
- req.setAttribute("sysMsgPage", sysMsg);
- }
- return new ModelAndView("cn/com/lzt/sysmsg/sysMsg-update");
- }
-
- /**
- * 系统消息查看
- * @author zbw
- * 2017-12-25
- * @param sysMsg
- * @param req
- * @return
- */
- @RequestMapping(params = "sysMsgSee")
- public ModelAndView sysMsgSee(SysMsgEntity sysMsg, HttpServletRequest req) {
- if (StringUtil.isNotEmpty(sysMsg.getId())) {
- sysMsg = sysMsgService.getEntity(SysMsgEntity.class, sysMsg.getId());
- req.setAttribute("sysMsgPage", sysMsg);
- }
- return new ModelAndView("cn/com/lzt/sysmsg/sysMsg-see");
- }
-
- /**
- * 导入功能跳转
- *
- * @return
- */
- @RequestMapping(params = "upload")
- public ModelAndView upload(HttpServletRequest req) {
- req.setAttribute("controller_name","sysMsgController");
- return new ModelAndView("common/upload/pub_excel_upload");
- }
-
- /**
- * 导出excel
- *
- * @param request
- * @param response
- */
- @RequestMapping(params = "exportXls")
- public String exportXls(SysMsgDto sysMsgDto,HttpServletRequest request,HttpServletResponse response
- , DataGrid dataGrid,ModelMap modelMap) {
-
- String ids=request.getParameter("ids");
- if(ids!=null&&ids.length()!=0){
- sysMsgDto.getSysMsgIdList().addAll(extractIdListByComma(ids));
- }
-
- /*//获取发布状态
- List<DictEntity> sendStatusList=systemService.queryDict(null, "send_status", null);
- Map<String, String> sendStatusMap=new HashMap<String, String>();
- for (int i = 0; i < sendStatusList.size(); i++) {
- sendStatusMap.put(sendStatusList.get(i).getTypecode(), sendStatusList.get(i).getTypename());
- }
-
-
- //标题 该list中用于存储标题的信息,每一个ExcelExportEntity 表示一列,根据List 的入栈顺序,由左至右,一次排序
- List<ExcelExportEntity> entityList = new ArrayList<ExcelExportEntity>();
- ExcelExportEntity head1=new ExcelExportEntity("消息标题 ", "msgTitle", 15);
- entityList.add(head1);
- ExcelExportEntity head2=new ExcelExportEntity("消息内容 ", "msgContent", 15);
- entityList.add(head2);
- ExcelExportEntity head3=new ExcelExportEntity("发布时间 ", "sendTime", 15);
- entityList.add(head3);
- ExcelExportEntity head4=new ExcelExportEntity("发布状态", "sendStatus", 15);
- entityList.add(head4);
-
-
- //组建数据集
- List<Map<String,Object>> dataResult = new ArrayList<Map<String,Object>>();
-
- String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
- List<SysMsgDto> sysMsgDtoList=sysMsgService.getSysMsgDtoExport(sysMsgDto, authSql);
-
- for (int i = 0; i < sysMsgDtoList.size(); i++) {
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("msgTitle", sysMsgDtoList.get(i).getMsgTitle());
- map.put("msgContent", sysMsgDtoList.get(i).getMsgContent());
- map.put("sendTime", sysMsgDtoList.get(i).getSendTime());
- map.put("sendStatus", sendStatusMap.get(sysMsgDtoList.get(i).getSendStatus()));
- dataResult.add(map);
- }
-
- modelMap.put(MapExcelConstants.ENTITY_LIST, entityList);
- modelMap.put(MapExcelConstants.MAP_LIST, dataResult);
- modelMap.put(NormalExcelConstants.FILE_NAME,"系统消息发布");
- modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("系统消息发布", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
- "导出信息"));
- return MapExcelConstants.JEECG_MAP_EXCEL_VIEW;*/
-
-
- /*CriteriaQuery cq = new CriteriaQuery(SysMsgEntity.class, dataGrid);
- org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, sysMsg, request.getParameterMap());
- List<SysMsgEntity> sysMsgs = this.sysMsgService.getListByCriteriaQuery(cq,false);
- modelMap.put(NormalExcelConstants.FILE_NAME,"系统消息");
- modelMap.put(NormalExcelConstants.CLASS,SysMsgEntity.class);
- modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("系统消息列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
- "导出信息"));
- modelMap.put(NormalExcelConstants.DATA_LIST,sysMsgs);
- return NormalExcelConstants.JEECG_EXCEL_VIEW;*/
-
-
- String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
- List<SysMsgDto> sysMsgDtoList=sysMsgService.getSysMsgDtoExport(sysMsgDto, authSql);
-
- modelMap.put(NormalExcelConstants.FILE_NAME,"系统消息");
- modelMap.put(NormalExcelConstants.CLASS,SysMsgDto.class);
- modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("系统消息列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
- "导出信息"));
- modelMap.put(NormalExcelConstants.DATA_LIST,sysMsgDtoList);
- return NormalExcelConstants.JEECG_EXCEL_VIEW;
- }
- /**
- * 导出excel 使模板
- *
- * @param request
- * @param response
- */
- @RequestMapping(params = "exportXlsByT")
- public String exportXlsByT(SysMsgEntity sysMsg,HttpServletRequest request,HttpServletResponse response
- , DataGrid dataGrid,ModelMap modelMap) {
- modelMap.put(NormalExcelConstants.FILE_NAME,"系统消息");
- modelMap.put(NormalExcelConstants.CLASS,SysMsgEntity.class);
- modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("系统消息列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
- "导出信息"));
- modelMap.put(NormalExcelConstants.DATA_LIST,new ArrayList());
- return NormalExcelConstants.JEECG_EXCEL_VIEW;
- }
-
- @SuppressWarnings("unchecked")
- @RequestMapping(params = "importExcel", method = RequestMethod.POST)
- @ResponseBody
- public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) {
- AjaxJson j = new AjaxJson();
-
- MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
- Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
- for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
- MultipartFile file = entity.getValue();// 获取上传文件对象
- ImportParams params = new ImportParams();
- params.setTitleRows(2);
- params.setHeadRows(1);
- params.setNeedSave(true);
- try {
- List<SysMsgEntity> listSysMsgEntitys = ExcelImportUtil.importExcel(file.getInputStream(),SysMsgEntity.class,params);
- for (SysMsgEntity sysMsg : listSysMsgEntitys) {
- sysMsgService.save(sysMsg);
- }
- j.setMsg("文件导入成功!");
- } catch (Exception e) {
- j.setMsg("文件导入失败!");
- logger.error(ExceptionUtil.getExceptionMessage(e));
- }finally{
- try {
- file.getInputStream().close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- return j;
- }
-
- @RequestMapping(method = RequestMethod.GET)
- @ResponseBody
- public List<SysMsgEntity> list() {
- List<SysMsgEntity> listSysMsgs=sysMsgService.getList(SysMsgEntity.class);
- return listSysMsgs;
- }
-
- @RequestMapping(value = "/{id}", method = RequestMethod.GET)
- @ResponseBody
- public ResponseEntity<?> get(@PathVariable("id") String id) {
- SysMsgEntity task = sysMsgService.get(SysMsgEntity.class, id);
- if (task == null) {
- return new ResponseEntity(HttpStatus.NOT_FOUND);
- }
- return new ResponseEntity(task, HttpStatus.OK);
- }
- @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
- @ResponseBody
- public ResponseEntity<?> create(@RequestBody SysMsgEntity sysMsg, UriComponentsBuilder uriBuilder) {
- //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息.
- Set<ConstraintViolation<SysMsgEntity>> failures = validator.validate(sysMsg);
- if (!failures.isEmpty()) {
- return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
- }
- //保存
- try{
- sysMsgService.save(sysMsg);
- } catch (Exception e) {
- e.printStackTrace();
- return new ResponseEntity(HttpStatus.NO_CONTENT);
- }
- //按照Restful风格约定,创建指向新任务的url, 也可以直接返回id或对象.
- String id = sysMsg.getId();
- URI uri = uriBuilder.path("/rest/sysMsgController/" + id).build().toUri();
- HttpHeaders headers = new HttpHeaders();
- headers.setLocation(uri);
- return new ResponseEntity(headers, HttpStatus.CREATED);
- }
- @RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<?> update(@RequestBody SysMsgEntity sysMsg) {
- //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息.
- Set<ConstraintViolation<SysMsgEntity>> failures = validator.validate(sysMsg);
- if (!failures.isEmpty()) {
- return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
- }
- //保存
- try{
- sysMsgService.saveOrUpdate(sysMsg);
- } catch (Exception e) {
- e.printStackTrace();
- return new ResponseEntity(HttpStatus.NO_CONTENT);
- }
- //按Restful约定,返回204状态码, 无内容. 也可以返回200状态码.
- return new ResponseEntity(HttpStatus.NO_CONTENT);
- }
- @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
- @ResponseStatus(HttpStatus.NO_CONTENT)
- public void delete(@PathVariable("id") String id) {
- sysMsgService.deleteEntityById(SysMsgEntity.class, id);
- }
-
-
-
-
- /**
- * 我的消息主页数据查看
- * 系统消息列表 页面跳转
- *
- *
- * @return
- */
- @RequestMapping(params = "myMsgList")
- public ModelAndView myMsgList(HttpServletRequest request) {
- return new ModelAndView("cn/com/lzt/sysmsg/mymsg/myMsgList");
- }
- /**
- * 获取我的消息未读消息个数
- * easyui AJAX请求数据
- * @author 刘梦祥
- * @date 2022年8月2日14:32:39
- */
- @RequestMapping(params = "getMyMsgCount")
- @ResponseBody
- public Object getMyMsgCount() {
- TSUser tSUser = ResourceUtil.getSessionUser();
- if(tSUser != null){
- SysMsgDto sysMsgDto = new SysMsgDto();
- sysMsgDto.setReceivedId(tSUser.getId());
- sysMsgDto.setReadStatus("0");
- String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
- MiniDaoPage<SysMsgDto> sysMsgDtoList = sysMsgService.getMyMsgDtoPage(sysMsgDto, 1, 999,authSql);
- return sysMsgDtoList.getTotal();
- }else{
- return 0;
- }
- }
- /**
- * 我的消息主页数据查看
- * easyui AJAX请求数据
- *
- * @param request
- * @param response
- * @param dataGrid
- */
- @RequestMapping(params = "myMsgDatagrid")
- public void myMsgDatagrid(SysMsgDto sysMsgDto,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
- /*//获取数据字典中的消息标题
- List<DictEntity> msgTitleCodeProcessList=systemService.queryDict(null, "process", null);
- Map<String, String> msgTitleCodeProcessMap=new HashMap<String, String>();
- Map<String, String> msgTitleProcessCodeMap=new HashMap<String, String>();
- for (int i = 0; i < msgTitleCodeProcessList.size(); i++) {
- msgTitleCodeProcessMap.put(msgTitleCodeProcessList.get(i).getTypename(),msgTitleCodeProcessList.get(i).getTypecode());
- msgTitleProcessCodeMap.put(msgTitleCodeProcessList.get(i).getTypecode(), msgTitleCodeProcessList.get(i).getTypename());
- }
-
- if(sysMsgDto.getMsgTitle()!=null&&sysMsgDto.getMsgTitle().length()!=0){
- if(msgTitleCodeProcessMap.containsKey(sysMsgDto.getMsgTitle())){
- sysMsgDto.setMsgTitle(msgTitleCodeProcessMap.get(sysMsgDto.getMsgTitle()));
- }
- }*/
- TSUser tSUser = ResourceUtil.getSessionUser();
- sysMsgDto.setReceivedId(tSUser.getId());
- String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
- MiniDaoPage<SysMsgDto> sysMsgDtoList = sysMsgService.getMyMsgDtoPage(sysMsgDto, dataGrid.getPage(), dataGrid.getRows(),authSql);
-
- dataGrid.setTotal(sysMsgDtoList.getTotal());
- dataGrid.setResults(sysMsgDtoList.getResults());
- TagUtil.datagrid(response, dataGrid);
-
- /*CriteriaQuery cq = new CriteriaQuery(SysMsgEntity.class, dataGrid);
- //查询条件组装器
- org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, sysMsg, request.getParameterMap());
- try{
- //自定义追加查询条件
- }catch (Exception e) {
- throw new BusinessException(e.getMessage());
- }
- cq.add();
- this.sysMsgService.getDataGridReturn(cq, true);
- TagUtil.datagrid(response, dataGrid);*/
- }
- /**
- * 我的消息主页数据查看
- * easyui AJAX请求数据
- */
- @RequestMapping(params = "myMsgDatagridToWX")
- @ResponseBody
- public AjaxJson myMsgDatagridToWX(SysMsgDto sysMsgDto,Integer pageSize,Integer rowsSize) {
- AjaxJson j = new AjaxJson();
- if(StringUtils.isNotEmpty(sysMsgDto.getReceivedId())){
- MiniDaoPage<SysMsgDto> sysMsgDtoList = sysMsgService.getMyMsgDtoPage(sysMsgDto, pageSize == null ? 1 : pageSize, rowsSize == null ? 100 : rowsSize,"");
- List<SysMsgDto> sysMsgDtos = sysMsgDtoList.getResults();
- Map<String,Object> attr = new HashMap<>();
- attr.put("pageSize",pageSize == null ? 1 : pageSize);
- attr.put("rowsSize",rowsSize == null ? 100 : rowsSize);
- attr.put("totalCount",sysMsgDtoList.getTotal());
- j.setAttributes(attr);
- j.setMsg("请求成功!");
- j.setObj(sysMsgDtos);
- }else{
- j.setMsg("请传入用户id!");
- j.setSuccess(false);
- }
- return j;
- }
- /**
- * 一键已读
- * @author 刘梦祥
- * @date 2022年8月24日17:00:44
- * @return
- */
- @RequestMapping(params = "doReadToWX")
- @ResponseBody
- public AjaxJson doReadToWX(String id) {
- AjaxJson j = new AjaxJson();
- if(StringUtils.isNotEmpty(id)){
- String updateMsgReadStatus = "update t_bus_sys_msg_detail set read_status = '1',read_time = NOW() where msg_id = '"+id+"' ";
- Integer sqlStatus = systemService.executeSql(updateMsgReadStatus);
- j.setMsg(sqlStatus != null && sqlStatus != 0 ? "操作成功!" : "操作失败!");
- j.setSuccess(sqlStatus != null && sqlStatus != 0);
- }else{
- j.setSuccess(false);
- j.setMsg("操作失败!请检查消息id!");
- }
- return j;
- }
- /**
- * 一键全读
- * @author 刘梦祥
- * @date 2022年8月24日17:00:44
- * @return
- */
- @RequestMapping(params = "readAllMsgToWX")
- @ResponseBody
- public AjaxJson readAllMsgToWX(String receivedId) {
- AjaxJson j = new AjaxJson();
- if(StringUtils.isNotEmpty(receivedId)){
- SysMsgDto sysMsgDto = new SysMsgDto();
- sysMsgDto.setReceivedId(receivedId);
- sysMsgDto.setReadStatus("0");
- String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
- MiniDaoPage<SysMsgDto> sysMsgDtoList = sysMsgService.getMyMsgDtoPage(sysMsgDto, 1, 99999999,authSql);
- List<SysMsgDto> sysMsgDtos = sysMsgDtoList.getResults();
- if(sysMsgDtos != null && sysMsgDtos.size() > 0){
- StringBuffer msgIds = new StringBuffer();
- for (SysMsgDto sysMsgDto1 : sysMsgDtos){
- msgIds.append("'");
- msgIds.append(sysMsgDto1.getId());
- msgIds.append("'");
- msgIds.append(",");
- }
- String queryMsgIds = "";
- if (msgIds.length() > 0){
- queryMsgIds = msgIds.substring(0,msgIds.length() -1).toString();
- }
- String updateMsgReadStatus = "update t_bus_sys_msg_detail set read_status = '1',read_time = NOW() where msg_id in ("+queryMsgIds+")";
- Integer sqlStatus = systemService.executeSql(updateMsgReadStatus);
- j.setSuccess(sqlStatus != null && sqlStatus != 0);
- j.setMsg(sqlStatus != null && sqlStatus != 0 ? "操作成功!" : "操作失败!");
- }
- }else{
- j.setSuccess(false);
- j.setMsg("操作失败!请检查用户id!");
- }
- return j;
- }
-
- /**
- * 首页消息通知看板数据
- * 只查看最新的10条
- * easyui AJAX请求数据
- *
- * @param request
- * @param response
- * @param dataGrid
- */
- @RequestMapping(params = "homePageMyMsg")
- @ResponseBody
- public String homePageMyMsg(SysMsgDto sysMsgDto,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
- // AjaxJson j = new AjaxJson();
- TSUser tSUser=ResourceUtil.getSessionUser();
- sysMsgDto.setReceivedId(tSUser.getId());
- String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
- MiniDaoPage<SysMsgDto> sysMsgDtoList = sysMsgService.getMyMsgDtoPage(sysMsgDto, 1, 10,authSql);
- // Map<String, Object> m=new HashMap<String, Object>();
- // SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyy-MM-dd");
- /*String str="[";
- for (int i = 0; i < sysMsgDtoList.getResults().size(); i++) {
- String sendTime=simpleDateFormat.format(sysMsgDtoList.getResults().get(i).getSendTime());
- String createDate=simpleDateFormat.format(sysMsgDtoList.getResults().get(i).getCreateDate());
- JSONObject jsonObject = JSONObject.fromObject(sysMsgDtoList.getResults().get(i));
- Map<String, Object> map=jsonObject;
- jsonObject.put("sendTime", sendTime);
- jsonObject.put("createDate", createDate);
- if(str.length()!=1){
- str+=",{";
- }else{
- str+="{";
- }
- for (Map.Entry<String, Object> m : map.entrySet()) {
- if(!str.substring(str.length()-1, str.length()).equals("{")){
- if(m.getValue().toString().length()>70){
- str+=",'"+m.getKey()+"':'"+m.getValue().toString().subSequence(0, 70)+"...'";
- }else{
- str+=",'"+m.getKey()+"':'"+m.getValue()+"'";
- }
-
- }else{
- if(m.getValue().toString().length()>70){
- str+="'"+m.getKey()+"':'"+m.getValue().toString().subSequence(0, 70)+"...'";
- }else{
- str+="'"+m.getKey()+"':'"+m.getValue()+"'";
- }
-
- }
-
- }
- str+="}";
-
- // m.put(String.valueOf(i), jsonObject.toString());
- }
- str+="]";*/
- String str =JSONObject.toJSONString(sysMsgDtoList);
- // j.setAttributes(m);
- return str;
- }
-
- /**
- * 首页消息通知看板数据
- * 只查看最新的10条
- * easyui AJAX请求数据
- *
- * @param request
- * @param response
- * @param dataGrid
- * @param user
- */
- /*@RequestMapping(params = "testGet")
- @ResponseBody
- public String testGet(HttpServletRequest request, HttpServletResponse response) {
- System.out.println("qqqqqqqqqqqqqqq");
- System.out.println("qqqqqqqqqqqqqqq");
- System.out.println("qqqqqqqqqqqqqqq");
- System.out.println("qqqqqqqqqqqqqqq");
- System.out.println("qqqqqqqqqqqqqqq");
- System.out.println("qqqqqqqqqqqqqqq");
- return "qqqqqqqqqqqqqqqqq";
- }*/
-
- /**
- * 菜单我的消息查看页面跳转
- *
- * @return
- */
- @RequestMapping(params = "myMsgSee")
- public ModelAndView myMsgSee(SysMsgEntity sysMsg, HttpServletRequest req) {
- if (StringUtil.isNotEmpty(sysMsg.getId())) {
- sysMsg = sysMsgService.getEntity(SysMsgEntity.class, sysMsg.getId());
- req.setAttribute("sysMsgPage", sysMsg);
- }
- StringBuffer hql = new StringBuffer(" FROM SysMsgDetailEntity where msgId=?");
- List<SysMsgDetailEntity> sysMsgDetailEntityList = commonService.findHql(hql.toString(),sysMsg.getId());
- if(sysMsgDetailEntityList.size()>0){
- sysMsgDetailEntityList.get(0).setReadStatus(Globals.read_status_1);
- sysMsgDetailEntityList.get(0).setReadTime(new Date());
- systemService.saveOrUpdate(sysMsgDetailEntityList.get(0));
- }
- return new ModelAndView("cn/com/lzt/sysmsg/mymsg/myMsg-see");
- }
- /**
- * 一键全读
- * @author 刘梦祥
- * @date 2022年8月24日17:00:44
- * @return
- */
- @RequestMapping(params = "readAllMsg")
- @ResponseBody
- public AjaxJson readAllMsg() {
- AjaxJson j = new AjaxJson();
- SysMsgDto sysMsgDto = new SysMsgDto();
- TSUser tSUser = ResourceUtil.getSessionUser();
- sysMsgDto.setReceivedId(tSUser.getId());
- sysMsgDto.setReadStatus("0");
- String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
- MiniDaoPage<SysMsgDto> sysMsgDtoList = sysMsgService.getMyMsgDtoPage(sysMsgDto, 1, 99999999,authSql);
- List<SysMsgDto> sysMsgDtos = sysMsgDtoList.getResults();
- if(sysMsgDtos != null && sysMsgDtos.size() > 0){
- StringBuffer msgIds = new StringBuffer();
- for (SysMsgDto sysMsgDto1 : sysMsgDtos){
- msgIds.append("'");
- msgIds.append(sysMsgDto1.getId());
- msgIds.append("'");
- msgIds.append(",");
- }
- String queryMsgIds = "";
- if (msgIds.length() > 0){
- queryMsgIds = msgIds.substring(0,msgIds.length() -1).toString();
- }
- String updateMsgReadStatus = "update t_bus_sys_msg_detail set read_status = '1',read_time = NOW() where msg_id in ("+queryMsgIds+")";
- Integer sqlStatus = systemService.executeSql(updateMsgReadStatus);
- j.setMsg(sqlStatus != null && sqlStatus != 0 ? "操作成功!" : "操作失败!");
- }
- return j;
- }
- /**
- * 一键已读
- * @author 刘梦祥
- * @date 2022年8月24日17:00:44
- * @return
- */
- @RequestMapping(params = "doRead")
- @ResponseBody
- public AjaxJson doRead(String id) {
- AjaxJson j = new AjaxJson();
- StringBuffer hql = new StringBuffer(" FROM SysMsgDetailEntity where msgId=?");
- List<SysMsgDetailEntity> sysMsgDetailEntityList = commonService.findHql(hql.toString(),id);
- if(sysMsgDetailEntityList.size()>0){
- sysMsgDetailEntityList.get(0).setReadStatus(Globals.read_status_1);
- sysMsgDetailEntityList.get(0).setReadTime(new Date());
- systemService.saveOrUpdate(sysMsgDetailEntityList.get(0));
- }
- j.setMsg("操作成功!");
- return j;
- }
-
- /**
- * 首页我的消息查看页面跳转
- * @author zbw
- * 2018-1-8
- * @param sysMsg
- * @param req
- * @return
- */
- @RequestMapping(params = "myMsgHomePageSee")
- public ModelAndView myMsgHomePageSee(SysMsgEntity sysMsg, HttpServletRequest req) {
- if (StringUtil.isNotEmpty(sysMsg.getId())) {
- sysMsg = sysMsgService.getEntity(SysMsgEntity.class, sysMsg.getId());
- req.setAttribute("sysMsgPage", sysMsg);
- }
- TSUser tSUser=ResourceUtil.getSessionUser();
- String receivedId=tSUser.getId();
- StringBuffer hql = new StringBuffer(" FROM SysMsgDetailEntity where msgId=? and receivedId=? ");
- List<SysMsgDetailEntity> sysMsgDetailEntityList = commonService.findHql(hql.toString(),sysMsg.getId(),receivedId);
- if(sysMsgDetailEntityList.size()>0){
- sysMsgDetailEntityList.get(0).setReadStatus(Globals.read_status_1);
- sysMsgDetailEntityList.get(0).setReadTime(new Date());
- systemService.saveOrUpdate(sysMsgDetailEntityList.get(0));
- }
- return new ModelAndView("cn/com/lzt/sysmsg/mymsg/myMsgHomePage-see");
- }
-
-
- /**
- * 系统消息保存总方法
- * @author zbw
- * 2017-11-30
- * @param sysMsg
- * @param request
- * @return
- */
- @RequestMapping(params = "saveSysMsgAndSysMsgDetail")
- @ResponseBody
- public AjaxJson saveSysMsgAndSysMsgDetail(SysMsgEntity sysMsg, HttpServletRequest request){
- AjaxJson j = new AjaxJson();
- try {
- j=sysMsgService.saveSysMsg(sysMsg);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return j;
- }
-
-
- /**
- * 系统消息发布总方法
- * @author zbw
- * 2017-11-30
- * @param request
- * @return
- */
- @RequestMapping(params = "publishMsg")
- @ResponseBody
- public AjaxJson publishMsg(String ids,HttpServletRequest request){
- AjaxJson j = new AjaxJson();
- try {
- j=sysMsgService.doBatchPublishSysMsg(ids);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return j;
- }
-
- /**
- * 系统消息删除总方法
- * @author zbw
- * 2017-11-30
- * @param request
- * @return
- */
- @RequestMapping(params = "deleteSysMsgAndSysMsgDetail")
- @ResponseBody
- public AjaxJson deleteSysMsgAndSysMsgDetail(String ids,HttpServletRequest request){
- AjaxJson j = new AjaxJson();
- try {
- j=sysMsgService.doBatchDelSysMsg(ids);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return j;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
|