Commit 53edf4f5 by lijingjing

通知消息发送调整;

parent 04371dfb
......@@ -108,6 +108,8 @@ public interface IEntrustSampleItemService extends IBaseService<EntrustSampleIte
List<EntrustSampleItem> getListByEntrustId(Long entrustId);
List<Long> getTesterIdListByEntrustId(Long entrustId);
boolean revokeRemovedItem(Long[] ids);
Page<EntrustSampleItemVO> getItemFillProgressQuery(Page<EntrustSampleItemVO> page, EntrustSampleItemVO itemVO);
......
......@@ -1327,6 +1327,12 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
}
@Override
public List<Long> getTesterIdListByEntrustId(Long entrustId) {
List<EntrustSampleItem> sampleItems = getListByEntrustId(entrustId);
return CollectionUtils.isEmpty(sampleItems) ? null : sampleItems.stream().map(EntrustSampleItem::getTesterId).collect(Collectors.toList());
}
@Override
public boolean revokeRemovedItem(Long[] ids) {
if (null == ids) {
throw new PatznException("检测项目编号为空");
......
......@@ -391,7 +391,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
entrust.setFlowStatus(EntrustFlowEnum.CHECK.getName());
if (update(entrust, Condition.create().in("id", ids))) {
entrustRecordService.record(ids, EntrustStatusEnum.DRAFT.getDisplay(), EntrustStatusEnum.CHECK.getDisplay(), 0, account, "提交至委托审核");
lmsMsgService.sendMsg("/hmhj/entrust_manage/entrust_review", "有委托从委托登记提交过来,请及时审核", "新的委托审核任务!", account, userInfoService.getUserIds(MessageUserEnum.GROUP_USER, null));
lmsMsgService.sendMsg("/hmhj/entrust_manage/entrust_review", "有委托从委托登记提交过来,请及时审核", "新的委托审核任务!", account, null);
}
return true;
}
......@@ -408,7 +408,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
entrust.setProgress(EntrustStatusEnum.OUT_INPUT);
if (update(entrust, Condition.create().in("id", ids))) {
entrustRecordService.record(ids, EntrustStatusEnum.OUT_DRAFT.getDisplay(), EntrustStatusEnum.OUT_INPUT.getDisplay(), 0, account, "提交至外委数据录入");
lmsMsgService.sendMsg("/hmhj/accept_manage/sub_input", "有外委登记提交过来,请及时填写外委数据", "新的委托外委数据录入任务!", account, userInfoService.getUserIds(MessageUserEnum.GROUP_USER, null));
lmsMsgService.sendMsg("/hmhj/accept_manage/sub_input", "有外委登记提交过来,请及时填写外委数据", "新的委托外委数据录入任务!", account, null);
}
return true;
}
......@@ -422,6 +422,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
RestAssert.fail(ids.length != count, "请选择退回委托审核的委托");
List<Entrust> entrustList = getBatchIds(Arrays.asList(ids));
boolean hasSendMessage = false;
List<Long> userIds = new ArrayList<>();
for (Entrust e : entrustList) {
if (isCanIntoNextNode(e)) {
rejectToPrevNode(e, reason, account);
......@@ -432,10 +433,11 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
e.setFlowStatus(EntrustFlowEnum.DRAFT.getName());
updateById(e);
entrustRecordService.record(new Long[]{e.getId()}, EntrustStatusEnum.CHECK.getDisplay(), EntrustStatusEnum.DRAFT.getDisplay(), 1, account, reason);
userIds.add(e.getUid());
}
}
if (!hasSendMessage) {
lmsMsgService.sendMsg("/hmhj/entrust_manage/entrust_register", "有委托从委托审核驳回,请及时查看退回原因并处理", "新的委托审核退回任务!", account, userInfoService.getUserIds(MessageUserEnum.GROUP_USER, null));
lmsMsgService.sendMsg("/hmhj/entrust_manage/entrust_register", "有委托从委托审核驳回,请及时查看退回原因并处理", "新的委托审核退回任务!", account, userIds);
}
return true;
......@@ -448,6 +450,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
RestAssert.fail(ids.length != count, "请选择委托审核的委托");
List<Entrust> entrustList = getBatchIds(Arrays.asList(ids));
boolean hasSendMessage = false;
List<Long> userIds = new ArrayList<>();
for (Entrust e : entrustList) {
// 若存在路径,根据状态路径处理数据
if (isCanIntoNextNode(e)) {
......@@ -460,10 +463,15 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
updateById(e);
entrustSampleService.updateSampleCodeByEntrustId(e.getId(), 2);
entrustRecordService.record(new Long[]{e.getId()}, EntrustStatusEnum.CHECK.getDisplay(), EntrustStatusEnum.MAKE.getDisplay(), 0, account, "提交至样品待制备");
List<Long> uidList = userInfoService.getUserIdsByGroupName(e.getTestSide());
if (CollectionUtils.isNotEmpty(uidList)) {
userIds.addAll(uidList);
}
}
if (!hasSendMessage) {
lmsMsgService.sendMsg("/hmhj/sample_manage/sample_prepare", "有委托审核通过,请及时进行样品的制备", "新的样品制备任务!", account, userInfoService.getUserIds(MessageUserEnum.GROUP_USER, null));
}
userIds = userIds.stream().distinct().collect(Collectors.toList());
if (!hasSendMessage && CollectionUtils.isNotEmpty(userIds)) {
lmsMsgService.sendMsg("/hmhj/sample_manage/sample_prepare", "有委托审核通过,请及时进行样品的制备", "新的样品制备任务!", account, userIds);
}
return true;
}
......@@ -475,6 +483,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
RestAssert.fail(ids.length != count, "请选择委托登记的委托");
List<Entrust> entrustList = getBatchIds(Arrays.asList(ids));
boolean hasSendMessage = false;
List<Long> userIds = new ArrayList<>();
for (Entrust e : entrustList) {
// 若存在路径,根据状态路径处理数据
if (isCanIntoNextNode(e)) {
......@@ -488,11 +497,16 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
entrustRecordService.record(new Long[]{e.getId()}, EntrustStatusEnum.DRAFT.getDisplay(), EntrustStatusEnum.MAKE.getDisplay(), 0, account, "委托登记提交至样品待制备");
// 此处需要批量更新样品编码,根据级别更新
entrustSampleService.updateSampleCodeByEntrustId(e.getId(), 1);
List<Long> uidList = userInfoService.getUserIdsByGroupName(e.getTestSide());
if (CollectionUtils.isNotEmpty(uidList)) {
userIds.addAll(uidList);
}
}
}
if (!hasSendMessage) {
lmsMsgService.sendMsg("/hmhj/sample_manage/sample_prepare", "有委托登记提交至样品待制备,请及时进行样品的制备", "新的样品制备任务!", account, userInfoService.getUserIds(MessageUserEnum.GROUP_USER, null));
userIds = userIds.stream().distinct().collect(Collectors.toList());
if (!hasSendMessage && CollectionUtils.isNotEmpty(userIds)) {
lmsMsgService.sendMsg("/hmhj/sample_manage/sample_prepare", "有委托登记提交至样品待制备,请及时进行样品的制备", "新的样品制备任务!", account, userIds);
}
return true;
......@@ -903,12 +917,15 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
boolean isUpdateSampleInfo = nextFlowValue < 9 || nextFlowValue > 12;
// 若为特殊需求,必须要走评审
String uri = "";
List<Long> sendUidList = new ArrayList<>();
if (isSpecAsk || nextStatus == EntrustStatusEnum.CHECK) {
uri = "/hmhj/entrust_manage/entrust_review";
} else if (nextStatus == EntrustStatusEnum.MAKE) {
uri = "/hmhj/sample_manage/sample_prepare";
sendUidList = userInfoService.getUserIdsByGroupName(entrust.getTestSide());
} else if (nextStatus == EntrustStatusEnum.TEST) {
uri = "/hmhj/accept_manage/input";
sendUidList = entrustSampleItemService.getTesterIdListByEntrustId(entrust.getId());
} else if (nextStatus == EntrustStatusEnum.OUT_INPUT) {
uri = "/hmhj/accept_manage/sub_input";
} else if (nextStatus == EntrustStatusEnum.QUALITY_CHECK) {
......@@ -924,23 +941,13 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
entrust.setProgress(nextStatus);
entrust.setFlowStatus(nextFlowStatus.getName());
updateById(entrust);
//
String remark = "提交至" + nextFlowStatus.getDisplay(),
title = String.format("新的%s任务!", nextFlowStatus.getDisplay()),
content = String.format("有%s提交过来,请及时%s", EntrustFlowEnum.convert(flowStatus).getDisplay(), nextFlowStatus.getDisplay());
entrustRecordService.record(new Long[]{entrust.getId()}, status.getDisplay(), nextStatus.getDisplay(), 0, account, remark);
if (StringUtils.isNotBlank(uri)) {
List<Long> userIds = userInfoService.getUserIds(MessageUserEnum.GROUP_USER, null);
// 若为数据录入,消息具体到检测人
if (nextFlowStatus == EntrustFlowEnum.TEST) {
List<EntrustSampleItem> sampleItems = entrustSampleItemService.getListByEntrustId(entrust.getId());
if (CollectionUtils.isEmpty(sampleItems)) {
// 为空不发消息,直接返回
return true;
}
userIds = sampleItems.stream().map(EntrustSampleItem::getTesterId).collect(Collectors.toList());
}
lmsMsgService.sendMsg(uri, content, title, account, userIds);
lmsMsgService.sendMsg(uri, content, title, account, sendUidList);
}
return true;
}
......@@ -969,12 +976,15 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
// 当前委托状态
EntrustStatusEnum status = entrust.getStatus();
String uri = "";
List<Long> sendUidList = new ArrayList<>();
if (prevStatus == EntrustStatusEnum.DRAFT) {
uri = "/hmhj/entrust_manage/entrust_register";
sendUidList.add(entrust.getUid());
} else if (prevStatus == EntrustStatusEnum.CHECK) {
} else if (prevStatus == EntrustStatusEnum.MAKE) {
uri = "/hmhj/sample_manage/sample_prepare";
sendUidList = userInfoService.getUserIdsByGroupName(entrust.getTestSide());
} else if (prevStatus == EntrustStatusEnum.OUT_INPUT) {
} else if (prevStatus == EntrustStatusEnum.QUALITY_CHECK) {
......@@ -993,7 +1003,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
content = String.format("有%s驳回过来,请及时%s", EntrustFlowEnum.convert(flowStatus).getDisplay(), prevFlowStatus.getDisplay());
entrustRecordService.record(new Long[]{entrust.getId()}, status.getDisplay(), prevStatus.getDisplay(), 1, account, reason);
if (StringUtils.isNotBlank(uri)) {
lmsMsgService.sendMsg(uri, content, title, account, userInfoService.getUserIds(MessageUserEnum.GROUP_USER, null));
lmsMsgService.sendMsg(uri, content, title, account, sendUidList);
}
return true;
}
......@@ -1016,7 +1026,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
}
entrust.setId(null);
entrust.setCode(null).setStatus(EntrustStatusEnum.DRAFT).setProgress(EntrustStatusEnum.DRAFT)
.setFlowStatus(EntrustFlowEnum.DRAFT.getName()).setEntrustTime(new Date()).setExpectSendTime(new Date())
.setFlowStatus(EntrustFlowEnum.DRAFT.getName()).setEntrustTime(new Date()).setExpectSendTime(new Date()).setReceiveTime(new Date())
.setUid(account.getUserId()).setCtime(new Date()).setLid(null).setLtime(null).setOrgId(null).setSampleName(sampleList.get(0).getName());
// 保存委托信息
saveEntrust(entrust);
......@@ -1084,6 +1094,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
int count = super.count(Condition.create().in("id", ids).eq("status", EntrustStatusEnum.MAKE));
RestAssert.fail(ids.length != count, "请选择要退回至登记的委托");
List<Entrust> entrustList = getBatchIds(Arrays.asList(ids));
List<Long> sendUidList = new ArrayList<>();
for (Entrust e : entrustList) {
e.setStatus(EntrustStatusEnum.DRAFT);
e.setProgress(EntrustStatusEnum.BACK_MAKE);
......@@ -1091,6 +1102,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
e.setFlowStatus(EntrustFlowEnum.DRAFT.getName());
updateById(e);
entrustRecordService.record(new Long[]{e.getId()}, EntrustStatusEnum.MAKE.getDisplay(), EntrustStatusEnum.DRAFT.getDisplay(), 1, account, reason);
sendUidList.add(e.getUid());
// 更新样品状态
EntrustSample entrustSample = new EntrustSample();
entrustSample.setStatus(EntrustSampleStatusEnum.DRAFT);
......@@ -1104,7 +1116,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
entrustSampleItemService.update(entrustSampleItem, Condition.create().in("entrust_sample_id", sampleIds));
}
}
lmsMsgService.sendMsg("/hmhj/entrust_manage/entrust_register", "有委托从样品制备退回,请及时查看退回原因并处理", "新的样品制备退回任务!", account, userInfoService.getUserIds(MessageUserEnum.GROUP_USER, null));
lmsMsgService.sendMsg("/hmhj/entrust_manage/entrust_register", "有委托从样品制备退回,请及时查看退回原因并处理", "新的样品制备退回任务!", account, sendUidList);
return true;
}
......@@ -1115,6 +1127,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
int count = super.count(Condition.create().in("id", ids).eq("status", EntrustStatusEnum.TEST));
RestAssert.fail(ids.length != count, "请选择要退回至登记的委托");
List<Entrust> entrustList = getBatchIds(Arrays.asList(ids));
List<Long> sendUidList = new ArrayList<>();
for (Entrust e : entrustList) {
e.setStatus(EntrustStatusEnum.DRAFT);
e.setProgress(EntrustStatusEnum.BACK_RECEIVE);
......@@ -1122,6 +1135,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
e.setFlowStatus(EntrustFlowEnum.DRAFT.getName());
updateById(e);
entrustRecordService.record(new Long[]{e.getId()}, EntrustStatusEnum.TEST.getDisplay(), EntrustStatusEnum.DRAFT.getDisplay(), 1, account, reason);
sendUidList.add(e.getUid());
// 更新样品状态
EntrustSample entrustSample = new EntrustSample();
entrustSample.setStatus(EntrustSampleStatusEnum.DRAFT);
......@@ -1138,7 +1152,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
// 删除委托下样品备样
entrustSampleBackupService.remove(Condition.create().eq("entrust_id", e.getId()));
}
lmsMsgService.sendMsg("/hmhj/entrust_manage/entrust_register", "有委托从样品接收退回,请及时查看退回原因并处理", "新的样品接收退回任务!", account, userInfoService.getUserIds(MessageUserEnum.GROUP_USER, null));
lmsMsgService.sendMsg("/hmhj/entrust_manage/entrust_register", "有委托从样品接收退回,请及时查看退回原因并处理", "新的样品接收退回任务!", account, sendUidList);
return true;
}
......@@ -1466,6 +1480,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
RestAssert.fail(null == ids || 0 == ids.length, "请选择要提交的委托!");
List<Entrust> entrustList = getBatchIds(Arrays.asList(ids));
List<Long> specialIds = new ArrayList<>(), normalIds = new ArrayList<>();
List<Long> sendUserIdList = new ArrayList<>();
for (Entrust entrust : entrustList) {
if ("是".equals(entrust.getSpecialAsk())) {
specialIds.add(entrust.getId());
......@@ -1475,6 +1490,10 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
submitToNextNode(entrust, account);
} else {
normalIds.add(entrust.getId());
List<Long> userIdList = userInfoService.getUserIdsByGroupName(entrust.getTestSide());
if (CollectionUtils.isNotEmpty(userIdList)) {
sendUserIdList.addAll(userIdList);
}
}
}
}
......@@ -1485,7 +1504,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
updateModel.setFlowStatus(EntrustFlowEnum.CHECK.getName());
update(updateModel, Condition.create().in("id", specialIds));
entrustRecordService.record(specialIds, EntrustStatusEnum.DRAFT.getDisplay(), EntrustStatusEnum.CHECK.getDisplay(), 0, account, "提交至委托审核");
lmsMsgService.sendMsg("/hmhj/entrust_manage/entrust_review", "有委托从委托登记提交过来,请及时审核", "新的委托审核任务!", account, userInfoService.getUserIds(MessageUserEnum.GROUP_USER, null));
lmsMsgService.sendMsg("/hmhj/entrust_manage/entrust_review", "有委托从委托登记提交过来,请及时审核", "新的委托审核任务!", account, null);
}
if (CollectionUtils.isNotEmpty(normalIds)) {
......@@ -1498,7 +1517,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
entrustSampleService.updateSampleCodeByEntrustId(entrustId, HmConst.TWO);
});
entrustRecordService.record(normalIds, EntrustStatusEnum.CHECK.getDisplay(), EntrustStatusEnum.MAKE.getDisplay(), 0, account, "提交至样品待制备");
lmsMsgService.sendMsg("/hmhj/sample_manage/sample_prepare", "有委托审核通过,请及时进行样品的制备", "新的样品制备任务!", account, userInfoService.getUserIds(MessageUserEnum.GROUP_USER, null));
lmsMsgService.sendMsg("/hmhj/sample_manage/sample_prepare", "有委托审核通过,请及时进行样品的制备", "新的样品制备任务!", account, sendUserIdList);
}
return true;
}
......
......@@ -11,10 +11,10 @@ import com.patzn.cloud.feign.lims.base.client.LmsUserGroupClient;
import com.patzn.cloud.service.base.entity.SysOrg;
import com.patzn.cloud.service.base.entity.SysUser;
import com.patzn.cloud.service.hmhj.entity.Entrust;
import com.patzn.cloud.service.hmhj.enums.MessageUserEnum;
import com.patzn.cloud.service.lims.base.entity.LmsUserGroup;
import com.patzn.cloud.service.lims.base.vo.GroupUserVO;
import com.patzn.cloud.service.lims.common.consts.Symbol;
import com.patzn.cloud.service.lims.common.service.ILmsMsgService;
import com.patzn.cloud.service.lims.hmhj.service.IEntrustService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -51,6 +51,9 @@ public class UserInfoServiceImpl {
@Autowired
private SysRoleClient sysRoleClient;
@Autowired
private ILmsMsgService lmsMsgService;
public List<LmsUserGroup> getGroupList(Long userId) {
if (null == userId) {
return OTHER_GROUP_LIST;
......@@ -97,6 +100,19 @@ public class UserInfoServiceImpl {
return Stream.of(userIdStr.split(Symbol.COMMA)).map(Long::valueOf).distinct().collect(Collectors.toList());
}
public List<Long> getUserIdsByGroupName(String groupName) {
if (StringUtils.isBlank(groupName)) {
return null;
}
Account account = LoginHelper.getAccount();
List<GroupUserVO> groupUserList = lmsUserGroupClient.getGroupUserIdsList(account.getCompanyId()).serviceData();
if (CollectionUtils.isEmpty(groupUserList)) {
return null;
}
String userIdStr = groupUserList.stream().filter(t -> t.getGroupName().equals(groupName)).map(GroupUserVO::getUserIds).collect(Collectors.joining(Symbol.COMMA));
return Stream.of(userIdStr.split(Symbol.COMMA)).map(Long::valueOf).distinct().collect(Collectors.toList());
}
public boolean isGroupLeader(Long entrustId, Account account) {
if (null == entrustId) {
return false;
......@@ -139,16 +155,4 @@ public class UserInfoServiceImpl {
return getUserById(LoginHelper.getAccount().getUserId());
}
public List<Long> getUserIds(MessageUserEnum messageUserEnum, Long someoneId) {
List<Long> userIdList = new ArrayList<>();
if (MessageUserEnum.CURRENT == messageUserEnum) {
userIdList.add(LoginHelper.getAccount().getUserId());
} else if (MessageUserEnum.SOMEONE == messageUserEnum) {
userIdList.add(someoneId);
} else {
userIdList.addAll(getGroupUserIds(null));
}
return userIdList;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment