请购单推送采购订单增加最终需求数量校验

This commit is contained in:
lihao 2025-10-17 19:03:38 +08:00
parent f8c0b93110
commit 9ab4bf8bdc
1 changed files with 269 additions and 0 deletions

View File

@ -0,0 +1,269 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package nccloud.web.pu.poorder.transfer.action;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import nc.itf.scmpub.reference.uap.bd.supplier.SupplierPubService;
import nc.itf.uap.pf.IPfExchangeService;
import nc.vo.ml.NCLangRes4VoTransl;
import nc.vo.pu.m20.entity.PraybillHeaderVO;
import nc.vo.pu.m20.entity.PraybillItemVO;
import nc.vo.pu.m20.entity.PraybillVO;
import nc.vo.pu.m21.entity.OrderItemVO;
import nc.vo.pu.m21.entity.OrderVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.CircularlyAccessibleValueObject;
import nc.vo.pub.compiler.PfParameterVO;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.pubapp.pattern.model.entity.bill.AbstractBill;
import nc.vo.scmpub.res.billtype.POBillType;
import nc.vo.scmpub.util.TransferSortUtil;
import nccloud.dto.pu.poorder.entity.PkTsVODTO;
import nccloud.dto.pu.poorder.entity.TransferData;
import nccloud.dto.pu.poorder.entity.TransferInfo;
import nccloud.framework.core.json.IJson;
import nccloud.framework.service.ServiceLocator;
import nccloud.framework.web.json.JsonFactory;
import nccloud.framework.web.processor.template.BillGridConvertProcessor;
import nccloud.framework.web.ui.pattern.billgrid.BillGrid;
import nccloud.pubitf.pu.poorder.transfer.service.ITransferVOQueryService;
public class Transfer20To21Action extends AbstractTransferAction {
protected static final int BEGININDEX = 0;
protected static final int ENDINDEX = 20;
public Transfer20To21Action() {
}
public AbstractBill[] getDestAbstractBill(TransferInfo transferInfo, String read) throws Exception {
PraybillVO[] sorceVOs = this.getAggVO(read);
for (PraybillVO vo : sorceVOs) {
for (PraybillItemVO itemVO:vo.getBVO()){
if(null!=itemVO.getAttributeValue("vbdef33") && itemVO.getNastnum().compareTo(itemVO.getAttributeValue("vbdef33"))<0){
throw new BusinessException("采购数量大于最终需求数量不能生成采购订单!");
}
}
}
IPfExchangeService service = (IPfExchangeService)ServiceLocator.find(IPfExchangeService.class);
OrderVO[] vos = (OrderVO[])service.runChangeDataAry(POBillType.PrayBill.getCode(), POBillType.Order.getCode(), sorceVOs, (PfParameterVO)null);
vos = (OrderVO[])(new TransferSortUtil("vsourcerowno", "vsourcecode")).sort(vos);
if (vos != null && vos.length > 0) {
for(OrderVO orderVO : vos) {
UFDate dbilldate = orderVO.getHVO().getDbilldate();
OrderItemVO[] bvos = orderVO.getBVO();
for(OrderItemVO bvo : bvos) {
UFDate dplanarrvdate = bvo.getDplanarrvdate();
if (dbilldate != null && (null == dplanarrvdate || dbilldate.compareTo(dplanarrvdate) > 0)) {
bvo.setDplanarrvdate(dbilldate);
}
}
}
}
return vos;
}
public Boolean isNeedRelateCT() {
return Boolean.TRUE;
}
private PraybillVO[] getAggVOByBillGrid(String read) {
IJson json = JsonFactory.create();
BillGrid[] billGrids = (BillGrid[])json.fromJson(read, BillGrid[].class);
BillGridConvertProcessor processor = new BillGridConvertProcessor();
List<PraybillVO> list = new ArrayList();
for(BillGrid billGrid : billGrids) {
PraybillVO vos = (PraybillVO)processor.fromBillCard(billGrid, "pk_praybill_b");
list.add(vos);
}
return (PraybillVO[])list.toArray(new PraybillVO[0]);
}
private PraybillVO[] getAggVO(String read) {
IJson json = JsonFactory.create();
TransferInfo queryInfo = (TransferInfo)json.fromJson(read, TransferInfo.class);
PraybillVO[] aggctvos = null;
Map<String, UFDateTime> idTsHeadMap = this.getIdTsIndex(queryInfo, "pk_praybill");
Map<String, UFDateTime> idTsIndex = this.getIdTsIndex(queryInfo, "pk_praybill_b");
Map<String, Map<String, Object>> idUserObjectIndex = this.getBodyIdUserObjectIndex(queryInfo);
if (idTsHeadMap.size() == 0) {
return aggctvos;
} else {
String[] hpks = new String[idTsHeadMap.size()];
String[] bpks = null;
hpks = (String[])idTsHeadMap.keySet().toArray(hpks);
if (idTsIndex != null && idTsIndex.size() > 0) {
bpks = new String[idTsIndex.size()];
bpks = (String[])idTsIndex.keySet().toArray(bpks);
}
ITransferVOQueryService query = (ITransferVOQueryService)ServiceLocator.find(ITransferVOQueryService.class);
PraybillHeaderVO[] hvos = (PraybillHeaderVO[])query.query(hpks, PraybillHeaderVO.class);
PraybillItemVO[] bvos = (PraybillItemVO[])query.query(bpks, PraybillItemVO.class);
this.tsCheck(idTsHeadMap, hvos);
if (hvos == null) {
return aggctvos;
} else {
aggctvos = this.getAggCtPuVOS(hvos, bvos, idTsHeadMap, idTsIndex, idUserObjectIndex);
return aggctvos;
}
}
}
private void tsCheck(Map<String, UFDateTime> idTsHeadMap, PraybillHeaderVO[] hvos) {
Map<String, UFDateTime> hvoHeadTsMap = new HashMap();
for(PraybillHeaderVO hvo : hvos) {
hvoHeadTsMap.put(hvo.getPk_praybill(), hvo.getTs());
}
for(Map.Entry<String, UFDateTime> item : idTsHeadMap.entrySet()) {
if (item.getValue() == null || hvoHeadTsMap.get(item.getKey()) == null || !((UFDateTime)item.getValue()).equals(hvoHeadTsMap.get(item.getKey()))) {
ExceptionUtils.wrappBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("4004100_0", "04004100-0048"));
}
}
}
private Map<String, UFDateTime> getIdTsIndex(TransferInfo queryInfo, String attrcode) {
Map<String, UFDateTime> idTsIndex = new LinkedHashMap();
TransferData[] tData = queryInfo.getData();
if (tData != null && tData.length > 0) {
for(TransferData element : tData) {
if ("pk_praybill".equalsIgnoreCase(attrcode)) {
PkTsVODTO head = element.getHead();
if (head != null) {
idTsIndex.put(head.getPk(), head.getTs());
}
} else {
PkTsVODTO[] bodys = element.getBodys();
if (bodys != null) {
for(PkTsVODTO body : bodys) {
String pk = body.getPk();
pk = pk.length() > 20 ? pk.substring(0, 20) : pk;
idTsIndex.put(pk, body.getTs());
}
}
}
}
}
return idTsIndex;
}
private Map<String, Map<String, Object>> getBodyIdUserObjectIndex(TransferInfo queryInfo) {
Map<String, Map<String, Object>> idTsIndex = new HashMap();
TransferData[] tData = queryInfo.getData();
if (tData != null && tData.length > 0) {
for(TransferData element : tData) {
PkTsVODTO[] bodys = element.getBodys();
if (bodys != null) {
for(PkTsVODTO body : bodys) {
Map<String, Object> userObject = body.getUserObject();
Map<String, Object> var14 = userObject != null ? userObject : new HashMap();
idTsIndex.put(body.getPk(), var14);
}
}
}
}
return idTsIndex;
}
private PraybillVO[] getAggCtPuVOS(PraybillHeaderVO[] hvos, PraybillItemVO[] bvos, Map<String, UFDateTime> idTsHeadMap, Map<String, UFDateTime> idTsIndex, Map<String, Map<String, Object>> idUserObjectIndex) {
Set<String> supplieroidList = new HashSet();
Iterator<Map.Entry<String, Map<String, Object>>> iterator1 = idUserObjectIndex.entrySet().iterator();
if (idUserObjectIndex != null && idUserObjectIndex.size() > 0) {
while(iterator1.hasNext()) {
Map.Entry<String, Map<String, Object>> next = (Map.Entry)iterator1.next();
Map<String, Object> object = (Map)next.getValue();
String pk_suggestsupplier = String.valueOf(object.get("pk_suggestsupplier"));
if (pk_suggestsupplier != null) {
supplieroidList.add(pk_suggestsupplier);
}
}
}
Map<String, String> vidsByOids = SupplierPubService.querySupplierVidsByOids((String[])supplieroidList.toArray(new String[supplieroidList.size()]));
PraybillVO[] aggvos = new PraybillVO[hvos.length];
for(int n = 0; n < aggvos.length; ++n) {
hvos[n].setTs((UFDateTime)idTsHeadMap.get(hvos[n].getPk_praybill()));
PraybillVO aggvo = new PraybillVO();
aggvo.setParentVO(hvos[n]);
String pk_praybill = hvos[n].getPk_praybill();
List<PraybillItemVO> lbvo = new ArrayList();
if (bvos != null) {
for(PraybillItemVO bvo : bvos) {
String pk_praybill_b = bvo.getPk_praybill_b();
bvo.setTs((UFDateTime)idTsIndex.get(pk_praybill_b));
Iterator<Map.Entry<String, Map<String, Object>>> iterator = idUserObjectIndex.entrySet().iterator();
if (idUserObjectIndex != null && idUserObjectIndex.size() > 0) {
while(iterator.hasNext()) {
Map.Entry<String, Map<String, Object>> next = (Map.Entry)iterator.next();
if (((String)next.getKey()).startsWith(pk_praybill_b)) {
Map<String, Object> object = (Map)next.getValue();
PraybillItemVO clone = (PraybillItemVO)bvo.clone();
this.moifyBodyItem(lbvo, clone, object, pk_praybill);
}
}
} else {
Map<String, Object> hashMap = new HashMap();
this.moifyBodyItem(lbvo, bvo, hashMap, pk_praybill);
}
}
}
if (lbvo != null) {
PraybillItemVO[] arr = new PraybillItemVO[lbvo.size()];
aggvo.setChildrenVO((CircularlyAccessibleValueObject[])lbvo.toArray(arr));
for(PraybillItemVO bvo : aggvo.getBVO()) {
bvo.setPk_suggestsupplier_v(vidsByOids.get(bvo.getPk_suggestsupplier()) == null ? bvo.getPk_suggestsupplier() : (String)vidsByOids.get(bvo.getPk_suggestsupplier()));
}
}
aggvos[n] = aggvo;
}
return aggvos;
}
private void moifyBodyItem(List<PraybillItemVO> lbvo, PraybillItemVO bvo, Map<String, Object> map, String pk_praybill) {
Map<String, Object> var8 = map != null ? map : new HashMap();
String nnum = String.valueOf(((Map)var8).get("nnum"));
String nastnum = String.valueOf(((Map)var8).get("nastnum"));
String pk_suggestsupplier = String.valueOf(((Map)var8).get("pk_suggestsupplier"));
if (nnum != null && !"null".equals(nnum) && !"".equals(nnum)) {
bvo.setAttributeValue("nnum", ((Map)var8).get("nnum"));
}
if (nastnum != null && !"null".equals(nastnum) && !"".equals(nastnum)) {
bvo.setAttributeValue("nastnum", ((Map)var8).get("nastnum"));
}
if (pk_suggestsupplier != null && !"null".equals(pk_suggestsupplier) && !"".equals(pk_suggestsupplier)) {
bvo.setPk_suggestsupplier(pk_suggestsupplier);
}
if (bvo.getPk_praybill().equalsIgnoreCase(pk_praybill)) {
lbvo.add(bvo);
}
}
}