From 0284c08961db9aa58c48953e80f2dd6d011a3365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=83=E6=B0=94=E6=BB=A1=E6=BB=A1=28jgy=29?= Date: Wed, 6 Nov 2024 15:50:56 +0800 Subject: [PATCH] =?UTF-8?q?2024-11-06=20MES+sys=20API+Device=20=E4=B8=89?= =?UTF-8?q?=E4=B8=AA=E6=A8=A1=E5=9D=97=20=E7=94=9F=E4=BA=A7=E5=B7=A5?= =?UTF-8?q?=E5=8D=95=E5=88=87=E7=BA=BF=E3=80=81=E5=88=87=E7=BA=BF=E8=B0=83?= =?UTF-8?q?=E6=8B=A8=E4=BA=A7=E7=94=9F=E6=96=B0=E8=AE=BE=E5=A4=87=E7=82=B9?= =?UTF-8?q?=E6=A3=80=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../op/system/api/RemoteDeviceService.java | 5 + .../system/api/domain/device/EquPlanDTO.java | 633 ++++++++++++++++++ .../factory/RemoteDeviceFallbackFactory.java | 5 + .../controller/DeviceTaskController.java | 15 + .../op/device/service/IDeviceTaskService.java | 5 +- .../service/impl/DeviceTaskServiceImpl.java | 132 +++- .../plan/mapper/ProOrderWorkorderMapper.java | 4 + .../impl/ProOrderWorkorderServiceImpl.java | 82 ++- .../mapper/plan/ProOrderWorkorderMapper.xml | 14 + 9 files changed, 878 insertions(+), 17 deletions(-) create mode 100644 op-api/op-api-system/src/main/java/com/op/system/api/domain/device/EquPlanDTO.java diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/RemoteDeviceService.java b/op-api/op-api-system/src/main/java/com/op/system/api/RemoteDeviceService.java index 95aa6590..2a7f15b1 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/RemoteDeviceService.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/RemoteDeviceService.java @@ -3,6 +3,7 @@ package com.op.system.api; import com.op.common.core.constant.ServiceNameConstants; import com.op.common.core.domain.R; import com.op.system.api.domain.DataSourcePropertyDTO; +import com.op.system.api.domain.device.EquPlanDTO; import com.op.system.api.factory.RemoteDeviceFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; @@ -41,4 +42,8 @@ public interface RemoteDeviceService { @PostMapping("/deviceTask/removeDatasource") public R removeDatasource(@RequestBody DataSourcePropertyDTO dataSourceProperty); + + //切线后创建当日新的点检工单 + @PostMapping("/deviceTask/createSpotCheckWorkOrder") + public R createSpotCheckWorkOrder(@RequestBody EquPlanDTO equPlanDTO); } diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/domain/device/EquPlanDTO.java b/op-api/op-api-system/src/main/java/com/op/system/api/domain/device/EquPlanDTO.java new file mode 100644 index 00000000..4c0efaab --- /dev/null +++ b/op-api/op-api-system/src/main/java/com/op/system/api/domain/device/EquPlanDTO.java @@ -0,0 +1,633 @@ +package com.op.system.api.domain.device; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.op.common.core.annotation.Excel; +import com.op.common.core.web.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.util.Date; +import java.util.List; + +/** + * 计划对象 equ_plan + * + * @author Open Platform + * @date 2023-10-16 + */ +public class EquPlanDTO extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String planId; + + /** + * 计划编码 + */ + @Excel(name = "计划编码") + private String planCode; + + /** + * 计划名称 + */ + @Excel(name = "计划名称") + private String planName; + + /** + * 车间 + */ + @Excel(name = "车间编码") + private String planWorkshop; + + /** + * 产线 + */ + private String planProdLine; + + /** + * 设备名称 + */ + private String equipmentName; + + /** + * 设备编码 + */ + private String equipmentCode; + + /** + * 循环周期 + */ + @Excel(name = "循环周期") + private String planLoop; + + /** + * 循环周期类型 + */ + @Excel(name = "循环周期类型") + private String planLoopType; + + /** + * 循环执行时间开始 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "循环执行时间开始", width = 30, dateFormat = "yyyy-MM-dd") + private Date planLoopStart; + + /** + * 循环执行时间结束 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "循环执行时间结束", width = 30, dateFormat = "yyyy-MM-dd") + private Date planLoopEnd; + + /** + * 巡检人员 + */ + private String planPerson; + + /** + * 计划状态 + */ + @Excel(name = "计划状态") + private String planStatus; + + /** + * 是否可生产-限制 + */ + @Excel(name = "是否可生产-限制") + private String planRestrict; + + /** + * 维护类型 + */ + private String planType; + + /** + * 是否委外 + */ + private String planOutsource; + + /** + * 委外工单编码 + */ + @Excel(name = "委外工单编码") + private String workCode; + + /** + * 工厂 + */ + @Excel(name = "工厂") + private String factoryCode; + + /** + * 备用字段1 + */ + private String attr1; + + /** + * 备用字段2 + */ + private String attr2; + + /** + * 备用字段3 + */ + private String attr3; + + /** + * 删除标志 + */ + private String delFlag; + + // 创建日期范围list + private List createTimeArray; + + // 更新日期范围list + private List updateTimeArray; + + // 更新日期开始 + private String updateTimeStart; + + // 更新日期结束 + private String updateTimeEnd; + + // 创建日期开始 + private String createTimeStart; + + // 创建日期结束 + private String createTimeEnd; + + private List planTimeArray; + + private List personListVO; + + private String workCenterName; + + // 保养类型 + @Excel(name = "保养类型") + private String upkeep; + + // 计划保养时间计算规则 + private String calculationRule; + + // 是否停机保养 + @Excel(name = "是否停机保养") + private String shutDown; + private String planEquId; + + private List loopStartArray; + + private Date loopStart; + + private Date loopEnd; + + private List loopEndArray; + + private Date loopEndArrayStart; + + private Date getLoopEndArrayEnd; + + @Excel(name = "委外人员") + private String workPerson; + + @Excel(name = "委外单位") + private String workOutsourcingUnit; + + @Excel(name = "联系方式") + private String workConnection; + + @Excel(name = "委外原因") + private String workReason; + + //jgy 新增 生产线体编码 每天生成线体信息的时候只生成计划生产的 + private String lineCode; + private List lineCodes; + private String workOrderCode;//工单号 + private String changeLineType;//切线类型 + + public String getWorkOutsourcingUnit() { + return workOutsourcingUnit; + } + + public void setWorkOutsourcingUnit(String workOutsourcingUnit) { + this.workOutsourcingUnit = workOutsourcingUnit; + } + + public String getWorkConnection() { + return workConnection; + } + + public void setWorkConnection(String workConnection) { + this.workConnection = workConnection; + } + + public String getWorkReason() { + return workReason; + } + + public void setWorkReason(String workReason) { + this.workReason = workReason; + } + + public String getWorkPerson() { + return workPerson; + } + + public void setWorkPerson(String workPerson) { + this.workPerson = workPerson; + } + + public List getLoopEndArray() { + return loopEndArray; + } + + public void setLoopEndArray(List loopEndArray) { + this.loopEndArray = loopEndArray; + } + + public Date getLoopEndArrayStart() { + return loopEndArrayStart; + } + + public void setLoopEndArrayStart(Date loopEndArrayStart) { + this.loopEndArrayStart = loopEndArrayStart; + } + + public Date getGetLoopEndArrayEnd() { + return getLoopEndArrayEnd; + } + + public void setGetLoopEndArrayEnd(Date getLoopEndArrayEnd) { + this.getLoopEndArrayEnd = getLoopEndArrayEnd; + } + + public Date getLoopEnd() { + return loopEnd; + } + + public void setLoopEnd(Date loopEnd) { + this.loopEnd = loopEnd; + } + + public Date getLoopStart() { + return loopStart; + } + + public void setLoopStart(Date loopStart) { + this.loopStart = loopStart; + } + + public List getLoopStartArray() { + return loopStartArray; + } + + public void setLoopStartArray(List loopStartArray) { + this.loopStartArray = loopStartArray; + } + + public String getPlanEquId() { + return planEquId; + } + + public void setPlanEquId(String planEquId) { + this.planEquId = planEquId; + } + + public String getUpkeep() { + return upkeep; + } + + public void setUpkeep(String upkeep) { + this.upkeep = upkeep; + } + + public String getCalculationRule() { + return calculationRule; + } + + public void setCalculationRule(String calculationRule) { + this.calculationRule = calculationRule; + } + + public String getShutDown() { + return shutDown; + } + + public void setShutDown(String shutDown) { + this.shutDown = shutDown; + } + + public String getWorkCenterName() { + return workCenterName; + } + + public void setWorkCenterName(String workCenterName) { + this.workCenterName = workCenterName; + } + + public List getPersonListVO() { + return personListVO; + } + + public void setPersonListVO(List personListVO) { + this.personListVO = personListVO; + } + + public List getPlanTimeArray() { + return planTimeArray; + } + + public void setPlanTimeArray(List planTimeArray) { + this.planTimeArray = planTimeArray; + } + + public List getCreateTimeArray() { + return createTimeArray; + } + + public void setCreateTimeArray(List createTimeArray) { + this.createTimeArray = createTimeArray; + } + + public List getUpdateTimeArray() { + return updateTimeArray; + } + + public void setUpdateTimeArray(List updateTimeArray) { + this.updateTimeArray = updateTimeArray; + } + + public String getUpdateTimeStart() { + return updateTimeStart; + } + + public void setUpdateTimeStart(String updateTimeStart) { + this.updateTimeStart = updateTimeStart; + } + + public String getUpdateTimeEnd() { + return updateTimeEnd; + } + + public void setUpdateTimeEnd(String updateTimeEnd) { + this.updateTimeEnd = updateTimeEnd; + } + + public String getCreateTimeStart() { + return createTimeStart; + } + + public void setCreateTimeStart(String createTimeStart) { + this.createTimeStart = createTimeStart; + } + + public String getCreateTimeEnd() { + return createTimeEnd; + } + + public void setCreateTimeEnd(String createTimeEnd) { + this.createTimeEnd = createTimeEnd; + } + + public void setPlanId(String planId) { + this.planId = planId; + } + + public String getPlanId() { + return planId; + } + + public void setPlanCode(String planCode) { + this.planCode = planCode; + } + + public String getPlanCode() { + return planCode; + } + + public void setPlanName(String planName) { + this.planName = planName; + } + + public String getPlanName() { + return planName; + } + + public void setPlanWorkshop(String planWorkshop) { + this.planWorkshop = planWorkshop; + } + + public String getPlanWorkshop() { + return planWorkshop; + } + + public void setPlanProdLine(String planProdLine) { + this.planProdLine = planProdLine; + } + + public String getPlanProdLine() { + return planProdLine; + } + + public void setEquipmentName(String equipmentName) { + this.equipmentName = equipmentName; + } + + public String getEquipmentName() { + return equipmentName; + } + + public void setEquipmentCode(String equipmentCode) { + this.equipmentCode = equipmentCode; + } + + public String getEquipmentCode() { + return equipmentCode; + } + + public void setPlanLoop(String planLoop) { + this.planLoop = planLoop; + } + + public String getPlanLoop() { + return planLoop; + } + + public void setPlanLoopType(String planLoopType) { + this.planLoopType = planLoopType; + } + + public String getPlanLoopType() { + return planLoopType; + } + + public void setPlanLoopStart(Date planLoopStart) { + this.planLoopStart = planLoopStart; + } + + public Date getPlanLoopStart() { + return planLoopStart; + } + + public void setPlanLoopEnd(Date planLoopEnd) { + this.planLoopEnd = planLoopEnd; + } + + public Date getPlanLoopEnd() { + return planLoopEnd; + } + + public void setPlanPerson(String planPerson) { + this.planPerson = planPerson; + } + + public String getPlanPerson() { + return planPerson; + } + + public void setPlanStatus(String planStatus) { + this.planStatus = planStatus; + } + + public String getPlanStatus() { + return planStatus; + } + + public void setPlanRestrict(String planRestrict) { + this.planRestrict = planRestrict; + } + + public String getPlanRestrict() { + return planRestrict; + } + + public void setPlanType(String planType) { + this.planType = planType; + } + + public String getPlanType() { + return planType; + } + + public void setPlanOutsource(String planOutsource) { + this.planOutsource = planOutsource; + } + + public String getPlanOutsource() { + return planOutsource; + } + + public void setWorkCode(String workCode) { + this.workCode = workCode; + } + + public String getWorkCode() { + return workCode; + } + + public void setFactoryCode(String factoryCode) { + this.factoryCode = factoryCode; + } + + public String getFactoryCode() { + return factoryCode; + } + + public void setAttr1(String attr1) { + this.attr1 = attr1; + } + + public String getAttr1() { + return attr1; + } + + public void setAttr2(String attr2) { + this.attr2 = attr2; + } + + public String getAttr2() { + return attr2; + } + + public void setAttr3(String attr3) { + this.attr3 = attr3; + } + + public String getAttr3() { + return attr3; + } + + public void setDelFlag(String delFlag) { + this.delFlag = delFlag; + } + + public String getDelFlag() { + return delFlag; + } + + public void setLineCode(String lineCode) { + this.lineCode = lineCode; + } + + public String getLineCode() { + return lineCode; + } + + public void setLineCodes(List lineCodes) { + this.lineCodes = lineCodes; + } + + public List getLineCodes() { + return lineCodes; + } + + public void setWorkOrderCode(String workOrderCode) { + this.workOrderCode = workOrderCode; + } + + public String getWorkOrderCode() { + return workOrderCode; + } + + public void setChangeLineType(String changeLineType) { + this.changeLineType = changeLineType; + } + + public String getChangeLineType() { + return changeLineType; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("planId", getPlanId()) + .append("planCode", getPlanCode()) + .append("planName", getPlanName()) + .append("planWorkshop", getPlanWorkshop()) + .append("planProdLine", getPlanProdLine()) + .append("equipmentName", getEquipmentName()) + .append("equipmentCode", getEquipmentCode()) + .append("planLoop", getPlanLoop()) + .append("planLoopType", getPlanLoopType()) + .append("planLoopStart", getPlanLoopStart()) + .append("planLoopEnd", getPlanLoopEnd()) + .append("planPerson", getPlanPerson()) + .append("planStatus", getPlanStatus()) + .append("planRestrict", getPlanRestrict()) + .append("planType", getPlanType()) + .append("planOutsource", getPlanOutsource()) + .append("workCode", getWorkCode()) + .append("factoryCode", getFactoryCode()) + .append("attr1", getAttr1()) + .append("attr2", getAttr2()) + .append("attr3", getAttr3()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteDeviceFallbackFactory.java b/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteDeviceFallbackFactory.java index 866b659c..f7d224d5 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteDeviceFallbackFactory.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteDeviceFallbackFactory.java @@ -57,6 +57,11 @@ public class RemoteDeviceFallbackFactory implements FallbackFactory addSpotCheckTask = new ArrayList<>(); + /** * 根据点检计划生成点检任务 **/ @@ -263,6 +280,100 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService { logger.info("++++++++++++" + poolName + "++++点检结束++++++++++"); } + //切线后 创建点检工单 + public AjaxResult createSpotCheckWorkOrder(com.op.system.api.domain.device.EquPlanDTO equPlanDTO) { + DynamicDataSourceContextHolder.push(equPlanDTO.getFactoryCode());// 这是数据源的key + logger.info(equPlanDTO.getFactoryCode() + "工厂切线接口传输参数:" + JSONArray.toJSONString(equPlanDTO)); + DynamicDataSourceContextHolder.push(equPlanDTO.getFactoryCode());// 这是数据源的key + EquPlan equPlan = new EquPlan(); + equPlan.setPlanType("spotInspection"); + List plans = deviceTaskMapper.getPlans(equPlan);//所有的 + List changeLineCodeList = equPlanDTO.getLineCodes();//切线后的实际传过来的要新增的产线信息 + List addProducePlans = new ArrayList<>();//切线后,真正能生成的生产线 下面的设备的点检计划 + List addProduceLine = new ArrayList<>();//真正能生成的切线生产线 + + if(!CollectionUtils.isEmpty(changeLineCodeList) && !CollectionUtils.isEmpty(plans)){ + for(String lineCode : changeLineCodeList){ + for(EquPlan plan : plans){ + if(!StringUtils.isBlank(plan.getLineCode())){ + if(plan.getLineCode().equals(lineCode)){ + addProducePlans.add(plan); + logger.info(equPlanDTO.getFactoryCode() + "工厂切线后新生成计划信息:" + JSONArray.toJSONString(plan)); + addProduceLine.add(lineCode); + } + } + } + } + } + addProduceLine = addProduceLine.stream().distinct().collect(Collectors.toList()); + logger.info(equPlanDTO.getFactoryCode() + "工厂切线后新生成产线:" + JSONArray.toJSONString(addProduceLine)); + addSpotCheckTask = new ArrayList<>(); + + for (EquPlan plan : addProducePlans) { + EquOrder hasTask = deviceTaskMapper.getNewTaskOrder(plan); + if (hasTask == null || Integer.parseInt(plan.getPlanLoop()) <= hasTask.getDays() || checkHourTask(hasTask, plan)) { + //生成点检计划 + int m = this.createOrderPlan(plan); + if (m == 0) { + error("equ_order相关添加失败"); + return error(); + }else{ + + } + } + } + + logger.info("++++++++++++" + equPlanDTO.getFactoryCode() + "++++切线后创建微信提醒开始++++++++++"); + this.spotCheckSendWeChat(addProduceLine,equPlanDTO); + logger.info("++++++++++++" + equPlanDTO.getFactoryCode() + "++++切线后创建微信提醒结束++++++++++"); + logger.info("++++++++++++" + equPlanDTO.getFactoryCode() + "++++切线后创建点检工单流程结束++++++++++"); + return success(); + } + + private void spotCheckSendWeChat(List addProduceLine, EquPlanDTO equPlanDTO) { + //发企业微信--------------------开始(跟班组有关) + SimpleDateFormat myFmt=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒"); //规范时间格式 + SysNoticeGroup noticeQo = new SysNoticeGroup(); + noticeQo.setNoticeId(24L); //id写死了? + 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("${productLineCode}", addProduceLine + "")//产线 + .replace("${changeLineType}", equPlanDTO.getChangeLineType())//切线类型 + .replace("${orderCode}", addSpotCheckTask + "")//点检工单号 + .replace("${workOrderCode}", equPlanDTO.getWorkOrderCode());//工单号 + + //替换标签 + Pattern p= Pattern.compile("<[^>]+>"); + Matcher m = p.matcher(contentInfo); + contentInfo = m.replaceAll(""); + + wechart0.setText(contentInfo); + wecharts.add(wechart0); + } + logger.info(equPlanDTO.getChangeLineType()+ "后,企业微信提醒维修请求:" + JSONObject.toJSONString(wecharts)); + if (!CollectionUtils.isEmpty(wecharts)) { + new Thread(() -> { + AjaxResult wxResult = remoteOpenService.sendWeChartMessage(wecharts); + logger.info("企业微信返回结果:" + JSONObject.toJSONString(wxResult)); + }).start(); + + } + logger.info("企业微信发送维修信息成功!"); + } + } + public void createPatrolCheckPlanFunc(String poolName) { DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key /**equ_plan equ_plan_equ**/ @@ -345,6 +456,7 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService { /**equ_order**/ sce = equOrderMapper.insertEquOrder(order); + addSpotCheckTask.add(orderCode);//新增点检任务 System.out.println(plan.getPlanCode() + "========equ_order:" + sce); /**equ_plan_equ_spare->equ_spare_apply*************************************************************/ EquPlanEquSpare equPlanEquSpare = new EquPlanEquSpare(); @@ -564,17 +676,11 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService { List produceLine = new ArrayList<>(); for(String str : planProduceLine){ - str = str.substring(1, str.length() - 1); - String[] subArrays = str.split("],\\["); - for (String subArrayStr : subArrays) { - subArrayStr = subArrayStr.substring(1, subArrayStr.length() - 1); - String[] parts = subArrayStr.split("\",\""); - for (int i = 1 ; i < parts.length ; i++) { - if(i == parts.length - 1){ - planProduceLineCode.add(parts[i].replaceAll("\"", "")); - }else{ - planProduceLineCode.add(parts[i]); - } + JSONArray array = JSONArray.parseArray(str); + for (int i = 0; i < array.size(); i++) { + JSONArray subArray = (JSONArray) array.get(i); + for (int j = 1; j < subArray.size(); j++) { + planProduceLineCode.add(subArray.get(j).toString()); } } } @@ -595,8 +701,8 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService { } produceLine = produceLine.stream().distinct().collect(Collectors.toList()); - logger.info(poolName + "工厂今日生成的产线:" + JSONArray.toJSONString(produceLine)); - logger.info(poolName + "工厂返回生成今日生产的产线点检计划信息:" + JSONArray.toJSONString(returnPlanList)); + logger.info("工厂:" + poolName + ",时间:" + DateUtils.getDate() + ",今日生产的产线:" + JSONArray.toJSONString(produceLine)); + logger.info("工厂:" + poolName + ",时间:" + DateUtils.getDate() + "凌晨,返回今日生成的点检计划信息:" + JSONArray.toJSONString(returnPlanList)); return returnPlanList; } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderWorkorderMapper.java b/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderWorkorderMapper.java index 6bdac342..7e538326 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderWorkorderMapper.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderWorkorderMapper.java @@ -260,5 +260,9 @@ public interface ProOrderWorkorderMapper { List getBatchList(String workorderId); int bpAddBatch(@Param("list") List orders); + + String getPreviousLineCode(String workorderId);//查询之前的产线 + + String getPlanLineCodes(String workorderId); } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderWorkorderServiceImpl.java b/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderWorkorderServiceImpl.java index 70055aa0..0011ea35 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderWorkorderServiceImpl.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderWorkorderServiceImpl.java @@ -21,8 +21,9 @@ import com.op.plan.domain.dto.SplitOrderDTO; import com.op.plan.domain.vo.CascaderDTO; import com.op.plan.mapper.*; import com.op.plan.service.IProOrderWorkorderService; +import com.op.system.api.RemoteDeviceService; import com.op.system.api.RemoteSapService; -import com.op.system.api.domain.SysSapLog; +import com.op.system.api.domain.device.EquPlanDTO; import com.op.system.api.domain.dto.MesPrepareDTO; import com.op.system.api.domain.dto.MesPrepareDetailDTO; import com.op.system.api.domain.sap.*; @@ -73,6 +74,9 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService { @Autowired private ProWhiteOrderMapper proWhiteOrderMapper; + @Autowired + private RemoteDeviceService remoteDeviceService; + /** * 查询生产工单 * @@ -926,6 +930,9 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService { @DS("#header.poolName") @Transactional public AjaxResult subChangeWorkOrderPro(SplitOrderDTO splitOrderDTO) { + //jgy 设备新增 + String planLineCodes = proOrderWorkorderMapper.getPlanLineCodes(splitOrderDTO.getProOrderWorkorder().getWorkorderId());//查询之前计划的产线范围 + // 获得子工单对象——(这里没有用BeanUtils是因为若依与这个冲突造成死循环得到错误的结果) ProOrderWorkorder proWorkOrder = splitOrderDTO.getProOrderWorkorder(); @@ -1095,10 +1102,14 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService { run = false; } } + + /*************************************设备模块 - 判断是否要生成新的点检工单开始************************************/ + String changeLineType = "工单切线"; + this.checkWhetherGenerateNewWorkOrder(splitOrderDTO , planLineCodes , changeLineType); + /*************************************设备模块 - 判断是否要生成新的点检工单结束************************************/ return success("变更成功"); } - return error(500, "批次号不能重复"); } @@ -1731,6 +1742,10 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService { @DS("#header.poolName") @Transactional public AjaxResult subChangeWorkOrderM(SplitOrderDTO splitOrderDTO) { + //jgy 设备新增 + //String previousLineCode = proOrderWorkorderMapper.getPreviousLineCode(splitOrderDTO.getProOrderWorkorder().getWorkorderId());//查询之前真正生产的产线 + String planLineCodes = proOrderWorkorderMapper.getPlanLineCodes(splitOrderDTO.getProOrderWorkorder().getWorkorderId());//查询之前计划的产线范围 + ProOrderWorkorder proWorkOrder = splitOrderDTO.getProOrderWorkorder(); proWorkOrder.setProdLineCode(JSONArray.toJSONString(splitOrderDTO.getProdLineCodeArray())); proWorkOrder.setUpdateBy(SecurityUtils.getUsername()); @@ -1750,9 +1765,72 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService { sonWorkOrder = proOrderWorkorderMapper.getSonWorkOrder(sonWorkOrder); } } + + /*************************************设备模块 - 判断是否要生成新的点检工单开始************************************/ + String changeLineType = "切线调拨"; + this.checkWhetherGenerateNewWorkOrder(splitOrderDTO,planLineCodes,changeLineType); + /*************************************设备模块 - 判断是否要生成新的点检工单结束************************************/ return success("变更成功"); } + private void checkWhetherGenerateNewWorkOrder(SplitOrderDTO splitOrderDTO, String planLineCodes,String changeLineType) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String key = "#header.poolName"; + String poolName = request.getHeader(key.substring(8)); + + String [][] currentLineCodes = splitOrderDTO.getProdLineCodeArray();//现在的产线列表 + List currentLines = new ArrayList<>(); + List previousLines = new ArrayList<>(); + List addLines = new ArrayList<>();//新增的需要生成的产线 + + //处理现在的产线信息 prod_line_code + if(currentLineCodes.length > 0){ + for (int i = 0; i < currentLineCodes.length; i++) { + for (int j = 1; j < currentLineCodes[i].length; j++) { + currentLines.add(currentLineCodes[i][j]); + } + } + } + + //解析之前的 prod_line_code + if(!StringUtils.isBlank(planLineCodes)){ + JSONArray array = JSONArray.parseArray(planLineCodes); + for (int i = 0; i < array.size(); i++) { + JSONArray subArray = (JSONArray) array.get(i); + for (int j = 1; j < subArray.size(); j++) { + previousLines.add(subArray.get(j).toString()); + } + } + } + + //找出新增的 + for (String item : currentLines) { + if (!previousLines.contains(item)) { + addLines.add(item); + } +// if(StringUtils.isNotBlank(previousLineCode)){ +// if(!previousLineCode.equals(item)){ +// addLines.add(item); +// } +// } + } + + //去重 + addLines = addLines.stream().distinct().collect(Collectors.toList()); + + if(!CollectionUtils.isEmpty(addLines)){//如果 现在的产线是空 以前可能是空的 也可能不是空的 证明没有进行切线 + EquPlanDTO equPlanDTO = new EquPlanDTO(); + equPlanDTO.setWorkOrderCode(splitOrderDTO.getProOrderWorkorder().getWorkorderCode()); + equPlanDTO.setFactoryCode(poolName); + equPlanDTO.setLineCodes(addLines); + equPlanDTO.setChangeLineType(changeLineType); + logger.info(poolName + "工厂进行切线,生成产线" + addLines + "的新点检信息"); + remoteDeviceService.createSpotCheckWorkOrder(equPlanDTO); + }else{ + logger.info(poolName + "工厂进行切线,没有新产线需要点检。"); + } + } + public static void main(String args[]) { String s = "000800003044"; System.out.println(s.substring(3)); diff --git a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderMapper.xml b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderMapper.xml index 3f8b83cd..0d8e8edf 100644 --- a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderMapper.xml +++ b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderMapper.xml @@ -1093,4 +1093,18 @@ and del_flag = '0' + + + +