1. 异常取消发送消息内容添加取消原因

2. 异常发送消息提示信息修改
3. 计划异常待办事项发送消息
4. 异常定时器写日志的提示信息修改
5. 设备维修提报发送消息
6. 把StringUtils的格式化消息内容的正则表达式修改
master
赵嘉伟 3 years ago
parent 843b6f01a1
commit 77d0c382e4

@ -155,7 +155,7 @@ public interface AbnormalBillService extends IService<AbnormalBill> {
void batchRepair(SfcDto sfcDto); void batchRepair(SfcDto sfcDto);
/** /**
* * (status)
* @param message * @param message
* @param abnormalBill * @param abnormalBill
* @param abnormalBillDispose * @param abnormalBillDispose

@ -1176,7 +1176,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
if(!StringUtil.isBlank(customFieldByGroup.getMessageNoticeLevel())){ if(!StringUtil.isBlank(customFieldByGroup.getMessageNoticeLevel())){
abnormalMessage.setGrade(Double.parseDouble(customFieldByGroup.getMessageNoticeLevel())); abnormalMessage.setGrade(Double.parseDouble(customFieldByGroup.getMessageNoticeLevel()));
}else{ }else{
throw new BaseException("该用户组没有维护升级的等级,请维护。"); throw new BaseException("该用户组没有维护等级,请维护。");
} }
MessageType messageTypeUp = messageTypeMapper.findMessageTypeByUserGroup(site, abnormalMessage.getUpUserGroup()); MessageType messageTypeUp = messageTypeMapper.findMessageTypeByUserGroup(site, abnormalMessage.getUpUserGroup());
//得到升级的消息类型 //得到升级的消息类型
@ -1207,7 +1207,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
} }
List<String> customFieldByUserId = usrMapper.findCustomFieldByUserId(site, nwaUsers); List<String> customFieldByUserId = usrMapper.findCustomFieldByUserId(site, nwaUsers);
if(customFieldByUserId != null && customFieldByUserId.size() <= 0){ if(customFieldByUserId != null && customFieldByUserId.size() <= 0){
throw new BaseException("消息发送失败,发送的用户组下面的自定义数据没有维护"); throw new BaseException("消息发送失败,发送的用户组下面的用户的自定义数据没有维护");
} }
StringBuilder sendUsers = new StringBuilder(); StringBuilder sendUsers = new StringBuilder();
for (int i = 0; i < Objects.requireNonNull(customFieldByUserId).size(); i++) { for (int i = 0; i < Objects.requireNonNull(customFieldByUserId).size(); i++) {

@ -20,7 +20,10 @@ import com.foreverwin.mesnac.common.model.Message;
import com.foreverwin.mesnac.common.service.MessageService; import com.foreverwin.mesnac.common.service.MessageService;
import com.foreverwin.mesnac.common.util.ActiveMQUtil; import com.foreverwin.mesnac.common.util.ActiveMQUtil;
import com.foreverwin.mesnac.common.util.StringUtil; import com.foreverwin.mesnac.common.util.StringUtil;
import com.foreverwin.mesnac.listener.mapper.UsrMapper;
import com.foreverwin.mesnac.meapi.mapper.MessageTypeMapper;
import com.foreverwin.mesnac.meapi.mapper.UserGroupMapper; import com.foreverwin.mesnac.meapi.mapper.UserGroupMapper;
import com.foreverwin.mesnac.meapi.model.MessageType;
import com.foreverwin.mesnac.meapi.model.NwaUser; import com.foreverwin.mesnac.meapi.model.NwaUser;
import com.foreverwin.mesnac.meapi.model.UserGroup; import com.foreverwin.mesnac.meapi.model.UserGroup;
import com.foreverwin.mesnac.meapi.service.NwaUserService; import com.foreverwin.mesnac.meapi.service.NwaUserService;
@ -78,6 +81,12 @@ public class AbnormalPlanServiceImpl extends ServiceImpl<AbnormalPlanMapper, Abn
@Autowired @Autowired
private UserGroupMapper userGroupMapper; private UserGroupMapper userGroupMapper;
@Autowired
private MessageTypeMapper messageTypeMapper;
@Autowired
private UsrMapper usrMapper;
@Override @Override
public IPage<AbnormalPlan> selectPage(FrontPage<AbnormalPlan> frontPage, AbnormalPlan abnormalPlan) { public IPage<AbnormalPlan> selectPage(FrontPage<AbnormalPlan> frontPage, AbnormalPlan abnormalPlan) {
@ -191,18 +200,22 @@ public class AbnormalPlanServiceImpl extends ServiceImpl<AbnormalPlanMapper, Abn
message.setHandle(UUID.randomUUID().toString()); message.setHandle(UUID.randomUUID().toString());
message.setSite(site); message.setSite(site);
message.setObjectBo(abnormalPlan.getHandle()); message.setObjectBo(abnormalPlan.getHandle());
message.setType(Constants.ABNORMAL_PLAN); message.setType(Constants.ABNORMAL_MESSAGE_PLAN);
message.setMessageType(Constants.ABNORMAL_MESSAGE_PLAN); //设置消息的类型消息的唯一id
MessageType messageType = messageTypeMapper.findMessageTypeByUserGroup(site, abnormalPlan.getSendUserGroup());
if(messageType == null){
throw new BaseException("根据发送的用户组找不到对应的消息类型,请维护。");
}
message.setMessageType(messageType.getMessageType());
message.setSendUserGroup(abnormalPlan.getSendUserGroup()); message.setSendUserGroup(abnormalPlan.getSendUserGroup());
//格式化消息内容 //格式化消息内容
String messageContent = abnormalBillService.formatMessage(abnormalBill, message.getMessageType(), site); String messageContent = abnormalBillService.formatMessage(abnormalBill, message.getMessageType(), site);
message.setContent(messageContent); message.setContent(messageContent);
message.setResponseDateTime(now); message.setResponseDateTime(now);
UserGroup customFieldByGroup = userGroupMapper.getCustomFieldByGroup(site, message.getSendUserGroup()); UserGroup customFieldByGroup = userGroupMapper.getCustomFieldByGroup(site, message.getSendUserGroup());
//得到升级的时间和等级 //设置节点(计划异常待办事项不需要设置节点)
if(customFieldByGroup != null && !StringUtil.isBlank(customFieldByGroup.getMessageNoticeTime())){
message.setUpDateTime(message.getResponseDateTime().plusMinutes(Integer.parseInt(customFieldByGroup.getMessageNoticeTime())));
}
if(customFieldByGroup != null && !StringUtil.isBlank(customFieldByGroup.getMessageNoticeLevel())) { if(customFieldByGroup != null && !StringUtil.isBlank(customFieldByGroup.getMessageNoticeLevel())) {
message.setGrade(Double.parseDouble(customFieldByGroup.getMessageNoticeLevel())); message.setGrade(Double.parseDouble(customFieldByGroup.getMessageNoticeLevel()));
} }
@ -218,12 +231,16 @@ public class AbnormalPlanServiceImpl extends ServiceImpl<AbnormalPlanMapper, Abn
if(nwaUsers != null && nwaUsers.size() <= 0){ if(nwaUsers != null && nwaUsers.size() <= 0){
throw new BaseException("消息发送失败,发送的用户组下面没有用户"); throw new BaseException("消息发送失败,发送的用户组下面没有用户");
} }
List<String> customFieldByUserId = usrMapper.findCustomFieldByUserId(site, nwaUsers);
if(customFieldByUserId != null && customFieldByUserId.size() <= 0){
throw new BaseException("消息发送失败,发送的用户组下面的自定义数据没有维护");
}
StringBuilder sendUsers = new StringBuilder(); StringBuilder sendUsers = new StringBuilder();
for (int i = 0; i < Objects.requireNonNull(nwaUsers).size(); i++) { for (int i = 0; i < Objects.requireNonNull(customFieldByUserId).size(); i++) {
if(i == (nwaUsers.size() - 1)){ if(i == (customFieldByUserId.size() - 1)){
sendUsers.append(nwaUsers.get(i).getUserName()); sendUsers.append(customFieldByUserId.get(i));
}else{ }else{
sendUsers.append(nwaUsers.get(i).getUserName()).append("|"); sendUsers.append(customFieldByUserId.get(i)).append("|");
} }
} }
activeMQUtil.wechatSendMessage(sendUsers.toString(),message.getContent()); activeMQUtil.wechatSendMessage(sendUsers.toString(),message.getContent());

@ -127,14 +127,22 @@ public class AnomalyJobServiceImpl implements AnomalyJobService {
abnormalMessage.setModifiedUser(user); abnormalMessage.setModifiedUser(user);
abnormalMessage.setModifiedDateTime(now); abnormalMessage.setModifiedDateTime(now);
List<NwaUser> nwaUsers = null;
//发送消息 //发送消息
List<NwaUser> nwaUsers = nwaUserService.checkUserGroup(site,abnormalMessage.getSendUserGroup()); try{
nwaUsers = nwaUserService.checkUserGroup(site,abnormalMessage.getSendUserGroup());
if(nwaUsers == null){
logger.info("异常单:"+abnormalBill.getAbnormalNo()+"消息发送失败,错误信息:找不到发送的用户组\n");
}
}catch(Exception e){
logger.info("异常单:"+abnormalBill.getAbnormalNo()+"消息发送失败,错误信息:找不到发送的用户组\n");
}
if(nwaUsers != null && nwaUsers.size() <= 0){ if(nwaUsers != null && nwaUsers.size() <= 0){
logger.info("消息发送失败,发送的用户组下面没有用户") ; logger.info("异常单:"+abnormalBill.getAbnormalNo()+"消息发送失败,错误信息:发送的用户组下面没有用户\n") ;
}else{ }else{
List<String> customFieldByUserId = usrMapper.findCustomFieldByUserId(site, nwaUsers); List<String> customFieldByUserId = usrMapper.findCustomFieldByUserId(site, nwaUsers);
if(customFieldByUserId != null && customFieldByUserId.size() <= 0){ if(customFieldByUserId != null && customFieldByUserId.size() <= 0){
logger.info("消息发送失败,发送的用户组下面的用户的自定义数据没有维护"); logger.info("异常单:"+abnormalBill.getAbnormalNo()+"消息发送失败,错误信息:发送的用户组下面的用户的自定义数据没有维护\n");
}else { }else {
StringBuilder sendUsers = new StringBuilder(); StringBuilder sendUsers = new StringBuilder();
for (int i = 0; i < Objects.requireNonNull(customFieldByUserId).size(); i++) { for (int i = 0; i < Objects.requireNonNull(customFieldByUserId).size(); i++) {
@ -164,7 +172,8 @@ public class AnomalyJobServiceImpl implements AnomalyJobService {
messageTypeQueryWrapper.setEntity(messageTypeEntity); messageTypeQueryWrapper.setEntity(messageTypeEntity);
MessageType sendMessageType = messageTypeMapper.selectOne(messageTypeQueryWrapper); MessageType sendMessageType = messageTypeMapper.selectOne(messageTypeQueryWrapper);
if(sendMessageType == null){ if(sendMessageType == null){
return "消息类型:"+message.getMessageType()+"找不到,异常单为:"+abnormalBill.getAbnormalNo()+",状态为:"+abnormalBill.getStatus(); // return "消息类型:"+message.getMessageType()+"找不到,异常单为:"+abnormalBill.getAbnormalNo()+",状态为:"+abnormalBill.getStatus();
return "找不到消息类型!!!";
} }
//找到要替换的消息 //找到要替换的消息
Map<String, String> replaceMessage = abnormalBillMapper.findReplaceMessageByAbnormal(abnormalBill); Map<String, String> replaceMessage = abnormalBillMapper.findReplaceMessageByAbnormal(abnormalBill);

@ -1281,7 +1281,8 @@
WHEN zabd.ABNORMAL_METHOD = 'FB' THEN '返修(不返回原工艺)' WHEN zabd.ABNORMAL_METHOD = 'FB' THEN '返修(不返回原工艺)'
ELSE '' ELSE ''
END METHOD, END METHOD,
zab.ABNORMAL_NO ABNORMAL_NO zab.ABNORMAL_NO,
zab.CANCEL_REASON CANCEL_REASON
FROM Z_ABNORMAL_BILL zab FROM Z_ABNORMAL_BILL zab
INNER JOIN ITEM i ON i.HANDLE = zab.ITEM_BO INNER JOIN ITEM i ON i.HANDLE = zab.ITEM_BO
LEFT JOIN RESRCE r ON r.RESRCE = zab.RESRCE AND r.SITE = zab.SITE LEFT JOIN RESRCE r ON r.RESRCE = zab.RESRCE AND r.SITE = zab.SITE
@ -1307,7 +1308,9 @@
</if> </if>
</where> </where>
GROUP BY wct.DESCRIPTION ,so.SHOP_ORDER ,it.DESCRIPTION,r.DESCRIPTION,r2.DESCRIPTION, GROUP BY wct.DESCRIPTION ,so.SHOP_ORDER ,it.DESCRIPTION,r.DESCRIPTION,r2.DESCRIPTION,
zab.WORK_ORDER,zab.ITEM_NUMBER,zabd.ABNORMAL_METHOD,zab.ABNORMAL_NO,item.VALUE,workOrder.VALUE zab.WORK_ORDER,zab.ITEM_NUMBER,zabd.ABNORMAL_METHOD,zab.ABNORMAL_NO,item.VALUE,workOrder.VALUE,
zab.CANCEL_REASON
</select> </select>
</mapper> </mapper>

@ -78,5 +78,9 @@
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.foreverwin.mesnac</groupId>
<artifactId>listener</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

@ -1,11 +1,12 @@
package com.foreverwin.mesnac.equip.mapper; package com.foreverwin.mesnac.equip.mapper;
import com.foreverwin.mesnac.equip.model.ResourceRepairTask;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.foreverwin.mesnac.equip.model.ResourceRepairTask;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* <p> * <p>
@ -46,4 +47,7 @@ public interface ResourceRepairTaskMapper extends BaseMapper<ResourceRepairTask>
*/ */
void insertRepairTaskLog(ResourceRepairTask resourceRepairTask); void insertRepairTaskLog(ResourceRepairTask resourceRepairTask);
Map<String,String> findReplaceMessageByResourceRepairTask(ResourceRepairTask resourceRepairTask);
} }

@ -76,4 +76,25 @@ public interface ResourceRepairTaskService extends IService<ResourceRepairTask>
*/ */
Boolean updateResourceRepairTaskInfoByHandle(ResourceRepairTask resourceRepairTask); Boolean updateResourceRepairTaskInfoByHandle(ResourceRepairTask resourceRepairTask);
/**
*
*
* #WORKCENTER#
* #RESRCE#
* #DESCRIPTION#
* #NCCODE#
* #NCDESCRIPTION
* @param resourceRepairTask handle
*/
void createAndSendMessage(ResourceRepairTask resourceRepairTask);
/**
*
* @param resourceRepairTask
* @param messageType
* @param site
* @return
*/
String formatMessage(ResourceRepairTask resourceRepairTask,String messageType,String site);
} }

@ -6,7 +6,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.mesnac.common.constant.Constants; import com.foreverwin.mesnac.common.constant.Constants;
import com.foreverwin.mesnac.common.enums.HandleEnum; import com.foreverwin.mesnac.common.enums.HandleEnum;
import com.foreverwin.mesnac.common.helper.NextNumberHelper; import com.foreverwin.mesnac.common.helper.NextNumberHelper;
import com.foreverwin.mesnac.common.model.Message;
import com.foreverwin.mesnac.common.service.AnomalyService; import com.foreverwin.mesnac.common.service.AnomalyService;
import com.foreverwin.mesnac.common.service.MessageService;
import com.foreverwin.mesnac.common.util.ActiveMQUtil;
import com.foreverwin.mesnac.common.util.StringUtil;
import com.foreverwin.mesnac.equip.mapper.ResourceInspectTaskMapper; import com.foreverwin.mesnac.equip.mapper.ResourceInspectTaskMapper;
import com.foreverwin.mesnac.equip.mapper.ResourceRepairTaskMapper; import com.foreverwin.mesnac.equip.mapper.ResourceRepairTaskMapper;
import com.foreverwin.mesnac.equip.model.ResourceInspectTask; import com.foreverwin.mesnac.equip.model.ResourceInspectTask;
@ -15,14 +19,20 @@ import com.foreverwin.mesnac.equip.model.ResourceRepairTask;
import com.foreverwin.mesnac.equip.service.ResourceInspectPlanService; import com.foreverwin.mesnac.equip.service.ResourceInspectPlanService;
import com.foreverwin.mesnac.equip.service.ResourceInspectTaskSpareService; import com.foreverwin.mesnac.equip.service.ResourceInspectTaskSpareService;
import com.foreverwin.mesnac.equip.service.ResourceRepairTaskService; import com.foreverwin.mesnac.equip.service.ResourceRepairTaskService;
import com.foreverwin.mesnac.listener.mapper.UsrMapper;
import com.foreverwin.mesnac.meapi.mapper.MessageTypeMapper;
import com.foreverwin.mesnac.meapi.mapper.NcCodeMapper; import com.foreverwin.mesnac.meapi.mapper.NcCodeMapper;
import com.foreverwin.mesnac.meapi.mapper.NwaUserMapper; import com.foreverwin.mesnac.meapi.mapper.NwaUserMapper;
import com.foreverwin.mesnac.meapi.mapper.UserGroupMapper;
import com.foreverwin.mesnac.meapi.model.DataField; import com.foreverwin.mesnac.meapi.model.DataField;
import com.foreverwin.mesnac.meapi.model.MessageType;
import com.foreverwin.mesnac.meapi.model.NwaUser; import com.foreverwin.mesnac.meapi.model.NwaUser;
import com.foreverwin.mesnac.meapi.model.UserGroup;
import com.foreverwin.mesnac.meapi.service.DataFieldListService; import com.foreverwin.mesnac.meapi.service.DataFieldListService;
import com.foreverwin.mesnac.meapi.service.NcCodeService; import com.foreverwin.mesnac.meapi.service.NcCodeService;
import com.foreverwin.mesnac.meapi.service.NwaUserService; import com.foreverwin.mesnac.meapi.service.NwaUserService;
import com.foreverwin.mesnac.meapi.service.ResrceService; import com.foreverwin.mesnac.meapi.service.ResrceService;
import com.foreverwin.modular.core.exception.BaseException;
import com.foreverwin.modular.core.exception.BusinessException; import com.foreverwin.modular.core.exception.BusinessException;
import com.foreverwin.modular.core.util.CommonMethods; import com.foreverwin.modular.core.util.CommonMethods;
import com.foreverwin.modular.core.util.FrontPage; import com.foreverwin.modular.core.util.FrontPage;
@ -34,10 +44,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Arrays; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
/** /**
* <p> * <p>
@ -77,6 +84,16 @@ public class ResourceRepairTaskServiceImpl extends ServiceImpl<ResourceRepairTas
private ResourceInspectPlanService resourceInspectPlanService; private ResourceInspectPlanService resourceInspectPlanService;
@Autowired @Autowired
private NcCodeMapper ncCodeMapper; private NcCodeMapper ncCodeMapper;
@Autowired
private MessageTypeMapper messageTypeMapper;
@Autowired
private UserGroupMapper userGroupMapper;
@Autowired
private UsrMapper usrMapper;
@Autowired
private ActiveMQUtil activeMQUtil;
@Autowired
private MessageService messageService;
@Override @Override
public HashMap<String, Object> init() { public HashMap<String, Object> init() {
@ -155,6 +172,7 @@ public class ResourceRepairTaskServiceImpl extends ServiceImpl<ResourceRepairTas
resourceRepairTask.setCreateUser(reportUser); resourceRepairTask.setCreateUser(reportUser);
resourceRepairTask.setCreatedDateTime(LocalDateTime.now()); resourceRepairTask.setCreatedDateTime(LocalDateTime.now());
resourceRepairTaskService.save(resourceRepairTask); resourceRepairTaskService.save(resourceRepairTask);
this.createAndSendMessage(resourceRepairTask);
} }
@Override @Override
@ -381,6 +399,101 @@ public class ResourceRepairTaskServiceImpl extends ServiceImpl<ResourceRepairTas
return resourceRepairTaskService.updateById(resourceRepairTask); return resourceRepairTaskService.updateById(resourceRepairTask);
} }
@Override
public void createAndSendMessage(ResourceRepairTask resourceRepairTask) {
String site = CommonMethods.getSite();
String user = CommonMethods.getUser();
LocalDateTime now = LocalDateTime.now();
Message message = new Message();
message.setHandle(UUID.randomUUID().toString());
message.setSite(site);
message.setObjectBo(resourceRepairTask.getHandle());
message.setType(Constants.REPAIR_TYPE);
//根据用户组找到对应的消息内容
MessageType messageType = messageTypeMapper.findMessageTypeByUserGroup(site, resourceRepairTask.getAnother());
if(messageType == null){
throw new BaseException("根据发送的用户组找不到对应的消息类型,请维护。");
}
message.setMessageType(messageType.getMessageType());
message.setSendUserGroup(resourceRepairTask.getAnother());
//格式化消息内容
String messageContent = this.formatMessage(resourceRepairTask, messageType.getMessageType(), site);
message.setContent(messageContent);
message.setResponseDateTime(LocalDateTime.now());
// message.setUpUserGroup(message.getSendUserGroup()+"_SJ");
//得到升级的时间和等级
UserGroup customFieldByGroup = userGroupMapper.getCustomFieldByGroup(site, message.getSendUserGroup());
// if(customFieldByGroup != null && !StringUtil.isBlank(customFieldByGroup.getMessageNoticeTime())){
// message.setUpDateTime(message.getResponseDateTime().plusMinutes(Integer.parseInt(customFieldByGroup.getMessageNoticeTime())));
// }else{
// throw new BaseException("该用户组没有维护升级的时间,请维护。");
// }
if(customFieldByGroup != null && !StringUtil.isBlank(customFieldByGroup.getMessageNoticeLevel())){
message.setGrade(Double.parseDouble(customFieldByGroup.getMessageNoticeLevel()));
}else{
throw new BaseException("该用户组没有维护等级,请维护。");
}
// MessageType messageTypeUp = messageTypeMapper.findMessageTypeByUserGroup(site, message.getUpUserGroup());
// //得到升级的消息类型
// if(messageTypeUp == null){
// throw new BaseException("用户组"+message.getSendUserGroup()+"的升级用户没有维护消息类型");
// }
// message.setUpMessageType(messageTypeUp.getMessageType());
message.setNode(Constants.RESOURCE_REPAIR_MESSAGE_REPORT);
message.setStatus("Y");
message.setCreatedUser(user);
message.setCreatedDateTime(now);
message.setModifiedUser(user);
message.setModifiedDateTime(now);
//发送消息
List<NwaUser> nwaUsers = nwaUserService.checkUserGroup(site,message.getSendUserGroup());
if(nwaUsers != null && nwaUsers.size() <= 0){
throw new BaseException("消息发送失败,发送的用户组下面没有用户");
}
List<String> customFieldByUserId = usrMapper.findCustomFieldByUserId(site, nwaUsers);
if(customFieldByUserId != null && customFieldByUserId.size() <= 0){
throw new BaseException("消息发送失败,发送的用户组下面的用户的自定义数据没有维护");
}
StringBuilder sendUsers = new StringBuilder();
for (int i = 0; i < Objects.requireNonNull(customFieldByUserId).size(); i++) {
if(i == (customFieldByUserId.size() - 1)){
sendUsers.append(customFieldByUserId.get(i));
}else{
sendUsers.append(customFieldByUserId.get(i)).append("|");
}
}
activeMQUtil.wechatSendMessage(sendUsers.toString(),message.getContent());
messageService.saveOrUpdate(message);
}
@Override
public String formatMessage(ResourceRepairTask resourceRepairTask, String messageType, String site) {
/*
*
*/
MessageType messageTypeEntity = new MessageType();
messageTypeEntity.setSite(site);
messageTypeEntity.setMessageType(messageType);
QueryWrapper<MessageType> messageTypeQueryWrapper = new QueryWrapper<MessageType>();
messageTypeQueryWrapper.setEntity(messageTypeEntity);
MessageType sendMessageType = messageTypeMapper.selectOne(messageTypeQueryWrapper);
if(sendMessageType == null){
throw new BaseException("维修提报找不到要发送的消息类型");
}
/**
* mapkey resourceRepairTask
*/
Map<String, String> replaceMessageMap = resourceRepairTaskMapper.findReplaceMessageByResourceRepairTask(resourceRepairTask);
String messageBody = sendMessageType.getBody();
//格式化之后的消息
return com.foreverwin.mesnac.meapi.util.StringUtils.format(messageBody, replaceMessageMap);
}
} }

@ -1051,5 +1051,16 @@
<!--自定义sql--> <!--自定义sql-->
<select id="findReplaceMessageByResourceRepairTask" parameterType="com.foreverwin.mesnac.equip.model.ResourceRepairTask" resultType="HashMap">
SELECT wct.DESCRIPTION WORKCENTER,r.RESRCE RESRCE,r.DESCRIPTION DESCRIPTION ,zrrt.OTHER NCCODE,zrrt.BREAK_DOWN_DESCRIPTION NCDESCRIPTION
FROM Z_RESOURCE_REPAIR_TASK zrrt
INNER JOIN RESRCE r ON r.RESRCE = zrrt.RESOURCE_NO AND r.SITE = zrrt.SITE
LEFT JOIN WORK_CENTER_MEMBER wcm ON wcm.WORK_CENTER_OR_RESOURCE_GBO = r.HANDLE
LEFT JOIN WORK_CENTER_MEMBER wcm2 ON wcm2.WORK_CENTER_OR_RESOURCE_GBO = wcm.WORK_CENTER_BO
LEFT JOIN WORK_CENTER wc ON wc.HANDLE = wcm2.WORK_CENTER_BO
LEFT JOIN WORK_CENTER_T wct ON wct.WORK_CENTER_BO = wc.HANDLE AND wct.LOCALE = 'zh'
<where>
zrrt.HANDLE = #{handle}
</where>
</select>
</mapper> </mapper>

@ -214,7 +214,8 @@ public class StringUtils {
} }
} }
} }
Pattern pattern = Pattern.compile("#.*#"); Pattern pattern = Pattern.compile("#.*?#");
Matcher matcher = pattern.matcher(message); Matcher matcher = pattern.matcher(message);
message = matcher.replaceAll("[空]"); message = matcher.replaceAll("[空]");
return message; return message;

Loading…
Cancel
Save