From 0fabec7da47f0a34e45c608354a5e55fef161411 Mon Sep 17 00:00:00 2001 From: lihao Date: Fri, 17 Oct 2025 19:04:48 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E8=B4=AD=E8=AE=A2=E5=8D=95=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E5=88=B0=E8=B4=A7=E5=8D=95=E5=A2=9E=E5=8A=A0=E6=9C=80?= =?UTF-8?q?=E7=BB=88=E9=9C=80=E6=B1=82=E6=95=B0=E9=87=8F=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../transfer/action/TransferOrderAction.java | 243 ++++++++++++++++++ 1 file changed, 243 insertions(+) create mode 100644 pu/src/client/nccloud/web/pu/arrival/transfer/action/TransferOrderAction.java diff --git a/pu/src/client/nccloud/web/pu/arrival/transfer/action/TransferOrderAction.java b/pu/src/client/nccloud/web/pu/arrival/transfer/action/TransferOrderAction.java new file mode 100644 index 00000000..5555472b --- /dev/null +++ b/pu/src/client/nccloud/web/pu/arrival/transfer/action/TransferOrderAction.java @@ -0,0 +1,243 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package nccloud.web.pu.arrival.transfer.action; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import nc.itf.uap.pf.IPfExchangeService; +import nc.pubitf.pu.m21.pu.m23.IOrderQueryFor23; +import nc.ui.querytemplate.querytree.IQueryScheme; +import nc.vo.ml.NCLangRes4VoTransl; +import nc.vo.pu.m20.entity.PraybillItemVO; +import nc.vo.pu.m20.entity.PraybillVO; +import nc.vo.pu.m21.entity.OrderHeaderVO; +import nc.vo.pu.m21.entity.OrderItemVO; +import nc.vo.pu.m21.entity.OrderVO; +import nc.vo.pu.m23.entity.ArriveHeaderVO; +import nc.vo.pu.m23.entity.ArriveMatFeeVO; +import nc.vo.pu.m23.entity.ArriveVO; +import nc.vo.pu.pub.util.BillHelper; +import nc.vo.pub.AggregatedValueObject; +import nc.vo.pub.BusinessException; +import nc.vo.pub.compiler.PfParameterVO; +import nc.vo.pub.lang.UFBoolean; +import nc.vo.pub.lang.UFDateTime; +import nc.vo.scmpub.util.ArrayUtil; +import nc.vo.scmpub.util.BillBodySortUtils; +import nc.vo.scmpub.util.TransferSortUtil; +import nccloud.dto.baseapp.querytree.dataformat.Condition; +import nccloud.dto.baseapp.querytree.dataformat.PageInfo; +import nccloud.dto.baseapp.querytree.dataformat.QueryCondition; +import nccloud.dto.baseapp.querytree.dataformat.QueryTreeFormatVO; +import nccloud.dto.baseapp.querytree.dataformat.Value; +import nccloud.dto.pu.arrival.entity.PkTsParamsVO; +import nccloud.dto.pu.arrival.entity.TransferData; +import nccloud.dto.pu.arrival.entity.TransferInfo; +import nccloud.dto.scmpub.pub.utils.SCMRowNoUtils; +import nccloud.framework.core.exception.ExceptionUtils; +import nccloud.framework.core.json.IJson; +import nccloud.framework.service.ServiceLocator; +import nccloud.framework.web.action.itf.ICommonAction; +import nccloud.framework.web.container.IRequest; +import nccloud.framework.web.json.JsonFactory; +import nccloud.framework.web.ui.pattern.extbillcard.ExtBillCard; +import nccloud.framework.web.ui.pattern.extbillcard.ExtBillCardOperator; +import nccloud.pubitf.platform.query.INCCloudQueryService; +import nccloud.web.pu.arrival.utis.ArrivalPrecisionHandler; +import nccloud.web.pu.arrival.utis.ArrivalScalaSetter; + +public class TransferOrderAction implements ICommonAction { + public TransferOrderAction() { + } + + public Object doAction(IRequest request) { + ExtBillCard[] cards = null; + + try { + String read = request.read(); + IJson json = JsonFactory.create(); + TransferInfo info = (TransferInfo)json.fromJson(read, TransferInfo.class); + Map idTsMap = new HashMap(); + TransferData[] datas = info.getData(); + Set bodyPks = new HashSet(); + Map> planPks = new HashMap(); + if (datas != null) { + for(TransferData data : datas) { + PkTsParamsVO head = data.getHead(); + if (head != null) { + idTsMap.put(head.getPk(), new UFDateTime(head.getTs())); + } + + PkTsParamsVO[] bodys = data.getBodys(); + if (bodys != null) { + for(PkTsParamsVO body : bodys) { + String pk = body.getPk(); + if (pk.contains("~")) { + String[] pks = pk.split("~"); + idTsMap.put(pks[0], new UFDateTime(body.getTs())); + bodyPks.add(pks[0]); + Set planSet = (Set)planPks.get(head.getPk()); + if (planSet == null) { + planSet = new HashSet(); + planPks.put(head.getPk(), planSet); + } + + planSet.add(pks[1]); + } else { + idTsMap.put(body.getPk(), new UFDateTime(body.getTs())); + bodyPks.add(body.getPk()); + } + } + } + } + } + + QueryTreeFormatVO queryTemplateInfo = new QueryTreeFormatVO(); + queryTemplateInfo.setOid("0001Z810000000081SLU"); + queryTemplateInfo.setQuerytype("tree"); + queryTemplateInfo.setPageInfo((PageInfo)null); + queryTemplateInfo.setPageCode("400401200_return23"); + queryTemplateInfo.setQueryAreaCode(info.getQueryAreaCode()); + List conditions = new ArrayList(); + QueryCondition con = new QueryCondition(); + Condition condition = new Condition(); + condition.setOprtype("="); + condition.setLogic("and"); + condition.setField("pk_order_b.pk_order_b"); + StringBuilder sb = new StringBuilder(); + + for(String pk : bodyPks) { + sb.append(pk).append(","); + } + + if (sb.length() > 0) { + sb.deleteCharAt(sb.length() - 1); + } + + Value value = new Value(); + value.setFirstvalue(sb.toString()); + condition.setValue(value); + conditions.add(condition); + con.setConditions(conditions); + con.setLogic("and"); + queryTemplateInfo.setQuerycondition(con); + INCCloudQueryService queryutil = (INCCloudQueryService)ServiceLocator.find(INCCloudQueryService.class); + IQueryScheme scheme = queryutil.convertCondition(queryTemplateInfo); + IOrderQueryFor23 query = (IOrderQueryFor23)ServiceLocator.find(IOrderQueryFor23.class); + OrderVO[] sorceVOs = query.queryFor23(scheme, (String[])bodyPks.toArray(new String[bodyPks.size()])); + if (sorceVOs != null) { + for(OrderVO vo : sorceVOs) { + OrderHeaderVO head = vo.getHVO(); + head.setTs((UFDateTime)idTsMap.get(head.getPk_order())); + OrderItemVO[] items = vo.getBVO(); + if (items != null) { + List list = new LinkedList(); + + for(OrderItemVO item : items) { + if (idTsMap.get(item.getPk_order_b()) != null) { + item.setTs((UFDateTime)idTsMap.get(item.getPk_order_b())); + Set set = (Set)planPks.get(head.getPk_order()); + if (set != null) { + if (set.contains(item.getPk_receiveplan())) { + list.add(item); + } + } else { + list.add(item); + } + } + } + + vo.setBVO((OrderItemVO[])list.toArray(new OrderItemVO[list.size()])); + } + } + + IPfExchangeService service = (IPfExchangeService)ServiceLocator.find(IPfExchangeService.class); + + for (OrderVO vo : sorceVOs) { + for (OrderItemVO itemVO:vo.getBVO()){ + if(null != itemVO.getAttributeValue("vbdef33") && itemVO.getNastnum().compareTo(itemVO.getAttributeValue("vbdef33"))<0){ + throw new BusinessException("采购数量大于最终需求数量不能生成采购订单!"); + } + } + } + AggregatedValueObject[] arrivos = service.runChangeDataAry("21", "23", sorceVOs, (PfParameterVO)null); + ArriveVO[] vos = (ArriveVO[])arrivos; + List gransonds = new ArrayList(); + if (!ArrayUtil.isEmpty(vos)) { + for(ArriveVO vo : vos) { + if (!ArrayUtil.isEmpty(vo.getAllGrandSonVOs())) { + gransonds.add(vo.getAllGrandSonVOs()); + } + } + } + + vos = (ArriveVO[])(new TransferSortUtil("vsourcerowno", "vsourcecode")).sort(vos); + ExtBillCardOperator operator = new ExtBillCardOperator(info.getPagecode()); + if (vos != null && vos.length > 0) { + for(ArriveVO vo : vos) { + BillBodySortUtils.sort(vo.getBVO(), "crowno"); + ArriveHeaderVO hvo = vo.getHVO(); + UFBoolean bisback = hvo.getBisback(); + if (bisback == null) { + hvo.setBisback(UFBoolean.FALSE); + } + + int[] rows = this.getItemRows(vo); + SCMRowNoUtils.setMultiSelectRowNo(vo.getBVO(), rows); + } + + cards = new ExtBillCard[vos.length]; + + for(int i = 0; i < vos.length; ++i) { + cards[i] = operator.toCard(vos[i]); + ArrivalScalaSetter.setArrivalScalaBillCard(cards[i]); + (new ArrivalPrecisionHandler()).processCard(cards[i]); + } + } + + if (gransonds.size() > 0 && !ArrayUtil.isEmpty(vos)) { + for(int i = 0; i < vos.length; ++i) { + if (cards[i].getGrandSons("card_fee_detail") == null) { + ExceptionUtils.wrapBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("4004100_0", "04004100-0309", (String)null, new String[]{vos[i].getBVO()[0].getVsourcecode()})); + } + } + } + } else { + ExceptionUtils.wrapBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("4004100_0", "04004100-0005")); + } + } catch (Exception e) { + ExceptionUtils.wrapException(e); + } + + return cards; + } + + private int[] getItemRows(ArriveVO aggVO) { + BillHelper helper = new BillHelper(aggVO); + int[] trows = new int[aggVO.getBVO().length]; + List lists = new ArrayList(); + + for(int i = 0; i < trows.length; ++i) { + Object object = helper.getBodyValue(i, "pk_material"); + if (object != null && !object.toString().equals("null")) { + lists.add(i); + } + } + + int[] rows = new int[lists.size()]; + + for(int n = 0; n < lists.size(); ++n) { + rows[n] = (Integer)lists.get(n); + } + + return rows; + } +}