|
|
@ -7,7 +7,11 @@ import java.text.SimpleDateFormat;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
|
import com.op.common.core.domain.BaseFileData;
|
|
|
|
import com.op.common.core.domain.BaseFileData;
|
|
|
|
import com.op.common.core.utils.DateUtils;
|
|
|
|
import com.op.common.core.utils.DateUtils;
|
|
|
@ -17,6 +21,11 @@ import com.op.common.core.web.domain.AjaxResult;
|
|
|
|
import com.op.common.security.utils.SecurityUtils;
|
|
|
|
import com.op.common.security.utils.SecurityUtils;
|
|
|
|
import com.op.device.domain.*;
|
|
|
|
import com.op.device.domain.*;
|
|
|
|
import com.op.device.mapper.*;
|
|
|
|
import com.op.device.mapper.*;
|
|
|
|
|
|
|
|
import com.op.system.api.RemoteOpenService;
|
|
|
|
|
|
|
|
import com.op.system.api.domain.SysNoticeGroup;
|
|
|
|
|
|
|
|
import com.op.system.api.domain.dto.WechartDTO;
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
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 com.op.device.service.IEquRepairWorkOrderService;
|
|
|
|
import com.op.device.service.IEquRepairWorkOrderService;
|
|
|
@ -39,6 +48,8 @@ import static com.op.common.core.web.domain.AjaxResult.success;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class EquRepairWorkOrderServiceImpl implements IEquRepairWorkOrderService {
|
|
|
|
public class EquRepairWorkOrderServiceImpl implements IEquRepairWorkOrderService {
|
|
|
|
|
|
|
|
protected Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private EquOrderMapper equOrderMapper;
|
|
|
|
private EquOrderMapper equOrderMapper;
|
|
|
|
|
|
|
|
|
|
|
@ -60,6 +71,12 @@ public class EquRepairWorkOrderServiceImpl implements IEquRepairWorkOrderService
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private EquEquipmentMapper equEquipmentMapper;
|
|
|
|
private EquEquipmentMapper equEquipmentMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private RemoteOpenService remoteOpenService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private EquRepairOrderMapper equRepairOrderMapper;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询维修工单
|
|
|
|
* 查询维修工单
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -152,6 +169,7 @@ public class EquRepairWorkOrderServiceImpl implements IEquRepairWorkOrderService
|
|
|
|
equRepairWorkOrder.setOrderCode("无");
|
|
|
|
equRepairWorkOrder.setOrderCode("无");
|
|
|
|
equRepairWorkOrder.setOutWorkCode("无");
|
|
|
|
equRepairWorkOrder.setOutWorkCode("无");
|
|
|
|
equRepairWorkOrder.setWorkCode("WX" + DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + equipmentCode + serialNum);
|
|
|
|
equRepairWorkOrder.setWorkCode("WX" + DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + equipmentCode + serialNum);
|
|
|
|
|
|
|
|
equRepairWorkOrder.setWorkHandle("1");
|
|
|
|
equRepairWorkOrder.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
equRepairWorkOrder.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
equRepairWorkOrder.setCreateTime(DateUtils.getNowDate());
|
|
|
|
equRepairWorkOrder.setCreateTime(DateUtils.getNowDate());
|
|
|
|
//工厂号
|
|
|
|
//工厂号
|
|
|
@ -165,6 +183,106 @@ public class EquRepairWorkOrderServiceImpl implements IEquRepairWorkOrderService
|
|
|
|
equEquipment.setEquipmentCode(equipmentCode);
|
|
|
|
equEquipment.setEquipmentCode(equipmentCode);
|
|
|
|
equEquipment.setEquipmentStatus("0");//0故障
|
|
|
|
equEquipment.setEquipmentStatus("0");//0故障
|
|
|
|
equRepairWorkOrderMapper.updateEquipmentStatus(equEquipment);
|
|
|
|
equRepairWorkOrderMapper.updateEquipmentStatus(equEquipment);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////快速工单后发送微信提醒
|
|
|
|
|
|
|
|
//发企业微信--------------------开始(跟班组有关)
|
|
|
|
|
|
|
|
SimpleDateFormat myFmt=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒"); //规范时间格式
|
|
|
|
|
|
|
|
SysNoticeGroup noticeQo = new SysNoticeGroup();
|
|
|
|
|
|
|
|
noticeQo.setNoticeId(11L); //id写死了?
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
String workHandle = "立即维修";
|
|
|
|
|
|
|
|
////判断是否需要停机维修
|
|
|
|
|
|
|
|
String workDownMachine = "";
|
|
|
|
|
|
|
|
if(equRepairWorkOrder.getWorkDownMachine().equals("1")){
|
|
|
|
|
|
|
|
workDownMachine = "停机";
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
workDownMachine = "不停机";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//在前端填的时候,需要判空!!!!!!
|
|
|
|
|
|
|
|
contentInfo = contentInfo
|
|
|
|
|
|
|
|
.replace("${message}", "\n")
|
|
|
|
|
|
|
|
.replace("${equipmentCode}", equRepairWorkOrder.getEquipmentCode()+"\n")
|
|
|
|
|
|
|
|
.replace("${workCode}", equRepairWorkOrder.getWorkCode()+"\n")
|
|
|
|
|
|
|
|
.replace("${workHandle}", workHandle+"\n");
|
|
|
|
|
|
|
|
//故障描述
|
|
|
|
|
|
|
|
if(StringUtils.isNotEmpty(equRepairWorkOrder.getWorkFaultDesc())){
|
|
|
|
|
|
|
|
contentInfo = contentInfo.replace("${workFaultDesc}", equRepairWorkOrder.getWorkFaultDesc()+"\n");
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
contentInfo = contentInfo.replace("${workFaultDesc}", "无"+"\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//维修组
|
|
|
|
|
|
|
|
if(StringUtils.isNotEmpty(equRepairWorkOrder.getWorkTeam())){
|
|
|
|
|
|
|
|
contentInfo = contentInfo.replace("${workTeam}", equRepairWorkOrder.getWorkTeam()+"\n");
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
contentInfo = contentInfo.replace("${workTeam}", "无"+"\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//计划停机维修时间
|
|
|
|
|
|
|
|
if(equRepairWorkOrder.getWorkPlanTime() != null){
|
|
|
|
|
|
|
|
contentInfo = contentInfo.replace("${workPlanTime}", myFmt.format(equRepairWorkOrder.getWorkPlanTime())+"\n");
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
contentInfo = contentInfo.replace("${workPlanTime}", "无"+"\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//计划停机维修时间
|
|
|
|
|
|
|
|
if(equRepairWorkOrder.getWorkPlanDownTime() != null){
|
|
|
|
|
|
|
|
contentInfo = contentInfo.replace("${workPlanDownTime}", myFmt.format(equRepairWorkOrder.getWorkPlanDownTime())+"\n");
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
contentInfo = contentInfo.replace("${workPlanDownTime}", "无"+"\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//是否停机
|
|
|
|
|
|
|
|
if(StringUtils.isNotEmpty(workDownMachine)){
|
|
|
|
|
|
|
|
contentInfo = contentInfo.replace("${workDownMachine}", workDownMachine+"\n");
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
contentInfo = contentInfo.replace("${workDownMachine}", "无"+"\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查询设备相关信息
|
|
|
|
|
|
|
|
//设备名称
|
|
|
|
|
|
|
|
EquEquipment equ = equEquipmentMapper.selectEquEquipmentByEquEquipmentCode(equRepairWorkOrder.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 result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|