From 42b0c4622dcb14f4764dfccf1eb939d14eb52703 Mon Sep 17 00:00:00 2001 From: zhaoxiaolin Date: Fri, 3 Nov 2023 14:21:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E5=88=92bug+=E6=8A=A5=E5=B7=A5?= =?UTF-8?q?=E4=B8=8A=E4=BD=8D=E6=9C=BA=E6=8E=A5=E5=8F=A3=E6=8F=90=E4=BE=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/op/system/api/domain/sap/SapRFW.java | 9 ++ .../src/main/java/com/op/job/task/RyTask.java | 2 +- .../controller/WCSInterfaceController.java | 14 ++++ .../java/com/op/mes/mapper/MesMapper.java | 3 + .../op/mes/mapper/MesReportWorkMapper.java | 4 + .../op/mes/service/IWCSInterfaceService.java | 3 + .../service/impl/IWCInterfaceServiceImpl.java | 82 +++++++++++++++++++ .../service/impl/MesPrepareServiceImpl.java | 15 ++-- .../impl/MesReportWorkServiceImpl.java | 4 + .../main/resources/mapper/mes/MesMapper.xml | 6 ++ .../mapper/mes/MesReportWorkMapper.xml | 18 ++++ .../plan/controller/ProOrderController.java | 10 +++ .../ProOrderWorkorderController.java | 8 +- .../java/com/op/plan/domain/ProOrder.java | 20 ++++- .../com/op/plan/domain/ProOrderWorkorder.java | 9 ++ .../com/op/plan/domain/dto/ProOrderDTO.java | 10 +++ .../com/op/plan/domain/dto/SplitOrderDTO.java | 9 ++ .../plan/mapper/ProOrderWorkorderMapper.java | 2 + .../com/op/plan/service/IProOrderService.java | 2 + .../service/impl/ProOrderServiceImpl.java | 66 ++++++--------- .../impl/ProOrderWorkorderServiceImpl.java | 9 +- .../mapper/plan/ProOrderWorkorderMapper.xml | 11 ++- 22 files changed, 253 insertions(+), 63 deletions(-) diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/domain/sap/SapRFW.java b/op-api/op-api-system/src/main/java/com/op/system/api/domain/sap/SapRFW.java index 8d6eb22b..491981d4 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/domain/sap/SapRFW.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/domain/sap/SapRFW.java @@ -142,4 +142,13 @@ public class SapRFW { '}'; } } + @Override + public String toString() { + return "{" + + "aufnr:"+aufnr+","+ + "gamng:"+gamng+","+ + "lt_gs:"+lt_gs.toString()+","+ + "lt_hw:"+lt_hw.toString()+","+ + "}"; + } } diff --git a/op-modules/op-job/src/main/java/com/op/job/task/RyTask.java b/op-modules/op-job/src/main/java/com/op/job/task/RyTask.java index 4d8617b0..a1afab77 100644 --- a/op-modules/op-job/src/main/java/com/op/job/task/RyTask.java +++ b/op-modules/op-job/src/main/java/com/op/job/task/RyTask.java @@ -73,7 +73,7 @@ public class RyTask { remotePlanService.syncSAPOrders(); } - /**每5分钟报工一次**/ + /**每5分钟报工一次(废弃)**/ public void reportWorkTask(){ logger.info("++报工接口+开始++reportWorkTask+++++"); remoteMesService.reportWorkTask(); diff --git a/op-modules/op-mes/src/main/java/com/op/mes/controller/WCSInterfaceController.java b/op-modules/op-mes/src/main/java/com/op/mes/controller/WCSInterfaceController.java index 3221eee7..30c10a78 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/controller/WCSInterfaceController.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/controller/WCSInterfaceController.java @@ -6,6 +6,7 @@ import com.op.common.core.web.controller.BaseController; import com.op.common.core.web.domain.AjaxResult; import com.op.common.log.annotation.Log; import com.op.common.log.enums.BusinessType; +import com.op.mes.domain.MesReportWork; import com.op.mes.domain.dto.BaseEquipmentDto; import com.op.mes.domain.dto.LGInfoDto; import com.op.system.api.domain.dto.BoardDTO; @@ -102,6 +103,19 @@ public class WCSInterfaceController extends BaseController { } return success(wCInterfaceService.getMesBoardEquProductionToday(boardDTO)); } + + /**上位机报工**/ + @PostMapping("/reportWork") + public AjaxResult reportWork(@RequestBody MesReportWork mesReportWork) { + if(StringUtils.isBlank(mesReportWork.getFactoryCode())){ + return error("[factoryCode] is null"); + } + if(StringUtils.isBlank(mesReportWork.getReportCode())){ + return error("[reportCode] is null"); + } + return success(wCInterfaceService.reportWork(mesReportWork)); + } + /************************************************************/ /****************************数据库清理************************/ /************************************************************/ diff --git a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesMapper.java b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesMapper.java index e01e5f29..874ea270 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesMapper.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesMapper.java @@ -3,6 +3,7 @@ package com.op.mes.mapper; import com.op.mes.domain.dto.BaseEquipmentDto; import com.op.mes.domain.dto.LGInfoDto; import com.op.system.api.domain.SysDept; +import com.op.system.api.domain.SysSapLog; import com.op.system.api.domain.dto.BoardDTO; import com.op.system.api.domain.dto.WCSDTO; import com.op.system.api.domain.dto.WCSDataItemsDTO; @@ -48,4 +49,6 @@ public interface MesMapper { void deleteBkDateByTable(@Param("startDate") String startDate, @Param("endDate")String endDate); void deleteBkDate(@Param("table")String addMonthTable,@Param("startDate") String startDate, @Param("endDate")String endDate); + + void addSapLog(SysSapLog sysSapLog); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesReportWorkMapper.java b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesReportWorkMapper.java index c6c8177f..575ddcd8 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesReportWorkMapper.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesReportWorkMapper.java @@ -89,4 +89,8 @@ public interface MesReportWorkMapper { List getEquNames(MesHourReport mesHourReport); List selectProShift(); + + MesReportWork getProdResult(MesReportWork work); + + ProOrderWorkorder getOrderByCode(String workorderCode); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/IWCSInterfaceService.java b/op-modules/op-mes/src/main/java/com/op/mes/service/IWCSInterfaceService.java index 8b720e6f..c227a08b 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/IWCSInterfaceService.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/IWCSInterfaceService.java @@ -2,6 +2,7 @@ package com.op.mes.service; import com.op.common.core.domain.R; import com.op.common.core.web.domain.AjaxResult; +import com.op.mes.domain.MesReportWork; import com.op.mes.domain.MesShift; import com.op.mes.domain.dto.BaseEquipmentDto; import com.op.mes.domain.dto.LGInfoDto; @@ -33,4 +34,6 @@ public interface IWCSInterfaceService { R dataClearTask(List tables); R dataBKTask(List tables); + + R reportWork(MesReportWork mesReportWork); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java index f424345e..a335cbcc 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/IWCInterfaceServiceImpl.java @@ -6,25 +6,32 @@ import com.op.common.core.domain.R; import com.op.common.core.utils.DateUtils; import com.op.common.core.utils.bean.BeanUtils; import com.op.common.core.utils.uuid.IdUtils; +import com.op.mes.domain.MesReportWork; import com.op.mes.domain.MesShift; +import com.op.mes.domain.ProOrderWorkorder; import com.op.mes.domain.dto.LGInfoDto; import com.op.mes.mapper.MesMapper; import com.op.mes.mapper.MesReportWorkMapper; import com.op.mes.mapper.ProRfidProcessDetailMapper; import com.op.mes.service.IWCSInterfaceService; +import com.op.system.api.RemoteSapService; import com.op.system.api.RemoteUserService; import com.op.system.api.domain.SysDept; +import com.op.system.api.domain.SysSapLog; import com.op.system.api.domain.SysUser; import com.op.system.api.domain.dto.BoardDTO; import com.op.system.api.domain.dto.WCSDTO; import com.op.system.api.domain.dto.WCSDataDTO; import com.op.system.api.domain.mes.ProRfidProcessDetail; +import com.op.system.api.domain.sap.SapRFW; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import java.math.BigDecimal; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; @@ -54,6 +61,9 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService { @Autowired private RemoteUserService remoteUserService; + @Autowired + private RemoteSapService remoteSapService; + /**下一工序机台集合获取 * JSON * { @@ -259,6 +269,76 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService { return R.ok(true); } + @Override + public R reportWork(MesReportWork mesReportWork) { + DynamicDataSourceContextHolder.push("ds_"+mesReportWork.getFactoryCode());// 这是数据源的key + mesReportWork.setUploadStatus("1");//除了1报工成功的,都需要报工 + mesReportWork.setProdType("prod"); + List reportWorks = mesReportWorkMapper.getReportWorkList(mesReportWork); + if(CollectionUtils.isEmpty(reportWorks)){ + return R.fail("未查询报工单"); + } + + MesReportWork work = reportWorks.get(0); + SapRFW sapRFW = new SapRFW(); + sapRFW.setAufnr(work.getWorkorderCodeSap());//虚拟工单号 + sapRFW.setGamng(work.getQuantityFeedback().toString());//报工数量 + SapRFW.lt_gs ltgs = sapRFW.getLt_gs();//生产订单报工工时修改 + ltgs.setConf_activity1(work.getSac1());//人工 + ltgs.setConf_activity2(work.getSac2()); + ltgs.setConf_activity3(work.getSac3());//机器 + ltgs.setConf_activity4(work.getSac4()); + ltgs.setConf_activity5(work.getSac5());//折旧 + ltgs.setConf_activity6(work.getSac6()); + SapRFW.lt_hw lthw = sapRFW.getLt_hw();//MES生产订单报工货物移动修改 + lthw.setEntry_qnt(work.getQuantityFeedback().toString());//TODO; + lthw.setMaterial(work.getProcessCode()); + + //添加调用sap日志 + SysSapLog sysSapLog = new SysSapLog(); + sysSapLog.setId(IdUtils.fastSimpleUUID()); + sysSapLog.setMesssge(sapRFW.toString()); + sysSapLog.setMethod("reportWork"); + sysSapLog.setReqcode("请求"); + sysSapLog.setCreateTime(DateUtils.getNowDate()); + mesMapper.addSapLog(sysSapLog); + + R r = remoteSapService.sapRFWOrder(sapRFW); + //上传成功,更改mes_report_work状态 + if (r.getCode() == 200) { + work.setUploadStatus("1"); + } else { + work.setUploadStatus("2"); + work.setUploadMsg(r.getMsg()); + } + work.setUploadTime(DateUtils.getNowDate()); + mesReportWorkMapper.updateSyncSapStatus(work); + //工单完成数量>工单数量:关闭订单 + MesReportWork proResult = mesReportWorkMapper.getProdResult(work); + ProOrderWorkorder topOrder = this.getTopOrder(work.getWorkorderCode()); + if(proResult.getQuantityFeedback().compareTo(new BigDecimal(topOrder.getQuantitySplit()))>=0){ + //工单完成,关闭工单 + remoteSapService.sapCloseOrder(work.getOrderCode()); + work.setStatus("w4"); + work.setUpdateTime(DateUtils.getNowDate()); + //pro_work_order status->w4报工 + mesReportWorkMapper.updateWorkOrderStatus(work); + } + return R.ok(); + } + + //根据工单子单编码获取最顶级订单的母单 + private ProOrderWorkorder getTopOrder(String workorderCode) { + //pro_order_workorder + ProOrderWorkorder topOrder = mesReportWorkMapper.getOrderByCode(workorderCode); + while (!"0".equals(topOrder.getParentOrder()) && StringUtils.isNotEmpty(topOrder.getParentOrder())) { + //pro_order_workorder + topOrder = mesReportWorkMapper.getOrderByCode(topOrder.getParentOrder()); + } + return topOrder; + } + + public void dateBKFunc(String poolName,List tables){ DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key DateTimeFormatter ymdhms = DateTimeFormatter.ofPattern("yyyy-MM-dd"); @@ -322,6 +402,8 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService { return "保存成功条数:"+saveNum; } + + public static void main(String args[]){ DateTimeFormatter ymdhms = DateTimeFormatter.ofPattern("yyyy-MM-dd"); LocalDate today = LocalDate.now(); diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesPrepareServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesPrepareServiceImpl.java index 97f45a5d..a4d034cd 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesPrepareServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesPrepareServiceImpl.java @@ -236,8 +236,8 @@ public class MesPrepareServiceImpl implements IMesPrepareService { try { dateSources.forEach(dateSource -> { logger.info("++++++++++++" + dateSource.get("poolName") + "++++报工开始++++++++++"); - Runnable run = () -> reportWorkByFactory(dateSource.get("poolName")); - executorService.execute(run); + //Runnable run = () -> reportWorkByFactory(dateSource.get("poolName")); + //executorService.execute(run); }); } catch (Exception e) { logger.error("service == deviceOfflineTimingTask == exception", e); @@ -249,17 +249,16 @@ public class MesPrepareServiceImpl implements IMesPrepareService { } //报工 public void reportWorkByFactory(String poolName) { - DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key - MesReportWork mesReportWork = new MesReportWork(); + MesReportWork mesReportWork = new MesReportWork(); mesReportWork.setUploadStatus("1");//除了1报工成功的,都需要报工 mesReportWork.setProdType("prod"); List reportWorks = mesReportWorkMapper.getReportWorkList(mesReportWork); - for(MesReportWork work:reportWorks){ + for(MesReportWork work:reportWorks) { SapRFW sapRFW = new SapRFW(); sapRFW.setAufnr(work.getWorkorderCodeSap());//虚拟工单号 sapRFW.setGamng(work.getQuantityFeedback().toString());//报工数量 SapRFW.lt_gs ltgs = sapRFW.getLt_gs();//生产订单报工工时修改 - ltgs.setConf_activity1(work.getSac1()); + ltgs.setConf_activity1(work.getSac1());//人工 ltgs.setConf_activity2(work.getSac2()); ltgs.setConf_activity3(work.getSac3()); ltgs.setConf_activity4(work.getSac4()); @@ -270,9 +269,9 @@ public class MesPrepareServiceImpl implements IMesPrepareService { lthw.setMaterial(work.getProcessCode()); R r = remoteSapService.sapRFWOrder(sapRFW); //上传成功,更改mes_report_work状态 - if(r.getCode() == 200){ + if (r.getCode() == 200) { work.setUploadStatus("1"); - }else{ + } else { work.setUploadStatus("2"); work.setUploadMsg(r.getMsg()); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorkServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorkServiceImpl.java index 13963b84..40addf16 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorkServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorkServiceImpl.java @@ -12,6 +12,7 @@ import com.op.mes.domain.*; import com.op.mes.domain.dto.LineChartDto; import com.op.mes.domain.dto.LineChartSeriesDto; import com.op.mes.domain.dto.SysFactoryDto; +import com.op.mes.service.IWCSInterfaceService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.op.mes.mapper.MesReportWorkMapper; @@ -29,6 +30,8 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService { @Autowired private MesReportWorkMapper mesReportWorkMapper; + @Autowired + private IWCSInterfaceService iWCSInterfaceService; /** * 查询报工报表 * @@ -63,6 +66,7 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService { @DS("#header.poolName") public int insertMesReportWork(MesReportWork mesReportWork) { mesReportWork.setCreateTime(DateUtils.getNowDate()); + iWCSInterfaceService.reportWork(mesReportWork); return mesReportWorkMapper.insertMesReportWork(mesReportWork); } diff --git a/op-modules/op-mes/src/main/resources/mapper/mes/MesMapper.xml b/op-modules/op-mes/src/main/resources/mapper/mes/MesMapper.xml index 5c279053..c154fa4a 100644 --- a/op-modules/op-mes/src/main/resources/mapper/mes/MesMapper.xml +++ b/op-modules/op-mes/src/main/resources/mapper/mes/MesMapper.xml @@ -156,6 +156,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT TOP 0 * INTO ${tableNew} FROM mes_material_transfer_result + + insert into sys_sap_log + (id,messsge,create_time,reqcode,method,remark,status) + values( + #{id},#{messsge}, #{createTime}, #{reqcode},#{method},#{remark},#{status}) + + + + insert into mes_report_work diff --git a/op-modules/op-plan/src/main/java/com/op/plan/controller/ProOrderController.java b/op-modules/op-plan/src/main/java/com/op/plan/controller/ProOrderController.java index e819116b..d8c90655 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/controller/ProOrderController.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/controller/ProOrderController.java @@ -2,6 +2,7 @@ package com.op.plan.controller; import java.io.IOException; import java.util.ArrayList; +import java.util.Date; import java.util.List; import javax.servlet.http.HttpServletResponse; @@ -171,6 +172,15 @@ public class ProOrderController extends BaseController { return success(proOrderService.getProShifts()); } + /** + * 获取工单执行顺序 + * @return + */ + @PutMapping("/getProSortNo") + public int getProSortNo(@RequestBody ProOrder proOrder) { + return proOrderService.getProSortNo(proOrder); + } + /** * 通过工艺编码获取设备信息list * diff --git a/op-modules/op-plan/src/main/java/com/op/plan/controller/ProOrderWorkorderController.java b/op-modules/op-plan/src/main/java/com/op/plan/controller/ProOrderWorkorderController.java index 809bfc3f..ef9b4bb9 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/controller/ProOrderWorkorderController.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/controller/ProOrderWorkorderController.java @@ -158,7 +158,7 @@ public class ProOrderWorkorderController extends BaseController { @Log(title = "生产工单", businessType = BusinessType.DELETE) @DeleteMapping("/{workorderIds}") public AjaxResult remove(@PathVariable String[] workorderIds) { - //什么时候可以删除工单?TODO;没进入生产之前都可以? + //没进入生产之前都可以删除 // 根据工单的ids查工单的信息 List proOrderWorkorders = proOrderWorkorderService.selectProOrderWorkorderByWorkIds(workorderIds); if (ObjectUtils.isEmpty(proOrderWorkorders)) { @@ -195,15 +195,11 @@ public class ProOrderWorkorderController extends BaseController { } else { throw new ServiceException("工单已进行生产,不允许删除!"); } - // 判断是否含有湿料计划 boolean值(存在为true,不存在为false) -// if (proWetMaterialPlanDetailService.selectProWetMaterialPlanDetailByWorkId(proOrderWorkorder.getWorkorderId())) { -// throw new ServiceException("工单已创建湿料计划,不能删除!"); -// } } String[] orderWorkerIds = strings.toArray(new String[0]); // 删除成品工单 - if (proWorkOrder.size() > 0) { + if (orderWorkerIds.length > 0) { proOrderWorkorderService.deleteProOrderWorkorderByWorkorderIds(orderWorkerIds); } return toAjax(1); diff --git a/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrder.java b/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrder.java index 41f5d641..ffb51e77 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrder.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrder.java @@ -62,6 +62,16 @@ public class ProOrder extends TreeEntity { private String bomBo; private String syncUser; + private String productDate; + + public String getProductDate() { + return productDate; + } + + public void setProductDate(String productDate) { + this.productDate = productDate; + } + public String getBomBo() { return bomBo; } @@ -138,7 +148,7 @@ public class ProOrder extends TreeEntity { private String materialCode; private String materialName; - + private Integer sortNo; // 车数 private Integer carNum; @@ -338,6 +348,14 @@ public class ProOrder extends TreeEntity { return prodType; } + public Integer getSortNo() { + return sortNo; + } + + public void setSortNo(Integer sortNo) { + this.sortNo = sortNo; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrderWorkorder.java b/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrderWorkorder.java index 99587760..9fe84808 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrderWorkorder.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrderWorkorder.java @@ -150,6 +150,7 @@ public class ProOrderWorkorder extends TreeEntity { // 车数 private Integer carNum; + private Integer sortNo; public Integer getCarNum() { return carNum; @@ -506,6 +507,14 @@ public class ProOrderWorkorder extends TreeEntity { this.prodLineCodeArray = prodLineCodeArray; } + public Integer getSortNo() { + return sortNo; + } + + public void setSortNo(Integer sortNo) { + this.sortNo = sortNo; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/op-modules/op-plan/src/main/java/com/op/plan/domain/dto/ProOrderDTO.java b/op-modules/op-plan/src/main/java/com/op/plan/domain/dto/ProOrderDTO.java index a2632e3e..46a3e24e 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/domain/dto/ProOrderDTO.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/domain/dto/ProOrderDTO.java @@ -65,6 +65,8 @@ public class ProOrderDTO { private Integer carNum; + private Integer sortNo; + public Integer getCarNum() { return carNum; } @@ -83,6 +85,14 @@ public class ProOrderDTO { private List children; + public Integer getSortNo() { + return sortNo; + } + + public void setSortNo(Integer sortNo) { + this.sortNo = sortNo; + } + @Override public String toString() { return "ProOrderDTO{" + diff --git a/op-modules/op-plan/src/main/java/com/op/plan/domain/dto/SplitOrderDTO.java b/op-modules/op-plan/src/main/java/com/op/plan/domain/dto/SplitOrderDTO.java index 97e10046..6e0c7a35 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/domain/dto/SplitOrderDTO.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/domain/dto/SplitOrderDTO.java @@ -29,6 +29,15 @@ public class SplitOrderDTO { private String materialCode; private String materialName; + private Integer sortNo; + + public Integer getSortNo() { + return sortNo; + } + + public void setSortNo(Integer sortNo) { + this.sortNo = sortNo; + } public String getMaterialCode() { return materialCode; 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 55524237..708b08f1 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 @@ -148,5 +148,7 @@ public interface ProOrderWorkorderMapper { * @return */ List selectProOrderWorkorderByOrderId(String orderId); + + int getProSortNo(ProOrder proOrder); } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/service/IProOrderService.java b/op-modules/op-plan/src/main/java/com/op/plan/service/IProOrderService.java index 97a69c21..47098ea4 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/service/IProOrderService.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/service/IProOrderService.java @@ -134,4 +134,6 @@ public interface IProOrderService { * @return */ AjaxResult getCascadeProOrder(String orderCode); + + int getProSortNo(ProOrder proOrder); } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java b/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java index 3d04a8d8..e4ad8417 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java @@ -131,7 +131,7 @@ public class ProOrderServiceImpl implements IProOrderService { // 如果不重复 if (checkout) { - // 如果是白坯订单 + /****白坯订单*****/ if (splitOrderDTO.getProduct().getProdType().equals("white")){ boolean flag = false; @@ -181,7 +181,11 @@ public class ProOrderServiceImpl implements IProOrderService { proOrderMapper.updateWhiteOrder(proOrder); // 设置工单通用属性 - ProOrderWorkorder proOrderWorkorder = setCommonWorkAttribute(proOrder, splitOrderDTO.getProductDate(), splitOrderDTO.getProdLineCode(), splitOrderDTO.getShiftId(), splitOrderDTO.getRouteCode()); + ProOrderWorkorder proOrderWorkorder = setCommonWorkAttribute( + proOrder, splitOrderDTO.getProductDate(), + splitOrderDTO.getProdLineCode(), splitOrderDTO.getShiftId(), + splitOrderDTO.getRouteCode(),splitOrderDTO.getSortNo() + ); // 设置批次表通用信息 ProOrderWorkorderBatch proOrderWorkorderBatch = setCommonBatchAttribute(); // 设置工单 @@ -198,7 +202,7 @@ public class ProOrderServiceImpl implements IProOrderService { proOrderWorkorder.setEndFlag(1); proOrderWorkorder.setCarNum(splitOrderDTO.getCarNum()); - // 插入工单 + // 插入工单/**pro_order_workorder**/ proOrderWorkorderMapper.insertProOrderWorkorder(proOrderWorkorder); setBatch(proOrderWorkorderBatch,splitOrderDTO.getFormFields(),proOrderWorkorder.getWorkorderId(),1L); @@ -235,12 +239,16 @@ public class ProOrderServiceImpl implements IProOrderService { return success(); - }else { + }else {/****成品订单*****/ // 创建订单对象,并将信息copy进去 ProOrder proOrder = new ProOrder(); BeanUtils.copyProperties(splitOrderDTO.getProduct(), proOrder); // 设置工单通用属性 - ProOrderWorkorder proOrderWorkorder = setCommonWorkAttribute(proOrder, splitOrderDTO.getProductDate(), splitOrderDTO.getProdLineCode(), splitOrderDTO.getShiftId(), splitOrderDTO.getRouteCode()); + ProOrderWorkorder proOrderWorkorder = setCommonWorkAttribute( + proOrder, splitOrderDTO.getProductDate(), + splitOrderDTO.getProdLineCode(), splitOrderDTO.getShiftId(), + splitOrderDTO.getRouteCode(),splitOrderDTO.getSortNo() + ); // 创建批次表通用对象 ProOrderWorkorderBatch workBatch = setCommonBatchAttribute(); // code @@ -263,12 +271,9 @@ public class ProOrderServiceImpl implements IProOrderService { workOrder.setWorkorderCode(proOrder.getOrderCode() + "-" + endCode); // 3.设置父工单 workOrder.setParentOrder(parentOrder.toString()); - // 工单对应车数-白坯订单操作 -// if (proOrder.getProdType().equals("white")) { -// int everyNum = (int) Math.ceil(proOrder.getQuantity() / proOrder.getCarNum()); -// int carNum = (int) Math.ceil(splitOrderDTO.getSplitNum() / everyNum); -// workOrder.setCarNum(carNum); -// } + + workOrder.setSortNo(splitOrderDTO.getSortNo()); + // 将工单信息更新至数据库 proOrderWorkorderMapper.insertProOrderWorkorder(workOrder); // 生成批次表信息并更新至数据库 @@ -296,34 +301,6 @@ public class ProOrderServiceImpl implements IProOrderService { } } } - - - // 关闭订单,判断是否拆分完成 -// ProOrder order = proOrderMapper.selectProOrderById(splitOrderDTO.getProduct().getId()); -// Long quantitySplit = order.getQuantitySplit(); -// Long quantity1 = order.getQuantity(); -// if (quantity1.equals(quantitySplit)) { -// // 需要关闭订单的codeList -// List orderCodes = new ArrayList<>(); -// // 临时存放code -// StringBuilder orderCode = new StringBuilder(); -// orderCode.append(order.getOrderCode()); -// while(true) { -// orderCodes.add(orderCode.toString()); -// String selectOrderCode = proOrderMapper.selectChildProOrderCodeByCode(orderCode.toString()); -// if (selectOrderCode == null) { -// break; -// } -// orderCode.setLength(0); -// orderCode.append(selectOrderCode); -// } -// -// // 关闭订单 -// for (String code : orderCodes) { -// remoteSapService.sapCloseOrder(code); -// } -// -// } return success(); } @@ -695,6 +672,12 @@ public class ProOrderServiceImpl implements IProOrderService { return success(proOrderVO); } + @Override + @DS("#header.poolName") + public int getProSortNo(ProOrder proOrder) { + return proOrderWorkorderMapper.getProSortNo(proOrder); + } + public void getSAPOrderByFactory(String poolName) { DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key // SapProOrder sapqo = new SapProOrder();//proOrderMapper.getMaxCreatetime(); @@ -845,7 +828,7 @@ public class ProOrderServiceImpl implements IProOrderService { * @param proOrder * @return */ - private ProOrderWorkorder setCommonWorkAttribute(ProOrder proOrder, Date date, String proLineCode, String shiftId, String routeCode) { + private ProOrderWorkorder setCommonWorkAttribute(ProOrder proOrder, Date date, String proLineCode, String shiftId, String routeCode, Integer orderNum) { ProOrderWorkorder proOrderWorkorder = new ProOrderWorkorder(); // 更新者 proOrderWorkorder.setUpdateBy(SecurityContextHolder.getUserName()); @@ -865,6 +848,8 @@ public class ProOrderServiceImpl implements IProOrderService { proOrderWorkorder.setProductSpc(proOrder.getProdSpc()); // 产线 proOrderWorkorder.setProdLineCode(proLineCode); + // 产线 + proOrderWorkorder.setOrderNum(orderNum); // 班次 proOrderWorkorder.setShiftId(shiftId); // TODO 产品类型(pro_type) @@ -915,6 +900,7 @@ public class ProOrderServiceImpl implements IProOrderService { proOrderWorkorder.setQuantitySplit(Long.valueOf(proOrder.getAtrr1())); // 设置工单产品类型 proOrderWorkorder.setProdType(proOrder.getOrderType()); + return proOrderWorkorder; } 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 b0da33ed..bc6e778c 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 @@ -97,12 +97,11 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService { Map equipMap = proOrderMapper.getEquipInfoByCodes(equipCods.substring(1));//设备字典 for (int c = 0; c < codeArray.size(); c++) { String equipCode = codeArray.getJSONArray(c).getString(1); - prodLineName += equipMap.get(equipCode).getLabel() + ","; + CascaderDTO eInfo = equipMap.get(equipCode); + if(eInfo != null){ + prodLineName += eInfo.getLabel() + ","; + } } -// Set keys = equipMap.keySet(); -// for (String key : keys) { -// prodLineName += equipMap.get(key).getLabel() + ","; -// } workorder.setProdLineName(prodLineName); // // 通过设备code查询出机型名称 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 692a4adf..694a8a40 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 @@ -37,13 +37,14 @@ + select workorder_id, workorder_code, workorder_name, order_id, order_code, product_id, product_code, product_name, product_spc, unit, quantity_produced, quantity_split, route_code, prod_line_code, product_date, shift_id, parent_order, ancestors, status, remark, attr1, attr2, attr3, attr4, create_by, create_time, - update_by, update_time, prod_type, factory_code , end_flag , car_num + update_by, update_time, prod_type, factory_code , end_flag , car_num,sort_no from pro_order_workorder @@ -201,6 +202,7 @@ factory_code, end_flag, car_num, + sort_no, #{workorderId}, @@ -235,6 +237,7 @@ #{factoryCode}, #{endFlag}, #{carNum}, + #{sortNo}, @@ -341,6 +344,10 @@ where order_id = #{orderId} and del_flag = '0' + insert into mes_prepare_detail @@ -422,7 +429,7 @@ update pro_order_workorder set del_flag = '1' - where order_id in + where workorder_id in #{workorderId}