Browse Source

生产订单领料海安工厂

dev
shenzhouyu 2 weeks ago
parent
commit
1615f82281
  1. 74
      src/main/java/com/gaotao/modules/autoWareHourceHaian/service/impl/HaiAnIssureNotifyServiceImpl.java
  2. 17
      src/main/java/com/gaotao/modules/trans/service/impl/TransHeaderServiceImpl.java

74
src/main/java/com/gaotao/modules/autoWareHourceHaian/service/impl/HaiAnIssureNotifyServiceImpl.java

@ -33,10 +33,12 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -212,7 +214,7 @@ public class HaiAnIssureNotifyServiceImpl implements HaiAnIssureNotifyService {
/** /**
* @author rqrq * @author rqrq
* @Description 保存海安工单与物料仅申请数据删除后重建并落到haian表 - rqrq
* @Description 追加保存海安工单与物料同一领料单下允许多工单共存不清理既有父子行 - rqrq
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ -241,10 +243,6 @@ public class HaiAnIssureNotifyServiceImpl implements HaiAnIssureNotifyService {
} }
} }
// 编辑场景统一删后重存直接清理父子后按新数据重建 - rqrq
haiAnIssureNotifyMapper.haiAnDeleteMaterialRowsByNotifyNo(data.getSite(), data.getNotifyNo());
haiAnIssureNotifyMapper.haiAnDeleteOrderRowsByNotifyNo(data.getSite(), data.getNotifyNo());
// 以工单三元组+subsite聚合避免同单跨子站点明细被错误合并到同一父行 - rqrq // 以工单三元组+subsite聚合避免同单跨子站点明细被错误合并到同一父行 - rqrq
Map<HaiAnGroupKey, List<HaiAnShoporderAndMaterialDto>> groupedMap = materialRows.stream() Map<HaiAnGroupKey, List<HaiAnShoporderAndMaterialDto>> groupedMap = materialRows.stream()
.collect(Collectors.groupingBy( .collect(Collectors.groupingBy(
@ -253,11 +251,18 @@ public class HaiAnIssureNotifyServiceImpl implements HaiAnIssureNotifyService {
Collectors.toList() Collectors.toList()
)); ));
// 工单重复校验同一领料单下 orderNo+releaseNo+sequenceNo 不可重复 - rqrq
validateDuplicateShopOrders(data.getSite(), data.getNotifyNo(), groupedMap.keySet());
// 从当前最大itemNo续号追加保留领料单下已有工单数据 - rqrq
BigDecimal nextItem = haiAnIssureNotifyMapper.haiAnGetNextItemForSOIssueNotifyOrderList(buildParentSeed(data)); BigDecimal nextItem = haiAnIssureNotifyMapper.haiAnGetNextItemForSOIssueNotifyOrderList(buildParentSeed(data));
if (nextItem == null) {
if (nextItem == null || nextItem.compareTo(BigDecimal.ONE) < 0) {
nextItem = BigDecimal.ONE; nextItem = BigDecimal.ONE;
} }
List<String> newItemNos = new ArrayList<>();
List<HaiAnSOIssueNotifyOrderMaterialList> allChildren = new ArrayList<>();
for (Map.Entry<HaiAnGroupKey, List<HaiAnShoporderAndMaterialDto>> entry : groupedMap.entrySet()) { for (Map.Entry<HaiAnGroupKey, List<HaiAnShoporderAndMaterialDto>> entry : groupedMap.entrySet()) {
HaiAnGroupKey groupKey = entry.getKey(); HaiAnGroupKey groupKey = entry.getKey();
List<HaiAnShoporderAndMaterialDto> groupDtos = entry.getValue(); List<HaiAnShoporderAndMaterialDto> groupDtos = entry.getValue();
@ -271,10 +276,18 @@ public class HaiAnIssureNotifyServiceImpl implements HaiAnIssureNotifyService {
fillOrderDefaultValues(parent); fillOrderDefaultValues(parent);
haiAnIssureNotifyMapper.haiAnSaveSOIssueNotifyOrderList(parent); haiAnIssureNotifyMapper.haiAnSaveSOIssueNotifyOrderList(parent);
List<HaiAnSOIssueNotifyOrderMaterialList> children = buildChildren(data.getNotifyNo(), data.getSite(), subSite, groupDtos, nextItem, parent.getOrderType());
haiAnIssureNotifyMapper.haiAnBatchSaveSOIssueNotifyOrderMaterialList(children);
newItemNos.add(nextItem.toPlainString());
allChildren.addAll(buildChildren(data.getNotifyNo(), data.getSite(), subSite, groupDtos, nextItem, parent.getOrderType()));
nextItem = nextItem.add(BigDecimal.ONE); nextItem = nextItem.add(BigDecimal.ONE);
} }
// 仅清理本次新增item下的子行后重插不影响既有工单明细 - rqrq
if (!newItemNos.isEmpty()) {
haiAnIssureNotifyMapper.haiAnDeleteSOIssueNotifyOrderMaterialInList(data.getNotifyNo(), data.getSite(), newItemNos);
}
if (!allChildren.isEmpty()) {
haiAnIssureNotifyMapper.haiAnBatchSaveSOIssueNotifyOrderMaterialList(allChildren);
}
return "200"; return "200";
} }
@ -595,6 +608,51 @@ public class HaiAnIssureNotifyServiceImpl implements HaiAnIssureNotifyService {
return seed; return seed;
} }
/**
* @author rqrq
* @Description 校验领料单内工单是否重复按orderNo+releaseNo+sequenceNo判重含库内已有与本次请求内部重复 - rqrq
*/
private void validateDuplicateShopOrders(String site, String notifyNo, Set<HaiAnGroupKey> requestGroups) {
HaiAnSOIssueNotifyHeaderData query = new HaiAnSOIssueNotifyHeaderData();
query.setSite(site);
query.setNotifyNo(notifyNo);
List<HaiAnSOIssueNotifyOrderListData> existingOrders = haiAnIssureNotifyMapper.haiAnGetNotifyNoDetail(query);
Set<String> existingKeys = new HashSet<>();
if (existingOrders != null) {
for (HaiAnSOIssueNotifyOrderListData order : existingOrders) {
if (order == null) {
continue;
}
existingKeys.add(buildShopOrderUniqueKey(order.getSoorderNo(), order.getReleaseNo(), order.getSequenceNo()));
}
}
Set<String> requestKeys = new HashSet<>();
List<String> duplicateMsgs = new ArrayList<>();
for (HaiAnGroupKey groupKey : requestGroups) {
if (groupKey == null) {
continue;
}
String key = buildShopOrderUniqueKey(groupKey.getOrderNo(), groupKey.getReleaseNo(), groupKey.getSequenceNo());
String display = groupKey.getOrderNo() + "/" + groupKey.getReleaseNo() + "/" + groupKey.getSequenceNo();
if (existingKeys.contains(key)) {
duplicateMsgs.add(display + "(已存在于当前领料单)");
} else if (!requestKeys.add(key)) {
duplicateMsgs.add(display + "(本次提交重复)");
}
}
if (!duplicateMsgs.isEmpty()) {
throw new RuntimeException("工单重复,无法保存:" + String.join(";", duplicateMsgs));
}
}
private String buildShopOrderUniqueKey(String orderNo, String releaseNo, String sequenceNo) {
return StringUtils.defaultString(orderNo) + "|"
+ StringUtils.defaultString(releaseNo) + "|"
+ StringUtils.defaultString(sequenceNo);
}
private void fillOrderDefaultValues(HaiAnSOIssueNotifyOrderList parentItem) { private void fillOrderDefaultValues(HaiAnSOIssueNotifyOrderList parentItem) {
String normalizedOrderType = resolveHeaderOrderType(parentItem.getOrderType()); String normalizedOrderType = resolveHeaderOrderType(parentItem.getOrderType());
String productionArea; String productionArea;

17
src/main/java/com/gaotao/modules/trans/service/impl/TransHeaderServiceImpl.java

@ -13,7 +13,7 @@ import com.gaotao.modules.trans.service.TransDetailService;
import com.gaotao.modules.trans.service.TransDetailSubService; import com.gaotao.modules.trans.service.TransDetailSubService;
import com.gaotao.modules.trans.service.TransHeaderService; import com.gaotao.modules.trans.service.TransHeaderService;
import com.gaotao.modules.trans.service.TransNoControlService; import com.gaotao.modules.trans.service.TransNoControlService;
import com.gaotao.modules.warehouse.service.InventoryStockService;
// import com.gaotao.modules.warehouse.service.InventoryStockService;
import jakarta.transaction.Transactional; import jakarta.transaction.Transactional;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -31,8 +31,8 @@ public class TransHeaderServiceImpl extends ServiceImpl<TransHeaderMapper, Trans
@Autowired @Autowired
private TransNoControlService transNoService; private TransNoControlService transNoService;
@Autowired
private InventoryStockService inventoryStockService;
// @Autowired
// private InventoryStockService inventoryStockService;
@Autowired @Autowired
private TransDetailSubService transDetailSubService; private TransDetailSubService transDetailSubService;
@Autowired @Autowired
@ -176,11 +176,12 @@ public class TransHeaderServiceImpl extends ServiceImpl<TransHeaderMapper, Trans
transDetailSubService.save(sub); transDetailSubService.save(sub);
} }
for(TransDetail detail:detailList){
// 变更库存
inventoryStockService.changeInventoryStock(detail.getSite(),detail.getOrderRef4(),detail.getPartNo(),
detail.getBatchNo(), detail.getLocationId(), detail.getTransQty(),detail.getWdrNo(),detail.getEngChgLevel(),fangxiang);
}
// 暂不维护 inventory_stock先观察业务是否正常单据/HU 仍会写入
// for(TransDetail detail:detailList){
// // 变更库存
// inventoryStockService.changeInventoryStock(detail.getSite(),detail.getOrderRef4(),detail.getPartNo(),
// detail.getBatchNo(), detail.getLocationId(), detail.getTransQty(),detail.getWdrNo(),detail.getEngChgLevel(),fangxiang);
// }
return detailList; return detailList;
} }

Loading…
Cancel
Save