From ac634b5f61a7855f7ce125e4ac9db7d91a064b0a Mon Sep 17 00:00:00 2001 From: A0010407 Date: Tue, 28 May 2024 15:40:47 +0800 Subject: [PATCH] =?UTF-8?q?2024-5-28=20=E8=AE=BE=E5=A4=87-=E4=BF=9D?= =?UTF-8?q?=E5=85=BB-=E7=BB=93=E6=9E=9C=E6=A3=80=E9=AA=8C=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../op/device/domain/dto/UpKeepOrderDTO.java | 10 ++ .../impl/EquUpkeepOrderServiceImpl.java | 96 +++++++++++++++++++ 2 files changed, 106 insertions(+) diff --git a/op-modules/op-device/src/main/java/com/op/device/domain/dto/UpKeepOrderDTO.java b/op-modules/op-device/src/main/java/com/op/device/domain/dto/UpKeepOrderDTO.java index 2b33d50c..937a6537 100644 --- a/op-modules/op-device/src/main/java/com/op/device/domain/dto/UpKeepOrderDTO.java +++ b/op-modules/op-device/src/main/java/com/op/device/domain/dto/UpKeepOrderDTO.java @@ -6,6 +6,8 @@ import java.util.List; public class UpKeepOrderDTO { private List ids; + private List orderCodes; + private String inspect; public String getInspect() { @@ -23,4 +25,12 @@ public class UpKeepOrderDTO { public void setIds(List ids) { this.ids = ids; } + + public List getOrderCodes() { + return orderCodes; + } + + public void setOrderCodes(List orderCodes) { + this.orderCodes = orderCodes; + } } diff --git a/op-modules/op-device/src/main/java/com/op/device/service/impl/EquUpkeepOrderServiceImpl.java b/op-modules/op-device/src/main/java/com/op/device/service/impl/EquUpkeepOrderServiceImpl.java index 95d67e0f..5c6c1069 100644 --- a/op-modules/op-device/src/main/java/com/op/device/service/impl/EquUpkeepOrderServiceImpl.java +++ b/op-modules/op-device/src/main/java/com/op/device/service/impl/EquUpkeepOrderServiceImpl.java @@ -1,24 +1,37 @@ package com.op.device.service.impl; +import com.alibaba.fastjson2.JSONObject; import com.baomidou.dynamic.datasource.annotation.DS; import com.op.common.core.context.SecurityContextHolder; 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.web.domain.AjaxResult; +import com.op.common.security.utils.SecurityUtils; import com.op.device.domain.*; import com.op.device.domain.dto.UpKeepOrderDTO; import com.op.device.mapper.*; 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.dto.WechartDTO; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletRequest; +import java.text.SimpleDateFormat; import java.util.ArrayList; 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; @@ -30,6 +43,7 @@ import static com.op.common.core.web.domain.AjaxResult.success; */ @Service public class EquUpkeepOrderServiceImpl implements IEquUpkeepOrderService { + protected Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private EquOrderMapper equOrderMapper; @Autowired @@ -45,6 +59,12 @@ public class EquUpkeepOrderServiceImpl implements IEquUpkeepOrderService { @Autowired private SparePartsLedgerMapper sparePartsLedgerMapper; + @Autowired + private RemoteOpenService remoteOpenService; + + @Autowired + private EquRepairOrderMapper equRepairOrderMapper; + /** * 查询保养工单 * @@ -249,6 +269,82 @@ public class EquUpkeepOrderServiceImpl implements IEquUpkeepOrderService { order.setOrderInspect(upKeepOrderDTO.getInspect()); equOrderMapper.updateEquOrder(order); } + + String orderCodes = ""; + List 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 notices = equRepairOrderMapper.getNoticesGroup(noticeQo); + if(!CollectionUtils.isEmpty(notices)) { + List wecharts = new ArrayList<>(); + List 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(); } }