Browse Source

退料修改

master
shenzhouyu 2 months ago
parent
commit
85338f79f0
  1. 42
      src/main/java/com/gaotao/modules/production/service/impl/ProductionReturnServiceImpl.java
  2. 5
      src/main/resources/mapper/production/ProductionReturnMapper.xml

42
src/main/java/com/gaotao/modules/production/service/impl/ProductionReturnServiceImpl.java

@ -191,6 +191,16 @@ public class ProductionReturnServiceImpl implements ProductionReturnService {
transCommonRequestDto.setSourceNo(returnDto.getWorkOrderNo()); transCommonRequestDto.setSourceNo(returnDto.getWorkOrderNo());
Double seqNo = 1.0; Double seqNo = 1.0;
List<Location> allLocation = productionReturnMapper.getAllLocation(returnDto.getSite());
Map<String, String> locationWarehouseMap = allLocation.stream()
.filter(loc -> loc != null
&& loc.getLocationId() != null
&& !loc.getLocationId().trim().isEmpty())
.collect(Collectors.toMap(
loc -> loc.getLocationId().trim(),
Location::getWarehouseId,
(oldVal, newVal) -> newVal
));
// 处理每个选择的物料 // 处理每个选择的物料
for (WorkOrderMaterialDto material : returnDto.getSelectedMaterials()) { for (WorkOrderMaterialDto material : returnDto.getSelectedMaterials()) {
// 创建出库记录详情 // 创建出库记录详情
@ -199,8 +209,11 @@ public class ProductionReturnServiceImpl implements ProductionReturnService {
subDto.setPartNo(returnDto.getComponentPartNo()); subDto.setPartNo(returnDto.getComponentPartNo());
subDto.setSubNo(material.getLabelCode()); subDto.setSubNo(material.getLabelCode());
subDto.setBatchNo(material.getBatchNo()); subDto.setBatchNo(material.getBatchNo());
subDto.setWarehouseId(material.getWarehouseId());
subDto.setLocationId(material.getLocationId()); subDto.setLocationId(material.getLocationId());
String targetWarehouseId = locationWarehouseMap.get(material.getLocationId());
if (targetWarehouseId != null) {
subDto.setWarehouseId(targetWarehouseId);
}
subDto.setTransQty(material.getIssueQty().toString()); subDto.setTransQty(material.getIssueQty().toString());
subDto.setDirection("+"); subDto.setDirection("+");
subDto.setWdrNo(material.getWdrNo()); subDto.setWdrNo(material.getWdrNo());
@ -230,7 +243,10 @@ public class ProductionReturnServiceImpl implements ProductionReturnService {
HandlingUnit hu = new HandlingUnit(); HandlingUnit hu = new HandlingUnit();
hu.setUnitId(material.getLabelCode()); hu.setUnitId(material.getLabelCode());
hu.setLocationId(material.getLocationId()); hu.setLocationId(material.getLocationId());
String targetWarehouseId = locationWarehouseMap.get(material.getLocationId());
if (targetWarehouseId != null) {
hu.setWarehouseId(targetWarehouseId);
}
String unitId = material.getLabelCode(); String unitId = material.getLabelCode();
if (unitId != null && huMap.containsKey(unitId)) { if (unitId != null && huMap.containsKey(unitId)) {
//减去要出的hu上的数量 //减去要出的hu上的数量
@ -348,6 +364,16 @@ public class ProductionReturnServiceImpl implements ProductionReturnService {
transCommonRequestDto.setSourceNo(returnDto.getNotifyNo()); transCommonRequestDto.setSourceNo(returnDto.getNotifyNo());
Double seqNo = 1.0; Double seqNo = 1.0;
List<Location> allLocation = productionReturnMapper.getAllLocation(returnDto.getSite());
Map<String, String> locationWarehouseMap = allLocation.stream()
.filter(loc -> loc != null
&& loc.getLocationId() != null
&& !loc.getLocationId().trim().isEmpty())
.collect(Collectors.toMap(
loc -> loc.getLocationId().trim(),
Location::getWarehouseId,
(oldVal, newVal) -> newVal
));
// 处理每个选择的物料 // 处理每个选择的物料
for (WorkOrderMaterialDto material : returnDto.getSelectedMaterials()) { for (WorkOrderMaterialDto material : returnDto.getSelectedMaterials()) {
// 验证物料匹配 // 验证物料匹配
@ -369,8 +395,12 @@ public class ProductionReturnServiceImpl implements ProductionReturnService {
subDto.setPartNo(returnDto.getComponentPartNo()); subDto.setPartNo(returnDto.getComponentPartNo());
subDto.setSubNo(material.getLabelCode()); subDto.setSubNo(material.getLabelCode());
subDto.setBatchNo(material.getBatchNo()); subDto.setBatchNo(material.getBatchNo());
subDto.setWarehouseId(material.getWarehouseId());
subDto.setLocationId(material.getLocationId()); subDto.setLocationId(material.getLocationId());
String targetWarehouseId = locationWarehouseMap.get(material.getLocationId());
if (targetWarehouseId != null) {
subDto.setWarehouseId(targetWarehouseId);
}
subDto.setTransQty(material.getIssueQty().toString()); subDto.setTransQty(material.getIssueQty().toString());
subDto.setDirection("+"); subDto.setDirection("+");
subDto.setWdrNo(material.getWdrNo()); subDto.setWdrNo(material.getWdrNo());
@ -401,7 +431,11 @@ public class ProductionReturnServiceImpl implements ProductionReturnService {
for (WorkOrderMaterialDto material : returnDto.getSelectedMaterials()) { for (WorkOrderMaterialDto material : returnDto.getSelectedMaterials()) {
HandlingUnit hu = new HandlingUnit(); HandlingUnit hu = new HandlingUnit();
hu.setUnitId(material.getLabelCode()); hu.setUnitId(material.getLabelCode());
hu.setLocationId(material.getLocationId());
hu.setWarehouseId(material.getWarehouseId());
String targetWarehouseId = locationWarehouseMap.get(material.getLocationId());
if (targetWarehouseId != null) {
hu.setWarehouseId(targetWarehouseId);
}
String unitId = material.getLabelCode(); String unitId = material.getLabelCode();
if (unitId != null && huMap.containsKey(unitId)) { if (unitId != null && huMap.containsKey(unitId)) {

5
src/main/resources/mapper/production/ProductionReturnMapper.xml

@ -56,6 +56,11 @@
WHEN #{hu.unitId} THEN #{hu.locationId} WHEN #{hu.unitId} THEN #{hu.locationId}
</foreach> </foreach>
END, END,
warehouse_id = CASE unit_id
<foreach collection="list" item="hu" separator="">
WHEN #{hu.unitId} THEN #{hu.warehouseId}
</foreach>
END,
qty = CASE unit_id qty = CASE unit_id
<foreach collection="list" item="hu" separator=""> <foreach collection="list" item="hu" separator="">
WHEN #{hu.unitId} THEN #{hu.qty} WHEN #{hu.unitId} THEN #{hu.qty}

Loading…
Cancel
Save