diff --git a/arap/src/private/nc/bs/arap/actions/GatheringbillEditSaveBatchBSAction.java b/arap/src/private/nc/bs/arap/actions/GatheringbillEditSaveBatchBSAction.java index 5bf8ae84..92e08e1f 100644 --- a/arap/src/private/nc/bs/arap/actions/GatheringbillEditSaveBatchBSAction.java +++ b/arap/src/private/nc/bs/arap/actions/GatheringbillEditSaveBatchBSAction.java @@ -22,89 +22,93 @@ 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); - this.validatorCode.remove(44); - } + 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); + this.validatorCode.remove(44); + } - protected void doBeforeUpdate(AggregatedValueObject[] bills, AggregatedValueObject[] orginBills) throws BusinessException { - ArapBillPubUtil.fillTradeTypeInfo(bills); + protected void doBeforeUpdate(AggregatedValueObject[] bills, AggregatedValueObject[] orginBills) + throws BusinessException { + ArapBillPubUtil.fillTradeTypeInfo(bills); - for(AggregatedValueObject bill : bills) { - ArapBillPubUtil.processMoneyOnlySum(bill); - } + for (AggregatedValueObject bill : bills) { + ArapBillPubUtil.processMoneyOnlySum(bill); + } - /** - * 收款单保存校验关联的销售订单实际收款金额是否超过价税合计 - */ - int i = 0; + /** + * տУ۶ʵտǷ񳬹˰ϼ + */ + 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 +"元,无法传输!请检查订单累计收款金额!】"); - } - } + 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); + ArapBillVOUtils.prepareDefaultInfo(bills, true); + BillDateUtils.setBillDateByNow(bills); + int updateType = this.getUpdateType(bills, orginBills); - for(AggregatedValueObject bill : bills) { - bill.getParentVO().setStatus(1); - } + 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) { + 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); - } + if (updateType == TEMP_2_SAVE || updateType == SAVE_2_SAVE) { + BillAccountCalendarUtils.setAccperiodYearMonth(bills); + } - this.checkIsCorrdBillMoneyControl(bills, orginBills); - this.checkOtherSystemBill(bills, orginBills); - (new CrossRuleCheckValidator()).validate(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 index 70c8334d..fd55a8b9 100644 --- a/arap/src/private/nc/bs/arap/actions/GatheringbillSaveBatchBSAction.java +++ b/arap/src/private/nc/bs/arap/actions/GatheringbillSaveBatchBSAction.java @@ -59,29 +59,29 @@ public class GatheringbillSaveBatchBSAction extends BillInsertBatchBSAction { ArapBillVOUtils.setDefaultSettleFlag(bills); /** - * 收款单保存校验关联的销售订单实际收款金额是否超过价税合计 + * տУ۶ʵտǷ񳬹˰ϼ */ for(AggregatedValueObject bill : bills) { - BaseBillVO billVO = (BaseBillVO) bill.getParentVO(); //修改的收款单 - UFDouble money = billVO.getMoney(); //金额 + 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 + String def3 = billVO.getDef3(); //տӦ۶id if(StringUtil.isEmpty(def3) || "N".equals(def3) || "~".equals(def3)){ - //无绑定的销售订单则下一次循环 + //ް󶨵۶һѭ continue; } - //根据销售订单id去查询销售订单 + //۶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()); @@ -89,7 +89,7 @@ public class GatheringbillSaveBatchBSAction extends BillInsertBatchBSAction { } UFDouble moreMoney = nreceivedmny.add(money).sub(ntotalorigmny); if(nreceivedmny.add(money).compareTo(ntotalorigmny) > 0){ - throw new BusinessException("【该笔收款已超销售订单"+ moreMoney +"元,无法传输!请检查订单累计收款金额!】"); + throw new BusinessException("ñտѳ۶"+ moreMoney +"Ԫ޷䣡鶩ۼտ"); } } } diff --git a/arap/src/public/nc/api/arap/resource/GatheringbillRestResource.java b/arap/src/public/nc/api/arap/resource/GatheringbillRestResource.java index a31a86bd..28fd1ffc 100644 --- a/arap/src/public/nc/api/arap/resource/GatheringbillRestResource.java +++ b/arap/src/public/nc/api/arap/resource/GatheringbillRestResource.java @@ -138,12 +138,12 @@ public class GatheringbillRestResource extends ArapBaseRestResource { Object tr = dao.executeQuery( "select ntaxrate from so_saleorder_b where csaleorderid = '" + csaleorderid + "'", new ColumnProcessor()); - ntaxrate = new UFDouble(tr.toString()); + //ntaxrate = new UFDouble(tr.toString()); // ˰ Object ctaxcodeid = hybo.findColValue("so_saleorder_b", "ctaxcodeid", "csaleorderid = '" + csaleorderid + "' "); Object tc = hybo.findColValue("bd_taxcode", "code", "pk_taxcode = '" + ctaxcodeid + "' "); - ctaxcode = tc.toString(); + ctaxcode = getString_TrimAsNull(tc); // ҵԱ Object cemployeeid = hybo.findColValue("so_saleorder", "cemployeeid", "csaleorderid = '" + csaleorderid + "' "); @@ -160,7 +160,10 @@ public class GatheringbillRestResource extends ArapBaseRestResource { } } // pk_currtype ֱ Ĭ - headvo.setPk_currtype("CNY"); + if (headvo.getPk_currtype() == null || headvo.getPk_currtype().isEmpty()) { + headvo.setPk_currtype("CNY"); + } + // accessorynum Ĭ2 headvo.setAccessorynum(2); // Ƶ ĬBIP @@ -237,8 +240,12 @@ public class GatheringbillRestResource extends ArapBaseRestResource { itemvo.setNotax_cr(notax_cr); // zhangxinah֯˰() itemvo.setLocal_notax_cr(notax_cr); - // - itemvo.setRate(UFDouble.ZERO_DBL); + // ΪʱĬΪ1 + if (headvo.getRate() == null) { + itemvo.setRate(UFDouble.ONE_DBL); + } else { + itemvo.setRate(headvo.getRate()); + } // itemvo.setTaxcodeid(ctaxcode); // @@ -246,7 +253,8 @@ public class GatheringbillRestResource extends ArapBaseRestResource { // ֧Ŀ itemvo.setPk_subjcode("201"); money = money.add(itemvo.getMoney_cr()); - itemvo.setLocal_money_cr(itemvo.getMoney_cr()); + itemvo.setLocal_money_cr( + itemvo.getMoney_cr().multiply(itemvo.getRate()).setScale(2, UFDouble.ROUND_HALF_UP)); Object def2 = itemvo.getDef2(); if (def2 != null) itemvo.setDef2(hybo.findColValue("bd_defdoc", "pk_defdoc", " code = '" + def2 + "' ") + ""); @@ -285,8 +293,8 @@ public class GatheringbillRestResource extends ArapBaseRestResource { headvo.setMoney(money); headvo.setGloballocal(money); - headvo.setRate(new UFDouble(1)); - headvo.setLocal_money(money); + // headvo.setRate(new UFDouble(1)); + headvo.setLocal_money(money.multiply(headvo.getRate()).setScale(2, UFDouble.ROUND_HALF_UP)); AggGatheringBillVO bill = new AggGatheringBillVO(); bill.setParentVO(headvo); bill.setChildrenVO((CircularlyAccessibleValueObject[]) itemvos.toArray(new GatheringBillItemVO[0])); @@ -769,4 +777,12 @@ public class GatheringbillRestResource extends ArapBaseRestResource { return ResultMessageUtil.exceptionToJSON(e); } } + + public static String getString_TrimAsNull(Object value) { + if ((value == null) || (value.toString().trim().length() == 0)) { + return ""; + } + return value.toString().trim(); + } + } diff --git a/cmp/src/client/nccloud/web/cmp/informer/informer/action/myBtnClickAction.java b/cmp/src/client/nccloud/web/cmp/informer/informer/action/myBtnClickAction.java index 64d07342..97bbb510 100644 --- a/cmp/src/client/nccloud/web/cmp/informer/informer/action/myBtnClickAction.java +++ b/cmp/src/client/nccloud/web/cmp/informer/informer/action/myBtnClickAction.java @@ -165,7 +165,7 @@ public class myBtnClickAction extends InformerAction implements ICommonAction { "ELSE '' " + "END as direction, 'CNY' as currencyCode,moneyy , bant.code as dfcode,bant.name as dfname,oppbankaccount,bankt.accnum dfaccnum " + ",pk_oppunit,org.code as orgcode,org.name as orgname,cmp.pk_informer " + - ",cmp.memo,cmp.transerial,df.name as ksmc,df.code as ksbm,cmp.note_no,def01,cmp.oppunitname " + + ",cmp.memo,cmp.transerial,df.name as ksmc,df.code as ksbm,cmp.note_no,vdef1,cmp.oppunitname " + "from cmp_informer cmp " + "left join bd_bankaccbas bank on cmp.pk_bankacc=bank.pk_bankaccbas " + "left join bd_bankdoc ban on cmp.pk_bank=ban.pk_bankdoc " + @@ -182,13 +182,13 @@ public class myBtnClickAction extends InformerAction implements ICommonAction { for (int i = 0; i < results.size(); i++) { Map vmao = new HashMap(); Map row = results.get(i); - String def01 = (String) row.get("def01"); - if ("".equals(def01)) { + String vdef1 = (String) row.get("vdef1"); + if ("".equals(vdef1)) { resultMap.put("flag", "false"); resultMap.put("message", "޷ٴ"); return resultMap; } - if ("".equals(def01)) { + if ("".equals(vdef1)) { vmao.put("publishStatus", "ٴη"); } else { vmao.put("publishStatus", ""); @@ -241,6 +241,7 @@ public class myBtnClickAction extends InformerAction implements ICommonAction { Map access_token = (Map) map.get("data"); String urls2 = urlpath + "/iuap-api-gateway/" + tenant + "/current_yonbip_default_sys/KKAPI/paymentNotice/addBatch?access_token=" + access_token.get("access_token"); Map mapjson = httpFW(urls2, jsonString1); + Logger.error("myBtnClickAction-jsonString1 = " + jsonString1); Logger.error("myBtnClickAction-mapjson = " + mapjson); if (!"200".equals(mapjson.getOrDefault("code", "") + "")) { throw new Exception(mapjson.getOrDefault("message", "ʧ") + ""); @@ -266,10 +267,10 @@ public class myBtnClickAction extends InformerAction implements ICommonAction { String pk_s = (String) pks.get(i); String sql1; if (successData != null && successData.contains(pk_s)) { - sql1 = "update cmp_informer set def01='' where pk_informer='" + pk_s + "'"; + sql1 = "update cmp_informer set vdef1='' where pk_informer='" + pk_s + "'"; sqlStr.add(sql1); } else { - sql1 = "update cmp_informer set def01='ʧ' where pk_informer='" + pk_s + "'"; + sql1 = "update cmp_informer set vdef1='ʧ' where pk_informer='" + pk_s + "'"; } sqlStr.add(sql1); diff --git a/purp/src/private/nc/impl/pp/supplierprice/rule/SupPriceQryRule.java b/purp/src/private/nc/impl/pp/supplierprice/rule/SupPriceQryRule.java index bcaed470..081dd3a2 100644 --- a/purp/src/private/nc/impl/pp/supplierprice/rule/SupPriceQryRule.java +++ b/purp/src/private/nc/impl/pp/supplierprice/rule/SupPriceQryRule.java @@ -82,7 +82,7 @@ public class SupPriceQryRule { return ""; } else { ConditionVO[] copyconvos = (ConditionVO[])CloneUtil.deepClone(convos); - + List list = new ArrayList(); for(ConditionVO vo : copyconvos) { if (vo.getFieldCode().equals(SupPriceRptConst.DBUSINESSDATE)) { int month = Integer.valueOf(vo.getValue()); @@ -91,17 +91,23 @@ public class SupPriceQryRule { vo.setFieldCode(htablealias + ".dbilldate"); vo.setOperaCode("between"); vo.setDataType(3); - String var10001 = befdate.toString(); - vo.setValue(var10001 + " ," + curdate.toString() + " "); + String befdateStr = befdate.toString(); + vo.setValue(befdateStr + " ," + curdate.toString() + " "); } else if (vo.getFieldCode().equals("pk_supplier")) { vo.setFieldCode(htablealias + ".cvendorid"); + } else if (vo.getFieldCode().equalsIgnoreCase("memo")) { + tranMap.put("memo", vo); } else { vo.setFieldCode(htablealias + "." + vo.getFieldCode()); } + if (!vo.getFieldCode().equalsIgnoreCase("memo")) { + list.add(vo); + } } StringBuilder sql = new StringBuilder(""); - sql.append((new ConditionVO()).getSQLStr(copyconvos)); + ConditionVO[] array = list.toArray(new ConditionVO[0]); + sql.append((new ConditionVO()).getSQLStr(array)); this.addMarWhere(sql, tranMap, rptutils, btablealias); return sql.toString(); } @@ -162,9 +168,11 @@ public class SupPriceQryRule { vo.setFieldCode(htablealias + ".dbilldate"); vo.setOperaCode("between"); vo.setDataType(3); - String var10001 = befdate.toString(); - vo.setValue(var10001 + " ," + curdate.toString() + " "); + String befdateStr = befdate.toString(); + vo.setValue(befdateStr + " ," + curdate.toString() + " "); list.add(vo); + } else if (vo.getFieldCode().equalsIgnoreCase("memo")) { + tranMap.put("memo", vo); } else if (!vo.getFieldCode().equals("bsc")) { vo.setFieldCode(htablealias + "." + vo.getFieldCode()); list.add(vo); @@ -184,7 +192,7 @@ public class SupPriceQryRule { return ""; } else { ConditionVO[] copyconvos = (ConditionVO[])CloneUtil.deepClone(convos); - + List list = new ArrayList(); for(ConditionVO vo : copyconvos) { if (vo.getFieldCode().equals(SupPriceRptConst.DBUSINESSDATE)) { int month = Integer.valueOf(vo.getValue()); @@ -193,19 +201,25 @@ public class SupPriceQryRule { vo.setFieldCode(tablealias + ".dvaliddate"); vo.setOperaCode("between"); vo.setDataType(3); - String var10001 = befdate.toString(); - vo.setValue(var10001 + " ," + curdate.toString() + " "); + String befdateStr = befdate.toString(); + vo.setValue(befdateStr + " ," + curdate.toString() + " "); } else if (vo.getDataType() == 3 && vo.getOperaCode().equalsIgnoreCase("=")) { UFDate date = new UFDate(vo.getValue()); vo.setValue(date.toLocalString()); vo.setFieldCode(tablealias + "." + vo.getFieldCode()); + } else if (vo.getFieldCode().equalsIgnoreCase("memo")) { + tranMap.put("memo", vo); } else { vo.setFieldCode(tablealias + "." + vo.getFieldCode()); } + if (!vo.getFieldCode().equalsIgnoreCase("memo")) { + list.add(vo); + } } StringBuilder sql = new StringBuilder(""); - sql.append((new ConditionVO()).getSQLStr(copyconvos)); + ConditionVO[] array = list.toArray(new ConditionVO[0]); + sql.append((new ConditionVO()).getSQLStr(array)); this.addMarWhere(sql, tranMap, rptutils, tablealias); return sql.toString(); } diff --git a/purp/src/public/nc/vo/pp/report/util/PurpRptUtils.java b/purp/src/public/nc/vo/pp/report/util/PurpRptUtils.java index fcfae47b..a0bdcaf0 100644 --- a/purp/src/public/nc/vo/pp/report/util/PurpRptUtils.java +++ b/purp/src/public/nc/vo/pp/report/util/PurpRptUtils.java @@ -5,8 +5,6 @@ package nc.vo.pp.report.util; -import java.util.HashMap; -import java.util.Map; import nc.bs.ic.icreport.pub.RPMetaDataUtil; import nc.bs.pubapp.report.ReportPermissionUtils; import nc.pub.smart.context.SmartContext; @@ -22,6 +20,9 @@ import nc.vo.pubapp.pattern.model.meta.entity.view.IDataViewMeta; import nc.vo.scmbd.pub.SCMESAPI; import nc.vo.scmpub.util.ArrayUtil; +import java.util.HashMap; +import java.util.Map; + /** * ¼۸ѯ * 20052312 @@ -58,9 +59,9 @@ public class PurpRptUtils { if (vos != null && vos.length > 0) { Object[][] datas = new Object[vos.length][fields.length]; - for(int i = 0; i < vos.length; ++i) { + for (int i = 0; i < vos.length; ++i) { if (vos[i] != null) { - for(int k = 0; k < fields.length; ++k) { + for (int k = 0; k < fields.length; ++k) { datas[i][k] = vos[i].getAttributeValue(fields[k]); } } @@ -96,7 +97,8 @@ public class PurpRptUtils { ConditionVO codeVO = this.getMarCondVO(tranMap, marcodeKey); ConditionVO nameVO = this.getMarCondVO(tranMap, marnameKey); ConditionVO classVO = this.getMarCondVO(tranMap, marclassKey); - if (null == codeVO && null == nameVO && null == classVO) { + boolean flag = tranMap.get("memo") == null; + if (null == codeVO && null == nameVO && null == classVO && flag) { return ""; } else { StringBuilder wheresql = new StringBuilder(); @@ -116,6 +118,11 @@ public class PurpRptUtils { wheresql.append(" and "); this.setMarWhere(classVO, "bd_material.pk_marbasclass", wheresql); } + if (!flag) { + ConditionVO memoVo = (ConditionVO) tranMap.get("memo"); + wheresql.append(" and "); + this.setMarWhere(memoVo, "bd_material.memo", wheresql); + } wheresql.append(" ) "); return wheresql.toString(); @@ -169,6 +176,9 @@ public class PurpRptUtils { } else if (condvo.getOperaCode().equals("left like")) { String value = condvo.getValue().replaceAll("\\(", "").replaceAll("\\)", ""); wheresql.append(field + " like '" + SCMESAPI.sqlEncodeGeneral(value) + "%' "); + } else if (condvo.getOperaCode().equals("like")) { + String value = condvo.getValue().replaceAll("\\(", "").replaceAll("\\)", ""); + wheresql.append(field + " like '%" + SCMESAPI.sqlEncodeGeneral(value) + "%' "); } } diff --git a/so/META-INF/SaleInv.rest b/so/META-INF/SaleInv.rest new file mode 100644 index 00000000..2376205a --- /dev/null +++ b/so/META-INF/SaleInv.rest @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/so/META-INF/saleinvoice.rest b/so/META-INF/saleinvoice.rest deleted file mode 100644 index 8e9487b8..00000000 --- a/so/META-INF/saleinvoice.rest +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/so/META-INF/saveCommit.rest b/so/META-INF/saveCommit.rest deleted file mode 100644 index 10db0a06..00000000 --- a/so/META-INF/saveCommit.rest +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/so/src/public/nccloud/api/so/saleinvoice/operator/BillSaveAction.java b/so/src/public/nccloud/api/so/saleinvoice/operator/BillSaveAction.java deleted file mode 100644 index 7b706c61..00000000 --- a/so/src/public/nccloud/api/so/saleinvoice/operator/BillSaveAction.java +++ /dev/null @@ -1,360 +0,0 @@ -package nccloud.api.so.saleinvoice.operator; - -import com.alibaba.fastjson.JSONObject; -import nc.bs.framework.common.NCLocator; -import nc.bs.framework.core.util.ObjectCreator; -import nc.bs.ia.audit.pub.CloneUtil; -import nc.bs.logging.Logger; -import nc.bs.trade.business.HYSuperDMO; -import nc.itf.uap.IUAPQueryBS; -import nc.pubitf.so.m32.api.ISaleinvoiceQueryAPI; -import nc.vo.pub.BusinessException; -import nc.vo.pub.lang.UFBoolean; -import nc.vo.pub.lang.UFDate; -import nc.vo.pub.lang.UFDouble; -import nc.vo.scmpub.res.billtype.SOBillType; -import nc.vo.so.m32.entity.SaleInvoiceBVO; -import nc.vo.so.m32.entity.SaleInvoiceHVO; -import nc.vo.so.m32.entity.SaleInvoiceVO; -import nc.vo.sscivm.ivsale.IVApplicationAggVO; -import nc.vo.sscivm.ivsale.IVApplicationBodyVO; -import nc.vo.sscivm.ivsale.IVApplicationHeadVO; -import nccloud.api.baseapp.exchange.convert.IExchangeForService; -import nccloud.api.baseapp.exchange.convert.OpenApiConvertDataObject; -import nccloud.api.baseapp.exchange.convert.OpenApiConvertDataResult; -import nccloud.api.rest.utils.ResultMessageUtil; -import nccloud.itf.sscivm.ivsale.impl.IVApplicationServiceImpl; -import nccloud.pubitf.riart.pflow.CloudPFlowContext; -import nccloud.pubitf.riart.pflow.ICloudScriptPFlowService; -import nccloud.ws.rest.resource.AbstractNCCRestResource; -import org.json.JSONString; - -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import java.util.List; - -/** - * ۷Ʊӿ - * - * @author lj - * @date 2025/03/14 - * @update 20250415 mzr޸ - */ -@Path("so/saleinvoice/operator") -public class BillSaveAction extends AbstractNCCRestResource { - - public static String fplxStr = "";// Ʊ뷢Ʊ - - public BillSaveAction() { - - } - - public OpenApiConvertDataResult changeToExchangeData(OpenApiConvertDataObject openApiConvertDataObject) - throws Exception { - return getPFxxEJBService().changeToExchangeData(openApiConvertDataObject); - } - - public static IExchangeForService getPFxxEJBService() { - IExchangeForService exchangeForService = (IExchangeForService) ObjectCreator.newInstance("ufesbexpress", - "nccloud.pubimpl.pfxx.convert.ExchangeForServiceImpl"); - return exchangeForService; - } - - @Override - public String getModule() { - return "so"; - } - - @POST - @Path("/billSaveRp") - @Consumes({"application/json"}) - @Produces({"application/json"}) - public JSONString billSaveRp(JSONString json) throws Exception { - /** - * ۷Ʊ壺 - * 1.bipе۷Ʊidѯerp۷ƱVO - * 2.ݲѯ۷ƱVOɺ۷Ʊ - */ - JSONObject jobject = JSONObject.parseObject(json.toJSONString()); - if (jobject == null) { - return ResultMessageUtil.exceptionToJSON(new NullPointerException("JSONString:null")); - } - JSONObject bject = jobject.getJSONObject("billhead"); - if (bject == null) { - return ResultMessageUtil.exceptionToJSON(new NullPointerException("billhead:null")); - } - // ۷Ʊid - String csaleinvoiceid = bject.getString("vdef40"); - // ۷Ʊʵidѯ۷Ʊ - String[] ids = {csaleinvoiceid}; - SaleInvoiceVO[] saleInvoiceVOs = NCLocator.getInstance().lookup(ISaleinvoiceQueryAPI.class) - .queryVOByIDs(ids); - if (saleInvoiceVOs == null || saleInvoiceVOs.length <= 0) { - return ResultMessageUtil.exceptionToJSON(new NullPointerException("δϵͳвѯӦ۷Ʊ")); - } - try { - // úԭ۷Ʊװº巢Ʊ - SaleInvoiceVO saleInvoiceRedRushVO = makeNewRedRushSaleInvoice(saleInvoiceVOs[0], bject); - // ɺ巢Ʊ - ICloudScriptPFlowService flowService = NCLocator.getInstance().lookup(ICloudScriptPFlowService.class); - CloudPFlowContext context = new CloudPFlowContext(); - context.setBillType("32"); - context.setBillVos(new SaleInvoiceVO[]{saleInvoiceRedRushVO}); - context.setActionName("WRITE"); - SaleInvoiceVO[] returnSaveSaleInvoiceVOs = (SaleInvoiceVO[]) flowService.exeScriptPFlow(context); -// SaleInvoiceVO[] returnSaveSaleInvoiceVO = (SaleInvoiceVO[])PfServiceScmUtil.processBatch("WRITE", SOBillType.Invoice.getCode(), new SaleInvoiceVO[] { saleInvoiceRedRushVO }, null, null); - if (returnSaveSaleInvoiceVOs != null && returnSaveSaleInvoiceVOs.length > 0) { - // ɺ巢Ʊɹִ۷Ʊ - context.setBillType("32"); - context.setBillVos(returnSaveSaleInvoiceVOs); - context.setActionName("APPROVE"); - SaleInvoiceVO[] returnApproveSaleInvoiceVOs = (SaleInvoiceVO[]) flowService.exeScriptPFlow(context); - if (returnApproveSaleInvoiceVOs == null || returnApproveSaleInvoiceVOs.length <= 0) { - throw new BusinessException("۷Ʊʧ"); - } - /** - * Ʊ߼ - * 1.۷ƱŲѯοƱ - * 2.ԭƱº - */ - String vBillcode = saleInvoiceVOs[0].getParentVO().getVbillcode(); - HYSuperDMO dmo = new HYSuperDMO(); - // Ʊ뵥 - IVApplicationHeadVO[] iVApplicationHeadVO = (IVApplicationHeadVO[]) dmo.queryByWhereClause(IVApplicationHeadVO.class, "src_billno='" + vBillcode + "' and dr=0 "); - String pk_ivapplication = iVApplicationHeadVO[0].getPk_ivapplication(); // Ʊid - // Ʊ뵥ӱ - IVApplicationBodyVO[] iVApplicationBodyVOs = (IVApplicationBodyVO[]) dmo.queryByWhereClause(IVApplicationBodyVO.class, "pk_ivapplication='" + pk_ivapplication + "' and dr=0 "); - // úװƱVO - IVApplicationAggVO iVApplicationAggVO = makeNewRedRushIVApplicationAggVO(iVApplicationHeadVO[0], iVApplicationBodyVOs, bject, returnApproveSaleInvoiceVOs); - // ɺĿƱ -// context.setBillType("SSCIVA"); -// context.setBillVos( new IVApplicationAggVO[] { iVApplicationAggVO }); -// context.setActionName("SAVE"); -// IVApplicationAggVO[] returnSaveIVApplicationAggVO = (IVApplicationAggVO[] )flowService.exeScriptPFlow(context); - IVApplicationServiceImpl serviceImpl = new IVApplicationServiceImpl(); - IVApplicationAggVO returnSaveIVApplicationAggVO = serviceImpl.save(iVApplicationAggVO); -// Object returnIVApplicationAggVO = PfServiceScmUtil.processBatch("SAVE", "SSCIVA", new IVApplicationAggVO[] { iVApplicationAggVO }, null, null); - if (returnSaveIVApplicationAggVO != null) { - return ResultMessageUtil.toJSON(returnApproveSaleInvoiceVOs, "ӿڵóɹ"); - } else { - Exception e = new Exception("ӿڵʧ"); - return ResultMessageUtil.exceptionToJSON(e); - } - } else { - Exception e = new Exception("ӿڵʧ"); - return ResultMessageUtil.exceptionToJSON(e); - } - } catch (Exception e) { - Logger.error("billSaveRp-exp: ", e); - return ResultMessageUtil.exceptionToJSON(e); - } - } - - /** - * 巢ƱVO - * - * @param originalVO - * @param bject - * @return - * @throws Exception - */ - public static SaleInvoiceVO makeNewRedRushSaleInvoice(SaleInvoiceVO originalVO, JSONObject bject) throws Exception { - try { - SaleInvoiceVO saleInvoiceVO = new SaleInvoiceVO(); - // Ʊʵ - SaleInvoiceHVO saleInvoiceHVO = originalVO.getParentVO(); - // Ʊʵ - SaleInvoiceBVO[] saleInvoiceBVOs = originalVO.getChildrenVO(); - // Ʊʵ - SaleInvoiceHVO newSaleInvoiceHVO = new SaleInvoiceHVO(); - - // - UFDate dbilldate = new UFDate(bject.getString("dbilldate")); - // Ƶ - UFDate dmakedate = new UFDate(bject.getString("creationtime")); - - // ʵԸֵ - UFDouble sumNum = new UFDouble(); // ϼ - UFDouble sumNtax = new UFDouble(); // ϼ˰ - UFDouble sumNcaltaxmny = new UFDouble(); // ϼƼ˰ - UFDouble sumNorigmny = new UFDouble(); // ϼ˰ - UFDouble sumNorigtaxmny = new UFDouble(); // ϼƼ˰ϼ - int i = 0; - // ʵ - com.alibaba.fastjson.JSONArray bvoJsonArr = (com.alibaba.fastjson.JSONArray) bject.get("csaleinvoicebid"); - List bvoList = bvoJsonArr.toJavaList(JSONObject.class); - SaleInvoiceBVO[] newSaleInvoiceBVOs = new SaleInvoiceBVO[bvoList.size()]; // ʵ - for (SaleInvoiceBVO saleInvoiceBVO : saleInvoiceBVOs) { - String csaleinvoicebid = saleInvoiceBVO.getCsaleinvoicebid(); // ӱid - // ɸѡӱ - List newBvoArr = bvoList.stream().filter(item -> { - String parCsaleinvoicebid = item.getString("vbdef15") + ""; // ӱid - return csaleinvoicebid.equals(parCsaleinvoicebid); - }).toList(); - if (newBvoArr.size() <= 0) { - continue; - } - JSONObject bipBvoJson = newBvoArr.get(0); // ӱ - SaleInvoiceBVO newInvBVO = new SaleInvoiceBVO(); - // ¡ȡֵԭӱ۷Ʊ - newInvBVO = (SaleInvoiceBVO) CloneUtil.depthClone(saleInvoiceBVO); - // ֵ֮޸ʵʱֶ - newInvBVO.setCsaleinvoicebid(null); // Ʊʵid - newInvBVO.setDbilldate(dbilldate); // Ʊ - newInvBVO.setNastnum(new UFDouble(bipBvoJson.getString("nastnum"))); // - newInvBVO.setNnum(new UFDouble(bipBvoJson.getString("nnum"))); // - newInvBVO.setNtax(new UFDouble(bipBvoJson.getString("ntax"))); // ˰ - newInvBVO.setNmny(new UFDouble(bipBvoJson.getString("nmny"))); // ˰ - newInvBVO.setNtaxmny(new UFDouble(bipBvoJson.getString("ntaxmny"))); // Ҽ˰ϼ - newInvBVO.setNcaltaxmny(new UFDouble(bipBvoJson.getString("ncaltaxmny"))); // ˰ - newInvBVO.setNorigmny(new UFDouble(bipBvoJson.getString("norigmny"))); // ˰ - newInvBVO.setNorigtaxmny(new UFDouble(bipBvoJson.getString("norigtaxmny"))); // ˰ϼ - newInvBVO.setCopposesrcbid(bipBvoJson.getString("vbdef15")); // ԳԴӱid - newInvBVO.setNqtunitnum(null); // - newInvBVO.setCsaleinvoiceid(null); // Ʊid - newInvBVO.setNtotalcostnum(null); // ۼƳɱ - newInvBVO.setNtotalincomemny(null); // ۼȷӦս - newInvBVO.setNtotalincomenum(null); // ۼȷӦ - newInvBVO.setVchangerate("1.00/1.00"); // - newSaleInvoiceBVOs[i++] = newInvBVO; - sumNum = sumNum.add(new UFDouble(bipBvoJson.getString("nnum"))); - sumNtax = sumNtax.add(new UFDouble(bipBvoJson.getString("ntax"))); - sumNcaltaxmny = sumNcaltaxmny.add(new UFDouble(bipBvoJson.getString("ncaltaxmny"))); - sumNorigmny = sumNorigmny.add(new UFDouble(bipBvoJson.getString("norigmny"))); - sumNorigtaxmny = sumNorigtaxmny.add(new UFDouble(bipBvoJson.getString("norigtaxmny"))); - } - - // ¡ȡֵԭӱ۷Ʊ - newSaleInvoiceHVO = (SaleInvoiceHVO) CloneUtil.depthClone(saleInvoiceHVO); - // ֵ֮޸ʵʱֶ - newSaleInvoiceHVO.setCsaleinvoiceid(null); // Ʊʵid - newSaleInvoiceHVO.setVbillcode(null); // Ʊ - newSaleInvoiceHVO.setDbilldate(dbilldate); // Ʊ - newSaleInvoiceHVO.setDmakedate(dmakedate); // Ƶ - newSaleInvoiceHVO.setBsubunitflag(UFBoolean.TRUE); // ֱ - newSaleInvoiceHVO.setFopposeflag(2); // Գ 2Գɣ - newSaleInvoiceHVO.setFstatusflag(1); // ״̬ 1̬ - newSaleInvoiceHVO.setNtotalastnum(null); // - newSaleInvoiceHVO.setNtotalorigsubmny(null); // ֽ - newSaleInvoiceHVO.setNtotalorigmny(null); // ˰ϼ - newSaleInvoiceHVO.setVopposesrccode(saleInvoiceHVO.getVbillcode()); // ԳԴƱ - newSaleInvoiceHVO.setCopposesrcid(saleInvoiceHVO.getCsaleinvoiceid()); // ԳԴƱid - newSaleInvoiceHVO.setApprover(null); // - newSaleInvoiceHVO.setTaudittime(null); // - - // װVO - saleInvoiceVO.setParentVO(newSaleInvoiceHVO); - saleInvoiceVO.setChildrenVO(newSaleInvoiceBVOs); - return saleInvoiceVO; - } catch (Exception e) { - throw new BusinessException(e.getMessage()); - } - } - - /** - * 忪ƱVO - * - * @param applyHeadVO ԭƱʵ - * @param ivApplicationBodyVOS ԭƱʵ - * @param bject bip - * @param returnApproveSaleInvoiceVOs ɵĺ۷Ʊʵ - * @return - * @throws Exception - */ - public static IVApplicationAggVO makeNewRedRushIVApplicationAggVO(IVApplicationHeadVO applyHeadVO, IVApplicationBodyVO[] ivApplicationBodyVOS, JSONObject bject, SaleInvoiceVO[] returnApproveSaleInvoiceVOs) throws Exception { - try { - IVApplicationAggVO applicationAggVO = new IVApplicationAggVO(); - IVApplicationHeadVO newivApplicationHeadVO = new IVApplicationHeadVO(); // ʵ - - // ȡɺ巢Ʊʵ - String csaleinvoiceid = returnApproveSaleInvoiceVOs[0].getParentVO().getCsaleinvoiceid(); - String[] ids = {csaleinvoiceid}; - SaleInvoiceVO[] rpSaleInvoiceVOs = NCLocator.getInstance().lookup(ISaleinvoiceQueryAPI.class) - .queryVOByIDs(ids); - SaleInvoiceHVO rpSaleInvoiceHVO = rpSaleInvoiceVOs[0].getParentVO(); - - // ʵԸֵ - // ¡ȡֵԭӱƱ - newivApplicationHeadVO = (IVApplicationHeadVO) CloneUtil.depthClone(applyHeadVO); - // ݲжǷΪֺ - boolean isPartHCFlag = false; - UFDouble paramNtotalorigmny = new UFDouble(bject.getString("ntotalorigmny")); // ˰ϼƣ - UFDouble ntotalorigmny = applyHeadVO.getJshj(); // ԭƱ˰ϼ - // 뿪ƱԴ˰ϼƱȽֵ㣬Ϊֺ - if (ntotalorigmny.add(paramNtotalorigmny).compareTo(UFDouble.ZERO_DBL) > 0) { - isPartHCFlag = true; - } - UFDouble sumXmsl = new UFDouble(); // ϼ - UFDouble sumXmje = new UFDouble(); // ϼƽ - UFDouble sumXmjshj = new UFDouble(); // ϼƼ˰ϼ - UFDouble sumBchcje = new UFDouble(); // ϼƱκ - UFDouble sumSe = new UFDouble(); // ϼ˰ - // ʵԸֵ - int i = 0; - // ʵ - com.alibaba.fastjson.JSONArray bvoJsonArr = (com.alibaba.fastjson.JSONArray) bject.get("csaleinvoicebid"); - List bvoList = bvoJsonArr.toJavaList(JSONObject.class); - IVApplicationBodyVO[] newivApplicationBodyVOS = new IVApplicationBodyVO[bvoList.size()]; // ʵ - for (IVApplicationBodyVO ivApplicationBodyVO : ivApplicationBodyVOS) { - String src_pkdetail = ivApplicationBodyVO.getSrc_pkdetail(); // Դid - // ɸѡӱ - List newBvoArr = bvoList.stream().filter(item -> { - String parCsaleinvoicebid = item.getString("vbdef15") + ""; // ӱid - return src_pkdetail.equals(parCsaleinvoicebid); - }).toList(); - if (newBvoArr.size() <= 0) { - continue; - } - JSONObject bipBvoJson = newBvoArr.get(0); // ӱ - IVApplicationBodyVO newivApplicationBodyVO = new IVApplicationBodyVO(); -// BeanUtil.copyProperties(ivApplicationBodyVO,newivApplicationBodyVO, CopyOptions.create().setIgnoreNullValue(true)); - // ¡ȡֵԭӱƱ - newivApplicationBodyVO = (IVApplicationBodyVO) CloneUtil.depthClone(ivApplicationBodyVO); - // ֵ֮޸ʵʱֶ - newivApplicationBodyVO.setPk_ivappdetail(null); // Ʊʵid - newivApplicationBodyVO.setBillno(null); // Ʊʵ嵥ݺ - newivApplicationBodyVO.setSe(new UFDouble(bipBvoJson.getString("ntax"))); // ˰ - newivApplicationBodyVO.setXmsl(new UFDouble(bipBvoJson.getString("nnum"))); // - newivApplicationBodyVO.setXmje(new UFDouble(bipBvoJson.getString("norigmny"))); // - newivApplicationBodyVO.setXmjshj(new UFDouble(bipBvoJson.getString("norigtaxmny"))); // ˰ϼ - // κ = β - newivApplicationBodyVO.setBchcje(new UFDouble(bipBvoJson.getString("norigtaxmny")).multiply(new UFDouble(-1))); - newivApplicationBodyVOS[i++] = newivApplicationBodyVO; - sumSe = sumSe.add(new UFDouble(bipBvoJson.getString("ntax"))); - sumXmsl = sumXmsl.add(new UFDouble(bipBvoJson.getString("nnum"))); - sumXmje = sumXmje.add(new UFDouble(bipBvoJson.getString("norigmny"))); - sumXmjshj = sumXmjshj.add(new UFDouble(bipBvoJson.getString("norigtaxmny"))); - sumBchcje = sumBchcje.add(new UFDouble(bipBvoJson.getString("norigtaxmny")).multiply(new UFDouble(-1))); - } - // ֵ֮޸ʵʱֶ - newivApplicationHeadVO.setPk_ivapplication(null); // Ʊ뵥ʵid - newivApplicationHeadVO.setBillno(null); // ݺ - newivApplicationHeadVO.setPreparedate(new UFDate(bject.getString("dbilldate"))); // - newivApplicationHeadVO.setJshj(sumXmjshj); // ˰ϼ - newivApplicationHeadVO.setHjje(sumXmje); // ϼƽ - newivApplicationHeadVO.setHjse(sumSe); // ϼ˰ - newivApplicationHeadVO.setBchcje(sumBchcje); // κ - newivApplicationHeadVO.setHzfp(UFBoolean.TRUE); // ַƱ - newivApplicationHeadVO.setSrc_billtype(SOBillType.Invoice.getCode()); // Դ - newivApplicationHeadVO.setSrc_tradetype(rpSaleInvoiceHVO.getCtrantypeid()); // Դ - newivApplicationHeadVO.setTranstypecode(rpSaleInvoiceHVO.getVtrantypecode()); // Դͱ - newivApplicationHeadVO.setSrc_pkbusibill(rpSaleInvoiceHVO.getCsaleinvoiceid()); // Դid - newivApplicationHeadVO.setSrc_billno(rpSaleInvoiceHVO.getVbillcode()); // Դݱ - newivApplicationHeadVO.setHcyy("2"); // ԭ2Ʊ - - // װVO - applicationAggVO.setParentVO(newivApplicationHeadVO); - applicationAggVO.setChildrenVO(newivApplicationBodyVOS); - return applicationAggVO; - } catch (Exception e) { - throw new BusinessException(e.getMessage()); - } - } - - public IUAPQueryBS getQueryService() { - return NCLocator.getInstance().lookup(IUAPQueryBS.class); - } - -} \ No newline at end of file diff --git a/so/src/public/nccloud/api/so/saleinvoice/operator/IAPISaleInvMaitainImpl.java b/so/src/public/nccloud/api/so/saleinvoice/operator/IAPISaleInvMaitainImpl.java new file mode 100644 index 00000000..855ee718 --- /dev/null +++ b/so/src/public/nccloud/api/so/saleinvoice/operator/IAPISaleInvMaitainImpl.java @@ -0,0 +1,667 @@ +package nccloud.api.so.saleinvoice.operator; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import nc.bs.framework.common.InvocationInfoProxy; +import nc.bs.framework.common.NCLocator; +import nc.bs.logging.Logger; +import nc.bs.trade.business.HYSuperDMO; +import nc.itf.uap.IUAPQueryBS; +import nc.jdbc.framework.processor.ColumnProcessor; +import nc.jdbc.framework.processor.MapProcessor; +import nc.pubitf.so.m32.api.ISaleinvoiceQueryAPI; +import nc.vo.pub.BusinessException; +import nc.vo.pub.lang.UFBoolean; +import nc.vo.pub.lang.UFDate; +import nc.vo.pub.lang.UFDouble; +import nc.vo.pubapp.calculator.HslParseUtil; +import nc.vo.pubapp.pattern.model.entity.bill.AbstractBill; +import nc.vo.pubapp.pattern.tool.performance.DeepCloneTool; +import nc.vo.pubapp.pflow.PfUserObject; +import nc.vo.scmpub.res.billtype.SOBillType; +import nc.vo.so.m32.entity.SaleInvoiceBVO; +import nc.vo.so.m32.entity.SaleInvoiceHVO; +import nc.vo.so.m32.entity.SaleInvoiceVO; +import nc.vo.sscivm.ivsale.IVApplicationAggVO; +import nc.vo.sscivm.ivsale.IVApplicationBodyVO; +import nc.vo.sscivm.ivsale.IVApplicationHeadVO; +import nccloud.api.baseapp.exchange.convert.OpenApiConvertDataObject; +import nccloud.api.baseapp.exchange.convert.OpenApiConvertDataResult; +import nccloud.api.rest.utils.ResultMessageUtil; +import nccloud.commons.lang.StringUtils; +import nccloud.dto.scmpub.script.entity.SCMScriptResultDTO; +import nccloud.itf.sscivm.ivsale.impl.IVApplicationServiceImpl; +import nccloud.pubitf.riart.pflow.CloudPFlowContext; +import nccloud.pubitf.riart.pflow.ICloudScriptPFlowService; +import nccloud.pubitf.scmpub.commit.service.IBatchRunScriptService; +import nccloud.pubitf.scmpub.ssc.service.ISSCService; +import nccloud.pubitf.so.saleinvoice.service.ISaleInvoiceToTaxInvService; +import nccloud.pubitf.ssctp.sscbd.lientage.ISSClientageMatchService; +import org.json.JSONString; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.List; +import java.util.Map; + +/** + * ۷Ʊӿڷʵ + * + * @author mzr + * @date 20250417 + */ +public class IAPISaleInvMaitainImpl { + + public static String fplxStr = "";// Ʊ뷢Ʊ + + public static DeepCloneTool deepCloneTool; + + public static DeepCloneTool getCloneTool() { + if (deepCloneTool == null) { + deepCloneTool = new DeepCloneTool(); + } + return deepCloneTool; + } + + public JSONString saveBlue(JSONObject jobject) throws Exception { + JSONObject ufinterfaceObj = jsonObjectAss(jobject); + String tsType = ufinterfaceObj.getString("tsType"); + if (tsType != null && tsType.equals("1")) { + Exception e = new NullPointerException("۶ѯʧܣ"); + return ResultMessageUtil.exceptionToJSON(e); + } + JSONObject bjects = ufinterfaceObj.getJSONObject("ufinterface"); + String billtype = bjects.getString("billtype"); + String account = bjects.getString("account"); + String omscode = bjects.getString("orgcode"); + String groupcode = bjects.getString("groupcode"); + + if (billtype != null && account != null && groupcode != null && "32".equals(billtype)) { + OpenApiConvertDataObject openApiconvertData0bject = new OpenApiConvertDataObject(); + openApiconvertData0bject.setAccount(account); + openApiconvertData0bject.setBilltype(billtype); + openApiconvertData0bject.setGroupcode(groupcode); + openApiconvertData0bject.setOpenApiJsonData(ufinterfaceObj); + + OpenApiJsonConvertToExChangeXmlService oService = new OpenApiJsonConvertToExChangeXmlService(); + OpenApiConvertDataResult r = oService.changeToExchangeData(openApiconvertData0bject); + JSONObject returnJson = r.getDesc(); + String content = ""; + // JSON + JSONObject ufinterface = returnJson.getJSONObject("ufinterface"); + if (ufinterface != null) { + JSONArray sendResultArray = ufinterface.getJSONArray("sendresult"); + if (sendResultArray != null && !sendResultArray.isEmpty()) { + // ȡ content ֶ + content = sendResultArray.getJSONObject(0).getString("content"); + } + } + if (content == null || content.equals("")) { + return r != null + ? ResultMessageUtil.toJSON(r.getDesc(), "0") + : ResultMessageUtil.exceptionToJSON(new NullPointerException("δ֪쳣")); + } + String[] ids = {content}; + SaleInvoiceVO[] saleInvoiceVO = NCLocator.getInstance().lookup(ISaleinvoiceQueryAPI.class) + .queryVOByIDs(ids); + SaleInvoiceVO saleInvoiceVO22 = saleInvoiceVO[0]; + SaleInvoiceHVO saleInvoiceHVO = saleInvoiceVO22.getParentVO(); + // ۷Ʊ˿ʼ + InvocationInfoProxy.getInstance().setUserId(saleInvoiceHVO.getApprover()); + CloudPFlowContext context = new CloudPFlowContext(); + context.setBillType("32"); + context.setBillVos(new SaleInvoiceVO[]{saleInvoiceVO[0]}); + ISSCService sscService = (ISSCService) NCLocator.getInstance().lookup(ISSCService.class); + String[] actionNames = sscService.isStartSSCWorkFlow( + (AbstractBill[]) ((AbstractBill[]) context.getBillVos()), ISSClientageMatchService.BusiUnitTypeEnum.SO); + context.setActionName("APPROVE"); + context.setTrantype("32-02"); + context.setBatch(false); + context.setBatchUserObj(new PfUserObject[]{new PfUserObject()}); + IBatchRunScriptService service = (IBatchRunScriptService) NCLocator.getInstance() + .lookup(IBatchRunScriptService.class); + SCMScriptResultDTO result = service.runBacth(context, SaleInvoiceVO.class); + // ۷Ʊ˽ + ISaleInvoiceToTaxInvService invoiceService = NCLocator.getInstance() + .lookup(ISaleInvoiceToTaxInvService.class); + // Ʊ(ֵ˰ר÷Ʊ)=31,Ʊ(ͨƱ)=32,ֽʷƱ(ͳһƱ)=36,ֽʷƱ(ֵ˰ר÷Ʊ)=33,ֽʷƱ(ͨƱ)=34, + // ֵ˰ͨƱ=1,ֵ˰ר÷Ʊ=2,ֵ˰ͨƱ=3,ֵ˰ר÷Ʊ=4,ֵ˰ͨƱƷͣ=8,ƷͨƱ(ʽ)=9, + // ƷͨƱ=10,Ʒר÷Ʊ=11,ֵ˰ͨƱ(ʽ)=12,ֵ˰ר÷Ʊ()=99 + invoiceService.issueTaxInvoice(saleInvoiceVO, fplxStr); + + JSONObject desc = r.getDesc(); + if (desc != null) { + // ƱȫϢظͬƽ̨ + desc.put("vos", saleInvoiceVO); + } + return ResultMessageUtil.toJSON(desc, "0"); + } else { + Exception e = new NullPointerException( + "billtype:" + billtype + ",account:" + account + ",groupcode:" + groupcode); + return ResultMessageUtil.exceptionToJSON(e); + } + } + + public JSONString saveRed(JSONObject jobject) throws Exception { + /** + * ۷Ʊ壺 + * 1.bipе۷Ʊidѯerp۷ƱVO + * 2.ݲѯ۷ƱVOɺ۷Ʊ + */ + JSONObject bject = jobject.getJSONObject("billhead"); + if (bject == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("billhead:null")); + } + // ۷Ʊid + String csaleinvoiceid = bject.getString("vdef40"); + // ۷Ʊʵidѯ۷Ʊ + String[] ids = {csaleinvoiceid}; + SaleInvoiceVO[] saleInvoiceVOs = NCLocator.getInstance().lookup(ISaleinvoiceQueryAPI.class) + .queryVOByIDs(ids); + if (saleInvoiceVOs == null || saleInvoiceVOs.length <= 0) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("δϵͳвѯӦ۷Ʊ")); + } + // úԭ۷Ʊװº巢Ʊ + SaleInvoiceVO saleInvoiceRedRushVO = makeNewRedRushSaleInvoice(saleInvoiceVOs[0], bject); + // ɺ巢Ʊ + ICloudScriptPFlowService flowService = NCLocator.getInstance().lookup(ICloudScriptPFlowService.class); + CloudPFlowContext context = new CloudPFlowContext(); + context.setBillType("32"); + context.setBillVos(new SaleInvoiceVO[]{saleInvoiceRedRushVO}); + context.setActionName("WRITE"); + SaleInvoiceVO[] returnSaveSaleInvoiceVOs = (SaleInvoiceVO[]) flowService.exeScriptPFlow(context); + Logger.error("=========================inv-save============== "); + if (returnSaveSaleInvoiceVOs != null && returnSaveSaleInvoiceVOs.length > 0) { + Logger.error("inv-save = " + JSONArray.toJSONString(returnSaveSaleInvoiceVOs)); + // ɺ巢Ʊɹִ۷Ʊ + context.setBillType("32"); + context.setBillVos(returnSaveSaleInvoiceVOs); + context.setActionName("APPROVE"); + SaleInvoiceVO[] returnApproveSaleInvoiceVOs = (SaleInvoiceVO[]) flowService.exeScriptPFlow(context); + if (returnApproveSaleInvoiceVOs == null || returnApproveSaleInvoiceVOs.length <= 0) { + throw new BusinessException("۷Ʊʧ"); + } + Logger.error("=========================inv-audit============== "); + Logger.error("inv-audit = " + JSONArray.toJSONString(returnApproveSaleInvoiceVOs)); + /** + * Ʊ߼ + * 1.۷ƱŲѯοƱ + * 2.ԭƱº + */ + String vBillcode = saleInvoiceVOs[0].getParentVO().getVbillcode(); + HYSuperDMO dmo = new HYSuperDMO(); + // Ʊ뵥 + IVApplicationHeadVO[] iVApplicationHeadVO = (IVApplicationHeadVO[]) dmo.queryByWhereClause(IVApplicationHeadVO.class, "src_billno='" + vBillcode + "' and dr=0 "); + String pk_ivapplication = iVApplicationHeadVO[0].getPk_ivapplication(); // Ʊid + // Ʊ뵥ӱ + IVApplicationBodyVO[] iVApplicationBodyVOs = (IVApplicationBodyVO[]) dmo.queryByWhereClause(IVApplicationBodyVO.class, "pk_ivapplication='" + pk_ivapplication + "' and dr=0 "); + // úװƱVO + IVApplicationAggVO iVApplicationAggVO = makeNewRedRushIVApplicationAggVO(iVApplicationHeadVO[0], iVApplicationBodyVOs, bject, returnApproveSaleInvoiceVOs); + // ɺĿƱ + IVApplicationServiceImpl serviceImpl = new IVApplicationServiceImpl(); + IVApplicationAggVO returnSaveIVApplicationAggVO = serviceImpl.save(iVApplicationAggVO); + if (returnSaveIVApplicationAggVO != null) { + return ResultMessageUtil.toJSON(returnApproveSaleInvoiceVOs, "ӿڵóɹ"); + } else { + Exception e = new Exception("ӿڵʧ"); + return ResultMessageUtil.exceptionToJSON(e); + } + } else { + Exception e = new Exception("ӿڵʧ"); + return ResultMessageUtil.exceptionToJSON(e); + } + } + + public static JSONObject jsonObjectAss(JSONObject originalJson) throws Exception { + try { + // Ŀ JSON ʽ + JSONObject resultJson = new JSONObject(); + // ufinterface ֶ + JSONObject ufinterface = new JSONObject(); + ufinterface.put("billtype", "32"); + ufinterface.put("sender", "BIP_NC"); + ufinterface.put("level", "0"); + ufinterface.put("replace", "Y"); + ufinterface.put("roottag", "bill"); + ufinterface.put("isexchange", "Y"); + ufinterface.put("account", "01"); + ufinterface.put("groupcode", "00"); + // bill + JSONArray billArray = new JSONArray(); + JSONObject bill = new JSONObject(); + // billhead ṹ + JSONObject billhead = new JSONObject(); + billhead = originalJson.getJSONObject("billhead");// JSON + billhead.put("pk_org_v", originalJson.getJSONObject("billhead").getString("pk_org"));// Ʊ֯汾=Ʊ֯ + billhead.put("pk_group", "00");// + fplxStr = originalJson.getJSONObject("billhead").getString("vdef22"); + billhead.put("vtrantypecode", "32-02");// Ʊͱ + billhead.put("cbiztypeid", "SO01");// ҵ + billhead.put("approver", "BIP");// + billhead.put("fstatusflag", 1);// ״̬ + billhead.put("billmaker", "BIP");// Ƶ + billhead.put("csendcountryid", "CN");// + billhead.put("crececountryid", "CN");// ջ + billhead.put("ctaxcountryid", "CN");// ˰ + // 2025-2-8ҵҪ޸ģݷƱQԶ嵵շƱ + String ctrantypeidStr = "32-02";// ĬͨƱ + if (fplxStr != null && fplxStr.equals("31")) { + ctrantypeidStr = "32-01";// Ʊ(ֵ˰ר÷Ʊ) + } else if (fplxStr != null && fplxStr.equals("32")) { + ctrantypeidStr = "32-02";// Ʊ(ͨƱ) + } else if (fplxStr != null && fplxStr.equals("36")) { + ctrantypeidStr = "32-Cxx-03";// ۷Ʊ + } + billhead.put("ctrantypeid", ctrantypeidStr);// Ʊ + // billhead.put("ctrantypeid", "32-02");//Ʊ + billhead.put("fbuysellflag", "1");// + billhead.put("creator", "BIP");// + billhead.put("ccurrencyid", "CNY");// λ + billhead.put("corigcurrencyid", "CNY");// + billhead.put("nexchangerate", 1);// ۱ + billhead.put("btriatradeflag", 0);// ó + JSONObject newItem = new JSONObject(); + JSONObject otherJson = new JSONObject(); + JSONArray csaleinvoicebid = new JSONArray(); + // ԭʼе csaleinvoicebid + for (int i = 0; i < originalJson.getJSONObject("billhead").getJSONArray("csaleinvoicebid").size(); i++) { + JSONObject item = originalJson.getJSONObject("billhead").getJSONArray("csaleinvoicebid") + .getJSONObject(i); + + JSONObject itemDetails = new JSONObject(); + itemDetails = item; + itemDetails.put("carorgid", originalJson.getJSONObject("billhead").getString("pk_org"));// Ӧ֯ + itemDetails.put("csendstockorgid", originalJson.getJSONObject("billhead").getString("pk_org"));// ֯ԭʼ汾 + itemDetails.put("cmaterialid", item.getString("cmaterialvid"));// ϱ + Map value2 = getSaleorderVo(item.getString("csrcbid")); + if (value2 == null) { + resultJson = new JSONObject(); + resultJson.put("tsType", "1"); + return resultJson; + } + itemDetails.put("vfirsttype", "30");// Դͷ + itemDetails.put("vfirstcode", value2.get("vbillcode"));// Դͷݺ + itemDetails.put("blargessflag", value2.get("blargessflag"));// Ʒ + itemDetails.put("vfirsttrantype", "30-01");// Դͷ + itemDetails.put("vfirstrowno", value2.get("crowno"));// Դͷк + itemDetails.put("cfirstid", item.getString("csrcid"));// Դͷ + itemDetails.put("cfirstbid", item.getString("csrcbid"));// Դͷӱ + itemDetails.put("vsrctype", "30");// Դ + itemDetails.put("vsrccode", value2.get("vbillcode"));// Դݺ + itemDetails.put("vsrctrantype", "30-01");// Դ + itemDetails.put("vsrcrowno", value2.get("crowno"));// Դк + // ͨ ntaxrate ȡ taxcode + String taxcodeStr = getTaxcode(item.getString("ntaxrate")); + // taxcodeStr bodyMap + itemDetails.put("ctaxcodeid", taxcodeStr);// ˰ + itemDetails.put("nnum", item.getString("nastnum"));// + itemDetails.put("ftaxtypeflag", 1);// ˰ + itemDetails.put("pk_group", "00");// + itemDetails.put("pk_org", originalJson.getJSONObject("billhead").getString("pk_org"));// Ʊ֯ + itemDetails.put("cunitid", item.getString("castunitid"));// λ + itemDetails.put("vchangerate", value2.getOrDefault("vchangerate", "1/1") + "");// + + // ۶лȡ + String currencycode = getString_TrimAsNull(value2.get("currencycode")); + otherJson.put("corigcurrencyid", currencycode.isEmpty() ? "CNY" : currencycode); + // ۶лȡ۱ + BigDecimal nexchangerate = getUFDouble_NullAsZero(value2.get("nexchangerate")).toBigDecimal(); + otherJson.put("nexchangerate", nexchangerate); + + // item ȡֶ + BigDecimal nastnum = new BigDecimal(item.getString("nastnum")); // + nastnum = nastnum.setScale(4, RoundingMode.HALF_UP); + BigDecimal nqtorigtaxprice = new BigDecimal(item.getString("nqtorigtaxprice")); // ˰ + nqtorigtaxprice = nqtorigtaxprice.setScale(4, RoundingMode.HALF_UP); + BigDecimal ntaxrate = new BigDecimal(item.getString("ntaxrate")).divide(new BigDecimal("100")); // ˰ + ntaxrate = ntaxrate.setScale(4, RoundingMode.HALF_UP); + + // ˰ + BigDecimal norigtaxnetprice = nqtorigtaxprice; + // 1. ˰ϼƣ˰ + BigDecimal norigtaxmny = nastnum.multiply(norigtaxnetprice).setScale(2, RoundingMode.HALF_UP); + // 2. ۿ۶ + BigDecimal discountAmount = nastnum.multiply(nqtorigtaxprice).subtract(norigtaxmny).setScale(4, + RoundingMode.HALF_UP); + // 3. ˰ַӦ˰˰Ӧ˰ں˰ + BigDecimal ntax = norigtaxmny.multiply(ntaxrate).divide(BigDecimal.ONE.add(ntaxrate), 2, + RoundingMode.HALF_UP); // Ӧ˰˰ + BigDecimal taxInclusiveInner = norigtaxmny.multiply(ntaxrate).setScale(4, RoundingMode.HALF_UP); // Ӧ˰ں˰ + // 4. ˰ + BigDecimal norigmny = norigtaxmny.subtract(ntax).setScale(2, RoundingMode.HALF_UP); + // 4. ˰ۣnqtorigprice = ˰ / + BigDecimal nqtorigprice = norigmny.divide(nastnum, 4, RoundingMode.HALF_UP); + // ˰ = ˰ + BigDecimal ncaltaxmny = norigmny; + // ˰ۣ˰ۣ + BigDecimal norigtaxprice = nqtorigtaxprice.setScale(4, RoundingMode.HALF_UP); + // ˰ۣ˰ۣ + BigDecimal norignetprice = nqtorigprice; + + // ()ҪʣλС۱4λС + // ˰ + BigDecimal nmny = norigmny.multiply(nexchangerate).setScale(2, RoundingMode.HALF_UP); + // ˰ + BigDecimal nnetprice = norignetprice.multiply(nexchangerate).setScale(4, RoundingMode.HALF_UP); + // Ҽ˰ϼ ˰ϼ* + BigDecimal ntaxmny = norigtaxmny.multiply(nexchangerate).setScale(2, RoundingMode.HALF_UP); + // ˰ + ntax = ntaxmny.subtract(nmny).setScale(2, RoundingMode.HALF_UP); + + itemDetails.put("nqtorigprice", nqtorigprice);// ˰ + itemDetails.put("norigprice", nqtorigprice);// ˰ + itemDetails.put("norigmny", norigmny);// ˰ + itemDetails.put("nmny", nmny);// ˰ + itemDetails.put("norigtaxmny", norigtaxmny);// ˰ϼ + itemDetails.put("norigtaxprice", norigtaxprice);// ˰ + itemDetails.put("norignetprice", norignetprice);// ˰ + itemDetails.put("nqtorigtaxprice", nqtorigtaxprice);// ˰ + itemDetails.put("ntax", ntax);// ˰ + itemDetails.put("ncaltaxmny", ncaltaxmny);// ˰ + itemDetails.put("norigtaxnetprice", norigtaxnetprice);// ˰ + itemDetails.put("nnetprice", nnetprice);// ˰ + itemDetails.put("ntaxmny", ntaxmny);// Ҽ˰ϼ + csaleinvoicebid.add(itemDetails); + + } + newItem.put("item", csaleinvoicebid); + billhead.put("csaleinvoicebid", newItem); + if (otherJson != null && !otherJson.isEmpty()) { + // ѯ۶еıֺͻ + billhead.put("corigcurrencyid", otherJson.get("corigcurrencyid"));// + billhead.put("nexchangerate", otherJson.get("nexchangerate"));// ۱ + } + bill.put("billhead", billhead); + bill.put("id", ""); + // bill ӵ ufinterface + billArray.add(bill); + ufinterface.put("bill", billArray); + // ufinterface ӵյ resultJson + resultJson.put("ufinterface", ufinterface); + return resultJson; + } catch (Exception e) { + return (JSONObject) ResultMessageUtil.exceptionToJSON(e); + } + } + + private static String getTaxcode(String taxrateStr) throws BusinessException { + IUAPQueryBS queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class); + String sql = " select code FROM bd_taxrate tt inner join bd_taxcode tc on tt.pk_taxcode=tc.pk_taxcode where taxrate='" + + taxrateStr + "' AND ROWNUM = 1 "; + String taxcodeStr = (String) queryBS.executeQuery(sql, new ColumnProcessor()); + return taxcodeStr; + } + + private static Map getSaleorderVo(String csourcebillbidStr) throws BusinessException { + IUAPQueryBS queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class); + String sql = " select s.vbillcode,s.csaleorderid, s.corigcurrencyid," + + " sb.csaleorderbid,sb.crowno,sb.blargessflag,sb.nexchangerate,sb.vchangerate," + + " bdc.code currencycode" + + " from so_saleorder_b sb" + + " inner join so_saleorder s on sb.csaleorderid=s.csaleorderid" + + " left join bd_currtype bdc on s.corigcurrencyid=bdc.pk_currtype" + + " where sb.csaleorderbid='" + csourcebillbidStr + "' "; + Map value2 = (Map) queryBS.executeQuery(sql, new MapProcessor()); + return value2; + } + + private static String getString_TrimAsNull(Object value) { + if ((value == null) || (value.toString().trim().isEmpty())) { + return ""; + } + return value.toString().trim(); + } + + private static UFDouble getUFDouble_NullAsZero(Object value) { + if ((value == null) || (value.toString().trim().isEmpty()) || (value.toString().trim().equals("~"))) + return UFDouble.ONE_DBL; + if ((value instanceof UFDouble)) + return (UFDouble) value; + if ((value instanceof BigDecimal)) { + return new UFDouble((BigDecimal) value); + } + return new UFDouble(value.toString().trim()); + } + + /** + * 巢ƱVO + * + * @param originalVO + * @param bject + * @return + * @throws Exception + */ + public static SaleInvoiceVO makeNewRedRushSaleInvoice(SaleInvoiceVO originalVO, JSONObject bject) throws Exception { + try { + SaleInvoiceVO saleInvoiceVO = new SaleInvoiceVO(); + // Ʊʵ + SaleInvoiceHVO saleInvoiceHVO = originalVO.getParentVO(); + // Ʊʵ + SaleInvoiceBVO[] saleInvoiceBVOs = originalVO.getChildrenVO(); + // Ʊʵ + SaleInvoiceHVO newSaleInvoiceHVO = new SaleInvoiceHVO(); + + // + UFDate dbilldate = new UFDate(bject.getString("dbilldate")); + // Ƶ + UFDate dmakedate = new UFDate(bject.getString("creationtime")); + + // ʵԸֵ + UFDouble sumNum = new UFDouble(); // ϼ + UFDouble sumNtax = new UFDouble(); // ϼ˰ + UFDouble sumNcaltaxmny = new UFDouble(); // ϼƼ˰ + UFDouble sumNorigmny = new UFDouble(); // ϼ˰ + UFDouble sumNorigtaxmny = new UFDouble(); // ϼƼ˰ϼ + int i = 0; + // ʵ + com.alibaba.fastjson.JSONArray bvoJsonArr = (com.alibaba.fastjson.JSONArray) bject.get("csaleinvoicebid"); + List bvoList = bvoJsonArr.toJavaList(JSONObject.class); + SaleInvoiceBVO[] newSaleInvoiceBVOs = new SaleInvoiceBVO[bvoList.size()]; // ʵ + for (SaleInvoiceBVO saleInvoiceBVO : saleInvoiceBVOs) { + String csaleinvoicebid = saleInvoiceBVO.getCsaleinvoicebid(); // ӱid + // ɸѡӱ + List newBvoArr = bvoList.stream().filter(item -> { + String parCsaleinvoicebid = item.getString("vbdef15") + ""; // ӱid + return csaleinvoicebid.equals(parCsaleinvoicebid); + }).toList(); + if (newBvoArr.size() <= 0) { + continue; + } + JSONObject bipBvoJson = newBvoArr.get(0); // ӱ + SaleInvoiceBVO newInvBVO = new SaleInvoiceBVO(); + // ¡ȡֵԭӱ۷Ʊ + newInvBVO = (SaleInvoiceBVO) getCloneTool().deepClone(saleInvoiceBVO); + // ֵ֮޸ʵʱֶ + newInvBVO.setCsaleinvoicebid(null); // Ʊʵid + newInvBVO.setDbilldate(dbilldate); // Ʊ + String vchangerate = "1/1"; // + Map soMap = getSaleOrderInfo(bipBvoJson.getString("csrcbid")); + if (soMap != null && StringUtils.isNotEmpty(soMap.getOrDefault("vchangerate", "") + "")) { + vchangerate = soMap.get("vchangerate") + ""; // ۶Ļ + } + newInvBVO.setVchangerate(vchangerate); // + UFDouble[] vchangerateNums = HslParseUtil.parseHsl(vchangerate); + UFDouble vchangerateNum = UFDouble.ONE_DBL; + if (null != vchangerateNums && vchangerateNums.length != 0) { + vchangerateNum = vchangerateNums[0].div(vchangerateNums[1]).setScale(2, 4); + } + // BIPͬƽ̨ӦBIP2312BIP2312 =*ϵ + UFDouble nastnum = new UFDouble(bipBvoJson.getString("nastnum")); + newInvBVO.setNastnum(nastnum.multiply(vchangerateNum).setScale(2, 4)); // + newInvBVO.setNnum(nastnum); // + newInvBVO.setNqtorigtaxprice(new UFDouble(bipBvoJson.getString("nqtorigtaxprice"))); // ˰ + newInvBVO.setNqtorigprice(new UFDouble(bipBvoJson.getString("nqtorigprice"))); // ˰ + newInvBVO.setNorigtaxprice(new UFDouble(bipBvoJson.getString("norigtaxprice"))); // ˰ + newInvBVO.setNorigprice(new UFDouble(bipBvoJson.getString("norigprice"))); // ˰ + newInvBVO.setNorigtaxnetprice(new UFDouble(bipBvoJson.getString("norigtaxnetprice"))); // ˰ + newInvBVO.setNorignetprice(new UFDouble(bipBvoJson.getString("norignetprice"))); // ˰ + newInvBVO.setNqtorigtaxnetprc(new UFDouble(bipBvoJson.getString("nqtorigtaxnetprc"))); // ˰ + newInvBVO.setNqtorignetprice(new UFDouble(bipBvoJson.getString("nqtorignetprice"))); // ˰ + newInvBVO.setNtaxprice(new UFDouble(bipBvoJson.getString("ntaxprice"))); // Һ˰ + newInvBVO.setNprice(new UFDouble(bipBvoJson.getString("nprice"))); // ˰ + newInvBVO.setNtaxnetprice(new UFDouble(bipBvoJson.getString("ntaxnetprice"))); // Һ˰ + newInvBVO.setNnetprice(new UFDouble(bipBvoJson.getString("nnetprice"))); // ˰ + newInvBVO.setNqttaxprice(new UFDouble(bipBvoJson.getString("nqttaxprice"))); // Һ˰ + newInvBVO.setNqtprice(new UFDouble(bipBvoJson.getString("nqtprice"))); // ˰ + newInvBVO.setNqttaxnetprice(new UFDouble(bipBvoJson.getString("nqttaxnetprice"))); // Һ˰ + newInvBVO.setNqtnetprice(new UFDouble(bipBvoJson.getString("nqtnetprice"))); // ˰ + newInvBVO.setNtax(new UFDouble(bipBvoJson.getString("ntax"))); // ˰ + newInvBVO.setNorigmny(new UFDouble(bipBvoJson.getString("norigmny"))); // ˰ + newInvBVO.setNorigtaxmny(new UFDouble(bipBvoJson.getString("norigtaxmny"))); // ˰ϼ + newInvBVO.setNmny(new UFDouble(bipBvoJson.getString("nmny"))); // ˰ + newInvBVO.setNtaxmny(new UFDouble(bipBvoJson.getString("ntaxmny"))); // Ҽ˰ϼ + newInvBVO.setNcaltaxmny(new UFDouble(bipBvoJson.getString("nmny"))); // ˰=˰ + newInvBVO.setCopposesrcbid(bipBvoJson.getString("vbdef15")); // ԳԴӱid + newInvBVO.setNqtunitnum(null); // + newInvBVO.setCsaleinvoiceid(null); // Ʊid + newInvBVO.setNtotalcostnum(null); // ۼƳɱ + newInvBVO.setNtotalincomemny(null); // ۼȷӦս + newInvBVO.setNtotalincomenum(null); // ۼȷӦ + newSaleInvoiceBVOs[i++] = newInvBVO; + sumNum = sumNum.add(new UFDouble(bipBvoJson.getString("nnum"))); + sumNtax = sumNtax.add(new UFDouble(bipBvoJson.getString("ntax"))); + sumNcaltaxmny = sumNcaltaxmny.add(new UFDouble(bipBvoJson.getString("ncaltaxmny"))); + sumNorigmny = sumNorigmny.add(new UFDouble(bipBvoJson.getString("norigmny"))); + sumNorigtaxmny = sumNorigtaxmny.add(new UFDouble(bipBvoJson.getString("norigtaxmny"))); + } + + // ¡ȡֵԭӱ۷Ʊ + newSaleInvoiceHVO = (SaleInvoiceHVO) getCloneTool().deepClone(saleInvoiceHVO); + // ֵ֮޸ʵʱֶ + newSaleInvoiceHVO.setCsaleinvoiceid(null); // Ʊʵid + newSaleInvoiceHVO.setVbillcode(null); // Ʊ + newSaleInvoiceHVO.setDbilldate(dbilldate); // Ʊ + newSaleInvoiceHVO.setDmakedate(dmakedate); // Ƶ + newSaleInvoiceHVO.setBsubunitflag(UFBoolean.TRUE); // ֱ + newSaleInvoiceHVO.setFopposeflag(2); // Գ 2Գɣ + newSaleInvoiceHVO.setFstatusflag(1); // ״̬ 1̬ + newSaleInvoiceHVO.setNtotalastnum(null); // + newSaleInvoiceHVO.setNtotalorigsubmny(null); // ֽ + newSaleInvoiceHVO.setNtotalorigmny(null); // ˰ϼ + newSaleInvoiceHVO.setVopposesrccode(saleInvoiceHVO.getVbillcode()); // ԳԴƱ + newSaleInvoiceHVO.setCopposesrcid(saleInvoiceHVO.getCsaleinvoiceid()); // ԳԴƱid + newSaleInvoiceHVO.setApprover(null); // + newSaleInvoiceHVO.setTaudittime(null); // + + // װVO + saleInvoiceVO.setParentVO(newSaleInvoiceHVO); + saleInvoiceVO.setChildrenVO(newSaleInvoiceBVOs); + return saleInvoiceVO; + } catch (Exception e) { + throw new BusinessException(e.getMessage()); + } + } + + /** + * 忪ƱVO + * + * @param applyHeadVO ԭƱʵ + * @param ivApplicationBodyVOS ԭƱʵ + * @param bject bip + * @param returnApproveSaleInvoiceVOs ɵĺ۷Ʊʵ + * @return + * @throws Exception + */ + public static IVApplicationAggVO makeNewRedRushIVApplicationAggVO(IVApplicationHeadVO applyHeadVO, IVApplicationBodyVO[] ivApplicationBodyVOS, JSONObject bject, SaleInvoiceVO[] returnApproveSaleInvoiceVOs) throws Exception { + try { + IVApplicationAggVO applicationAggVO = new IVApplicationAggVO(); + IVApplicationHeadVO newivApplicationHeadVO = new IVApplicationHeadVO(); // ʵ + + // ȡɺ巢Ʊʵ + String csaleinvoiceid = returnApproveSaleInvoiceVOs[0].getParentVO().getCsaleinvoiceid(); + String[] ids = {csaleinvoiceid}; + SaleInvoiceVO[] rpSaleInvoiceVOs = NCLocator.getInstance().lookup(ISaleinvoiceQueryAPI.class) + .queryVOByIDs(ids); + SaleInvoiceHVO rpSaleInvoiceHVO = rpSaleInvoiceVOs[0].getParentVO(); + + // ʵԸֵ + // ¡ȡֵԭӱƱ + newivApplicationHeadVO = (IVApplicationHeadVO) getCloneTool().deepClone(applyHeadVO); + // ݲжǷΪֺ + boolean isPartHCFlag = false; + UFDouble paramNtotalorigmny = new UFDouble(bject.getString("ntotalorigmny")); // ˰ϼƣ + UFDouble ntotalorigmny = applyHeadVO.getJshj(); // ԭƱ˰ϼ + // 뿪ƱԴ˰ϼƱȽֵ㣬Ϊֺ + if (ntotalorigmny.add(paramNtotalorigmny).compareTo(UFDouble.ZERO_DBL) > 0) { + isPartHCFlag = true; + } + UFDouble sumXmsl = new UFDouble(); // ϼ + UFDouble sumXmje = new UFDouble(); // ϼƽ + UFDouble sumXmjshj = new UFDouble(); // ϼƼ˰ϼ + UFDouble sumBchcje = new UFDouble(); // ϼƱκ + UFDouble sumSe = new UFDouble(); // ϼ˰ + // ʵԸֵ + int i = 0; + // ʵ + com.alibaba.fastjson.JSONArray bvoJsonArr = (com.alibaba.fastjson.JSONArray) bject.get("csaleinvoicebid"); + List bvoList = bvoJsonArr.toJavaList(JSONObject.class); + IVApplicationBodyVO[] newivApplicationBodyVOS = new IVApplicationBodyVO[bvoList.size()]; // ʵ + for (IVApplicationBodyVO ivApplicationBodyVO : ivApplicationBodyVOS) { + String src_pkdetail = ivApplicationBodyVO.getSrc_pkdetail(); // Դid + // ɸѡӱ + List newBvoArr = bvoList.stream().filter(item -> { + String parCsaleinvoicebid = item.getString("vbdef15") + ""; // ӱid + return src_pkdetail.equals(parCsaleinvoicebid); + }).toList(); + if (newBvoArr.size() <= 0) { + continue; + } + JSONObject bipBvoJson = newBvoArr.get(0); // ӱ + IVApplicationBodyVO newivApplicationBodyVO = new IVApplicationBodyVO(); +// BeanUtil.copyProperties(ivApplicationBodyVO,newivApplicationBodyVO, CopyOptions.create().setIgnoreNullValue(true)); + // ¡ȡֵԭӱƱ + newivApplicationBodyVO = (IVApplicationBodyVO) getCloneTool().deepClone(ivApplicationBodyVO); + // ֵ֮޸ʵʱֶ + newivApplicationBodyVO.setPk_ivappdetail(null); // Ʊʵid + newivApplicationBodyVO.setBillno(null); // Ʊʵ嵥ݺ + newivApplicationBodyVO.setSe(new UFDouble(bipBvoJson.getString("ntax"))); // ˰ + newivApplicationBodyVO.setXmsl(new UFDouble(bipBvoJson.getString("nnum"))); // + newivApplicationBodyVO.setXmje(new UFDouble(bipBvoJson.getString("norigmny"))); // + newivApplicationBodyVO.setXmjshj(new UFDouble(bipBvoJson.getString("norigtaxmny"))); // ˰ϼ + // κ = β + newivApplicationBodyVO.setBchcje(new UFDouble(bipBvoJson.getString("norigtaxmny")).multiply(new UFDouble(-1))); + newivApplicationBodyVOS[i++] = newivApplicationBodyVO; + sumSe = sumSe.add(new UFDouble(bipBvoJson.getString("ntax"))); + sumXmsl = sumXmsl.add(new UFDouble(bipBvoJson.getString("nnum"))); + sumXmje = sumXmje.add(new UFDouble(bipBvoJson.getString("norigmny"))); + sumXmjshj = sumXmjshj.add(new UFDouble(bipBvoJson.getString("norigtaxmny"))); + sumBchcje = sumBchcje.add(new UFDouble(bipBvoJson.getString("norigtaxmny")).multiply(new UFDouble(-1))); + } + // ֵ֮޸ʵʱֶ + newivApplicationHeadVO.setPk_ivapplication(null); // Ʊ뵥ʵid + newivApplicationHeadVO.setBillno(null); // ݺ + newivApplicationHeadVO.setPreparedate(new UFDate(bject.getString("dbilldate"))); // + newivApplicationHeadVO.setJshj(sumXmjshj); // ˰ϼ + newivApplicationHeadVO.setHjje(sumXmje); // ϼƽ + newivApplicationHeadVO.setHjse(sumSe); // ϼ˰ + newivApplicationHeadVO.setBchcje(sumBchcje); // κ + newivApplicationHeadVO.setHzfp(UFBoolean.TRUE); // ַƱ + newivApplicationHeadVO.setSrc_billtype(SOBillType.Invoice.getCode()); // Դ + newivApplicationHeadVO.setSrc_tradetype(rpSaleInvoiceHVO.getCtrantypeid()); // Դ + newivApplicationHeadVO.setTranstypecode(rpSaleInvoiceHVO.getVtrantypecode()); // Դͱ + newivApplicationHeadVO.setSrc_pkbusibill(rpSaleInvoiceHVO.getCsaleinvoiceid()); // Դid + newivApplicationHeadVO.setSrc_billno(rpSaleInvoiceHVO.getVbillcode()); // Դݱ + newivApplicationHeadVO.setHcyy("2"); // ԭ2Ʊ + + // װVO + applicationAggVO.setParentVO(newivApplicationHeadVO); + applicationAggVO.setChildrenVO(newivApplicationBodyVOS); + return applicationAggVO; + } catch (Exception e) { + throw new BusinessException(e.getMessage()); + } + } + + private static Map getSaleOrderInfo(String csaleorderbid) throws BusinessException { + IUAPQueryBS queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class); + String sql = " select s.vbillcode,s.csaleorderid, s.corigcurrencyid," + + " sb.csaleorderbid,sb.crowno,sb.blargessflag,sb.nexchangerate," + + " nvl(sb.vchangerate, '1/1') vchangerate, bdc.code currencycode" + + " from so_saleorder_b sb" + + " inner join so_saleorder s on sb.csaleorderid=s.csaleorderid" + + " left join bd_currtype bdc on s.corigcurrencyid=bdc.pk_currtype" + + " where sb.csaleorderbid='" + csaleorderbid + "' "; + return (Map) queryBS.executeQuery(sql, new MapProcessor()); + } + +} diff --git a/so/src/public/nccloud/api/so/saleinvoice/operator/SaleInvResource.java b/so/src/public/nccloud/api/so/saleinvoice/operator/SaleInvResource.java new file mode 100644 index 00000000..be925c78 --- /dev/null +++ b/so/src/public/nccloud/api/so/saleinvoice/operator/SaleInvResource.java @@ -0,0 +1,76 @@ +package nccloud.api.so.saleinvoice.operator; + +import com.alibaba.fastjson.JSONObject; +import nc.bs.logging.Logger; +import nccloud.api.rest.utils.ResultMessageUtil; +import nccloud.ws.rest.resource.AbstractNCCRestResource; +import org.json.JSONString; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; + +/** + * ۷Ʊӿ2005 + * zhangxinah + */ +@Path("so/saleinvoice/operator") +public class SaleInvResource extends AbstractNCCRestResource { + + public SaleInvResource() { + } + + @Override + public String getModule() { + return "so"; + } + + @POST + @Path("saveCommit") + @Consumes({"application/json"}) + @Produces({"application/json"}) + public JSONString saveCommit(JSONString json) { + try { + JSONObject jobject = JSONObject.parseObject(json.toJSONString()); + if (jobject == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("JSONString:null")); + } + JSONObject bject = jobject.getJSONObject("billhead"); + if (bject == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("billhead:null")); + } + IAPISaleInvMaitainImpl service = new IAPISaleInvMaitainImpl(); + return service.saveBlue(jobject); + } catch (Exception e) { + Logger.error("saveCommit-exp: ", e); + return ResultMessageUtil.exceptionToJSON(e); + } + } + + /** + * ۷Ʊӿ + * + * @author lj + * @date 2025/03/14 + * @update 20250415 mzr޸ + */ + @POST + @Path("billSaveRp") + @Consumes({"application/json"}) + @Produces({"application/json"}) + public JSONString billSaveRp(JSONString json) { + try { + JSONObject jobject = JSONObject.parseObject(json.toJSONString()); + if (jobject == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("JSONString:null")); + } + IAPISaleInvMaitainImpl service = new IAPISaleInvMaitainImpl(); + return service.saveRed(jobject); + } catch (Exception e) { + Logger.error("billSaveRp-exp: ", e); + return ResultMessageUtil.exceptionToJSON(e); + } + } + +} \ No newline at end of file diff --git a/so/src/public/nccloud/api/so/saleinvoice/operator/saveCommitAction.java b/so/src/public/nccloud/api/so/saleinvoice/operator/saveCommitAction.java deleted file mode 100644 index b721579e..00000000 --- a/so/src/public/nccloud/api/so/saleinvoice/operator/saveCommitAction.java +++ /dev/null @@ -1,431 +0,0 @@ -package nccloud.api.so.saleinvoice.operator; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import nc.bs.framework.common.InvocationInfoProxy; -import nc.bs.framework.common.NCLocator; -import nc.bs.framework.core.util.ObjectCreator; -import nc.itf.uap.IUAPQueryBS; -import nc.jdbc.framework.processor.ColumnProcessor; -import nc.jdbc.framework.processor.MapProcessor; -import nc.pubitf.so.m32.api.ISaleinvoiceQueryAPI; -import nc.vo.pub.BusinessException; -import nc.vo.pub.lang.UFDouble; -import nc.vo.pubapp.pattern.model.entity.bill.AbstractBill; -import nc.vo.pubapp.pflow.PfUserObject; -import nc.vo.so.m32.entity.SaleInvoiceHVO; -import nc.vo.so.m32.entity.SaleInvoiceVO; -import nccloud.api.baseapp.exchange.convert.IExchangeForService; -import nccloud.api.baseapp.exchange.convert.OpenApiConvertDataObject; -import nccloud.api.baseapp.exchange.convert.OpenApiConvertDataResult; -import nccloud.api.rest.utils.ResultMessageUtil; -import nccloud.dto.scmpub.script.entity.SCMScriptResultDTO; -import nccloud.pubitf.riart.pflow.CloudPFlowContext; -import nccloud.pubitf.scmpub.commit.service.IBatchRunScriptService; -import nccloud.pubitf.scmpub.ssc.service.ISSCService; -import nccloud.pubitf.so.saleinvoice.service.ISaleInvoiceToTaxInvService; -import nccloud.pubitf.ssctp.sscbd.lientage.ISSClientageMatchService.BusiUnitTypeEnum; -import nccloud.ws.rest.resource.AbstractNCCRestResource; -import org.json.JSONString; - -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.Map; - -/** - * ۷Ʊӿ2005 - * zhangxinah - */ -@Path("so/saleinvoice/operator") -public class saveCommitAction extends AbstractNCCRestResource { - - public static String fplxStr = "";// Ʊ뷢Ʊ - - public saveCommitAction() { - - } - - public OpenApiConvertDataResult changeToExchangeData(OpenApiConvertDataObject openApiConvertDataObject) - throws Exception { - return getPFxxEJBService().changeToExchangeData(openApiConvertDataObject); - } - - public static IExchangeForService getPFxxEJBService() { - IExchangeForService exchangeForService = (IExchangeForService) ObjectCreator.newInstance("ufesbexpress", - "nccloud.pubimpl.pfxx.convert.ExchangeForServiceImpl"); - return exchangeForService; - } - - @Override - public String getModule() { - return "so"; - } - - @POST - @Path("/saveCommit") - @Consumes({"application/json"}) - @Produces({"application/json"}) - public JSONString saveCommit(JSONString json) throws Exception { - JSONObject jobject = JSONObject.parseObject(json.toJSONString()); - if (jobject == null) { - return ResultMessageUtil.exceptionToJSON(new NullPointerException("JSONString:null")); - } else { - JSONObject bject = jobject.getJSONObject("billhead"); - if (bject == null) { - return ResultMessageUtil.exceptionToJSON(new NullPointerException("billhead:null")); - } else { - - JSONObject ufinterfaceObj = jsonObjectAss(jobject); - String tsType = ufinterfaceObj.getString("tsType"); - if (tsType != null && tsType.equals("1")) { - Exception e = new NullPointerException("۶ѯʧܣ"); - return ResultMessageUtil.exceptionToJSON(e); - } - JSONObject bjects = ufinterfaceObj.getJSONObject("ufinterface"); - String billtype = bjects.getString("billtype"); - String account = bjects.getString("account"); - String omscode = bjects.getString("orgcode"); - String groupcode = bjects.getString("groupcode"); - - if (billtype != null && account != null && groupcode != null && "32".equals(billtype)) { - OpenApiConvertDataObject openApiconvertData0bject = new OpenApiConvertDataObject(); - openApiconvertData0bject.setAccount(account); - openApiconvertData0bject.setBilltype(billtype); - openApiconvertData0bject.setGroupcode(groupcode); - openApiconvertData0bject.setOpenApiJsonData(ufinterfaceObj); - try { - OpenApiJsonConvertToExChangeXmlService oService = new OpenApiJsonConvertToExChangeXmlService(); - OpenApiConvertDataResult r = oService.changeToExchangeData(openApiconvertData0bject); - JSONObject returnJson = r.getDesc(); - String content = ""; - // JSON - JSONObject ufinterface = returnJson.getJSONObject("ufinterface"); - if (ufinterface != null) { - JSONArray sendResultArray = ufinterface.getJSONArray("sendresult"); - if (sendResultArray != null && sendResultArray.size() > 0) { - // ȡ content ֶ - content = sendResultArray.getJSONObject(0).getString("content"); - } - } - if (content == null || content.equals("")) { - return r != null ? ResultMessageUtil.toJSON(r.getDesc(), "0") - : ResultMessageUtil.exceptionToJSON(new NullPointerException("δ֪쳣")); - } - String[] ids = {content}; - SaleInvoiceVO[] saleInvoiceVO = NCLocator.getInstance().lookup(ISaleinvoiceQueryAPI.class) - .queryVOByIDs(ids); - SaleInvoiceVO saleInvoiceVO22 = saleInvoiceVO[0]; - SaleInvoiceHVO saleInvoiceHVO = saleInvoiceVO22.getParentVO(); - // ۷Ʊ˿ʼ - InvocationInfoProxy.getInstance().setUserId(saleInvoiceHVO.getApprover()); - CloudPFlowContext context = new CloudPFlowContext(); - context.setBillType("32"); - context.setBillVos(new SaleInvoiceVO[]{saleInvoiceVO[0]}); - ISSCService sscService = (ISSCService) NCLocator.getInstance().lookup(ISSCService.class); - String[] actionNames = sscService.isStartSSCWorkFlow( - (AbstractBill[]) ((AbstractBill[]) context.getBillVos()), BusiUnitTypeEnum.SO); - context.setActionName("APPROVE"); - context.setTrantype("32-02"); - context.setBatch(false); - context.setBatchUserObj(new PfUserObject[]{new PfUserObject()}); - IBatchRunScriptService service = (IBatchRunScriptService) NCLocator.getInstance() - .lookup(IBatchRunScriptService.class); - SCMScriptResultDTO result = service.runBacth(context, SaleInvoiceVO.class); - // ۷Ʊ˽ - ISaleInvoiceToTaxInvService invoiceService = NCLocator.getInstance() - .lookup(ISaleInvoiceToTaxInvService.class); - // Ʊ(ֵ˰ר÷Ʊ)=31,Ʊ(ͨƱ)=32,ֽʷƱ(ͳһƱ)=36,ֽʷƱ(ֵ˰ר÷Ʊ)=33,ֽʷƱ(ͨƱ)=34, - // ֵ˰ͨƱ=1,ֵ˰ר÷Ʊ=2,ֵ˰ͨƱ=3,ֵ˰ר÷Ʊ=4,ֵ˰ͨƱƷͣ=8,ƷͨƱ(ʽ)=9, - // ƷͨƱ=10,Ʒר÷Ʊ=11,ֵ˰ͨƱ(ʽ)=12,ֵ˰ר÷Ʊ()=99 - invoiceService.issueTaxInvoice(saleInvoiceVO, fplxStr); - - JSONObject desc = r.getDesc(); - if (desc != null) { - // ƱȫϢظͬƽ̨ - desc.put("vos", saleInvoiceVO); - } - return ResultMessageUtil.toJSON(desc, "0"); - } catch (Exception e) { - return ResultMessageUtil.exceptionToJSON(e); - } - } else { - Exception e = new NullPointerException( - "billtype:" + billtype + ",account:" + account + ",groupcode:" + groupcode); - return ResultMessageUtil.exceptionToJSON(e); - } - - } - } - } - - public static JSONObject jsonObjectAss(JSONObject originalJson) throws Exception { - try { - // Ŀ JSON ʽ - JSONObject resultJson = new JSONObject(); - // ufinterface ֶ - JSONObject ufinterface = new JSONObject(); - ufinterface.put("billtype", "32"); - ufinterface.put("sender", "BIP_NC"); - ufinterface.put("level", "0"); - ufinterface.put("replace", "Y"); - ufinterface.put("roottag", "bill"); - ufinterface.put("isexchange", "Y"); - ufinterface.put("account", "01"); - ufinterface.put("groupcode", "00"); - // bill - JSONArray billArray = new JSONArray(); - JSONObject bill = new JSONObject(); - // billhead ṹ - JSONObject billhead = new JSONObject(); - billhead = originalJson.getJSONObject("billhead");// JSON - billhead.put("pk_org_v", originalJson.getJSONObject("billhead").getString("pk_org"));// Ʊ֯汾=Ʊ֯ - billhead.put("pk_group", "00");// - fplxStr = originalJson.getJSONObject("billhead").getString("vdef22"); - billhead.put("vtrantypecode", "32-02");// Ʊͱ - billhead.put("cbiztypeid", "SO01");// ҵ - billhead.put("approver", "BIP");// - billhead.put("fstatusflag", 1);// ״̬ - billhead.put("billmaker", "BIP");// Ƶ - billhead.put("csendcountryid", "CN");// - billhead.put("crececountryid", "CN");// ջ - billhead.put("ctaxcountryid", "CN");// ˰ - // 2025-2-8ҵҪ޸ģݷƱQԶ嵵շƱ - String ctrantypeidStr = "32-02";// ĬͨƱ - if (fplxStr != null && fplxStr.equals("31")) { - ctrantypeidStr = "32-01";// Ʊ(ֵ˰ר÷Ʊ) - } else if (fplxStr != null && fplxStr.equals("32")) { - ctrantypeidStr = "32-02";// Ʊ(ͨƱ) - } else if (fplxStr != null && fplxStr.equals("36")) { - ctrantypeidStr = "32-Cxx-03";// ۷Ʊ - } - billhead.put("ctrantypeid", ctrantypeidStr);// Ʊ - // billhead.put("ctrantypeid", "32-02");//Ʊ - billhead.put("fbuysellflag", "1");// - billhead.put("creator", "BIP");// - billhead.put("ccurrencyid", "CNY");// λ - billhead.put("corigcurrencyid", "CNY");// - billhead.put("nexchangerate", 1);// ۱ - billhead.put("btriatradeflag", 0);// ó - JSONObject newItem = new JSONObject(); - JSONObject otherJson = new JSONObject(); - JSONArray csaleinvoicebid = new JSONArray(); - // ԭʼе csaleinvoicebid - for (int i = 0; i < originalJson.getJSONObject("billhead").getJSONArray("csaleinvoicebid").size(); i++) { - JSONObject item = originalJson.getJSONObject("billhead").getJSONArray("csaleinvoicebid") - .getJSONObject(i); - - JSONObject itemDetails = new JSONObject(); - itemDetails = item; - itemDetails.put("carorgid", originalJson.getJSONObject("billhead").getString("pk_org"));// Ӧ֯ - itemDetails.put("csendstockorgid", originalJson.getJSONObject("billhead").getString("pk_org"));// ֯ԭʼ汾 - itemDetails.put("cmaterialid", item.getString("cmaterialvid"));// ϱ - Map value2 = getSaleorderVo(item.getString("csrcbid")); - if (value2 == null) { - resultJson = new JSONObject(); - resultJson.put("tsType", "1"); - return resultJson; - } - itemDetails.put("vfirsttype", "30");// Դͷ - itemDetails.put("vfirstcode", value2.get("vbillcode"));// Դͷݺ - itemDetails.put("blargessflag", value2.get("blargessflag"));// Ʒ - itemDetails.put("vfirsttrantype", "30-01");// Դͷ - itemDetails.put("vfirstrowno", value2.get("crowno"));// Դͷк - itemDetails.put("cfirstid", item.getString("csrcid"));// Դͷ - itemDetails.put("cfirstbid", item.getString("csrcbid"));// Դͷӱ - itemDetails.put("vsrctype", "30");// Դ - itemDetails.put("vsrccode", value2.get("vbillcode"));// Դݺ - itemDetails.put("vsrctrantype", "30-01");// Դ - itemDetails.put("vsrcrowno", value2.get("crowno"));// Դк - // ͨ ntaxrate ȡ taxcode - String taxcodeStr = getTaxcode(item.getString("ntaxrate")); - // taxcodeStr bodyMap - itemDetails.put("ctaxcodeid", taxcodeStr);// ˰ - itemDetails.put("nnum", item.getString("nastnum"));// - itemDetails.put("ftaxtypeflag", 1);// ˰ - itemDetails.put("pk_group", "00");// - itemDetails.put("pk_org", originalJson.getJSONObject("billhead").getString("pk_org"));// Ʊ֯ - itemDetails.put("cunitid", item.getString("castunitid"));// λ - itemDetails.put("vchangerate", value2.getOrDefault("vchangerate", "1/1") + "");// - -// double nastnum = Double.parseDouble(item.getString("nastnum"));// -// double nqtorigtaxprice = Double.parseDouble(item.getString("nqtorigtaxprice"));//˰ -// double ntaxrate = Double.parseDouble(item.getString("ntaxrate"));//˰ -// -// double nqtorigprice = -// Math.round(nqtorigtaxprice / (1 + ntaxrate) * 100.0) / 100.0;//˰ۡ˰ۣ˰/(1+˰) -// double norigmny = Math.round(nqtorigprice * nastnum * 100.0) / 100.0;//˰˰* -// double norigtaxmny = Math.round(nastnum * nqtorigtaxprice * 100.0) / 100.0;//˰ϼơ˰*˰ۣ -// double norigtaxprice = Math.round(nqtorigtaxprice * 100.0) / 100.0;//˰ۣ˰ۣ -// double norignetprice = nqtorigprice;//˰ۣ˰ۣ -// double ntax = Math.round(norigtaxmny / (1 + ntaxrate) * ntaxrate * 100.0) / 100.0;//˰˰/(1+˰)*˰ʣ -// double ncaltaxmny = norigmny;//˰˰ -// double norigtaxnetprice = norigtaxprice;//˰ۣ˰ۣ - -// BigDecimal nastnum = new BigDecimal(item.getString("nastnum"));// -// BigDecimal nqtorigtaxprice = new BigDecimal(item.getString("nqtorigtaxprice"));//˰ -// BigDecimal ntaxrate = new BigDecimal(item.getString("ntaxrate"));//˰ -// -// // 1. 㲻˰ -// BigDecimal nqtorigprice = nqtorigtaxprice.divide(BigDecimal.ONE.add(ntaxrate), 4, RoundingMode.HALF_UP); -// // 2. ˰ = ˰ * -// BigDecimal norigmny = nqtorigprice.multiply(nastnum).setScale(4, RoundingMode.HALF_UP); -// // 3. ˰ = ˰ * ˰ -// BigDecimal ntax = norigmny.multiply(ntaxrate).setScale(4, RoundingMode.HALF_UP); -// // 4. 㺬˰ = ˰ + ˰ -// BigDecimal norigtaxmny = norigmny.add(ntax).setScale(4, RoundingMode.HALF_UP); -// // ˰ۣ˰ۣ -// BigDecimal norigtaxprice = nqtorigtaxprice.setScale(4, RoundingMode.HALF_UP); -// // ˰ۣ˰ۣ -// BigDecimal norignetprice = nqtorigprice; -// // ˰ = ˰ -// BigDecimal ncaltaxmny = norigmny; -// // ˰ = ˰ۣԭʼ -// BigDecimal norigtaxnetprice = norigtaxprice; - - // ۶лȡ - String currencycode = getString_TrimAsNull(value2.get("currencycode")); - otherJson.put("corigcurrencyid", currencycode.isEmpty() ? "CNY" : currencycode); - // ۶лȡ۱ - BigDecimal nexchangerate = getUFDouble_NullAsZero(value2.get("nexchangerate")).toBigDecimal(); - otherJson.put("nexchangerate", nexchangerate); - - // item ȡֶ - BigDecimal nastnum = new BigDecimal(item.getString("nastnum")); // - nastnum = nastnum.setScale(4, RoundingMode.HALF_UP); - BigDecimal nqtorigtaxprice = new BigDecimal(item.getString("nqtorigtaxprice")); // ˰ - nqtorigtaxprice = nqtorigtaxprice.setScale(4, RoundingMode.HALF_UP); - BigDecimal ntaxrate = new BigDecimal(item.getString("ntaxrate")).divide(new BigDecimal("100")); // ˰ - ntaxrate = ntaxrate.setScale(4, RoundingMode.HALF_UP); - - // ˰ - BigDecimal norigtaxnetprice = nqtorigtaxprice; - // 1. ˰ϼƣ˰ - BigDecimal norigtaxmny = nastnum.multiply(norigtaxnetprice).setScale(2, RoundingMode.HALF_UP); - // 2. ۿ۶ - BigDecimal discountAmount = nastnum.multiply(nqtorigtaxprice).subtract(norigtaxmny).setScale(4, - RoundingMode.HALF_UP); - // 3. ˰ַӦ˰˰Ӧ˰ں˰ - BigDecimal ntax = norigtaxmny.multiply(ntaxrate).divide(BigDecimal.ONE.add(ntaxrate), 2, - RoundingMode.HALF_UP); // Ӧ˰˰ - BigDecimal taxInclusiveInner = norigtaxmny.multiply(ntaxrate).setScale(4, RoundingMode.HALF_UP); // Ӧ˰ں˰ - // 4. ˰ - BigDecimal norigmny = norigtaxmny.subtract(ntax).setScale(2, RoundingMode.HALF_UP); - // 4. ˰ۣnqtorigprice = ˰ / - BigDecimal nqtorigprice = norigmny.divide(nastnum, 4, RoundingMode.HALF_UP); - // ˰ = ˰ - BigDecimal ncaltaxmny = norigmny; - // ˰ۣ˰ۣ - BigDecimal norigtaxprice = nqtorigtaxprice.setScale(4, RoundingMode.HALF_UP); - // ˰ۣ˰ۣ - BigDecimal norignetprice = nqtorigprice; - - // ()ҪʣλС۱4λС - // ˰ - BigDecimal nmny = norigmny.multiply(nexchangerate).setScale(2, RoundingMode.HALF_UP); - // ˰ - BigDecimal nnetprice = norignetprice.multiply(nexchangerate).setScale(4, RoundingMode.HALF_UP); - // Ҽ˰ϼ ˰ϼ* - BigDecimal ntaxmny = norigtaxmny.multiply(nexchangerate).setScale(2, RoundingMode.HALF_UP); - // ˰ - ntax = ntaxmny.subtract(nmny).setScale(2, RoundingMode.HALF_UP); - - itemDetails.put("nqtorigprice", nqtorigprice);// ˰ - itemDetails.put("norigprice", nqtorigprice);// ˰ - itemDetails.put("norigmny", norigmny);// ˰ - itemDetails.put("nmny", nmny);// ˰ - itemDetails.put("norigtaxmny", norigtaxmny);// ˰ϼ - itemDetails.put("norigtaxprice", norigtaxprice);// ˰ - itemDetails.put("norignetprice", norignetprice);// ˰ - itemDetails.put("nqtorigtaxprice", nqtorigtaxprice);// ˰ - itemDetails.put("ntax", ntax);// ˰ - itemDetails.put("ncaltaxmny", ncaltaxmny);// ˰ - itemDetails.put("norigtaxnetprice", norigtaxnetprice);// ˰ - itemDetails.put("nnetprice", nnetprice);// ˰ - itemDetails.put("ntaxmny", ntaxmny);// Ҽ˰ϼ - csaleinvoicebid.add(itemDetails); - - } - newItem.put("item", csaleinvoicebid); - billhead.put("csaleinvoicebid", newItem); - if (otherJson != null && !otherJson.isEmpty()) { - // ѯ۶еıֺͻ - billhead.put("corigcurrencyid", otherJson.get("corigcurrencyid"));// - billhead.put("nexchangerate", otherJson.get("nexchangerate"));// ۱ - } - bill.put("billhead", billhead); - bill.put("id", ""); - // bill ӵ ufinterface - billArray.add(bill); - ufinterface.put("bill", billArray); - // ufinterface ӵյ resultJson - resultJson.put("ufinterface", ufinterface); - return resultJson; - } catch (Exception e) { - return (JSONObject) ResultMessageUtil.exceptionToJSON(e); - } - } - - // תMap - public static String checkRequiredFields(JSONObject data) throws Exception { - String returnStr = ""; - // 2. ֶ pk_org - String pkOrg = (String) data.getOrDefault("pk_org", ""); - if (pkOrg.isEmpty()) { - return "ֶpk_orgȱʧΪ!"; - } - // 2. ֶ pk_org - String vbillcode = (String) data.getOrDefault("vbillcode", ""); - if (vbillcode.isEmpty()) { - return "ֶvbillcodeȱʧΪ!"; - } - return returnStr; - } - - private static String getTaxcode(String taxrateStr) throws BusinessException { - IUAPQueryBS queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class); - String sql = " select code FROM bd_taxrate tt inner join bd_taxcode tc on tt.pk_taxcode=tc.pk_taxcode where taxrate='" - + taxrateStr + "' AND ROWNUM = 1 "; - String taxcodeStr = (String) queryBS.executeQuery(sql, new ColumnProcessor()); - return taxcodeStr; - } - - private static Map getSaleorderVo(String csourcebillbidStr) throws BusinessException { - IUAPQueryBS queryBS = NCLocator.getInstance().lookup(IUAPQueryBS.class); - String sql = " select s.vbillcode,s.csaleorderid, s.corigcurrencyid," + - " sb.csaleorderbid,sb.crowno,sb.blargessflag,sb.nexchangerate,sb.vchangerate," + - " bdc.code currencycode" + - " from so_saleorder_b sb" + - " inner join so_saleorder s on sb.csaleorderid=s.csaleorderid" + - " left join bd_currtype bdc on s.corigcurrencyid=bdc.pk_currtype" + - " where sb.csaleorderbid='" + csourcebillbidStr + "' "; - Map value2 = (Map) queryBS.executeQuery(sql, new MapProcessor()); - return value2; - } - - private static String getString_TrimAsNull(Object value) { - if ((value == null) || (value.toString().trim().isEmpty())) { - return ""; - } - return value.toString().trim(); - } - - private static UFDouble getUFDouble_NullAsZero(Object value) { - if ((value == null) || (value.toString().trim().isEmpty()) || (value.toString().trim().equals("~"))) - return UFDouble.ONE_DBL; - if ((value instanceof UFDouble)) - return (UFDouble) value; - if ((value instanceof BigDecimal)) { - return new UFDouble((BigDecimal) value); - } - return new UFDouble(value.toString().trim()); - } - - public IUAPQueryBS getQueryService() { - return NCLocator.getInstance().lookup(IUAPQueryBS.class); - } - -} \ No newline at end of file diff --git a/so/src/public/nccloud/api/so/so/UpCdate/Updateinformer.java b/so/src/public/nccloud/api/so/so/UpCdate/Updateinformer.java index 80b7d554..03616085 100644 --- a/so/src/public/nccloud/api/so/so/UpCdate/Updateinformer.java +++ b/so/src/public/nccloud/api/so/so/UpCdate/Updateinformer.java @@ -1,6 +1,5 @@ package nccloud.api.so.so.UpCdate; -import nc.jdbc.framework.processor.MapListProcessor; -import org.springframework.util.ObjectUtils; + import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -10,13 +9,13 @@ import nc.itf.uap.IUAPQueryBS; import nc.jdbc.framework.JdbcSession; import nc.jdbc.framework.PersistenceManager; import nc.jdbc.framework.exception.DbException; -import nc.jdbc.framework.processor.ArrayListProcessor; import nc.jdbc.framework.processor.ColumnProcessor; +import nc.jdbc.framework.processor.MapListProcessor; import nc.vo.pub.BusinessException; import nccloud.api.rest.utils.ResultMessageUtil; import nccloud.ws.rest.resource.AbstractNCCRestResource; import org.json.JSONString; -import org.apache.http.client.methods.CloseableHttpResponse; + import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; @@ -27,86 +26,90 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import nc.itf.cm.productcostcollect.IProductCostCollectService; + +/** + * BIPˮ3δ˻NCC޸ͱʶ + * 20052312 + */ @Path("so/so/UpCdate") public class Updateinformer extends AbstractNCCRestResource { - @Override - public String getModule() { - return "so"; - } + @Override + public String getModule() { + return "so"; + } - // ڴ洢ֹάıֶκֶ˵ - private Map requiredFields; + // ڴ洢ֹάıֶκֶ˵ + private Map requiredFields; - // 췽ʼֶμ˵ - public Updateinformer() { - // ʼֶбֶ˵ - requiredFields = new HashMap<>(); - requiredFields.put("pk_org", "ҵԪ"); - requiredFields.put("array.vbillcode", "ݱ"); - requiredFields.put("array.crowno", "к"); - requiredFields.put("array.sendQty", ""); - } + // 췽ʼֶμ˵ + public Updateinformer() { + // ʼֶбֶ˵ + requiredFields = new HashMap<>(); + requiredFields.put("pk_org", "ҵԪ"); + requiredFields.put("array.vbillcode", "ݱ"); + requiredFields.put("array.crowno", "к"); + requiredFields.put("array.sendQty", ""); + } - @POST - @Path("/Updateinformer") - @Consumes({"application/json"}) - @Produces({"application/json"}) - public JSONString Updateinformer(JSONString json) { - JSONObject returnJson = new JSONObject(); - try { + @POST + @Path("/Updateinformer") + @Consumes({"application/json"}) + @Produces({"application/json"}) + public JSONString Updateinformer(JSONString json) { + JSONObject returnJson = new JSONObject(); + try { - JSONObject object = JSON.parseObject(json.toJSONString()); - if (object == null) { - return ResultMessageUtil.exceptionToJSON(new NullPointerException("JSONString:null")); - } - // Уֶ + JSONObject object = JSON.parseObject(json.toJSONString()); + if (object == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("JSONString:null")); + } + // Уֶ // String tipsStr = checkRequiredFields(object); // if (!tipsStr.equals("")) { // return ResultMessageUtil.exceptionToJSON(new NullPointerException(tipsStr)); // } - Object obj = object.getOrDefault("array", ""); + Object obj = object.getOrDefault("array", ""); if (obj.equals("")) { return ResultMessageUtil.exceptionToJSON(new NullPointerException("array:null")); } - ArrayList arrayList = new ArrayList<>(); - if (obj instanceof JSONArray) { - JSONArray jsonArray = (JSONArray) obj; - arrayList = new ArrayList<>(jsonArray.toJavaList(Object.class)); - } + ArrayList arrayList = new ArrayList<>(); + if (obj instanceof JSONArray) { + JSONArray jsonArray = (JSONArray) obj; + arrayList = new ArrayList<>(jsonArray.toJavaList(Object.class)); + } // StringBuilder sqlStr = new StringBuilder(); - List sqlStr = new ArrayList(); - ArrayList pk_list=null; + List sqlStr = new ArrayList(); + ArrayList pk_list = null; // for (int i = 0; i < arrayList.size(); i++) { // Map dataMap = (Map) arrayList.get(i); // pk_list.add((String) dataMap.get("pk_informer")); // } - String result = ""; - StringBuilder sb = new StringBuilder(); - if (arrayList.size() > 1) { - for (int i = 0; i < arrayList.size(); i++) { - Map dataMap = (Map) arrayList.get(i); + String result = ""; + StringBuilder sb = new StringBuilder(); + if (arrayList.size() > 1) { + for (int i = 0; i < arrayList.size(); i++) { + Map dataMap = (Map) arrayList.get(i); - sb.append("'").append(dataMap.get("pk_informer")).append("'"); - if (i < arrayList.size() - 1) { - sb.append(","); - } - } + sb.append("'").append(dataMap.get("pk_informer")).append("'"); + if (i < arrayList.size() - 1) { + sb.append(","); + } + } - result = sb.toString(); - }else { - Map dataMap = (Map) arrayList.get(0); + result = sb.toString(); + } else { + Map dataMap = (Map) arrayList.get(0); - result= "'"+(String) dataMap.get("pk_informer")+"'"; + result = "'" + (String) dataMap.get("pk_informer") + "'"; - } - String sqlser="select pk_informer from cmp_informer where pk_informer in("+result+")"; + } + String sqlser = "select pk_informer from cmp_informer where pk_informer in(" + result + ")"; // ArrayList results = (ArrayList) getQueryService().executeQuery(sqlser, new ArrayListProcessor()); - List> results = (List>) getQueryService().executeQuery(sqlser, new MapListProcessor()); + List> results = (List>) getQueryService().executeQuery(sqlser, new MapListProcessor()); // if (results != null || results.size()!=arrayList.size()) { // vbillcodes.add(dataMap.get("pk_informer")); // }else { @@ -114,190 +117,190 @@ public class Updateinformer extends AbstractNCCRestResource { // returnJson.put("msg", "ʧ,"+dataMap.get("pk_informer")+""); // return (JSONString) returnJson; // } - ArrayList result2 = new ArrayList<>(); - System.out.println(results.getClass()); - for (int i = 0; i < results.size(); i++) { - Map aa=results.get(i); - result2.add((String) aa.get("pk_informer")); - } - ArrayList vbillcodes = new ArrayList<>(); - for (int i = 0; i < arrayList.size(); i++) { - Map dataMap = (Map) arrayList.get(i); - Object pkInformer = dataMap.get("pk_informer"); - Object status = dataMap.get("status"); + ArrayList result2 = new ArrayList<>(); + System.out.println(results.getClass()); + for (int i = 0; i < results.size(); i++) { + Map aa = results.get(i); + result2.add((String) aa.get("pk_informer")); + } + ArrayList vbillcodes = new ArrayList<>(); + for (int i = 0; i < arrayList.size(); i++) { + Map dataMap = (Map) arrayList.get(i); + Object pkInformer = dataMap.get("pk_informer"); + Object status = dataMap.get("status"); - if (pkInformer == null || status == null) { - continue; // null ֵ - } - //жַڲresultsѯ - //resultsֵΪstring + if (pkInformer == null || status == null) { + continue; // null ֵ + } + // жַڲresultsѯ + // resultsֵΪstring - String pk_informer= (String) dataMap.get("pk_informer"); + String pk_informer = (String) dataMap.get("pk_informer"); if (result2.contains(pk_informer)) { - vbillcodes.add(dataMap.get("pk_informer")); + vbillcodes.add(dataMap.get("pk_informer")); - sqlStr.add("UPDATE cmp_informer SET def01 = '" + dataMap.get("status") + "' where pk_informer='"+dataMap.get("pk_informer") - + "';"); - } - } - returnJson.put("codeList", vbillcodes); + sqlStr.add("UPDATE cmp_informer SET vdef1 = '" + dataMap.get("status") + "' where pk_informer='" + dataMap.get("pk_informer") + + "';"); + } + } + returnJson.put("codeList", vbillcodes); - int succState = executeUpdate(sqlStr); + int succState = executeUpdate(sqlStr); - returnJson.put("state", '1'); - if (succState == 0) { - returnJson.put("msg", "ʧ"); - }else { - returnJson.put("msg", "ɹ,޸"+succState+""); + returnJson.put("state", '1'); + if (succState == 0) { + returnJson.put("msg", "ʧ"); + } else { + returnJson.put("msg", "ɹ,޸" + succState + ""); - } - return ResultMessageUtil.toJSON(returnJson); - } catch (DbException e) { - throw new RuntimeException(e); - } catch (Exception e) { - throw new RuntimeException(e); - } - } + } + return ResultMessageUtil.toJSON(returnJson); + } catch (DbException e) { + throw new RuntimeException(e); + } catch (Exception e) { + throw new RuntimeException(e); + } + } - /** - * updateSqlsΪҪִеsql䡣Ӱ - */ - public int executeUpdate(List updateSqls) throws DbException { - if (updateSqls == null) { - return 0; - } + /** + * updateSqlsΪҪִеsql䡣Ӱ + */ + public int executeUpdate(List updateSqls) throws DbException { + if (updateSqls == null) { + return 0; + } - int ret = 0; - PersistenceManager manager = null; - JdbcSession session = null; - Connection connection = null; + int ret = 0; + PersistenceManager manager = null; + JdbcSession session = null; + Connection connection = null; - try { - manager = PersistenceManager.getInstance(); - session = manager.getJdbcSession(); - connection = session.getConnection(); // ȡʵʵݿ + try { + manager = PersistenceManager.getInstance(); + session = manager.getJdbcSession(); + connection = session.getConnection(); // ȡʵʵݿ - // ʼ - connection.setAutoCommit(false); // Զύֶ + // ʼ + connection.setAutoCommit(false); // Զύֶ - // ִ - for (String sql : updateSqls) { - session.addBatch(sql); - } + // ִ + for (String sql : updateSqls) { + session.addBatch(sql); + } - // ִ - ret = session.executeBatch(); + // ִ + ret = session.executeBatch(); - // ύ - connection.commit(); // ɹύ + // ύ + connection.commit(); // ɹύ - } catch (DbException e) { - if (connection != null) { - try { - // 쳣ع - connection.rollback(); - } catch (SQLException rollbackEx) { - // ¼ع쳣ϸϢ - throw new DbException("Error during transaction rollback", rollbackEx) { - @Override - public boolean isDataIntegrityViolation() { - return false; - } + } catch (DbException e) { + if (connection != null) { + try { + // 쳣ع + connection.rollback(); + } catch (SQLException rollbackEx) { + // ¼ع쳣ϸϢ + throw new DbException("Error during transaction rollback", rollbackEx) { + @Override + public boolean isDataIntegrityViolation() { + return false; + } - @Override - public boolean isBadSQLGrammar() { - return false; - } - }; - } - } - throw e; // ԭʼ쳣׳ - } catch (SQLException e) { - throw new RuntimeException(e); - } finally { - if (connection != null) { - try { - // ָԶύģʽȷӰ - connection.setAutoCommit(true); - } catch (SQLException e) { - // ԻָԶύʱ쳣 - } - } - if (manager != null) { - manager.release(); - } - } + @Override + public boolean isBadSQLGrammar() { + return false; + } + }; + } + } + throw e; // ԭʼ쳣׳ + } catch (SQLException e) { + throw new RuntimeException(e); + } finally { + if (connection != null) { + try { + // ָԶύģʽȷӰ + connection.setAutoCommit(true); + } catch (SQLException e) { + // ԻָԶύʱ쳣 + } + } + if (manager != null) { + manager.release(); + } + } - return ret; - } + return ret; + } - // תMap - public static String checkRequiredFields(JSONObject data) throws Exception { - String returnStr = ""; - // 2. ֶ pk_org - String pkOrg = (String) data.getOrDefault("pk_org", ""); - if (pkOrg.isEmpty()) { - return "ֶpk_orgȱʧΪ!"; - } - // 3. ȡ array ֶ - Object array = data.getOrDefault("array", null); - if (array == null || !(array instanceof JSONArray) || ((JSONArray) array).isEmpty()) { - return "arrayΪջ򲻴!"; - } - ArrayList arrayList = new ArrayList<>(); - if (array instanceof JSONArray) { - JSONArray jsonArray = (JSONArray) array; - arrayList = new ArrayList<>(jsonArray.toJavaList(Object.class)); - } - // 5. ÿ󣬼ֶ - for (int i = 0; i < arrayList.size(); i++) { - Map item = (Map) arrayList.get(i); - // ֶ 'crowno' - if (item.getOrDefault("crowno", "").toString().isEmpty()) { - return " " + (i + 1) + " ȱٱֶcrowno!"; - } - // ֶ 'vbillcode' - if (item.getOrDefault("vbillcode", "").toString().isEmpty()) { - return " " + (i + 1) + " ȱٱֶvbillcode!"; - } - // ֶ 'sendQty' - if (item.getOrDefault("sendQty", "").toString().isEmpty()) { - return " " + (i + 1) + " ȱٱֶsendQty!"; - } - } - return returnStr; - } + // תMap + public static String checkRequiredFields(JSONObject data) throws Exception { + String returnStr = ""; + // 2. ֶ pk_org + String pkOrg = (String) data.getOrDefault("pk_org", ""); + if (pkOrg.isEmpty()) { + return "ֶpk_orgȱʧΪ!"; + } + // 3. ȡ array ֶ + Object array = data.getOrDefault("array", null); + if (array == null || !(array instanceof JSONArray) || ((JSONArray) array).isEmpty()) { + return "arrayΪջ򲻴!"; + } + ArrayList arrayList = new ArrayList<>(); + if (array instanceof JSONArray) { + JSONArray jsonArray = (JSONArray) array; + arrayList = new ArrayList<>(jsonArray.toJavaList(Object.class)); + } + // 5. ÿ󣬼ֶ + for (int i = 0; i < arrayList.size(); i++) { + Map item = (Map) arrayList.get(i); + // ֶ 'crowno' + if (item.getOrDefault("crowno", "").toString().isEmpty()) { + return " " + (i + 1) + " ȱٱֶcrowno!"; + } + // ֶ 'vbillcode' + if (item.getOrDefault("vbillcode", "").toString().isEmpty()) { + return " " + (i + 1) + " ȱٱֶvbillcode!"; + } + // ֶ 'sendQty' + if (item.getOrDefault("sendQty", "").toString().isEmpty()) { + return " " + (i + 1) + " ȱٱֶsendQty!"; + } + } + return returnStr; + } - /* - *ʱ䣺2024-11-28 - *ãѯ - *ֵ - *ֵmap - */ - private String getSaleorderBPK(String pk_org, String vbillcode, String crowno) throws BusinessException { - String sql = " select b.csaleorderbid from so_saleorder h \n" - + "left join so_saleorder_b b on h.csaleorderid=b.csaleorderid\n" - + "left join org_salesorg o on h.pk_org=o.pk_salesorg\n" - + "where h.vbillcode='" + vbillcode + "' and o.code='" + pk_org + "' and b.crowno='" + crowno + "' "; - String saleorderBPK = (String) getQueryService().executeQuery(sql, new ColumnProcessor()); - return saleorderBPK; - } + /* + *ʱ䣺2024-11-28 + *ãѯ + *ֵ + *ֵmap + */ + private String getSaleorderBPK(String pk_org, String vbillcode, String crowno) throws BusinessException { + String sql = " select b.csaleorderbid from so_saleorder h \n" + + "left join so_saleorder_b b on h.csaleorderid=b.csaleorderid\n" + + "left join org_salesorg o on h.pk_org=o.pk_salesorg\n" + + "where h.vbillcode='" + vbillcode + "' and o.code='" + pk_org + "' and b.crowno='" + crowno + "' "; + String saleorderBPK = (String) getQueryService().executeQuery(sql, new ColumnProcessor()); + return saleorderBPK; + } - /* - *ʱ䣺2024-11-28 - *ãѯ - *ֵ - *ֵmap - */ - private int updateSaleBSQty(String sql) throws BusinessException { - BaseDAO baseDAO = new BaseDAO(); - int succInt = baseDAO.executeUpdate(sql); - return succInt; - } + /* + *ʱ䣺2024-11-28 + *ãѯ + *ֵ + *ֵmap + */ + private int updateSaleBSQty(String sql) throws BusinessException { + BaseDAO baseDAO = new BaseDAO(); + int succInt = baseDAO.executeUpdate(sql); + return succInt; + } - public IUAPQueryBS getQueryService() { - return NCLocator.getInstance().lookup(IUAPQueryBS.class); - } + public IUAPQueryBS getQueryService() { + return NCLocator.getInstance().lookup(IUAPQueryBS.class); + } }