diff --git a/op-modules/op-device/src/main/java/com/op/device/service/impl/DevicePDAServiceImpl.java b/op-modules/op-device/src/main/java/com/op/device/service/impl/DevicePDAServiceImpl.java index c57a768b..930c6bc6 100644 --- a/op-modules/op-device/src/main/java/com/op/device/service/impl/DevicePDAServiceImpl.java +++ b/op-modules/op-device/src/main/java/com/op/device/service/impl/DevicePDAServiceImpl.java @@ -547,7 +547,7 @@ public class DevicePDAServiceImpl implements IDevicePDAService { } //报修人 - if(equRepairOrder.getOrderBreakdownTime() != null){ + if(equRepairOrder.getOrderRepairmanName() != null){ contentInfo = contentInfo.replace("${orderRepairmanName}", equRepairOrder.getOrderRepairmanName()+"\n"); }else{ contentInfo = contentInfo.replace("${orderRepairmanName}", "无"+"\n"); diff --git a/op-modules/op-open/src/main/java/com/op/open/mapper/OpenMapper.java b/op-modules/op-open/src/main/java/com/op/open/mapper/OpenMapper.java index 53e36544..fa441c9a 100644 --- a/op-modules/op-open/src/main/java/com/op/open/mapper/OpenMapper.java +++ b/op-modules/op-open/src/main/java/com/op/open/mapper/OpenMapper.java @@ -1,7 +1,9 @@ package com.op.open.mapper; +import com.op.system.api.domain.SysNoticeGroup; import com.op.system.api.domain.SysSapLog; import com.op.system.api.domain.device.DeviceRepairOrder; +import com.op.system.api.domain.device.EquEquipmentDTO; import com.op.system.api.domain.dto.WCSDTO; import com.op.system.api.domain.mes.MesReportWorkConsumeDTO; import com.op.system.api.domain.mes.MesReportWorkDTO; @@ -85,5 +87,9 @@ public interface OpenMapper { String getSampNum(QcCheckTaskProduceDTO sampQua); Date getLastTask(QcCheckTaskProduceDTO qcCheckTaskProduce); + + List getNoticesGroup(SysNoticeGroup noticeQo); + + EquEquipmentDTO selectEquipmentDetailByEquipmentCode(String equipmentCode); } diff --git a/op-modules/op-open/src/main/java/com/op/open/service/impl/OpenServiceImpl.java b/op-modules/op-open/src/main/java/com/op/open/service/impl/OpenServiceImpl.java index 9e18ca59..cd0fdf20 100644 --- a/op-modules/op-open/src/main/java/com/op/open/service/impl/OpenServiceImpl.java +++ b/op-modules/op-open/src/main/java/com/op/open/service/impl/OpenServiceImpl.java @@ -13,7 +13,10 @@ import com.op.common.core.web.domain.AjaxResult; import com.op.common.security.utils.SecurityUtils; import com.op.open.mapper.OpenMapper; import com.op.open.service.OpenService; +import com.op.system.api.RemoteOpenService; +import com.op.system.api.domain.SysNoticeGroup; import com.op.system.api.domain.device.DeviceRepairOrder; +import com.op.system.api.domain.device.EquEquipmentDTO; import com.op.system.api.domain.device.EquRepairOrderDTO; import com.op.system.api.domain.dto.WCSDTO; import com.op.system.api.domain.dto.WCSDataDTO; @@ -21,6 +24,8 @@ import com.op.system.api.domain.dto.WechartDTO; import com.op.system.api.domain.mes.ProRfidProcessDetail; import com.op.system.api.domain.quality.*; import org.apache.commons.lang.StringUtils; + +import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.time.Duration; import org.slf4j.Logger; @@ -33,6 +38,8 @@ import java.math.BigDecimal; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; import static com.op.common.core.web.domain.AjaxResult.error; @@ -68,8 +75,8 @@ public class OpenServiceImpl implements OpenService { @Autowired private OpenMapper openMapper; -// @Autowired -// private RemoteSapService remoteSapService; + @Autowired + private RemoteOpenService remoteOpenService; /** * 下一工序机台集合获取 @@ -265,43 +272,115 @@ public class OpenServiceImpl implements OpenService { @Override public AjaxResult machineRepair(EquRepairOrderDTO equRepairOrderDTO) { - if (equRepairOrderDTO.getFactory() == null) { return error("工厂源不可为空!"); } - DynamicDataSourceContextHolder.push("ds_" + equRepairOrderDTO.getFactory());// 这是数据源的key + DynamicDataSourceContextHolder.push("ds_" + equRepairOrderDTO.getFactory()); // 这是数据源的key - // 创建报修单 + ////创建报修单 DeviceRepairOrder equRepairOrder = new DeviceRepairOrder(); - // 获取故障报修流水号 - String serialNum = String.format("%03d", openMapper.selectOrderCodeSerialNumber()); + String serialNum = String.format("%03d", openMapper.selectOrderCodeSerialNumber()); // 获取故障报修流水号 if (equRepairOrderDTO.getEquipmentCode() == null) { return error("设备信息不可为空!"); } equRepairOrder.setOrderCode("BX" + DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + equRepairOrderDTO.getEquipmentCode() + serialNum);// 报修单号 - equRepairOrder.setOrderId(IdUtils.fastSimpleUUID());// id + equRepairOrder.setOrderId(IdUtils.fastSimpleUUID()); // id equRepairOrder.setEquipmentCode(equRepairOrderDTO.getEquipmentCode()); - equRepairOrder.setOrderSource("上位机");// 故障来源 - equRepairOrder.setOrderDesc(equRepairOrderDTO.getOrderDesc());//故障描述 新增加的 - equRepairOrder.setOrderTime(DateUtils.getNowDate());// 报修时间 - equRepairOrder.setOrderBreakdownTime(DateUtils.getNowDate());// 故障时间 + equRepairOrder.setOrderSource("上位机"); // 故障来源 + equRepairOrder.setOrderDesc(equRepairOrderDTO.getOrderDesc()); //故障描述 新增加的 + equRepairOrder.setOrderTime(DateUtils.getNowDate()); // 报修时间 + equRepairOrder.setOrderBreakdownTime(DateUtils.getNowDate()); // 故障时间 if (equRepairOrderDTO.getUserName() != null) { - equRepairOrder.setOrderRepairmanCode(equRepairOrderDTO.getUserName());// 用户账号 + equRepairOrder.setOrderRepairmanCode(equRepairOrderDTO.getUserName()); // 用户账号 } if (equRepairOrderDTO.getUserNickName() != null) { - equRepairOrder.setOrderRepairmanName(equRepairOrderDTO.getUserNickName());// 用户名称 + equRepairOrder.setOrderRepairmanName(equRepairOrderDTO.getUserNickName()); // 用户名称 } - equRepairOrder.setCreateTime(DateUtils.getNowDate()); equRepairOrder.setCreateBy(equRepairOrderDTO.getUserName()); - equRepairOrder.setOrderStatus("待审核");// 报修单状态 - equRepairOrder.setFactoryCode(equRepairOrderDTO.getFactory());// 工厂 + equRepairOrder.setOrderStatus("待审核"); // 报修单状态 + equRepairOrder.setFactoryCode(equRepairOrderDTO.getFactory()); // 工厂 if (equRepairOrderDTO.getPhoneNumber() != null) { - equRepairOrder.setOrderConnection(equRepairOrderDTO.getPhoneNumber());// 联系方式 + equRepairOrder.setOrderConnection(equRepairOrderDTO.getPhoneNumber()); // 联系方式 } - openMapper.insertEquRepairOrder(equRepairOrder); + ////发企业微信--------------------开始(跟班组有关) + SimpleDateFormat myFmt=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒"); //规范时间格式 + SysNoticeGroup noticeQo = new SysNoticeGroup(); + //id写死了? + noticeQo.setNoticeId(10L); + List notices = openMapper.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("${message}", "\n") + .replace("${equipmentCode}", equRepairOrder.getEquipmentCode()+"\n") + .replace("${orderCode}", equRepairOrder.getOrderCode()+"\n"); + + //故障时间 + if(equRepairOrder.getOrderBreakdownTime() != null){ + contentInfo = contentInfo.replace("${orderBreakdownTime}", myFmt.format(equRepairOrder.getOrderBreakdownTime())+"\n"); + }else{ + contentInfo = contentInfo.replace("${orderBreakdownTime}", "无"+"\n"); + } + + //故障原因 + if(StringUtils.isNotEmpty(equRepairOrder.getOrderDesc())){ + contentInfo = contentInfo.replace("${orderDesc}", equRepairOrder.getOrderDesc()+"\n"); + }else{ + contentInfo = contentInfo.replace("${orderDesc}", "无"+"\n"); + } + + //报修人名字 + if(StringUtils.isNotEmpty(equRepairOrder.getOrderRepairmanName())){ + contentInfo = contentInfo.replace("${orderRepairmanName}", equRepairOrder.getOrderRepairmanName()+"\n"); + }else{ + contentInfo = contentInfo.replace("${orderRepairmanName}", "无"+"\n"); + } + + //查询设备相关信息 + EquEquipmentDTO equ = openMapper.selectEquipmentDetailByEquipmentCode(equRepairOrder.getEquipmentCode()); + if(StringUtils.isNotEmpty(equ.getEquipmentName())){ + contentInfo = contentInfo.replace("${equipmentName}", equ.getEquipmentName()+"\n"); + }else{ + contentInfo = contentInfo.replace("${equipmentName}", "无"+"\n"); + } + //设备位置 + if(StringUtils.isNotEmpty(equ.getEquipmentLocation())){ + contentInfo = contentInfo.replace("${equipmentLocation}", equ.getEquipmentLocation()+"\n"); + }else{ + contentInfo = contentInfo.replace("${equipmentLocation}", "无"+"\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(); } @@ -518,7 +597,6 @@ public class OpenServiceImpl implements OpenService { } } - protected Boolean oneMinHas(Date lastData){ if(lastData != null){ int year= Integer.parseInt(String.format("%tY", lastData)); diff --git a/op-modules/op-open/src/main/resources/mapper/open/OpenMapper.xml b/op-modules/op-open/src/main/resources/mapper/open/OpenMapper.xml index 099a2a96..97d1f036 100644 --- a/op-modules/op-open/src/main/resources/mapper/open/OpenMapper.xml +++ b/op-modules/op-open/src/main/resources/mapper/open/OpenMapper.xml @@ -386,4 +386,23 @@ + + + +