从erp中同步采购/销售订单数据

master
zhouhy 6 months ago
parent 7ac2b4256e
commit 550fb33713

@ -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();
}
}
} }

@ -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;
/**
* ERPID;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;
/**
* (123)
*/
@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();
}
}

@ -160,6 +160,67 @@ public class MesSaleOrder extends BaseEntity {
*/ */
@Excel(name = "是否标识1-是0-否") @Excel(name = "是否标识1-是0-否")
private String isFlag; 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) { public void setSaleOrderId(Long saleOrderId) {
this.saleOrderId = saleOrderId; this.saleOrderId = saleOrderId;

@ -95,5 +95,10 @@ public interface MesBaseMaterialInfoMapper
*/ */
public int batchMesBaseMaterialInfo(List<MesBaseMaterialInfo> mesBaseMaterialInfos); public int batchMesBaseMaterialInfo(List<MesBaseMaterialInfo> mesBaseMaterialInfos);
/**
*
* */
public MesBaseMaterialInfo selectMesBaseMaterialInfoByCode(String materialCode);
} }

@ -59,4 +59,9 @@ public interface MesProjectInfoMapper
* @return * @return
*/ */
public int deleteMesProjectInfoByProjectIds(Long[] projectIds); public int deleteMesProjectInfoByProjectIds(Long[] projectIds);
/**
* erpid
* */
public MesProjectInfo selectMesProjectInfoByErpId(Long erpId);
} }

@ -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<MesPurchaseOrder> 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);
}

@ -59,4 +59,9 @@ public interface MesSaleOrderMapper
* @return * @return
*/ */
public int deleteMesSaleOrderBySaleOrderIds(Long[] saleOrderIds); public int deleteMesSaleOrderBySaleOrderIds(Long[] saleOrderIds);
/**
* erpid
* */
public MesSaleOrder selectMesSaleOrderByErpId(Long erpId);
} }

@ -4,4 +4,7 @@ public interface IKingdeeErpSyncService {
public int syncSupplierInfoFromErp(int startRow) throws Exception; public int syncSupplierInfoFromErp(int startRow) throws Exception;
public int syncMaterialInfoFromErp(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;
} }

@ -6,15 +6,12 @@ import com.google.gson.Gson;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.hw.common.core.utils.DateUtils; import com.hw.common.core.utils.DateUtils;
import com.hw.common.core.utils.StringUtils; import com.hw.common.core.utils.StringUtils;
import com.hw.jindie.domain.MesBaseMaterialInfo; import com.hw.jindie.domain.*;
import com.hw.jindie.domain.MesBaseSupplierInfo; import com.hw.jindie.mapper.*;
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.service.IKingdeeErpSyncService; import com.hw.jindie.service.IKingdeeErpSyncService;
import com.kingdee.bos.webapi.entity.RepoRet; import com.kingdee.bos.webapi.entity.RepoRet;
import com.kingdee.bos.webapi.sdk.K3CloudApi; import com.kingdee.bos.webapi.sdk.K3CloudApi;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -36,6 +33,12 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
private MesBaseMaterialInfoMapper mesBaseMaterialInfoMapper; private MesBaseMaterialInfoMapper mesBaseMaterialInfoMapper;
@Autowired @Autowired
private MesBaseSupplierInfoMapper mesBaseSupplierInfoMapper; 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)); mesBaseSupplierInfo.setAuditDate(conversionERPTime(FAuditDate));
} }
System.out.println(mesBaseSupplierInfo); // System.out.println(mesBaseSupplierInfo);
//通过erp主键判断表中是否有重复的数据如果有则更新没有则插入 //通过erp主键判断表中是否有重复的数据如果有则更新没有则插入
if (mesBaseSupplierInfos.size() == 0) { if (mesBaseSupplierInfos.size() == 0) {
mesBaseSupplierInfoMapper.insertMesBaseSupplierInfo(mesBaseSupplierInfo); mesBaseSupplierInfoMapper.insertMesBaseSupplierInfo(mesBaseSupplierInfo);
@ -129,7 +132,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
e.printStackTrace(); e.printStackTrace();
} }
} }
if (resultArray.size() < limit) { if (resultArray.size() == limit) {
// System.out.println(startRow); // System.out.println(startRow);
//通过递归同步所有供应商,测试先不用 //通过递归同步所有供应商,测试先不用
int i = syncSupplierInfoFromErp(startRow + resultArray.size()); 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); // System.out.println(startRow);
//通过递归同步所有物料信息,测试先不用 //通过递归同步所有物料信息,测试先不用
int i = syncMaterialInfoFromErp(startRow + resultArray.size()); int i = syncMaterialInfoFromErp(startRow + resultArray.size());
@ -273,19 +276,19 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
* @throws Exception * @throws Exception
* @DescrptionERP * @DescrptionERP
*/ */
public static void syncSaleOrderFromErp() throws Exception { public int syncSaleOrderFromErp(int startRow) throws Exception {
K3CloudApi api = new K3CloudApi(); K3CloudApi api = new K3CloudApi();
String FDocumentStatus = "C"; String FDocumentStatus = "C";
String json = "{\n" + // String json = "{\n" +
" \"FormId\": \"SAL_SaleOrder\",\n" + // " \"FormId\": \"SAL_SaleOrder\",\n" +
" \"FieldKeys\": \"FID,FBillNo,FApproveDate,FSaleOrderEntry_FEntryID,FMaterialId.FNumber,FMaterialName,FQty ,FMinPlanDeliveryDate,\",\n" + // " \"FieldKeys\": \"FID,FBillNo,FApproveDate,FSaleOrderEntry_FEntryID,FMaterialId.FNumber,FMaterialName,FQty ,FMinPlanDeliveryDate,\",\n" +
// " \"FilterString\": \"FDocumentStatus=\'" + FDocumentStatus + "\' and FMaterialGroup.FNUMBER IN ('28') \",\n" + //// " \"FilterString\": \"FDocumentStatus=\'" + FDocumentStatus + "\' and FMaterialGroup.FNUMBER IN ('28') \",\n" +
" \"OrderString\": \"\",\n" + // " \"OrderString\": \"\",\n" +
" \"TopRowCount\": 0,\n" + // " \"TopRowCount\": 0,\n" +
" \"StartRow\": 0,\n" + // " \"StartRow\": 0,\n" +
" \"Limit\": 2000,\n" + // " \"Limit\": 2000,\n" +
" \"SubSystemId\": \"\"\n" + // " \"SubSystemId\": \"\"\n" +
"}"; // "}";
JSONObject queryJson = new JSONObject(); JSONObject queryJson = new JSONObject();
String formId = "SAL_SaleOrder"; String formId = "SAL_SaleOrder";
@ -296,7 +299,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
filterString = ""; filterString = "";
String orderString = ""; String orderString = "";
int topRowCount = 0; int topRowCount = 0;
int startRow = 0; // int startRow = 0;
int limit = 10; int limit = 10;
queryJson.put("FormId", formId); queryJson.put("FormId", formId);
queryJson.put("FieldKeys", fieldKeys); queryJson.put("FieldKeys", fieldKeys);
@ -312,14 +315,120 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
JSONArray resultArray = JSONArray.parseArray(result); JSONArray resultArray = JSONArray.parseArray(result);
System.out.println(resultArray.size()); System.out.println(resultArray.size());
System.out.println("销售订单单据查询接口: " + result); System.out.println("销售订单单据查询接口: " + result);
List<MesSaleOrder> mesSaleOrderListInsert = new ArrayList<>();
List<MesSaleOrder> 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 * @throws Exception
* @DescrptionERP * @DescrptionERP
*/ */
public static void syncProjectInfoFromErp() throws Exception { public int syncProjectInfoFromErp(int startRow) throws Exception {
K3CloudApi api = new K3CloudApi(); K3CloudApi api = new K3CloudApi();
String FDocumentStatus = "C"; String FDocumentStatus = "C";
@ -330,7 +439,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
String filterString = ""; String filterString = "";
String orderString = ""; String orderString = "";
int topRowCount = 0; int topRowCount = 0;
int startRow = 0; // int startRow = 0;
int limit = 20; int limit = 20;
queryJson.put("FormId", formId); queryJson.put("FormId", formId);
queryJson.put("FieldKeys", fieldKeys); queryJson.put("FieldKeys", fieldKeys);
@ -351,6 +460,8 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
try { try {
JSONObject resultObject = (JSONObject) resultArray.get(i); JSONObject resultObject = (JSONObject) resultArray.get(i);
MesProjectInfo mesProjectInfo = new MesProjectInfo(); MesProjectInfo mesProjectInfo = new MesProjectInfo();
List<MesProjectInfo> projectInfoListUpdate = new ArrayList<MesProjectInfo>();
List<MesProjectInfo> projectInfoListInsert = new ArrayList<MesProjectInfo>();
Integer FID = resultObject.get("FID") == null ? 0 : (Integer) resultObject.get("FID"); Integer FID = resultObject.get("FID") == null ? 0 : (Integer) resultObject.get("FID");
String FNumber = resultObject.get("FNumber") == null ? null : (String) resultObject.get("FNumber"); 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 FModifyDate = resultObject.get("FModifyDate") == null ? null : (String) resultObject.get("FModifyDate");
String FCreateDate = resultObject.get("FCreateDate") == null ? null : (String) resultObject.get("FCreateDate"); String FCreateDate = resultObject.get("FCreateDate") == null ? null : (String) resultObject.get("FCreateDate");
mesProjectInfo.setErpId(Long.valueOf(FID)); mesProjectInfo.setErpId(Long.valueOf(FID));
mesProjectInfo.setProjectNo(FNumber); mesProjectInfo.setProjectNo(FNumber);
mesProjectInfo.setProjectName(FName); mesProjectInfo.setProjectName(FName);
@ -369,34 +479,60 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
mesProjectInfo.setForbidStatus(FForbidStatus); mesProjectInfo.setForbidStatus(FForbidStatus);
mesProjectInfo.setIsFlag("1"); mesProjectInfo.setIsFlag("1");
if (StringUtils.isNotEmpty(FAuditDate)) { if (StringUtils.isNotEmpty(FAuditDate)) {
FAuditDate = FAuditDate.replace("T", " "); mesProjectInfo.setAuditDate(conversionERPTime(FAuditDate));
Date date = DateUtils.dateTime("yyyy-MM-dd HH:mm:ss", FAuditDate);
mesProjectInfo.setAuditDate(date);
} }
if (StringUtils.isNotEmpty(FModifyDate)) { if (StringUtils.isNotEmpty(FModifyDate)) {
FModifyDate = FModifyDate.replace("T", " "); mesProjectInfo.setErpModifyDate(conversionERPTime(FModifyDate));
Date date = DateUtils.dateTime("yyyy-MM-dd HH:mm:ss", FModifyDate);
mesProjectInfo.setErpModifyDate(date);
} }
if (StringUtils.isNotEmpty(FCreateDate)) { if (StringUtils.isNotEmpty(FCreateDate)) {
FCreateDate = FCreateDate.replace("T", " "); mesProjectInfo.setCreateTime(conversionERPTime(FCreateDate));
Date date = DateUtils.dateTime("yyyy-MM-dd HH:mm:ss", FCreateDate);
mesProjectInfo.setCreateTime(date);
} }
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) { } catch (Exception e) {
e.printStackTrace(); 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 * @throws Exception
* @DescrptionERP * @DescrptionERP
*/ */
public static void syncPurchaseOrderFromErp() throws Exception { public int syncPurchaseOrderFromErp(int startRow) throws Exception {
K3CloudApi api = new K3CloudApi(); K3CloudApi api = new K3CloudApi();
String FDocumentStatus = "C"; String FDocumentStatus = "C";
@ -408,8 +544,8 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
String filterString = ""; String filterString = "";
String orderString = ""; String orderString = "";
int topRowCount = 0; int topRowCount = 0;
int startRow = 0; // int startRow = 0;
int limit = 200; int limit = 20;
queryJson.put("FormId", formId); queryJson.put("FormId", formId);
queryJson.put("FieldKeys", fieldKeys); queryJson.put("FieldKeys", fieldKeys);
queryJson.put("FilterString", filterString); queryJson.put("FilterString", filterString);
@ -424,6 +560,94 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
JSONArray resultArray = JSONArray.parseArray(result); JSONArray resultArray = JSONArray.parseArray(result);
System.out.println(resultArray.size()); System.out.println(resultArray.size());
System.out.println("采购订单单据查询接口: " + result); System.out.println("采购订单单据查询接口: " + result);
List<MesPurchaseOrder> mesPurchaseOrderListUpdate = new ArrayList<MesPurchaseOrder>();
List<MesPurchaseOrder> 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 { public static void main(String[] args) throws Exception {
@ -431,7 +655,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
// syncMaterialInfoFromErp(); // syncMaterialInfoFromErp();
// syncSaleOrderFromErp(); // syncSaleOrderFromErp();
// syncPurchaseOrderFromErp(); // syncPurchaseOrderFromErp();
syncProjectInfoFromErp(); // syncProjectInfoFromErp();
} }
//将erp中获取的时间string转换为date类型 //将erp中获取的时间string转换为date类型

@ -242,7 +242,7 @@
<select id="selectMaxErpModifyDate" resultMap="String"> <select id="selectMaxErpModifyDate" resultType="String">
<include refid="selectMesBaseMaterialInfoVo"/> <include refid="selectMesBaseMaterialInfoVo"/>
SELECT max(erp_modify_date) FROM mes_base_material_info order by erp_id SELECT max(erp_modify_date) FROM mes_base_material_info order by erp_id
</select> </select>
@ -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}) ( #{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})
</foreach> </foreach>
</insert> </insert>
<select id="selectMesBaseMaterialInfoByCode" parameterType="String" resultMap="MesBaseMaterialInfoResult">
<include refid="selectMesBaseMaterialInfoVo"/>
where material_code = #{materialCode}
</select>
</mapper> </mapper>

@ -128,4 +128,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{projectId} #{projectId}
</foreach> </foreach>
</delete> </delete>
<select id="selectMesProjectInfoByErpId" parameterType="Long" resultMap="MesProjectInfoResult">
<include refid="selectMesProjectInfoVo"/>
where erp_id = #{erpId}
</select>
</mapper> </mapper>

@ -0,0 +1,205 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hw.jindie.mapper.MesPurchaseOrderMapper">
<resultMap type="MesPurchaseOrder" id="MesPurchaseOrderResult">
<result property="purchaseOrderId" column="purchase_order_id" />
<result property="erpId" column="erp_id" />
<result property="fentryId" column="fentry_id" />
<result property="poNo" column="po_no" />
<result property="documentStatus" column="document_status" />
<result property="materialId" column="material_id" />
<result property="materialCode" column="material_code" />
<result property="materialName" column="material_name" />
<result property="orderAmount" column="order_amount" />
<result property="completeAmount" column="complete_amount" />
<result property="approveDate" column="approve_date" />
<result property="erpModifyDate" column="erp_modify_date" />
<result property="planDeliveryDate" column="plan_delivery_date" />
<result property="beginDate" column="begin_date" />
<result property="endDate" column="end_date" />
<result property="orderStatus" column="order_status" />
<result property="completeDate" column="complete_date" />
<result property="isFlag" column="is_flag" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="unitId" column="unit_id" />
<result property="stockUnitId" column="stock_unit_id" />
<result property="priceUnitId" column="price_unit_id" />
<result property="auxPropId" column="aux_prop_id" />
<result property="srcBillNo" column="src_bill_no" />
<result property="tondBase" column="tond_base" />
<result property="purchaseOrgId" column="purchase_org_id" />
<result property="supplierId" column="supplier_id" />
</resultMap>
<sql id="selectMesPurchaseOrderVo">
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
</sql>
<select id="selectMesPurchaseOrderList" parameterType="MesPurchaseOrder" resultMap="MesPurchaseOrderResult">
<include refid="selectMesPurchaseOrderVo"/>
<where>
<if test="erpId != null "> and erp_id = #{erpId}</if>
<if test="fentryId != null "> and fentry_id = #{fentryId}</if>
<if test="poNo != null and poNo != ''"> and po_no = #{poNo}</if>
<if test="documentStatus != null and documentStatus != ''"> and document_status = #{documentStatus}</if>
<if test="materialId != null "> and material_id = #{materialId}</if>
<if test="materialCode != null and materialCode != ''"> and material_code = #{materialCode}</if>
<if test="materialName != null and materialName != ''"> and material_name like concat('%', #{materialName}, '%')</if>
<if test="orderAmount != null "> and order_amount = #{orderAmount}</if>
<if test="completeAmount != null "> and complete_amount = #{completeAmount}</if>
<if test="approveDate != null "> and approve_date = #{approveDate}</if>
<if test="erpModifyDate != null "> and erp_modify_date = #{erpModifyDate}</if>
<if test="planDeliveryDate != null "> and plan_delivery_date = #{planDeliveryDate}</if>
<if test="beginDate != null "> and begin_date = #{beginDate}</if>
<if test="endDate != null "> and end_date = #{endDate}</if>
<if test="orderStatus != null and orderStatus != ''"> and order_status = #{orderStatus}</if>
<if test="completeDate != null "> and complete_date = #{completeDate}</if>
<if test="isFlag != null and isFlag != ''"> and is_flag = #{isFlag}</if>
<if test="unitId != null and unitId != ''"> and unit_id = #{unitId}</if>
<if test="stockUnitId != null and stockUnitId != ''"> and stock_unit_id = #{stockUnitId}</if>
<if test="priceUnitId != null and priceUnitId != ''"> and price_unit_id = #{priceUnitId}</if>
<if test="auxPropId != null and auxPropId != ''"> and aux_prop_id = #{auxPropId}</if>
<if test="srcBillNo != null and srcBillNo != ''"> and src_bill_no = #{srcBillNo}</if>
<if test="tondBase != null and tondBase != ''"> and tond_base = #{tondBase}</if>
<if test="purchaseOrgId != null and purchaseOrgId != ''"> and purchase_org_id = #{purchaseOrgId}</if>
<if test="supplierId != null and supplierId != ''"> and supplier_id = #{supplierId}</if>
</where>
</select>
<select id="selectMesPurchaseOrderByPurchaseOrderId" parameterType="Long" resultMap="MesPurchaseOrderResult">
<include refid="selectMesPurchaseOrderVo"/>
where purchase_order_id = #{purchaseOrderId}
</select>
<insert id="insertMesPurchaseOrder" parameterType="MesPurchaseOrder" useGeneratedKeys="true" keyProperty="purchaseOrderId">
insert into mes_purchase_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="erpId != null">erp_id,</if>
<if test="fentryId != null">fentry_id,</if>
<if test="poNo != null">po_no,</if>
<if test="documentStatus != null">document_status,</if>
<if test="materialId != null">material_id,</if>
<if test="materialCode != null and materialCode != ''">material_code,</if>
<if test="materialName != null">material_name,</if>
<if test="orderAmount != null">order_amount,</if>
<if test="completeAmount != null">complete_amount,</if>
<if test="approveDate != null">approve_date,</if>
<if test="erpModifyDate != null">erp_modify_date,</if>
<if test="planDeliveryDate != null">plan_delivery_date,</if>
<if test="beginDate != null">begin_date,</if>
<if test="endDate != null">end_date,</if>
<if test="orderStatus != null">order_status,</if>
<if test="completeDate != null">complete_date,</if>
<if test="isFlag != null and isFlag != ''">is_flag,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="unitId != null">unit_id,</if>
<if test="stockUnitId != null">stock_unit_id,</if>
<if test="priceUnitId != null">price_unit_id,</if>
<if test="auxPropId != null">aux_prop_id,</if>
<if test="srcBillNo != null">src_bill_no,</if>
<if test="tondBase != null">tond_base,</if>
<if test="purchaseOrgId != null">purchase_org_id,</if>
<if test="supplierId != null">supplier_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="erpId != null">#{erpId},</if>
<if test="fentryId != null">#{fentryId},</if>
<if test="poNo != null">#{poNo},</if>
<if test="documentStatus != null">#{documentStatus},</if>
<if test="materialId != null">#{materialId},</if>
<if test="materialCode != null and materialCode != ''">#{materialCode},</if>
<if test="materialName != null">#{materialName},</if>
<if test="orderAmount != null">#{orderAmount},</if>
<if test="completeAmount != null">#{completeAmount},</if>
<if test="approveDate != null">#{approveDate},</if>
<if test="erpModifyDate != null">#{erpModifyDate},</if>
<if test="planDeliveryDate != null">#{planDeliveryDate},</if>
<if test="beginDate != null">#{beginDate},</if>
<if test="endDate != null">#{endDate},</if>
<if test="orderStatus != null">#{orderStatus},</if>
<if test="completeDate != null">#{completeDate},</if>
<if test="isFlag != null and isFlag != ''">#{isFlag},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="unitId != null">#{unitId},</if>
<if test="stockUnitId != null">#{stockUnitId},</if>
<if test="priceUnitId != null">#{priceUnitId},</if>
<if test="auxPropId != null">#{auxPropId},</if>
<if test="srcBillNo != null">#{srcBillNo},</if>
<if test="tondBase != null">#{tondBase},</if>
<if test="purchaseOrgId != null">#{purchaseOrgId},</if>
<if test="supplierId != null">#{supplierId},</if>
</trim>
</insert>
<update id="updateMesPurchaseOrder" parameterType="MesPurchaseOrder">
update mes_purchase_order
<trim prefix="SET" suffixOverrides=",">
<if test="erpId != null">erp_id = #{erpId},</if>
<if test="fentryId != null">fentry_id = #{fentryId},</if>
<if test="poNo != null">po_no = #{poNo},</if>
<if test="documentStatus != null">document_status = #{documentStatus},</if>
<if test="materialId != null">material_id = #{materialId},</if>
<if test="materialCode != null and materialCode != ''">material_code = #{materialCode},</if>
<if test="materialName != null">material_name = #{materialName},</if>
<if test="orderAmount != null">order_amount = #{orderAmount},</if>
<if test="completeAmount != null">complete_amount = #{completeAmount},</if>
<if test="approveDate != null">approve_date = #{approveDate},</if>
<if test="erpModifyDate != null">erp_modify_date = #{erpModifyDate},</if>
<if test="planDeliveryDate != null">plan_delivery_date = #{planDeliveryDate},</if>
<if test="beginDate != null">begin_date = #{beginDate},</if>
<if test="endDate != null">end_date = #{endDate},</if>
<if test="orderStatus != null">order_status = #{orderStatus},</if>
<if test="completeDate != null">complete_date = #{completeDate},</if>
<if test="isFlag != null and isFlag != ''">is_flag = #{isFlag},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="unitId != null">unit_id=#{unitId},</if>
<if test="stockUnitId != null">stock_unit_id=#{stockUnitId},</if>
<if test="priceUnitId != null">price_unit_id=#{priceUnitId},</if>
<if test="auxPropId != null">aux_prop_id=#{auxPropId},</if>
<if test="srcBillNo != null">src_bill_no=#{srcBillNo},</if>
<if test="tondBase != null">tond_base=#{tondBase},</if>
<if test="purchaseOrgId != null">purchase_org_id=#{purchaseOrgId},</if>
<if test="supplierId != null">supplier_id=#{supplierId},</if>
</trim>
where purchase_order_id = #{purchaseOrderId}
</update>
<delete id="deleteMesPurchaseOrderByPurchaseOrderId" parameterType="Long">
delete from mes_purchase_order where purchase_order_id = #{purchaseOrderId}
</delete>
<delete id="deleteMesPurchaseOrderByPurchaseOrderIds" parameterType="String">
delete from mes_purchase_order where purchase_order_id in
<foreach item="purchaseOrderId" collection="array" open="(" separator="," close=")">
#{purchaseOrderId}
</foreach>
</delete>
<select id="selectMesPurchaseOrderByErpId" parameterType="Long" resultMap="MesPurchaseOrderResult">
<include refid="selectMesPurchaseOrderVo"/>
where erp_id = #{erpId}
</select>
</mapper>

@ -10,7 +10,7 @@
<result property="fentryId" column="fentry_id"/> <result property="fentryId" column="fentry_id"/>
<result property="saleorderCode" column="saleorder_code"/> <result property="saleorderCode" column="saleorder_code"/>
<result property="saleorderLinenumber" column="saleorder_linenumber"/> <result property="saleorderLinenumber" column="saleorder_linenumber"/>
<result property="documentStatus" column="document_status"/> <result property="documentStatus" column="document_statsu"/>
<result property="factoryId" column="factory_id"/> <result property="factoryId" column="factory_id"/>
<result property="prodlineId" column="prodline_id"/> <result property="prodlineId" column="prodline_id"/>
<result property="materialId" column="material_id"/> <result property="materialId" column="material_id"/>
@ -33,6 +33,12 @@
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/> <result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/> <result property="updateTime" column="update_time"/>
<result property="auxPropId" column="aux_prop_id"/>
<result property="stockId" column="stock_id"/>
<result property="saleDeptId" column="sale_dept_id"/>
<result property="ownerId" column="owner_id"/>
<result property="price" column="price"/>
<result property="stockOrgId" column="stock_org_id"/>
</resultMap> </resultMap>
<sql id="selectMesSaleOrderVo"> <sql id="selectMesSaleOrderVo">
@ -41,7 +47,7 @@
fentry_id, fentry_id,
saleorder_code, saleorder_code,
saleorder_linenumber, saleorder_linenumber,
document_status, document_statsu,
factory_id, factory_id,
prodline_id, prodline_id,
material_id, material_id,
@ -63,7 +69,13 @@
create_by, create_by,
create_time, create_time,
update_by, update_by,
update_time update_time,
aux_prop_id,
stock_id,
sale_dept_id,
owner_id,
price,
stock_org_id
from mes_sale_order from mes_sale_order
</sql> </sql>
@ -76,7 +88,7 @@
<if test="saleorderLinenumber != null and saleorderLinenumber != ''">and saleorder_linenumber = <if test="saleorderLinenumber != null and saleorderLinenumber != ''">and saleorder_linenumber =
#{saleorderLinenumber} #{saleorderLinenumber}
</if> </if>
<if test="documentStatus != null and documentStatus != ''">and document_status = #{documentStatus}</if> <if test="documentStatus != null and documentStatus != ''">and document_statsu = #{documentStatus}</if>
<if test="factoryId != null ">and factory_id = #{factoryId}</if> <if test="factoryId != null ">and factory_id = #{factoryId}</if>
<if test="prodlineId != null ">and prodline_id = #{prodlineId}</if> <if test="prodlineId != null ">and prodline_id = #{prodlineId}</if>
<if test="materialId != null ">and material_id = #{materialId}</if> <if test="materialId != null ">and material_id = #{materialId}</if>
@ -96,6 +108,12 @@
<if test="endDate != null ">and end_date = #{endDate}</if> <if test="endDate != null ">and end_date = #{endDate}</if>
<if test="completeDate != null ">and complete_date = #{completeDate}</if> <if test="completeDate != null ">and complete_date = #{completeDate}</if>
<if test="isFlag != null and isFlag != ''">and is_flag = #{isFlag}</if> <if test="isFlag != null and isFlag != ''">and is_flag = #{isFlag}</if>
<if test="auxPropId != null and auxPropId != ''">and aux_prop_id = #{auxPropId}</if>
<if test="stockId != null and stockId != ''">and stock_id = #{stockId}</if>
<if test="saleDeptId != null and saleDeptId != ''">and sale_dept_id = #{saleDeptId}</if>
<if test="ownerId != null and ownerId != ''">and owner_id = #{ownerId}</if>
<if test="price != null and price != ''">and price = #{price}</if>
<if test="stockOrgId != null and stockOrgId != ''">and stock_org_id = #{stockOrgId}</if>
</where> </where>
</select> </select>
@ -111,7 +129,7 @@
<if test="fentryId != null">fentry_id,</if> <if test="fentryId != null">fentry_id,</if>
<if test="saleorderCode != null">saleorder_code,</if> <if test="saleorderCode != null">saleorder_code,</if>
<if test="saleorderLinenumber != null">saleorder_linenumber,</if> <if test="saleorderLinenumber != null">saleorder_linenumber,</if>
<if test="documentStatus != null">document_status,</if> <if test="documentStatus != null">document_statsu,</if>
<if test="factoryId != null">factory_id,</if> <if test="factoryId != null">factory_id,</if>
<if test="prodlineId != null">prodline_id,</if> <if test="prodlineId != null">prodline_id,</if>
<if test="materialId != null">material_id,</if> <if test="materialId != null">material_id,</if>
@ -134,6 +152,12 @@
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if> <if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if> <if test="updateTime != null">update_time,</if>
<if test="auxPropId != null">aux_prop_id,</if>
<if test="stockId != null">stock_id,</if>
<if test="saleDeptId != null">sale_dept_id,</if>
<if test="ownerId != null">owner_id,</if>
<if test="price != null">price,</if>
<if test="stockOrgId != null">stock_org_id,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="erpId != null">#{erpId},</if> <if test="erpId != null">#{erpId},</if>
@ -163,6 +187,12 @@
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if> <if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if> <if test="updateTime != null">#{updateTime},</if>
<if test="auxPropId != null">#{auxPropId},</if>
<if test="stockId != null">#{stockId},</if>
<if test="saleDeptId != null">#{saleDeptId},</if>
<if test="ownerId != null">#{ownerId},</if>
<if test="price != null">#{price},</if>
<if test="stockOrgId != null">#{stockOrgId},</if>
</trim> </trim>
</insert> </insert>
@ -173,7 +203,7 @@
<if test="fentryId != null">fentry_id = #{fentryId},</if> <if test="fentryId != null">fentry_id = #{fentryId},</if>
<if test="saleorderCode != null">saleorder_code = #{saleorderCode},</if> <if test="saleorderCode != null">saleorder_code = #{saleorderCode},</if>
<if test="saleorderLinenumber != null">saleorder_linenumber = #{saleorderLinenumber},</if> <if test="saleorderLinenumber != null">saleorder_linenumber = #{saleorderLinenumber},</if>
<if test="documentStatus != null">document_status = #{documentStatus},</if> <if test="documentStatus != null">document_statsu = #{documentStatus},</if>
<if test="factoryId != null">factory_id = #{factoryId},</if> <if test="factoryId != null">factory_id = #{factoryId},</if>
<if test="prodlineId != null">prodline_id = #{prodlineId},</if> <if test="prodlineId != null">prodline_id = #{prodlineId},</if>
<if test="materialId != null">material_id = #{materialId},</if> <if test="materialId != null">material_id = #{materialId},</if>
@ -196,6 +226,12 @@
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
<if test="auxPropId != null">aux_prop_id=#{auxPropId},</if>
<if test="stockId != null">stock_id=#{stockId},</if>
<if test="saleDeptId != null">sale_dept_id=#{saleDeptId},</if>
<if test="ownerId != null">owner_id=#{ownerId},</if>
<if test="price != null">price=#{price},</if>
<if test="stockOrgId != null">stock_org_id=#{stockOrgId},</if>
</trim> </trim>
where sale_order_id = #{saleOrderId} where sale_order_id = #{saleOrderId}
</update> </update>
@ -212,4 +248,9 @@
#{saleOrderId} #{saleOrderId}
</foreach> </foreach>
</delete> </delete>
<select id="selectMesSaleOrderByErpId" parameterType="Long" resultMap="MesSaleOrderResult">
<include refid="selectMesSaleOrderVo"/>
where erp_id = #{erpId}
</select>
</mapper> </mapper>

Loading…
Cancel
Save