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 cfbca9c..82cea11 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 @@ -3,9 +3,11 @@ package com.hw.jindie.api; import com.hw.common.core.constant.SecurityConstants; import com.hw.common.core.constant.ServiceNameConstants; import com.hw.common.core.domain.R; +import com.hw.jindie.api.domain.vo.ErpSyncInfoVo; import com.hw.jindie.api.factory.RemoteJindieFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; /** @@ -23,7 +25,7 @@ public interface RemoteJindieService { /** 同步物料*/ @PostMapping("/jindie/syncMaterialInfoFromErp") - R syncMaterialInfoFromErp(@RequestHeader(SecurityConstants.FROM_SOURCE) String source); + R syncMaterialInfoFromErp(@RequestBody ErpSyncInfoVo erpSyncInfoVo,@RequestHeader(SecurityConstants.FROM_SOURCE) String source); /** 同步项目信息*/ @PostMapping("/jindie/syncProjectInfoFromErp") diff --git a/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/domain/vo/ErpSyncInfoVo.java b/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/domain/vo/ErpSyncInfoVo.java new file mode 100644 index 0000000..e39c8f2 --- /dev/null +++ b/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/domain/vo/ErpSyncInfoVo.java @@ -0,0 +1,9 @@ +package com.hw.jindie.api.domain.vo; + +import lombok.Data; + +@Data +public class ErpSyncInfoVo { + + private String maxErpModifyDate; +} 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 72e3517..ec794b8 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 @@ -2,7 +2,9 @@ package com.hw.jindie.api.factory; import com.hw.common.core.domain.R; import com.hw.jindie.api.RemoteJindieService; +import com.hw.jindie.api.domain.vo.ErpSyncInfoVo; import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.web.bind.annotation.RequestBody; /** * @ClassName : RemoteJindieFallbackFactory @@ -19,7 +21,7 @@ public class RemoteJindieFallbackFactory implements FallbackFactory syncMaterialInfoFromErp(String source) { + public R syncMaterialInfoFromErp(ErpSyncInfoVo erpSyncInfoVo,String source) { return R.fail("同步物料信息失败:" + throwable.getMessage()); } diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/controller/KingdeeErpSyncController.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/controller/KingdeeErpSyncController.java index 351c1ac..53ae338 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/controller/KingdeeErpSyncController.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/controller/KingdeeErpSyncController.java @@ -5,8 +5,11 @@ import com.hw.common.core.web.domain.AjaxResult; import com.hw.common.log.annotation.Log; import com.hw.common.log.enums.BusinessType; import com.hw.common.security.annotation.InnerAuth; +import com.hw.jindie.api.domain.vo.ErpSyncInfoVo; import com.hw.jindie.service.IKingdeeErpSyncService; import com.hw.jindie.service.impl.KingdeeErpService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -20,6 +23,8 @@ import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/jindie") public class KingdeeErpSyncController { + private static final Logger logger = LoggerFactory.getLogger(KingdeeErpSyncController.class); + @Autowired private IKingdeeErpSyncService kingdeeErpSyncService; @@ -29,15 +34,15 @@ public class KingdeeErpSyncController { /** * 从erp中同步供应商数据到MES - * */ + */ @PostMapping("/syncSupplierInfoFromErp") @Log(title = "ERP供应商信息", businessType = BusinessType.INSERT) @InnerAuth - public AjaxResult syncSupplierInfoFromErp(){ + public AjaxResult syncSupplierInfoFromErp() { try { return AjaxResult.success(kingdeeErpSyncService.syncSupplierInfoFromErp(0)); - } catch (Exception e){ - e.printStackTrace(); + } catch (Exception e) { + logger.error("同步供应商信息错误:" + e.getMessage()); return AjaxResult.error(); } } @@ -45,49 +50,46 @@ public class KingdeeErpSyncController { /** * 从ERP中同步物料信息到MES */ -// @RequiresPermissions("wms:mobile:addrawinstock") @Log(title = "ERP物料信息", businessType = BusinessType.INSERT) @PostMapping(("/syncMaterialInfoFromErp")) @InnerAuth - public AjaxResult syncMaterialInfoFromErp() { + public AjaxResult syncMaterialInfoFromErp(@RequestBody ErpSyncInfoVo erpSyncInfoVo) { try { - return AjaxResult.success(kingdeeErpSyncService.syncMaterialInfoFromErp(0)); + return AjaxResult.success(kingdeeErpSyncService.syncMaterialInfoFromErp(0, erpSyncInfoVo)); } catch (Exception e) { - e.printStackTrace(); + logger.error("同步物料信息错误:" + e.getMessage()); return AjaxResult.error(); } } - /** * 从ERP中同步项目信息到MES - * */ + */ @PostMapping("/syncProjectInfoFromErp") @Log(title = "ERP项目信息", businessType = BusinessType.INSERT) @InnerAuth - public AjaxResult syncProjectInfoFromErp(){ + public AjaxResult syncProjectInfoFromErp() { try { return AjaxResult.success(kingdeeErpSyncService.syncProjectInfoFromErp(0)); - } - catch (Exception e) { + } catch (Exception e) { + logger.error("同步项目信息错误:" + e.getMessage()); return AjaxResult.error(); } } /** * 从ERP中同步销售订单信息到ERP - * */ + */ @PostMapping("/syncSaleOrderFromErp") @Log(title = "ERP销售订单", businessType = BusinessType.INSERT) @InnerAuth - public AjaxResult syncSaleOrderFromErp(){ + public AjaxResult syncSaleOrderFromErp() { try { return AjaxResult.success(kingdeeErpSyncService.syncSaleOrderFromErp(0)); - } - catch (Exception e) { - e.printStackTrace(); + } catch (Exception e) { + logger.error("同步销售订单信息错误:" + e.getMessage()); return AjaxResult.error(); } } @@ -95,25 +97,20 @@ public class KingdeeErpSyncController { /** * 从ERP中同步采购订单信息到MES - * */ + */ @PostMapping("/syncPurchaseOrderFromErp") @Log(title = "ERP采购订单", businessType = BusinessType.INSERT) @InnerAuth - public AjaxResult syncPurchaseOrderFromErp(){ + public AjaxResult syncPurchaseOrderFromErp() { try { return AjaxResult.success(kingdeeErpSyncService.syncPurchaseOrderFromErp(0)); - } - catch (Exception e) { + } catch (Exception e) { + logger.error("同步采购订单信息错误:" + e.getMessage()); return AjaxResult.error(); } } - - - - - /** * 单一采购申请单保存->提交->审核 * @@ -133,8 +130,8 @@ public class KingdeeErpSyncController { * 采购入库单保存->提交->审核 * * @param params {"FMaterialId": "02030002","FMaterialDesc": "推进式搅拌机", - * "FAuxPropId": "①【搅拌机】380V--BLD12搅拌机功率3kw,速比23(转速65rpm) ②【搅拌杆】搅拌杆长度3200mm,轴径57 ③【叶轮】叶轮直径650,二叶双层 ④【材质】碳钢衬胶⑤【机架】TJA2机架特别备注:①湘潭电机二级能效;②衬胶材质③电压:三相380V/50Hz; 电机防护/绝缘/温升:IP56/F/B", - * "FUnitID": "tai","FStockId": "CK002","FSrcBillNo": "JYCG-2023-5184","FRealQty": 4.0000,"FDate": "2024-04-10 00:00:00"} + * "FAuxPropId": "①【搅拌机】380V--BLD12搅拌机功率3kw,速比23(转速65rpm) ②【搅拌杆】搅拌杆长度3200mm,轴径57 ③【叶轮】叶轮直径650,二叶双层 ④【材质】碳钢衬胶⑤【机架】TJA2机架特别备注:①湘潭电机二级能效;②衬胶材质③电压:三相380V/50Hz; 电机防护/绝缘/温升:IP56/F/B", + * "FUnitID": "tai","FStockId": "CK002","FSrcBillNo": "JYCG-2023-5184","FRealQty": 4.0000,"FDate": "2024-04-10 00:00:00"} * @return {"msg": "{"IsSuccess":true,"Errors":[],"SuccessEntitys":[{"Id":"106249","Number":"CGRK00779","DIndex":0}]}","code": 200 * } */ @@ -149,6 +146,7 @@ public class KingdeeErpSyncController { /** * 其他出库单保存->提交->审核 + * * @param params {"FMaterialId": "01150020","FDate": "2024-04-12 00:00:00","FUnitID": "zhi1","FStockId": "CK052","FAuxPropId": "304不锈钢滤帽","FQty": 4.0000,"FPrice": 20.3} * @return {"msg": "{\"IsSuccess\":true,\"Errors\":[],\"SuccessEntitys\":[{\"Id\":\"116470\",\"Number\":\"QTCK004153\",\"DIndex\":0}]}","code": 200} */ @@ -164,8 +162,9 @@ public class KingdeeErpSyncController { /** * 其他入库单保存->提交->审核 + * * @param params {"FMaterialId": "01150020","FDate": "2024-04-12 00:00:00","FUnitID": "zhi1","FStockId": "CK052","FAuxPropId": "304不锈钢滤帽","FQty": 4.0000,"FPrice": 20.3} - * @return { "msg": "{\"IsSuccess\":true,\"Errors\":[],\"SuccessEntitys\":[{\"Id\":\"100418\",\"Number\":\"QTRK000352\",\"DIndex\":0}]}", "code": 200} + * @return { "msg": "{\"IsSuccess\":true,\"Errors\":[],\"SuccessEntitys\":[{\"Id\":\"100418\",\"Number\":\"QTRK000352\",\"DIndex\":0}]}", "code": 200} */ @PostMapping(("/saveOtherInStorage")) public AjaxResult saveOtherInStorage(@RequestBody String params) { @@ -253,5 +252,4 @@ public class KingdeeErpSyncController { } - } diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/IKingdeeErpSyncService.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/IKingdeeErpSyncService.java index cd35a7b..17435c3 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/IKingdeeErpSyncService.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/IKingdeeErpSyncService.java @@ -1,9 +1,11 @@ package com.hw.jindie.service; +import com.hw.jindie.api.domain.vo.ErpSyncInfoVo; + public interface IKingdeeErpSyncService { public int syncSupplierInfoFromErp(int startRow) throws Exception; - public int syncMaterialInfoFromErp(int startRow) throws Exception; + public int syncMaterialInfoFromErp(int startRow, ErpSyncInfoVo erpSyncInfoVo) throws Exception; public int syncProjectInfoFromErp(int startRow) throws Exception; public int syncSaleOrderFromErp(int startRow) throws Exception; public int syncPurchaseOrderFromErp(int startRow) throws Exception; 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 515dd5e..2fedf6b 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 @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hw.common.core.utils.DateUtils; import com.hw.common.core.utils.StringUtils; +import com.hw.jindie.api.domain.vo.ErpSyncInfoVo; import com.hw.jindie.domain.*; import com.hw.jindie.mapper.*; import com.hw.jindie.service.IKingdeeErpSyncService; @@ -181,8 +182,9 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { * @Description:从金蝶ERP同步物料信息 */ @Override - public int syncMaterialInfoFromErp(int startRow) throws Exception { - String maxErpModifyDate = mesBaseMaterialInfoMapper.selectMaxErpModifyDate(); + public int syncMaterialInfoFromErp(int startRow, ErpSyncInfoVo erpSyncInfoVo) throws Exception { + String maxErpModifyDate = StringUtils.isEmpty(erpSyncInfoVo.getMaxErpModifyDate()) + ?mesBaseMaterialInfoMapper.selectMaxErpModifyDate():erpSyncInfoVo.getMaxErpModifyDate(); return syncMaterialInfoFromErp(startRow, maxErpModifyDate); } @@ -727,6 +729,10 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { mesPurchaseOrder.setTondBase(tondBase); mesPurchaseOrder.setSupplierId(supplierId); mesPurchaseOrder.setUpdateTime(currentDate); + + //todo:需要确认ERP中的采购订单信息有没有完成和代采购的状态等信息 +// mesPurchaseOrder.setOrderStatus(待采购); + if (approveDate != null) { mesPurchaseOrder.setApproveDate(conversionERPTime(approveDate)); } 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 12bc36c..28d98fa 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 @@ -10,7 +10,7 @@ - + @@ -48,7 +48,7 @@ fentry_id, saleorder_code, saleorder_linenumber, - document_statsu, + document_status, factory_id, prodline_id, material_id, @@ -89,7 +89,7 @@ and saleorder_linenumber = #{saleorderLinenumber} - and document_statsu = #{documentStatus} + and document_status = #{documentStatus} and factory_id = #{factoryId} and prodline_id = #{prodlineId} and material_id = #{materialId} @@ -130,7 +130,7 @@ fentry_id, saleorder_code, saleorder_linenumber, - document_statsu, + document_status, factory_id, prodline_id, material_id, @@ -204,7 +204,7 @@ fentry_id = #{fentryId}, saleorder_code = #{saleorderCode}, saleorder_linenumber = #{saleorderLinenumber}, - document_statsu = #{documentStatus}, + document_status = #{documentStatus}, factory_id = #{factoryId}, prodline_id = #{prodlineId}, material_id = #{materialId}, @@ -268,7 +268,7 @@ - INSERT INTO mes_sale_order (erp_id, fentry_id, saleorder_code, saleorder_linenumber, document_statsu, 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, 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})