From 274ee08d6b94ec36de820870c85bd3c88fcb1f49 Mon Sep 17 00:00:00 2001 From: liukewei Date: Mon, 22 Jan 2024 08:46:50 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B4=AF=E8=AE=A1=E8=B7=9F=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ehs/EhsHiddenDangerController.java | 15 +- .../ehs/EhsMyMessageController.java | 191 ++++++++++++- .../ehs/EhsNoticeMessageController.java | 1 + .../ruoyi/ehsMaterial/domain/EhsMaterial.java | 3 +- .../mapper/EhsMyMessageMapper.java | 2 + .../service/IEhsMyMessageService.java | 2 + .../service/impl/EhsMyMessageServiceImpl.java | 15 +- .../domain/EhsNoticeMessage.java | 6 + .../impl/EhsNoticeMessageServiceImpl.java | 2 + .../mapper/ehs/EhsMaterialMapper.xml | 3 + .../mapper/ehs/EhsMyMessageMapper.xml | 11 +- .../mapper/ehs/EhsNoticeMessageMapper.xml | 6 + ruoyi-ui/src/api/ehs/ehsMyMessage.js | 29 ++ ruoyi-ui/src/layout/components/Navbar.vue | 255 +++++++++++++++--- .../src/views/ehs/ehsHiddenDanger/index.vue | 5 +- ruoyi-ui/src/views/ehs/ehsMaterial/index.vue | 47 +++- .../src/views/ehs/ehsMaterial/indexAll.vue | 6 +- .../src/views/ehs/ehsNoticeMessage/index.vue | 4 +- .../views/ehs/ehsNoticeMessage/indexDept.vue | 9 +- ruoyi-ui/src/views/index.vue | 56 ++-- 20 files changed, 565 insertions(+), 103 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsHiddenDangerController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsHiddenDangerController.java index d806e79..de7f0c1 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsHiddenDangerController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsHiddenDangerController.java @@ -179,7 +179,10 @@ public class EhsHiddenDangerController extends BaseController { //获取临期或超时的隐患id,比较本人的最后一条,如果不一样就插入一条,如果一样就不插入,新插入的是未读 //如果点检首页弹窗的连接,就设置为已读,并转跳的隐患页面,并查询出所有临期或超时的隐患 - EhsHiddenDanger ehsHiddenDanger = ehsHiddenDangerService.selectOverTimeId(new EhsHiddenDanger()); + EhsHiddenDanger hdQuery = new EhsHiddenDanger(); + hdQuery.setDeptId(SecurityUtils.getDeptId()); + hdQuery.setOverTime(10); + EhsHiddenDanger ehsHiddenDanger = ehsHiddenDangerService.selectOverTimeId(hdQuery); EhsMyMessage ehsMyMessage = new EhsMyMessage(); ehsMyMessage.setMyMessageType("0"); ehsMyMessage.setMyUserId(SecurityUtils.getUserId()); @@ -202,12 +205,8 @@ public class EhsHiddenDangerController extends BaseController } } }else{//两者一致 - if(msg.getMyMessageState().equals("N")) { - return success(msg); - }else{ - msg.setMyMessageDesc(""); - return success(msg); - } + msg.setMyMessageDesc(""); + return success(msg); } } } @@ -215,7 +214,7 @@ public class EhsHiddenDangerController extends BaseController EhsMyMessage msgNew = new EhsMyMessage(); msgNew.setMyUserId(SecurityUtils.getUserId()); msgNew.setMyMessageType("0"); - msgNew.setMyMessageDesc("您有新的将要逾期或已逾期的记录,请及及时处理!"); + msgNew.setMyMessageDesc("您有新的将要逾期或已逾期的记录!"); msgNew.setMyMessageKey(ehsHiddenDanger.getOverTimeId()); msgNew.setMyMessageState("N"); ehsMyMessageService.save(msgNew); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsMyMessageController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsMyMessageController.java index 73023b9..1197477 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsMyMessageController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsMyMessageController.java @@ -4,9 +4,18 @@ import java.util.List; import java.util.Arrays; import javax.servlet.http.HttpServletResponse; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.core.domain.entity.SysDictType; +import com.ruoyi.common.utils.DictUtils; import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.ehsHiddenDanger.domain.EhsHiddenDanger; +import com.ruoyi.ehsMaterial.domain.EhsMaterial; +import com.ruoyi.ehsMaterial.service.IEhsMaterialService; import com.ruoyi.ehsNoticeMessage.domain.EhsNoticeMessage; import com.ruoyi.ehsNoticeMessage.service.IEhsNoticeMessageService; +import com.ruoyi.system.service.ISysDictDataService; +import com.ruoyi.system.service.ISysDictTypeService; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -43,6 +52,10 @@ public class EhsMyMessageController extends BaseController private IEhsMyMessageService ehsMyMessageService; @Autowired private IEhsNoticeMessageService ehsNoticeMessageService; + @Autowired + private IEhsMaterialService ehsMaterialService; + @Autowired + private ISysDictDataService dictDataService; /** * 查询我的的消息列表 */ @@ -113,23 +126,34 @@ public class EhsMyMessageController extends BaseController { return toAjax(ehsMyMessageService.removeByIds(Arrays.asList(myMessageIds))); } + + /** + * 获取待处理货待阅读的消息 + * @return + */ @GetMapping("/getUnread") public AjaxResult getUnread() { AjaxResult ajr = new AjaxResult(); - EhsMyMessage ehsMyMessage = new EhsMyMessage(); - ehsMyMessage.setMyMessageType("0"); - ehsMyMessage.setMyUserId(SecurityUtils.getUserId()); - EhsMyMessage msg = ehsMyMessageService.selectEhsMyMessageByMyMessageMax(ehsMyMessage); - if(msg == null){ - ajr.put("msgHD","0"); + //判断角色,只有局端和乡镇隐患管理员角色才计算 + if(SecurityUtils.hasRole("HDDept") ||SecurityUtils.hasRole("HDAdmin")) { + EhsMyMessage ehsMyMessage = new EhsMyMessage(); + ehsMyMessage.setMyMessageType("0"); + ehsMyMessage.setMyUserId(SecurityUtils.getUserId()); + EhsMyMessage msg = ehsMyMessageService.selectEhsMyMessageByMyMessageMax(ehsMyMessage); + if (msg == null) { + ajr.put("msgHD", "0"); + } else { + int mCount = (msg.getMyMessageKey().split(",")).length; + ajr.put("msgHD", mCount); + /*if (msg.getMyMessageState().equals("N")) + ajr.put("msgHD", "1"); + else + ajr.put("msgHD", "0");*/ + } }else{ - if(msg.getMyMessageState().equals("N")) - ajr.put("msgHD","1"); - else - ajr.put("msgHD","0"); + ajr.put("msgHD", "0"); } - //分析是否有本人的未读消息通知 //消息通知的每一记录,我的消息都应该有一条记录,如果没有,说明未读,并向我的消息插入一条记录,并设置为未读 //消息通知模块点击阅读按钮后,需要同时修改我的消息的已读标志 @@ -137,7 +161,7 @@ public class EhsMyMessageController extends BaseController EhsMyMessage myMsg = new EhsMyMessage(); myMsg.setNoticeDeptId(SecurityUtils.getDeptId()); myMsg.setNoticeStatus("1"); - myMsg.setNoticeMesgType(1L); + myMsg.setNoticeMesgType(0L); myMsg.setMyMessageType("1"); myMsg.setMyUserId(SecurityUtils.getUserId()); List list = ehsMyMessageService.selectUnReadNotice(myMsg); @@ -154,6 +178,149 @@ public class EhsMyMessageController extends BaseController msgQuery.setMyUserId(SecurityUtils.getUserId()); Long msgCount = ehsMyMessageService.msgCount(msgQuery); ajr.put("msg",msgCount.toString()); + ///////////////////////// 物资消息 + if(SecurityUtils.hasRole("store") ) { + for (int i = 1; i <= 4; i++) { + EhsMyMessage myMMsg = buildMaterialMsg(Long.parseLong(String.valueOf(i))); + int mCount = 0; + if (myMMsg != null && StringUtils.isNotEmpty(myMMsg.getMyMessageKey())) { + mCount = (myMMsg.getMyMessageKey().split(",")).length; + } + switch (i) { + case 1: + ajr.put("msgMaterial1", mCount); + break; + case 2: + ajr.put("msgMaterial2", mCount); + break; + case 3: + ajr.put("msgMaterial3", mCount); + break; + case 4: + ajr.put("msgMaterial4", mCount); + break; + } + } + } return ajr; } + @GetMapping("/setReadByHD") + public AjaxResult setReadByHD() + { + EhsMyMessage msgQuery = new EhsMyMessage(); + msgQuery.setMyMessageState("Y"); + msgQuery.setMyUserId(SecurityUtils.getUserId()); + return toAjax(ehsMyMessageService.updateHDbyKeyUserId(msgQuery)); + } + + /** + * 待处理出库消息 + * @return + */ + @GetMapping("/getSendQuantity/{classFirst}") + public AjaxResult getSendQuantity(@PathVariable Long classFirst) + { + return success(buildMaterialMsg(classFirst)); + } + private EhsMyMessage buildMaterialMsg(Long classFirst){ + EhsMaterial ehsMaterial = new EhsMaterial(); + if(classFirst!=0) + ehsMaterial.setClassFirst(classFirst); + String myMsgType ="m"+classFirst.toString(); + ehsMaterial.setIsSendQuantity(1); + List list = ehsMaterialService.selectEhsMaterialList(ehsMaterial); + String[] MaterialIds = list.stream().map(item -> item.getMaterialId().toString()).toArray(String[]::new); + String strmIds = StringUtils.join(MaterialIds,","); + EhsMyMessage ehsMyMessage = new EhsMyMessage(); + ehsMyMessage.setMyMessageType(myMsgType); + ehsMyMessage.setMyUserId(SecurityUtils.getUserId()); + EhsMyMessage msg = ehsMyMessageService.selectEhsMyMessageByMyMessageMax(ehsMyMessage); + boolean isNew =false; + if(msg==null ){ + if(StringUtils.isNotEmpty(strmIds)) + isNew = true; + else + isNew = false; + }else{ + if(StringUtils.isNotEmpty(strmIds)) { + if(!strmIds.equals(msg.getMyMessageKey())) {//两者不一致 + String[] newIds = strmIds.split(","); + String oldIds = "," + msg.getMyMessageKey() + ","; + for (String id : newIds) { + if (oldIds.indexOf("," + id + ",") == -1) {//不包含,表示有新的id + isNew = true; + break; + } + } + }else{//两者一致 + msg.setMyMessageDesc(""); + return msg; + } + } + } + if (isNew) {//有新的id,生成一个新记录 + EhsMyMessage msgNew = new EhsMyMessage(); + msgNew.setMyUserId(SecurityUtils.getUserId()); + msgNew.setMyMessageType(myMsgType); + String strMaterial = DictUtils.getDictLabel("material_class_fast",classFirst.toString()); + msgNew.setMyMessageDesc(strMaterial+"有" +list.size()+"条待处理出库!"); + msgNew.setMyMessageKey(strmIds); + msgNew.setMyMessageState("N"); + ehsMyMessageService.save(msgNew); + return msgNew; + } + ehsMyMessage.setMyMessageDesc(""); + return ehsMyMessage; + } + @GetMapping("/setMaterial/{myMessageId}") + public AjaxResult setMaterial(@PathVariable Long myMessageId) + { + EhsMyMessage msgQuery = new EhsMyMessage(); + msgQuery.setMyMessageState("Y"); + msgQuery.setMyMessageId(myMessageId); + return toAjax(ehsMyMessageService.updateById(msgQuery)); + } + + /** + * 获取待阅读消息提醒 + * @return + */ + @GetMapping("/getNoticeMsg") + public AjaxResult getNoticeMsg(){ + EhsMyMessage myMsg = new EhsMyMessage(); + myMsg.setNoticeDeptId(SecurityUtils.getDeptId()); + myMsg.setNoticeStatus("1"); + myMsg.setNoticeMesgType(0L); + myMsg.setMyMessageType("1"); + myMsg.setMyUserId(SecurityUtils.getUserId()); + List list = ehsMyMessageService.selectUnReadNotice(myMsg); + Long[] ids =null; + EhsMyMessage returnMymsg = new EhsMyMessage(); + if(!list.isEmpty()){//表示有新增的消息通知 + for(EhsMyMessage emsg :list){ + EhsMyMessage msgNew = new EhsMyMessage(); + msgNew.setMyMessageKey(emsg.getMyMessageId().toString()); + ehsMyMessageService.saveMyMessage(msgNew); + } + ids = list.stream().map(item->item.getMyMessageId()).toArray(Long[]::new); + returnMymsg.setMyMessageDesc("您有"+ids.length+"条新的消息通知未阅读!"); + }else{//没有新增的消息通知, + returnMymsg.setMyMessageDesc(""); + } + //计算全部未阅读的消息 + EhsMyMessage msgQuery = new EhsMyMessage(); + msgQuery.setMyMessageType("1"); + msgQuery.setMyMessageState("N"); + msgQuery.setMyUserId(SecurityUtils.getUserId()); + Long msgCount = ehsMyMessageService.msgCount(msgQuery); + ids = new Long[Integer.parseInt(msgCount.toString())]; + //需要根据现有未阅读消息通知数量生成一个数组,返回前端,以便前端根据这个数组计算未阅读数量 + for(int i=0;i { public EhsMyMessage selectEhsMyMessageByMyMessageMax(EhsMyMessage ehsMyMessage); public List selectUnReadNotice(EhsMyMessage ehsMyMessage); + public int updatebyKeyUserId(EhsMyMessage ehsMyMessage); + public int updateHDbyKeyUserId(EhsMyMessage ehsMyMessage); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsMyMessage/service/IEhsMyMessageService.java b/ruoyi-system/src/main/java/com/ruoyi/ehsMyMessage/service/IEhsMyMessageService.java index 9bd7263..c3a4f1d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsMyMessage/service/IEhsMyMessageService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsMyMessage/service/IEhsMyMessageService.java @@ -31,4 +31,6 @@ public interface IEhsMyMessageService extends IService { public Long msgCount(EhsMyMessage query); public List selectUnReadNotice(EhsMyMessage ehsMyMessage); public boolean saveMyMessage(EhsMyMessage msgNew); + public int updatebyKeyUserId(EhsMyMessage ehsMyMessage); + public int updateHDbyKeyUserId(EhsMyMessage ehsMyMessage); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsMyMessage/service/impl/EhsMyMessageServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/ehsMyMessage/service/impl/EhsMyMessageServiceImpl.java index 7951ea3..5e98e20 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsMyMessage/service/impl/EhsMyMessageServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsMyMessage/service/impl/EhsMyMessageServiceImpl.java @@ -77,7 +77,18 @@ public class EhsMyMessageServiceImpl extends ServiceImpl selectEhsNoticeMessageList(EhsNoticeMessage ehsNoticeMessage) { + ehsNoticeMessage.setMyUserId(SecurityUtils.getUserId()); return ehsNoticeMessageMapper.selectEhsNoticeMessageList(ehsNoticeMessage); } @Override diff --git a/ruoyi-system/src/main/resources/mapper/ehs/EhsMaterialMapper.xml b/ruoyi-system/src/main/resources/mapper/ehs/EhsMaterialMapper.xml index 2ffb238..f56d740 100644 --- a/ruoyi-system/src/main/resources/mapper/ehs/EhsMaterialMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/ehs/EhsMaterialMapper.xml @@ -24,6 +24,7 @@ + @@ -48,6 +49,8 @@ and reserve_location like concat('%', #{reserveLocation}, '%') and Manager_person like concat('%', #{managerPerson}, '%') and tel like concat('%', #{tel}, '%') + and a.send_quantity is null + and a.send_quantity is not null diff --git a/ruoyi-system/src/main/resources/mapper/ehs/EhsMyMessageMapper.xml b/ruoyi-system/src/main/resources/mapper/ehs/EhsMyMessageMapper.xml index ef0dda0..c52debf 100644 --- a/ruoyi-system/src/main/resources/mapper/ehs/EhsMyMessageMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/ehs/EhsMyMessageMapper.xml @@ -84,5 +84,14 @@ ) - + + update ehs_my_message + set my_message_state = #{myMessageState} + where my_message_key = #{myMessageKey} and my_user_id = #{myUserId} + + + update ehs_my_message + set my_message_state = #{myMessageState} + where my_message_type='0' and my_user_id = #{myUserId} + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/ehs/EhsNoticeMessageMapper.xml b/ruoyi-system/src/main/resources/mapper/ehs/EhsNoticeMessageMapper.xml index e074425..93cace6 100644 --- a/ruoyi-system/src/main/resources/mapper/ehs/EhsNoticeMessageMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/ehs/EhsNoticeMessageMapper.xml @@ -33,6 +33,9 @@ + + + @@ -48,9 +51,12 @@ (select f.original_name from ehs_notice_message_file f where m.notice_message_id = f.notice_message_id and f.dept_ID =#{fileDeptId}) original_name, (select f.file_size from ehs_notice_message_file f where m.notice_message_id = f.notice_message_id and f.dept_ID =#{fileDeptId}) file_size, (select f.dept_id from ehs_notice_message_file f where m.notice_message_id = f.notice_message_id and f.dept_ID =#{fileDeptId}) file_dept_id + ,mym.my_message_id,mym.my_message_state from ehs_notice_message m left join sys_user e on e.user_id = m.CREATE_USER_ID left join sys_dept d on m.dept_id=d.dept_id and d.parent_id!=0 + left join ehs_my_message mym on m.notice_message_id = my_message_key + and my_user_id = #{myUserId} and m.title like '%${title}%' and m.display_content = #{displayContent} diff --git a/ruoyi-ui/src/api/ehs/ehsMyMessage.js b/ruoyi-ui/src/api/ehs/ehsMyMessage.js index 5fceaa4..035f5bc 100644 --- a/ruoyi-ui/src/api/ehs/ehsMyMessage.js +++ b/ruoyi-ui/src/api/ehs/ehsMyMessage.js @@ -50,3 +50,32 @@ export function getUnread() { method: 'get' }) } +//设置隐患消息已读取 +export function setReadByHD() { + return request({ + url: '/ehsMyMessage/ehsMyMessage/setReadByHD', + method: 'get' + }) +} +//查询待出库 +export function getSendQuantity(classFirst) { + return request({ + url: '/ehsMyMessage/ehsMyMessage/getSendQuantity/'+classFirst, + method: 'get' + }) +} + +//设置物资消息已读 +export function setMaterial(myMessageId) { + return request({ + url: '/ehsMyMessage/ehsMyMessage/setMaterial/'+myMessageId, + method: 'get' + }) +} +//查询消息通信新消息和消息总数 +export function getNoticeMsg() { + return request({ + url: '/ehsMyMessage/ehsMyMessage/getNoticeMsg', + method: 'get' + }) +} diff --git a/ruoyi-ui/src/layout/components/Navbar.vue b/ruoyi-ui/src/layout/components/Navbar.vue index a31bd07..6fb03c4 100644 --- a/ruoyi-ui/src/layout/components/Navbar.vue +++ b/ruoyi-ui/src/layout/components/Navbar.vue @@ -7,7 +7,7 @@
- - + + + +
- - 隐患消息 - + + 通用应急救援装备 + + + 防汛抗旱装备 + + + 森林防灭火装备 + + + 救灾物资 + + + 隐患消息 消息通知 - + @@ -50,7 +63,7 @@
- +
@@ -69,7 +82,7 @@