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 99e654a..cfbca9c 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 @@ -5,9 +5,8 @@ import com.hw.common.core.constant.ServiceNameConstants; import com.hw.common.core.domain.R; import com.hw.jindie.api.factory.RemoteJindieFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; /** * @ClassName : RemoteJindieService @@ -19,10 +18,23 @@ import org.springframework.web.bind.annotation.RequestParam; public interface RemoteJindieService { /** 同步供应商*/ - @GetMapping("/jindie/ErpSupplierInfo") - R ErpSupplierInfo(@RequestHeader(SecurityConstants.FROM_SOURCE) String source); + @PostMapping("/jindie/syncSupplierInfoFromErp") + R syncSupplierInfoFromErp(@RequestHeader(SecurityConstants.FROM_SOURCE) String source); /** 同步物料*/ - @GetMapping("/jindie/syncMaterialInfo") - R ErpMesMaterialInfo(@RequestHeader(SecurityConstants.FROM_SOURCE) String source); + @PostMapping("/jindie/syncMaterialInfoFromErp") + R syncMaterialInfoFromErp(@RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + /** 同步项目信息*/ + @PostMapping("/jindie/syncProjectInfoFromErp") + R syncProjectInfoFromErp(@RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + /** 同步销售订单*/ + @PostMapping("/jindie/syncSaleOrderFromErp") + R syncSaleOrderFromErp(@RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + /** 同步采购订单*/ + @PostMapping("/jindie/syncPurchaseOrderFromErp") + R syncPurchaseOrderFromErp(@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 e81d500..72e3517 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 @@ -14,13 +14,28 @@ public class RemoteJindieFallbackFactory implements FallbackFactory ErpSupplierInfo(String source) { - return null; + public R syncSupplierInfoFromErp(String source) { + return R.fail("同步供应商信息失败:" + throwable.getMessage()); } @Override - public R ErpMesMaterialInfo(String source) { - return null; + public R syncMaterialInfoFromErp(String source) { + return R.fail("同步物料信息失败:" + throwable.getMessage()); + } + + @Override + public R syncProjectInfoFromErp(String source) { + return R.fail("同步项目信息失败:" + throwable.getMessage()); + } + + @Override + public R syncSaleOrderFromErp(String source) { + return R.fail("同步销售订单信息失败:" + throwable.getMessage()); + } + + @Override + public R syncPurchaseOrderFromErp(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 8866da5..351c1ac 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 @@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject; 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.service.IKingdeeErpSyncService; import com.hw.jindie.service.impl.KingdeeErpService; import org.springframework.beans.factory.annotation.Autowired; @@ -27,10 +28,12 @@ public class KingdeeErpSyncController { private KingdeeErpService kingdeeErpService; /** - * 同步erp中供应商数据 + * 从erp中同步供应商数据到MES * */ - @GetMapping("/ErpSupplierInfo") - public AjaxResult ErpSupplierInfo(){ + @PostMapping("/syncSupplierInfoFromErp") + @Log(title = "ERP供应商信息", businessType = BusinessType.INSERT) + @InnerAuth + public AjaxResult syncSupplierInfoFromErp(){ try { return AjaxResult.success(kingdeeErpSyncService.syncSupplierInfoFromErp(0)); } catch (Exception e){ @@ -40,12 +43,13 @@ public class KingdeeErpSyncController { } /** - * 新增原材料入库记录 + * 从ERP中同步物料信息到MES */ // @RequiresPermissions("wms:mobile:addrawinstock") - @Log(title = "物料信息", businessType = BusinessType.INSERT) - @GetMapping(("/syncMaterialInfo")) - public AjaxResult syncMaterialInfo() { + @Log(title = "ERP物料信息", businessType = BusinessType.INSERT) + @PostMapping(("/syncMaterialInfoFromErp")) + @InnerAuth + public AjaxResult syncMaterialInfoFromErp() { try { return AjaxResult.success(kingdeeErpSyncService.syncMaterialInfoFromErp(0)); } catch (Exception e) { @@ -55,6 +59,61 @@ public class KingdeeErpSyncController { } + + + /** + * 从ERP中同步项目信息到MES + * */ + @PostMapping("/syncProjectInfoFromErp") + @Log(title = "ERP项目信息", businessType = BusinessType.INSERT) + @InnerAuth + public AjaxResult syncProjectInfoFromErp(){ + try { + return AjaxResult.success(kingdeeErpSyncService.syncProjectInfoFromErp(0)); + } + catch (Exception e) { + return AjaxResult.error(); + } + } + + /** + * 从ERP中同步销售订单信息到ERP + * */ + @PostMapping("/syncSaleOrderFromErp") + @Log(title = "ERP销售订单", businessType = BusinessType.INSERT) + @InnerAuth + public AjaxResult syncSaleOrderFromErp(){ + try { + return AjaxResult.success(kingdeeErpSyncService.syncSaleOrderFromErp(0)); + } + catch (Exception e) { + e.printStackTrace(); + return AjaxResult.error(); + } + } + + + /** + * 从ERP中同步采购订单信息到MES + * */ + @PostMapping("/syncPurchaseOrderFromErp") + @Log(title = "ERP采购订单", businessType = BusinessType.INSERT) + @InnerAuth + public AjaxResult syncPurchaseOrderFromErp(){ + try { + return AjaxResult.success(kingdeeErpSyncService.syncPurchaseOrderFromErp(0)); + } + catch (Exception e) { + return AjaxResult.error(); + } + } + + + + + + + /** * 单一采购申请单保存->提交->审核 * @@ -193,41 +252,6 @@ public class KingdeeErpSyncController { } } - /** - * 从ERP中同步项目信息 - * */ - @GetMapping("/ERPProject") - public AjaxResult getERPProject(){ - try { - return AjaxResult.success(kingdeeErpSyncService.syncProjectInfoFromErp(0)); - } - catch (Exception e) { - return AjaxResult.error(); - } - } - /** - * 从ERP中同步销售订单信息 - * */ - @GetMapping("/ERPMesSaleOrder") - public AjaxResult getERPMesSaleOrder(){ - try { - return AjaxResult.success(kingdeeErpSyncService.syncSaleOrderFromErp(0)); - } - catch (Exception e) { - return AjaxResult.error(); - } - } - /** - * 从ERP中同步采购订单信息 - * */ - @GetMapping("/ERPPurchase") - public AjaxResult getERPPurchase(){ - try { - return AjaxResult.success(kingdeeErpSyncService.syncPurchaseOrderFromErp(0)); - } - catch (Exception e) { - return AjaxResult.error(); - } - } + } diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesBaseSupplierInfo.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesBaseSupplierInfo.java index 8916d71..bd3c8cd 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesBaseSupplierInfo.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesBaseSupplierInfo.java @@ -42,6 +42,8 @@ public class MesBaseSupplierInfo extends BaseEntity @Excel(name = "审核日期", width = 30, dateFormat = "yyyy-MM-dd") private Date auditDate; + private Date erpModifyDate; + public void setSupplierId(Long supplierId) { this.supplierId = supplierId; @@ -97,6 +99,14 @@ public class MesBaseSupplierInfo extends BaseEntity return auditDate; } + public Date getErpModifyDate() { + return erpModifyDate; + } + + public void setErpModifyDate(Date erpModifyDate) { + this.erpModifyDate = erpModifyDate; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesPurchaseOrder.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesPurchaseOrder.java index 82b7709..77b26ee 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesPurchaseOrder.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesPurchaseOrder.java @@ -131,7 +131,7 @@ public class MesPurchaseOrder extends BaseEntity { @Excel(name = "是否标识:1-是;0-否") private String isFlag; //采购单位id - private String unitId; + private Long unitId; //库存单位 private Long stockUnitId; //计价单位 @@ -148,11 +148,11 @@ public class MesPurchaseOrder extends BaseEntity { private Long supplierId; - public String getUnitId() { + public Long getUnitId() { return unitId; } - public void setUnitId(String unitId) { + public void setUnitId(Long unitId) { this.unitId = unitId; } 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 74a4858..6cdbc80 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 @@ -173,6 +173,8 @@ public class MesSaleOrder extends BaseEntity { //库存组织 private Long stockOrgId; + private String tondBase; + public Long getStockId() { return stockId; @@ -406,6 +408,14 @@ public class MesSaleOrder extends BaseEntity { return isFlag; } + public String getTondBase() { + return tondBase; + } + + public void setTondBase(String tondBase) { + this.tondBase = tondBase; + } + @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesBaseMaterialInfoMapper.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesBaseMaterialInfoMapper.java index 158f95b..dbc0df7 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesBaseMaterialInfoMapper.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesBaseMaterialInfoMapper.java @@ -77,7 +77,7 @@ public interface MesBaseMaterialInfoMapper * 获取最大的ERP更新时间 * @return String */ - public String getMaxErpModifyDate(); + public String selectMaxErpModifyDate(); /** * 查询物料信息 @@ -95,10 +95,5 @@ public interface MesBaseMaterialInfoMapper */ public int batchMesBaseMaterialInfo(List mesBaseMaterialInfos); - /** - * 通过物料编码查询 - * */ - public MesBaseMaterialInfo selectMesBaseMaterialInfoByCode(String materialCode); - } diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesBaseSupplierInfoMapper.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesBaseSupplierInfoMapper.java index 5e5da9a..6c79867 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesBaseSupplierInfoMapper.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesBaseSupplierInfoMapper.java @@ -59,4 +59,30 @@ public interface MesBaseSupplierInfoMapper * @return 结果 */ public int deleteMesBaseSupplierInfoBySupplierIds(Long[] supplierIds); + + + + + /** + * 获取最大的ERP更新时间 + * @return String + */ + public String selectMaxErpModifyDate(); + + /** + * 查询供应商信息 + * + * @param erpId ERP主键 + * @return 供应商信息 + */ + public MesBaseSupplierInfo selectMesBaseSupplierInfoByErpId(Long erpId); + + /** + * 批量新增供应商信息 + * + * @param mesBaseSupplierInfos 供应商信息列表 + * @return 结果 + */ + public int batchMesBaseSupplierInfo(List mesBaseSupplierInfos); + } diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesProjectInfoMapper.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesProjectInfoMapper.java index fb5e9d4..38c34ac 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesProjectInfoMapper.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesProjectInfoMapper.java @@ -1,5 +1,6 @@ package com.hw.jindie.mapper; +import com.hw.jindie.domain.MesBaseSupplierInfo; import com.hw.jindie.domain.MesProjectInfo; import java.util.List; @@ -64,4 +65,21 @@ public interface MesProjectInfoMapper * 根据erpid查询 * */ public MesProjectInfo selectMesProjectInfoByErpId(Long erpId); + + + + /** + * 获取最大的ERP更新时间 + * @return String + */ + public String selectMaxErpModifyDate(); + + /** + * 批量新增项目信息 + * + * @param mesProjectInfos 项目信息列表 + * @return 结果 + */ + public int batchMesBaseProjectInfo(List mesProjectInfos); + } diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesPurchaseOrderMapper.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesPurchaseOrderMapper.java index 768e2f8..18bb84f 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesPurchaseOrderMapper.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesPurchaseOrderMapper.java @@ -1,6 +1,7 @@ package com.hw.jindie.mapper; import com.hw.jindie.domain.MesPurchaseOrder; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -10,8 +11,7 @@ import java.util.List; * @author Yinq * @date 2024-02-19 */ -public interface MesPurchaseOrderMapper -{ +public interface MesPurchaseOrderMapper { /** * 查询采购订单信息 * @@ -59,8 +59,31 @@ public interface MesPurchaseOrderMapper * @return 结果 */ public int deleteMesPurchaseOrderByPurchaseOrderIds(Long[] purchaseOrderIds); + + + /** + * 获取最大的ERP更新时间 + * + * @return String + */ + public String selectMaxErpModifyDate(); + + /** + * 查询销售订单信息 + * + * @param erpId ERP主键 + * @param fentryId ERP销售明细主键 + * @return 销售订单信息 + */ + public MesPurchaseOrder selectMesPurchaseOrderByUI(@Param("erpId") Long erpId, + @Param("fentryId") Long fentryId); + /** - * 根据erpid查询 - * */ - public MesPurchaseOrder selectMesPurchaseOrderByErpId(Long erpId); + * 批量新增销售订单信息 + * + * @param mesPurchaseOrders 销售订单信息列表 + * @return 结果 + */ + public int batchMesBasePurchaseOrder(List mesPurchaseOrders); + } diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesSaleOrderMapper.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesSaleOrderMapper.java index f44c9e7..a11083b 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesSaleOrderMapper.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesSaleOrderMapper.java @@ -1,6 +1,7 @@ package com.hw.jindie.mapper; import com.hw.jindie.domain.MesSaleOrder; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -10,8 +11,7 @@ import java.util.List; * @author Yinq * @date 2024-02-19 */ -public interface MesSaleOrderMapper -{ +public interface MesSaleOrderMapper { /** * 查询销售订单信息 * @@ -60,8 +60,29 @@ public interface MesSaleOrderMapper */ public int deleteMesSaleOrderBySaleOrderIds(Long[] saleOrderIds); + + /** + * 获取最大的ERP更新时间 + * + * @return String + */ + public String selectMaxErpModifyDate(); + + /** + * 查询采购订单信息 + * + * @param erpId ERP主键 + * @param fentryId ERP采购明细主键 + * @return 采购订单信息 + */ + public MesSaleOrder selectMesSaleOrderByUI(@Param("erpId") Long erpId, + @Param("fentryId") Long fentryId); + /** - * 通过erpid查询 - * */ - public MesSaleOrder selectMesSaleOrderByErpId(Long erpId); + * 批量新增采购订单信息 + * + * @param mesSaleOrders 采购订单信息列表 + * @return 结果 + */ + public int batchMesBaseSaleOrder(List mesSaleOrders); } 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 4c4c179..515dd5e 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 @@ -2,16 +2,12 @@ package com.hw.jindie.service.impl; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import com.google.gson.Gson; -import com.google.gson.JsonObject; import com.hw.common.core.utils.DateUtils; import com.hw.common.core.utils.StringUtils; import com.hw.jindie.domain.*; import com.hw.jindie.mapper.*; import com.hw.jindie.service.IKingdeeErpSyncService; -import com.kingdee.bos.webapi.entity.RepoRet; import com.kingdee.bos.webapi.sdk.K3CloudApi; -import io.swagger.models.auth.In; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -40,23 +36,33 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { @Autowired private MesPurchaseOrderMapper mesPurchaseOrderMapper; + private static final int limit = 100; /** * @throws Exception * @Description:从金蝶ERP同步供应商信息 */ + @Override public int syncSupplierInfoFromErp(int startRow) throws Exception { + String maxErpModifyDate = mesBaseSupplierInfoMapper.selectMaxErpModifyDate(); + return syncSupplierInfoFromErp(startRow, maxErpModifyDate); + } + + + /** + * @throws Exception + * @Description:从金蝶ERP同步供应商信息,递归使用 + */ + public int syncSupplierInfoFromErp(int startRow, String maxErpModifyDate) throws Exception { + System.out.println("startRow=" + startRow + ",,,maxErpModifyDate=" + maxErpModifyDate); K3CloudApi api = new K3CloudApi(); - // "FormId": "BD_Supplier", -// "FieldKeys": "FNumber ,FName,FCreateDate,FModifyDate,FAuditDate", -// "FilterString": "FDocumentStatus='C' AND FCreateDate>'2022-01-01' ", JSONObject queryJson = new JSONObject(); String formId = "BD_Supplier"; String fieldKeys = "FSupplierId,FNumber,FName,FCreateDate,FModifyDate,FAuditDate,FCreatorId,FModifierId"; String orderString = ""; int topRowCount = 0; // int startRow = 0; - int limit = 2; +// int limit = 2; queryJson.put("FormId", formId); queryJson.put("FieldKeys", fieldKeys); queryJson.put("OrderString", orderString); @@ -64,7 +70,15 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { queryJson.put("StartRow", startRow); queryJson.put("Limit", limit); queryJson.put("SubSystemId", ""); + //条件查询 + System.out.println("maxErpModifyDate=" + maxErpModifyDate); + if (StringUtils.isNotEmpty(maxErpModifyDate)) { + String filterString = "FModifyDate >'" + maxErpModifyDate + "'"; + queryJson.put("FilterString", filterString); + } + System.out.println(queryJson.toString()); + // if (StringUtils.isNotEmpty(beginTime) && StringUtils.isNotEmpty(endTime)) { // String filterString = "FCreateDate >'" + beginTime + "' AND '" + endTime + "' >FCreateDate"; // queryJson.put("FilterString", filterString); @@ -76,66 +90,83 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { String result = api.billQuery(queryJson.toString()); + if (StringUtils.isEmpty(result)) { + return 1; + } + JSONArray resultArray = JSONArray.parseArray(result); -// System.out.println(resultArray.size()); -// System.out.println("供应商查询接口: " + result); + if (resultArray == null) { + return 1; + } + List toInsertSupplierInfoList = new ArrayList<>(); + List toUpdateSupplierInfoList = new ArrayList<>(); + Date currentDate = new Date(); for (int i = 0; i < resultArray.size(); i++) { try { JSONObject resultObject = (JSONObject) resultArray.get(i); MesBaseSupplierInfo mesBaseSupplierInfo = new MesBaseSupplierInfo(); //供应商编号 - String FNumber = (String) resultObject.get("FNumber"); + String FNumber = resultObject.getString("FNumber"); //供应商名称 - String FName = (String) resultObject.get("FName"); + String FName = resultObject.getString("FName"); //erp主键id - Integer erpId = resultObject.get("FSupplierId") == null ? 0 : (Integer) resultObject.get("FSupplierId"); + Long erpId = resultObject.getLong("FSupplierId"); //创建时间 - String FCreateDate = (String) resultObject.get("FCreateDate"); + String FCreateDate = resultObject.getString("FCreateDate"); //更新时间 - String FModifyDate = (String) resultObject.get("FModifyDate"); + String FModifyDate = resultObject.getString("FModifyDate"); //审核日期 - String FAuditDate = (String) resultObject.get("FAuditDate"); - - - mesBaseSupplierInfo.setErpId(Long.valueOf(erpId)); - - List mesBaseSupplierInfos = mesBaseSupplierInfoMapper.selectMesBaseSupplierInfoList(mesBaseSupplierInfo); + String FAuditDate = resultObject.getString("FAuditDate"); + mesBaseSupplierInfo.setErpId(erpId); mesBaseSupplierInfo.setSupplierCode(FNumber); mesBaseSupplierInfo.setSupplierName(FName); //供应商状态 mesBaseSupplierInfo.setSupplierStatus("1"); -// mesBaseSupplierInfo.setCreateBy(FCreatorId); -// mesBaseSupplierInfo.setUpdateBy(FModifierId); + mesBaseSupplierInfo.setUpdateTime(currentDate); + if (StringUtils.isNotEmpty(FCreateDate)) { mesBaseSupplierInfo.setCreateTime(conversionERPTime(FCreateDate)); } if (StringUtils.isNotEmpty(FModifyDate)) { - mesBaseSupplierInfo.setUpdateTime(conversionERPTime(FModifyDate)); + mesBaseSupplierInfo.setErpModifyDate(conversionERPTime(FModifyDate)); } if (StringUtils.isNotEmpty(FAuditDate)) { mesBaseSupplierInfo.setAuditDate(conversionERPTime(FAuditDate)); } -// System.out.println(mesBaseSupplierInfo); - //通过erp主键判断,表中是否有重复的数据,如果有则更新,没有则插入 - if (mesBaseSupplierInfos.size() == 0) { - mesBaseSupplierInfoMapper.insertMesBaseSupplierInfo(mesBaseSupplierInfo); + MesBaseSupplierInfo existedMesBaseSupplierInfo = mesBaseSupplierInfoMapper.selectMesBaseSupplierInfoByErpId(erpId); + + if (existedMesBaseSupplierInfo != null) { + mesBaseSupplierInfo.setSupplierId(existedMesBaseSupplierInfo.getSupplierId()); + toUpdateSupplierInfoList.add(mesBaseSupplierInfo); } else { - //todo 主键 - mesBaseSupplierInfo.setSupplierId(mesBaseSupplierInfos.get(0).getSupplierId()); - mesBaseSupplierInfoMapper.updateMesBaseSupplierInfo(mesBaseSupplierInfo); + toInsertSupplierInfoList.add(mesBaseSupplierInfo); } + } catch (Exception e) { e.printStackTrace(); } } + + + if (!toInsertSupplierInfoList.isEmpty()) { + mesBaseSupplierInfoMapper.batchMesBaseSupplierInfo(toInsertSupplierInfoList); + } + if (!toUpdateSupplierInfoList.isEmpty()) { + for (MesBaseSupplierInfo toUpdatedSupplierInfo : toUpdateSupplierInfoList) { + mesBaseSupplierInfoMapper.updateMesBaseSupplierInfo(toUpdatedSupplierInfo); + } + } + + System.out.println("size:"+resultArray.size()); + //如果返回的数组的数量等于分页数量,则继续获取下一页数据 if (resultArray.size() == limit) { // System.out.println(startRow); //通过递归同步所有供应商,测试先不用 - int i = syncSupplierInfoFromErp(startRow + resultArray.size()); + int i = syncSupplierInfoFromErp(startRow + resultArray.size(), maxErpModifyDate); // return i; return 1; } else { @@ -151,6 +182,15 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { */ @Override public int syncMaterialInfoFromErp(int startRow) throws Exception { + String maxErpModifyDate = mesBaseMaterialInfoMapper.selectMaxErpModifyDate(); + return syncMaterialInfoFromErp(startRow, maxErpModifyDate); + } + + /** + * @throws Exception + * @Description:从金蝶ERP同步物料信息,递归使用 + */ + public int syncMaterialInfoFromErp(int startRow, String maxErpModifyDate) throws Exception { K3CloudApi api = new K3CloudApi(); String FDocumentStatus = "C"; @@ -162,7 +202,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { String orderString = ""; int topRowCount = 0; // int startRow = 0; - int limit = 20; +// int limit = 20; queryJson.put("FormId", formId); queryJson.put("FieldKeys", fieldKeys); queryJson.put("OrderString", orderString); @@ -170,8 +210,8 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { queryJson.put("StartRow", startRow); queryJson.put("Limit", limit); queryJson.put("SubSystemId", ""); + //条件查询 - String maxErpModifyDate = mesBaseMaterialInfoMapper.getMaxErpModifyDate(); if (StringUtils.isNotEmpty(maxErpModifyDate)) { String filterString = "FModifyDate >'" + maxErpModifyDate + "'"; queryJson.put("FilterString", filterString); @@ -179,50 +219,60 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { System.out.println(queryJson.toString()); String result = api.billQuery(queryJson.toString()); + if (StringUtils.isEmpty(result)) { + return 1; + } + JSONArray resultArray = JSONArray.parseArray(result); + if (resultArray == null) { + return 1; + } System.out.println("物料单据查询接口: " + result); List toInsertMaterialInfoList = new ArrayList<>(); List toUpdateMaterialInfoList = new ArrayList<>(); + Date currentDate = new Date(); for (int i = 0; i < resultArray.size(); i++) { JSONObject resultObject = (JSONObject) resultArray.get(i); MesBaseMaterialInfo mesBaseMaterialInfo = new MesBaseMaterialInfo(); //erp主键 - Integer erpId = (Integer) resultObject.get("FMaterialId"); + Long erpId = resultObject.getLong("FMaterialId"); //物料编码 - String materialCode = (String) resultObject.get("FNumber"); + String materialCode = resultObject.getString("FNumber"); //物料名称 - String materialName = (String) resultObject.get("FName"); + String materialName = resultObject.getString("FName"); //计量单位ID - Integer materaialUnitId = resultObject.get("FBaseUnitId") == null ? null : (Integer) resultObject.get("FBaseUnitId"); + Long materialUnitId = resultObject.getLong("FBaseUnitId"); //物料规格 - String materialSpec = resultObject.get("FSpecification") == null ? null : (String) resultObject.get("FSpecification"); + String materialSpec = resultObject.getString("FSpecification"); //净重 - BigDecimal netWeight = resultObject.get("FNETWEIGHT") == null ? null : (BigDecimal) resultObject.get("FNETWEIGHT"); + BigDecimal netWeight = resultObject.getBigDecimal("FNETWEIGHT"); //毛重 - BigDecimal grossWeight = resultObject.get("FGROSSWEIGHT") == null ? null : (BigDecimal) resultObject.get("FGROSSWEIGHT"); + BigDecimal grossWeight = resultObject.getBigDecimal("FGROSSWEIGHT"); //创建时间 - String createDateStr = resultObject.get("FCreateDate") == null ? null : (String) resultObject.get("FCreateDate"); + String createDateStr = resultObject.getString("FCreateDate"); //erp最后更新日期 - String modifyDateStr = resultObject.get("FModifyDate") == null ? null : (String) resultObject.get("FModifyDate"); + String modifyDateStr = resultObject.getString("FModifyDate"); //审核日期 - String approveDateStr = resultObject.get("FApproveDate") == null ? null : (String) resultObject.get("FApproveDate"); + String approveDateStr = resultObject.getString("FApproveDate"); //创建组织 - Integer createOrgId = resultObject.get("FCreateOrgId") == null ? null : (Integer) resultObject.get("FCreateOrgId"); + Long createOrgId = resultObject.getLong("FCreateOrgId"); //使用组织 - Integer useOrgId = resultObject.get("FUseOrgId") == null ? null : (Integer) resultObject.get("FUseOrgId"); + Long useOrgId = resultObject.getLong("FUseOrgId"); //采购计量单价 - Integer purchasePriceUnitId = resultObject.get("FPurchasePriceUnitId") == null ? null : (Integer) resultObject.get("FPurchasePriceUnit"); + Long purchasePriceUnitId = resultObject.getLong("FPurchasePriceUnitId"); + mesBaseMaterialInfo.setErpId(erpId); mesBaseMaterialInfo.setMaterialCode(materialCode); mesBaseMaterialInfo.setMaterialName(materialName); - mesBaseMaterialInfo.setMaterialUnitId(Long.valueOf(materaialUnitId)); + mesBaseMaterialInfo.setMaterialUnitId(materialUnitId); mesBaseMaterialInfo.setMaterialSpec(materialSpec); mesBaseMaterialInfo.setNetWeight(netWeight); mesBaseMaterialInfo.setGrossWeight(grossWeight); - mesBaseMaterialInfo.setCreateOrgId(Long.valueOf(createOrgId)); - mesBaseMaterialInfo.setUseOrgId(Long.valueOf(useOrgId)); - mesBaseMaterialInfo.setPurchasePriceUnitId(Long.valueOf(purchasePriceUnitId)); + mesBaseMaterialInfo.setCreateOrgId(createOrgId); + mesBaseMaterialInfo.setUseOrgId(useOrgId); + mesBaseMaterialInfo.setUpdateTime(currentDate); + mesBaseMaterialInfo.setPurchasePriceUnitId(purchasePriceUnitId); if (StringUtils.isNotEmpty(createDateStr)) { mesBaseMaterialInfo.setCreateTime(conversionERPTime(createDateStr)); @@ -236,16 +286,13 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { mesBaseMaterialInfo.setApproveDate(conversionERPTime(approveDateStr)); } - - MesBaseMaterialInfo existedMesBaseMaterialInfo = mesBaseMaterialInfoMapper.selectMesBaseMaterialInfoByErpId(Long.valueOf(erpId)); - + MesBaseMaterialInfo existedMesBaseMaterialInfo = mesBaseMaterialInfoMapper.selectMesBaseMaterialInfoByErpId(erpId); if (existedMesBaseMaterialInfo != null) { mesBaseMaterialInfo.setMaterialId(existedMesBaseMaterialInfo.getMaterialId()); toUpdateMaterialInfoList.add(mesBaseMaterialInfo); } else { toInsertMaterialInfoList.add(mesBaseMaterialInfo); } - } if (!toInsertMaterialInfoList.isEmpty()) { @@ -257,11 +304,12 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { } } + System.out.println("size:"+resultArray.size()); /**分页递归获取所有物料信息*/ if (resultArray.size() == limit) { // System.out.println(startRow); //通过递归同步所有物料信息,测试先不用 - int i = syncMaterialInfoFromErp(startRow + resultArray.size()); + int i = syncMaterialInfoFromErp(startRow + resultArray.size(), maxErpModifyDate); // return i; return 1; } else { @@ -271,14 +319,23 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { } + /** + * @throws Exception + * @Descrption:从金蝶ERP同步销售订单 + */ + @Override + public int syncSaleOrderFromErp(int startRow) throws Exception { + String maxErpModifyDate = mesSaleOrderMapper.selectMaxErpModifyDate(); + return syncSaleOrderFromErp(startRow, maxErpModifyDate); + } /** * @throws Exception * @Descrption:从金蝶ERP同步销售订单 */ - public int syncSaleOrderFromErp(int startRow) throws Exception { + public int syncSaleOrderFromErp(int startRow,String maxErpModifyDate) throws Exception { K3CloudApi api = new K3CloudApi(); - String FDocumentStatus = "C"; +// String FDocumentStatus = "C"; // String json = "{\n" + // " \"FormId\": \"SAL_SaleOrder\",\n" + // " \"FieldKeys\": \"FID,FBillNo,FApproveDate,FSaleOrderEntry_FEntryID,FMaterialId.FNumber,FMaterialName,FQty ,FMinPlanDeliveryDate,\",\n" + @@ -292,18 +349,18 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { JSONObject queryJson = new JSONObject(); String formId = "SAL_SaleOrder"; - String fieldKeys = "FID,FBillNo,FApproveDate,FSaleOrderEntry_FEntryID,FMaterialId.FNumber,FMaterialName," + - "FQty,FModifyDate,FMinPlanDeliveryDate,FAuxPropId,FStockId,FOwnerId,FSaleDeptId,FPrice,FStockOrgId"; + String fieldKeys = "FID,FBillNo,FApproveDate,FSaleOrderEntry_FEntryID,FMaterialId,FMaterialId.FNumber,FMaterialName,FDocumentStatus," + + "FQty,FCreateDate,FModifyDate,FMinPlanDeliveryDate,FAuxPropId,FStockId,FOwnerId,FSaleDeptId,FPrice,FStockOrgId,F_TOND_Base"; // - String filterString = "FNumber='98010102'"; - filterString = ""; +// String filterString = "FNumber='98010102'"; +// String filterString = ""; String orderString = ""; int topRowCount = 0; // int startRow = 0; - int limit = 10; +// int limit = 10; queryJson.put("FormId", formId); queryJson.put("FieldKeys", fieldKeys); - queryJson.put("FilterString", filterString); +// queryJson.put("FilterString", filterString); queryJson.put("OrderString", orderString); queryJson.put("TopRowCount", topRowCount); queryJson.put("StartRow", startRow); @@ -311,109 +368,123 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { queryJson.put("SubSystemId", ""); System.out.println(queryJson.toString()); + //条件查询 + System.out.println("maxErpModifyDate=" + maxErpModifyDate); + if (StringUtils.isNotEmpty(maxErpModifyDate)) { + String filterString = "FModifyDate >'" + maxErpModifyDate + "'"; + queryJson.put("FilterString", filterString); + } + System.out.println(queryJson.toString()); + String result = api.billQuery(queryJson.toString()); JSONArray resultArray = JSONArray.parseArray(result); System.out.println(resultArray.size()); System.out.println("销售订单单据查询接口: " + result); - List mesSaleOrderListInsert = new ArrayList<>(); - List mesSaleOrderListUpdate = new ArrayList<>(); - for (int i = 0; i < resultArray.size(); i++){ - try{ - JSONObject resultObject = (JSONObject) resultArray.get(i); - MesSaleOrder mesSaleOrder = new MesSaleOrder(); - //erp主键 - Integer erpId = (Integer) resultObject.get("FID"); - //销售订单编号id - String saleOrderCode = (String) resultObject.get("FBillNo"); - //审核日期 - String approveDate = resultObject.get("FApproveDate") == null ? null : (String) resultObject.get("FApproveDate"); - //订单明细id - Integer fentyrId = resultObject.get("FSaleOrderEntry_FEntryID")==null?0:(Integer) resultObject.get("FSaleOrderEntry_FEntryID"); - //物料编码 - String materialCode = resultObject.get("FMaterialId.FNumber")==null?null:(String) resultObject.get("FMaterialId.FNumber"); - //物料名称 - String materialName = resultObject.get("FMaterialName")==null?null:(String) resultObject.get("FMaterialName"); - //订单数量 - BigDecimal orderAmount = resultObject.get("FQty")==null?new BigDecimal(0):(BigDecimal) resultObject.get("FQty"); - //erp最后修改日期 - String erpModifyDate = resultObject.get("FModifyDate")==null?null:(String) resultObject.get("FModifyDate"); - //计划交货日期 - String planDeliveryDate = resultObject.get("FMinPlanDeliveryDate")==null?null:(String) resultObject.get("FMinPlanDeliveryDate"); - //辅助属性 - Integer auxPropId = resultObject.get("FAuxPropId")==null?0:(Integer) resultObject.get("FAuxPropId"); - //仓库 - Integer stockId = resultObject.get("FStockId")==null?0:(Integer) resultObject.get("FStockId"); - //货主 - Integer ownerId = resultObject.get("FOwnerId")==null?0:(Integer) resultObject.get("FOwnerId"); - //销售部门 - Integer saleDeptId = resultObject.get("FSaleDeptId")==null?0:(Integer) resultObject.get("FSaleDeptId"); - //单价 - BigDecimal price = resultObject.get("FPrice")==null?new BigDecimal(0):(BigDecimal) resultObject.get("FPrice"); - //库存组织 - Integer stockOrgId = resultObject.get("FStockOrgId")==null?0:(Integer) resultObject.get("FStockOrgId"); - - mesSaleOrder.setErpId(Long.valueOf(erpId)); - mesSaleOrder.setSaleorderCode(saleOrderCode); - mesSaleOrder.setFentryId(Long.valueOf(fentyrId)); - //物料id - if (materialCode!=null){ - if(mesBaseMaterialInfoMapper.selectMesBaseMaterialInfoByCode(materialCode)!=null){ - mesSaleOrder.setMaterialId (mesBaseMaterialInfoMapper.selectMesBaseMaterialInfoByCode(materialCode).getMaterialId()); - } - } - mesSaleOrder.setMaterialCode(materialCode); - mesSaleOrder.setMaterialName(materialName); - mesSaleOrder.setOrderAmount(orderAmount); - mesSaleOrder.setAuxPropId(Long.valueOf(auxPropId)); - mesSaleOrder.setStockId(Long.valueOf(stockId)); - mesSaleOrder.setOwnerId(Long.valueOf(ownerId)); - mesSaleOrder.setSaleDeptId(Long.valueOf(saleDeptId)); - mesSaleOrder.setPrice(price); - mesSaleOrder.setStockOrgId(Long.valueOf(stockOrgId)); - if (planDeliveryDate!=null){ - mesSaleOrder.setPlanDeliveryDate(conversionERPTime(planDeliveryDate)); - } - if (erpModifyDate!=null){ - mesSaleOrder.setErpModifyDate(conversionERPTime(erpModifyDate)); - } - if (approveDate!=null){ - mesSaleOrder.setApproveDate(conversionERPTime(approveDate)); - } - MesSaleOrder mesSaleOrder1 = mesSaleOrderMapper.selectMesSaleOrderByErpId(Long.valueOf(erpId)); - if (mesSaleOrder1!=null){ - mesSaleOrder.setSaleOrderId(mesSaleOrder1.getSaleOrderId()); - mesSaleOrderMapper.insertMesSaleOrder(mesSaleOrder); -// mesSaleOrderListUpdate.add(mesSaleOrder); - } - else { -// mesSaleOrderListInsert.add(mesSaleOrder); - mesSaleOrderMapper.updateMesSaleOrder(mesSaleOrder); + List toInsertSaleOrderList = new ArrayList<>(); + List toUpdateSaleOrderList = new ArrayList<>(); + Date currentDate = new Date(); + for (int i = 0; i < resultArray.size(); i++) { + try { + JSONObject resultObject = (JSONObject) resultArray.get(i); + MesSaleOrder mesSaleOrder = new MesSaleOrder(); + //erp主键 + Long erpId = resultObject.getLong("FID"); + //销售订单编号id + String saleOrderCode = resultObject.getString("FBillNo"); + //审核日期 + String approveDate = resultObject.getString("FApproveDate"); + //订单明细id + Long fentyrId = resultObject.getLong("FSaleOrderEntry.FEntryID"); + //ERP物料id + Long fmaterialId = resultObject.getLong("FMaterialId"); + //物料编码 + String materialCode = resultObject.getString("FMaterialId.FNumber"); + //物料名称 + String materialName = resultObject.getString("FMaterialName"); + //订单数量 + BigDecimal orderAmount = resultObject.getBigDecimal("FQty"); + //erp最后修改日期 + String erpModifyDate = resultObject.getString("FModifyDate"); + //计划交货日期 + String planDeliveryDate = resultObject.getString("FMinPlanDeliveryDate"); + //辅助属性 + Long auxPropId = resultObject.getLong("FAuxPropId"); + //仓库 + Long stockId = resultObject.getLong("FStockId"); + //货主 + Long ownerId = resultObject.getLong("FOwnerId"); + //销售部门 + Long saleDeptId = resultObject.getLong("FSaleDeptId"); + //单价 + BigDecimal price = resultObject.getBigDecimal("FPrice"); + //库存组织 + Long stockOrgId = resultObject.getLong("FStockOrgId"); + //单据状态 + String documentStatus = resultObject.getString("FDocumentStatus"); + String tondBase = resultObject.getString("F.TOND.Base"); + String FCreateDate = resultObject.getString("FCreateDate"); + + mesSaleOrder.setErpId(erpId); + mesSaleOrder.setSaleorderCode(saleOrderCode); + mesSaleOrder.setFentryId(fentyrId); + mesSaleOrder.setDocumentStatus(documentStatus); + //erp物料id + mesSaleOrder.setMaterialId(fmaterialId); + mesSaleOrder.setMaterialCode(materialCode); + mesSaleOrder.setMaterialName(materialName); + mesSaleOrder.setOrderAmount(orderAmount); + mesSaleOrder.setAuxPropId(auxPropId); + mesSaleOrder.setStockId(stockId); + mesSaleOrder.setOwnerId(ownerId); + mesSaleOrder.setSaleDeptId(saleDeptId); + mesSaleOrder.setPrice(price); + mesSaleOrder.setStockOrgId(stockOrgId); + mesSaleOrder.setTondBase(tondBase); + mesSaleOrder.setUpdateTime(currentDate); + if (StringUtils.isNotEmpty(FCreateDate)) { + mesSaleOrder.setCreateTime(conversionERPTime(FCreateDate)); + } + if (planDeliveryDate != null) { + mesSaleOrder.setPlanDeliveryDate(conversionERPTime(planDeliveryDate)); + } + if (erpModifyDate != null) { + mesSaleOrder.setErpModifyDate(conversionERPTime(erpModifyDate)); + } + if (approveDate != null) { + mesSaleOrder.setApproveDate(conversionERPTime(approveDate)); + } + + MesSaleOrder existedMesSaleOrder = mesSaleOrderMapper.selectMesSaleOrderByUI(erpId, fentyrId); + if (existedMesSaleOrder != null) { + mesSaleOrder.setSaleOrderId(existedMesSaleOrder.getSaleOrderId()); + toUpdateSaleOrderList.add(mesSaleOrder); + } else { + toInsertSaleOrderList.add(mesSaleOrder); + } + + } catch (Exception e) { + e.printStackTrace(); } -// if (mesSaleOrderListInsert!=null){ -// for (MesSaleOrder mesSaleOrders : mesSaleOrderListInsert){ -// mesSaleOrderMapper.insertMesSaleOrder(mesSaleOrders); -// System.out.println(mesSaleOrders); -// } -// } -// if (mesSaleOrderListUpdate != null) { -// for (MesSaleOrder mesSaleOrders : mesSaleOrderListUpdate){ -// mesSaleOrderMapper.updateMesSaleOrder(mesSaleOrders); -// System.out.println(mesSaleOrders); -// } -// } + } + + if (!toInsertSaleOrderList.isEmpty()) { + mesSaleOrderMapper.batchMesBaseSaleOrder(toInsertSaleOrderList); } - catch (Exception e) - { - e.printStackTrace(); + if (!toUpdateSaleOrderList.isEmpty()) { + for (MesSaleOrder toUpdatedSaleOrder : toUpdateSaleOrderList) { + mesSaleOrderMapper.updateMesSaleOrder(toUpdatedSaleOrder); } } + + System.out.println("size:"+resultArray.size()); + /**分页递归获取所有物料信息*/ if (resultArray.size() == limit) { // System.out.println(startRow); //通过递归同步所有物料信息,测试先不用 - int i = syncSaleOrderFromErp(startRow + resultArray.size()); + int i = syncSaleOrderFromErp(startRow + resultArray.size(),maxErpModifyDate); // return i; return 1; } else { @@ -423,27 +494,35 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { } - /** * @throws Exception * @Descrption:从金蝶ERP同步项目信息 */ + @Override public int syncProjectInfoFromErp(int startRow) throws Exception { - K3CloudApi api = new K3CloudApi(); - String FDocumentStatus = "C"; + String maxErpModifyDate = mesProjectInfoMapper.selectMaxErpModifyDate(); + return syncProjectInfoFromErp(startRow,maxErpModifyDate); + } + /** + * @throws Exception + * @Descrption:从金蝶ERP同步项目信息 + */ + public int syncProjectInfoFromErp(int startRow,String maxErpModifyDate) throws Exception { + K3CloudApi api = new K3CloudApi(); +// String FDocumentStatus = "C"; JSONObject queryJson = new JSONObject(); String formId = "TOND_ProjectFile"; String fieldKeys = "FID,FNumber,FName,FPlanDate,FDocumentStatus,FForbidStatus,FCreateDate,FModifyDate,FAuditDate"; - String filterString = ""; +// String filterString = ""; String orderString = ""; int topRowCount = 0; // int startRow = 0; - int limit = 20; +// int limit = 20; queryJson.put("FormId", formId); queryJson.put("FieldKeys", fieldKeys); - queryJson.put("FilterString", filterString); +// queryJson.put("FilterString", filterString); queryJson.put("OrderString", orderString); queryJson.put("TopRowCount", topRowCount); queryJson.put("StartRow", startRow); @@ -451,33 +530,42 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { queryJson.put("SubSystemId", ""); System.out.println(queryJson.toString()); + //条件查询 + System.out.println("maxErpModifyDate=" + maxErpModifyDate); + if (StringUtils.isNotEmpty(maxErpModifyDate)) { + String filterString = "FModifyDate >'" + maxErpModifyDate + "'"; + queryJson.put("FilterString", filterString); + } + System.out.println(queryJson.toString()); + String result = api.billQuery(queryJson.toString()); JSONArray resultArray = JSONArray.parseArray(result); System.out.println(resultArray.size()); System.out.println("项目信息单据查询接口: " + result); + List toInsertProjectInfoList = new ArrayList<>(); + List toUpdateProjectInfoList = new ArrayList<>(); + Date currentDate = new Date(); for (int i = 0; i < resultArray.size(); i++) { try { JSONObject resultObject = (JSONObject) resultArray.get(i); MesProjectInfo mesProjectInfo = new MesProjectInfo(); - List projectInfoListUpdate = new ArrayList(); - List projectInfoListInsert = new ArrayList(); - - Integer FID = resultObject.get("FID") == null ? 0 : (Integer) resultObject.get("FID"); - String FNumber = resultObject.get("FNumber") == null ? null : (String) resultObject.get("FNumber"); - String FName = resultObject.get("FName") == null ? null : (String) resultObject.get("FName"); -// String FDocumentStatus = resultObject.get("FDocumentStatus")==null? null:(String)resultObject.get("FDocumentStatus"); - String FForbidStatus = resultObject.get("FForbidStatus") == null ? null : (String) resultObject.get("FForbidStatus"); - String FAuditDate = resultObject.get("FAuditDate") == null ? null : (String) resultObject.get("FAuditDate"); - String FModifyDate = resultObject.get("FModifyDate") == null ? null : (String) resultObject.get("FModifyDate"); - String FCreateDate = resultObject.get("FCreateDate") == null ? null : (String) resultObject.get("FCreateDate"); - - mesProjectInfo.setErpId(Long.valueOf(FID)); + Long erpId = resultObject.getLong("FID"); + String FNumber = resultObject.getString("FNumber"); + String FName = resultObject.getString("FName"); + String FDocumentStatus = resultObject.getString("FDocumentStatus"); + String FForbidStatus = resultObject.getString("FForbidStatus"); + String FAuditDate = resultObject.getString("FAuditDate"); + String FModifyDate = resultObject.getString("FModifyDate"); + String FCreateDate = resultObject.getString("FCreateDate"); + + mesProjectInfo.setErpId(erpId); mesProjectInfo.setProjectNo(FNumber); mesProjectInfo.setProjectName(FName); mesProjectInfo.setDocumentStatus(FDocumentStatus); mesProjectInfo.setForbidStatus(FForbidStatus); mesProjectInfo.setIsFlag("1"); + mesProjectInfo.setUpdateTime(currentDate); if (StringUtils.isNotEmpty(FAuditDate)) { mesProjectInfo.setAuditDate(conversionERPTime(FAuditDate)); } @@ -488,38 +576,34 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { mesProjectInfo.setCreateTime(conversionERPTime(FCreateDate)); } // System.out.println(mesProjectInfo); - MesProjectInfo mesProjectInfo1 = mesProjectInfoMapper.selectMesProjectInfoByErpId(mesProjectInfo.getErpId()); + MesProjectInfo existedProjectInfo = mesProjectInfoMapper.selectMesProjectInfoByErpId(erpId); - if (mesProjectInfo1 != null) - { - mesProjectInfo.setProjectId(mesProjectInfo1.getProjectId()); - projectInfoListUpdate.add(mesProjectInfo); - } - else { - projectInfoListInsert.add(mesProjectInfo); - } - if (!projectInfoListUpdate.isEmpty()){ - for (MesProjectInfo projectInfo : projectInfoListUpdate){ - mesProjectInfoMapper.updateMesProjectInfo(projectInfo); - System.out.println(projectInfo); - } - } - if (!projectInfoListInsert.isEmpty()){ - for (MesProjectInfo projectInfo : projectInfoListInsert){ - mesProjectInfoMapper.insertMesProjectInfo(projectInfo); - System.out.println(projectInfo); - } + if (existedProjectInfo != null) { + mesProjectInfo.setProjectId(existedProjectInfo.getProjectId()); + toUpdateProjectInfoList.add(mesProjectInfo); + } else { + toInsertProjectInfoList.add(mesProjectInfo); } - } catch (Exception e) { e.printStackTrace(); } } + + if (!toInsertProjectInfoList.isEmpty()) { + mesProjectInfoMapper.batchMesBaseProjectInfo(toInsertProjectInfoList); + } + if (!toUpdateProjectInfoList.isEmpty()) { + for (MesProjectInfo toUpdatedProjectInfo : toUpdateProjectInfoList) { + mesProjectInfoMapper.updateMesProjectInfo(toUpdatedProjectInfo); + } + } + + System.out.println("size:"+resultArray.size()); /**分页递归获取所有物料信息*/ if (resultArray.size() == limit) { // System.out.println(startRow); //通过递归同步所有物料信息,测试先不用 - int i = syncProjectInfoFromErp(startRow + resultArray.size()); + int i = syncProjectInfoFromErp(startRow + resultArray.size(),maxErpModifyDate); // return i; return 1; } else { @@ -532,23 +616,31 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { * @throws Exception * @Descrption:从金蝶ERP同步采购订单 */ - public int syncPurchaseOrderFromErp(int startRow) throws Exception { - K3CloudApi api = new K3CloudApi(); - String FDocumentStatus = "C"; - + @Override + public int syncPurchaseOrderFromErp(int startRow) throws Exception { + String maxErpModifyDate = mesPurchaseOrderMapper.selectMaxErpModifyDate(); + return syncPurchaseOrderFromErp(startRow,maxErpModifyDate); + } + /** + * @throws Exception + * @Descrption:从金蝶ERP同步采购订单 + */ + public int syncPurchaseOrderFromErp(int startRow,String maxErpModifyDate) throws Exception { + K3CloudApi api = new K3CloudApi(); +// String FDocumentStatus = "C"; JSONObject queryJson = new JSONObject(); String formId = "PUR_PurchaseOrder"; - String fieldKeys = "FID,FBillNo,FApproveDate,FDocumentStatus,FPOOrderEntry_FEntryID,FMaterialId.FNumber,FMaterialId.FName," + - "FQty,FDeliveryDate,FUnitId,FStockUnitID,FPriceUnitID,FAuxPropId,FSrcBillNo,FPurchaseOrgId,F_TOND_Base,FSupplierId"; - String filterString = ""; + String fieldKeys = "FID,FBillNo,FApproveDate,FDocumentStatus,FPOOrderEntry_FEntryID,FMaterialId,FMaterialId.FNumber,FMaterialId.FName," + + "FQty,FDeliveryDate,FCreateDate,FModifyDate,FUnitId,FStockUnitID,FPriceUnitID,FAuxPropId,FSrcBillNo,FPurchaseOrgId,F_TOND_Base,FSupplierId"; +// String filterString = ""; String orderString = ""; int topRowCount = 0; // int startRow = 0; - int limit = 20; +// int limit = 20; queryJson.put("FormId", formId); queryJson.put("FieldKeys", fieldKeys); - queryJson.put("FilterString", filterString); +// queryJson.put("FilterString", filterString); queryJson.put("OrderString", orderString); queryJson.put("TopRowCount", topRowCount); queryJson.put("StartRow", startRow); @@ -556,92 +648,130 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { queryJson.put("SubSystemId", ""); System.out.println(queryJson.toString()); + //条件查询 + System.out.println("maxErpModifyDate=" + maxErpModifyDate); + if (StringUtils.isNotEmpty(maxErpModifyDate)) { + String filterString = "FModifyDate >'" + maxErpModifyDate + "'"; + queryJson.put("FilterString", filterString); + } + System.out.println(queryJson.toString()); + String result = api.billQuery(queryJson.toString()); JSONArray resultArray = JSONArray.parseArray(result); System.out.println(resultArray.size()); System.out.println("采购订单单据查询接口: " + result); - List mesPurchaseOrderListUpdate = new ArrayList(); - List mesPurchaseOrderListInsert = new ArrayList<>(); - for (int i = 0 ;i < resultArray.size();i++){ - try{ + + List toInsertPurchaseOrderList = new ArrayList<>(); + List toUpdatePurchaseOrderList = new ArrayList<>(); + Date currentDate = new Date(); + for (int i = 0; i < resultArray.size(); i++) { + try { JSONObject resultObject = (JSONObject) resultArray.get(i); MesPurchaseOrder mesPurchaseOrder = new MesPurchaseOrder(); //erpid - Integer erpId = resultObject.get("FID")==null?null :(Integer) resultObject.get("FID"); + Long erpId = resultObject.getLong("FID"); //采购订单编号 - String poNo = resultObject.get("FBillNo")==null?null :(String) resultObject.get("FBillNo"); + String poNo = resultObject.getString("FBillNo"); //审核日期 - String approveDate = resultObject.get("FApproveDate")==null?null :(String) resultObject.get("FApproveDate"); + String approveDate = resultObject.getString("FApproveDate"); //单据状态 - String documentStatus = resultObject.get("FDocumentStatus")==null?null :(String) resultObject.get("FDocumentStatus"); + String documentStatus = resultObject.getString("FDocumentStatus"); //订单明细id - Integer fentryId = resultObject.get("FPOOrderEntry.FEntryID")==null?null:(Integer) resultObject.get("FPOOrderEntry.FEntryID"); + Long fentryId = resultObject.getLong("FPOOrderEntry.FEntryID"); + //erp物料ID + Long fmaterialId = resultObject.getLong("FMaterialId"); //物料编码 - String materialCode = resultObject.get("FMaterialId.FNumber")==null?null:(String) resultObject.get("FMaterialId.FNumber"); + String materialCode = resultObject.getString("FMaterialId.FNumber"); //物料名称 - String materialName = resultObject.get("FMaterialId.FName")==null?null:(String) resultObject.get("FMaterialId.FName"); + String materialName = resultObject.getString("FMaterialId.FName"); //订单计划数量 - BigDecimal orderAmount = resultObject.get("FQty")==null?new BigDecimal(0):(BigDecimal) resultObject.get("FQty"); + BigDecimal orderAmount = resultObject.getBigDecimal("FQty"); //计划交货日期 - String planDeliveryDate = resultObject.get("FDeliveryDate")==null?null:(String) resultObject.get("FDeliveryDate"); + String planDeliveryDate = resultObject.getString("FDeliveryDate"); //采购单位 - Integer unitId = resultObject.get("FUnitId")==null?null:(Integer) resultObject.get("FUnitId"); + Long unitId = resultObject.getLong("FUnitId"); //库存单位 - Integer stockUnitId = resultObject.get("FStockUnitID")==null?null:(Integer) resultObject.get("FStockUnitID"); + Long stockUnitId = resultObject.getLong("FStockUnitID"); //计价单位 - Integer priceUnitId = resultObject.get("FPriceUnitID")==null?null:(Integer) resultObject.get("FPriceUnitID"); + Long priceUnitId = resultObject.getLong("FPriceUnitID"); //辅助属性 - Integer auxPropId = resultObject.get("FAuxPropId") == null?null:(Integer) resultObject.get("FAuxPropId"); + Long auxPropId = resultObject.getLong("FAuxPropId"); //源单编号 - String srcBillNo = resultObject.get("FSrcBillNo") == null?null:(String) resultObject.get("FSrcBillNo"); + String srcBillNo = resultObject.getString("FSrcBillNo"); //采购组织 - Integer purchaseOrgId = resultObject.get("FPurchaseOrgId") ==null?null:(Integer) resultObject.get("FPurchaseOrgId"); + Long purchaseOrgId = resultObject.getLong("FPurchaseOrgId"); //京源项目 - String tondBase = resultObject.get("F_TOND_Base")==null?null:(String) resultObject.get("F_TOND_Base"); + String tondBase = resultObject.getString("F.TOND.Base"); //供应商id - Integer supplierId = resultObject.get("FSupplierId")==null?null:(Integer) resultObject.get("FSupplierId"); + Long supplierId = resultObject.getLong("FSupplierId"); - mesPurchaseOrder.setErpId(Long.valueOf(erpId)); + //创建时间 + String FCreateDate = resultObject.getString("FCreateDate"); + //更新时间 + String FModifyDate = resultObject.getString("FModifyDate"); + + mesPurchaseOrder.setErpId(erpId); mesPurchaseOrder.setPoNo(poNo); mesPurchaseOrder.setDocumentStatus(documentStatus); - mesPurchaseOrder.setFentryId(Long.valueOf(fentryId)); + mesPurchaseOrder.setFentryId(fentryId); + mesPurchaseOrder.setMaterialId(fmaterialId); mesPurchaseOrder.setMaterialCode(materialCode); - mesPurchaseOrder.setMaterialCode(materialName); + mesPurchaseOrder.setMaterialName(materialName); mesPurchaseOrder.setOrderAmount(orderAmount); - mesPurchaseOrder.setUnitId(unitId.toString()); - mesPurchaseOrder.setStockUnitId(Long.valueOf(stockUnitId)); - mesPurchaseOrder.setPriceUnitId(Long.valueOf(priceUnitId)); - mesPurchaseOrder.setAuxPropId(Long.valueOf(auxPropId)); + mesPurchaseOrder.setUnitId(unitId); + mesPurchaseOrder.setStockUnitId(stockUnitId); + mesPurchaseOrder.setPriceUnitId(priceUnitId); + mesPurchaseOrder.setAuxPropId(auxPropId); mesPurchaseOrder.setSrcBillNo(srcBillNo); - mesPurchaseOrder.setPurchaseOrgId(Long.valueOf(purchaseOrgId)); + mesPurchaseOrder.setPurchaseOrgId(purchaseOrgId); mesPurchaseOrder.setTondBase(tondBase); - mesPurchaseOrder.setSupplierId(Long.valueOf(supplierId)); - if (approveDate!=null){ + mesPurchaseOrder.setSupplierId(supplierId); + mesPurchaseOrder.setUpdateTime(currentDate); + if (approveDate != null) { mesPurchaseOrder.setApproveDate(conversionERPTime(approveDate)); } - if (planDeliveryDate!=null){ + if (planDeliveryDate != null) { mesPurchaseOrder.setPlanDeliveryDate(conversionERPTime(planDeliveryDate)); } - MesPurchaseOrder mesPurchaseOrder1 = mesPurchaseOrderMapper.selectMesPurchaseOrderByErpId(Long.valueOf(erpId)); - if (mesPurchaseOrder1!=null){ - mesPurchaseOrder.setPurchaseOrgId(mesPurchaseOrder1.getPurchaseOrgId()); - mesPurchaseOrderMapper.updateMesPurchaseOrder(mesPurchaseOrder); + if (StringUtils.isNotEmpty(FCreateDate)) { + mesPurchaseOrder.setCreateTime(conversionERPTime(FCreateDate)); } - else { - mesPurchaseOrderMapper.insertMesPurchaseOrder(mesPurchaseOrder); + if (StringUtils.isNotEmpty(FModifyDate)) { + mesPurchaseOrder.setErpModifyDate(conversionERPTime(FModifyDate)); } +// if (StringUtils.isNotEmpty(FAuditDate)) { +// mesPurchaseOrder.setAuditDate(conversionERPTime(FAuditDate)); +// } + MesPurchaseOrder existedPurchaseOrder = mesPurchaseOrderMapper.selectMesPurchaseOrderByUI(erpId, fentryId); - - }catch (Exception e){ + if (existedPurchaseOrder != null) { + mesPurchaseOrder.setPurchaseOrderId(existedPurchaseOrder.getPurchaseOrderId()); + toUpdatePurchaseOrderList.add(mesPurchaseOrder); + } else { + toInsertPurchaseOrderList.add(mesPurchaseOrder); + } + } catch (Exception e) { e.printStackTrace(); } } + + + if (!toInsertPurchaseOrderList.isEmpty()) { + mesPurchaseOrderMapper.batchMesBasePurchaseOrder(toInsertPurchaseOrderList); + } + if (!toUpdatePurchaseOrderList.isEmpty()) { + for (MesPurchaseOrder toUpdatePurchaseOrder : toUpdatePurchaseOrderList) { + mesPurchaseOrderMapper.updateMesPurchaseOrder(toUpdatePurchaseOrder); + } + } + + System.out.println("size:"+resultArray.size()); /**分页递归获取所有物料信息*/ if (resultArray.size() == limit) { // System.out.println(startRow); //通过递归同步所有物料信息,测试先不用 - int i = syncPurchaseOrderFromErp(startRow + resultArray.size()); + int i = syncPurchaseOrderFromErp(startRow + resultArray.size(),maxErpModifyDate); // return i; return 1; } else { @@ -651,8 +781,10 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { } public static void main(String[] args) throws Exception { + KingdeeErpSyncServiceImpl k = new KingdeeErpSyncServiceImpl(); + k.syncProjectInfoFromErp(0,""); // int i = syncSupplierInfoFromErp(0); -// syncMaterialInfoFromErp(); +// syncMaterialInfoFromErpTest(0); // syncSaleOrderFromErp(); // syncPurchaseOrderFromErp(); // syncProjectInfoFromErp(); @@ -664,4 +796,51 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { Date date = DateUtils.dateTime("yyyy-MM-dd HH:mm:ss", ERPTime); return date; } + + + + + + public static int syncMaterialInfoFromErpTest(int startRow) throws Exception { + K3CloudApi api = new K3CloudApi(); + String FDocumentStatus = "C"; + + JSONObject queryJson = new JSONObject(); + String formId = "BD_Material"; + String fieldKeys = "FMaterialId,FNumber,FName,FDocumentStatus,FForbidStatus,FMaterialGroup.FNUMBER,FBaseUnitId,FSpecification,FNETWEIGHT,FGROSSWEIGHT," + + "FCreateDate,FModifyDate,FApproveDate,FCreateOrgId,FUseOrgId,FPurchasePriceUnitId"; +// String filterString = "FNumber='98010102'"; + String orderString = ""; + int topRowCount = 0; +// int startRow = 0; +// int limit = 20; + queryJson.put("FormId", formId); + queryJson.put("FieldKeys", fieldKeys); + queryJson.put("OrderString", orderString); + queryJson.put("TopRowCount", topRowCount); + queryJson.put("StartRow", startRow); + queryJson.put("Limit", limit); + queryJson.put("SubSystemId", ""); + + //条件查询 + String filterString = "FNumber ='01010001'"; + queryJson.put("FilterString", filterString); + + System.out.println(queryJson.toString()); + + String result = api.billQuery(queryJson.toString()); + if (StringUtils.isEmpty(result)) { + return 1; + } + + JSONArray resultArray = JSONArray.parseArray(result); + if (resultArray == null) { + return 1; + } + System.out.println("物料单据查询接口: " + result); + + +return 1; + } + } diff --git a/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesBaseMaterialInfoMapper.xml b/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesBaseMaterialInfoMapper.xml index 2eaf955..a9dff2b 100644 --- a/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesBaseMaterialInfoMapper.xml +++ b/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesBaseMaterialInfoMapper.xml @@ -243,7 +243,6 @@ @@ -253,15 +252,10 @@ - INSERT INTO mes_base_material_info (erp_id, material_code, old_material_code, material_name, material_categories, material_subclass, material_type_id, batch_flag, material_unit_id, material_unit, material_matkl, material_spec, net_weight, gross_weight, factory_id, create_org_id, use_org_id, prodline_id, active_flag, deleted_flag, remark, purchase_price_unit_id, create_by, create_time, approve_date, erp_modify_date) VALUES + INSERT INTO mes_base_material_info (erp_id, material_code, old_material_code, material_name, material_categories, material_subclass, material_type_id, batch_flag, material_unit_id, material_unit, material_matkl, material_spec, net_weight, gross_weight, factory_id, create_org_id, use_org_id, prodline_id, active_flag, deleted_flag, remark, purchase_price_unit_id, create_by, create_time, approve_date, erp_modify_date,update_time) VALUES - ( #{item.erpId}, #{item.materialCode}, #{item.oldMaterialCode}, #{item.materialName}, #{item.materialCategories}, #{item.materialSubclass}, #{item.materialTypeId}, #{item.batchFlag}, #{item.materialUnifId}, #{item.materialUnit}, #{item.materialMatkl}, #{item.materialSpec}, #{item.netWeight}, #{item.grossWeight}, #{item.factoryId}, #{item.createOrgId}, #{item.useOrgId}, #{item.prodlineId}, #{item.activeFlag}, #{item.deletedFlag}, #{item.remark}, #{item.purchasePriceUnitId}, #{item.createBy}, #{item.createTime}, #{item.approveDate}, #{item.erpModifyDate}) + ( #{item.erpId}, #{item.materialCode}, #{item.oldMaterialCode}, #{item.materialName}, #{item.materialCategories}, #{item.materialSubclass}, #{item.materialTypeId}, #{item.batchFlag}, #{item.materialUnitId}, #{item.materialUnit}, #{item.materialMatkl}, #{item.materialSpec}, #{item.netWeight}, #{item.grossWeight}, #{item.factoryId}, #{item.createOrgId}, #{item.useOrgId}, #{item.prodlineId}, #{item.activeFlag}, #{item.deletedFlag}, #{item.remark}, #{item.purchasePriceUnitId}, #{item.createBy}, #{item.createTime}, #{item.approveDate}, #{item.erpModifyDate}, #{item.updateTime}) - - diff --git a/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesBaseSupplierInfoMapper.xml b/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesBaseSupplierInfoMapper.xml index 7b0f699..dddc85b 100644 --- a/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesBaseSupplierInfoMapper.xml +++ b/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesBaseSupplierInfoMapper.xml @@ -16,10 +16,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + - select supplier_id, supplier_code, supplier_name, erp_id, supplier_status, remark, create_by, create_time, update_by, update_time, audit_date from mes_base_supplier_info + select supplier_id, supplier_code, supplier_name, erp_id, supplier_status, remark, create_by, create_time, update_by, update_time, audit_date,erp_modify_date from mes_base_supplier_info + SELECT max(erp_modify_date) FROM mes_base_supplier_info order by erp_id + + + + + + INSERT INTO mes_base_supplier_info (supplier_code, supplier_name, erp_id, supplier_status, remark, create_by, create_time, update_by, update_time, audit_date, erp_modify_date) VALUES + + (#{item.supplierCode}, #{item.supplierName},#{item.erpId}, #{item.supplierStatus}, #{item.remark}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.auditDate}, #{item.erpModifyDate}) + + + diff --git a/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesProjectInfoMapper.xml b/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesProjectInfoMapper.xml index bcb99ca..adc3d29 100644 --- a/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesProjectInfoMapper.xml +++ b/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesProjectInfoMapper.xml @@ -131,6 +131,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + + INSERT INTO mes_project_info (erp_id, project_no, project_name, document_status, forbid_status, audit_date, erp_modify_date, order_status, complete_date, create_time,update_time) VALUES + + (#{item.erpId}, #{item.projectNo}, #{item.projectName},#{item.documentStatus}, #{item.forbidStatus}, #{item.auditDate}, #{item.erpModifyDate}, #{item.orderStatus}, #{item.completeDate}, #{item.createTime}, #{item.updateTime}) + + + diff --git a/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesPurchaseOrderMapper.xml b/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesPurchaseOrderMapper.xml index 04a7aa6..caf4ebb 100644 --- a/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesPurchaseOrderMapper.xml +++ b/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesPurchaseOrderMapper.xml @@ -198,8 +198,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{purchaseOrderId} - + SELECT max(erp_modify_date) FROM mes_purchase_order order by erp_id,fentry_id + + + + + + + INSERT INTO mes_purchase_order (erp_id, fentry_id, po_no, document_status, material_id, material_code, material_name, order_amount, complete_amount, approve_date, erp_modify_date, plan_delivery_date, order_status, unit_id, stock_unit_id, price_unit_id, aux_prop_id, src_bill_no, purchase_org_id, tond_base, supplier_id, create_time,update_time) VALUES + + (#{item.erpId}, #{item.fentryId}, #{item.poNo},#{item.documentStatus}, #{item.materialId}, #{item.materialCode}, #{item.materialName}, #{item.orderAmount}, #{item.completeAmount}, #{item.approveDate}, #{item.erpModifyDate}, #{item.planDeliveryDate}, #{item.orderStatus}, #{item.unitId}, #{item.stockUnitId}, #{item.priceUnitId}, #{item.auxPropId}, #{item.srcBillNo}, #{item.purchaseOrgId}, #{item.tondBase}, #{item.supplierId}, #{item.createTime},#{item.updateTime}) + + 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 84e5a70..12bc36c 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 @@ -39,6 +39,7 @@ + @@ -253,4 +254,24 @@ where erp_id = #{erpId} + + + + + + + + + + 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 + + (#{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}) + + + 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 7951261..e119ddf 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 @@ -67,15 +67,28 @@ public class RyTask System.out.println("++创建保养工单++getDmsMaintInstance"); remoteDmsService.getDmsBillsMaintInstance(SecurityConstants.INNER,planMaintCode); } - public void ERPSynMesSupplierInfo(String beginTime, String endTime){ + public void syncSupplierInfoFromErp(){ System.out.println("++同步ERP中物料供应商++ErpSupplierInfo"); - remoteJindieService.ErpSupplierInfo(SecurityConstants.INNER); + remoteJindieService.syncSupplierInfoFromErp(SecurityConstants.INNER); } - public void ERPSynMesMaterialInfo(String beginTime, String endTime){ - - //todo 查询createtime>上次执行时间和updatetime>上次执行时间的,要区分是第一次查询还是后续查询 + public void syncMaterialInfoFromErp(){ System.out.println("++同步ERP中物料信息++ErpMesMaterialInfo"); - remoteJindieService.ErpMesMaterialInfo(SecurityConstants.INNER); + remoteJindieService.syncMaterialInfoFromErp(SecurityConstants.INNER); + } + + public void syncProjectInfoFromErp(){ + System.out.println("++同步ERP中项目信息++ErpProjectInfo"); + remoteJindieService.syncProjectInfoFromErp(SecurityConstants.INNER); + } + + public void syncSaleOrderFromErp(){ + System.out.println("++同步ERP中销售订单信息++ErpSaleOrder"); + remoteJindieService.syncSaleOrderFromErp(SecurityConstants.INNER); + } + + public void syncPurchaseOrderFromErp(){ + System.out.println("++同步ERP中采购订单信息++ErpPurchaseOrder"); + remoteJindieService.syncPurchaseOrderFromErp(SecurityConstants.INNER); } }