2024-5-28 设备-保养-结果检验微信通知

master
A0010407 8 months ago
parent 9ba60dba19
commit ac634b5f61

@ -6,6 +6,8 @@ import java.util.List;
public class UpKeepOrderDTO { public class UpKeepOrderDTO {
private List<String> ids; private List<String> ids;
private List<String> orderCodes;
private String inspect; private String inspect;
public String getInspect() { public String getInspect() {
@ -23,4 +25,12 @@ public class UpKeepOrderDTO {
public void setIds(List<String> ids) { public void setIds(List<String> ids) {
this.ids = ids; this.ids = ids;
} }
public List<String> getOrderCodes() {
return orderCodes;
}
public void setOrderCodes(List<String> orderCodes) {
this.orderCodes = orderCodes;
}
} }

@ -1,24 +1,37 @@
package com.op.device.service.impl; package com.op.device.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.context.SecurityContextHolder; import com.op.common.core.context.SecurityContextHolder;
import com.op.common.core.utils.DateUtils; import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.StringUtils;
import com.op.common.core.utils.uuid.IdUtils; import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.core.web.domain.AjaxResult; import com.op.common.core.web.domain.AjaxResult;
import com.op.common.security.utils.SecurityUtils;
import com.op.device.domain.*; import com.op.device.domain.*;
import com.op.device.domain.dto.UpKeepOrderDTO; import com.op.device.domain.dto.UpKeepOrderDTO;
import com.op.device.mapper.*; import com.op.device.mapper.*;
import com.op.device.service.IEquUpkeepOrderService; import com.op.device.service.IEquUpkeepOrderService;
import com.op.system.api.RemoteOpenService;
import com.op.system.api.domain.SysNoticeGroup;
import com.op.system.api.domain.SysUser; import com.op.system.api.domain.SysUser;
import com.op.system.api.domain.dto.WechartDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static com.op.common.core.web.domain.AjaxResult.success; import static com.op.common.core.web.domain.AjaxResult.success;
@ -30,6 +43,7 @@ import static com.op.common.core.web.domain.AjaxResult.success;
*/ */
@Service @Service
public class EquUpkeepOrderServiceImpl implements IEquUpkeepOrderService { public class EquUpkeepOrderServiceImpl implements IEquUpkeepOrderService {
protected Logger logger = LoggerFactory.getLogger(getClass());
@Autowired @Autowired
private EquOrderMapper equOrderMapper; private EquOrderMapper equOrderMapper;
@Autowired @Autowired
@ -45,6 +59,12 @@ public class EquUpkeepOrderServiceImpl implements IEquUpkeepOrderService {
@Autowired @Autowired
private SparePartsLedgerMapper sparePartsLedgerMapper; private SparePartsLedgerMapper sparePartsLedgerMapper;
@Autowired
private RemoteOpenService remoteOpenService;
@Autowired
private EquRepairOrderMapper equRepairOrderMapper;
/** /**
* *
* *
@ -249,6 +269,82 @@ public class EquUpkeepOrderServiceImpl implements IEquUpkeepOrderService {
order.setOrderInspect(upKeepOrderDTO.getInspect()); order.setOrderInspect(upKeepOrderDTO.getInspect());
equOrderMapper.updateEquOrder(order); equOrderMapper.updateEquOrder(order);
} }
String orderCodes = "";
List<String> list = upKeepOrderDTO.getOrderCodes();
for (String orderCode : list) {
orderCodes = orderCode + "、" + orderCodes ;
}
String inspect = "";
if(upKeepOrderDTO.getInspect().equals("noPass")){
inspect = "不通过" ;
}else if(upKeepOrderDTO.getInspect().equals("pass")){
inspect = "通过" ;
}else{
inspect = "待检验" ;
}
//PDA企业微信报修审核提醒
//发企业微信--------------------开始(跟班组有关)
SimpleDateFormat myFmt=new SimpleDateFormat("yyyy.MM.dd HH:mm:ss"); //规范时间格式
SysNoticeGroup noticeQo = new SysNoticeGroup();
noticeQo.setNoticeId(13L);
EquTeamUser equTeamUser = new EquTeamUser();
equTeamUser.setUserName(SecurityUtils.getUsername());
EquTeamUser equTeamUser1 = equRepairOrderMapper.getRepairPhoneNumber(equTeamUser);
Integer number = ids.size(); //个数
List<SysNoticeGroup> notices = equRepairOrderMapper.getNoticesGroup(noticeQo);
if(!CollectionUtils.isEmpty(notices)) {
List<WechartDTO> wecharts = new ArrayList<>();
List<String> userCodes = notices.stream()
.map(SysNoticeGroup::getUserCode)
.collect(Collectors.toList());
for (SysNoticeGroup noticeDto : notices) {
WechartDTO wechart0 = new WechartDTO();
wechart0.setUserId(noticeDto.getWxId());
String contentInfo = noticeDto.getNoticeContent();
contentInfo = contentInfo
.replace("${n}", "\n")
.replace("${number}", number.toString())
.replace("${messageType}", "保养")
.replace("${result}", inspect + "\n")
.replace("${checkTime}", myFmt.format(DateUtils.getNowDate())+"\n")
;
//工单号
if(StringUtils.isNotEmpty(orderCodes)){
contentInfo = contentInfo.replace("${orderCodes}", orderCodes +"\n");
}else{
contentInfo = contentInfo.replace("${orderCodes}", "无"+"\n");
}
//检查人
if(StringUtils.isNotEmpty(equTeamUser1.getNickName())){
contentInfo = contentInfo.replace("${checkPeople}", equTeamUser1.getNickName()+"\n");
}else{
contentInfo = contentInfo.replace("${checkPeople}", "无"+"\n");
}
Pattern p= Pattern.compile("<[^>]+>");
Matcher m = p.matcher(contentInfo);
contentInfo = m.replaceAll("");
System.out.println(contentInfo);
wechart0.setText(contentInfo);
wecharts.add(wechart0);
}
logger.info("保养结果检验企业微信提醒请求:" + JSONObject.toJSONString(wecharts));
if (!CollectionUtils.isEmpty(wecharts)) {
new Thread(() -> {
AjaxResult wxresult = remoteOpenService.sendWeChartMessage(wecharts);
logger.info("保养结果检验企业微信提醒结果:" + JSONObject.toJSONString(wxresult));
}).start();
}
//发企业微信--------------------结束
}
return success(); return success();
} }
} }

Loading…
Cancel
Save