change - 采购申请单加规格参数同步、定时同步入库信息给ERP

master
yinq 4 months ago
parent cb91161d1e
commit c605167956

@ -44,4 +44,7 @@ public interface RemoteJindieService {
@PostMapping("/jindie/singleSavePurchaseRequisition") @PostMapping("/jindie/singleSavePurchaseRequisition")
R<AjaxResult> singleSavePurchaseRequisition(@RequestBody String params, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); R<AjaxResult> singleSavePurchaseRequisition(@RequestBody String params, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/** 采购入库单保存->提交->审核*/
@PostMapping("/jindie/savePurchaseStorage")
R<AjaxResult> savePurchaseStorage(@RequestBody String params, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
} }

@ -45,6 +45,11 @@ public class RemoteJindieFallbackFactory implements FallbackFactory<RemoteJindie
public R<AjaxResult> singleSavePurchaseRequisition(String params, String source) { public R<AjaxResult> singleSavePurchaseRequisition(String params, String source) {
return R.fail("采购申请单excel导入失败:" + throwable.getMessage()); return R.fail("采购申请单excel导入失败:" + throwable.getMessage());
} }
@Override
public R<AjaxResult> savePurchaseStorage(String params, String source) {
return R.fail("采购入库单同步失败:" + throwable.getMessage());
}
}; };
} }
} }

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.hw</groupId>
<artifactId>hw-api</artifactId>
<version>3.6.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hw-api-wms</artifactId>
<description>
hw-api-wms接口模块
</description>
<dependencies>
<!-- RuoYi Common Core-->
<dependency>
<groupId>com.hw</groupId>
<artifactId>hw-common-core</artifactId>
</dependency>
</dependencies>
</project>

@ -0,0 +1,26 @@
package com.hw.wms.api;
import com.hw.common.core.constant.SecurityConstants;
import com.hw.common.core.constant.ServiceNameConstants;
import com.hw.common.core.domain.R;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.wms.api.factory.RemoteWmsFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
@FeignClient(contextId = "remoteWmsService", value = ServiceNameConstants.WMS_SERVICE, fallbackFactory = RemoteWmsFallbackFactory.class)
public interface RemoteWmsService {
/**
* ERP
* @param source
* @return
*/
@PostMapping("/api/synchronizeInventoryInformationToERP")
public R<AjaxResult> synchronizeInventoryInformationToERP(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}

@ -0,0 +1,31 @@
package com.hw.wms.api.factory;
import com.hw.common.core.domain.R;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.wms.api.RemoteWmsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
/**
* Wms
*
* @author ruoyi
*/
@Component
public class RemoteWmsFallbackFactory implements FallbackFactory<RemoteWmsService> {
private static final Logger log = LoggerFactory.getLogger(RemoteWmsFallbackFactory.class);
@Override
public RemoteWmsService create(Throwable throwable) {
log.error("Wms服务调用失败:{}", throwable.getMessage());
return new RemoteWmsService() {
@Override
public R<AjaxResult> synchronizeInventoryInformationToERP(String source) {
return R.fail("定时同步入库信息给ERP失败:" + throwable.getMessage());
}
};
}
}

@ -17,6 +17,7 @@
<module>hw-api-dms</module> <module>hw-api-dms</module>
<module>hw-api-job</module> <module>hw-api-job</module>
<module>hw-api-jindie</module> <module>hw-api-jindie</module>
<module>hw-api-wms</module>
</modules> </modules>
<artifactId>hw-api</artifactId> <artifactId>hw-api</artifactId>

@ -56,4 +56,8 @@ public class ServiceNameConstants
* jindieserviceid * jindieserviceid
* */ * */
public static final String JINDIE_SERVICE = "hw-jindie"; public static final String JINDIE_SERVICE = "hw-jindie";
/**
* wmsserviceid
* */
public static final String WMS_SERVICE = "hw-wms";
} }

@ -146,7 +146,18 @@ public class MesPurchaseOrder extends BaseEntity {
private Long purchaseOrgId; private Long purchaseOrgId;
//供应商id //供应商id
private Long supplierId; private Long supplierId;
/**
*
*/
private String specificationParameter;
public String getSpecificationParameter() {
return specificationParameter;
}
public void setSpecificationParameter(String specificationParameter) {
this.specificationParameter = specificationParameter;
}
public Long getUnitId() { public Long getUnitId() {
return unitId; return unitId;

@ -211,7 +211,11 @@ public class KingdeeErpService {
FStockIdObject.put("FNumber", FStockId); FStockIdObject.put("FNumber", FStockId);
FEntity.put("FStockId", FStockIdObject); //仓库 FEntity.put("FStockId", FStockIdObject); //仓库
JSONObject FAuxPropIdObject = new JSONObject(); JSONObject FAuxPropIdObject = new JSONObject();
if (StringUtils.isEmpty(FAuxPropId)){
FAuxPropIdObject.put("FAUXPROPID__FF100001", "null");
} else {
FAuxPropIdObject.put("FAUXPROPID__FF100001", FAuxPropId); FAuxPropIdObject.put("FAUXPROPID__FF100001", FAuxPropId);
}
FEntity.put("FAuxPropId", FAuxPropIdObject); //辅助属性 FEntity.put("FAuxPropId", FAuxPropIdObject); //辅助属性
FEntity.put("FSrcBillNo", FSrcBillNo); //源单编号 FEntity.put("FSrcBillNo", FSrcBillNo); //源单编号

@ -762,12 +762,13 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
* @DescrptionERP * @DescrptionERP
*/ */
public int syncPurchaseOrderFromErp(int startRow, String maxErpModifyDate) throws Exception { public int syncPurchaseOrderFromErp(int startRow, String maxErpModifyDate) throws Exception {
maxErpModifyDate = "2022-03-23 11:30:57";
K3CloudApi api = new K3CloudApi(); K3CloudApi api = new K3CloudApi();
// String FDocumentStatus = "C"; // String FDocumentStatus = "C";
JSONObject queryJson = new JSONObject(); JSONObject queryJson = new JSONObject();
String formId = "PUR_PurchaseOrder"; String formId = "PUR_PurchaseOrder";
String fieldKeys = "FID,FBillNo,FApproveDate,FDocumentStatus,FPOOrderEntry_FEntryID,FMaterialId,FMaterialId.FNumber,FMaterialId.FName," + String fieldKeys = "FID,FBillNo,FApproveDate,FDocumentStatus,FPOOrderEntry_FEntryID,FMaterialId,FMaterialId.FNumber,FMaterialId.FName," +
"FQty,FDeliveryDate,FCreateDate,FModifyDate,FUnitId,FStockUnitID,FPriceUnitID,FAuxPropId,FSrcBillNo,FPurchaseOrgId,F_TOND_Base,FSupplierId"; "FQty,FDeliveryDate,FCreateDate,FModifyDate,FUnitId,FStockUnitID,FPriceUnitID,FAuxPropId,FAUXPROPID.FF100001,FSrcBillNo,FPurchaseOrgId,F_TOND_Base,FSupplierId";
// String filterString = ""; // String filterString = "";
String orderString = ""; String orderString = "";
int topRowCount = 0; int topRowCount = 0;
@ -831,6 +832,8 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
Long priceUnitId = resultObject.getLong("FPriceUnitID"); Long priceUnitId = resultObject.getLong("FPriceUnitID");
//辅助属性 //辅助属性
Long auxPropId = resultObject.getLong("FAuxPropId"); Long auxPropId = resultObject.getLong("FAuxPropId");
//规格参数
String FF100001 = resultObject.getString("FAUXPROPID.FF100001");
//源单编号 //源单编号
String srcBillNo = resultObject.getString("FSrcBillNo"); String srcBillNo = resultObject.getString("FSrcBillNo");
//采购组织 //采购组织
@ -857,6 +860,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
mesPurchaseOrder.setStockUnitId(stockUnitId); mesPurchaseOrder.setStockUnitId(stockUnitId);
mesPurchaseOrder.setPriceUnitId(priceUnitId); mesPurchaseOrder.setPriceUnitId(priceUnitId);
mesPurchaseOrder.setAuxPropId(auxPropId); mesPurchaseOrder.setAuxPropId(auxPropId);
mesPurchaseOrder.setSpecificationParameter(FF100001);
mesPurchaseOrder.setSrcBillNo(srcBillNo); mesPurchaseOrder.setSrcBillNo(srcBillNo);
mesPurchaseOrder.setPurchaseOrgId(purchaseOrgId); mesPurchaseOrder.setPurchaseOrgId(purchaseOrgId);
mesPurchaseOrder.setTondBase(tondBase); mesPurchaseOrder.setTondBase(tondBase);

@ -36,6 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="tondBase" column="tond_base" /> <result property="tondBase" column="tond_base" />
<result property="purchaseOrgId" column="purchase_org_id" /> <result property="purchaseOrgId" column="purchase_org_id" />
<result property="supplierId" column="supplier_id" /> <result property="supplierId" column="supplier_id" />
<result property="specificationParameter" column="specification_parameter" />
</resultMap> </resultMap>
<sql id="selectMesPurchaseOrderVo"> <sql id="selectMesPurchaseOrderVo">
@ -43,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
material_id, material_code, material_name, order_amount, complete_amount, material_id, material_code, material_name, order_amount, complete_amount,
approve_date, erp_modify_date, plan_delivery_date, begin_date, end_date, order_status, 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, 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 stock_unit_id,price_unit_id,aux_prop_id,specification_parameter, src_bill_no,tond_base,purchase_org_id,supplier_id
from mes_purchase_order from mes_purchase_order
</sql> </sql>
@ -112,6 +113,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="stockUnitId != null">stock_unit_id,</if> <if test="stockUnitId != null">stock_unit_id,</if>
<if test="priceUnitId != null">price_unit_id,</if> <if test="priceUnitId != null">price_unit_id,</if>
<if test="auxPropId != null">aux_prop_id,</if> <if test="auxPropId != null">aux_prop_id,</if>
<if test="specificationParameter != null">specification_parameter,</if>
<if test="srcBillNo != null">src_bill_no,</if> <if test="srcBillNo != null">src_bill_no,</if>
<if test="tondBase != null">tond_base,</if> <if test="tondBase != null">tond_base,</if>
<if test="purchaseOrgId != null">purchase_org_id,</if> <if test="purchaseOrgId != null">purchase_org_id,</if>
@ -144,6 +146,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="stockUnitId != null">#{stockUnitId},</if> <if test="stockUnitId != null">#{stockUnitId},</if>
<if test="priceUnitId != null">#{priceUnitId},</if> <if test="priceUnitId != null">#{priceUnitId},</if>
<if test="auxPropId != null">#{auxPropId},</if> <if test="auxPropId != null">#{auxPropId},</if>
<if test="specificationParameter != null">#{specificationParameter},</if>
<if test="srcBillNo != null">#{srcBillNo},</if> <if test="srcBillNo != null">#{srcBillNo},</if>
<if test="tondBase != null">#{tondBase},</if> <if test="tondBase != null">#{tondBase},</if>
<if test="purchaseOrgId != null">#{purchaseOrgId},</if> <if test="purchaseOrgId != null">#{purchaseOrgId},</if>
@ -180,6 +183,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="stockUnitId != null">stock_unit_id=#{stockUnitId},</if> <if test="stockUnitId != null">stock_unit_id=#{stockUnitId},</if>
<if test="priceUnitId != null">price_unit_id=#{priceUnitId},</if> <if test="priceUnitId != null">price_unit_id=#{priceUnitId},</if>
<if test="auxPropId != null">aux_prop_id=#{auxPropId},</if> <if test="auxPropId != null">aux_prop_id=#{auxPropId},</if>
<if test="specificationParameter != null">specification_parameter=#{specificationParameter},</if>
<if test="srcBillNo != null">src_bill_no=#{srcBillNo},</if> <if test="srcBillNo != null">src_bill_no=#{srcBillNo},</if>
<if test="tondBase != null">tond_base=#{tondBase},</if> <if test="tondBase != null">tond_base=#{tondBase},</if>
<if test="purchaseOrgId != null">purchase_org_id=#{purchaseOrgId},</if> <if test="purchaseOrgId != null">purchase_org_id=#{purchaseOrgId},</if>
@ -210,9 +214,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="batchMesBasePurchaseOrder"> <insert id="batchMesBasePurchaseOrder">
INSERT INTO mes_purchase_order (erp_id, fentry_id, po_no, document_status, material_id, material_code, material_name, order_amount, complete_amount, approve_date, erp_modify_date, plan_delivery_date, order_status, unit_id, stock_unit_id, price_unit_id, aux_prop_id, src_bill_no, purchase_org_id, tond_base, supplier_id, create_time,update_time) VALUES INSERT INTO mes_purchase_order (erp_id, fentry_id, po_no, document_status, material_id, material_code, material_name, order_amount, complete_amount, approve_date, erp_modify_date, plan_delivery_date, order_status, unit_id, stock_unit_id, price_unit_id, aux_prop_id, specification_parameter, src_bill_no, purchase_org_id, tond_base, supplier_id, create_time,update_time) VALUES
<foreach item="item" index="index" collection="list" separator=","> <foreach item="item" index="index" collection="list" separator=",">
(#{item.erpId}, #{item.fentryId}, #{item.poNo},#{item.documentStatus}, #{item.materialId}, #{item.materialCode}, #{item.materialName}, #{item.orderAmount}, #{item.completeAmount}, #{item.approveDate}, #{item.erpModifyDate}, #{item.planDeliveryDate}, #{item.orderStatus}, #{item.unitId}, #{item.stockUnitId}, #{item.priceUnitId}, #{item.auxPropId}, #{item.srcBillNo}, #{item.purchaseOrgId}, #{item.tondBase}, #{item.supplierId}, #{item.createTime},#{item.updateTime}) (#{item.erpId}, #{item.fentryId}, #{item.poNo},#{item.documentStatus}, #{item.materialId}, #{item.materialCode}, #{item.materialName}, #{item.orderAmount}, #{item.completeAmount}, #{item.approveDate}, #{item.erpModifyDate}, #{item.planDeliveryDate}, #{item.orderStatus}, #{item.unitId}, #{item.stockUnitId}, #{item.priceUnitId}, #{item.auxPropId}, #{specificationParameter},#{item.srcBillNo}, #{item.purchaseOrgId}, #{item.tondBase}, #{item.supplierId}, #{item.createTime},#{item.updateTime})
</foreach> </foreach>
</insert> </insert>
</mapper> </mapper>

@ -96,6 +96,13 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>com.hw</groupId>
<artifactId>hw-api-wms</artifactId>
<version>3.6.3</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

@ -5,6 +5,7 @@ import com.hw.dms.api.RemoteDmsService;
import com.hw.ems.api.RemoteEmsService; import com.hw.ems.api.RemoteEmsService;
import com.hw.jindie.api.RemoteJindieService; import com.hw.jindie.api.RemoteJindieService;
import com.hw.jindie.api.domain.vo.ErpSyncInfoVo; import com.hw.jindie.api.domain.vo.ErpSyncInfoVo;
import com.hw.wms.api.RemoteWmsService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.hw.common.core.utils.StringUtils; import com.hw.common.core.utils.StringUtils;
@ -23,6 +24,10 @@ public class RyTask
private RemoteDmsService remoteDmsService; private RemoteDmsService remoteDmsService;
@Autowired @Autowired
private RemoteJindieService remoteJindieService; private RemoteJindieService remoteJindieService;
@Autowired
private RemoteWmsService remoteWmsService;
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
{ {
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i)); System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
@ -102,4 +107,8 @@ public class RyTask
remoteJindieService.syncPurchaseOrderFromErp(erpSyncInfoVo,SecurityConstants.INNER); remoteJindieService.syncPurchaseOrderFromErp(erpSyncInfoVo,SecurityConstants.INNER);
} }
public void syncInventoryInformationToERP(){
System.out.println("++定时同步入库信息给ERP++ErpPurchaseOrder");
remoteWmsService.synchronizeInventoryInformationToERP(SecurityConstants.INNER);
}
} }

@ -36,6 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<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="specificationParameter" column="specification_parameter" />
</resultMap> </resultMap>
<resultMap id="MesPurchaseOrderMesOrderBindResult" type="MesPurchaseOrder" extends="MesPurchaseOrderResult"> <resultMap id="MesPurchaseOrderMesOrderBindResult" type="MesPurchaseOrder" extends="MesPurchaseOrderResult">
@ -65,7 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectMesPurchaseOrderVo"> <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, unit_id, stock_unit_id, price_unit_id, aux_prop_id, src_bill_no, purchase_org_id, tond_base, supplier_id, remark, create_by, create_time, update_by, update_time from mes_purchase_order 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, unit_id, stock_unit_id, price_unit_id, aux_prop_id, specification_parameter, src_bill_no, purchase_org_id, tond_base, supplier_id, remark, create_by, create_time, update_by, update_time from mes_purchase_order
</sql> </sql>
<select id="selectMesPurchaseOrderList" parameterType="MesPurchaseOrder" resultMap="MesPurchaseOrderResult"> <select id="selectMesPurchaseOrderList" parameterType="MesPurchaseOrder" resultMap="MesPurchaseOrderResult">

@ -82,6 +82,13 @@
<artifactId>hw-api-mes</artifactId> <artifactId>hw-api-mes</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.hw</groupId>
<artifactId>hw-api-jindie</artifactId>
<version>3.6.3</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

@ -45,6 +45,9 @@ public class WmsApiController extends BaseController {
@Autowired @Autowired
private IWmsProductInstockService wmsProductInstockService; private IWmsProductInstockService wmsProductInstockService;
@Autowired
private IWmsErpScheduledTaskService wmsErpScheduledTaskService;
/** /**
* *
@ -178,4 +181,14 @@ public class WmsApiController extends BaseController {
public AjaxResult getNewestOutstockCabinet(WmsRawOutstock wmsRawOutstock) { public AjaxResult getNewestOutstockCabinet(WmsRawOutstock wmsRawOutstock) {
return success(wmsRawOutstockService.getNewestOutstockCabinet(wmsRawOutstock)); return success(wmsRawOutstockService.getNewestOutstockCabinet(wmsRawOutstock));
} }
/**
* ERP
* @return
*/
@PostMapping(("/synchronizeInventoryInformationToERP"))
public AjaxResult synchronizeInventoryInformationToERP() {
return toAjax(wmsErpScheduledTaskService.synchronizeInventoryInformationToERP());
}
} }

@ -114,6 +114,38 @@ public class WmsRawInstock extends BaseEntity
private String materialName; private String materialName;
/** 计量单位编号 */
private String unitCode;
/** 仓库编号 */
private String warehouseCode;
/** 规格参数 */
private String specificationParameter;
public String getSpecificationParameter() {
return specificationParameter;
}
public void setSpecificationParameter(String specificationParameter) {
this.specificationParameter = specificationParameter;
}
public String getWarehouseCode() {
return warehouseCode;
}
public void setWarehouseCode(String warehouseCode) {
this.warehouseCode = warehouseCode;
}
public String getUnitCode() {
return unitCode;
}
public void setUnitCode(String unitCode) {
this.unitCode = unitCode;
}
public void setRawInstockId(Long rawInstockId) public void setRawInstockId(Long rawInstockId)
{ {

@ -77,4 +77,11 @@ public interface WmsRawInstockMapper
* @return * @return
*/ */
public List<WmsRawInstock> selectWmsRawInstockJoinList(WmsRawInstock wmsRawInstock); public List<WmsRawInstock> selectWmsRawInstockJoinList(WmsRawInstock wmsRawInstock);
/**
* ERPList
* @param wmsRawInstock
* @return
*/
public List<WmsRawInstock> selectWmsRawInstockERPNotSynchronized(WmsRawInstock wmsRawInstock);
} }

@ -0,0 +1,20 @@
package com.hw.wms.service;
/**
* erpService
*
* @author Yinq
* @date 2024-07-25
*/
public interface IWmsErpScheduledTaskService {
/**
* ERP
* @return
*/
int synchronizeInventoryInformationToERP();
}

@ -0,0 +1,84 @@
package com.hw.wms.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.hw.common.core.constant.SecurityConstants;
import com.hw.common.core.domain.R;
import com.hw.common.core.utils.DateUtils;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.jindie.api.RemoteJindieService;
import com.hw.wms.domain.WmsRawInstock;
import com.hw.wms.mapper.WmsRawInstockMapper;
import com.hw.wms.service.IWmsErpScheduledTaskService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* erpService
*
* @author Yinq
* @date 2024-07-25
*/
@Service
public class IWmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskService {
private static final Logger log = LoggerFactory.getLogger(IWmsErpScheduledTaskServiceImpl.class);
@Autowired
private WmsRawInstockMapper wmsRawInstockMapper;
@Autowired
private RemoteJindieService remoteJindieService;
/**
* ERP
*
* @return
*/
@Override
public int synchronizeInventoryInformationToERP() {
//仓库编码
String FStockId = "CK002";
WmsRawInstock wmsRawInstock = new WmsRawInstock();
int result = 0;
List<WmsRawInstock> inStockList = wmsRawInstockMapper.selectWmsRawInstockERPNotSynchronized(wmsRawInstock);
Map<Long, List<WmsRawInstock>> materialIdMap = inStockList.stream().collect(Collectors.groupingBy(WmsRawInstock::getMaterialId));
for (Long materialId : materialIdMap.keySet()) {
List<WmsRawInstock> wmsRawInstockList = materialIdMap.get(materialId);
JSONObject data = new JSONObject();
double FRealQty = wmsRawInstockList.stream().mapToDouble(item -> item.getInstockAmount().subtract(item.getErpAmount()).doubleValue()).sum();
WmsRawInstock instock = wmsRawInstockList.get(0);
data.put("FDate", DateUtils.getTime());
data.put("FMaterialId", instock.getMaterialCode());
data.put("FAuxPropId", instock.getSpecificationParameter());
data.put("FSrcBillNo", instock.getPoNo());
data.put("FUnitID", instock.getUnitCode());
data.put("FRealQty", FRealQty);
data.put("FStockId", FStockId);
String params = data.toJSONString();
R<AjaxResult> paramsResult = remoteJindieService.savePurchaseStorage(params, SecurityConstants.INNER);
String paramsResultData = paramsResult.getMsg();
JSONObject jsonObject = JSONObject.parseObject(paramsResultData);
Boolean isSuccess = (Boolean) jsonObject.get("IsSuccess");
if (isSuccess) {
result++;
for (WmsRawInstock rawInstock : wmsRawInstockList) {
rawInstock.setErpStatus("1");//同步ERP状态(0:失败,1成功)
rawInstock.setErpAmount(rawInstock.getInstockAmount());
rawInstock.setUpdateDate(DateUtils.getNowDate());
wmsRawInstockMapper.updateWmsRawInstock(rawInstock);
}
log.info("synchronizeInventoryInformationToERP成功:" + paramsResult.toString());
} else {
log.error("synchronizeInventoryInformationToERP失败:" + paramsResult.toString());
}
}
return result;
}
}

@ -6,7 +6,7 @@ import com.hw.common.core.exception.ServiceException;
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.common.security.utils.SecurityUtils; import com.hw.common.security.utils.SecurityUtils;
import com.hw.printer.api.RemotePrinterService; //import com.hw.printer.api.RemotePrinterService;
import com.hw.wms.domain.WmsBaseLocation; import com.hw.wms.domain.WmsBaseLocation;
import com.hw.wms.domain.WmsBaseWarehouse; import com.hw.wms.domain.WmsBaseWarehouse;
import com.hw.wms.mapper.WmsBaseLocationMapper; import com.hw.wms.mapper.WmsBaseLocationMapper;
@ -33,8 +33,8 @@ public class WmsBaseLocationServiceImpl implements IWmsBaseLocationService {
@Autowired @Autowired
private WmsBaseWarehouseMapper wmsBaseWarehouseMapper; private WmsBaseWarehouseMapper wmsBaseWarehouseMapper;
@Resource // @Resource
private RemotePrinterService remotePrinterService; // private RemotePrinterService remotePrinterService;
/** /**
* *
@ -189,7 +189,7 @@ public class WmsBaseLocationServiceImpl implements IWmsBaseLocationService {
params.put("text", qrCode); params.put("text", qrCode);
params.put("qrCode", qrCode); params.put("qrCode", qrCode);
//调用的打印接口 //调用的打印接口
remotePrinterService.printLocationLabel(params, SecurityConstants.INNER); // remotePrinterService.printLocationLabel(params, SecurityConstants.INNER);
} catch (Exception e) { } catch (Exception e) {
buffer.append("打印料箱条码报错——[条码内容:").append(qrCode).append("]").append(e.getMessage()); buffer.append("打印料箱条码报错——[条码内容:").append(qrCode).append("]").append(e.getMessage());
} }

@ -32,6 +32,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="materialCode" column="material_code" /> <result property="materialCode" column="material_code" />
<result property="materialName" column="material_name" /> <result property="materialName" column="material_name" />
<result property="unitCode" column="unit_code" />
<result property="warehouseCode" column="warehouse_code" />
<result property="specificationParameter" column="specification_parameter" />
</resultMap> </resultMap>
<sql id="selectWmsRawInstockVo"> <sql id="selectWmsRawInstockVo">
@ -189,6 +192,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where> </where>
</select> </select>
<select id="selectWmsRawInstockERPNotSynchronized" parameterType="WmsRawInstock" resultMap="WmsRawInstockResult">
select wri.raw_instock_id,
wri.task_code,
wri.warehouse_id,
wbw.warehouse_code,
wri.instock_type,
wri.material_id,
wri.po_no,
mpo.specification_parameter,
mbmi.material_code,
mbui.unit_code,
wri.instock_amount,
if(wri.erp_amount is null, 0, wri.erp_amount) erp_amount,
wri.erp_status
from wms_raw_instock wri
left join wms_base_warehouse wbw on wbw.warehouse_id = wri.warehouse_id
left join mes_base_material_info mbmi on mbmi.material_id = wri.material_id
left join mes_base_unit_info mbui on mbui.erp_id = mbmi.material_unit_id
left join (select po_no, material_id, max(specification_parameter) specification_parameter
from mes_purchase_order
group by po_no, material_id) mpo on mpo.po_no = wri.po_no and mpo.material_id = wri.material_id
where wri.execute_status = 2
and wri.erp_status != 1
and wri.instock_type in (1, 3)
and wri.instock_amount > if(wri.erp_amount is null, 0, wri.erp_amount)
</select>
</mapper> </mapper>

@ -240,7 +240,12 @@
<artifactId>hw-api-dms</artifactId> <artifactId>hw-api-dms</artifactId>
<version>${hw.version}</version> <version>${hw.version}</version>
</dependency> </dependency>
<!-- wms接口 -->
<dependency>
<groupId>com.hw</groupId>
<artifactId>hw-api-wms</artifactId>
<version>${hw.version}</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>

Loading…
Cancel
Save