diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/RemoteMesService.java b/op-api/op-api-system/src/main/java/com/op/system/api/RemoteMesService.java index d0527ab9..9ba5c354 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/RemoteMesService.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/RemoteMesService.java @@ -32,5 +32,4 @@ public interface RemoteMesService { /**获取领料单**/ @PostMapping("/prepare/getMesPrepare") public R getMesPrepare(); - } diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/RemoteSapService.java b/op-api/op-api-system/src/main/java/com/op/system/api/RemoteSapService.java index b029df80..069e0729 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/RemoteSapService.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/RemoteSapService.java @@ -2,6 +2,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.sap.SapCreateOrder; import com.op.system.api.domain.sap.SapMaterialPreparation; import com.op.system.api.factory.RemoteSapFallbackFactory; import com.op.system.api.model.SapProOrder; @@ -28,4 +29,8 @@ public interface RemoteSapService { public R sapProRouteProcess(); @PostMapping("/sap/materialPreparation") public R>materialPreparation(@RequestParam("shopOrder") String shopOrder); + + /**回传sap母工单**/ + @PostMapping("/sap/SapCreateOrder") + public R SapCreateOrder(@RequestBody List sapCreateOrderList); } diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/domain/sap/SapCreateOrder.java b/op-api/op-api-system/src/main/java/com/op/system/api/domain/sap/SapCreateOrder.java new file mode 100644 index 00000000..02574da8 --- /dev/null +++ b/op-api/op-api-system/src/main/java/com/op/system/api/domain/sap/SapCreateOrder.java @@ -0,0 +1,124 @@ +package com.op.system.api.domain.sap; + +public class SapCreateOrder { + + private String werks;//工厂编码 + + private String aufpar;//订单类型 + + private String matnr;//物料编号 + + private String quantity;//数量 + + private String dates;//开始时间 + + private String datee;//完成时间 + + public String getWerks() { + return werks; + } + + public void setWerks(String werks) { + this.werks = werks; + } + + public String getAufpar() { + return aufpar; + } + + public void setAufpar(String aufpar) { + this.aufpar = aufpar; + } + + public String getMatnr() { + return matnr; + } + + public void setMatnr(String matnr) { + this.matnr = matnr; + } + + public String getQuantity() { + return quantity; + } + + public void setQuantity(String quantity) { + this.quantity = quantity; + } + + public String getDates() { + return dates; + } + + public void setDates(String dates) { + this.dates = dates; + } + + public String getDatee() { + return datee; + } + + public void setDatee(String datee) { + this.datee = datee; + } + + // @NotNull(message = "计划工厂不能为空") +// @NotBlank(message = "计划工厂不能为空") +// @Size(min = 0, max = 4, message = "计划工厂长度不能超过4个字符") +// public String getP_WERKS() { +// return P_WERKS; +// } +// +// public void setP_WERKS(String p_WERKS) { +// P_WERKS = p_WERKS; +// } +// @NotNull +// @NotBlank(message = "订单类型不能为空") +// @Size(min = 0, max = 4, message = "订单类型长度不能超过64个字符") +// public String getP_AUFPAR() { +// return P_AUFPAR; +// } +// +// public void setP_AUFPAR(String p_AUFPAR) { +// P_AUFPAR = p_AUFPAR; +// } +// @NotNull +// @NotBlank(message = "物料编号不能为空") +// @Size(min = 0, max = 18, message = "物料编号长度不能超过18个字符") +// public String getP_MATNR() { +// return P_MATNR; +// } +// +// public void setP_MATNR(String p_MATNR) { +// P_MATNR = p_MATNR; +// } +// @NotNull +// @NotBlank(message = "数量不能为空") +// public String getP_QUANTITY() { +// return P_QUANTITY; +// } +// +// public void setP_QUANTITY(String p_QUANTITY) { +// P_QUANTITY = p_QUANTITY; +// } +// @NotNull +// @NotBlank(message = "开始时间不能为空") +// @Size(min = 0, max = 8, message = "开始时间长度不能超过8个字符") +// public String getP_DATES() { +// return P_DATES; +// } +// +// public void setP_DATES(String p_DATES) { +// P_DATES = p_DATES; +// } +// @NotNull +// @NotBlank(message = "完成时间不能为空") +// @Size(min = 0, max = 8, message = "完成时间长度不能超过8个字符") +// public String getP_DATEE() { +// return P_DATEE; +// } +// +// public void setP_DATEE(String p_DATEE) { +// P_DATEE = p_DATEE; +// } +} diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteSapFallbackFactory.java b/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteSapFallbackFactory.java index 59e4890d..5afe485e 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteSapFallbackFactory.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteSapFallbackFactory.java @@ -2,6 +2,7 @@ package com.op.system.api.factory; import com.op.common.core.domain.R; import com.op.system.api.RemoteSapService; +import com.op.system.api.domain.sap.SapCreateOrder; import com.op.system.api.domain.sap.SapMaterialPreparation; import com.op.system.api.model.SapProOrder; import org.slf4j.Logger; @@ -36,6 +37,11 @@ public class RemoteSapFallbackFactory implements FallbackFactory> materialPreparation(String shopOrder) { return R.fail("SAP服务获取SAP领料单失败:" + throwable.getMessage()); } + + @Override + public R SapCreateOrder(List sapCreateOrderList) { + return R.fail("回传sap工单失败:" + throwable.getMessage()); + } }; } } 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 6539c9b5..e7871597 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 @@ -26,7 +26,6 @@ public interface ProOrderWorkorderMapper { * @return 生产工单 */ public ProOrderWorkorder selectProOrderWorkorderByWorkorderId(String workorderId); - public ProOrderWorkorder selectWhiteOrderWorkorderById(ProOrderWorkorder 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 07d8f155..ad2555ae 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.baomidou.dynamic.datasource.annotation.DS; import com.op.common.core.context.SecurityContextHolder; +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; @@ -12,10 +13,14 @@ import com.op.plan.domain.dto.ProOrderDTO; import com.op.plan.domain.dto.SplitOrderDTO; import com.op.plan.mapper.*; import com.op.plan.service.IProOrderWorkorderService; +import com.op.system.api.RemoteSapService; 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 net.bytebuddy.matcher.FilterableList; 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.transaction.annotation.Transactional; @@ -35,6 +40,7 @@ import static com.op.common.core.web.domain.AjaxResult.success; */ @Service public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService { + protected Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private ProOrderWorkorderMapper proOrderWorkorderMapper; @Autowired @@ -45,8 +51,8 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService { private ProWorkorderProcessDetailMapper proWorkorderProcessDetailMapper; @Autowired private ProWetMaterialPlanDetailMapper proWetMaterialPlanDetailMapper; - - + @Autowired + private RemoteSapService remoteSapService; /** * 查询生产工单 * @@ -195,10 +201,11 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService { } } } + List sapList = new ArrayList<>();//回传给sap的工单 //如果是白坯生成备料单 for(String workorderId:workorderIds){ ProOrderWorkorder whiteOrder = proOrderWorkorderMapper.selectProOrderWorkorderByWorkorderId(workorderId); - if(whiteOrder!=null){//是白坯订单,自主生成领料单; + if(whiteOrder!=null&&"white".equals(whiteOrder.getProdType())){//是白坯订单,自主生成领料单; //备(领)料主单 MesPrepareDTO mesPrepare = new MesPrepareDTO(); BeanUtils.copyBeanProp(mesPrepare,whiteOrder); @@ -225,8 +232,22 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService { } details.add(detail); proOrderWorkorderMapper.createPrepareDetails(details); + }else if(whiteOrder!=null){//成品的母工单回传sap + SapCreateOrder sap = new SapCreateOrder(); + sap.setWerks(whiteOrder.getFactoryCode());//工厂编码 + sap.setAufpar(whiteOrder.getProdType());//订单类型 + sap.setMatnr(whiteOrder.getProductCode());//物料编号 + sap.setQuantity(whiteOrder.getQuantitySplit()+"");//数量 + sap.setDates(DateUtils.parseDateToStr("yyyy-MM-dd",whiteOrder.getProductDate()));//开始时间 + sap.setDatee(DateUtils.parseDateToStr("yyyy-MM-dd",whiteOrder.getProductDate()));//完成时间 + sapList.add(sap); } } + if(!CollectionUtils.isEmpty(sapList)){ + R r = remoteSapService.SapCreateOrder(sapList); + logger.info("sap工单回传:"+r.getMsg()); + } + //下达工单 return proOrderWorkorderMapper.downProOrderWorkorderByWorkorderIds(workorderIds); } 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 7f8d01ae..ad5b4a61 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 @@ -82,10 +82,9 @@ -