From 0030bd2f1c0513b3bee8db5a37a102454cbaec40 Mon Sep 17 00:00:00 2001 From: lihao Date: Wed, 12 Nov 2025 11:03:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=B7=E8=B4=AD=E5=8D=95=E5=B7=B2=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E6=97=B6=E4=BF=AE=E6=94=B9=E4=B8=8B=E6=B8=B8=E3=80=82?= =?UTF-8?q?=20=E8=AF=B7=E8=B4=AD=E5=8D=95=E4=BF=AE=E8=AE=A2=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E5=A4=84=E7=90=86=E7=B1=BB=EF=BC=9A=E6=BA=90=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/pu/m20/action/PraybillRAction.java | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 pu/src/private/nc/impl/pu/m20/action/PraybillRAction.java diff --git a/pu/src/private/nc/impl/pu/m20/action/PraybillRAction.java b/pu/src/private/nc/impl/pu/m20/action/PraybillRAction.java new file mode 100644 index 00000000..1ba54826 --- /dev/null +++ b/pu/src/private/nc/impl/pu/m20/action/PraybillRAction.java @@ -0,0 +1,162 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package nc.impl.pu.m20.action; + +import java.util.Arrays; +import nc.bs.pu.m20.maintain.PraybillInsertReviseBP; +import nc.bs.pu.m20.maintain.PraybillUpdateReviseBP; +import nc.bs.pu.m20.maintain.rule.delete.ReviseDeleteBeforeEventRule; +import nc.bs.pu.m20.plugin.PraybillPluginPoint; +import nc.impl.pubapp.pattern.data.bill.BillDelete; +import nc.impl.pubapp.pattern.data.bill.BillQuery; +import nc.impl.pubapp.pattern.data.bill.BillUpdate; +import nc.impl.pubapp.pattern.data.bill.tool.BillConcurrentTool; +import nc.impl.pubapp.pattern.data.bill.tool.BillTransferTool; +import nc.impl.pubapp.pattern.rule.processer.AroundProcesser; +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.m20.enumeration.EnumRevise; +import nc.vo.pu.pub.enumeration.POEnumBillStatus; +import nc.vo.pub.lang.UFBoolean; +import nc.vo.pub.lang.UFDate; +import nc.vo.pubapp.AppContext; +import nc.vo.pubapp.pattern.model.entity.bill.IBill; +import nccloud.commons.lang.ArrayUtils; + +public class PraybillRAction { + public PraybillRAction() { + } + + public PraybillVO[] revise(PraybillVO[] orderVos) { + if (ArrayUtils.isEmpty(orderVos)) { + return null; + } else { + BillTransferTool tool = new BillTransferTool(orderVos); + PraybillVO[] voOrginal = (PraybillVO[])tool.getOriginBills(); + PraybillVO[] voRevised; + if (POEnumBillStatus.APPROVE.value().equals(orderVos[0].getHVO().getFbillstatus())) { + BillConcurrentTool utilBill = new BillConcurrentTool(); + utilBill.lockBill(voOrginal); + utilBill.checkTS(orderVos, voOrginal); + this.insertNewVO(orderVos); + voRevised = this.saveNewVO(orderVos, voOrginal); + this.saveOriginVos(voOrginal); + } else { + voRevised = this.updateVO(orderVos, voOrginal); + } + + return voRevised; + } + } + + public PraybillVO[] reviseDelete(PraybillVO[] orderVos) { + if (ArrayUtils.isEmpty(orderVos)) { + return null; + } else { + AroundProcesser processer = new AroundProcesser(PraybillPluginPoint.REVISEDELETE); + this.addBeforeRule(processer); + processer.before(orderVos); + BillDelete bo = new BillDelete(); + bo.delete(orderVos); + return this.updateHistoryVos(orderVos); + } + } + + private void addBeforeRule(AroundProcesser processer) { + processer.addBeforeRule(new ReviseDeleteBeforeEventRule()); + } + + private void insertNewVO(PraybillVO[] orderVos) { + if (!ArrayUtils.isEmpty(orderVos)) { + for(int i = 0; i < orderVos.length; ++i) { + PraybillHeaderVO voHead = orderVos[i].getHVO(); + String pk_praybill = voHead.getPk_praybill(); + voHead.setStatus(2); + voHead.setPk_praybill((String)null); + voHead.setBislatest(UFBoolean.FALSE); + voHead.setPk_srcpraybill(pk_praybill); + int nversion = Integer.valueOf(voHead.getNversion()); + voHead.setNversion(nversion + 1); + voHead.setApprover((String)null); + voHead.setTaudittime((UFDate)null); + voHead.setFbillstatus(POEnumBillStatus.FREE.toIntValue()); + voHead.setModifyStatus(EnumRevise.MODIFY.toIntValue()); + voHead.setCreviseoperid(AppContext.getInstance().getPkUser()); + voHead.setTrevisiontime(AppContext.getInstance().getBusiDate()); + voHead.setBshowLatest(UFBoolean.TRUE); + PraybillItemVO[] bodyVo = orderVos[i].getBVO(); + PraybillItemVO[] bodyVos = (PraybillItemVO[])Arrays.stream(bodyVo).filter((vo) -> vo.getStatus() != 3).toArray((x$0) -> new PraybillItemVO[x$0]); + + for(int j = 0; j < bodyVos.length; ++j) { + String pk_praybill_b = bodyVos[j].getPk_praybill_b(); + bodyVos[j].setPk_srcpraybillb(pk_praybill_b); + bodyVos[j].setStatus(2); + bodyVos[j].setPk_praybill_b((String)null); + bodyVos[j].setPk_praybill((String)null); + } + + orderVos[i].setBVO(bodyVos); + } + + } + } + + private void saveOriginVos(PraybillVO[] orgVos) { + PraybillVO[] orgVosClone = new PraybillVO[orgVos.length]; + + for(int i = 0; i < orgVos.length; ++i) { + orgVosClone[i] = (PraybillVO)orgVos[i].clone(); + PraybillHeaderVO headVo = orgVosClone[i].getHVO(); + headVo.setPk_srcpraybill(headVo.getPk_praybill()); + headVo.setBshowLatest(UFBoolean.FALSE); + headVo.setStatus(1); + PraybillItemVO[] bodyVos = orgVosClone[i].getBVO(); + + for(PraybillItemVO bVo : bodyVos) { + bVo.setPk_srcpraybillb(bVo.getPk_praybill_b()); + bVo.setStatus(1); + } + } + + (new BillUpdate()).update(orgVosClone, orgVos); + } + + private PraybillVO[] saveNewVO(PraybillVO[] orderVos, PraybillVO[] voOrginal) { + if (ArrayUtils.isEmpty(orderVos)) { + return null; + } else { + PraybillVO[] vo = (new PraybillInsertReviseBP()).insert(orderVos, voOrginal); + return vo; + } + } + + private PraybillVO[] updateVO(PraybillVO[] voSaved, PraybillVO[] voOrginal) { + return ArrayUtils.isEmpty(voSaved) ? null : (new PraybillUpdateReviseBP()).update(voSaved, voOrginal); + } + + private PraybillVO[] updateHistoryVos(PraybillVO[] orgVos) { + String[] oids = new String[orgVos.length]; + + for(int i = 0; i < orgVos.length; ++i) { + oids[i] = orgVos[i].getHVO().getPk_srcpraybill(); + } + + PraybillVO[] oldVos = (PraybillVO[])(new BillQuery(PraybillVO.class)).query(oids); + PraybillVO[] oldVosClone = new PraybillVO[oldVos.length]; + + for(int j = 0; j < oldVos.length; ++j) { + oldVosClone[j] = (PraybillVO)oldVos[j].clone(); + PraybillHeaderVO headVo = oldVosClone[j].getHVO(); + headVo.setBshowLatest(UFBoolean.TRUE); + headVo.setBislatest(UFBoolean.TRUE); + headVo.setStatus(1); + } + + PraybillVO[] updatedVos = (PraybillVO[])(new BillUpdate()).update(oldVosClone, oldVos); + return updatedVos; + } +}