diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/domain/dto/MesPrepareDTO.java b/op-api/op-api-system/src/main/java/com/op/system/api/domain/dto/MesPrepareDTO.java index 7dfdce5b..51d30ba9 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/domain/dto/MesPrepareDTO.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/domain/dto/MesPrepareDTO.java @@ -1,15 +1,14 @@ package com.op.system.api.domain.dto; +import java.util.Date; 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 com.op.common.core.annotation.Excel; +import com.op.common.core.web.domain.BaseEntity; /** - * 备料单对象 mes_prepare + * 备料单对象 mes_prepareDTO * * @author Open Platform * @date 2023-08-03 @@ -23,6 +22,7 @@ public class MesPrepareDTO extends BaseEntity { /** 工单编码 */ @Excel(name = "工单编码") private String workorderCode; + private String workorderCodeSap; /** 工单名称 */ @Excel(name = "工单名称") @@ -120,6 +120,25 @@ public class MesPrepareDTO extends BaseEntity { /** 工厂编码 */ @Excel(name = "工厂编码") private String factoryCode; + + private String dayStr; + + public String getWorkorderCodeSap() { + return workorderCodeSap; + } + + public void setWorkorderCodeSap(String workorderCodeSap) { + this.workorderCodeSap = workorderCodeSap; + } + + public String getDayStr() { + return dayStr; + } + + public void setDayStr(String dayStr) { + this.dayStr = dayStr; + } + public String getMaterialCode() { return materialCode; } @@ -305,37 +324,37 @@ public class MesPrepareDTO extends BaseEntity { @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("prepareId", getPrepareId()) - .append("workorderCode", getWorkorderCode()) - .append("workorderName", getWorkorderName()) - .append("parentOrder", getParentOrder()) - .append("orderId", getOrderId()) - .append("orderCode", getOrderCode()) - .append("productId", getProductId()) - .append("productCode", getProductCode()) - .append("prodType", getProdType()) - .append("productName", getProductName()) - .append("productSpc", getProductSpc()) - .append("wetDetailPlanId", getWetDetailPlanId()) - .append("productDate", getProductDate()) - .append("shiftId", getShiftId()) - .append("ancestors", getAncestors()) - .append("status", getStatus()) - .append("remark", getRemark()) - .append("attr1", getAttr1()) - .append("attr2", getAttr2()) - .append("attr3", getAttr3()) - .append("attr4", getAttr4()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("factoryCode", getFactoryCode()) - .append("materialCode", getMaterialCode()) - .append("materialName", getMaterialName()) - .append("materialSpc", getMaterialSpc()) - .append("quantity", getQuantity()) - .append("unit", getUnit()) - .toString(); + .append("prepareId", getPrepareId()) + .append("workorderCode", getWorkorderCode()) + .append("workorderName", getWorkorderName()) + .append("parentOrder", getParentOrder()) + .append("orderId", getOrderId()) + .append("orderCode", getOrderCode()) + .append("productId", getProductId()) + .append("productCode", getProductCode()) + .append("prodType", getProdType()) + .append("productName", getProductName()) + .append("productSpc", getProductSpc()) + .append("wetDetailPlanId", getWetDetailPlanId()) + .append("productDate", getProductDate()) + .append("shiftId", getShiftId()) + .append("ancestors", getAncestors()) + .append("status", getStatus()) + .append("remark", getRemark()) + .append("attr1", getAttr1()) + .append("attr2", getAttr2()) + .append("attr3", getAttr3()) + .append("attr4", getAttr4()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("factoryCode", getFactoryCode()) + .append("materialCode", getMaterialCode()) + .append("materialName", getMaterialName()) + .append("materialSpc", getMaterialSpc()) + .append("quantity", getQuantity()) + .append("unit", getUnit()) + .toString(); } } diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/domain/dto/MesPrepareDetailDTO.java b/op-api/op-api-system/src/main/java/com/op/system/api/domain/dto/MesPrepareDetailDTO.java index d8c48f20..98e02a0a 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/domain/dto/MesPrepareDetailDTO.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/domain/dto/MesPrepareDetailDTO.java @@ -1,12 +1,11 @@ package com.op.system.api.domain.dto; +import java.util.Date; 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 com.op.common.core.annotation.Excel; +import com.op.common.core.web.domain.BaseEntity; /** * mes备料单明细对象 mes_prepare_detail @@ -42,7 +41,9 @@ public class MesPrepareDetailDTO extends BaseEntity { /** 生产数量 */ @Excel(name = "生产数量") - private Long quantity; + private String quantity; + + private String fundQuanlity; /** 工单生产日期 */ @JsonFormat(pattern = "yyyy-MM-dd") @@ -76,11 +77,57 @@ public class MesPrepareDetailDTO extends BaseEntity { /** 产品类型 */ @Excel(name = "产品类型") private String prodType; + /** 库位 */ + private String locator; + + private String needDate; + private String recoil; + private String buyFlag; + + public String getBuyFlag() { + return buyFlag; + } + + public void setBuyFlag(String buyFlag) { + this.buyFlag = buyFlag; + } /** $column.columnComment */ @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") private String factoryCode; + public String getRecoil() { + return recoil; + } + + public void setRecoil(String recoil) { + this.recoil = recoil; + } + + public String getFundQuanlity() { + return fundQuanlity; + } + + public void setFundQuanlity(String fundQuanlity) { + this.fundQuanlity = fundQuanlity; + } + + public String getNeedDate() { + return needDate; + } + + public void setNeedDate(String needDate) { + this.needDate = needDate; + } + + public String getLocator() { + return locator; + } + + public void setLocator(String locator) { + this.locator = locator; + } + public void setRecordId(String recordId) { this.recordId = recordId; } @@ -123,11 +170,11 @@ public class MesPrepareDetailDTO extends BaseEntity { public String getUnit() { return unit; } - public void setQuantity(Long quantity) { + public void setQuantity(String quantity) { this.quantity = quantity; } - public Long getQuantity() { + public String getQuantity() { return quantity; } public void setProductDate(Date productDate) { @@ -197,27 +244,27 @@ public class MesPrepareDetailDTO extends BaseEntity { @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("recordId", getRecordId()) - .append("prepareId", getPrepareId()) - .append("materialCode", getMaterialCode()) - .append("materailName", getMaterailName()) - .append("materailSpc", getMaterailSpc()) - .append("unit", getUnit()) - .append("quantity", getQuantity()) - .append("productDate", getProductDate()) - .append("shiftId", getShiftId()) - .append("status", getStatus()) - .append("remark", getRemark()) - .append("attr1", getAttr1()) - .append("attr2", getAttr2()) - .append("attr3", getAttr3()) - .append("attr4", getAttr4()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("prodType", getProdType()) - .append("factoryCode", getFactoryCode()) - .toString(); + .append("recordId", getRecordId()) + .append("prepareId", getPrepareId()) + .append("materialCode", getMaterialCode()) + .append("materailName", getMaterailName()) + .append("materailSpc", getMaterailSpc()) + .append("unit", getUnit()) + .append("quantity", getQuantity()) + .append("productDate", getProductDate()) + .append("shiftId", getShiftId()) + .append("status", getStatus()) + .append("remark", getRemark()) + .append("attr1", getAttr1()) + .append("attr2", getAttr2()) + .append("attr3", getAttr3()) + .append("attr4", getAttr4()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("prodType", getProdType()) + .append("factoryCode", getFactoryCode()) + .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 79c5d44c..bd5ff7f9 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 @@ -53,7 +53,7 @@ public class RyTask { remoteSapService.shopOrderSync(sapProOrder); } - /**每天22点执行 + /**每天22点执行(废弃) * 理论今天16点出明天的领料单 * 0 00 22 * * ? */ diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/IMesPrepareService.java b/op-modules/op-mes/src/main/java/com/op/mes/service/IMesPrepareService.java index 334c839c..35476916 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/IMesPrepareService.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/IMesPrepareService.java @@ -60,6 +60,7 @@ public interface IMesPrepareService { */ public int deleteMesPrepareByPrepareId(String prepareId); + /**废弃**/ public R getMesPrepare(); public R reportWorkTask(); 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 a4d034cd..ef37bf94 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 @@ -140,9 +140,11 @@ public class MesPrepareServiceImpl implements IMesPrepareService { new LinkedBlockingQueue()); try { dateSources.forEach(dateSource -> { - logger.info("++++++++++++" + dateSource.get("poolName") + "++++开始++++++++++"); - Runnable run = () -> getMesPrepareByFactory(dateSource.get("poolName")); - executorService.execute(run); + if(!"ds_999".equals(dateSource.get("poolName"))){ + logger.info("++++++++++++" + dateSource.get("poolName") + "++++开始++++++++++"); + Runnable run = () -> getMesPrepareByFactory(dateSource.get("poolName")); + executorService.execute(run); + } }); } catch (Exception e) { logger.error("service == deviceOfflineTimingTask == exception", e); @@ -156,67 +158,63 @@ public class MesPrepareServiceImpl implements IMesPrepareService { } public void getMesPrepareByFactory(String poolName) { - DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key -// List list = sapMaterialPreparationList.stream() -// .filter(a->a.getWERKS().equals(poolName)) -// .collect(Collectors.toList()); - - //获取T+1天的所有母工单 - MesPrepare qo = new MesPrepare(); - Calendar cal = Calendar.getInstance(); - cal.add(Calendar.DATE, 1);//这里改为1 - Date time = cal.getTime(); - qo.setDayStr(new SimpleDateFormat("yyyy-MM-dd").format(time)); - List parents = mesPrepareMapper.getParentWorkOrderT1(qo); - if (CollectionUtils.isEmpty(parents)) { - System.out.println("T+1无母工单数据"); - } - for (MesPrepare mesPrepare : parents) { - List sapMaterialPreparationList = remoteSapService.materialPreparation(mesPrepare.getWorkorderCodeSap()).getData(); - if (CollectionUtils.isEmpty(sapMaterialPreparationList)) { - System.out.println("sap无领料单数据"); - } - //取出各领料单 - Set orderCodes = sapMaterialPreparationList.stream().map(SapMaterialPreparation::getAUFNR).collect(Collectors.toSet()); - for (String orderCode : orderCodes) { - /**mes_prepare**/ - String mesPrepareId = IdUtils.fastSimpleUUID(); - MesPrepare mesPrepare0 = new MesPrepare(); - mesPrepare0.setPrepareId(mesPrepareId); - mesPrepare0.setWorkorderCode(orderCode);//工单(子) - mesPrepare0.setCreateTime(DateUtils.getNowDate()); - mesPrepare0.setCreateBy(SecurityUtils.getUsername()); - mesPrepare0.setStatus("L0");//默认待确认 - mesPrepareMapper.insertMesPrepare(mesPrepare0); - /**mes_prepare_detail**/ - List details = new ArrayList<>(); -// List listdetails = list.stream() -// .filter(a->a.getAUFNR().equals(orderCode)) -// .collect(Collectors.toList()); - MesPrepareDetail detail = null; - Date createDate = DateUtils.getNowDate(); - for (SapMaterialPreparation sap : sapMaterialPreparationList) { - detail = new MesPrepareDetail(); - detail.setPrepareId(mesPrepareId); - detail.setRecordId(IdUtils.fastSimpleUUID()); - detail.setAttr1(sap.getRSPOS());//预留/相关需求的项目编号 - detail.setMaterialCode(sap.getMATNR());//物料号 - detail.setMaterailName(sap.getMAKTX());//物料描述(短文本) - detail.setFactoryCode(sap.getWERKS());//工厂 - detail.setLocator(sap.getLGORT());//库存地点 - detail.setNeedDate(sap.getBDTER());//组件的需求日期 - detail.setQuantity(sap.getBDMNG());////需求量 - detail.setFundQuanlity(sap.getZQLSL());//欠料数量 - detail.setUnit(sap.getMEINS());//基本计量单位 - detail.setRecoil(sap.getRGEKZ());//反冲标识 - detail.setBuyFlag(sap.getDBSKZ());//直接采购标识 - detail.setCreateBy(SecurityUtils.getUsername()); - detail.setCreateTime(createDate); - details.add(detail); - } - mesPrepareDetailMapper.insertMesPrepareDetails(details); - } - } +// DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key +// //获取T+1天的所有母工单 +// MesPrepare qo = new MesPrepare(); +// Calendar cal = Calendar.getInstance(); +// cal.add(Calendar.DATE, 1);//这里改为1 +// Date time = cal.getTime(); +// qo.setDayStr(new SimpleDateFormat("yyyy-MM-dd").format(time)); +// List parents = mesPrepareMapper.getParentWorkOrderT1(qo); +// if (CollectionUtils.isEmpty(parents)) { +// System.out.println("T+1无母工单数据"); +// } +// for (MesPrepare mesPrepare : parents) { +// List sapMaterialPreparationList = remoteSapService.materialPreparation(mesPrepare.getWorkorderCodeSap()).getData(); +// if (CollectionUtils.isEmpty(sapMaterialPreparationList)) { +// System.out.println("sap无领料单数据"); +// } +// //取出各领料单 +// Set orderCodes = sapMaterialPreparationList.stream().map(SapMaterialPreparation::getAUFNR).collect(Collectors.toSet()); +// for (String orderCode : orderCodes) { +// /**mes_prepare**/ +// String mesPrepareId = IdUtils.fastSimpleUUID(); +// MesPrepare mesPrepare0 = new MesPrepare(); +// mesPrepare0.setPrepareId(mesPrepareId); +// mesPrepare0.setWorkorderCode(orderCode);//工单(子) +// mesPrepare0.setCreateTime(DateUtils.getNowDate()); +// mesPrepare0.setCreateBy(SecurityUtils.getUsername()); +// mesPrepare0.setStatus("L0");//默认待确认 +// mesPrepareMapper.insertMesPrepare(mesPrepare0); +// /**mes_prepare_detail**/ +// List details = new ArrayList<>(); +//// List listdetails = list.stream() +//// .filter(a->a.getAUFNR().equals(orderCode)) +//// .collect(Collectors.toList()); +// MesPrepareDetail detail = null; +// Date createDate = DateUtils.getNowDate(); +// for (SapMaterialPreparation sap : sapMaterialPreparationList) { +// detail = new MesPrepareDetail(); +// detail.setPrepareId(mesPrepareId); +// detail.setRecordId(IdUtils.fastSimpleUUID()); +// detail.setAttr1(sap.getRSPOS());//预留/相关需求的项目编号 +// detail.setMaterialCode(sap.getMATNR());//物料号 +// detail.setMaterailName(sap.getMAKTX());//物料描述(短文本) +// detail.setFactoryCode(sap.getWERKS());//工厂 +// detail.setLocator(sap.getLGORT());//库存地点 +// detail.setNeedDate(sap.getBDTER());//组件的需求日期 +// detail.setQuantity(sap.getBDMNG());////需求量 +// detail.setFundQuanlity(sap.getZQLSL());//欠料数量 +// detail.setUnit(sap.getMEINS());//基本计量单位 +// detail.setRecoil(sap.getRGEKZ());//反冲标识 +// detail.setBuyFlag(sap.getDBSKZ());//直接采购标识 +// detail.setCreateBy(SecurityUtils.getUsername()); +// detail.setCreateTime(createDate); +// details.add(detail); +// } +// mesPrepareDetailMapper.insertMesPrepareDetails(details); +// } +// } } 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 d575119c..16a3d725 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 @@ -100,7 +100,7 @@ public interface ProOrderWorkorderMapper { ProOrderWorkorder selectWorkOrderByCode(String workorderCode); /**下发生产订单**/ - public int downProOrderWorkorderByWorkorderIds(String[] workorderIds); + public int downWorkorders(String[] workorderIds); public List getWorkOrderByIds(String[] workorderIds); @@ -158,5 +158,13 @@ public interface ProOrderWorkorderMapper { ProOrderWorkorder getWorkOrderByCode(String workorderCode); void updateProOrderWorkorderM(ProOrderWorkorder proWorkOrder); + + void insertMesPrepare(MesPrepareDTO mesPrepare0); + + int insertMesPrepareDetails(@Param("list") List details); + + int updateWhiteWorkOrder(ProOrderWorkorder whiteOrder); + + ProOrderWorkorder getPWorkOrder(ProOrderWorkorder whiteOrder); } 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 fb0a8981..5140d41f 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 @@ -2,6 +2,7 @@ package com.op.plan.service.impl; import com.alibaba.fastjson2.JSONArray; import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; import com.op.common.core.context.SecurityContextHolder; import com.op.common.core.domain.R; import com.op.common.core.exception.ServiceException; @@ -21,7 +22,9 @@ import com.op.system.api.domain.SysSapLog; import com.op.system.api.domain.dto.MesPrepareDTO; import com.op.system.api.domain.dto.MesPrepareDetailDTO; import com.op.system.api.domain.sap.SapCreateOrder; +import com.op.system.api.domain.sap.SapMaterialPreparation; import net.bytebuddy.matcher.FilterableList; +import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,6 +36,7 @@ import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletRequest; +import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -219,8 +223,6 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService { @DS("#header.poolName") @Transactional(rollbackFor = Exception.class) public int downProOrderWorkorderByWorkorderIds(String[] workorderIds) { - List ids = new ArrayList<>(); - List psorders = new ArrayList<>();//父级工单 List sapList = null;//回传给sap的工单 //如果是白坯生成备料单 for (String workorderId : workorderIds) { @@ -256,11 +258,30 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService { details.add(detail); proOrderWorkorderMapper.createPrepareDetails(details); - ids.add(workorderId); }else{ //无湿料计划,下发不了 } - } else if (whiteOrder != null && !"white".equals(whiteOrder.getProdType())) {//成品的母工单回传sap + + whiteOrder.setUpdateBy(SecurityUtils.getUsername()); + whiteOrder.setUpdateTime(DateUtils.getNowDate()); + return proOrderWorkorderMapper.updateWhiteWorkOrder(whiteOrder); + } else if (whiteOrder != null && !"white".equals(whiteOrder.getProdType())) { + List pcodes = new ArrayList<>();//一起下发用 + List wcodes = new ArrayList<>();//领料单用 + //成品的母工单//查上一级工单 + Boolean isTop = true; + while(isTop) { + pcodes.add(whiteOrder.getWorkorderId()); + wcodes.add(whiteOrder.getWorkorderCode()); + //查上一级工单 + whiteOrder.setWorkorderCode(whiteOrder.getParentOrder()); + ProOrderWorkorder pWorkOrder = proOrderWorkorderMapper.getPWorkOrder(whiteOrder); + if(pWorkOrder == null || "0".equals(pWorkOrder.getParentOrder())){ + isTop = false; + }else{ + BeanUtils.copyProperties(pWorkOrder,whiteOrder); + } + } sapList = new ArrayList<>(); SapCreateOrder sap = new SapCreateOrder(); sap.setWerks(whiteOrder.getFactoryCode());//工厂编码 @@ -274,7 +295,7 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService { //添加调用sap日志 SysSapLog sysSapLog = new SysSapLog(); sysSapLog.setId(IdUtils.fastSimpleUUID()); - sysSapLog.setMesssge(sapList.toString()); + sysSapLog.setMesssge(Arrays.asList(sapList).toString()); sysSapLog.setMethod("downProOrderWorkorderByWorkorderIds"); sysSapLog.setReqcode("请求"); sysSapLog.setCreateTime(DateUtils.getNowDate()); @@ -287,65 +308,31 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService { return 0; } List returnCodes = r.getData(); + Date updateTime = DateUtils.getNowDate(); if (!CollectionUtils.isEmpty(returnCodes)) { - for (String sapCode : returnCodes) { + logger.info("sap工单回传sap虚拟工单号:" + StringUtils.join(returnCodes, ",")); + for (int m=0;m pordes = getListBySonCode(pOrder); - if(!CollectionUtils.isEmpty(pordes)){ - psorders.addAll(pordes); - } + //获取领料单 + Collections.reverse(wcodes); + this.getMesPrepare(returnCodes,wcodes); - ids.add(workorderId); - } - } - } - if(!CollectionUtils.isEmpty(ids)){ - String[] idsArray = (String[])ids.toArray(new String[ids.size()]); - List workorders = proOrderWorkorderMapper.getWorkOrderByIds(idsArray); - for (ProOrderWorkorder workorder : workorders) { - //关联工艺 - if (StringUtils.isNotBlank(workorder.getRouteCode())) { - List workDetails = proWorkorderProcessDetailMapper.getWorkOrderDetailsByRouteCode(workorder); - if (!CollectionUtils.isEmpty(workDetails)) { - workDetails.forEach(str -> { - str.setRecordId(IdUtils.fastSimpleUUID()); - str.setWorkorderId(workorder.getWorkorderId()); - str.setStatus("s0");//未执行 - str.setCreateBy(SecurityContextHolder.getUserName()); - str.setCreateTime(DateUtils.getNowDate()); - str.setFactoryCode(workorder.getFactoryCode()); - }); - proWorkorderProcessDetailMapper.addWorkOrderDetails(workDetails); - } - } - } - //下达工单 - if(!CollectionUtils.isEmpty(psorders)){ - List pcodes = psorders.stream().map(e -> e.getOrderCode()).collect(Collectors.toList()); - ids.addAll(pcodes); + //关闭订单//母订单的订单编码 + R closeR= remoteSapService.sapCloseOrder(whiteOrder.getOrderCode()); + logger.info("下发工单后关闭订单"+whiteOrder.getOrderCode()+":"+closeR.getMsg()); + + //下达工单 + String[] idsArrayAll = (String[])pcodes.toArray(new String[pcodes.size()]); + return proOrderWorkorderMapper.downWorkorders(idsArrayAll); } - String[] idsArrayAll = (String[])ids.toArray(new String[ids.size()]); - //下达工单 - return proOrderWorkorderMapper.downProOrderWorkorderByWorkorderIds(idsArrayAll); } return 0; } @@ -361,45 +348,73 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService { return codeList; } - // //获取最低级材料 -// private void getLastChildren(List all, List allChildren , BaseBomComponentDTO bc) { -// List cList = all.stream().filter(item -> item.getCumc().equals(bc.getComponent())) -// .collect(Collectors.toList()); -// if(CollectionUtils.isEmpty(cList)){ -// allChildren.add(bc); -// }else{ -// for(BaseBomComponentDTO bcc : cList){ -// getLastChildren(all, allChildren ,bcc); -// } -// } -// } -// //获取顶级定单的bom组成 -// private List getBomDtos(String workorderId){ -// List bomdtoAdds = new ArrayList<>();//所有数据 -// -// List cumsDtos = new ArrayList<>(); -// BaseBomComponentDTO cumsDto = new BaseBomComponentDTO(); -// ProOrder order = this.getTopOrder(workorderId); -// cumsDto.setCumc(order.getProdCode()); -// cumsDtos.add(cumsDto); -// List bomdtos = proOrderWorkorderMapper.getBomComponents(order,cumsDtos);//最新版本的第一层子 -// bomdtoAdds.addAll(bomdtos); -// Boolean isTrue = true; -// while(isTrue){ -// List bomdtoTop = new ArrayList<>(); -// bomdtos.forEach(e->e.setCumc(e.getComponent())); -// bomdtoTop.addAll(bomdtos); -// List bomdtoSon = proOrderWorkorderMapper.getBomComponents(order,bomdtoTop); -// if(CollectionUtils.isEmpty(bomdtoSon)){ -// isTrue = false; -// }else{ -// bomdtos = bomdtoSon; -// bomdtoAdds.addAll(bomdtoSon); -// } -// } -// -// return bomdtos; -// } + public void getMesPrepare(List sapWorkOrders,List workOrders) { + for(String sapWorkOrder:sapWorkOrders){ + logger.info("获取sap领料单:" + sapWorkOrder+"开始"); +// //添加调用sap日志 +// SysSapLog sysSapLog = new SysSapLog(); +// sysSapLog.setId(IdUtils.fastSimpleUUID()); +// sysSapLog.setMesssge(sapWorkOrder); +// sysSapLog.setMethod("getMesPrepare"); +// sysSapLog.setReqcode("请求"); +// sysSapLog.setCreateTime(DateUtils.getNowDate()); +// proOrderMapper.addSapLog(sysSapLog); + + List sapMaterialPreparationList = remoteSapService.materialPreparation(sapWorkOrder).getData(); + if (CollectionUtils.isEmpty(sapMaterialPreparationList)) { + System.out.println("sap无领料单数据"); + } + //取出各领料单 + List orderCodes = sapMaterialPreparationList.stream().map(SapMaterialPreparation::getAUFNR).collect(Collectors.toList()); + Date createDate = DateUtils.getNowDate(); + for (int m = 0;m details = new ArrayList<>(); + + MesPrepareDetailDTO detail = null; + for (SapMaterialPreparation sap : sapMaterialPreparationList) { + detail = new MesPrepareDetailDTO(); + detail.setPrepareId(mesPrepareId); + detail.setRecordId(IdUtils.fastSimpleUUID()); + detail.setAttr1(sap.getRSPOS());//预留/相关需求的项目编号 + detail.setMaterialCode(sap.getMATNR());//物料号 + detail.setMaterailName(sap.getMAKTX());//物料描述(短文本) + detail.setFactoryCode(sap.getWERKS());//工厂 + detail.setLocator(sap.getLGORT());//库存地点 + detail.setNeedDate(sap.getBDTER());//组件的需求日期 + detail.setQuantity(sap.getBDMNG());////需求量 + detail.setFundQuanlity(sap.getZQLSL());//欠料数量 + detail.setUnit(sap.getMEINS());//基本计量单位 + detail.setRecoil(sap.getRGEKZ());//反冲标识 + detail.setBuyFlag(sap.getDBSKZ());//直接采购标识 + detail.setCreateBy(SecurityUtils.getUsername()); + detail.setCreateTime(createDate); + details.add(detail); + logger.info("领料单内容detail:"+sap.getRSPOS()+","+sap.getMATNR()+","+ + sap.getMAKTX()+","+sap.getWERKS()+","+ sap.getLGORT()+","+ + sap.getBDTER()+","+sap.getBDMNG()+","+sap.getZQLSL()+","+ + sap.getMEINS()+","+sap.getRGEKZ()+","+sap.getDBSKZ() + ); + } + proOrderWorkorderMapper.insertMesPrepareDetails(details); + logger.info("获取sap领料单:" + sapWorkOrder+"结束"); + } + } + } + + //根据工单子单编码获取最顶级订单的母单 private ProOrder getTopOrder(String workorderId) { //pro_order_workorder 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 15976353..894489c0 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 @@ -360,6 +360,14 @@ from pro_order_workorder where workorder_code = #{workorderCode} and del_flag = '0' + insert into mes_prepare_detail @@ -376,6 +384,90 @@ ) + + insert into mes_prepare + + prepare_id, + workorder_code, + workorder_name, + parent_order, + order_id, + order_code, + product_id, + product_code, + prod_type, + product_name, + product_spc, + wet_detail_plan_id, + product_date, + shift_id, + ancestors, + status, + remark, + attr1, + attr2, + attr3, + attr4, + create_by, + create_time, + update_by, + update_time, + factory_code, + material_code, + material_name, + material_spc, + unit, + quantity, + + + #{prepareId}, + #{workorderCode}, + #{workorderName}, + #{parentOrder}, + #{orderId}, + #{orderCode}, + #{productId}, + #{productCode}, + #{prodType}, + #{productName}, + #{productSpc}, + #{wetDetailPlanId}, + #{productDate}, + #{shiftId}, + #{ancestors}, + #{status}, + #{remark}, + #{attr1}, + #{attr2}, + #{attr3}, + #{attr4}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{factoryCode}, + #{materialCode}, + #{materialName}, + #{materialSpc}, + #{unit}, + #{quantity}, + + + + INSERT INTO mes_prepare_detail ( + record_id,prepare_id,material_code,material_name,unit, + quantity,create_by,create_time,factory_code,status, + locator,need_date,recoil,fund_quanlity,buy_flag + )VALUES + + ( + #{d.recordId},#{d.prepareId},#{d.materialCode},#{d.materailName},#{d.unit}, + #{d.quantity},#{d.createBy},#{d.createTime},#{d.factoryCode},#{d.status}, + #{d.locator},#{d.needDate},#{d.recoil},#{d.fundQuanlity},#{d.buyFlag} + ) + + + update pro_order_workorder @@ -415,12 +507,12 @@ where workorder_id = #{workorderId} - + update pro_order_workorder set status = 'w1' - where workorder_code in - - #{workorderCode} + where workorder_id in + + #{workorderId} and del_flag = '0' @@ -440,6 +532,11 @@ where workorder_id = #{workorderId} + + update pro_order_workorder + set status = 'w1' + where workorder_id = #{workorderId} + update pro_order_workorder