change - 采购申请单加规格参数同步、定时同步入库信息给ERP
parent
cb91161d1e
commit
c605167956
@ -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());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
com.hw.wms.api.factory.RemoteWmsFallbackFactory
|
@ -0,0 +1,20 @@
|
||||
package com.hw.wms.service;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* erp定时任务Service业务层处理
|
||||
*
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* erp定时任务Service业务层处理
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue