请购单已执行时修改下游。 请购单修订保存处理类:源码

This commit is contained in:
lihao 2025-11-12 11:03:14 +08:00
parent 8315431933
commit 0030bd2f1c
1 changed files with 162 additions and 0 deletions

View File

@ -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<PraybillVO> 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<PraybillVO> processer = new AroundProcesser(PraybillPluginPoint.REVISEDELETE);
this.addBeforeRule(processer);
processer.before(orderVos);
BillDelete<IBill> bo = new BillDelete();
bo.delete(orderVos);
return this.updateHistoryVos(orderVos);
}
}
private void addBeforeRule(AroundProcesser<PraybillVO> 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;
}
}