diff --git a/arap/src/private/nc/bs/arap/actions/GatheringbillEditSaveBatchBSAction.java b/arap/src/private/nc/bs/arap/actions/GatheringbillEditSaveBatchBSAction.java new file mode 100644 index 0000000..a49745c --- /dev/null +++ b/arap/src/private/nc/bs/arap/actions/GatheringbillEditSaveBatchBSAction.java @@ -0,0 +1,109 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package nc.bs.arap.actions; + +import nc.bs.arap.bill.ArapBillPubUtil; +import nc.bs.arap.util.ArapBillVOUtils; +import nc.bs.arap.util.BillAccountCalendarUtils; +import nc.bs.arap.util.BillDateUtils; +import nc.bs.arap.validator.CrossRuleCheckValidator; +import nc.bs.dao.BaseDAO; +import nc.jdbc.framework.processor.MapProcessor; +import nc.vo.arap.basebill.BaseBillVO; +import nc.vo.arap.utils.StringUtil; +import nc.vo.pub.AggregatedValueObject; +import nc.vo.pub.BusinessException; +import nc.vo.pub.CircularlyAccessibleValueObject; +import nc.vo.pub.lang.UFDouble; + +import java.util.Map; + +public class GatheringbillEditSaveBatchBSAction extends BillUpdateBatchBSAction { + public GatheringbillEditSaveBatchBSAction() { + this.validatorCode.add(5); + this.validatorCode.add(34); + this.validatorCode.add(57); + this.validatorCode.add(59); + this.validatorCode.add(62); + this.validatorCode.add(93); + this.validatorCode.add(94); + this.validatorCode.add(100); + } + + protected void doBeforeUpdate(AggregatedValueObject[] bills, AggregatedValueObject[] orginBills) throws BusinessException { + ArapBillPubUtil.fillTradeTypeInfo(bills); + + for(AggregatedValueObject bill : bills) { + ArapBillPubUtil.processMoneyOnlySum(bill); + } + + /** + * 收款单保存校验关联的销售订单实际收款金额是否超过价税合计 + */ + int i = 0; + + for(AggregatedValueObject bill : bills) { + AggregatedValueObject oriBill = orginBills[i++]; + BaseBillVO billVO = (BaseBillVO) bill.getParentVO(); //修改的收款单 + BaseBillVO billOriVO = (BaseBillVO) oriBill.getParentVO(); //之前的收款单 + UFDouble money = billVO.getMoney(); //修改后的金额 + UFDouble oriMoney = billOriVO.getMoney(); //修改前的金额 + String pk_tradetype = billVO.getPk_tradetype(); + if(!"F2-Cxx-02".equals(pk_tradetype)){ + continue; + } + String def3 = billVO.getDef3(); //收款单对应的销售订单id + if(StringUtil.isEmpty(def3) || "N".equals(def3) || "~".equals(def3)){ + //无绑定的销售订单则下一次循环 + continue; + } + //计算收款单金额差值 + UFDouble changeMoney = money.sub(oriMoney); + //根据销售订单id去查询销售订单 + BaseDAO dao = new BaseDAO(); + String sql = "select nreceivedmny,ntotalorigmny from so_saleorder where dr = 0 and csaleorderid = '" +def3+"'"; + Map saleMap = (Map)dao.executeQuery(sql, new MapProcessor()); + //销售订单价税合计 + UFDouble ntotalorigmny = UFDouble.ZERO_DBL; + //销售订单实际收款金额 + UFDouble nreceivedmny = UFDouble.ZERO_DBL; + if(saleMap != null) { + nreceivedmny = new UFDouble(saleMap.get("nreceivedmny") == null ? "0" : saleMap.get("nreceivedmny").toString()); + ntotalorigmny = new UFDouble(saleMap.get("ntotalorigmny") == null ? "0" : saleMap.get("ntotalorigmny").toString()); + } + UFDouble moreMoney = nreceivedmny.add(changeMoney).sub(ntotalorigmny); + if(nreceivedmny.add(changeMoney).compareTo(ntotalorigmny) > 0){ + throw new BusinessException("【该笔收款已超销售订单"+ moreMoney +"元,无法传输!请检查订单累计收款金额!】"); + } + } + + ArapBillVOUtils.prepareDefaultInfo(bills, true); + BillDateUtils.setBillDateByNow(bills); + int updateType = this.getUpdateType(bills, orginBills); + + for(AggregatedValueObject bill : bills) { + bill.getParentVO().setStatus(1); + } + + if (updateType == TEMP_2_SAVE || updateType == SAVE_2_SAVE) { + for(AggregatedValueObject bill : bills) { + for(CircularlyAccessibleValueObject item : bill.getChildrenVO()) { + if (item.getStatus() != 2 && item.getStatus() != 3) { + item.setStatus(1); + } + } + } + } + + if (updateType == TEMP_2_SAVE || updateType == SAVE_2_SAVE) { + BillAccountCalendarUtils.setAccperiodYearMonth(bills); + } + + this.checkIsCorrdBillMoneyControl(bills, orginBills); + this.checkOtherSystemBill(bills, orginBills); + (new CrossRuleCheckValidator()).validate(bills); + } +} diff --git a/arap/src/private/nc/bs/arap/actions/GatheringbillSaveBatchBSAction.java b/arap/src/private/nc/bs/arap/actions/GatheringbillSaveBatchBSAction.java new file mode 100644 index 0000000..00be7a2 --- /dev/null +++ b/arap/src/private/nc/bs/arap/actions/GatheringbillSaveBatchBSAction.java @@ -0,0 +1,96 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package nc.bs.arap.actions; + +import nc.bs.arap.bill.ArapBillPubUtil; +import nc.bs.arap.util.ArapBillVOUtils; +import nc.bs.arap.util.BillAccountCalendarUtils; +import nc.bs.arap.util.BillDateUtils; +import nc.bs.arap.util.BillMoneyVUtils; +import nc.bs.arap.validator.CrossRuleCheckValidator; +import nc.bs.dao.BaseDAO; +import nc.jdbc.framework.processor.MapProcessor; +import nc.vo.arap.basebill.BaseBillVO; +import nc.vo.arap.utils.StringUtil; +import nc.vo.pub.AggregatedValueObject; +import nc.vo.pub.BusinessException; +import nc.vo.pub.lang.UFDouble; + +import java.util.Map; + +public class GatheringbillSaveBatchBSAction extends BillInsertBatchBSAction { + public GatheringbillSaveBatchBSAction() { + this.validatorCode.add(5); + this.validatorCode.add(15); + this.validatorCode.add(29); + this.validatorCode.add(19); + this.validatorCode.add(8); + this.validatorCode.add(24); + this.validatorCode.add(28); + this.validatorCode.add(44); + this.validatorCode.add(46); + this.validatorCode.add(31); + this.validatorCode.add(36); + this.validatorCode.add(23); + this.validatorCode.add(49); + this.validatorCode.add(57); + this.validatorCode.add(59); + this.validatorCode.add(62); + this.validatorCode.add(93); + this.validatorCode.add(94); + this.validatorCode.add(100); + } + + protected void doBeforeInsert(AggregatedValueObject[] bills) throws BusinessException { + ArapBillPubUtil.fillTradeTypeInfo(bills); + BillDateUtils.setBillDateByNow(bills); + ArapBillPubUtil.resetBasedocVid(bills); + BillAccountCalendarUtils.setAccperiodYearMonth(bills); + ArapBillVOUtils.prepareDefaultInfo(bills); + BillMoneyVUtils.sumAllVoBodyToHead(bills); + (new CrossRuleCheckValidator()).validate(bills); + ArapBillPubUtil.resetDestVODoc(bills); + ArapBillVOUtils.setMaterialInfo(bills); + ArapBillVOUtils.setDefaultSagaFrozen(bills); + ArapBillVOUtils.setDefaultFeeundertaker(bills); + ArapBillVOUtils.setDefaultSettleFlag(bills); + + /** + * 收款单保存校验关联的销售订单实际收款金额是否超过价税合计 + */ + + for(AggregatedValueObject bill : bills) { + BaseBillVO billVO = (BaseBillVO) bill.getParentVO(); //修改的收款单 + UFDouble money = billVO.getMoney(); //金额 + String pk_tradetype = billVO.getPk_tradetype(); + if(!"F2-Cxx-02".equals(pk_tradetype)){ + continue; + } + String def3 = billVO.getDef3(); //收款单对应的销售订单id + if(StringUtil.isEmpty(def3) || "N".equals(def3) || "~".equals(def3)){ + //无绑定的销售订单则下一次循环 + continue; + } + + //根据销售订单id去查询销售订单 + BaseDAO dao = new BaseDAO(); + String sql = "select nreceivedmny,ntotalorigmny from so_saleorder where dr = 0 and csaleorderid = '" +def3+"'"; + Map saleMap = (Map)dao.executeQuery(sql, new MapProcessor()); + //销售订单价税合计 + UFDouble ntotalorigmny = UFDouble.ZERO_DBL; + //销售订单实际收款金额 + UFDouble nreceivedmny = UFDouble.ZERO_DBL; + if(saleMap != null) { + nreceivedmny = new UFDouble(saleMap.get("nreceivedmny") == null ? "0" : saleMap.get("nreceivedmny").toString()); + ntotalorigmny = new UFDouble(saleMap.get("ntotalorigmny") == null ? "0" : saleMap.get("ntotalorigmny").toString()); + } + UFDouble moreMoney = nreceivedmny.add(money).sub(ntotalorigmny); + if(nreceivedmny.add(money).compareTo(ntotalorigmny) > 0){ + throw new BusinessException("【该笔收款已超销售订单"+ moreMoney +"元,无法传输!请检查订单累计收款金额!】"); + } + } + } +} diff --git a/sscivm/src/private/nccloud/itf/sscivm/ivsale/impl/IVApplicationServiceImpl.java b/sscivm/src/private/nccloud/itf/sscivm/ivsale/impl/IVApplicationServiceImpl.java new file mode 100644 index 0000000..276d6b6 --- /dev/null +++ b/sscivm/src/private/nccloud/itf/sscivm/ivsale/impl/IVApplicationServiceImpl.java @@ -0,0 +1,931 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package nccloud.itf.sscivm.ivsale.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.google.gson.Gson; +import com.google.gson.internal.LinkedTreeMap; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import nc.bs.businessevent.EventDispatcher; +import nc.bs.dao.BaseDAO; +import nc.bs.framework.common.InvocationInfoProxy; +import nc.bs.framework.common.NCLocator; +import nc.bs.framework.common.RuntimeEnv; +import nc.bs.pub.pf.PfUtilTools; +import nc.bs.sscivm.ivsale.bp.IVApplicationDeleteBP; +import nc.bs.sscivm.ivsale.bp.IVApplicationInsertBP; +import nc.bs.sscivm.ivsale.bp.IVApplicationQueryBP; +import nc.bs.sscivm.ivsale.bp.IVApplicationUpdateBP; +import nc.bs.sscivm.ivsale.splitmerge.util.TransSpiltMergePksUtil; +import nc.bs.sscivm.ivsale.util.ApplicationBusinessEvent; +import nc.bs.sscivm.ivsale.util.IVApplicationBillDefValue; +import nc.bs.sscivm.ivsale.util.IVApplicationSlsmUtil; +import nc.bs.sscivm.ivsale.util.IVSaleUtil; +import nc.bs.sscivm.logger.SSCIVMLogger; +import nc.bs.sscivm.util.IVMSagaValidationUtils; +import nc.impl.pubapp.pattern.data.bill.tool.BillTransferTool; +import nc.itf.bd.material.baseinfo.IMaterialBaseInfoQueryService; +import nc.itf.uap.pf.IWorkflowDefine; +import nc.itf.uap.pf.IWorkflowMachine; +import nc.itf.uap.pf.metadata.IFlowBizItf; +import nc.jdbc.framework.processor.ColumnProcessor; +import nc.pubitf.bbd.CurrtypeQuery; +import nc.pubitf.para.SysInitQuery; +import nc.pubitf.uapbd.CurrencyRateUtilHelper; +import nc.pubitf.uapbd.ICustomerPubService; +import nc.pubitf.uapbd.IMaterialPubService; +import nc.uap.pf.metadata.PfMetadataTools; +import nc.vo.bd.currtype.CurrtypeVO; +import nc.vo.bd.material.MaterialVO; +import nc.vo.bd.material.MaterialVersionVO; +import nc.vo.ic.pub.util.StringUtil; +import nc.vo.ml.NCLangRes4VoTransl; +import nc.vo.org.OrgQueryUtil; +import nc.vo.org.OrgVO; +import nc.vo.pf.pub.util.SQLUtil; +import nc.vo.pub.AggregatedValueObject; +import nc.vo.pub.BusinessException; +import nc.vo.pub.CircularlyAccessibleValueObject; +import nc.vo.pub.lang.UFBoolean; +import nc.vo.pub.lang.UFDate; +import nc.vo.pub.lang.UFDateTime; +import nc.vo.pub.lang.UFDouble; +import nc.vo.pub.workflownote.WorkflownoteVO; +import nc.vo.pubapp.pattern.exception.ExceptionUtils; +import nc.vo.sscivm.ivmpub.IVAplocationFPXZ; +import nc.vo.sscivm.ivmpub.IVAplocationKPFS; +import nc.vo.sscivm.ivsale.IVApplicationAggVO; +import nc.vo.sscivm.ivsale.IVApplicationBodyVO; +import nc.vo.sscivm.ivsale.IVApplicationHeadVO; +import nc.vo.sscivm.ivsale.IVApplogVO; +import nc.vo.sscivm.ivsale.IVBilltypeVO; +import nc.vo.sscivm.ivsale.IVTspzsBodyVO; +import nc.vo.sscivm.ivsale.MessageVO; +import nc.vo.uap.pf.PFBusinessException; +import nc.vo.uap.pf.PfProcessBatchRetObject; +import nc.vo.wfengine.definition.WorkflowTypeEnum; +import nccloud.commons.lang.StringUtils; +import nccloud.itf.sscivm.ivsale.service.ApplicationLogService; +import nccloud.itf.sscivm.ivsale.service.IVABilltypeExtService; +import nccloud.itf.sscivm.ivsale.service.IVApplicationInvoiceService; +import nccloud.itf.sscivm.ivsale.service.IVApplicationQueryService; +import nccloud.itf.sscivm.ivsale.service.IVApplicationService; +import nccloud.pubitf.riart.pflow.CloudPFlowContext; +import nccloud.pubitf.riart.pflow.ICloudScriptPFlowService; +import nccloud.putitf.riart.billtype.IBilltypeService; + +public class IVApplicationServiceImpl implements IVApplicationService { + public IVApplicationServiceImpl() { + } + + public IVApplicationAggVO save(IVApplicationAggVO ivApplicationVO) throws BusinessException { + IVApplicationAggVO[] ivApplicationVOs = null; + + try { + ivApplicationVOs = this.saveBatch(new IVApplicationAggVO[]{ivApplicationVO}); + } catch (Exception e) { + SSCIVMLogger.error(e.getMessage(), e); + ExceptionUtils.marsh(e); + } + + return ivApplicationVOs != null && ivApplicationVOs.length != 0 ? ivApplicationVOs[0] : null; + } + + public IVApplicationAggVO[] saveBatch(IVApplicationAggVO[] clientFullVOs) throws BusinessException { + IVApplicationAggVO[] retvos = null; + HashSet retVOLits = new HashSet(); + + try { + IVApplicationInsertBP action = new IVApplicationInsertBP(); + retvos = action.insert(clientFullVOs); + HashSet tradetypeids = new HashSet(); + + for(IVApplicationAggVO applicationAggVO : retvos) { + tradetypeids.add(applicationAggVO.getParentVO().getTranstypecode()); + } + + IVABilltypeExtService var10000 = (IVABilltypeExtService)NCLocator.getInstance().lookup(IVABilltypeExtService.class); + String var10001 = InvocationInfoProxy.getInstance().getGroupId(); + IVBilltypeVO[] billtypeVOS = var10000.getBilltypeVOsByWhere(" pk_group ='" + var10001 + "' and " + SQLUtil.buildSqlForIn("billtypecode", (String[])tradetypeids.toArray(new String[tradetypeids.size()]))); + if (billtypeVOS != null && billtypeVOS.length > 0) { + HashSet atuoVOs = new HashSet(); + HashSet noatuoVOs = new HashSet(); + + for(IVApplicationAggVO retvo : retvos) { + boolean Isatuo_submit = UFBoolean.FALSE.booleanValue(); + + for(IVBilltypeVO billtypeVO : billtypeVOS) { + if (retvo.getParentVO().getTranstypecode() != null && retvo.getParentVO().getTranstypecode().equals(billtypeVO.getBilltypecode()) && billtypeVO.getIsatuo_submit() == UFBoolean.TRUE) { + Isatuo_submit = UFBoolean.TRUE.booleanValue(); + } + } + + if (Isatuo_submit) { + atuoVOs.add(retvo); + } else { + noatuoVOs.add(retvo); + } + } + + if (atuoVOs != null && atuoVOs.size() > 0) { + Object submitObj = this.submit((IVApplicationAggVO[])atuoVOs.toArray(new IVApplicationAggVO[atuoVOs.size()]), (IVApplicationAggVO[])null, (Object)null); + if (submitObj instanceof Map) { + throw new BusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", "01058sal-0053")); + } + + retvos = (IVApplicationAggVO[])submitObj; + if (retvos != null && retvos.length > 0) { + for(IVApplicationAggVO retvo : retvos) { + retVOLits.add(retvo); + } + + if (noatuoVOs != null && noatuoVOs.size() > 0) { + retVOLits.addAll(noatuoVOs); + } + } + + retvos = (IVApplicationAggVO[])retVOLits.toArray(new IVApplicationAggVO[retVOLits.size()]); + } else if (noatuoVOs != null && noatuoVOs.size() > 0) { + retVOLits.addAll(noatuoVOs); + retvos = (IVApplicationAggVO[])retVOLits.toArray(new IVApplicationAggVO[retVOLits.size()]); + } + } + } catch (Exception e) { + SSCIVMLogger.error(e.getMessage(), e); + ExceptionUtils.marsh(e); + } + + return retvos; + } + + public void deleteById(String pk) throws BusinessException { + this.deleteByIds(new String[]{pk}); + } + + public void deleteByIds(String[] pks) throws BusinessException { + IVApplicationAggVO[] retvos = (new IVApplicationQueryBP()).queryAggIVApplicationVOByCondition(SQLUtil.buildSqlForIn("pk_ivapplication", pks)); + (new IVApplicationDeleteBP()).delete(retvos); + } + + public void delete(IVApplicationAggVO vo) throws BusinessException { + try { + (new IVApplicationDeleteBP()).delete(new IVApplicationAggVO[]{vo}); + } catch (Exception e) { + SSCIVMLogger.error(e.getMessage(), e); + ExceptionUtils.marsh(e); + } + + } + + public void deleteBatch(IVApplicationAggVO[] vos) throws BusinessException { + try { + (new IVApplicationDeleteBP()).delete(vos); + } catch (Exception e) { + SSCIVMLogger.error(e.getMessage(), e); + ExceptionUtils.marsh(e); + } + + } + + public void deleteBatchdUnCheckApproveStaus(IVApplicationAggVO[] vos) throws BusinessException { + try { + (new IVApplicationDeleteBP()).deleteUnCheckApproveStaus(vos); + } catch (Exception e) { + SSCIVMLogger.error(e.getMessage(), e); + ExceptionUtils.marsh(e); + } + + } + + public IVApplicationAggVO update(IVApplicationAggVO ivApplicationVO) throws BusinessException { + IVApplicationAggVO[] retvos = null; + + try { + if (ivApplicationVO == null || ivApplicationVO.getParentVO() == null) { + return null; + } + + Integer approveStatus = ivApplicationVO.getParentVO().getBillstatus(); + if (approveStatus == 1) { + throw new BusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", "01058sal-0024")); + } + + if (approveStatus == 3 || approveStatus == 2) { + String billId = ivApplicationVO.getParentVO().getPk_ivapplication(); + String billType = ivApplicationVO.getParentVO().getTranstypecode(); + String userId = InvocationInfoProxy.getInstance().getUserId(); + if (!this.isFlowCheckman(billId, billType, userId)) { + throw new BusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", "01058sal-0050")); + } + } + + retvos = this.updateBatch(new IVApplicationAggVO[]{ivApplicationVO}, (IVApplicationAggVO[])null); + if (retvos != null && retvos.length > 0) { + CircularlyAccessibleValueObject[] bodys = retvos[0].getChildrenVO(); + if (bodys != null && bodys.length > 0) { + for(int m = 0; m < bodys.length; ++m) { + CircularlyAccessibleValueObject body = bodys[m]; + body.setAttributeValue("rowid", ivApplicationVO.getChildrenVO()[m].getAttributeValue("rowid")); + } + } + } + } catch (Exception e) { + SSCIVMLogger.error(e.getMessage(), e); + ExceptionUtils.marsh(e); + } + + return retvos != null && retvos.length != 0 ? retvos[0] : null; + } + + public IVApplicationAggVO[] updateBatch(IVApplicationAggVO[] clientFullVOs, IVApplicationAggVO[] originBills) throws BusinessException { + IVApplicationAggVO[] retvos = null; + + try { + BillTransferTool transferTool = new BillTransferTool(clientFullVOs); + IVApplicationUpdateBP action = new IVApplicationUpdateBP(); + originBills = (IVApplicationAggVO[])transferTool.getOriginBills(); + retvos = action.update(clientFullVOs, originBills); + } catch (Exception e) { + SSCIVMLogger.error(e.getMessage(), e); + ExceptionUtils.marsh(e); + } + + return retvos; + } + + public IVApplicationAggVO updateForUI(IVApplicationAggVO ivApplicationVO) throws BusinessException { + IVApplicationAggVO[] retvos = null; + + try { + if (ivApplicationVO == null || ivApplicationVO.getParentVO() == null) { + return null; + } + + Integer approveStatus = ivApplicationVO.getParentVO().getBillstatus(); + if (approveStatus == 1) { + throw new BusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", "01058sal-0024")); + } + + if (approveStatus == 3 || approveStatus == 2) { + String billId = ivApplicationVO.getParentVO().getPk_ivapplication(); + String billType = ivApplicationVO.getParentVO().getTranstypecode(); + String userId = InvocationInfoProxy.getInstance().getUserId(); + if (!this.isFlowCheckman(billId, billType, userId)) { + throw new BusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", "01058sal-0050")); + } + } + + //如果来源单据为销售发票,根据来源单据编号src_billno和来源单据类型(billtype = 32)查询销售发票价税合计(ntotalorigmny)与开票申请中价税合计(jshj)比较,须满足 jshj 0){ + throw new BusinessException("价税合计不能超过销售发票中价税合计"); + } + } + + retvos = this.updateBatchForUI(new IVApplicationAggVO[]{ivApplicationVO}, (IVApplicationAggVO[])null); + if (retvos != null && retvos.length > 0) { + CircularlyAccessibleValueObject[] bodys = retvos[0].getChildrenVO(); + if (bodys != null && bodys.length > 0) { + for(int m = 0; m < bodys.length; ++m) { + CircularlyAccessibleValueObject body = bodys[m]; + body.setAttributeValue("rowid", ivApplicationVO.getChildrenVO()[m].getAttributeValue("rowid")); + } + } + } + } catch (Exception e) { + SSCIVMLogger.error(e.getMessage(), e); + ExceptionUtils.marsh(e); + } + + return retvos != null && retvos.length != 0 ? retvos[0] : null; + } + + private IVApplicationAggVO[] updateBatchForUI(IVApplicationAggVO[] clientFullVOs, IVApplicationAggVO[] originBills) throws BusinessException { + IVApplicationAggVO[] retvos = null; + + try { + BillTransferTool transferTool = new BillTransferTool(clientFullVOs); + IVApplicationUpdateBP action = new IVApplicationUpdateBP(); + originBills = (IVApplicationAggVO[])transferTool.getOriginBills(); + retvos = action.update(clientFullVOs, originBills); + Map pkAndOldVOMap = new HashMap(); + + for(IVApplicationAggVO aggVO : originBills) { + pkAndOldVOMap.put(aggVO.getPrimaryKey(), aggVO); + } + + HashSet tradetypeids = new HashSet(); + + for(IVApplicationAggVO applicationAggVO : retvos) { + IVApplicationAggVO oldApplicationAggVO = (IVApplicationAggVO)pkAndOldVOMap.get(applicationAggVO.getPrimaryKey()); + if (applicationAggVO.getParentVO().getBillstatus() == -1 && oldApplicationAggVO.getParentVO().getBillstatus() == -1) { + tradetypeids.add(applicationAggVO.getParentVO().getTranstypecode()); + } + } + + if (tradetypeids.size() == 0) { + return retvos; + } + + IVABilltypeExtService var10000 = (IVABilltypeExtService)NCLocator.getInstance().lookup(IVABilltypeExtService.class); + String var10001 = InvocationInfoProxy.getInstance().getGroupId(); + IVBilltypeVO[] billtypeVOS = var10000.getBilltypeVOsByWhere(" pk_group ='" + var10001 + "' and " + SQLUtil.buildSqlForIn("billtypecode", (String[])tradetypeids.toArray(new String[tradetypeids.size()]))); + if (billtypeVOS != null && billtypeVOS.length > 0) { + HashSet atuoVOs = new HashSet(); + HashSet noatuoVOs = new HashSet(); + + for(IVApplicationAggVO retvo : retvos) { + boolean Isatuo_submit = UFBoolean.FALSE.booleanValue(); + + for(IVBilltypeVO billtypeVO : billtypeVOS) { + if (retvo.getParentVO().getTranstypecode() != null && retvo.getParentVO().getTranstypecode().equals(billtypeVO.getBilltypecode()) && billtypeVO.getIsatuo_submit() == UFBoolean.TRUE) { + Isatuo_submit = UFBoolean.TRUE.booleanValue(); + } + } + + if (Isatuo_submit) { + atuoVOs.add(retvo); + } else { + noatuoVOs.add(retvo); + } + } + + List retVOLits = new ArrayList(); + if (atuoVOs != null && atuoVOs.size() > 0) { + Object submitObj = this.submit((IVApplicationAggVO[])atuoVOs.toArray(new IVApplicationAggVO[atuoVOs.size()]), (IVApplicationAggVO[])null, (Object)null); + if (submitObj instanceof Map) { + throw new BusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", "01058sal-0053")); + } + + retvos = (IVApplicationAggVO[])submitObj; + if (retvos != null && retvos.length > 0) { + for(IVApplicationAggVO retvo : retvos) { + retVOLits.add(retvo); + } + + if (noatuoVOs != null && noatuoVOs.size() > 0) { + retVOLits.addAll(noatuoVOs); + } + } + + retvos = (IVApplicationAggVO[])retVOLits.toArray(new IVApplicationAggVO[retVOLits.size()]); + } else if (noatuoVOs != null && noatuoVOs.size() > 0) { + retVOLits.addAll(noatuoVOs); + retvos = (IVApplicationAggVO[])retVOLits.toArray(new IVApplicationAggVO[retVOLits.size()]); + } + } + } catch (Exception e) { + SSCIVMLogger.error(e.getMessage(), e); + ExceptionUtils.marsh(e); + } + + return retvos; + } + + public Object submit(IVApplicationAggVO[] clientBills, IVApplicationAggVO[] originBills, Object assingUsers) throws BusinessException { + if (clientBills != null && clientBills.length > 0) { + String[] pks = new String[clientBills.length]; + + for(int i = 0; i < clientBills.length; ++i) { + pks[i] = clientBills[i].getParentVO().getPk_ivapplication(); + } + + IVMSagaValidationUtils.checkSagaStatus(pks, IVApplicationHeadVO.getDefaultTableName(), "pk_ivapplication"); + } + + List retvos = new ArrayList(); + + try { + for(int i = 0; i < clientBills.length; ++i) { + AggregatedValueObject billVO = clientBills[i]; + if (clientBills[i].getParentVO().getBillstatus() != -1) { + String var10002 = NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", "01058sal-0025"); + throw new BusinessException(var10002 + (i + 1) + NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", "01058sal-0026")); + } + + Object retObj = this.doNccCommit(billVO, assingUsers); + if (retObj instanceof Map) { + return retObj; + } + + if (retObj != null) { + retvos.add((IVApplicationAggVO)((MessageVO)retObj).getSuccessVO()); + } + } + } catch (Exception e) { + SSCIVMLogger.error(e.getMessage(), e); + ExceptionUtils.marsh(e); + } + + return retvos.toArray(new IVApplicationAggVO[retvos.size()]); + } + + private Object doNccCommit(AggregatedValueObject aggVos, Object assingUsers) throws Exception { + MessageVO result = null; + IVApplicationQueryService ivApplicationQueryService = (IVApplicationQueryService)NCLocator.getInstance().lookup(IVApplicationQueryService.class); + AggregatedValueObject billVO = aggVos; + String djlxbm = null; + + try { + if (billVO.getParentVO() instanceof IVApplicationHeadVO) { + IVApplicationAggVO[] submitVos = ivApplicationQueryService.queryAggVOsByPks(new String[]{((IVApplicationHeadVO)billVO.getParentVO()).getPrimaryKey()}); + if (submitVos != null && submitVos.length > 0 && (null == ((IVApplicationHeadVO)billVO.getParentVO()).getTs() || ((IVApplicationHeadVO)billVO.getParentVO()).getTs().compareTo(submitVos[0].getParentVO().getTs()) != 0)) { + throw new Exception(NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", "01058sal-0057")); + } + + String tradetypePk = ((IVApplicationHeadVO)billVO.getParentVO()).getPk_tradetype(); + djlxbm = ((IBilltypeService)NCLocator.getInstance().lookup(IBilltypeService.class)).getBilltypeCode(tradetypePk); + } + + Object retObj = null; + HashMap paramMap = new HashMap(); + paramMap.put("silently", "silently"); + String cuserid = InvocationInfoProxy.getInstance().getUserId(); + UFDateTime currTime = new UFDateTime(InvocationInfoProxy.getInstance().getBizDateTime()); + WorkflownoteVO noteVO = null; + + try { + noteVO = ((IWorkflowMachine)NCLocator.getInstance().lookup(IWorkflowMachine.class)).checkWorkFlow("SAVE", djlxbm, billVO, (HashMap)null); + } catch (BusinessException e) { + SSCIVMLogger.error(e.getMessage(), e); + } + + boolean hasWorkfFlow = false; + if (noteVO == null) { + try { + IFlowBizItf fbi = (IFlowBizItf)PfMetadataTools.getBizItfImpl(billVO, IFlowBizItf.class); + IWorkflowDefine wfDefine = (IWorkflowDefine)NCLocator.getInstance().lookup(IWorkflowDefine.class); + hasWorkfFlow = wfDefine.hasValidProcessDef(((IVApplicationHeadVO)billVO.getParentVO()).getPk_org(), ((IVApplicationHeadVO)billVO.getParentVO()).getTranstypecode(), fbi.getPkorg(), fbi.getBillMaker(), fbi.getEmendEnum(), WorkflowTypeEnum.Workflow.getIntValue()); + if (!hasWorkfFlow) { + hasWorkfFlow = wfDefine.hasValidProcessDef(InvocationInfoProxy.getInstance().getGroupId(), ((IVApplicationHeadVO)billVO.getParentVO()).getTranstypecode(), fbi.getPkorg(), fbi.getBillMaker(), fbi.getEmendEnum(), WorkflowTypeEnum.Workflow.getIntValue()); + } + } catch (PFBusinessException var16) { + String err = NCLangRes4VoTransl.getNCLangRes().getStrByID("pfworkflow", "UPPpfworkflow-000058"); + if (var16.getMessage() == null || !var16.getMessage().contains(err)) { + throw new PFBusinessException(var16); + } + } + + if (!hasWorkfFlow) { + ((IVApplicationHeadVO)billVO.getParentVO()).setApprover(cuserid); + ((IVApplicationHeadVO)billVO.getParentVO()).setApprovedate(currTime); + ((IVApplicationHeadVO)billVO.getParentVO()).setBillstatus(1); + UFDate preDate = ((IVApplicationHeadVO)billVO.getParentVO()).getPreparedate(); + if (preDate.toStdString().substring(0, 10).compareTo(currTime.toStdString().substring(0, 10)) > 0) { + throw new BusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", "01058sal-0150")); + } + + retObj = this.approveVOs(new IVApplicationAggVO[]{(IVApplicationAggVO)billVO}); + } else { + retObj = this.commitScriptPFlow("START", djlxbm, billVO, assingUsers); + } + } else { + retObj = this.commitScriptPFlow("SAVE", djlxbm, billVO, assingUsers); + } + + if (retObj == null) { + result = new MessageVO(billVO, 8); + result.setSuccess(false); + result.setErrorMessage(NCLangRes4VoTransl.getNCLangRes().getStrByID("2011", "UPP2011-000339")); + } else { + if (retObj instanceof Map) { + return retObj; + } + + if (retObj instanceof AggregatedValueObject) { + result = new MessageVO((AggregatedValueObject)retObj, 8); + } else if (retObj instanceof MessageVO[]) { + MessageVO[] messages = (MessageVO[])retObj; + result = messages[0]; + } else if (retObj instanceof MessageVO) { + result = (MessageVO)retObj; + } else if (retObj instanceof PfProcessBatchRetObject) { + if ((PfProcessBatchRetObject)retObj != null && ((PfProcessBatchRetObject)retObj).getRetObj() != null) { + result = (MessageVO)((PfProcessBatchRetObject)retObj).getRetObj()[0]; + } else { + result = new MessageVO((AggregatedValueObject)null, 8); + } + } + } + } catch (Exception e) { + SSCIVMLogger.error(e.getMessage(), e); + ExceptionUtils.marsh(e); + } + + return result; + } + + private Object commitScriptPFlow(String actionName, String djlxbm, AggregatedValueObject aggVo, Object assingUsers) throws BusinessException { + new JSONObject(); + HashMap eParam = new HashMap(); + if (assingUsers instanceof LinkedTreeMap) { + JSONObject assignContent = JSON.parseObject((new Gson()).toJson(assingUsers)); + eParam.put("content", assignContent); + } + + eParam.put("silently", "silently"); + if ("START".equals(actionName)) { + String checkman = ""; + BaseDAO dao = new BaseDAO(); + String sql = " SELECT a.checkman FROM PUB_WORKFLOWNOTE a INNER JOIN PUB_WF_TASK b ON a.PK_WF_TASK = b.PK_WF_TASK WHERE a.billid ='" + aggVo.getParentVO().getPrimaryKey() + "' and a.actiontype='MAKEBILL' and b.REJECTTACHEACTIVITYID is not null and a.ischeck='N' "; + Object obj = dao.executeQuery(sql, new ColumnProcessor()); + if (obj != null) { + checkman = (String)obj; + actionName = "SIGNAL" + checkman; + } + } + + CloudPFlowContext context = new CloudPFlowContext(); + context.setActionName(actionName); + context.setBillType(djlxbm); + context.setBillVos(new AggregatedValueObject[]{aggVo}); + context.seteParam(eParam); + Object[] ss = null; + if ("START".equals(actionName)) { + WorkflownoteVO noteVO = null; + + try { + noteVO = ((IWorkflowMachine)NCLocator.getInstance().lookup(IWorkflowMachine.class)).checkWorkFlow("START", djlxbm, aggVo, (HashMap)null); + } catch (BusinessException e) { + SSCIVMLogger.error(e.getMessage(), e); + } + + WorkflowTypeEnum flowtype = PfUtilTools.runningFlowStatus(StringUtils.isNotEmpty(context.getTrantype()) ? context.getTrantype() : context.getBillType(), aggVo.getParentVO().getPrimaryKey()); + if (flowtype == null && (noteVO == null || noteVO.getTaskInfo().getAssignableInfos().size() == 0)) { + ss = ((ICloudScriptPFlowService)NCLocator.getInstance().lookup(ICloudScriptPFlowService.class)).exeScriptPFlow_CommitNoFlowBatch(context); + } + } + + if (ss == null) { + ss = ((ICloudScriptPFlowService)NCLocator.getInstance().lookup(ICloudScriptPFlowService.class)).exeScriptPFlow(context); + } + + Object obj = ss[0]; + if (obj instanceof Map map && ((Map)obj).get("workflow") != null && ("approveflow".equals(String.valueOf(((Map)obj).get("workflow"))) || "workflow".equals(String.valueOf(((Map)obj).get("workflow"))))) { + if (map.get("workflow") != null) { + return map; + } + } + + return obj; + } + + public IVApplicationAggVO[] recall(IVApplicationAggVO[] clientBills, IVApplicationAggVO[] originBills) throws BusinessException { + if (clientBills != null && clientBills.length > 0) { + String[] pks = new String[clientBills.length]; + + for(int i = 0; i < clientBills.length; ++i) { + pks[i] = clientBills[i].getParentVO().getPk_ivapplication(); + } + + IVMSagaValidationUtils.checkSagaStatus(pks, IVApplicationHeadVO.getDefaultTableName(), "pk_ivapplication"); + } + + List retvos = new ArrayList(); + + try { + for(int i = 0; i < clientBills.length; ++i) { + AggregatedValueObject billVO = clientBills[i]; + if (clientBills[i].getParentVO().getBillstatus() != 3 && clientBills[i].getParentVO().getBillstatus() != 1) { + String var11 = NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", "01058sal-0025"); + throw new BusinessException(var11 + (i + 1) + NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", "01058sal-0028")); + } + + List applogVOList = ((ApplicationLogService)NCLocator.getInstance().lookup(ApplicationLogService.class)).queryApplicationLogByLyid(TransSpiltMergePksUtil.transIvapplicationToLyid(new String[]{clientBills[i].getParentVO().getPk_ivapplication()})); + if (applogVOList != null && applogVOList.size() > 0) { + String var10002 = NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", "01058sal-0029"); + throw new BusinessException(var10002 + clientBills[i].getParentVO().getBillno() + NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", "01058sal-0030")); + } + + Object retObj = this.doNccRecall(billVO); + retvos.add((IVApplicationAggVO)((MessageVO)retObj).getSuccessVO()); + } + } catch (Exception e) { + SSCIVMLogger.error(e.getMessage(), e); + ExceptionUtils.marsh(e); + } + + return (IVApplicationAggVO[])retvos.toArray(new IVApplicationAggVO[retvos.size()]); + } + + private Object doNccRecall(AggregatedValueObject billVO) throws Exception { + MessageVO result = null; + IVApplicationQueryService ivApplicationQueryService = (IVApplicationQueryService)NCLocator.getInstance().lookup(IVApplicationQueryService.class); + String djlxbm = null; + + try { + if (billVO.getParentVO() instanceof IVApplicationHeadVO) { + IVApplicationAggVO[] submitVos = ivApplicationQueryService.queryAggVOsByPks(new String[]{((IVApplicationHeadVO)billVO.getParentVO()).getPrimaryKey()}); + if (submitVos != null && submitVos.length > 0 && (null == ((IVApplicationHeadVO)billVO.getParentVO()).getTs() || ((IVApplicationHeadVO)billVO.getParentVO()).getTs().compareTo(submitVos[0].getParentVO().getTs()) != 0)) { + throw new Exception(NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", "01058sal-0057")); + } + + String tradetypePk = ((IVApplicationHeadVO)billVO.getParentVO()).getPk_tradetype(); + djlxbm = ((IBilltypeService)NCLocator.getInstance().lookup(IBilltypeService.class)).getBilltypeCode(tradetypePk); + } + + String actionName = "RECALL"; + boolean isApproveflowFlag = IVSaleUtil.isApproveFlowStartup(billVO.getParentVO().getPrimaryKey(), djlxbm); + if (isApproveflowFlag) { + actionName = "UNSAVE"; + } + + Object[] exeScriptPFlow = null; + CloudPFlowContext context = new CloudPFlowContext(); + context.setActionName(actionName); + context.setBillType(djlxbm); + context.setBillVos(new AggregatedValueObject[]{billVO}); + context.seteParam(new HashMap()); + WorkflowTypeEnum flowtype = PfUtilTools.runningFlowStatus(StringUtils.isNotEmpty(context.getTrantype()) ? context.getTrantype() : context.getBillType(), billVO.getParentVO().getPrimaryKey()); + ICloudScriptPFlowService service = (ICloudScriptPFlowService)NCLocator.getInstance().lookup(ICloudScriptPFlowService.class); + if (flowtype == null) { + exeScriptPFlow = service.exeScriptPFlow_UnSaveNoFlowBatch(context); + } else { + exeScriptPFlow = service.exeScriptPFlow(context); + } + + if (exeScriptPFlow[0] instanceof PfProcessBatchRetObject) { + if ((PfProcessBatchRetObject)exeScriptPFlow[0] != null && ((PfProcessBatchRetObject)exeScriptPFlow[0]).getRetObj() != null) { + result = new MessageVO((AggregatedValueObject)((PfProcessBatchRetObject)exeScriptPFlow[0]).getRetObj()[0], 9); + } else { + result = new MessageVO((AggregatedValueObject)null, 9); + } + } else if (exeScriptPFlow[0] instanceof AggregatedValueObject) { + result = new MessageVO((AggregatedValueObject)exeScriptPFlow[0], 9); + } + + return result; + } catch (Exception e) { + SSCIVMLogger.error(e.getMessage(), e); + throw e; + } + } + + public IVApplicationAggVO dealDefValue(String uistate, String pk_group, String pk_user, String pk_tradetype, String appcode) throws Exception { + IVApplicationAggVO retvos = new IVApplicationAggVO(); + IVApplicationBillDefValue billDefValue = new IVApplicationBillDefValue(); + if (!"onInit".equals(uistate) && !"add".equals(uistate)) { + if (!"onChange".equals(uistate) && "edit".equals(uistate)) { + } + } else { + retvos = billDefValue.getNewVO(pk_group, pk_user, pk_tradetype, appcode); + } + + return retvos; + } + + public String getOrgLocalCurrPK(String pk_org) throws BusinessException { + String orgLocalCurrPK = CurrencyRateUtilHelper.getInstance().getLocalCurrtypeByOrgID(pk_org); + return orgLocalCurrPK; + } + + public Integer getCurrDigit(String pk_currtype) throws BusinessException { + if (StringUtils.isEmpty(pk_currtype)) { + return 0; + } else { + CurrtypeVO currtypeVO = null; + if (RuntimeEnv.getInstance().isRunningInServer()) { + currtypeVO = CurrtypeQuery.getInstance().getCurrtypeVO(pk_currtype); + } + + return currtypeVO == null ? 0 : currtypeVO.getCurrdigit(); + } + } + + public String getOrgVersion(String voclassname, String name, String pk_org) throws Exception { + OrgVO[] vos = OrgQueryUtil.queryOrgVOByPks(new String[]{pk_org}); + return vos[0].getPk_vid(); + } + + public MessageVO[] approveVOs(IVApplicationAggVO[] applicationAggVOs) throws Exception { + if (applicationAggVOs != null && applicationAggVOs.length != 0) { + for(int i = 0; i < applicationAggVOs.length; ++i) { + applicationAggVOs[i].getParentVO().setStatus(1); + } + + IVApplicationAggVO[] aggVOs = this.updateBatch(applicationAggVOs, (IVApplicationAggVO[])null); + MessageVO[] msgs = new MessageVO[aggVOs.length]; + + for(int i = 0; i < aggVOs.length; ++i) { + msgs[i] = new MessageVO(aggVOs[i], 1); + } + + EventDispatcher.fireEvent(new ApplicationBusinessEvent("f4555e3d-c6a1-42bf-8354-57be38eb5dd6", "1020", aggVOs)); + IVApplicationInvoiceService applicationInvoiceService = (IVApplicationInvoiceService)NCLocator.getInstance().lookup(IVApplicationInvoiceService.class); + + for(int i = 0; i < aggVOs.length; ++i) { + String billTypePk = aggVOs[i].getParentVO().getPk_tradetype(); + String billtypeCode = ((IBilltypeService)NCLocator.getInstance().lookup(IBilltypeService.class)).getBilltypeCode(billTypePk); + IVBilltypeVO billtypeVO = ((IVABilltypeExtService)NCLocator.getInstance().lookup(IVABilltypeExtService.class)).getBilltypeVOByCode(billtypeCode, InvocationInfoProxy.getInstance().getGroupId()); + if (null != billtypeVO && IVApplicationSlsmUtil.slsmCheck(aggVOs[i]) && billtypeVO.getIsatuo_invoice() == UFBoolean.TRUE) { + JSONObject jsonObj = new JSONObject(); + IVApplicationAggVO[] voAfterMakeInvoice = applicationInvoiceService.makeInvoice(new IVApplicationAggVO[]{aggVOs[i]}, jsonObj, (Map)null, false); + msgs[i] = new MessageVO(voAfterMakeInvoice[0], 1); + } + } + + return msgs; + } else { + return null; + } + } + + public Object unApproveVOs(IVApplicationAggVO[] applicationAggVOs) throws BusinessException { + if (applicationAggVOs != null && applicationAggVOs.length != 0) { + for(int i = 0; i < applicationAggVOs.length; ++i) { + List applogVOList = ((ApplicationLogService)NCLocator.getInstance().lookup(ApplicationLogService.class)).queryApplicationLogByLyid(TransSpiltMergePksUtil.transIvapplicationToLyid(new String[]{applicationAggVOs[i].getParentVO().getPk_ivapplication()})); + if (applogVOList != null && applogVOList.size() > 0) { + String var10002 = NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", "01058sal-0029"); + throw new BusinessException(var10002 + applicationAggVOs[i].getParentVO().getBillno() + NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", "01058sal-0030")); + } + + applicationAggVOs[i].getParentVO().setStatus(1); + } + + IVApplicationAggVO[] aggVOs = this.updateBatch(applicationAggVOs, (IVApplicationAggVO[])null); + MessageVO[] msgs = new MessageVO[aggVOs.length]; + + for(int i = 0; i < aggVOs.length; ++i) { + msgs[i] = new MessageVO(aggVOs[i], 2); + } + + EventDispatcher.fireEvent(new ApplicationBusinessEvent("f4555e3d-c6a1-42bf-8354-57be38eb5dd6", "1022", aggVOs)); + return msgs; + } else { + return null; + } + } + + public IVApplicationAggVO copyApplication(String pk) throws Exception { + IVApplicationAggVO aggVO = ((IVApplicationQueryService)NCLocator.getInstance().lookup(IVApplicationQueryService.class)).queryByPK(pk); + if (aggVO == null) { + throw new BusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", "01058sal-0057")); + } else if (aggVO.getParentVO().getHzfp() != UFBoolean.TRUE && aggVO.getParentVO().getZffp() != UFBoolean.TRUE) { + if (aggVO.getParentVO().getSrc_pkbusibill() != null) { + throw new BusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", "01058sal-0032")); + } else { + IVApplicationAggVO copyVo = aggVO.clone(); + IVApplicationHeadVO headvo = copyVo.getParentVO(); + String[] headFieldNotCopy = new String[]{"pk_ivapplication", "approvedate", "approver", "billno", "billstatus", "creationtime", "creator", "kpr", "kpzt", "lyid", "modifiedtime", "modifier", "preparedate", "src_billno", "src_pkbusibill", "src_tradetype", "saga_frozen", "saga_gtxid", "saga_btxid", "saga_status", "invoiced_hjje", "invoiced_hjse", "invoiced_jshj", "invoiceing_hjje", "invoiceing_hjse", "invoiceing_jshj", "caninvoice_hjje", "caninvoice_hjse", "caninvoice_jshj", "hzxxsqb", "email", "slsm"}; + + for(int i = 0; i < headFieldNotCopy.length; ++i) { + headvo.setAttributeValue(headFieldNotCopy[i], (Object)null); + } + + Set meterialPKs = new HashSet(); + + for(int i = 0; i < copyVo.getChildrenVO().length; ++i) { + IVApplicationBodyVO bodyVO = (IVApplicationBodyVO)copyVo.getChildrenVO()[i]; + bodyVO.setPk_ivappdetail((String)null); + bodyVO.setPk_ivapplication((String)null); + bodyVO.setCaninvoice_se(UFDouble.ZERO_DBL); + bodyVO.setCaninvoice_xmje(UFDouble.ZERO_DBL); + bodyVO.setCaninvoice_xmjshj(UFDouble.ZERO_DBL); + bodyVO.setCaninvoice_xmsl(UFDouble.ZERO_DBL); + bodyVO.setInvoiced_se(UFDouble.ZERO_DBL); + bodyVO.setInvoiced_xmje(UFDouble.ZERO_DBL); + bodyVO.setInvoiced_xmjshj(UFDouble.ZERO_DBL); + bodyVO.setInvoiced_xmsl(UFDouble.ZERO_DBL); + bodyVO.setInvoiceing_se(UFDouble.ZERO_DBL); + bodyVO.setInvoiceing_xmje(UFDouble.ZERO_DBL); + bodyVO.setInvoiceing_xmjshj(UFDouble.ZERO_DBL); + bodyVO.setInvoiceing_xmsl(UFDouble.ZERO_DBL); + if (bodyVO.getPk_materiel() != null) { + meterialPKs.add(bodyVO.getPk_materiel()); + } + + if (IVAplocationFPXZ.FPXZ_ZCH.toIntValue() == bodyVO.getFphxz()) { + bodyVO.setHh((String)null); + bodyVO.setZkhhh((String)null); + } + } + + if (copyVo.getIvTspzsBodyVO() != null) { + for(int i = 0; i < copyVo.getIvTspzsBodyVO().length; ++i) { + IVTspzsBodyVO ivTspzsBodyVO = copyVo.getIvTspzsBodyVO()[i]; + ivTspzsBodyVO.setPk_ivtspzsdetail((String)null); + ivTspzsBodyVO.setPk_ivapplication((String)null); + ivTspzsBodyVO.setPk_ivappdetail((String)null); + } + } + + if (meterialPKs.size() > 0) { + Map meterialMap = new HashMap(); + MaterialVO[] materialVOS = ((IMaterialBaseInfoQueryService)NCLocator.getInstance().lookup(IMaterialBaseInfoQueryService.class)).queryDataByPks((String[])meterialPKs.toArray(new String[0])); + meterialPKs.clear(); + + for(MaterialVO materialVO : materialVOS) { + meterialPKs.add(materialVO.getPk_source()); + meterialMap.put(materialVO.getPk_material(), materialVO.getPk_source()); + } + + Map map = ((IMaterialPubService)NCLocator.getInstance().lookup(IMaterialPubService.class)).queryMaterialBaseInfoByOidPks((String[])meterialPKs.toArray(new String[0]), new String[]{"pk_material"}); + + for(int i = 0; i < copyVo.getChildrenVO().length; ++i) { + IVApplicationBodyVO bodyVO = (IVApplicationBodyVO)copyVo.getChildrenVO()[i]; + if (bodyVO.getPk_materiel() != null) { + bodyVO.setPk_materiel(((MaterialVersionVO)map.get(meterialMap.get(bodyVO.getPk_materiel()))).getPk_material()); + } + } + } + + String cuserid = InvocationInfoProxy.getInstance().getUserId(); + UFDateTime currTime = new UFDateTime(InvocationInfoProxy.getInstance().getBizDateTime()); + UFDate currDate = currTime.getDate(); + headvo.setBillstatus(-1); + headvo.setPreparedate(currDate); + headvo.setCreator(cuserid); + headvo.setCreationtime(currTime); + headvo.setModifier(cuserid); + headvo.setModifiedtime(currTime); + headvo.setHzfp(UFBoolean.FALSE); + headvo.setCkfp(UFBoolean.FALSE); + headvo.setZffp(UFBoolean.FALSE); + headvo.setFpdm(""); + headvo.setFphm(""); + Integer paramValue = SysInitQuery.getParaInt(headvo.getPk_org(), "SSCIVA01"); + headvo.setKpfs(paramValue == null ? IVAplocationKPFS.ZLKP.toIntValue() : paramValue); + Map map = new HashMap(); + map.put(headvo.getPk_customer(), headvo.getPreparedate()); + Map idMap = ((ICustomerPubService)NCLocator.getInstance().lookup(ICustomerPubService.class)).getCustomerLastVIDByOidAndDate(map); + headvo.setPk_customer_v((String)idMap.get(headvo.getPk_customer())); + + for(int i = 0; i < copyVo.getChildrenVO().length; ++i) { + IVApplicationBodyVO bodyvo = (IVApplicationBodyVO)copyVo.getChildrenVO()[i]; + bodyvo.setStatus(2); + } + + return copyVo; + } + } else { + throw new BusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("1058sal_0", "01058sal-0031")); + } + } + + public boolean isFlowCheckman(String billId, String billType, String userId) throws BusinessException { + return IVSaleUtil.isCheckman(billId, billType, userId); + } + + public IVApplicationAggVO calHeadJe(IVApplicationAggVO vo) throws BusinessException { + UFDouble hjje = UFDouble.ZERO_DBL; + UFDouble hjse = UFDouble.ZERO_DBL; + UFDouble jshj = UFDouble.ZERO_DBL; + UFDouble can_hjje = UFDouble.ZERO_DBL; + UFDouble can_hjse = UFDouble.ZERO_DBL; + UFDouble can_jshj = UFDouble.ZERO_DBL; + + for(IVApplicationBodyVO bvo : vo.getBodyVOs()) { + if (bvo.getStatus() != 3) { + UFDouble xmje = bvo.getXmje() == null ? UFDouble.ZERO_DBL : bvo.getXmje(); + UFDouble se = bvo.getSe() == null ? UFDouble.ZERO_DBL : bvo.getSe(); + UFDouble xmjshj = bvo.getXmjshj() == null ? UFDouble.ZERO_DBL : bvo.getXmjshj(); + UFDouble can_xmje = bvo.getCaninvoice_xmje() == null ? UFDouble.ZERO_DBL : bvo.getCaninvoice_xmje(); + UFDouble can_se = bvo.getCaninvoice_se() == null ? UFDouble.ZERO_DBL : bvo.getCaninvoice_se(); + UFDouble can_xmjshj = bvo.getCaninvoice_xmjshj() == null ? UFDouble.ZERO_DBL : bvo.getCaninvoice_xmjshj(); + hjje = hjje.add(xmje); + hjse = hjse.add(se); + jshj = jshj.add(xmjshj); + can_hjje = can_hjje.add(can_xmje); + can_hjse = can_hjse.add(can_se); + can_jshj = can_jshj.add(can_xmjshj); + } + } + + IVApplicationHeadVO headvo = vo.getHeadVO(); + headvo.setHjje(hjje); + headvo.setHjse(hjse); + headvo.setJshj(jshj); + headvo.setCaninvoice_hjje(can_hjje); + headvo.setCaninvoice_hjse(can_hjse); + headvo.setCaninvoice_jshj(can_jshj); + return vo; + } +}