opt:修改单位取值为物料凭证单位、非分配单单位

This commit is contained in:
2026-10-21 17:14:52 +08:00
parent 1a49bcc5b1
commit f4b75aee65
10 changed files with 109 additions and 99 deletions

View File

@@ -13,7 +13,7 @@ import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
import org.nl.wms.basedata_manage.service.dto.MaterialInfoSyncQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;import org.nl.common.base.ResponseData;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

View File

@@ -37,6 +37,12 @@ public class MdMeMaterialbase implements Serializable {
*/
private String material_code;
/**
* 物料编码
*/
private String lastMaterialId;
/**
* 物料名称
*/

View File

@@ -75,7 +75,6 @@ public class SectattrServiceImpl extends ServiceImpl<SectattrMapper, Sectattr> i
@Override
public Sectattr findByCode(String code) {
LambdaQueryWrapper<Sectattr> queryWrapper = new LambdaQueryWrapper<>(Sectattr.class)
.eq(Sectattr::getSect_code, code)
.eq(Sectattr::getIs_delete, BaseDataEnum.IS_YES_NOT.code("否"));

View File

@@ -21,8 +21,8 @@ import org.springframework.util.StringUtils;
@Slf4j
public class SapApi {
private static final String BASIC_AUTH_USER = "sb-164b126d-0398-4635-9d0d-8be99d6e3fdd!b6436|it-rt-dev-12nylocm!b39";
private static final String BASIC_AUTH_PASSWORD = "e3530ba3-2243-4c09-9320-db961c08d04c$aVQJe8yGKZmbkvqE9a1opQU0P2uwRLkGMqHJvrrvmH8=";
private static final String BASIC_AUTH_USER = "sb-44f42158-6589-470d-94e2-cb4ff68ff64e!b6440|it-rt-prd-mc97okah!b39";
private static final String BASIC_AUTH_PASSWORD = "07c6eebc-1ff3-4f73-a4d8-870757951649$WTL_Vf-jxg8aWRlTvxP8BC8oloOYosae2JzQykImlpg=";
/**
* MM054 交货单收货确认

View File

@@ -4,7 +4,7 @@ public class SapConstant {
/** SAP CPI Inbound 统一接口地址(各业务接口共用,通过 header.intf_id 区分) */
public static final String SAP_INBOUND_URL2 = "https://dev-12nylocm.it-cpi010-rt.cpi.cn40.apps.platform.sapcloud.cn/http/ERP/Inbound";
public static final String SAP_INBOUND_URL = "https://dev-12nylocm.it-cpi010-rt.cpi.cn40.apps.platform.sapcloud.cn/http/QAS/Inbound";
public static final String SAP_INBOUND_URL = "https://prd-mc97okah.it-cpi010-rt.cpi.cn40.apps.platform.sapcloud.cn/http/PRD900/Inbound";
/** 接口编号:交货单确认 */
public static final String INTF_MM054 = "MM054";

View File

@@ -94,17 +94,18 @@ public class InboundPdaController {
@Log("平库入库")
@SaIgnore
public ResponseEntity usualInbound(@RequestBody UsualInboundDto usualInboundDto) {
inboundPdaService.usualInbound(usualInboundDto);
return ResponseData.build();
// inboundPdaService.usualInbound(usualInboundDto);
// return ResponseData.build();
return null;
}
// @PostMapping("/usualInboundList")
// @Log("批量入平库")
// @SaIgnore
// public ResponseEntity usualInboundList(@RequestBody UsualInboundBatchDto batchDto) {
// JSONObject result = inboundPdaService.usualInboundList(batchDto);
// return ResponseData.build(result);
// }
@PostMapping("/usualInboundList")
@Log("批量入平库")
@SaIgnore
public ResponseEntity usualInboundList(@RequestBody UsualInboundBatchDto batchDto) {
JSONObject result = inboundPdaService.usualInboundList(batchDto);
return ResponseData.build(result);
}
@PostMapping("/returnInbound")
@Log("退料入库")
@SaIgnore

View File

@@ -17,13 +17,13 @@ public interface InboundPdaService {
void usualInbound(UsualInboundDto usualInboundDto);
// /**
// * 批量入平库:对勾选的多张 SAP 物料凭证逐单执行平库入库。
// *
// * @param batchDto 勾选行列表 + 可选库区
// * @return 执行结果汇总 {total, successCount, failCount, failList[]}
// */
// JSONObject usualInboundList(UsualInboundBatchDto batchDto);
/**
* 批量入平库:对勾选的多张 SAP 物料凭证逐单执行平库入库。
*
* @param batchDto 勾选行列表 + 可选库区
* @return 执行结果汇总 {total, successCount, failCount, failList[]}
*/
JSONObject usualInboundList(UsualInboundBatchDto batchDto);
void submitGroupPlateInbound(GroupPlateInboundDto dto, Boolean subTask);

View File

@@ -528,64 +528,64 @@ public class InboundPdaServiceImpl implements InboundPdaService {
.apply("UPPER(unit_name) = {0}", val.toUpperCase()).last("limit 1"));
}
// @Override
// public JSONObject usualInboundList(UsualInboundBatchDto batchDto) {
// if (batchDto == null || batchDto.getList() == null || batchDto.getList().isEmpty()) {
// throw new BadRequestException("批量入平库失败:未选择任何单据");
// }
// String sectCode = StrUtil.isNotBlank(batchDto.getSect_code())
// ? batchDto.getSect_code().trim() :"R001";
// InboundPdaService self = SpringContextHolder.getBean(InboundPdaService.class);
// List<JSONObject> failList = new ArrayList<>();
// int successCount = 0;
// int total = batchDto.getList().size();
// for (UsualInboundBatchDto.Item row : batchDto.getList()) {
// if (row == null) {
// total--;
// continue;
// }
// String billNo = StrUtil.blankToDefault(row.getMblnr(), String.valueOf(row.getId()));
// MaterialDocument document = resolveBatchDocument(row);
// String skipReason = checkBatchRow(document);
// if (skipReason != null) {
// failList.add(buildBatchResult(billNo, skipReason));
// continue;
// }
// try {
// self.usualInbound(buildUsualInboundDto(document, sectCode));
// successCount++;
// } catch (Exception e) {
// failList.add(buildBatchResult(billNo, e.getMessage()));
// }
// }
// JSONObject result = new JSONObject();
// result.put("total", total);
// result.put("successCount", successCount);
// result.put("failCount", failList.size());
// result.put("failList", failList);
// result.put("sect_code", sectCode);
// return result;
// }
//
// /**
// * 按 id 优先、mblnr 兜底定位物料凭证主单,供校验与明细反查共用。
// */
// private MaterialDocument resolveBatchDocument(UsualInboundBatchDto.Item row) {
// if (row.getId() != null) {
// MaterialDocument document = documentMapper.selectById(row.getId());
// if (document != null) {
// return document;
// }
// }
// if (StrUtil.isNotBlank(row.getMblnr())) {
// return documentMapper.selectOne(new LambdaQueryWrapper<MaterialDocument>()
// .eq(MaterialDocument::getMblnr, row.getMblnr())
// .eq(MaterialDocument::getBilltype, MaterialDocumentBillType.PURCHASE_IN.getCode())
// .eq(MaterialDocument::getDeleted, 0)
// .last("LIMIT 1"));
// }
// return null;
// }
@Override
public JSONObject usualInboundList(UsualInboundBatchDto batchDto) {
if (batchDto == null || batchDto.getList() == null || batchDto.getList().isEmpty()) {
throw new BadRequestException("批量入平库失败:未选择任何单据");
}
String sectCode = StrUtil.isNotBlank(batchDto.getSect_code())
? batchDto.getSect_code().trim() :"R001";
InboundPdaService self = SpringContextHolder.getBean(InboundPdaService.class);
List<JSONObject> failList = new ArrayList<>();
int successCount = 0;
int total = batchDto.getList().size();
for (UsualInboundBatchDto.Item row : batchDto.getList()) {
if (row == null) {
total--;
continue;
}
String billNo = StrUtil.blankToDefault(row.getMblnr(), String.valueOf(row.getId()));
MaterialDocument document = resolveBatchDocument(row);
String skipReason = checkBatchRow(document);
if (skipReason != null) {
failList.add(buildBatchResult(billNo, skipReason));
continue;
}
try {
self.usualInbound(buildUsualInboundDto(document, sectCode));
successCount++;
} catch (Exception e) {
failList.add(buildBatchResult(billNo, e.getMessage()));
}
}
JSONObject result = new JSONObject();
result.put("total", total);
result.put("successCount", successCount);
result.put("failCount", failList.size());
result.put("failList", failList);
result.put("sect_code", sectCode);
return result;
}
/**
* 按 id 优先、mblnr 兜底定位物料凭证主单,供校验与明细反查共用。
*/
private MaterialDocument resolveBatchDocument(UsualInboundBatchDto.Item row) {
if (row.getId() != null) {
MaterialDocument document = documentMapper.selectById(row.getId());
if (document != null) {
return document;
}
}
if (StrUtil.isNotBlank(row.getMblnr())) {
return documentMapper.selectOne(new LambdaQueryWrapper<MaterialDocument>()
.eq(MaterialDocument::getMblnr, row.getMblnr())
.eq(MaterialDocument::getBilltype, MaterialDocumentBillType.PURCHASE_IN.getCode())
.eq(MaterialDocument::getDeleted, 0)
.last("LIMIT 1"));
}
return null;
}
/**
* 批量前的单据校验:只处理「采购入库 + 已创建 + 入库方向」的单据,防止重复入库或入错方向。

View File

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.IdUtil;
@@ -243,23 +244,25 @@ public class StInventoryServiceImpl implements IStInventoryService {
.eq(GroupPlate::getMaterial_code, invParam.getMaterialCode())
.eq(GroupPlate::getStatus, GROUP_PLATE_STATUS.code("入库"));
GroupPlate groupPlate = iMdPbGroupplateService.getOne(query);
//添加库存变动记录
StIvtStructivtflow record = new StIvtStructivtflow();
record.setId(IdUtil.getStringId());
record.setUpdate_time(DateUtil.now());
record.setVehicle_code(invParam.getStoragevehicleCode());
record.setMaterial_id(invParam.getMaterialCode());
record.setPcsn(invParam.getPcsn());
record.setQty(groupPlate.getQty());
record.setChange_qty(invParam.getQty());
record.setSource_form_id(invParam.getExtCode());
record.setUnit_id(invParam.getUnitId());
record.setStruct_code(invParam.getStructCode());
record.setStor_code(invParam.getStorCode());
record.setSect_code(invParam.getSectCode());
record.setGrowth(true);
record.setTask_type(invParam.getRemark());
recordsInFinish.add(record);
if (ObjectUtils.isNotEmpty(groupPlate)) {
//添加库存变动记录
StIvtStructivtflow record = new StIvtStructivtflow();
record.setId(IdUtil.getStringId());
record.setUpdate_time(DateUtil.now());
record.setVehicle_code(invParam.getStoragevehicleCode());
record.setMaterial_id(invParam.getMaterialCode());
record.setPcsn(invParam.getPcsn());
record.setQty(groupPlate.getQty());
record.setChange_qty(invParam.getQty());
record.setSource_form_id(invParam.getExtCode());
record.setUnit_id(invParam.getUnitId());
record.setStruct_code(invParam.getStructCode());
record.setStor_code(invParam.getStorCode());
record.setSect_code(invParam.getSectCode());
record.setGrowth(true);
record.setTask_type(invParam.getRemark());
recordsInFinish.add(record);
}
}
stIvtStructivtflowService.saveBatch(recordsInFinish);
break;

View File

@@ -48,6 +48,8 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* 需求单库存调拨完成回传 SAP MM057 物料转储
*/
@@ -56,6 +58,7 @@ import java.util.List;
public class SapDealLLDBBillPmDeamndCallBack implements CallbackStrategy {
private static final DateTimeFormatter DATE_BASIC = DateTimeFormatter.BASIC_ISO_DATE;
private static final String DEFAULT_UNIT_NAME = "PCS";
@Autowired
private IPmDemandService iPmDemandService;
@@ -243,9 +246,7 @@ public class SapDealLLDBBillPmDeamndCallBack implements CallbackStrategy {
item.setLgort(StrUtil.blankToDefault(
resolveInventoryLgort(demand.getInventory_dis()),
dis != null ? dis.getSect_code() : ""));
item.setMeins(StrUtil.blankToDefault(
dis != null ? dis.getQty_unit_name() : null,
StrUtil.blankToDefault(param.getQty_unit_name(), demand.getUnit())));
item.setMeins(StringUtils.isNotBlank(demand.getUnit())?demand.getUnit():DEFAULT_UNIT_NAME);
item.setMenge(resolveQty(param, dis).doubleValue());
item.setUmwrk(SapConstant.WERKS);
item.setSobkz("");