Merge remote-tracking branch 'origin/feature/sap-interface-0804' into feature/sap-interface-0804

This commit is contained in:
2026-10-09 16:41:02 +08:00
9 changed files with 114 additions and 76 deletions

View File

@@ -1,6 +1,7 @@
package org.nl.wms.basedata_manage.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -9,6 +10,7 @@ import org.nl.common.domain.query.PageQuery;
import org.nl.common.logging.annotation.Log;
import org.nl.wms.basedata_manage.service.IMdMeMaterialbaseService;
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;
@@ -69,5 +71,12 @@ public class MaterialbaseController {
return ResponseData.build();
}
@PostMapping("/materialInfoSync")
@Log("物料信息同步")
@SaIgnore
public ResponseEntity<Object> materialInfoSync(@RequestBody MaterialInfoSyncQuery query) {
return ResponseData.build(iMdMeMaterialbaseService.syncMaterialInfo(query), HttpStatus.OK);
}
}

View File

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
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.Map;
import java.util.Set;
@@ -58,4 +59,9 @@ public interface IMdMeMaterialbaseService extends IService<MdMeMaterialbase> {
* @return 返回结果
*/
MdMeMaterialbase getByCode(String material_code);
/**
* 外部系统分页拉取物料。传 materialCode 查指定物料;传 lastMaterialId 查该标识之后的数据;两者都为空则全表分页。
*/
IPage<MdMeMaterialbase> syncMaterialInfo(MaterialInfoSyncQuery query);
}

View File

@@ -178,7 +178,7 @@ public class MdMeMaterialbase implements Serializable {
private String is_delete;
/**
* 外部标识
* SAP外部标识
*/
private String ext_id;

View File

@@ -19,6 +19,7 @@ import org.nl.wms.basedata_manage.service.IMdMeMaterialbaseService;
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.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.service.WmsToErpService;
import org.nl.wms.ext_manage.service.dto.ErpMaterial;
@@ -170,6 +171,28 @@ public class MdMeMaterialbaseServiceImpl extends ServiceImpl<MdMeMaterialbaseMap
// this.saveBatch(materDaoList);
}
@Override
public IPage<MdMeMaterialbase> syncMaterialInfo(MaterialInfoSyncQuery query) {
int pageNum = 0;
int pageSize = 100;
if (query != null) {
if (query.getPage() != null && query.getPage() > 0) {
pageNum = query.getPage();
}
if (query.getSize() != null && query.getSize() > 0) {
pageSize = query.getSize();
}
}
LambdaQueryWrapper<MdMeMaterialbase> wrapper = new LambdaQueryWrapper<>();
if (query != null && StrUtil.isNotBlank(query.getMaterialCode())) {
wrapper.eq(MdMeMaterialbase::getMaterial_code, query.getMaterialCode().trim());
} else if (query != null && StrUtil.isNotBlank(query.getLastMaterialId())) {
wrapper.gt(MdMeMaterialbase::getMaterial_id, query.getLastMaterialId().trim());
}
wrapper.orderByAsc(MdMeMaterialbase::getMaterial_id);
return this.page(new Page<>(pageNum + 1, pageSize), wrapper);
}
@Override
public MdMeMaterialbase getByCode(String materialCode) {
MdMeMaterialbase one = this.getOne(

View File

@@ -40,7 +40,7 @@ public class SapSyncController {
}
@PostMapping("/insertSapWwJhd")
@Log("SAP委外交货单同步(MM062)")
@Log("SAP委外交货出库单同步(MM062)")
public ResponseEntity<Object> insertSapWwjhd(@RequestBody DeliveryOrderDTO deliveryOrderDTO) {
JSONObject result = outboundDeliveryService.insertSapWwjhd(deliveryOrderDTO);
return ResponseData.build(result, HttpStatus.OK);

View File

@@ -940,11 +940,11 @@ public class MesToWmsServiceImpl implements MesToWmsService {
List<Structattr> structattrs = iStructattrService.inBoundSectDiv(
StrategyStructParam.builder()
.ioType(StatusEnum.STRATEGY_TYPE.code("入库"))
.sect_code(region.getPoint_type_explain())
.sect_code("H003")//喷涂库region.getPoint_type_explain()
.strategyMaters(new ArrayList<>())
.build());
if (CollectionUtils.isEmpty(structattrs)) {
throw new BadRequestException("喷涂入库失败,库区" + region.getPoint_type_explain() + "没有可用仓位");
throw new BadRequestException("喷涂入库失败,库区H003没有可用仓位");
}
Structattr struct = structattrs.get(0);

View File

@@ -98,13 +98,13 @@ public class InboundPdaController {
return ResponseData.build();
}
@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;
// }
/**
* 批量前的单据校验:只处理「采购入库 + 已创建 + 入库方向」的单据,防止重复入库或入错方向。