|
|
@ -4,9 +4,18 @@ import java.util.List;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
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.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.domain.EhsNoticeMessage;
|
|
|
|
import com.ruoyi.ehsNoticeMessage.service.IEhsNoticeMessageService;
|
|
|
|
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.security.access.prepost.PreAuthorize;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
@ -43,6 +52,10 @@ public class EhsMyMessageController extends BaseController
|
|
|
|
private IEhsMyMessageService ehsMyMessageService;
|
|
|
|
private IEhsMyMessageService ehsMyMessageService;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private IEhsNoticeMessageService ehsNoticeMessageService;
|
|
|
|
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 toAjax(ehsMyMessageService.removeByIds(Arrays.asList(myMessageIds)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 获取待处理货待阅读的消息
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
@GetMapping("/getUnread")
|
|
|
|
@GetMapping("/getUnread")
|
|
|
|
public AjaxResult getUnread()
|
|
|
|
public AjaxResult getUnread()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AjaxResult ajr = new AjaxResult();
|
|
|
|
AjaxResult ajr = new AjaxResult();
|
|
|
|
EhsMyMessage ehsMyMessage = new EhsMyMessage();
|
|
|
|
//判断角色,只有局端和乡镇隐患管理员角色才计算
|
|
|
|
ehsMyMessage.setMyMessageType("0");
|
|
|
|
if(SecurityUtils.hasRole("HDDept") ||SecurityUtils.hasRole("HDAdmin")) {
|
|
|
|
ehsMyMessage.setMyUserId(SecurityUtils.getUserId());
|
|
|
|
EhsMyMessage ehsMyMessage = new EhsMyMessage();
|
|
|
|
EhsMyMessage msg = ehsMyMessageService.selectEhsMyMessageByMyMessageMax(ehsMyMessage);
|
|
|
|
ehsMyMessage.setMyMessageType("0");
|
|
|
|
if(msg == null){
|
|
|
|
ehsMyMessage.setMyUserId(SecurityUtils.getUserId());
|
|
|
|
ajr.put("msgHD","0");
|
|
|
|
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{
|
|
|
|
}else{
|
|
|
|
if(msg.getMyMessageState().equals("N"))
|
|
|
|
ajr.put("msgHD", "0");
|
|
|
|
ajr.put("msgHD","1");
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
ajr.put("msgHD","0");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//分析是否有本人的未读消息通知
|
|
|
|
//分析是否有本人的未读消息通知
|
|
|
|
//消息通知的每一记录,我的消息都应该有一条记录,如果没有,说明未读,并向我的消息插入一条记录,并设置为未读
|
|
|
|
//消息通知的每一记录,我的消息都应该有一条记录,如果没有,说明未读,并向我的消息插入一条记录,并设置为未读
|
|
|
|
//消息通知模块点击阅读按钮后,需要同时修改我的消息的已读标志
|
|
|
|
//消息通知模块点击阅读按钮后,需要同时修改我的消息的已读标志
|
|
|
@ -137,7 +161,7 @@ public class EhsMyMessageController extends BaseController
|
|
|
|
EhsMyMessage myMsg = new EhsMyMessage();
|
|
|
|
EhsMyMessage myMsg = new EhsMyMessage();
|
|
|
|
myMsg.setNoticeDeptId(SecurityUtils.getDeptId());
|
|
|
|
myMsg.setNoticeDeptId(SecurityUtils.getDeptId());
|
|
|
|
myMsg.setNoticeStatus("1");
|
|
|
|
myMsg.setNoticeStatus("1");
|
|
|
|
myMsg.setNoticeMesgType(1L);
|
|
|
|
myMsg.setNoticeMesgType(0L);
|
|
|
|
myMsg.setMyMessageType("1");
|
|
|
|
myMsg.setMyMessageType("1");
|
|
|
|
myMsg.setMyUserId(SecurityUtils.getUserId());
|
|
|
|
myMsg.setMyUserId(SecurityUtils.getUserId());
|
|
|
|
List<EhsMyMessage> list = ehsMyMessageService.selectUnReadNotice(myMsg);
|
|
|
|
List<EhsMyMessage> list = ehsMyMessageService.selectUnReadNotice(myMsg);
|
|
|
@ -154,6 +178,149 @@ public class EhsMyMessageController extends BaseController
|
|
|
|
msgQuery.setMyUserId(SecurityUtils.getUserId());
|
|
|
|
msgQuery.setMyUserId(SecurityUtils.getUserId());
|
|
|
|
Long msgCount = ehsMyMessageService.msgCount(msgQuery);
|
|
|
|
Long msgCount = ehsMyMessageService.msgCount(msgQuery);
|
|
|
|
ajr.put("msg",msgCount.toString());
|
|
|
|
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;
|
|
|
|
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<EhsMaterial> 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<EhsMyMessage> 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<msgCount;i++){
|
|
|
|
|
|
|
|
ids[i]=Long.valueOf(i) ;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
returnMymsg.setMyMessageKey(StringUtils.join(ids,","));
|
|
|
|
|
|
|
|
returnMymsg.setMyMessageType("1");
|
|
|
|
|
|
|
|
returnMymsg.setMyMessageState("N");
|
|
|
|
|
|
|
|
return success(returnMymsg);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|