2024-11-06 MES+sys API+Device 三个模块 生产工单切线、切线调拨产生新设备点检任务

master
元气满满(jgy) 5 months ago
parent 3535c84db7
commit 0284c08961

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

@ -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<Date> createTimeArray;
// 更新日期范围list
private List<Date> updateTimeArray;
// 更新日期开始
private String updateTimeStart;
// 更新日期结束
private String updateTimeEnd;
// 创建日期开始
private String createTimeStart;
// 创建日期结束
private String createTimeEnd;
private List<Date> planTimeArray;
private List<String> personListVO;
private String workCenterName;
// 保养类型
@Excel(name = "保养类型")
private String upkeep;
// 计划保养时间计算规则
private String calculationRule;
// 是否停机保养
@Excel(name = "是否停机保养")
private String shutDown;
private String planEquId;
private List<Date> loopStartArray;
private Date loopStart;
private Date loopEnd;
private List<Date> 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<String> 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<Date> getLoopEndArray() {
return loopEndArray;
}
public void setLoopEndArray(List<Date> 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<Date> getLoopStartArray() {
return loopStartArray;
}
public void setLoopStartArray(List<Date> 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<String> getPersonListVO() {
return personListVO;
}
public void setPersonListVO(List<String> personListVO) {
this.personListVO = personListVO;
}
public List<Date> getPlanTimeArray() {
return planTimeArray;
}
public void setPlanTimeArray(List<Date> planTimeArray) {
this.planTimeArray = planTimeArray;
}
public List<Date> getCreateTimeArray() {
return createTimeArray;
}
public void setCreateTimeArray(List<Date> createTimeArray) {
this.createTimeArray = createTimeArray;
}
public List<Date> getUpdateTimeArray() {
return updateTimeArray;
}
public void setUpdateTimeArray(List<Date> 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<String> lineCodes) {
this.lineCodes = lineCodes;
}
public List<String> 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();
}
}

@ -57,6 +57,11 @@ public class RemoteDeviceFallbackFactory implements FallbackFactory<RemoteDevice
public R removeDatasource(DataSourcePropertyDTO dataSourceProperty) {
return R.fail("设备数据源移除失败:" + throwable.getMessage());
}
@Override
public R createSpotCheckWorkOrder(com.op.system.api.domain.device.EquPlanDTO equPlanDTO) {
return R.fail("切换产线,新增点检工单失败:" + throwable.getMessage());
}
};
}
}

@ -8,6 +8,7 @@ import com.op.common.datasource.creator.DynamicDatasourceCreator;
import com.op.device.service.IDeviceTaskService;
import com.op.system.api.domain.DataSourcePropertyDTO;
import com.op.common.core.utils.bean.BeanUtils;
import com.op.system.api.domain.device.EquPlanDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -116,4 +117,18 @@ public class DeviceTaskController {
dynamicRoutingDataSource.removeDataSource(dataSourceProperty.getPoolName());
return R.ok();
}
/**
* 线
*
* @return
*/
@PostMapping("/createSpotCheckWorkOrder")
public R createSpotCheckWorkOrder(@RequestBody EquPlanDTO equPlanDTO) {
AjaxResult result = taskService.createSpotCheckWorkOrder(equPlanDTO);
if (result.isSuccess()) {
return R.ok("切线后新点检工单生成成功");
}
return R.fail("切线后新点检工单生成失败");
}
}

@ -1,8 +1,7 @@
package com.op.device.service;
import com.op.common.core.domain.R;
import com.op.common.core.web.domain.AjaxResult;
import com.op.device.domain.EquPlan;
import com.op.system.api.domain.device.EquPlanDTO;
/**
* TaskService
@ -21,4 +20,6 @@ public interface IDeviceTaskService {
AjaxResult createEquipmentOperationTask();
AjaxResult equipmentBKTask();
AjaxResult createSpotCheckWorkOrder(EquPlanDTO equPlanDTO);//切线后创建新的点检工单
}

@ -1,6 +1,7 @@
package com.op.device.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils;
@ -10,8 +11,12 @@ import com.op.common.core.web.domain.AjaxResult;
import com.op.device.domain.*;
import com.op.device.mapper.*;
import com.op.device.service.IDeviceTaskService;
import com.op.system.api.RemoteOpenService;
import com.op.system.api.RemoteUserService;
import com.op.system.api.domain.SysNoticeGroup;
import com.op.system.api.domain.SysUser;
import com.op.system.api.domain.device.EquPlanDTO;
import com.op.system.api.domain.dto.WechartDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
@ -19,12 +24,15 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
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;
@ -81,6 +89,15 @@ public class DeviceTaskServiceImpl implements IDeviceTaskService {
@Autowired
private EquOperationMapper equOperationMapper;
@Autowired
private EquRepairOrderMapper equRepairOrderMapper;
@Autowired
private RemoteOpenService remoteOpenService;
//全局变量
private List<String> 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<EquPlan> plans = deviceTaskMapper.getPlans(equPlan);//所有的
List<String> changeLineCodeList = equPlanDTO.getLineCodes();//切线后的实际传过来的要新增的产线信息
List<EquPlan> addProducePlans = new ArrayList<>();//切线后,真正能生成的生产线 下面的设备的点检计划
List<String> 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<String> addProduceLine, EquPlanDTO equPlanDTO) {
//发企业微信--------------------开始(跟班组有关)
SimpleDateFormat myFmt=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒"); //规范时间格式
SysNoticeGroup noticeQo = new SysNoticeGroup();
noticeQo.setNoticeId(24L); //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();
//在前端填的时候,需要判空!!!!!!
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<String> 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;
}

@ -260,5 +260,9 @@ public interface ProOrderWorkorderMapper {
List<String> getBatchList(String workorderId);
int bpAddBatch(@Param("list") List<ProOrder> orders);
String getPreviousLineCode(String workorderId);//查询之前的产线
String getPlanLineCodes(String workorderId);
}

@ -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<String> currentLines = new ArrayList<>();
List<String> previousLines = new ArrayList<>();
List<String> 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));

@ -1093,4 +1093,18 @@
and del_flag = '0'
</update>
<select id="getPreviousLineCode" resultType = "java.lang.String">
select workorder_name
from pro_order_workorder
where workorder_id = #{workorderId}
and del_flag = '0'
</select>
<select id="getPlanLineCodes" resultType = "java.lang.String">
select prod_line_code
from pro_order_workorder
where workorder_id = #{workorderId}
and del_flag = '0'
</select>
</mapper>

Loading…
Cancel
Save