add:中鼎接口对接
This commit is contained in:
@@ -17,6 +17,7 @@ import org.springframework.http.ResponseEntity;import org.nl.common.base.Respons
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -71,6 +72,13 @@ public class MaterialbaseController {
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@PostMapping("/pushZd")
|
||||
@Log("下推物料同步至中鼎WMS")
|
||||
public ResponseEntity<Object> pushZd(@RequestBody List<String> ids) {
|
||||
iMdMeMaterialbaseService.pushZd(ids);
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
// @PostMapping("/materialInfoSync")
|
||||
// @Log("物料信息同步")
|
||||
// @SaIgnore
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
|
||||
//import org.nl.wms.basedata_manage.service.dto.MaterialInfoSyncQuery;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -53,6 +54,11 @@ public interface IMdMeMaterialbaseService extends IService<MdMeMaterialbase> {
|
||||
*/
|
||||
void materialSync(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 勾选物料下推同步至中鼎 WMS。
|
||||
*/
|
||||
void pushZd(List<String> ids);
|
||||
|
||||
/**
|
||||
* 根据编码获取物料
|
||||
* @param material_code 物料编码
|
||||
|
||||
@@ -21,12 +21,14 @@ import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdPbMeasureunit;
|
||||
//import org.nl.wms.basedata_manage.service.dto.MaterialInfoSyncQuery;
|
||||
import org.nl.wms.basedata_manage.service.dao.mapper.MdMeMaterialbaseMapper;
|
||||
import org.nl.wms.ext_manage.api.ZDWmsApi;
|
||||
import org.nl.wms.ext_manage.service.WmsToErpService;
|
||||
import org.nl.wms.ext_manage.service.dto.ErpMaterial;
|
||||
import org.nl.wms.ext_manage.service.impl.ErpSyncService;
|
||||
import org.nl.wms.pm_manage.sap.outBoundDelivery.service.impl.OutboundDeliveryServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -60,6 +62,8 @@ public class MdMeMaterialbaseServiceImpl extends ServiceImpl<MdMeMaterialbaseMap
|
||||
*/
|
||||
@Autowired
|
||||
private IMdPbMeasureunitService iMdPbMeasureunitService;
|
||||
@Autowired
|
||||
private ZDWmsApi zdWmsApi;
|
||||
|
||||
@Override
|
||||
public IPage<MdMeMaterialbase> queryAll(Map whereJson, PageQuery page) {
|
||||
@@ -171,6 +175,18 @@ public class MdMeMaterialbaseServiceImpl extends ServiceImpl<MdMeMaterialbaseMap
|
||||
// this.saveBatch(materDaoList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushZd(List<String> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
throw new BadRequestException("下推失败:未选择物料");
|
||||
}
|
||||
List<MdMeMaterialbase> materials = this.listByIds(ids);
|
||||
if (CollectionUtils.isEmpty(materials)) {
|
||||
throw new BadRequestException("下推失败:物料不存在");
|
||||
}
|
||||
zdWmsApi.syncMaterial(materials);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public IPage<MdMeMaterialbase> syncMaterialInfo(MaterialInfoSyncQuery query) {
|
||||
// int pageNum = 0;
|
||||
|
||||
@@ -0,0 +1,436 @@
|
||||
package org.nl.wms.ext_manage.api;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.wms.basedata_manage.service.IMdPbClassstandardService;
|
||||
import org.nl.wms.basedata_manage.service.IMdPbMeasureunitService;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdPbClassstandard;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdPbMeasureunit;
|
||||
import org.nl.wms.pm_manage.sap.materialDocument.service.dao.MaterialDocumentItem;
|
||||
import org.nl.wms.pm_manage.sap.materialDocument.service.dto.MaterialDocumentFormDto;
|
||||
import org.nl.wms.pm_manage.sap.outBoundDelivery.service.dao.OutboundDelivery;
|
||||
import org.nl.wms.pm_manage.sap.outBoundDelivery.service.dao.OutboundDeliveryItem;
|
||||
import org.nl.wms.system_manage.enums.SysParamConstant;
|
||||
import org.nl.wms.system_manage.service.param.dao.Param;
|
||||
import org.nl.wms.system_manage.service.param.impl.SysParamServiceImpl;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 中鼎 WMS 接口。
|
||||
* 物料主数据对应接口文档 3.6(WMS_MES_002),采购入库对应 3.8(WMS_SAP_001)。
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ZDWmsApi {
|
||||
|
||||
/**
|
||||
* 下推 SAP 物料凭证至中鼎 WMS。地址为 ZD_SAP_URL(insertSapRkd)。
|
||||
*/
|
||||
public ResponseEntity insertSapWlpz(List<MaterialDocumentFormDto> materialDocumentFormDtos, int billType, String externalType) {
|
||||
if (CollectionUtils.isEmpty(materialDocumentFormDtos)) {
|
||||
throw new BadRequestException("中鼎单据下推失败:未选择单据");
|
||||
}
|
||||
String url = requireZdSapUrl();
|
||||
JSONObject lastResult = null;
|
||||
for (MaterialDocumentFormDto dto : materialDocumentFormDtos) {
|
||||
JSONObject body = buildMaterialDocumentPayload(dto, externalType);
|
||||
lastResult = postZd(url, body, "insertSapWlpz");
|
||||
}
|
||||
return new ResponseEntity(lastResult, HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下推 SAP 交货单至中鼎 WMS。地址由 ZD_SAP_URL 推导为 insertSapWwJhd。
|
||||
*/
|
||||
public ResponseEntity insertSapJhd(OutboundDelivery order, List<OutboundDeliveryItem> items, int billType, String externalType) {
|
||||
String url = requireZdSapUrl();
|
||||
JSONObject body = buildDeliveryPayload(order, items, externalType);
|
||||
JSONObject result = postZd(url, body, "insertSapJhd");
|
||||
return new ResponseEntity(result, HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下推物料主数据至中鼎 WMS。请求体为物料数组。
|
||||
*/
|
||||
public ResponseEntity syncMaterial(List<MdMeMaterialbase> materials) {
|
||||
if (CollectionUtils.isEmpty(materials)) {
|
||||
throw new BadRequestException("中鼎物料下推失败:未选择物料");
|
||||
}
|
||||
Param param = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode(SysParamConstant.ZD_MATER_SYNC);
|
||||
if (param == null || StrUtil.isBlank(param.getValue())) {
|
||||
throw new BadRequestException("中鼎物料下推失败:未配置ZD_MATER_SYNC");
|
||||
}
|
||||
String url = param.getValue().trim();
|
||||
JSONArray body = buildMaterialPayload(materials);
|
||||
log.info("接口地址:{}", url);
|
||||
log.info("syncMaterial请求参数:{}", body.toJSONString());
|
||||
try {
|
||||
String resultMsg = HttpRequest.post(url)
|
||||
.contentType("application/json")
|
||||
.body(body.toJSONString())
|
||||
.execute()
|
||||
.body();
|
||||
JSONObject result = JSONObject.parseObject(resultMsg);
|
||||
if (result == null) {
|
||||
throw new BadRequestException("中鼎物料下推失败:返回为空");
|
||||
}
|
||||
log.info("syncMaterial:-------------------{}", result);
|
||||
assertSuccess(result);
|
||||
return new ResponseEntity(result, HttpStatus.OK);
|
||||
} catch (BadRequestException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("中鼎物料下推失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装物料主数据同步请求,请求体为数组。
|
||||
*/
|
||||
private JSONArray buildMaterialPayload(List<MdMeMaterialbase> materials) {
|
||||
Set<String> classIds = materials.stream()
|
||||
.map(MdMeMaterialbase::getMaterial_type_id)
|
||||
.filter(StrUtil::isNotBlank)
|
||||
.collect(Collectors.toSet());
|
||||
Set<String> unitIds = materials.stream()
|
||||
.map(MdMeMaterialbase::getQty_unit_id)
|
||||
.filter(StrUtil::isNotBlank)
|
||||
.collect(Collectors.toSet());
|
||||
Map<String, MdPbClassstandard> classMap = classIds.isEmpty()
|
||||
? Collections.emptyMap()
|
||||
: SpringContextHolder.getBean(IMdPbClassstandardService.class).listByIds(classIds).stream()
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toMap(MdPbClassstandard::getClass_id, Function.identity(), (a, b) -> a));
|
||||
Map<String, MdPbMeasureunit> unitMap = unitIds.isEmpty()
|
||||
? Collections.emptyMap()
|
||||
: SpringContextHolder.getBean(IMdPbMeasureunitService.class).listByIds(unitIds).stream()
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toMap(MdPbMeasureunit::getMeasure_unit_id, Function.identity(), (a, b) -> a));
|
||||
JSONArray items = new JSONArray();
|
||||
for (MdMeMaterialbase material : materials) {
|
||||
if (material == null || StrUtil.isBlank(material.getMaterial_code())) {
|
||||
throw new BadRequestException("中鼎物料下推失败:物料编码为空");
|
||||
}
|
||||
if (StrUtil.isBlank(material.getMaterial_name())) {
|
||||
throw new BadRequestException("中鼎物料下推失败:物料" + material.getMaterial_code() + "名称为空");
|
||||
}
|
||||
String skuCode = material.getMaterial_code().trim();
|
||||
MdPbClassstandard materialClass = classMap.get(material.getMaterial_type_id());
|
||||
MdPbMeasureunit unit = unitMap.get(material.getQty_unit_id());
|
||||
String unitCode = unit == null ? "" : StrUtil.blankToDefault(unit.getUnit_code(), "");
|
||||
String unitName = unit == null ? "" : StrUtil.blankToDefault(unit.getUnit_name(), "");
|
||||
if (StrUtil.isBlank(unitCode)) {
|
||||
unitCode = StrUtil.blankToDefault(material.getQty_unit_name(), "");
|
||||
}
|
||||
if (StrUtil.isBlank(unitName)) {
|
||||
unitName = StrUtil.blankToDefault(material.getQty_unit_name(), unitCode);
|
||||
}
|
||||
if (StrUtil.isBlank(unitCode)) {
|
||||
throw new BadRequestException("中鼎物料下推失败:物料" + skuCode + "单位为空");
|
||||
}
|
||||
JSONObject row = new JSONObject(true);
|
||||
row.put("skuCode", skuCode);
|
||||
row.put("skuName", material.getMaterial_name().trim());
|
||||
row.put("skuSpec", StrUtil.blankToDefault(StrUtil.blankToDefault(material.getMaterial_spec(), material.getMaterial_model()), ""));
|
||||
row.put("categoryCode", materialClass == null ? "" : StrUtil.blankToDefault(materialClass.getClass_code(), ""));
|
||||
row.put("categoryName", materialClass == null ? "" : StrUtil.blankToDefault(materialClass.getClass_name(), ""));
|
||||
row.put("unitCode", unitCode.trim());
|
||||
row.put("unitName", unitName.trim());
|
||||
row.put("status", 0);
|
||||
items.add(row);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
private int parseMaterialStatus(String isUsed) {
|
||||
if (StrUtil.isBlank(isUsed) || "1".equals(isUsed.trim())) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private String requireZdSapUrl() {
|
||||
Param param = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode(SysParamConstant.ZD_SAP_URL);
|
||||
if (param == null || StrUtil.isBlank(param.getValue())) {
|
||||
throw new BadRequestException("中鼎单据下推失败:未配置ZD_SAP_URL");
|
||||
}
|
||||
return param.getValue().trim();
|
||||
}
|
||||
|
||||
|
||||
private JSONObject postZd(String url, JSONObject body, String action) {
|
||||
log.info("接口地址:{}", url);
|
||||
log.info("{}请求参数:{}", action, body.toJSONString());
|
||||
try {
|
||||
String resultMsg = HttpRequest.post(url)
|
||||
.contentType("application/json")
|
||||
.body(body.toJSONString())
|
||||
.execute()
|
||||
.body();
|
||||
JSONObject result = JSONObject.parseObject(resultMsg);
|
||||
if (result == null) {
|
||||
throw new BadRequestException("中鼎单据下推失败:返回为空");
|
||||
}
|
||||
log.info("{}:-------------------{}", action, result);
|
||||
assertSuccess(result);
|
||||
return result;
|
||||
} catch (BadRequestException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("中鼎单据下推失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 入库为 1,出库为 2。委外入库按约定为 2。
|
||||
*/
|
||||
private int resolveBillType(String externalType) {
|
||||
if (StrUtil.isBlank(externalType)) {
|
||||
throw new BadRequestException("中鼎单据下推失败:单据类型为空");
|
||||
}
|
||||
switch (externalType.trim()) {
|
||||
case "TRANSFER_IN":
|
||||
case "PURCHASE_IN":
|
||||
case "SUBCONTRACT_RETURN_IN":
|
||||
case "OTHER_IN":
|
||||
case "SALES_RETURN_IN":
|
||||
return 1;
|
||||
case "TRANSFER_OUT":
|
||||
case "SUBCONTRACT_IN":
|
||||
case "OTHER_OUT":
|
||||
case "SUBCONTRACT_OUT":
|
||||
case "SALES_OUT":
|
||||
return 2;
|
||||
default:
|
||||
throw new BadRequestException("中鼎单据下推失败:不支持的单据类型" + externalType);
|
||||
}
|
||||
}
|
||||
|
||||
private JSONObject buildMaterialDocumentPayload(MaterialDocumentFormDto dto, String externalType) {
|
||||
if (dto == null || StrUtil.isBlank(dto.getMblnr())) {
|
||||
throw new BadRequestException("中鼎单据下推失败:物料凭证号为空");
|
||||
}
|
||||
if (StrUtil.isBlank(dto.getMjahr())) {
|
||||
throw new BadRequestException("中鼎单据下推失败:单据" + dto.getMblnr() + "年份为空");
|
||||
}
|
||||
if (CollectionUtils.isEmpty(dto.getItems())) {
|
||||
throw new BadRequestException("中鼎单据下推失败:单据" + dto.getMblnr() + "明细为空");
|
||||
}
|
||||
String mblnr = dto.getMblnr().trim();
|
||||
String mjahr = dto.getMjahr().trim();
|
||||
JSONObject body = new JSONObject(true);
|
||||
body.put("externalId", mblnr + "/" + mjahr);
|
||||
body.put("externalNo", mblnr);
|
||||
body.put("billType", resolveBillType(externalType));
|
||||
body.put("externalType", externalType);
|
||||
if (StrUtil.isNotBlank(dto.getUsnam())) {
|
||||
body.put("creator", dto.getUsnam().trim());
|
||||
}
|
||||
String createTime = formatCreateTime(dto.getBudat(), dto.getBldat());
|
||||
if (StrUtil.isNotBlank(createTime)) {
|
||||
body.put("createTime", createTime);
|
||||
}
|
||||
body.put("status", 0);
|
||||
JSONArray itemList = new JSONArray();
|
||||
int index = 1;
|
||||
for (MaterialDocumentItem item : dto.getItems()) {
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
int zeile = item.getZeile() == null ? index : item.getZeile();
|
||||
if (StrUtil.isBlank(item.getLgort())) {
|
||||
throw new BadRequestException("中鼎单据下推失败:单据" + mblnr + "行" + zeile + "库存地点为空");
|
||||
}
|
||||
if (StrUtil.isBlank(item.getMatnr())) {
|
||||
throw new BadRequestException("中鼎单据下推失败:单据" + mblnr + "行" + zeile + "物料编号为空");
|
||||
}
|
||||
if (StrUtil.isBlank(item.getMaktx())) {
|
||||
throw new BadRequestException("中鼎单据下推失败:单据" + mblnr + "行" + zeile + "物料描述为空");
|
||||
}
|
||||
if (item.getMenge() == null) {
|
||||
throw new BadRequestException("中鼎单据下推失败:单据" + mblnr + "行" + zeile + "数量为空");
|
||||
}
|
||||
if (StrUtil.isBlank(item.getMeins())) {
|
||||
throw new BadRequestException("中鼎单据下推失败:单据" + mblnr + "行" + zeile + "单位为空");
|
||||
}
|
||||
JSONObject row = new JSONObject(true);
|
||||
row.put("externalItemId", mblnr + "/" + zeile);
|
||||
row.put("externalItemNo", String.valueOf(zeile));
|
||||
row.put("houseCode", item.getLgort().trim());
|
||||
row.put("skuCode", item.getMatnr().trim());
|
||||
row.put("skuName", item.getMaktx().trim());
|
||||
row.put("skuSpec", "");
|
||||
row.put("batchNo", StrUtil.blankToDefault(item.getCharg(), ""));
|
||||
row.put("qty", item.getMenge());
|
||||
row.put("unit", item.getMeins().trim());
|
||||
row.put("itemStatus", 0);
|
||||
row.put("trackNo", "");
|
||||
itemList.add(row);
|
||||
index++;
|
||||
}
|
||||
if (itemList.isEmpty()) {
|
||||
throw new BadRequestException("中鼎单据下推失败:单据" + mblnr + "明细为空");
|
||||
}
|
||||
body.put("itemList", itemList);
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按 SAP 交货单同步报文组装。externalId、externalNo 均为交货单号,status=0。
|
||||
* 委外交货出库把组件追加成明细:skuCode 取组件物料,数量取组件数量,行号为 posnr-rspos。
|
||||
*/
|
||||
private JSONObject buildDeliveryPayload(OutboundDelivery order, List<OutboundDeliveryItem> items, String externalType) {
|
||||
if (order == null || StrUtil.isBlank(order.getVbeln())) {
|
||||
throw new BadRequestException("中鼎单据下推失败:交货单号为空");
|
||||
}
|
||||
if (CollectionUtils.isEmpty(items)) {
|
||||
throw new BadRequestException("中鼎单据下推失败:单据" + order.getVbeln() + "明细为空");
|
||||
}
|
||||
String vbeln = order.getVbeln().trim();
|
||||
List<OutboundDeliveryItem> mains = new ArrayList<>();
|
||||
Map<String, List<OutboundDeliveryItem>> components = new LinkedHashMap<>();
|
||||
for (OutboundDeliveryItem item : items) {
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
if (item.getRspos() == null || item.getRspos() == 0) {
|
||||
mains.add(item);
|
||||
} else {
|
||||
components.computeIfAbsent(StrUtil.blankToDefault(item.getPosnr(), ""), key -> new ArrayList<>()).add(item);
|
||||
}
|
||||
}
|
||||
if (mains.isEmpty()) {
|
||||
throw new BadRequestException("中鼎单据下推失败:单据" + vbeln + "明细为空");
|
||||
}
|
||||
JSONObject body = new JSONObject(true);
|
||||
body.put("externalId", vbeln);
|
||||
body.put("externalNo", vbeln);
|
||||
body.put("billType", resolveBillType(externalType));
|
||||
body.put("externalType", externalType);
|
||||
body.put("creator", "wms");
|
||||
String createTime = formatCreateTime(
|
||||
order.getBldat() == null ? null : order.getBldat().toString(),
|
||||
order.getWadat() == null ? null : order.getWadat().toString());
|
||||
if (StrUtil.isNotBlank(createTime)) {
|
||||
body.put("createTime", createTime);
|
||||
}
|
||||
body.put("status", 0);
|
||||
JSONArray itemList = new JSONArray();
|
||||
boolean appendComponent = "SUBCONTRACT_OUT".equals(externalType);
|
||||
for (OutboundDeliveryItem item : mains) {
|
||||
String posnr = StrUtil.trim(item.getPosnr());
|
||||
if (StrUtil.isBlank(posnr)) {
|
||||
throw new BadRequestException("中鼎单据下推失败:单据" + vbeln + "行号为空");
|
||||
}
|
||||
itemList.add(deliveryItem(vbeln, posnr, posnr, item.getLgort(), item.getMaterial(),
|
||||
item.getMatl_desc(), item.getDeliv_qty(), item.getUnit(), true));
|
||||
if (!appendComponent) {
|
||||
continue;
|
||||
}
|
||||
List<OutboundDeliveryItem> comps = components.get(StrUtil.blankToDefault(item.getPosnr(), ""));
|
||||
if (CollectionUtils.isEmpty(comps)) {
|
||||
continue;
|
||||
}
|
||||
for (OutboundDeliveryItem comp : comps) {
|
||||
String itemNo = posnr + "-" + comp.getRspos();
|
||||
itemList.add(deliveryItem(vbeln, itemNo, itemNo,
|
||||
StrUtil.blankToDefault(comp.getLgort(), item.getLgort()),
|
||||
comp.getComponent_material(), "",
|
||||
comp.getComponent_qty(),
|
||||
StrUtil.blankToDefault(comp.getUnit(), item.getUnit()),
|
||||
false));
|
||||
}
|
||||
}
|
||||
body.put("itemList", itemList);
|
||||
return body;
|
||||
}
|
||||
|
||||
private JSONObject deliveryItem(String billNo, String itemId, String itemNo, String houseCode, String skuCode,
|
||||
String skuName, BigDecimal qty, String unit, boolean requireSkuName) {
|
||||
if (StrUtil.isBlank(houseCode)) {
|
||||
throw new BadRequestException("中鼎单据下推失败:单据" + billNo + "行" + itemNo + "库存地点为空");
|
||||
}
|
||||
if (StrUtil.isBlank(skuCode)) {
|
||||
throw new BadRequestException("中鼎单据下推失败:单据" + billNo + "行" + itemNo + "物料编号为空");
|
||||
}
|
||||
if (requireSkuName && StrUtil.isBlank(skuName)) {
|
||||
throw new BadRequestException("中鼎单据下推失败:单据" + billNo + "行" + itemNo + "物料描述为空");
|
||||
}
|
||||
if (qty == null) {
|
||||
throw new BadRequestException("中鼎单据下推失败:单据" + billNo + "行" + itemNo + "数量为空");
|
||||
}
|
||||
if (StrUtil.isBlank(unit)) {
|
||||
throw new BadRequestException("中鼎单据下推失败:单据" + billNo + "行" + itemNo + "单位为空");
|
||||
}
|
||||
JSONObject row = new JSONObject(true);
|
||||
row.put("externalItemId", billNo + "/" + itemId);
|
||||
row.put("externalItemNo", itemNo);
|
||||
row.put("houseCode", houseCode.trim());
|
||||
row.put("skuCode", skuCode.trim());
|
||||
row.put("skuName", StrUtil.blankToDefault(StrUtil.trim(skuName), ""));
|
||||
row.put("skuSpec", "");
|
||||
row.put("batchNo", "");
|
||||
row.put("qty", qty);
|
||||
row.put("unit", unit.trim());
|
||||
row.put("itemStatus", 0);
|
||||
row.put("trackNo", "");
|
||||
return row;
|
||||
}
|
||||
|
||||
/**
|
||||
* budat 优先,没有则用 bldat,补成 yyyy-MM-dd HH:mm:ss。
|
||||
*/
|
||||
private String formatCreateTime(String budat, String bldat) {
|
||||
String raw = StrUtil.blankToDefault(StrUtil.trim(budat), StrUtil.trim(bldat));
|
||||
if (StrUtil.isBlank(raw)) {
|
||||
return null;
|
||||
}
|
||||
raw = raw.trim();
|
||||
if (raw.length() >= 19 && raw.charAt(10) == ' ') {
|
||||
return raw.substring(0, 19);
|
||||
}
|
||||
if (raw.length() == 8 && raw.chars().allMatch(Character::isDigit)) {
|
||||
return raw.substring(0, 4) + "-" + raw.substring(4, 6) + "-" + raw.substring(6, 8) + " 00:00:00";
|
||||
}
|
||||
if (raw.length() >= 10 && raw.charAt(4) == '-' && raw.charAt(7) == '-') {
|
||||
return raw.substring(0, 10) + " 00:00:00";
|
||||
}
|
||||
return raw;
|
||||
}
|
||||
|
||||
private void assertSuccess(JSONObject result) {
|
||||
Integer respCode = result.getInteger("respCode");
|
||||
if (respCode == null || respCode != 0) {
|
||||
String msg = StrUtil.blankToDefault(result.getString("respMsg"), result.getString("message"));
|
||||
throw new BadRequestException("中鼎单据下推失败:" + StrUtil.blankToDefault(msg, "中鼎返回失败"));
|
||||
}
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
Integer dataCode = data.getInteger("respCode");
|
||||
if (dataCode != null && dataCode != 0) {
|
||||
throw new BadRequestException("中鼎单据下推失败:" + StrUtil.blankToDefault(data.getString("respMsg"), "中鼎返回失败"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.protocol.RequestDate;
|
||||
import org.nl.common.base.ResponseData;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.wms.ext_manage.api.MesApi;
|
||||
import org.nl.wms.ext_manage.purchase.service.InboundZDwmsService;
|
||||
@@ -32,6 +34,10 @@ public class ZDwmsCallbackController {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("ResultCode", 0);
|
||||
result.put("Message", "回调处理成功");
|
||||
return ResponseEntity.ok(result);
|
||||
return ResponseData.build();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.base.ResponseData;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.wms.ext_manage.sap.dto.SapBillFeedbackRequest;
|
||||
import org.nl.wms.pm_manage.sap.materialDocument.service.MaterialDocumentService;
|
||||
import org.nl.wms.pm_manage.sap.materialDocument.service.dto.MaterialDocumentDTO;
|
||||
import org.nl.wms.pm_manage.sap.outBoundDelivery.service.OutboundDeliveryService;
|
||||
@@ -20,6 +21,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/wms/sap_services/maintain")
|
||||
@@ -59,4 +62,24 @@ public class SapSyncController {
|
||||
JSONObject result = salesReturnOutService.insertSapMm021(dto);
|
||||
return ResponseData.build(result, HttpStatus.OK);
|
||||
}
|
||||
@PostMapping("/sapBillFeedback")
|
||||
@Log("反馈SAP单据完成")
|
||||
public ResponseEntity<Object> sapBillFeedback(@RequestBody SapBillFeedbackRequest requests) {
|
||||
//这些业务类型的单子,只要把MaterialDocumentIo原单据关闭就可以
|
||||
// TRANSFER_IN("TRANSFER_IN", "调拨入库", MaterialDocumentIo.IN, "调拨入库"),
|
||||
// TRANSFER_OUT("TRANSFER_OUT", "调拨出库", MaterialDocumentIo.OUT, "调拨出库"),
|
||||
// PURCHASE_IN("PURCHASE_IN", "采购入库", MaterialDocumentIo.IN, "采购入库"),
|
||||
// SUBCONTRACT_IN("SUBCONTRACT_IN", "委外入库-成品", MaterialDocumentIo.IN, "采购入库"),
|
||||
// SUBCONTRACT_RETURN_IN("SUBCONTRACT_RETURN_IN", "委外交货退货入库", MaterialDocumentIo.IN, "其他入库"),
|
||||
// OTHER_IN("OTHER_IN", "其他入库", MaterialDocumentIo.IN, "其他入库"),
|
||||
// SALES_OUT("SALES_OUT", "销售出库-原料", MaterialDocumentIo.OUT, "销售出库"),
|
||||
// SALES_RETURN_IN("SALES_RETURN_IN", "销售退库-原料", MaterialDocumentIo.IN, "其他入库"),
|
||||
// OTHER_OUT("OTHER_OUT", "其他出库", MaterialDocumentIo.OUT, "其他出库");
|
||||
//
|
||||
//SUBCONTRACT_OUT委外交货单调用:SapOutboundDelivery
|
||||
//SALES_OUT 原材料销售出库:SapOutboundDelivery
|
||||
//SALES_RETURN_IN 原材料销售退货 SapOutboundDelivery;
|
||||
//TRANSFER_IN 公司间调拨收货 SapOutboundDelivery;
|
||||
return ResponseData.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.nl.wms.ext_manage.sap.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* SAP单据反馈明细。只有主表时不传 externalItemNo。
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class SapBillFeedbackItem {
|
||||
|
||||
/** 明细单号 */
|
||||
private String externalItemNo;
|
||||
|
||||
/** 物料号 */
|
||||
private String skuCode;
|
||||
|
||||
/** 计划执行数量 */
|
||||
private Integer planQty;
|
||||
|
||||
/** 实际执行数量 */
|
||||
private Integer actualQty;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.nl.wms.ext_manage.sap.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* SAP单据反馈请求。请求体为数组。
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class SapBillFeedbackRequest {
|
||||
|
||||
/** 单据类型,与同步接口 externalType 一致 */
|
||||
private String externalType;
|
||||
|
||||
/** 单据编码,对应同步报文 externalNo */
|
||||
private String externalNo;
|
||||
|
||||
/** 单据明细 */
|
||||
private List<SapBillFeedbackItem> item;
|
||||
}
|
||||
@@ -28,6 +28,7 @@ public interface WmsToZDWmdService {
|
||||
"E504", "6.007",
|
||||
"E505", "6.007",
|
||||
"E506", "6.007",
|
||||
"MiniLoad", "7.017",
|
||||
"E507", "6.007");
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,7 +42,7 @@ public class WmsToZDWmdServiceImpl implements WmsToZDWmdService {
|
||||
map.put("Creator", demand.getCreator());
|
||||
map.put("CreateTime", demand.getCreateTime());
|
||||
map.put("Priority", demand.getPriority());
|
||||
map.put("Status", 0);
|
||||
map.put("Status", 2);//2追加
|
||||
map.put("WorkOrder", demand.getWorkOrder());
|
||||
map.put("SkuCode", demand.getSkuCode());
|
||||
map.put("SkuName", demand.getSkuName());
|
||||
|
||||
@@ -360,25 +360,25 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
.collect(Collectors.toList()))
|
||||
.ne(PmDemand::getStatus, DemandStatus.FINISH.getValue())
|
||||
.ne(PmDemand::getIs_deleted, 1));
|
||||
if (pmDemandDtos.size() < allWorkDemand.size()) {
|
||||
// 统计 allWorkDemand 中每个工单的数量
|
||||
Map<String, Long> sourceCountMap = allWorkDemand.stream()
|
||||
.collect(Collectors.groupingBy(PmDemand::getWork_order, Collectors.counting()));
|
||||
|
||||
// 统计 pmDemandDtos 中每个工单的数量
|
||||
Map<String, Long> targetCountMap = pmDemandDtos.stream()
|
||||
.collect(Collectors.groupingBy(PmDemandDto::getWorkOrder, Collectors.counting()));
|
||||
|
||||
// 找出数量不一致的工单
|
||||
String collect = sourceCountMap.entrySet().stream()
|
||||
.filter(entry -> {
|
||||
Long targetCount = targetCountMap.getOrDefault(entry.getKey(), 0L);
|
||||
return !entry.getValue().equals(targetCount);
|
||||
})
|
||||
.map(Map.Entry::getKey)
|
||||
.collect(Collectors.joining(","));
|
||||
throw new BadRequestException("存在未勾选完全的工单" + collect);
|
||||
}
|
||||
// if (pmDemandDtos.size() < allWorkDemand.size()) {
|
||||
// // 统计 allWorkDemand 中每个工单的数量
|
||||
// Map<String, Long> sourceCountMap = allWorkDemand.stream()
|
||||
// .collect(Collectors.groupingBy(PmDemand::getWork_order, Collectors.counting()));
|
||||
//
|
||||
// // 统计 pmDemandDtos 中每个工单的数量
|
||||
// Map<String, Long> targetCountMap = pmDemandDtos.stream()
|
||||
// .collect(Collectors.groupingBy(PmDemandDto::getWorkOrder, Collectors.counting()));
|
||||
//
|
||||
// // 找出数量不一致的工单
|
||||
// String collect = sourceCountMap.entrySet().stream()
|
||||
// .filter(entry -> {
|
||||
// Long targetCount = targetCountMap.getOrDefault(entry.getKey(), 0L);
|
||||
// return !entry.getValue().equals(targetCount);
|
||||
// })
|
||||
// .map(Map.Entry::getKey)
|
||||
// .collect(Collectors.joining(","));
|
||||
// throw new BadRequestException("存在未勾选完全的工单" + collect);
|
||||
// }
|
||||
// 一次性分成两组
|
||||
Param zdStorParam = iSysParamService.findByCode(EXTConstant.ZD_STOR_SET);
|
||||
List ZD_STOR_SET;
|
||||
@@ -415,45 +415,14 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
|
||||
final long orderCount = orderDemands.stream()
|
||||
.filter(d -> ZD_STOR_SET.contains(resolveInventoryWarehouse(d.getInventory_dis())))
|
||||
.count();
|
||||
if (orderCount > demandDtos.size()){
|
||||
throw new BadRequestException("工单"+workOrder+"下推中鼎失败,存在未勾选的单子");
|
||||
}
|
||||
// if (orderCount > demandDtos.size()){
|
||||
// throw new BadRequestException("工单"+workOrder+"下推中鼎失败,存在未勾选的单子");
|
||||
// }
|
||||
List<PmDemandDto> zd = new ArrayList<>();
|
||||
List<AddInvParam> addInvParams = new ArrayList<>();
|
||||
List<InFinishParam> inFinishParams = new ArrayList<>();
|
||||
for (PmDemandDto zdDemand : demandDtos) {
|
||||
Structattr structattr = iStructattrService.getOne(new LambdaQueryWrapper<Structattr>()
|
||||
.eq(Structattr::getSect_code, zdDemand.getTargetHouseCode())
|
||||
.isNotNull(Structattr::getStoragevehicle_code)
|
||||
.last("limit 1"));
|
||||
AddInvParam addInvParam = new AddInvParam();
|
||||
addInvParam.setMaterialCode(zdDemand.getSkuCode());
|
||||
addInvParam.setUnitId("1");
|
||||
addInvParam.setUnitName(zdDemand.getUnit());
|
||||
addInvParam.setPcsn("1");
|
||||
addInvParam.setStoragevehicleCode(structattr.getStoragevehicle_code());
|
||||
addInvParam.setQty(zdDemand.getQty());
|
||||
addInvParam.setStorCode(structattr.getStor_code());
|
||||
addInvParam.setSectCode(structattr.getSect_code());
|
||||
addInvParam.setStructCode(structattr.getStruct_code());
|
||||
addInvParam.setRemark("中鼎需求单变动");
|
||||
addInvParams.add(addInvParam);
|
||||
InFinishParam inFinishParam = new InFinishParam();
|
||||
BeanUtils.copyProperties(addInvParam,inFinishParam);
|
||||
inFinishParams.add(inFinishParam);
|
||||
zd.add(zdDemand);
|
||||
}
|
||||
wmsToZDWmdService.syncDemandOrder(zd);
|
||||
try {
|
||||
iStInventoryService.changeInventory(InventoryChangeType.ADD_INV, addInvParams);
|
||||
iStInventoryService.changeInventory(InventoryChangeType.IN_FINISH, inFinishParams);
|
||||
this.update(new LambdaUpdateWrapper<PmDemand>()
|
||||
.set(PmDemand::getStatus,DemandStatus.FINISH.getValue())
|
||||
.in(PmDemand::getId,demandDtos.stream()
|
||||
.map(PmDemandDto::getId).collect(Collectors.toList())));
|
||||
}catch (Exception ex){
|
||||
log.error("回传中鼎成功,WMS库存变动失败"+ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -77,4 +78,11 @@ public class MaterialDocumentManageController {
|
||||
materialDocumentService.pushOut(billType, dto);
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@PostMapping("/{billType}/pushZd")
|
||||
@Log("下推SAP物料凭证至中鼎WMS")
|
||||
public ResponseEntity<Object> pushZd(@PathVariable String billType, @RequestBody List<Long> ids) {
|
||||
materialDocumentService.pushZd(billType, ids);
|
||||
return ResponseData.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,4 +28,6 @@ public interface MaterialDocumentService {
|
||||
void print(List<Long> ids);
|
||||
|
||||
void pushOut(String billType, MaterialDocumentFormDto dto);
|
||||
|
||||
void pushZd(String billType, List<Long> ids);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.common.utils.ZplUtil;
|
||||
import org.nl.wms.basedata_manage.service.IMdMeMaterialbaseService;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
|
||||
import org.nl.wms.ext_manage.api.ZDWmsApi;
|
||||
import org.nl.wms.pm_manage.sap.materialDocument.enums.MaterialDocumentBillType;
|
||||
import org.nl.wms.pm_manage.sap.materialDocument.enums.MaterialDocumentIo;
|
||||
import org.nl.wms.pm_manage.sap.materialDocument.enums.MaterialDocumentStatus;
|
||||
@@ -40,6 +41,7 @@ import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -60,6 +62,7 @@ public class MaterialDocumentServiceImpl implements MaterialDocumentService {
|
||||
private final MaterialDocumentItemMapper itemMapper;
|
||||
private final IOutBillService outBillService;
|
||||
private final IMdMeMaterialbaseService materialbaseService;
|
||||
private final ZDWmsApi zdWmsApi;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -343,6 +346,51 @@ public class MaterialDocumentServiceImpl implements MaterialDocumentService {
|
||||
documentMapper.updateById(document);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushZd(String billType, List<Long> ids) {
|
||||
MaterialDocumentBillType type = requireBillType(billType);
|
||||
Integer zdBillType = zdBillType(type);
|
||||
if (zdBillType == null) {
|
||||
throw new BadRequestException("下推失败:" + type.getName() + "不支持下推中鼎WMS");
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
throw new BadRequestException("下推失败:未选择单据");
|
||||
}
|
||||
String operator = currentOperator();
|
||||
for (Long id : ids) {
|
||||
MaterialDocument document = getEditableDocument(id, false);
|
||||
if (!StrUtil.equals(document.getBilltype(), type.getCode())) {
|
||||
throw new BadRequestException("下推失败:单据" + document.getMblnr() + "类型不匹配");
|
||||
}
|
||||
if (!MaterialDocumentStatus.CREATED.getCode().equals(document.getStatus())) {
|
||||
throw new BadRequestException("下推失败:单据" + document.getMblnr() + "不是已创建状态");
|
||||
}
|
||||
List<MaterialDocumentItem> items = listItems(document.getId());
|
||||
if (CollectionUtils.isEmpty(items)) {
|
||||
throw new BadRequestException("下推失败:单据" + document.getMblnr() + "明细不存在");
|
||||
}
|
||||
MaterialDocumentFormDto dto = BeanUtil.copyProperties(document, MaterialDocumentFormDto.class);
|
||||
dto.setItems(items);
|
||||
zdWmsApi.insertSapWlpz(Collections.singletonList(dto), zdBillType, type.getCode());
|
||||
document.setStatus(MaterialDocumentStatus.POSTED.getCode());
|
||||
document.setUpdated_by(operator);
|
||||
documentMapper.updateById(document);
|
||||
}
|
||||
}
|
||||
|
||||
private Integer zdBillType(MaterialDocumentBillType type) {
|
||||
if (type == MaterialDocumentBillType.PURCHASE_IN) {
|
||||
return 1;
|
||||
}
|
||||
if (type == MaterialDocumentBillType.TRANSFER_OUT) {
|
||||
return 106;
|
||||
}
|
||||
if (type == MaterialDocumentBillType.SUBCONTRACT_RETURN_IN) {
|
||||
return 109;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private JSONObject convertToOutBill(MaterialDocument document, MaterialDocumentBillType type,
|
||||
String houseCode, List<MaterialDocumentItem> items) {
|
||||
List<String> materialCodes = items.stream()
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 按 billtype 分类的委外交货单管理(前端 SAP 入/出库管理子页面)
|
||||
@@ -83,6 +84,14 @@ public class OutboundDeliveryBillController {
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@PostMapping("/{billType}/pushZd")
|
||||
@Log("下推SAP交货单至中鼎WMS")
|
||||
public ResponseEntity<Object> pushZd(@PathVariable String billType, @RequestBody List<Long> ids) {
|
||||
validateBillType(billType);
|
||||
outboundDeliveryService.pushZd(billType, ids);
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@PostMapping("/{billType}/returnConfirm")
|
||||
@Log("SAP交货单退货确认")
|
||||
public ResponseEntity<Object> returnConfirm(@PathVariable String billType, @RequestBody OutboundDeliveryOrderDto dto) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@@ -77,6 +78,13 @@ public class OutboundDeliveryController {
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@PostMapping("/pushZd")
|
||||
@Log("下推SAP委外交货单至中鼎WMS")
|
||||
public ResponseEntity<Object> pushZd(@RequestBody List<Long> ids) {
|
||||
outboundDeliveryService.pushZd(null, ids);
|
||||
return ResponseData.build();
|
||||
}
|
||||
|
||||
@PostMapping("/reverse")
|
||||
@Log("SAP委外交货单倒冲")
|
||||
public ResponseEntity<Object> reverse(@RequestBody OutboundDeliveryReverseDto dto) {
|
||||
|
||||
@@ -39,6 +39,8 @@ public interface OutboundDeliveryService extends IService<OutboundDelivery> {
|
||||
|
||||
void pushOut(OutboundDeliveryOrderDto dto);
|
||||
|
||||
void pushZd(String billType, List<Long> ids);
|
||||
|
||||
void reverse(OutboundDeliveryReverseDto dto);
|
||||
|
||||
void returnConfirm(OutboundDeliveryOrderDto dto);
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.ext_manage.api.ZDWmsApi;
|
||||
import org.nl.wms.ext_manage.sap.api.SapApi;
|
||||
import org.nl.wms.ext_manage.sap.api.dto.SubcontractConfirmBody;
|
||||
import org.nl.wms.ext_manage.sap.api.dto.SubcontractConfirmHeader;
|
||||
@@ -90,6 +91,8 @@ public class OutboundDeliveryServiceImpl extends ServiceImpl<OutboundDeliveryMap
|
||||
@Autowired
|
||||
private SapApi sapApi;
|
||||
@Autowired
|
||||
private ZDWmsApi zdWmsApi;
|
||||
@Autowired
|
||||
private ISapSubcontractReverseRecordService reverseRecordService;
|
||||
|
||||
@Override
|
||||
@@ -464,6 +467,53 @@ public class OutboundDeliveryServiceImpl extends ServiceImpl<OutboundDeliveryMap
|
||||
orderMapper.updateById(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushZd(String billType, List<Long> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
throw new BadRequestException("下推失败:未选择单据");
|
||||
}
|
||||
for (Long id : ids) {
|
||||
OutboundDelivery order = orderMapper.selectById(id);
|
||||
if (order == null) {
|
||||
throw new BadRequestException("下推失败:交货单不存在");
|
||||
}
|
||||
if (StrUtil.isNotBlank(billType) && !StrUtil.equals(order.getBilltype(), billType)) {
|
||||
throw new BadRequestException("下推失败:单据" + order.getVbeln() + "类型不匹配");
|
||||
}
|
||||
Integer zdBillType = zdBillType(order.getBilltype());
|
||||
if (zdBillType == null) {
|
||||
throw new BadRequestException("下推失败:单据" + order.getVbeln() + "不支持下推中鼎WMS");
|
||||
}
|
||||
if (!OutboundDeliveryStatus.CREATED.getCode().equals(order.getStatus())) {
|
||||
throw new BadRequestException("下推失败:单据" + order.getVbeln() + "不是已创建状态");
|
||||
}
|
||||
List<OutboundDeliveryItem> items = listItems(order.getVbeln());
|
||||
if (CollectionUtils.isEmpty(items)) {
|
||||
throw new BadRequestException("下推失败:单据" + order.getVbeln() + "明细不存在");
|
||||
}
|
||||
zdWmsApi.insertSapJhd(order, items, zdBillType, order.getBilltype());
|
||||
order.setStatus(OutboundDeliveryStatus.POSTED.getCode());
|
||||
orderMapper.updateById(order);
|
||||
}
|
||||
}
|
||||
|
||||
private Integer zdBillType(String billType) {
|
||||
OutboundDeliveryBillType type = OutboundDeliveryBillType.ofCode(billType);
|
||||
if (type == OutboundDeliveryBillType.TRANSFER_IN) {
|
||||
return 107;
|
||||
}
|
||||
if (type == OutboundDeliveryBillType.SALES_RETURN_IN) {
|
||||
return 2;
|
||||
}
|
||||
if (type == OutboundDeliveryBillType.SUBCONTRACT_OUT) {
|
||||
return 108;
|
||||
}
|
||||
if (type == OutboundDeliveryBillType.SALES_OUT) {
|
||||
return 102;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void reverse(OutboundDeliveryReverseDto dto) {
|
||||
|
||||
@@ -29,6 +29,8 @@ public class SysParamConstant {
|
||||
public final static String ZD_URL_RETURN = "ZD_URL_RETURN";
|
||||
public final static String ZD_URL_LOC = "ZD_URL_LOC";
|
||||
public final static String ZD_URL_IOORDER = "ZD_URL_IOORDER";
|
||||
public final static String ZD_SAP_URL = "ZD_SAP_URL";
|
||||
public final static String ZD_MATER_SYNC = "ZD_MATER_SYNC";
|
||||
/**
|
||||
* MES URL
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user