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 875e712..8866da5 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 @@ -193,4 +193,41 @@ 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/MesPurchaseOrder.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesPurchaseOrder.java new file mode 100644 index 0000000..82b7709 --- /dev/null +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/domain/MesPurchaseOrder.java @@ -0,0 +1,387 @@ +package com.hw.jindie.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.hw.common.core.annotation.Excel; +import com.hw.common.core.web.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 采购订单信息对象 mes_purchase_order + * + * @author Yinq + * @date 2024-02-19 + */ +public class MesPurchaseOrder extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * 主键标识 + */ + private Long purchaseOrderId; + + /** + * ERP主键信息;对应FID + */ + @Excel(name = "ERP主键信息") + private Long erpId; + + /** + * 金蝶ERP订单明细ID;对应FPOOrderEntry.FEntryID + */ + @Excel(name = "金蝶ERP订单明细ID") + private Long fentryId; + + /** + * 采购订单编号;对应FBillNo + */ + @Excel(name = "采购订单编号") + private String poNo; + + /** + * 单据状态;FDocumentStatus + */ + @Excel(name = "单据状态") + private String documentStatus; + + /** + * 物料ID,关联物料信息主键 + */ + @Excel(name = "物料ID") + private Long materialId; + + /** + * 物料编码;对应FMaterialId.FNumber + */ + @Excel(name = "物料编码") + private String materialCode; + + /** + * 物料名称;对应FMaterialId.FName + */ + @Excel(name = "物料名称") + private String materialName; + + /** + * 订单计划数量;对应FQty + */ + @Excel(name = "订单计划数量") + private BigDecimal orderAmount; + + /** + * 完成采购数量 + */ + @Excel(name = "完成采购数量") + private BigDecimal completeAmount; + + /** + * 审核日期;对应FApproveDate + */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "审核日期;对应FApproveDate", width = 30, dateFormat = "yyyy-MM-dd") + private Date approveDate; + + /** + * ERP最后修改日期;对应FModifyDate + */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "ERP最后修改日期;对应FModifyDate", width = 30, dateFormat = "yyyy-MM-dd") + private Date erpModifyDate; + + /** + * 计划交货日期;对应FDeliveryDate + */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "计划交货日期;对应FDeliveryDate", width = 30, dateFormat = "yyyy-MM-dd") + private Date planDeliveryDate; + + /** + * 计划开始日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "计划开始日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date beginDate; + + /** + * 计划结束日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "计划结束日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date endDate; + + /** + * 订单状态(1待采购2采购中3采购完成) + */ + @Excel(name = "订单状态(1待采购2采购中3采购完成)") + private String orderStatus; + + /** + * 完成日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "完成日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date completeDate; + + /** + * 是否标识:1-是;0-否 + */ + @Excel(name = "是否标识:1-是;0-否") + private String isFlag; + //采购单位id + private String unitId; + //库存单位 + private Long stockUnitId; + //计价单位 + private Long priceUnitId; + //辅助属性 + private Long auxPropId; + //源单编号 + private String srcBillNo; + //采购组织 + private String tondBase; + //京源项目 + private Long purchaseOrgId; + //供应商id + private Long supplierId; + + + public String getUnitId() { + return unitId; + } + + public void setUnitId(String unitId) { + this.unitId = unitId; + } + + public Long getStockUnitId() { + return stockUnitId; + } + + public void setStockUnitId(Long stockUnitId) { + this.stockUnitId = stockUnitId; + } + + public Long getPriceUnitId() { + return priceUnitId; + } + + public void setPriceUnitId(Long priceUnitId) { + this.priceUnitId = priceUnitId; + } + + public Long getAuxPropId() { + return auxPropId; + } + + public void setAuxPropId(Long auxPropId) { + this.auxPropId = auxPropId; + } + + public String getSrcBillNo() { + return srcBillNo; + } + + public void setSrcBillNo(String srcBillNo) { + this.srcBillNo = srcBillNo; + } + + public String getTondBase() { + return tondBase; + } + + public void setTondBase(String tondBase) { + this.tondBase = tondBase; + } + + public Long getPurchaseOrgId() { + return purchaseOrgId; + } + + public void setPurchaseOrgId(Long purchaseOrgId) { + this.purchaseOrgId = purchaseOrgId; + } + + public Long getSupplierId() { + return supplierId; + } + + public void setSupplierId(Long supplierId) { + this.supplierId = supplierId; + } + + public void setPurchaseOrderId(Long purchaseOrderId) { + this.purchaseOrderId = purchaseOrderId; + } + + public Long getPurchaseOrderId() { + return purchaseOrderId; + } + + public void setErpId(Long erpId) { + this.erpId = erpId; + } + + public Long getErpId() { + return erpId; + } + + public void setFentryId(Long fentryId) { + this.fentryId = fentryId; + } + + public Long getFentryId() { + return fentryId; + } + + public void setPoNo(String poNo) { + this.poNo = poNo; + } + + public String getPoNo() { + return poNo; + } + + public void setDocumentStatus(String documentStatus) { + this.documentStatus = documentStatus; + } + + public String getDocumentStatus() { + return documentStatus; + } + + public void setMaterialId(Long materialId) { + this.materialId = materialId; + } + + public Long getMaterialId() { + return materialId; + } + + public void setMaterialCode(String materialCode) { + this.materialCode = materialCode; + } + + public String getMaterialCode() { + return materialCode; + } + + public void setMaterialName(String materialName) { + this.materialName = materialName; + } + + public String getMaterialName() { + return materialName; + } + + public void setOrderAmount(BigDecimal orderAmount) { + this.orderAmount = orderAmount; + } + + public BigDecimal getOrderAmount() { + return orderAmount; + } + + public void setCompleteAmount(BigDecimal completeAmount) { + this.completeAmount = completeAmount; + } + + public BigDecimal getCompleteAmount() { + return completeAmount; + } + + public void setApproveDate(Date approveDate) { + this.approveDate = approveDate; + } + + public Date getApproveDate() { + return approveDate; + } + + public void setErpModifyDate(Date erpModifyDate) { + this.erpModifyDate = erpModifyDate; + } + + public Date getErpModifyDate() { + return erpModifyDate; + } + + public void setPlanDeliveryDate(Date planDeliveryDate) { + this.planDeliveryDate = planDeliveryDate; + } + + public Date getPlanDeliveryDate() { + return planDeliveryDate; + } + + public void setBeginDate(Date beginDate) { + this.beginDate = beginDate; + } + + public Date getBeginDate() { + return beginDate; + } + + public void setEndDate(Date endDate) { + this.endDate = endDate; + } + + public Date getEndDate() { + return endDate; + } + + public void setOrderStatus(String orderStatus) { + this.orderStatus = orderStatus; + } + + public String getOrderStatus() { + return orderStatus; + } + + public void setCompleteDate(Date completeDate) { + this.completeDate = completeDate; + } + + public Date getCompleteDate() { + return completeDate; + } + + public void setIsFlag(String isFlag) { + this.isFlag = isFlag; + } + + public String getIsFlag() { + return isFlag; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("purchaseOrderId", getPurchaseOrderId()) + .append("erpId", getErpId()) + .append("fentryId", getFentryId()) + .append("poNo", getPoNo()) + .append("documentStatus", getDocumentStatus()) + .append("materialId", getMaterialId()) + .append("materialCode", getMaterialCode()) + .append("materialName", getMaterialName()) + .append("orderAmount", getOrderAmount()) + .append("completeAmount", getCompleteAmount()) + .append("approveDate", getApproveDate()) + .append("erpModifyDate", getErpModifyDate()) + .append("planDeliveryDate", getPlanDeliveryDate()) + .append("beginDate", getBeginDate()) + .append("endDate", getEndDate()) + .append("orderStatus", getOrderStatus()) + .append("completeDate", getCompleteDate()) + .append("isFlag", getIsFlag()) + .append("remark", getRemark()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} 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 73dbecc..74a4858 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 @@ -160,6 +160,67 @@ public class MesSaleOrder extends BaseEntity { */ @Excel(name = "是否标识:1-是;0-否") private String isFlag; + //辅助属性 + private Long auxPropId; + //仓库 + private Long stockId; + //销售部门 + private Long saleDeptId; + //货主 + private Long ownerId; + //单价 + private BigDecimal price; + //库存组织 + private Long stockOrgId; + + + public Long getStockId() { + return stockId; + } + + public void setStockId(Long stockId) { + this.stockId = stockId; + } + + public Long getSaleDeptId() { + return saleDeptId; + } + + public void setSaleDeptId(Long saleDeptId) { + this.saleDeptId = saleDeptId; + } + + public Long getOwnerId() { + return ownerId; + } + + public void setOwnerId(Long ownerId) { + this.ownerId = ownerId; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public Long getStockOrgId() { + return stockOrgId; + } + + public void setStockOrgId(Long stockOrgId) { + this.stockOrgId = stockOrgId; + } + + public Long getAuxPropId() { + return auxPropId; + } + + public void setAuxPropId(Long auxPropId) { + this.auxPropId = auxPropId; + } public void setSaleOrderId(Long saleOrderId) { this.saleOrderId = saleOrderId; 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 504d119..158f95b 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 @@ -95,5 +95,10 @@ 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/MesProjectInfoMapper.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesProjectInfoMapper.java index 814d58e..fb5e9d4 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 @@ -59,4 +59,9 @@ public interface MesProjectInfoMapper * @return 结果 */ public int deleteMesProjectInfoByProjectIds(Long[] projectIds); + + /** + * 根据erpid查询 + * */ + public MesProjectInfo selectMesProjectInfoByErpId(Long erpId); } 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 new file mode 100644 index 0000000..768e2f8 --- /dev/null +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/mapper/MesPurchaseOrderMapper.java @@ -0,0 +1,66 @@ +package com.hw.jindie.mapper; + +import com.hw.jindie.domain.MesPurchaseOrder; + +import java.util.List; + +/** + * 采购订单信息Mapper接口 + * + * @author Yinq + * @date 2024-02-19 + */ +public interface MesPurchaseOrderMapper +{ + /** + * 查询采购订单信息 + * + * @param purchaseOrderId 采购订单信息主键 + * @return 采购订单信息 + */ + public MesPurchaseOrder selectMesPurchaseOrderByPurchaseOrderId(Long purchaseOrderId); + + /** + * 查询采购订单信息列表 + * + * @param mesPurchaseOrder 采购订单信息 + * @return 采购订单信息集合 + */ + public List selectMesPurchaseOrderList(MesPurchaseOrder mesPurchaseOrder); + + /** + * 新增采购订单信息 + * + * @param mesPurchaseOrder 采购订单信息 + * @return 结果 + */ + public int insertMesPurchaseOrder(MesPurchaseOrder mesPurchaseOrder); + + /** + * 修改采购订单信息 + * + * @param mesPurchaseOrder 采购订单信息 + * @return 结果 + */ + public int updateMesPurchaseOrder(MesPurchaseOrder mesPurchaseOrder); + + /** + * 删除采购订单信息 + * + * @param purchaseOrderId 采购订单信息主键 + * @return 结果 + */ + public int deleteMesPurchaseOrderByPurchaseOrderId(Long purchaseOrderId); + + /** + * 批量删除采购订单信息 + * + * @param purchaseOrderIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteMesPurchaseOrderByPurchaseOrderIds(Long[] purchaseOrderIds); + /** + * 根据erpid查询 + * */ + public MesPurchaseOrder selectMesPurchaseOrderByErpId(Long erpId); +} 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 431e908..f44c9e7 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 @@ -59,4 +59,9 @@ public interface MesSaleOrderMapper * @return 结果 */ public int deleteMesSaleOrderBySaleOrderIds(Long[] saleOrderIds); + + /** + * 通过erpid查询 + * */ + public MesSaleOrder selectMesSaleOrderByErpId(Long erpId); } 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 99f30de..cd35a7b 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 @@ -4,4 +4,7 @@ public interface IKingdeeErpSyncService { public int syncSupplierInfoFromErp(int startRow) throws Exception; public int syncMaterialInfoFromErp(int startRow) 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 9276b11..4c4c179 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 @@ -6,15 +6,12 @@ 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.MesBaseMaterialInfo; -import com.hw.jindie.domain.MesBaseSupplierInfo; -import com.hw.jindie.domain.MesProjectInfo; -import com.hw.jindie.domain.MesSaleOrder; -import com.hw.jindie.mapper.MesBaseMaterialInfoMapper; -import com.hw.jindie.mapper.MesBaseSupplierInfoMapper; +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; @@ -36,6 +33,12 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { private MesBaseMaterialInfoMapper mesBaseMaterialInfoMapper; @Autowired private MesBaseSupplierInfoMapper mesBaseSupplierInfoMapper; + @Autowired + private MesProjectInfoMapper mesProjectInfoMapper; + @Autowired + private MesSaleOrderMapper mesSaleOrderMapper; + @Autowired + private MesPurchaseOrderMapper mesPurchaseOrderMapper; /** @@ -116,7 +119,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { mesBaseSupplierInfo.setAuditDate(conversionERPTime(FAuditDate)); } - System.out.println(mesBaseSupplierInfo); +// System.out.println(mesBaseSupplierInfo); //通过erp主键判断,表中是否有重复的数据,如果有则更新,没有则插入 if (mesBaseSupplierInfos.size() == 0) { mesBaseSupplierInfoMapper.insertMesBaseSupplierInfo(mesBaseSupplierInfo); @@ -129,7 +132,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { e.printStackTrace(); } } - if (resultArray.size() < limit) { + if (resultArray.size() == limit) { // System.out.println(startRow); //通过递归同步所有供应商,测试先不用 int i = syncSupplierInfoFromErp(startRow + resultArray.size()); @@ -255,7 +258,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { } /**分页递归获取所有物料信息*/ - if (resultArray.size() < limit) { + if (resultArray.size() == limit) { // System.out.println(startRow); //通过递归同步所有物料信息,测试先不用 int i = syncMaterialInfoFromErp(startRow + resultArray.size()); @@ -273,19 +276,19 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { * @throws Exception * @Descrption:从金蝶ERP同步销售订单 */ - public static void syncSaleOrderFromErp() throws Exception { + public int syncSaleOrderFromErp(int startRow) throws Exception { K3CloudApi api = new K3CloudApi(); String FDocumentStatus = "C"; - String json = "{\n" + - " \"FormId\": \"SAL_SaleOrder\",\n" + - " \"FieldKeys\": \"FID,FBillNo,FApproveDate,FSaleOrderEntry_FEntryID,FMaterialId.FNumber,FMaterialName,FQty ,FMinPlanDeliveryDate,\",\n" + -// " \"FilterString\": \"FDocumentStatus=\'" + FDocumentStatus + "\' and FMaterialGroup.FNUMBER IN ('28') \",\n" + - " \"OrderString\": \"\",\n" + - " \"TopRowCount\": 0,\n" + - " \"StartRow\": 0,\n" + - " \"Limit\": 2000,\n" + - " \"SubSystemId\": \"\"\n" + - "}"; +// String json = "{\n" + +// " \"FormId\": \"SAL_SaleOrder\",\n" + +// " \"FieldKeys\": \"FID,FBillNo,FApproveDate,FSaleOrderEntry_FEntryID,FMaterialId.FNumber,FMaterialName,FQty ,FMinPlanDeliveryDate,\",\n" + +//// " \"FilterString\": \"FDocumentStatus=\'" + FDocumentStatus + "\' and FMaterialGroup.FNUMBER IN ('28') \",\n" + +// " \"OrderString\": \"\",\n" + +// " \"TopRowCount\": 0,\n" + +// " \"StartRow\": 0,\n" + +// " \"Limit\": 2000,\n" + +// " \"SubSystemId\": \"\"\n" + +// "}"; JSONObject queryJson = new JSONObject(); String formId = "SAL_SaleOrder"; @@ -296,7 +299,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { filterString = ""; String orderString = ""; int topRowCount = 0; - int startRow = 0; +// int startRow = 0; int limit = 10; queryJson.put("FormId", formId); queryJson.put("FieldKeys", fieldKeys); @@ -312,14 +315,120 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { 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); + } +// 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); +// } +// } + + } + catch (Exception e) + { + e.printStackTrace(); + } + } + /**分页递归获取所有物料信息*/ + if (resultArray.size() == limit) { +// System.out.println(startRow); + //通过递归同步所有物料信息,测试先不用 + int i = syncSaleOrderFromErp(startRow + resultArray.size()); +// return i; + return 1; + } else { + //为空时的总行数 + return startRow + resultArray.size(); + } } + /** * @throws Exception * @Descrption:从金蝶ERP同步项目信息 */ - public static void syncProjectInfoFromErp() throws Exception { + public int syncProjectInfoFromErp(int startRow) throws Exception { K3CloudApi api = new K3CloudApi(); String FDocumentStatus = "C"; @@ -330,7 +439,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { String filterString = ""; String orderString = ""; int topRowCount = 0; - int startRow = 0; +// int startRow = 0; int limit = 20; queryJson.put("FormId", formId); queryJson.put("FieldKeys", fieldKeys); @@ -351,6 +460,8 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { 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"); @@ -361,7 +472,6 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { 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)); mesProjectInfo.setProjectNo(FNumber); mesProjectInfo.setProjectName(FName); @@ -369,34 +479,60 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { mesProjectInfo.setForbidStatus(FForbidStatus); mesProjectInfo.setIsFlag("1"); if (StringUtils.isNotEmpty(FAuditDate)) { - FAuditDate = FAuditDate.replace("T", " "); - Date date = DateUtils.dateTime("yyyy-MM-dd HH:mm:ss", FAuditDate); - mesProjectInfo.setAuditDate(date); + mesProjectInfo.setAuditDate(conversionERPTime(FAuditDate)); } if (StringUtils.isNotEmpty(FModifyDate)) { - FModifyDate = FModifyDate.replace("T", " "); - Date date = DateUtils.dateTime("yyyy-MM-dd HH:mm:ss", FModifyDate); - mesProjectInfo.setErpModifyDate(date); + mesProjectInfo.setErpModifyDate(conversionERPTime(FModifyDate)); } if (StringUtils.isNotEmpty(FCreateDate)) { - FCreateDate = FCreateDate.replace("T", " "); - Date date = DateUtils.dateTime("yyyy-MM-dd HH:mm:ss", FCreateDate); - mesProjectInfo.setCreateTime(date); + mesProjectInfo.setCreateTime(conversionERPTime(FCreateDate)); } - System.out.println(mesProjectInfo); +// System.out.println(mesProjectInfo); + MesProjectInfo mesProjectInfo1 = mesProjectInfoMapper.selectMesProjectInfoByErpId(mesProjectInfo.getErpId()); + 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); + } + } } catch (Exception e) { e.printStackTrace(); } } + /**分页递归获取所有物料信息*/ + if (resultArray.size() == limit) { +// System.out.println(startRow); + //通过递归同步所有物料信息,测试先不用 + int i = syncProjectInfoFromErp(startRow + resultArray.size()); +// return i; + return 1; + } else { + //为空时的总行数 + return startRow + resultArray.size(); + } } /** * @throws Exception * @Descrption:从金蝶ERP同步采购订单 */ - public static void syncPurchaseOrderFromErp() throws Exception { + public int syncPurchaseOrderFromErp(int startRow) throws Exception { K3CloudApi api = new K3CloudApi(); String FDocumentStatus = "C"; @@ -408,8 +544,8 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { String filterString = ""; String orderString = ""; int topRowCount = 0; - int startRow = 0; - int limit = 200; +// int startRow = 0; + int limit = 20; queryJson.put("FormId", formId); queryJson.put("FieldKeys", fieldKeys); queryJson.put("FilterString", filterString); @@ -424,6 +560,94 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { 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{ + JSONObject resultObject = (JSONObject) resultArray.get(i); + MesPurchaseOrder mesPurchaseOrder = new MesPurchaseOrder(); + //erpid + Integer erpId = resultObject.get("FID")==null?null :(Integer) resultObject.get("FID"); + //采购订单编号 + String poNo = resultObject.get("FBillNo")==null?null :(String) resultObject.get("FBillNo"); + //审核日期 + String approveDate = resultObject.get("FApproveDate")==null?null :(String) resultObject.get("FApproveDate"); + //单据状态 + String documentStatus = resultObject.get("FDocumentStatus")==null?null :(String) resultObject.get("FDocumentStatus"); + //订单明细id + Integer fentryId = resultObject.get("FPOOrderEntry.FEntryID")==null?null:(Integer) resultObject.get("FPOOrderEntry.FEntryID"); + //物料编码 + String materialCode = resultObject.get("FMaterialId.FNumber")==null?null:(String) resultObject.get("FMaterialId.FNumber"); + //物料名称 + String materialName = resultObject.get("FMaterialId.FName")==null?null:(String) resultObject.get("FMaterialId.FName"); + //订单计划数量 + BigDecimal orderAmount = resultObject.get("FQty")==null?new BigDecimal(0):(BigDecimal) resultObject.get("FQty"); + //计划交货日期 + String planDeliveryDate = resultObject.get("FDeliveryDate")==null?null:(String) resultObject.get("FDeliveryDate"); + //采购单位 + Integer unitId = resultObject.get("FUnitId")==null?null:(Integer) resultObject.get("FUnitId"); + //库存单位 + Integer stockUnitId = resultObject.get("FStockUnitID")==null?null:(Integer) resultObject.get("FStockUnitID"); + //计价单位 + Integer priceUnitId = resultObject.get("FPriceUnitID")==null?null:(Integer) resultObject.get("FPriceUnitID"); + //辅助属性 + Integer auxPropId = resultObject.get("FAuxPropId") == null?null:(Integer) resultObject.get("FAuxPropId"); + //源单编号 + String srcBillNo = resultObject.get("FSrcBillNo") == null?null:(String) resultObject.get("FSrcBillNo"); + //采购组织 + Integer purchaseOrgId = resultObject.get("FPurchaseOrgId") ==null?null:(Integer) resultObject.get("FPurchaseOrgId"); + //京源项目 + String tondBase = resultObject.get("F_TOND_Base")==null?null:(String) resultObject.get("F_TOND_Base"); + //供应商id + Integer supplierId = resultObject.get("FSupplierId")==null?null:(Integer) resultObject.get("FSupplierId"); + + mesPurchaseOrder.setErpId(Long.valueOf(erpId)); + mesPurchaseOrder.setPoNo(poNo); + mesPurchaseOrder.setDocumentStatus(documentStatus); + mesPurchaseOrder.setFentryId(Long.valueOf(fentryId)); + mesPurchaseOrder.setMaterialCode(materialCode); + mesPurchaseOrder.setMaterialCode(materialName); + mesPurchaseOrder.setOrderAmount(orderAmount); + mesPurchaseOrder.setUnitId(unitId.toString()); + mesPurchaseOrder.setStockUnitId(Long.valueOf(stockUnitId)); + mesPurchaseOrder.setPriceUnitId(Long.valueOf(priceUnitId)); + mesPurchaseOrder.setAuxPropId(Long.valueOf(auxPropId)); + mesPurchaseOrder.setSrcBillNo(srcBillNo); + mesPurchaseOrder.setPurchaseOrgId(Long.valueOf(purchaseOrgId)); + mesPurchaseOrder.setTondBase(tondBase); + mesPurchaseOrder.setSupplierId(Long.valueOf(supplierId)); + if (approveDate!=null){ + mesPurchaseOrder.setApproveDate(conversionERPTime(approveDate)); + } + if (planDeliveryDate!=null){ + mesPurchaseOrder.setPlanDeliveryDate(conversionERPTime(planDeliveryDate)); + } + MesPurchaseOrder mesPurchaseOrder1 = mesPurchaseOrderMapper.selectMesPurchaseOrderByErpId(Long.valueOf(erpId)); + if (mesPurchaseOrder1!=null){ + mesPurchaseOrder.setPurchaseOrgId(mesPurchaseOrder1.getPurchaseOrgId()); + mesPurchaseOrderMapper.updateMesPurchaseOrder(mesPurchaseOrder); + } + else { + mesPurchaseOrderMapper.insertMesPurchaseOrder(mesPurchaseOrder); + } + + + + }catch (Exception e){ + e.printStackTrace(); + } + } + /**分页递归获取所有物料信息*/ + if (resultArray.size() == limit) { +// System.out.println(startRow); + //通过递归同步所有物料信息,测试先不用 + int i = syncPurchaseOrderFromErp(startRow + resultArray.size()); +// return i; + return 1; + } else { + //为空时的总行数 + return startRow + resultArray.size(); + } } public static void main(String[] args) throws Exception { @@ -431,7 +655,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService { // syncMaterialInfoFromErp(); // syncSaleOrderFromErp(); // syncPurchaseOrderFromErp(); - syncProjectInfoFromErp(); +// syncProjectInfoFromErp(); } //将erp中获取的时间string转换为date类型 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 fe24330..2eaf955 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 @@ -242,7 +242,7 @@ - SELECT max(erp_modify_date) FROM mes_base_material_info order by erp_id @@ -258,6 +258,10 @@ ( #{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}) + 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 b958453..bcb99ca 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 @@ -128,4 +128,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{projectId} + + 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 new file mode 100644 index 0000000..04a7aa6 --- /dev/null +++ b/hw-modules/hw-jindie/src/main/resources/mapper/jindie/MesPurchaseOrderMapper.xml @@ -0,0 +1,205 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select purchase_order_id, 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, begin_date, end_date, order_status, + complete_date, is_flag, remark, create_by, create_time, update_by, update_time ,unit_id, + stock_unit_id,price_unit_id,aux_prop_id,src_bill_no,tond_base,purchase_org_id,supplier_id + from mes_purchase_order + + + + + + + + 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, + begin_date, + end_date, + order_status, + complete_date, + is_flag, + remark, + create_by, + create_time, + update_by, + update_time, + unit_id, + stock_unit_id, + price_unit_id, + aux_prop_id, + src_bill_no, + tond_base, + purchase_org_id, + supplier_id, + + + #{erpId}, + #{fentryId}, + #{poNo}, + #{documentStatus}, + #{materialId}, + #{materialCode}, + #{materialName}, + #{orderAmount}, + #{completeAmount}, + #{approveDate}, + #{erpModifyDate}, + #{planDeliveryDate}, + #{beginDate}, + #{endDate}, + #{orderStatus}, + #{completeDate}, + #{isFlag}, + #{remark}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{unitId}, + #{stockUnitId}, + #{priceUnitId}, + #{auxPropId}, + #{srcBillNo}, + #{tondBase}, + #{purchaseOrgId}, + #{supplierId}, + + + + + update mes_purchase_order + + erp_id = #{erpId}, + fentry_id = #{fentryId}, + po_no = #{poNo}, + document_status = #{documentStatus}, + material_id = #{materialId}, + material_code = #{materialCode}, + material_name = #{materialName}, + order_amount = #{orderAmount}, + complete_amount = #{completeAmount}, + approve_date = #{approveDate}, + erp_modify_date = #{erpModifyDate}, + plan_delivery_date = #{planDeliveryDate}, + begin_date = #{beginDate}, + end_date = #{endDate}, + order_status = #{orderStatus}, + complete_date = #{completeDate}, + is_flag = #{isFlag}, + remark = #{remark}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + unit_id=#{unitId}, + stock_unit_id=#{stockUnitId}, + price_unit_id=#{priceUnitId}, + aux_prop_id=#{auxPropId}, + src_bill_no=#{srcBillNo}, + tond_base=#{tondBase}, + purchase_org_id=#{purchaseOrgId}, + supplier_id=#{supplierId}, + + where purchase_order_id = #{purchaseOrderId} + + + + delete from mes_purchase_order where purchase_order_id = #{purchaseOrderId} + + + + delete from mes_purchase_order where purchase_order_id in + + #{purchaseOrderId} + + + + 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 0102cba..84e5a70 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 @@ - + @@ -33,6 +33,12 @@ + + + + + + @@ -41,7 +47,7 @@ fentry_id, saleorder_code, saleorder_linenumber, - document_status, + document_statsu, factory_id, prodline_id, material_id, @@ -63,7 +69,13 @@ create_by, create_time, update_by, - update_time + update_time, + aux_prop_id, + stock_id, + sale_dept_id, + owner_id, + price, + stock_org_id from mes_sale_order @@ -76,7 +88,7 @@ and saleorder_linenumber = #{saleorderLinenumber} - and document_status = #{documentStatus} + and document_statsu = #{documentStatus} and factory_id = #{factoryId} and prodline_id = #{prodlineId} and material_id = #{materialId} @@ -96,6 +108,12 @@ and end_date = #{endDate} and complete_date = #{completeDate} and is_flag = #{isFlag} + and aux_prop_id = #{auxPropId} + and stock_id = #{stockId} + and sale_dept_id = #{saleDeptId} + and owner_id = #{ownerId} + and price = #{price} + and stock_org_id = #{stockOrgId} @@ -111,7 +129,7 @@ fentry_id, saleorder_code, saleorder_linenumber, - document_status, + document_statsu, factory_id, prodline_id, material_id, @@ -134,6 +152,12 @@ create_time, update_by, update_time, + aux_prop_id, + stock_id, + sale_dept_id, + owner_id, + price, + stock_org_id, #{erpId}, @@ -163,6 +187,12 @@ #{createTime}, #{updateBy}, #{updateTime}, + #{auxPropId}, + #{stockId}, + #{saleDeptId}, + #{ownerId}, + #{price}, + #{stockOrgId}, @@ -173,7 +203,7 @@ fentry_id = #{fentryId}, saleorder_code = #{saleorderCode}, saleorder_linenumber = #{saleorderLinenumber}, - document_status = #{documentStatus}, + document_statsu = #{documentStatus}, factory_id = #{factoryId}, prodline_id = #{prodlineId}, material_id = #{materialId}, @@ -196,6 +226,12 @@ create_time = #{createTime}, update_by = #{updateBy}, update_time = #{updateTime}, + aux_prop_id=#{auxPropId}, + stock_id=#{stockId}, + sale_dept_id=#{saleDeptId}, + owner_id=#{ownerId}, + price=#{price}, + stock_org_id=#{stockOrgId}, where sale_order_id = #{saleOrderId} @@ -212,4 +248,9 @@ #{saleOrderId} + +