diff --git a/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/RemoteJindieService.java b/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/RemoteJindieService.java index f18d905..91594d1 100644 --- a/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/RemoteJindieService.java +++ b/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/RemoteJindieService.java @@ -47,4 +47,9 @@ public interface RemoteJindieService { /** 采购入库单保存->提交->审核*/ @PostMapping("/jindie/savePurchaseStorage") R savePurchaseStorage(@RequestBody String params, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + /** 其他出库单保存->提交->审核*/ + @PostMapping("/jindie/saveOtherOutStorage") + R saveOtherOutStorage(@RequestBody String params, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + } diff --git a/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/factory/RemoteJindieFallbackFactory.java b/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/factory/RemoteJindieFallbackFactory.java index 3deb8cd..b8a7ad1 100644 --- a/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/factory/RemoteJindieFallbackFactory.java +++ b/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/factory/RemoteJindieFallbackFactory.java @@ -50,6 +50,11 @@ public class RemoteJindieFallbackFactory implements FallbackFactory savePurchaseStorage(String params, String source) { return R.fail("采购入库单同步失败:" + throwable.getMessage()); } + + @Override + public R saveOtherOutStorage(String params, String source) { + return R.fail("其他出库单同步失败:" + throwable.getMessage()); + } }; } } diff --git a/hw-api/hw-api-wms/src/main/java/com/hw/wms/api/RemoteWmsService.java b/hw-api/hw-api-wms/src/main/java/com/hw/wms/api/RemoteWmsService.java index 01697c2..6c9340c 100644 --- a/hw-api/hw-api-wms/src/main/java/com/hw/wms/api/RemoteWmsService.java +++ b/hw-api/hw-api-wms/src/main/java/com/hw/wms/api/RemoteWmsService.java @@ -21,6 +21,12 @@ public interface RemoteWmsService { @PostMapping("/api/synchronizeInventoryInformationToERP") public R synchronizeInventoryInformationToERP(@RequestHeader(SecurityConstants.FROM_SOURCE) String source); - + /** + * 定时同步原材料出库给ERP + * @param source + * @return + */ + @PostMapping("/api/synchronizeRawMaterialDeliveryInformationToERP") + public R synchronizeRawMaterialDeliveryInformationToERP(@RequestHeader(SecurityConstants.FROM_SOURCE) String source); } diff --git a/hw-api/hw-api-wms/src/main/java/com/hw/wms/api/factory/RemoteWmsFallbackFactory.java b/hw-api/hw-api-wms/src/main/java/com/hw/wms/api/factory/RemoteWmsFallbackFactory.java index f763298..00fc5cf 100644 --- a/hw-api/hw-api-wms/src/main/java/com/hw/wms/api/factory/RemoteWmsFallbackFactory.java +++ b/hw-api/hw-api-wms/src/main/java/com/hw/wms/api/factory/RemoteWmsFallbackFactory.java @@ -26,6 +26,11 @@ public class RemoteWmsFallbackFactory implements FallbackFactory synchronizeInventoryInformationToERP(String source) { return R.fail("定时同步入库信息给ERP失败:" + throwable.getMessage()); } + + @Override + public R synchronizeRawMaterialDeliveryInformationToERP(String source) { + return R.fail("定时同步原材料出库给ERP失败:" + throwable.getMessage()); + } }; } } diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesSaleOrder.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesSaleOrder.java index 249d5ec..c2cd208 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesSaleOrder.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesSaleOrder.java @@ -178,6 +178,18 @@ public class MesSaleOrder extends BaseEntity { private String tondBase; + /** + * 规格参数 + */ + private String specificationParameter; + + public String getSpecificationParameter() { + return specificationParameter; + } + + public void setSpecificationParameter(String specificationParameter) { + this.specificationParameter = specificationParameter; + } public Long getStockId() { return stockId; diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/impl/KingdeeErpSyncServiceImpl.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/impl/KingdeeErpSyncServiceImpl.java index ab44b2f..6ab8590 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/impl/KingdeeErpSyncServiceImpl.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/impl/KingdeeErpSyncServiceImpl.java @@ -479,8 +479,8 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { JSONObject queryJson = new JSONObject(); String formId = "SAL_SaleOrder"; - String fieldKeys = "FID,FBillNo,FApproveDate,FSaleOrderEntry_FEntryID,FSaleOrderEntry_FMaterialModel,FMaterialId,FMaterialId.FNumber,FMaterialName,FDocumentStatus," + - "FQty,FCreateDate,FModifyDate,FMinPlanDeliveryDate,FAuxPropId,FStockId,FOwnerId,FSaleDeptId,FPrice,FStockOrgId,F_TOND_Base"; + String fieldKeys = "FID,FBillNo,FApproveDate,FSaleOrderEntry_FEntryID,FMaterialModel,FMaterialId,FMaterialId.FNumber,FMaterialName,FDocumentStatus," + + "FQty,FCreateDate,FModifyDate,FMinPlanDeliveryDate,FAuxPropId,FAUXPROPID.FF100001,FStockId,FOwnerId,FSaleDeptId,FPrice,FStockOrgId,F_TOND_Base"; // // String filterString = "FNumber='98010102'"; // String filterString = ""; @@ -542,6 +542,8 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { String planDeliveryDate = resultObject.getString("FMinPlanDeliveryDate"); //辅助属性 Long auxPropId = resultObject.getLong("FAuxPropId"); + //规格参数 + String FF100001 = resultObject.getString("FAUXPROPID.FF100001"); //仓库 Long stockId = resultObject.getLong("FStockId"); //货主 @@ -568,6 +570,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { mesSaleOrder.setMaterialName(materialName); mesSaleOrder.setOrderAmount(orderAmount); mesSaleOrder.setAuxPropId(auxPropId); + mesSaleOrder.setSpecificationParameter(FF100001); mesSaleOrder.setStockId(stockId); mesSaleOrder.setOwnerId(ownerId); mesSaleOrder.setSaleDeptId(saleDeptId); diff --git a/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesSaleOrderMapper.xml b/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesSaleOrderMapper.xml index 184ee9c..fcf063d 100644 --- a/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesSaleOrderMapper.xml +++ b/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesSaleOrderMapper.xml @@ -41,6 +41,7 @@ + @@ -74,6 +75,7 @@ update_by, update_time, aux_prop_id, + specification_parameter, stock_id, sale_dept_id, owner_id, @@ -157,6 +159,7 @@ update_by, update_time, aux_prop_id, + specification_parameter, stock_id, sale_dept_id, owner_id, @@ -193,6 +196,7 @@ #{updateBy}, #{updateTime}, #{auxPropId}, + #{specificationParameter}, #{stockId}, #{saleDeptId}, #{ownerId}, @@ -233,6 +237,7 @@ update_by = #{updateBy}, update_time = #{updateTime}, aux_prop_id=#{auxPropId}, + specification_parameter=#{specificationParameter}, stock_id=#{stockId}, sale_dept_id=#{saleDeptId}, owner_id=#{ownerId}, @@ -273,9 +278,9 @@ - INSERT INTO mes_sale_order (erp_id, fentry_id, saleorder_code, saleorder_linenumber, document_status, material_id, material_code, material_name, matkl, order_amount, complete_amount, release_qty, approve_date, erp_modify_date, plan_delivery_date, stock_id, owner_id, aux_prop_id, sale_dept_id, price, stock_org_id, tond_base, create_time,update_time) VALUES + INSERT INTO mes_sale_order (erp_id, fentry_id, saleorder_code, saleorder_linenumber, document_status, material_id, material_code, material_name, matkl, order_amount, complete_amount, release_qty, approve_date, erp_modify_date, plan_delivery_date, stock_id, owner_id, aux_prop_id, specification_parameter, sale_dept_id, price, stock_org_id, tond_base, create_time,update_time) VALUES - (#{item.erpId}, #{item.fentryId}, #{item.saleorderCode}, #{item.saleorderLinenumber}, #{item.documentStatus}, #{item.materialId}, #{item.materialCode}, #{item.materialName}, #{item.matkl}, #{item.orderAmount}, #{item.completeAmount}, #{item.releaseQty}, #{item.approveDate}, #{item.erpModifyDate}, #{item.planDeliveryDate}, #{item.stockId}, #{item.ownerId}, #{item.auxPropId}, #{item.saleDeptId}, #{item.price}, #{item.stockOrgId}, #{item.tondBase}, #{item.createTime}, #{item.updateTime}) + (#{item.erpId}, #{item.fentryId}, #{item.saleorderCode}, #{item.saleorderLinenumber}, #{item.documentStatus}, #{item.materialId}, #{item.materialCode}, #{item.materialName}, #{item.matkl}, #{item.orderAmount}, #{item.completeAmount}, #{item.releaseQty}, #{item.approveDate}, #{item.erpModifyDate}, #{item.planDeliveryDate}, #{item.stockId}, #{item.ownerId}, #{item.auxPropId}, #{item.specificationParameter}, #{item.saleDeptId}, #{item.price}, #{item.stockOrgId}, #{item.tondBase}, #{item.createTime}, #{item.updateTime}) diff --git a/hw-modules/hw-job/src/main/java/com/hw/job/task/RyTask.java b/hw-modules/hw-job/src/main/java/com/hw/job/task/RyTask.java index bdf0e75..854f003 100644 --- a/hw-modules/hw-job/src/main/java/com/hw/job/task/RyTask.java +++ b/hw-modules/hw-job/src/main/java/com/hw/job/task/RyTask.java @@ -111,4 +111,9 @@ public class RyTask System.out.println("++定时同步入库信息给ERP++ErpPurchaseOrder"); remoteWmsService.synchronizeInventoryInformationToERP(SecurityConstants.INNER); } + + public void syncRawMaterialDeliveryInformationToERP(){ + System.out.println("++定时同步入库信息给ERP++ErpPurchaseOrder"); + remoteWmsService.synchronizeRawMaterialDeliveryInformationToERP(SecurityConstants.INNER); + } } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsApiController.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsApiController.java index 3a5584e..76c6b85 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsApiController.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsApiController.java @@ -191,4 +191,13 @@ public class WmsApiController extends BaseController { return toAjax(wmsErpScheduledTaskService.synchronizeInventoryInformationToERP()); } + /** + * 定时同步原材料出库信息给ERP + * @return + */ + @PostMapping(("/synchronizeRawMaterialDeliveryInformationToERP")) + public AjaxResult synchronizeRawMaterialDeliveryInformationToERP() { + return toAjax(wmsErpScheduledTaskService.synchronizeRawMaterialDeliveryInformationToERP()); + } + } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawOutstock.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawOutstock.java index 40e684e..101211d 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawOutstock.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/WmsRawOutstock.java @@ -220,6 +220,39 @@ public class WmsRawOutstock extends BaseEntity { */ private List wmsRawOutstockDetailList; + /** 单价 */ + private BigDecimal price; + + /** 规格参数 */ + private String specificationParameter; + + /** 计量单位编号 */ + private String unitCode; + + public String getUnitCode() { + return unitCode; + } + + public void setUnitCode(String unitCode) { + this.unitCode = unitCode; + } + + public String getSpecificationParameter() { + return specificationParameter; + } + + public void setSpecificationParameter(String specificationParameter) { + this.specificationParameter = specificationParameter; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + public void setRawOutstockId(Long rawOutstockId) { this.rawOutstockId = rawOutstockId; } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsRawOutstockMapper.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsRawOutstockMapper.java index c66b0c0..57c3386 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsRawOutstockMapper.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/mapper/WmsRawOutstockMapper.java @@ -146,4 +146,11 @@ public interface WmsRawOutstockMapper * @return 原材料出库记录 */ public WmsRawOutstock selectNewestWmsRawOutstock(WmsRawOutstock wmsRawOutstock); + + /** + * 执行完成且未同步ERP的原材料出库List + * @param rawOutstock + * @return + */ + List selectWmsRawOutstockERPNotSynchronized(WmsRawOutstock rawOutstock); } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsErpScheduledTaskService.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsErpScheduledTaskService.java index 32aeca7..23241f0 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsErpScheduledTaskService.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsErpScheduledTaskService.java @@ -16,5 +16,9 @@ public interface IWmsErpScheduledTaskService { */ int synchronizeInventoryInformationToERP(); - + /** + * 定时同步原材料出库信息给ERP + * @return + */ + int synchronizeRawMaterialDeliveryInformationToERP(); } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsErpScheduledTaskServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsErpScheduledTaskServiceImpl.java index 4a5eb47..3f47c6d 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsErpScheduledTaskServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsErpScheduledTaskServiceImpl.java @@ -7,7 +7,9 @@ import com.hw.common.core.utils.DateUtils; import com.hw.common.core.web.domain.AjaxResult; import com.hw.jindie.api.RemoteJindieService; import com.hw.wms.domain.WmsRawInstock; +import com.hw.wms.domain.WmsRawOutstock; import com.hw.wms.mapper.WmsRawInstockMapper; +import com.hw.wms.mapper.WmsRawOutstockMapper; import com.hw.wms.service.IWmsErpScheduledTaskService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,6 +36,9 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi @Autowired private WmsRawInstockMapper wmsRawInstockMapper; + @Autowired + private WmsRawOutstockMapper wmsRawOutstockMapper; + @Autowired private RemoteJindieService remoteJindieService; @@ -89,4 +94,57 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi } } + /** + * 定时同步原材料出库信息给ERP + * @return + */ + @Override + public int synchronizeRawMaterialDeliveryInformationToERP() { + WmsRawOutstock rawOutstock = new WmsRawOutstock(); + int result = 0; + List outStockList = wmsRawOutstockMapper.selectWmsRawOutstockERPNotSynchronized(rawOutstock); + Map> materialIdMap = outStockList.stream().collect(Collectors.groupingBy(WmsRawOutstock::getMaterialId)); + for (Long materialId : materialIdMap.keySet()) { + syncOutstockInformation(materialIdMap, materialId, result); + } + return result; + } + + @Transactional(propagation = Propagation.REQUIRES_NEW) + void syncOutstockInformation(Map> materialIdMap, Long materialId, int result) { + List wmsRawOutstockList = materialIdMap.get(materialId); + JSONObject data = new JSONObject(); + double FRealQty = wmsRawOutstockList.stream().mapToDouble(item -> item.getRealOutstockAmount().subtract(item.getErpAmount()).doubleValue()).sum(); + WmsRawOutstock outstock = wmsRawOutstockList.get(0); + data.put("FDate", DateUtils.getTime()); + data.put("FMaterialId", outstock.getMaterialCode()); + data.put("FAuxPropId", outstock.getSpecificationParameter()); + data.put("FUnitID", outstock.getUnitCode()); + data.put("FQty", FRealQty); + data.put("FPrice", outstock.getPrice()); + data.put("FStockId", FStockId); + String params = data.toJSONString(); + R paramsResult = remoteJindieService.saveOtherOutStorage(params, SecurityConstants.INNER); + String paramsResultData = paramsResult.getMsg(); + JSONObject jsonObject = JSONObject.parseObject(paramsResultData); + Boolean isSuccess = (Boolean) jsonObject.get("IsSuccess"); + if (isSuccess) { + result++; + for (WmsRawOutstock wmsRawOutstock : wmsRawOutstockList) { + if (wmsRawOutstock.getRealOutstockAmount().equals(wmsRawOutstock.getOutstockAmount())){ + wmsRawOutstock.setErpStatus("1");//同步ERP状态(0:失败,1成功,2同步中) + } else { + wmsRawOutstock.setErpStatus("2");//同步ERP状态(0:失败,1成功,2同步中) + } + wmsRawOutstock.setErpAmount(wmsRawOutstock.getRealOutstockAmount()); + wmsRawOutstock.setUpdateDate(DateUtils.getNowDate()); + wmsRawOutstockMapper.updateWmsRawOutstock(wmsRawOutstock); + } + log.info("synchronizeRawMaterialDeliveryInformationToERP成功:" + paramsResult.toString()); + } else { + log.error("synchronizeRawMaterialDeliveryInformationToERP失败:" + paramsResult.toString()); + } + + } + } diff --git a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawOutstockMapper.xml b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawOutstockMapper.xml index b6cbc6a..ac080ba 100644 --- a/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawOutstockMapper.xml +++ b/hw-modules/hw-wms/src/main/resources/mapper/wms/WmsRawOutstockMapper.xml @@ -45,6 +45,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + @@ -350,4 +353,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" order by wro.raw_outstock_id desc limit 1 + +