2024-5-24 设备-上位机-报修之后-发送微信+PDA修改

master
A0010407 8 months ago
parent 13fd0189cb
commit 81d4b8cc51

@ -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");

@ -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<SysNoticeGroup> getNoticesGroup(SysNoticeGroup noticeQo);
EquEquipmentDTO selectEquipmentDetailByEquipmentCode(String equipmentCode);
}

@ -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<SysNoticeGroup> notices = openMapper.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("${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");
}
//替换掉<p>标签
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));

@ -386,4 +386,23 @@
</foreach>
</insert>
<select id="getNoticesGroup" resultType="com.op.system.api.domain.SysNoticeGroup">
select sng.notice_id noticeId,
sn.notice_title noticeTitle,
sn.notice_type noticeType,
sn.notice_content noticeContent,
btu.user_name userCode,
btu.wx_id wxId
from sys_notice_group sng
left join sys_notice sn on sng.notice_id = sn.notice_id
left join base_team_user btu on sng.group_code = btu.team_code
where sng.notice_id = #{noticeId}
</select>
<select id="selectEquipmentDetailByEquipmentCode" parameterType="String" resultType="com.op.system.api.domain.device.EquEquipmentDTO">
select equipment_id, equipment_code, equipment_name, equipment_brand, equipment_spec, equipment_type_id, equipment_type_code, equipment_type_name, workshop_id, workshop_code, workshop_name, status, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time, workshop_section, equipment_location, hourly_unit_price, equipment_barcode, equipment_barcode_image, manufacturer, supplier, use_life, buy_time, asset_original_value, net_asset_value, asset_head, fixed_asset_code, department, unit_working_hours, plc_ip, plc_port, del_flag, sap_asset,equipment_status,equipment_category from base_equipment
where equipment_code = #{equipmentCode}
and del_flag = '0'
</select>
</mapper>

Loading…
Cancel
Save