From dfef160673cd775292b79a423adc262cbc3c2549 Mon Sep 17 00:00:00 2001 From: lihao Date: Mon, 14 Apr 2025 18:18:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E7=A5=A8=E7=94=B3=E8=AF=B7=E7=B2=BE?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/util/DataChangeLogic.java | 1207 +++++++++++++++++ 1 file changed, 1207 insertions(+) create mode 100644 sscivm/src/client/nccloud/web/sscivm/ivsale/application/util/DataChangeLogic.java diff --git a/sscivm/src/client/nccloud/web/sscivm/ivsale/application/util/DataChangeLogic.java b/sscivm/src/client/nccloud/web/sscivm/ivsale/application/util/DataChangeLogic.java new file mode 100644 index 0000000..e7253bc --- /dev/null +++ b/sscivm/src/client/nccloud/web/sscivm/ivsale/application/util/DataChangeLogic.java @@ -0,0 +1,1207 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package nccloud.web.sscivm.ivsale.application.util; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import nc.bs.framework.common.NCLocator; +import nc.bs.framework.exception.ComponentException; +import nc.bs.sscivm.logger.SSCIVMLogger; +import nc.itf.bd.bankacc.base.IBankAccBaseInfoQueryService; +import nc.itf.bd.bankacc.subinfo.IBankAccSubInfoQueryService; +import nc.itf.bd.bankdoc.IBankdocQueryService; +import nc.itf.bd.cust.custtax.ICustTaxQueryService; +import nc.itf.bd.cust.freecust.IFreeCustQueryService; +import nc.itf.bd.material.baseinfo.IMaterialBaseInfoQueryService; +import nc.itf.uap.IUAPQueryBS; +import nc.pubitf.para.SysInitQuery; +import nc.pubitf.uapbd.IAddressPubService; +import nc.pubitf.uapbd.ICustomerPubService; +import nc.pubitf.uapbd.IMaterialPubService; +import nc.pubitf.uapbd.ISupplierPubService; +import nc.pubitf.uapbd.TaxcodeUtil; +import nc.pubitf.uapbd.taxcode.TaxcodeTaxrateQueryVO; +import nc.pubitf.uapbd.taxcode.TaxrateQueryVO; +import nc.vo.bd.address.AddressVO; +import nc.vo.bd.bankaccount.BankAccSubVO; +import nc.vo.bd.bankaccount.BankAccbasVO; +import nc.vo.bd.bankdoc.BankdocVO; +import nc.vo.bd.cust.CustbankVO; +import nc.vo.bd.cust.CustomerVO; +import nc.vo.bd.cust.custtax.CusttaxVO; +import nc.vo.bd.freecustom.FreeCustomVO; +import nc.vo.bd.material.MaterialVO; +import nc.vo.bd.material.measdoc.MeasdocVO; +import nc.vo.bd.supplier.SupplierVO; +import nc.vo.bd.taxcode.TaxrateVO; +import nc.vo.ml.MultiLangUtil; +import nc.vo.ml.NCLangRes4VoTransl; +import nc.vo.org.OrgVO; +import nc.vo.pub.CircularlyAccessibleValueObject; +import nc.vo.pub.lang.UFBoolean; +import nc.vo.pub.lang.UFDate; +import nc.vo.pub.lang.UFDouble; +import nc.vo.sscivm.ivmpub.IVAplocationFPXZ; +import nc.vo.sscivm.ivmpub.IVAplocationKPFS; +import nc.vo.sscivm.ivsale.IVApplicationAggVO; +import nc.vo.sscivm.ivsale.IVApplicationBodyVO; +import nc.vo.sscivm.ivsale.IVApplicationHeadVO; +import nccloud.base.exception.BusinessTypeException; +import nccloud.framework.core.model.entity.VOStatus; +import nccloud.framework.service.ServiceLocator; +import nccloud.framework.web.convert.precision.GridPrecisionOperator; +import nccloud.framework.web.processor.template.BillCardConvertProcessor; +import nccloud.framework.web.ui.model.row.Row; +import nccloud.framework.web.ui.pattern.billcard.BillCard; +import nccloud.framework.web.ui.pattern.billcard.BillCardOperator; +import nccloud.framework.web.ui.pattern.billcard.CardBodyAfterEditEvent; +import nccloud.framework.web.ui.pattern.billcard.CardHeadAfterEditEvent; +import nccloud.framework.web.ui.pattern.form.Form; +import nccloud.framework.web.ui.pattern.form.FormAfterEditEvent; +import nccloud.framework.web.ui.pattern.grid.Grid; +import nccloud.framework.web.ui.pattern.grid.GridAfterEditEvent; +import nccloud.itf.sscivm.ivsale.service.IVApplicationQueryService; +import nccloud.itf.sscivm.ivsale.service.IVApplicationService; +import nccloud.web.sscivm.invoice.util.InvoiceMainUtil; +import org.apache.commons.lang3.StringUtils; +import uap.json.JSONObject; + +public class DataChangeLogic { + public DataChangeLogic() { + } + + public static void setViewScala(BillCard card) throws Exception { + Form hTable = card.getHead(); + Grid bTable = card.getBody(); + Grid tspzTable = card.getGrandSon("InvApplication_Tspz"); + int hlDigit = 2; + String pk_org = toString(getHeadValue(hTable, "pk_org")); + String orgLocalCurrPK = getIVApplicationService().getOrgLocalCurrPK(pk_org); + if (orgLocalCurrPK != null) { + hlDigit = getIVApplicationService().getCurrDigit(orgLocalCurrPK); + } + + setHeadScaleValue(hTable, "jshj", hlDigit); + setHeadScaleValue(hTable, "hjje", hlDigit); + setHeadScaleValue(hTable, "hjse", hlDigit); + setHeadScaleValue(hTable, "caninvoice_jshj", hlDigit); + setHeadScaleValue(hTable, "caninvoice_hjje", hlDigit); + setHeadScaleValue(hTable, "caninvoice_hjse", hlDigit); + setHeadScaleValue(hTable, "invoiceing_jshj", hlDigit); + setHeadScaleValue(hTable, "invoiced_hjje", hlDigit); + setHeadScaleValue(hTable, "invoiced_hjse", hlDigit); + setHeadScaleValue(hTable, "invoiced_jshj", hlDigit); + setHeadScaleValue(hTable, "invoiced_hjje", hlDigit); + setHeadScaleValue(hTable, "invoiced_hjse", hlDigit); + Set materialPkSet = new HashSet(); + if (bTable != null) { + Row[] rows = bTable.getModel().getRows(); + + for(int i = 0; i < rows.length; ++i) { + Row row = rows[i]; + if (null != row) { + setRowScaleValue(row, "xmje", hlDigit); + setRowScaleValue(row, "xmjshj", hlDigit); + setRowScaleValue(row, "se", hlDigit); + setRowScaleValue(row, "caninvoice_xmje", hlDigit); + setRowScaleValue(row, "caninvoice_xmjshj", hlDigit); + setRowScaleValue(row, "caninvoice_se", hlDigit); + setRowScaleValue(row, "invoiceing_xmje", hlDigit); + setRowScaleValue(row, "invoiceing_xmjshj", hlDigit); + setRowScaleValue(row, "invoiceing_se", hlDigit); + setRowScaleValue(row, "invoiced_xmje", hlDigit); + setRowScaleValue(row, "invoiced_xmjshj", hlDigit); + setRowScaleValue(row, "invoiced_se", hlDigit); + setRowScaleValue(row, "sl", 2); + } + + materialPkSet.add((String)row.getCell("pk_materiel").getValue()); + } + + Map materialMeasdocMap = getUnitFromMaterial((String[])materialPkSet.toArray(new String[materialPkSet.size()])); + GridPrecisionOperator gridPrecisionOperator = new GridPrecisionOperator(bTable); + + for(int i = 0; i < rows.length; ++i) { + String materialPk = (String)rows[i].getCell("pk_materiel").getValue(); + gridPrecisionOperator.addNumPrecision("xmsl", i, (String)materialMeasdocMap.get(materialPk)); + gridPrecisionOperator.addNumPrecision("caninvoice_xmsl", i, (String)materialMeasdocMap.get(materialPk)); + gridPrecisionOperator.addNumPrecision("invoiceing_xmsl", i, (String)materialMeasdocMap.get(materialPk)); + gridPrecisionOperator.addNumPrecision("invoiced_xmsl", i, (String)materialMeasdocMap.get(materialPk)); + gridPrecisionOperator.addCurrencyPricePrecision("xmdj", i, orgLocalCurrPK); + } + + gridPrecisionOperator.processPrecision(); + } + + if (tspzTable != null) { + Row[] rows = tspzTable.getModel().getRows(); + + for(int i = 0; i < rows.length; ++i) { + Row row = rows[i]; + if (null != row) { + setRowScaleValue(row, "hjje", hlDigit); + setRowScaleValue(row, "kce", hlDigit); + setRowScaleValue(row, "bckcje", hlDigit); + setRowScaleValue(row, "kce", hlDigit); + } + } + } + + } + + public static void setViewScalaForBody(Grid bTable) throws Exception { + Set materialPkSet = new HashSet(); + if (bTable != null) { + Row[] rows = bTable.getModel().getRows(); + int hlDigit = 2; + String orgLocalCurrPK = getIVApplicationService().getOrgLocalCurrPK((String)rows[0].getCell("pk_org").getValue()); + if (orgLocalCurrPK != null) { + hlDigit = getIVApplicationService().getCurrDigit(orgLocalCurrPK); + } + + for(int i = 0; i < rows.length; ++i) { + Row row = rows[i]; + if (null != row) { + setRowScaleValue(row, "xmje", hlDigit); + setRowScaleValue(row, "xmjshj", hlDigit); + setRowScaleValue(row, "se", hlDigit); + setRowScaleValue(row, "sl", 2); + setRowScaleValue(row, "caninvoice_se", hlDigit); + setRowScaleValue(row, "caninvoice_xmje", hlDigit); + setRowScaleValue(row, "caninvoice_xmjshj", hlDigit); + setRowScaleValue(row, "invoiceing_se", hlDigit); + setRowScaleValue(row, "invoiceing_xmje", hlDigit); + setRowScaleValue(row, "invoiceing_xmjshj", hlDigit); + setRowScaleValue(row, "invoiced_se", hlDigit); + setRowScaleValue(row, "invoiced_xmje", hlDigit); + setRowScaleValue(row, "invoiced_xmjshj", hlDigit); + } + + materialPkSet.add((String)row.getCell("pk_materiel").getValue()); + } + + Map materialMeasdocMap = getUnitFromMaterial((String[])materialPkSet.toArray(new String[materialPkSet.size()])); + GridPrecisionOperator gridPrecisionOperator = new GridPrecisionOperator(bTable); + + for(int i = 0; i < rows.length; ++i) { + String materialPk = (String)rows[i].getCell("pk_materiel").getValue(); + gridPrecisionOperator.addNumPrecision("xmsl", i, (String)materialMeasdocMap.get(materialPk)); + gridPrecisionOperator.addNumPrecision("caninvoice_xmsl", i, (String)materialMeasdocMap.get(materialPk)); + gridPrecisionOperator.addNumPrecision("invoiced_xmsl", i, (String)materialMeasdocMap.get(materialPk)); + gridPrecisionOperator.addNumPrecision("invoiceing_xmsl", i, (String)materialMeasdocMap.get(materialPk)); + gridPrecisionOperator.addCurrencyPricePrecision("xmdj", i, orgLocalCurrPK); + } + + gridPrecisionOperator.processPrecision(); + } + + } + + public static Map getUnitFromMaterial(String[] materialPks) { + Map materialDecMap = new HashMap(); + + try { + if (null == materialPks || materialPks.length == 0) { + return materialDecMap; + } + + Map pkAndMaterialVOMap = ((IMaterialPubService)ServiceLocator.find(IMaterialPubService.class)).queryMaterialBaseInfoByPks(materialPks, new String[]{"pk_measdoc"}); + if (pkAndMaterialVOMap != null && pkAndMaterialVOMap.size() > 0) { + for(Map.Entry entry : pkAndMaterialVOMap.entrySet()) { + materialDecMap.put((String)entry.getKey(), ((MaterialVO)entry.getValue()).getPk_measdoc()); + } + } + } catch (Exception e) { + SSCIVMLogger.debug(e.getMessage()); + } + + return materialDecMap; + } + + public static void setViewScalaToTwo(BillCard card) throws Exception { + Form hTable = card.getHead(); + Grid bTable = card.getBody(); + Grid tspzTable = card.getGrandSon(InvoiceMainUtil.TSPZTAB); + int hlDigit = 2; + setHeadScaleValue(hTable, "jshj", hlDigit); + setHeadScaleValue(hTable, "hjje", hlDigit); + setHeadScaleValue(hTable, "hjse", hlDigit); + if (bTable != null) { + for(int i = 0; i < bTable.getModel().getRows().length; ++i) { + Row row = bTable.getModel().getRows()[i]; + if (null != row) { + setRowScaleValue(row, "xmje", hlDigit); + setRowScaleValue(row, "xmjshj", hlDigit); + setRowScaleValue(row, "se", hlDigit); + setRowScaleValue(row, "sl", hlDigit); + Object sl = row.getCell("sl").getValue(); + if (sl != null) { + UFDouble ufsl = new UFDouble(sl.toString()); + ufsl = ufsl.multiply((double)100.0F); + ufsl = ufsl.setScale(2, 4); + row.getCell("sl").setValue(ufsl); + } + + UFDouble xmsl = (UFDouble)row.getCell("xmsl").getValue(); + UFDouble xmdj = (UFDouble)row.getCell("xmdj").getValue(); + xmsl.setTrimZero(true); + xmdj.setTrimZero(true); + int xmdjScale = xmdj != null && xmdj.toString().split("\\.") != null && xmdj.toString().split("\\.").length > 1 ? xmdj.toString().split("\\.")[1].length() : 0; + int xmslScale = xmsl != null && xmsl.toString().split("\\.") != null && xmsl.toString().split("\\.").length > 1 ? xmsl.toString().split("\\.")[1].length() : 0; + if (xmdjScale < 2) { + xmdjScale = 2; + } + + setRowScaleValue(row, "xmdj", xmdjScale); + setRowScaleValue(row, "xmsl", xmslScale); + } + } + } + + if (tspzTable != null) { + Row[] rows = tspzTable.getModel().getRows(); + + for(int i = 0; i < rows.length; ++i) { + Row row = rows[i]; + if (null != row) { + setRowScaleValue(row, "hjje", hlDigit); + setRowScaleValue(row, "kce", hlDigit); + setRowScaleValue(row, "bckcje", hlDigit); + setRowScaleValue(row, "kce", hlDigit); + } + } + } + + } + + public static void setViewScala(Grid grid) throws Exception { + Row[] rows = grid.getModel().getRows(); + int hlDigit = 2; + if (rows != null && rows.length > 0) { + String orgLocalCurrPK = getIVApplicationService().getOrgLocalCurrPK((String)rows[0].getCell("pk_org").getValue()); + if (orgLocalCurrPK != null) { + hlDigit = getIVApplicationService().getCurrDigit(orgLocalCurrPK); + } + + for(Row row : rows) { + setRowScaleValue(row, "hjje", hlDigit); + setRowScaleValue(row, "hjse", hlDigit); + setRowScaleValue(row, "jshj", hlDigit); + setRowScaleValue(row, "caninvoice_hjje", hlDigit); + setRowScaleValue(row, "caninvoice_hjse", hlDigit); + setRowScaleValue(row, "caninvoice_jshj", hlDigit); + setRowScaleValue(row, "invoiceing_hjje", hlDigit); + setRowScaleValue(row, "invoiced_hjse", hlDigit); + setRowScaleValue(row, "invoiced_jshj", hlDigit); + setRowScaleValue(row, "invoiced_hjje", hlDigit); + setRowScaleValue(row, "invoiced_hjse", hlDigit); + setRowScaleValue(row, "invoiced_jshj", hlDigit); + } + } + + } + + public static void setViewScalaToTwo(Grid grid) throws Exception { + Row[] rows = grid.getModel().getRows(); + int hlDigit = 2; + if (rows != null && rows.length > 0) { + for(Row row : rows) { + setRowScaleValue(row, "hjje", hlDigit); + setRowScaleValue(row, "hjse", hlDigit); + setRowScaleValue(row, "jshj", hlDigit); + } + } + + } + + public static BillCard valueChanged(Object afterEditEvent, JSONObject object) throws Exception { + String tableID = (String)object.get("tableID"); + String changeType = (String)object.get("type"); + Form hTable = null; + Grid bTable = null; + String field = null; + Object newValue = null; + Row row = null; + IVApplicationAggVO vo = null; + String pageCode = null; + if ("headcard".equals(changeType)) { + CardHeadAfterEditEvent headEvent = (CardHeadAfterEditEvent)afterEditEvent; + hTable = headEvent.getCard().getHead(); + bTable = headEvent.getCard().getBody(); + field = headEvent.getAttrcode(); + newValue = headEvent.getNewvalue().getValue(); + } else if ("bodycard".equals(changeType)) { + CardBodyAfterEditEvent bodyEvent = (CardBodyAfterEditEvent)afterEditEvent; + pageCode = bodyEvent.getCard().getPageid(); + hTable = bodyEvent.getCard().getHead(); + BillCard billcard = bodyEvent.getCard(); + new BillCardOperator(pageCode); + BillCardConvertProcessor processor = new BillCardConvertProcessor(); + vo = (IVApplicationAggVO)processor.fromBillCard(billcard); + bTable = bodyEvent.getCard().getBody(); + field = bodyEvent.getAttrcode(); + newValue = bodyEvent.getChangedrows()[0].getNewvalue() == null ? "" : bodyEvent.getChangedrows()[0].getNewvalue().getValue(); + row = bodyEvent.getRow(bodyEvent.getChangedrows()[0]); + } else if ("form".equals(changeType)) { + FormAfterEditEvent formEvent = (FormAfterEditEvent)afterEditEvent; + hTable = formEvent.getForm(); + field = formEvent.getAttrcode(); + newValue = formEvent.getNewvalue(); + } else if ("grid".equals(changeType)) { + GridAfterEditEvent gridEvent = (GridAfterEditEvent)afterEditEvent; + bTable = gridEvent.getGrid(); + field = gridEvent.getAttrcode(); + newValue = gridEvent.getChangedrows()[0].getNewvalue(); + row = gridEvent.getRow(gridEvent.getChangedrows()[0]); + } + + if ("head".equals(tableID) && "pk_org".equals(field)) { + String pk_org = String.valueOf(newValue); + afterEditHeadPKORGFY(hTable, bTable, pk_org); + } else if ("head".equals(tableID) && "pk_customer".equals(field)) { + String pk_customer = String.valueOf(newValue); + afterEditHeadPKCUSTOMER(hTable, bTable, pk_customer); + } else if ("head".equals(tableID) && "gmf_zh".equals(field)) { + String gmf_zh = String.valueOf(newValue); + afterEditHeadGMFZH(hTable, bTable, gmf_zh); + } else if ("head".equals(tableID) && "pk_customer_v".equals(field)) { + String pk_customer_v = String.valueOf(newValue); + afterEditHeadPKCUSTOMERV(hTable, bTable, pk_customer_v); + } else if ("head".equals(tableID) && "gmf_dh".equals(field)) { + String gmf_dh = String.valueOf(newValue); + Object gmf_dz_old = getHeadValue(hTable, "gmf_dz"); + String gmf_dz = gmf_dz_old == null ? "" : gmf_dz_old.toString(); + afterEditHeadGMFDHDZ(hTable, gmf_dh, gmf_dz); + } else if ("head".equals(tableID) && "gmf_dz".equals(field)) { + String gmf_dz = String.valueOf(newValue); + Object gmf_dh_old = getHeadValue(hTable, "gmf_dh"); + String gmf_dh = gmf_dh_old == null ? "" : gmf_dh_old.toString(); + afterEditHeadGMFDHDZ(hTable, gmf_dh, gmf_dz); + } else if ("head".equals(tableID) && "gmf_yh".equals(field)) { + String gmf_yh = String.valueOf(newValue); + Object gmf_zhh_old = getHeadValue(hTable, "gmf_zhh"); + String gmf_zhh = gmf_zhh_old == null ? "" : gmf_zhh_old.toString(); + afterEditHeadGMFYHZHH(hTable, gmf_yh, gmf_zhh); + } else if ("head".equals(tableID) && "gmf_zhh".equals(field)) { + String gmf_zhh = String.valueOf(newValue); + Object gmf_yh_old = getHeadValue(hTable, "gmf_yh"); + String gmf_yh = gmf_yh_old == null ? "" : gmf_yh_old.toString(); + afterEditHeadGMFYHZHH(hTable, gmf_yh, gmf_zhh); + } else if ("head".equals(tableID) && "pk_supplier".equals(field)) { + String pk_supplier = String.valueOf(newValue); + afterEditHeadPKSUPPLIER(hTable, bTable, pk_supplier); + } else if ("head".equals(tableID) && "pk_supplier_v".equals(field)) { + String pk_supplier_v = String.valueOf(newValue); + afterEditHeadPKSUPPLIERV(hTable, bTable, pk_supplier_v); + } else if ("head".equals(tableID) && "xsf_dz".equals(field)) { + String xsf_dz = String.valueOf(newValue); + String xsf_dh = getHeadValue(hTable, "xsf_dh") == null ? "" : (String)getHeadValue(hTable, "xsf_dh"); + afterEditHeadXSFDZDH(hTable, xsf_dz, xsf_dh); + } else if ("head".equals(tableID) && "xsf_dh".equals(field)) { + String xsf_dh = String.valueOf(newValue); + String xsf_dz = getHeadValue(hTable, "xsf_dz") == null ? "" : (String)getHeadValue(hTable, "xsf_dz"); + afterEditHeadXSFDZDH(hTable, xsf_dz, xsf_dh); + } else if ("head".equals(tableID) && "xsf_yh".equals(field)) { + String xsf_yh = String.valueOf(newValue); + String xsf_zhh = getHeadValue(hTable, "xsf_zhh") == null ? "" : (String)getHeadValue(hTable, "xsf_zhh"); + afterEditHeadXSFYHZHH(hTable, xsf_yh, xsf_zhh); + } else if ("head".equals(tableID) && "xsf_zhh".equals(field)) { + String xsf_zhh = String.valueOf(newValue); + String xsf_yh = getHeadValue(hTable, "xsf_yh") == null ? "" : (String)getHeadValue(hTable, "xsf_yh"); + afterEditHeadXSFYHZHH(hTable, xsf_yh, xsf_zhh); + } else if ("head".equals(tableID) && "pk_freecustom".equals(field)) { + String pk_freeCustom = String.valueOf(newValue); + afterEditHeadFreeCustom(hTable, bTable, pk_freeCustom); + } + + if ("body".equals(tableID) && field.equals("xmdj")) { + afterEditBodyMoney(hTable, bTable, row, field); + totalBodyMoney(hTable, bTable); + } else if ("body".equals(tableID) && field.equals("sl")) { + afterEditBodyMoney(hTable, bTable, row, field); + totalBodyMoney(hTable, bTable); + } else if ("body".equals(tableID) && field.equals("xmje")) { + afterEditBodyMoney(hTable, bTable, row, field); + totalBodyMoney(hTable, bTable); + } else if ("body".equals(tableID) && field.equals("se")) { + afterEditBodyMoney(hTable, bTable, row, field); + totalBodyMoney(hTable, bTable); + } else if ("body".equals(tableID) && field.equals("xmsl")) { + afterEditBodyMoney(hTable, bTable, row, field); + totalBodyMoney(hTable, bTable); + } else if ("body".equals(tableID) && field.equals("xmjshj")) { + afterEditBodyMoney(hTable, bTable, row, field); + totalBodyMoney(hTable, bTable); + } else if ("body".equals(tableID) && field.equals("pk_materiel")) { + afterEditBodyMateriel(hTable, bTable, row, field); + } else if ("body".equals(tableID) && field.equals("zkje")) { + bTable = afterEditBodyZkje(vo, pageCode, bTable, row, field); + totalBodyMoney(hTable, bTable); + } else if ("body".equals(tableID) && field.equals("fphxz")) { + afterEditBodyFphxz(bTable, row, field); + } else if ("body".equals(tableID) && field.equals("taxcode")) { + afterEditBodyTaxcode(hTable, bTable, row, field); + } + + BillCard billcard = new BillCard(); + billcard.setHead(hTable); + billcard.setBody(bTable); + return billcard; + } + + private static void afterEditHeadGMFYHZHH(Form hTable, String gmf_yh, String gmf_zhh) { + setHeadValue(hTable, "gmf_yhzh", gmf_yh + gmf_zhh); + } + + private static void afterEditHeadGMFDHDZ(Form hTable, String gmf_dh, String gmf_dz) { + setHeadValue(hTable, "gmf_dzdh", gmf_dz + gmf_dh); + } + + public static void afterEditHeadXSFDZDH(Form hTable, String xsf_dz, String xsf_dh) { + setHeadValue(hTable, "xsf_dzdh", xsf_dz + xsf_dh); + } + + public static void afterEditHeadXSFYHZHH(Form hTable, String xsf_yh, String xsf_zhh) { + setHeadValue(hTable, "xsf_yhzh", xsf_yh + xsf_zhh); + } + + public static void afterEditHeadPKORGFY(Form hTable, Grid bTable, String pk_org) throws Exception { + String pk_org_v = getIVApplicationService().getOrgVersion(IVApplicationHeadVO.class.toString().substring(6), "pk_org", pk_org); + setHeadValue(hTable, "pk_org_v", pk_org_v); + String orgCode = ""; + OrgVO orgVo = (OrgVO)((IUAPQueryBS)ServiceLocator.find(IUAPQueryBS.class)).retrieveByPK(OrgVO.class, pk_org); + if (orgVo != null) { + orgCode = orgVo.getCode(); + } + + setHeadValue(hTable, "orgcode", orgCode); + setHeadValue(hTable, "pk_dept", (Object)null); + setHeadValue(hTable, "xsf_khh", (Object)null); + setHeadValue(hTable, "xsf_zh", (Object)null); + setHeadValue(hTable, "xsf_dzdh", (Object)null); + setHeadValue(hTable, "xsf_mc", (Object)null); + setHeadValue(hTable, "xsf_nsrsbh", (Object)null); + setHeadValue(hTable, "xsf_yhzh", (Object)null); + setHeadValue(hTable, "gmf_khh", (Object)null); + setHeadValue(hTable, "gmf_zh", (Object)null); + setHeadValue(hTable, "pk_customer", (Object)null); + setHeadValue(hTable, "pk_customer_v", (Object)null); + setHeadValue(hTable, "pk_customer_v", (Object)null); + setHeadValue(hTable, "kpr", (Object)null); + setHeadValue(hTable, "gmf_zh", (Object)null); + setHeadValue(hTable, "gmf_khh", (Object)null); + setHeadValue(hTable, "gmf_yhzh", (Object)null); + setHeadValue(hTable, "gmf_nsrsbh", (Object)null); + setHeadValue(hTable, "gmf_mc", (Object)null); + setHeadValue(hTable, "gmf_dzdh", (Object)null); + if (StringUtils.isNotEmpty(pk_org) && !"null".equals(pk_org)) { + Integer paramValue = SysInitQuery.getParaInt(pk_org, "SSCIVA01"); + setHeadValue(hTable, "kpfs", paramValue == null ? IVAplocationKPFS.ZLKP.toIntValue() : paramValue); + } + + setBodyValue(bTable, "pk_org", pk_org); + } + + public static void afterEditHeadPKSUPPLIERV(Form hTable, Grid bTable, String pk_supplier_v) throws Exception { + if (StringUtils.isEmpty(pk_supplier_v)) { + setHeadValue(hTable, "pk_supplier", (Object)null); + afterEditHeadPKSUPPLIER(hTable, bTable, (String)null); + } else { + Map map = ((ISupplierPubService)ServiceLocator.find(ISupplierPubService.class)).getSupplierOIDByVid(new String[]{pk_supplier_v}); + setHeadValue(hTable, "pk_supplier", map.get(pk_supplier_v)); + afterEditHeadPKSUPPLIER(hTable, bTable, (String)map.get(pk_supplier_v)); + } + + } + + public static void afterEditHeadPKSUPPLIER(Form hTable, Grid bTable, String pk_supplier) throws Exception { + SupplierVO[] supplierVos = ((ISupplierPubService)ServiceLocator.find(ISupplierPubService.class)).getSupplierVO(new String[]{pk_supplier}, new String[]{"taxpayerid", "name", "corpaddress", "tel1", "tel2", "tel3"}); + setHeadValue(hTable, "xsf_nsrsbh", (Object)null); + setHeadValue(hTable, "xsf_mc", (Object)null); + setHeadValue(hTable, "xsf_dzdh", (Object)null); + setHeadValue(hTable, "xsf_zh", (Object)null); + setHeadValue(hTable, "xsf_khh", (Object)null); + setHeadValue(hTable, "xsf_yhzh", (Object)null); + setHeadValue(hTable, "pk_supplier_v", (Object)null); + setHeadValue(hTable, "xsf_dz", (Object)null); + setHeadValue(hTable, "xsf_dh", (Object)null); + setHeadValue(hTable, "xsf_yh", (Object)null); + setHeadValue(hTable, "xsf_zhh", (Object)null); + if (supplierVos != null && supplierVos.length > 0) { + SupplierVO suppliervo = supplierVos[0]; + Map map = new HashMap(); + UFDate sqrq = new UFDate((String)getHeadValue(hTable, "preparedate")); + map.put(suppliervo.getPk_supplier(), sqrq); + Map idmap = ((ISupplierPubService)ServiceLocator.find(ISupplierPubService.class)).getSupplierLastVIDByOidAndDate(map); + setHeadValue(hTable, "pk_supplier_v", idmap.get(suppliervo.getPk_supplier())); + setHeadValue(hTable, "xsf_nsrsbh", suppliervo.getTaxpayerid()); + setHeadValue(hTable, "xsf_mc", suppliervo.getName()); + String addressPk = suppliervo.getCorpaddress(); + AddressVO addressVO = ((IAddressPubService)ServiceLocator.find(IAddressPubService.class)).getAddressVOByPk(addressPk); + String dz = ""; + if (addressVO != null) { + dz = addressVO.getDetailinfo(); + } + + String dh = suppliervo.getTel1() == null ? (suppliervo.getTel2() == null ? (suppliervo.getTel3() == null ? "" : suppliervo.getTel3()) : suppliervo.getTel2()) : suppliervo.getTel1(); + setHeadValue(hTable, "xsf_dz", dz); + setHeadValue(hTable, "xsf_dh", dh); + setHeadValue(hTable, "xsf_dzdh", dz + dh); + List custbankVOS = (List)((IUAPQueryBS)ServiceLocator.find(IUAPQueryBS.class)).retrieveByClause(CustbankVO.class, "pk_cust='" + suppliervo.getPk_supplier() + "'"); + if (custbankVOS != null && custbankVOS.size() > 0) { + String pk_bankaccbas = ((CustbankVO)custbankVOS.get(0)).getPk_bankaccbas(); + String pk_bankaccsub = ((CustbankVO)custbankVOS.get(0)).getPk_bankaccsub(); + BankAccbasVO[] bankAccbasVOS = ((IBankAccBaseInfoQueryService)ServiceLocator.find(IBankAccBaseInfoQueryService.class)).queryBankAccBasVOByPks(new String[]{pk_bankaccbas}, false); + if (bankAccbasVOS != null && bankAccbasVOS.length > 0 && pk_bankaccsub != null) { + BankAccbasVO bankAccbasVO = bankAccbasVOS[0]; + BankdocVO bankdocVO = ((IBankdocQueryService)ServiceLocator.find(IBankdocQueryService.class)).getBankdocVOByPk(bankAccbasVO.getPk_bankdoc()); + setHeadValue(hTable, "gmf_zh", pk_bankaccsub); + setHeadValue(hTable, "gmf_khh", bankAccbasVO.getPk_bankdoc()); + String xsf_yh = bankdocVO.getName() == null ? "" : bankdocVO.getName(); + String xsf_zh = bankAccbasVO.getBankaccsub()[0].getAccnum() == null ? "" : bankAccbasVO.getBankaccsub()[0].getAccnum(); + setHeadValue(hTable, "xsf_yh", xsf_yh); + setHeadValue(hTable, "xsf_zhh", xsf_zh); + setHeadValue(hTable, "xsf_yhzh", xsf_yh + xsf_zh); + } + } + } + + } + + public static void afterEditHeadPKCUSTOMER(Form hTable, Grid bTable, String pk_customer) throws Exception { + CustomerVO[] customerVoS = ((ICustomerPubService)ServiceLocator.find(ICustomerPubService.class)).getCustomerVO(new String[]{pk_customer}, new String[]{"name", "email", "corpaddress", "tel1", "tel2", "tel3", "taxpayerid"}); + Map map = new HashMap(); + UFDate sqrq = new UFDate((String)getHeadValue(hTable, "preparedate")); + map.put(pk_customer, sqrq); + Map idMap = ((ICustomerPubService)ServiceLocator.find(ICustomerPubService.class)).getCustomerLastVIDByOidAndDate(map); + setHeadValue(hTable, "gmf_nsrsbh", (Object)null); + setHeadValue(hTable, "gmf_mc", (Object)null); + setHeadValue(hTable, "gmf_dzdh", (Object)null); + setHeadValue(hTable, "gmf_zh", (Object)null); + setHeadValue(hTable, "gmf_khh", (Object)null); + setHeadValue(hTable, "gmf_yhzh", (Object)null); + setHeadValue(hTable, "pk_customer_v", (Object)null); + setHeadValue(hTable, "gmf_dz", (Object)null); + setHeadValue(hTable, "gmf_dh", (Object)null); + setHeadValue(hTable, "gmf_yh", (Object)null); + setHeadValue(hTable, "gmf_zhh", (Object)null); + if (customerVoS != null && customerVoS.length > 0) { + setHeadValue(hTable, "pk_customer_v", idMap.get(pk_customer)); + String pk_org = (String)getHeadValue(hTable, "pk_org"); + if (pk_org == null) { + return; + } + + CusttaxVO taxvo = ((ICustTaxQueryService)NCLocator.getInstance().lookup(ICustTaxQueryService.class)).queryCusttaxVOByOrgID(pk_org, pk_customer); + if (taxvo == null) { + return; + } + + setHeadValue(hTable, "fplx", taxvo.getInvoiceclass()); + setHeadValue(hTable, "gmf_nsrsbh", taxvo.getTaxpayerid()); + setHeadValue(hTable, "gmf_mc", taxvo.getBuyername()); + String var10002 = taxvo.getBuyeraddress() == null ? "" : taxvo.getBuyeraddress(); + setHeadValue(hTable, "gmf_dzdh", var10002 + " " + (taxvo.getBuyertel() == null ? "" : taxvo.getBuyertel())); + var10002 = taxvo.getBuyerbankname() == null ? "" : taxvo.getBuyerbankname(); + setHeadValue(hTable, "gmf_yhzh", var10002 + (taxvo.getBuyerbanknum() == null ? "" : taxvo.getBuyerbanknum())); + setHeadValue(hTable, "email", taxvo.getReceivermail()); + setHeadValue(hTable, "sms", taxvo.getReceivertel()); + setHeadValue(hTable, "gmf_dz", taxvo.getBuyeraddress() == null ? "" : taxvo.getBuyeraddress()); + setHeadValue(hTable, "gmf_dh", taxvo.getBuyertel() == null ? "" : taxvo.getBuyertel()); + setHeadValue(hTable, "gmf_yh", taxvo.getBuyerbankname() == null ? "" : taxvo.getBuyerbankname()); + setHeadValue(hTable, "gmf_zhh", taxvo.getBuyerbanknum() == null ? "" : taxvo.getBuyerbanknum()); + } + + } + + public static void afterEditHeadFreeCustom(Form hTable, Grid bTable, String pk_FreeCustom) throws Exception { + setHeadValue(hTable, "gmf_nsrsbh", (Object)null); + setHeadValue(hTable, "gmf_mc", (Object)null); + setHeadValue(hTable, "gmf_dzdh", (Object)null); + setHeadValue(hTable, "gmf_yhzh", (Object)null); + setHeadValue(hTable, "gmf_dz", (Object)null); + setHeadValue(hTable, "gmf_dh", (Object)null); + setHeadValue(hTable, "gmf_yh", (Object)null); + setHeadValue(hTable, "gmf_zhh", (Object)null); + setHeadValue(hTable, "xsf_nsrsbh", (Object)null); + setHeadValue(hTable, "xsf_mc", (Object)null); + setHeadValue(hTable, "xsf_dzdh", (Object)null); + setHeadValue(hTable, "xsf_yhzh", (Object)null); + setHeadValue(hTable, "xsf_dz", (Object)null); + setHeadValue(hTable, "xsf_dh", (Object)null); + setHeadValue(hTable, "xsf_yh", (Object)null); + setHeadValue(hTable, "xsf_zhh", (Object)null); + if (StringUtils.isNotEmpty(pk_FreeCustom)) { + String pk_customer = (String)getHeadValue(hTable, "pk_customer"); + String pk_supplier = (String)getHeadValue(hTable, "pk_supplier"); + FreeCustomVO[] vos = ((IFreeCustQueryService)ServiceLocator.find(IFreeCustQueryService.class)).queryFreeCustVOsByCondition("pk_freecustom='" + pk_FreeCustom + "'"); + FreeCustomVO vo = vos[0]; + String bankName = ""; + if (StringUtils.isNotEmpty(vo.getBank())) { + BankdocVO bankdocVO = ((IBankdocQueryService)ServiceLocator.find(IBankdocQueryService.class)).getBankdocVOByPk(vo.getBank()); + bankName = bankdocVO.getName() == null ? "" : bankdocVO.getName(); + } + + String address = vo.getAddress() == null ? "" : vo.getAddress(); + String tel = vo.getLinkphone() == null ? "" : vo.getLinkphone(); + String accNum = vo.getBankaccount() == null ? "" : vo.getBankaccount(); + if (StringUtils.isNotEmpty(pk_customer)) { + setHeadValue(hTable, "gmf_nsrsbh", vo.getPersoncode()); + setHeadValue(hTable, "gmf_mc", vo.getName()); + setHeadValue(hTable, "gmf_dzdh", address + tel); + setHeadValue(hTable, "gmf_yhzh", bankName + accNum); + setHeadValue(hTable, "gmf_dz", address); + setHeadValue(hTable, "gmf_dh", tel); + setHeadValue(hTable, "gmf_yh", bankName); + setHeadValue(hTable, "gmf_zhh", accNum); + } + + if (StringUtils.isNotEmpty(pk_supplier)) { + setHeadValue(hTable, "xsf_nsrsbh", vo.getPersoncode()); + setHeadValue(hTable, "xsf_mc", vo.getName()); + setHeadValue(hTable, "xsf_dzdh", address + tel); + setHeadValue(hTable, "xsf_yhzh", bankName + accNum); + setHeadValue(hTable, "xsf_dz", address); + setHeadValue(hTable, "xsf_dh", tel); + setHeadValue(hTable, "xsf_yh", bankName); + setHeadValue(hTable, "xsf_zhh", accNum); + } + } + + } + + public static void afterEditHeadPKCUSTOMERV(Form hTable, Grid bTable, String pk_customer_v) throws Exception { + if (pk_customer_v != null && !"".equals(pk_customer_v)) { + Map idMap = ((ICustomerPubService)NCLocator.getInstance().lookup(ICustomerPubService.class)).getCustomerOIDByVid(new String[]{pk_customer_v}); + setHeadValue(hTable, "pk_customer", idMap.get(pk_customer_v)); + afterEditHeadPKCUSTOMER(hTable, bTable, (String)idMap.get(pk_customer_v)); + } else { + setHeadValue(hTable, "pk_customer", (Object)null); + afterEditHeadPKCUSTOMER(hTable, bTable, ""); + } + + } + + public static void afterEditHeadGMFZH(Form hTable, Grid bTable, String gmf_zh) throws Exception { + BankAccSubVO[] bankAccSubVOS = ((IBankAccSubInfoQueryService)ServiceLocator.find(IBankAccSubInfoQueryService.class)).querySubInfosByPKs(new String[]{gmf_zh}); + String pk_customer = (String)getHeadValue(hTable, "pk_customer"); + String pk_supplier = (String)getHeadValue(hTable, "pk_supplier"); + if (bankAccSubVOS != null && bankAccSubVOS.length > 0) { + BankAccbasVO[] bankAccbasVOS = ((IBankAccBaseInfoQueryService)ServiceLocator.find(IBankAccBaseInfoQueryService.class)).queryBankAccBasVOByPks(new String[]{bankAccSubVOS[0].getPk_bankaccbas()}, false); + if (bankAccbasVOS != null && bankAccbasVOS.length > 0) { + if (gmf_zh != null) { + BankAccbasVO bankAccbasVO = bankAccbasVOS[0]; + BankdocVO bankdocVO = ((IBankdocQueryService)ServiceLocator.find(IBankdocQueryService.class)).getBankdocVOByPk(bankAccbasVO.getPk_bankdoc()); + if (StringUtils.isNotEmpty(pk_customer)) { + setHeadValue(hTable, "gmf_zh", gmf_zh); + setHeadValue(hTable, "gmf_khh", bankAccbasVO.getPk_bankdoc()); + String var10002 = bankdocVO.getName() == null ? "" : bankdocVO.getName(); + setHeadValue(hTable, "gmf_yhzh", var10002 + (bankAccbasVO.getBankaccsub()[0].getAccnum() == null ? "" : bankAccbasVO.getBankaccsub()[0].getAccnum())); + setHeadValue(hTable, "gmf_yh", bankdocVO.getName() == null ? "" : bankdocVO.getName()); + setHeadValue(hTable, "gmf_zhh", bankAccbasVO.getBankaccsub()[0].getAccnum() == null ? "" : bankAccbasVO.getBankaccsub()[0].getAccnum()); + } + + if (StringUtils.isNotEmpty(pk_supplier)) { + setHeadValue(hTable, "xsf_zh", gmf_zh); + setHeadValue(hTable, "xsf_khh", bankAccbasVO.getPk_bankdoc()); + String var10 = bankdocVO.getName() == null ? "" : bankdocVO.getName(); + setHeadValue(hTable, "xsf_yhzh", var10 + (bankAccbasVO.getBankaccsub()[0].getAccnum() == null ? "" : bankAccbasVO.getBankaccsub()[0].getAccnum())); + setHeadValue(hTable, "xsf_yh", bankdocVO.getName() == null ? "" : bankdocVO.getName()); + setHeadValue(hTable, "xsf_zhh", bankAccbasVO.getBankaccsub()[0].getAccnum() == null ? "" : bankAccbasVO.getBankaccsub()[0].getAccnum()); + } + } else { + setHeadValue(hTable, "gmf_zh", (Object)null); + setHeadValue(hTable, "gmf_khh", (Object)null); + setHeadValue(hTable, "gmf_yhzh", (Object)null); + setHeadValue(hTable, "gmf_yh", (Object)null); + setHeadValue(hTable, "gmf_zhh", (Object)null); + setHeadValue(hTable, "xsf_zh", (Object)null); + setHeadValue(hTable, "xsf_khh", (Object)null); + setHeadValue(hTable, "xsf_yhzh", (Object)null); + setHeadValue(hTable, "xsf_yh", (Object)null); + setHeadValue(hTable, "xsf_zhh", (Object)null); + } + } + } + + } + + public static void afterEditBodyMateriel(Form hTable, Grid bTable, Row row, String cell) throws Exception { + String pk_materiel = (String)getBodyValueByRow(row, "pk_materiel"); + MaterialVO[] materialVOS = ((IMaterialBaseInfoQueryService)ServiceLocator.find(IMaterialBaseInfoQueryService.class)).queryDataByPks(new String[]{pk_materiel}); + if (materialVOS != null && materialVOS.length > 0 && materialVOS[0] != null) { + MaterialVO materialVO = materialVOS[0]; + setBodyValueByRow(row, "xmmc", materialVO.getName()); + setBodyValueByRow(row, "spbm", materialVO.getCode()); + Object var10002 = materialVO.getAttributeValue("materialspec") == null ? "" : materialVO.getAttributeValue("materialspec"); + setBodyValueByRow(row, "ggxh", "" + var10002 + (materialVO.getAttributeValue("materialtype") == null ? "" : materialVO.getAttributeValue("materialtype"))); + IVApplicationQueryService ivservice = (IVApplicationQueryService)ServiceLocator.find(IVApplicationQueryService.class); + MeasdocVO[] measdocVOS = ivservice.queryMeasdocByPk(materialVO.getPk_measdoc()); + if (measdocVOS != null && measdocVOS.length > 0) { + String name = MultiLangUtil.getSuperVONameOfCurrentLang(measdocVOS[0], "name", (String)null); + setBodyValueByRow(row, "dw", name); + } else { + setBodyValueByRow(row, "dw", (Object)null); + } + + String pk_org = getHeadValue(hTable, "pk_org") == null ? null : (String)getHeadValue(hTable, "pk_org"); + String pk_customer = getHeadValue(hTable, "pk_customer") == null ? null : (String)getHeadValue(hTable, "pk_customer"); + UFDate date = getHeadValue(hTable, "preparedate") == null ? null : new UFDate((String)getHeadValue(hTable, "preparedate")); + TaxcodeTaxrateQueryVO taxQueryVO = new TaxcodeTaxrateQueryVO(); + taxQueryVO.setReptaxcountryid("0001Z010000000079UJJ"); + taxQueryVO.setPursaletype(1); + taxQueryVO.setIstriangletrade(UFBoolean.FALSE); + taxQueryVO.setPk_org(pk_org); + taxQueryVO.setMaterialid(pk_materiel); + taxQueryVO.setCustomerid(pk_customer); + taxQueryVO.setBusinessDate(date); + TaxrateVO[] vos = TaxcodeUtil.getInstance().getTaxratesByTaxcodeCondAndDates(new TaxcodeTaxrateQueryVO[]{taxQueryVO}); + if (vos != null && vos.length > 0 && vos[0] != null) { + setBodyValueByRow(row, "taxcode", vos[0].getPk_taxcode()); + setBodyValueByRow(row, "sl", vos[0].getTaxrate()); + afterEditBodyMoney(hTable, bTable, row, "sl"); + if (vos[0].getTaxrate().compareTo(UFDouble.ZERO_DBL) == 0) { + setBodyValueByRow(row, "lslbs", vos[0].getZero_tax_tag()); + } + } + } else { + setBodyValueByRow(row, "xmmc", (Object)null); + setBodyValueByRow(row, "ggxh", (Object)null); + setBodyValueByRow(row, "dw", (Object)null); + } + + } + + public static void afterEditBodyFphxz(Grid bTable, Row row, String cell) throws Exception { + Integer fphxz = getBodyValueByRow(row, "fphxz") == null ? null : Integer.parseInt(String.valueOf(getBodyValueByRow(row, "fphxz"))); + if (fphxz == null || fphxz != IVAplocationFPXZ.PFPXZ_BZKH.toIntValue()) { + setBodyValueByRow(row, "zkhhh", (Object)null); + } + + } + + public static void afterEditBodyTaxcode(Form hTable, Grid bTable, Row row, String cell) throws Exception { + String taxcode = getBodyValueByRow(row, "taxcode") == null ? null : String.valueOf(getBodyValueByRow(row, "taxcode")); + if (taxcode == null) { + setBodyValueByRow(row, "sl", new UFDouble((double)0.0F)); + } else { + UFDate date = new UFDate((String)getHeadValue(hTable, "preparedate")); + TaxrateQueryVO queryvo = new TaxrateQueryVO(); + queryvo.setTaxcodeid(taxcode); + queryvo.setBusinessDate(date); + TaxrateVO[] vos = TaxcodeUtil.getInstance().getTaxratesByTaxcodeIdAndDates(new TaxrateQueryVO[]{queryvo}); + if (vos != null && vos.length > 0 && vos[0] != null) { + setBodyValueByRow(row, "sl", vos[0].getTaxrate()); + if (vos[0].getTaxrate().compareTo(UFDouble.ZERO_DBL) == 0) { + setBodyValueByRow(row, "lslbs", vos[0].getZero_tax_tag()); + } else { + setBodyValueByRow(row, "lslbs", (Object)null); + } + } else { + setBodyValueByRow(row, "sl", new UFDouble((double)0.0F)); + } + } + + afterEditBodyMoney(hTable, bTable, row, "sl"); + } + + public static void afterEditBodyMoney(Form hTable, Grid bTable, Row row, String cell) throws Exception { + if (null != row) { + UFDouble xmdj = getBodyValueByRow(row, "xmdj") == null ? new UFDouble((double)0.0F) : new UFDouble(String.valueOf(getBodyValueByRow(row, "xmdj"))); + UFDouble xmsl = getBodyValueByRow(row, "xmsl") == null ? new UFDouble((double)0.0F) : new UFDouble(String.valueOf(getBodyValueByRow(row, "xmsl"))); + UFDouble sl = getBodyValueByRow(row, "sl") == null ? new UFDouble((double)0.0F) : new UFDouble(String.valueOf(getBodyValueByRow(row, "sl"))); + UFDouble xmje = getBodyValueByRow(row, "xmje") == null ? new UFDouble((double)0.0F) : new UFDouble(String.valueOf(getBodyValueByRow(row, "xmje"))); + UFDouble se = getBodyValueByRow(row, "se") == null ? new UFDouble((double)0.0F) : new UFDouble(String.valueOf(getBodyValueByRow(row, "se"))); + UFDouble xmjshj = getBodyValueByRow(row, "xmjshj") == null ? new UFDouble((double)0.0F) : new UFDouble(String.valueOf(getBodyValueByRow(row, "xmjshj"))); + int scale = 2; + String pk_org = toString(getBodyValueByRow(row, "pk_org")); + String orgLocalCurrPK = getIVApplicationService().getOrgLocalCurrPK(pk_org); + if (orgLocalCurrPK != null) { + scale = getIVApplicationService().getCurrDigit(orgLocalCurrPK); + } + + sl = sl.multiply(new UFDouble(0.01)); + if (sl.compareTo(new UFDouble((double)0.0F)) >= 0 && sl.compareTo(new UFDouble(1)) <= 0) { + if (!"xmdj".equals(cell) && !"xmsl".equals(cell)) { + if ("xmje".equals(cell)) { + if (xmsl.compareTo(new UFDouble((double)0.0F)) != 0) { + xmdj = xmje.compareTo(new UFDouble((double)0.0F)) == 0 ? new UFDouble((double)0.0F) : xmje.div(xmsl); + setBodyValueByRow(row, "xmdj", xmdj); + } + + if (sl.compareTo(new UFDouble((double)0.0F)) > 0) { + UFDouble var30 = xmje.div(new UFDouble(1)).multiply(sl); + se = var30.setScale(scale, 4); + setBodyValueByRow(row, "se", se); + } + + UFDouble var33 = xmje.add(se); + xmjshj = var33.setScale(scale, 4); + setBodyValueByRow(row, "xmjshj", xmjshj); + } else if ("sl".equals(cell)) { + UFDouble var25 = xmjshj.compareTo(new UFDouble((double)0.0F)) == 0 ? new UFDouble((double)0.0F) : xmjshj.div(sl.add(new UFDouble(1))).multiply(new UFDouble(1)); + xmje = var25.setScale(scale, 4); + setBodyValueByRow(row, "xmje", xmje); + UFDouble var31 = xmjshj.sub(xmje); + se = var31.setScale(scale, 4); + setBodyValueByRow(row, "se", se); + if (xmsl.compareTo(new UFDouble((double)0.0F)) != 0 && xmje.compareTo(new UFDouble((double)0.0F)) != 0) { + xmdj = xmje.div(xmsl); + setBodyValueByRow(row, "xmdj", xmdj); + } + + setBodyValueByRow(row, "lslbs", (Object)null); + if (sl.compareTo(UFDouble.ZERO_DBL) == 0) { + String taxcode = getBodyValueByRow(row, "taxcode") == null ? null : String.valueOf(getBodyValueByRow(row, "taxcode")); + if (taxcode != null) { + UFDate date = new UFDate((String)getHeadValue(hTable, "preparedate")); + TaxrateQueryVO queryvo = new TaxrateQueryVO(); + queryvo.setTaxcodeid(taxcode); + queryvo.setBusinessDate(date); + TaxrateVO[] vos = TaxcodeUtil.getInstance().getTaxratesByTaxcodeIdAndDates(new TaxrateQueryVO[]{queryvo}); + if (vos != null && vos.length > 0) { + setBodyValueByRow(row, "lslbs", vos[0].getZero_tax_tag() == null ? null : "" + vos[0].getZero_tax_tag()); + } + } + } + } else if ("se".equals(cell)) { + if (xmjshj.compareTo(new UFDouble((double)0.0F)) > 0) { + UFDouble var26 = xmjshj.sub(se); + xmje = var26.setScale(scale, 4); + setBodyValueByRow(row, "xmje", xmje); + xmdj = xmsl.compareTo(new UFDouble((double)0.0F)) != 0 && xmje.compareTo(new UFDouble((double)0.0F)) != 0 ? xmje.div(xmsl) : new UFDouble((double)0.0F); + setBodyValueByRow(row, "xmdj", xmdj); + if (xmje.compareTo(new UFDouble((double)0.0F)) > 0) { + sl = se.div(xmje).multiply(new UFDouble(100)); + setBodyValueByRow(row, "sl", sl); + } + } + } else if ("xmjshj".equals(cell)) { + if (sl.compareTo(new UFDouble((double)0.0F)) != 0) { + UFDouble var27 = xmjshj.compareTo(new UFDouble((double)0.0F)) == 0 ? new UFDouble((double)0.0F) : xmjshj.div(sl.add(new UFDouble(1))).multiply(new UFDouble(1)); + xmje = var27.setScale(scale, 4); + setBodyValueByRow(row, "xmje", xmje); + UFDouble var32 = xmjshj.sub(xmje); + se = var32.setScale(scale, 4); + setBodyValueByRow(row, "se", se); + if (xmsl.compareTo(new UFDouble((double)0.0F)) != 0 && xmje.compareTo(new UFDouble((double)0.0F)) != 0) { + xmdj = xmje.div(xmsl); + setBodyValueByRow(row, "xmdj", xmdj); + } + } else { + UFDouble var28 = xmjshj.sub(se); + xmje = var28.setScale(scale, 4); + setBodyValueByRow(row, "xmje", xmje); + xmdj = xmsl.compareTo(new UFDouble((double)0.0F)) != 0 && xmje.compareTo(new UFDouble((double)0.0F)) != 0 ? xmje.div(xmsl) : new UFDouble((double)0.0F); + setBodyValueByRow(row, "xmdj", xmdj); + } + } + } else { + UFDouble var24 = xmdj.multiply(xmsl); + xmje = var24.setScale(scale, 4); + setBodyValueByRow(row, "xmje", xmje); + UFDouble var29 = xmje.div(new UFDouble(1)).multiply(sl); + se = var29.setScale(scale, 4); + setBodyValueByRow(row, "se", se); + xmjshj = xmje.add(se); + setBodyValueByRow(row, "xmjshj", xmjshj); + } + + setBodyValueByRow(row, "caninvoice_se", se.setScale(scale, 4)); + setBodyValueByRow(row, "caninvoice_xmje", xmje.setScale(scale, 4)); + setBodyValueByRow(row, "caninvoice_xmsl", xmsl); + setBodyValueByRow(row, "caninvoice_xmjshj", xmjshj.setScale(scale, 4)); + totalBodyMoney(hTable, bTable); + } else { + setBodyValueByRow(row, "sl", new UFDouble((double)0.0F)); + } + } + } + + public static Grid afterEditBodyZkje(IVApplicationAggVO vo, String pageCode, Grid bTable, Row row, String cell) throws Exception { + if (vo == null) { + return bTable; + } else { + IVApplicationBodyVO[] bodyvos = vo.getBodyVOs(); + IVApplicationBodyVO changeBody = null; + int changeIndex = 0; + + for(int i = 0; i < bodyvos.length; ++i) { + IVApplicationBodyVO bodyvo = bodyvos[i]; + String rowid = bodyvo.getAttributeValue("rowid") == null ? "" : (String)bodyvo.getAttributeValue("rowid"); + if (row.getRowid().equals(rowid)) { + changeIndex = i; + changeBody = bodyvo; + break; + } + } + + if (changeBody != null && changeBody.getXmjshj() != null && !(changeBody.getXmjshj().doubleValue() < (double)0.0F)) { + UFDouble zkje = changeBody.getZkje(); + if (zkje != null && zkje.compareTo(changeBody.getXmjshj()) >= 0) { + throw new BusinessTypeException(NCLangRes4VoTransl.getNCLangRes().getStrByID("1058ncc_0", "01058ncc-0026"), "warning"); + } else if (zkje != null && zkje.compareTo(UFDouble.ZERO_DBL) < 0) { + throw new BusinessTypeException(NCLangRes4VoTransl.getNCLangRes().getStrByID("1058ncc_0", "01058ncc-0027"), "warning"); + } else { + IVApplicationBodyVO zkhBody = null; + if (changeBody.getZkhhh() != null) { + for(IVApplicationBodyVO bodyvo : bodyvos) { + if (bodyvo.getHh() != null && bodyvo.getHh().equals(changeBody.getZkhhh())) { + zkhBody = bodyvo; + break; + } + } + } + + List newBodys = new ArrayList(); + if (zkje != null && zkje.doubleValue() != (double)0.0F) { + boolean addLine = false; + if (zkhBody == null) { + addLine = true; + zkhBody = new IVApplicationBodyVO(); + zkhBody.setStatus(VOStatus.New.intValue()); + String hh = "1"; + Set hhs = new HashSet(); + + for(IVApplicationBodyVO bodyvo : bodyvos) { + if (bodyvo.getHh() != null && bodyvo.getStatus() != VOStatus.Deleted.intValue()) { + hhs.add(bodyvo.getHh()); + } + } + + while(hhs.contains(hh)) { + int var10000 = Integer.parseInt(hh); + hh = "" + (var10000 + 1); + } + + zkhBody.setHh(hh); + changeBody.setZkhhh(hh); + zkhBody.setXmmc(changeBody.getXmmc()); + zkhBody.setGgxh(zkhBody.getGgxh()); + zkhBody.setPk_materiel(changeBody.getPk_materiel()); + zkhBody.setSpbm(changeBody.getSpbm()); + zkhBody.setXmdj(changeBody.getXmdj()); + zkhBody.setSl(changeBody.getSl()); + zkhBody.setFphxz(IVAplocationFPXZ.FPXZ_ZKH.toIntValue()); + zkhBody.setPk_group(changeBody.getPk_group()); + zkhBody.setPk_org(changeBody.getPk_org()); + zkhBody.setDw(changeBody.getDw()); + zkhBody.setZxbm(changeBody.getZxbm()); + zkhBody.setYhzcbs(changeBody.getYhzcbs()); + zkhBody.setLslbs(changeBody.getLslbs()); + zkhBody.setZzstsgl(changeBody.getZzstsgl()); + zkhBody.setSsflbm(changeBody.getSsflbm()); + zkhBody.setTaxcode(changeBody.getTaxcode()); + } + + int scale = 2; + String pk_org = toString(getBodyValueByRow(row, "pk_org")); + String orgLocalCurrPK = getIVApplicationService().getOrgLocalCurrPK(pk_org); + if (orgLocalCurrPK != null) { + scale = getIVApplicationService().getCurrDigit(orgLocalCurrPK); + } + + changeBody.setFphxz(IVAplocationFPXZ.PFPXZ_BZKH.toIntValue()); + UFDouble xmjshj = zkje.multiply((double)-1.0F); + xmjshj = xmjshj.setScale(scale, 4); + zkhBody.setXmjshj(xmjshj); + UFDouble sl = zkhBody.getSl() == null ? new UFDouble((double)0.0F) : zkhBody.getSl(); + sl = sl.multiply(new UFDouble(0.01)); + if (sl.compareTo(new UFDouble((double)0.0F)) >= 0 && sl.compareTo(new UFDouble(1)) <= 0) { + UFDouble xmje = xmjshj.compareTo(new UFDouble((double)0.0F)) == 0 ? new UFDouble((double)0.0F) : xmjshj.div(sl.add(new UFDouble(1))).multiply(new UFDouble(1)); + xmje = xmje.setScale(scale, 4); + UFDouble se = xmjshj.sub(xmje); + se = se.setScale(scale, 4); + UFDouble xmdj = new UFDouble((double)0.0F); + UFDouble xmsl = new UFDouble((double)0.0F); + zkhBody.setXmje(xmje); + zkhBody.setSe(se); + zkhBody.setXmsl(xmsl); + zkhBody.setXmdj(xmdj); + } else { + zkhBody.setSl(new UFDouble((double)0.0F)); + zkhBody.setSe(UFDouble.ZERO_DBL.setScale(scale, 4)); + zkhBody.setXmje(xmjshj); + } + + zkhBody.setCaninvoice_se(zkhBody.getSe()); + zkhBody.setCaninvoice_xmje(zkhBody.getXmje()); + zkhBody.setCaninvoice_xmjshj(zkhBody.getXmjshj()); + zkhBody.setCaninvoice_xmsl(zkhBody.getXmsl()); + + for(int i = 0; i < bodyvos.length; ++i) { + newBodys.add(bodyvos[i]); + if (addLine && i == changeIndex) { + newBodys.add(zkhBody); + } + } + } else { + for(int i = 0; i < bodyvos.length; ++i) { + if (bodyvos[i].getHh() != null && bodyvos[i].getHh().equals(changeBody.getZkhhh())) { + changeBody.setZkhhh((String)null); + changeBody.setFphxz(IVAplocationFPXZ.FPXZ_ZCH.toIntValue()); + bodyvos[i].setStatus(VOStatus.Deleted.intValue()); + } + + newBodys.add(bodyvos[i]); + } + } + + vo.setChildrenVO((CircularlyAccessibleValueObject[])newBodys.toArray(new IVApplicationBodyVO[0])); + BillCardOperator oper = new BillCardOperator(pageCode); + BillCard rocard = oper.toCard(vo); + bTable = rocard.getBody(); + return bTable; + } + } else { + return bTable; + } + } + } + + public static void totalBodyMoney(Form hTable, Grid bTable) throws Exception { + Row[] rows = bTable.getModel().getRows(); + UFDouble xmje = new UFDouble((double)0.0F); + UFDouble se = new UFDouble((double)0.0F); + UFDouble xmjshj = new UFDouble((double)0.0F); + int scale = 2; + String pk_org = toString(getHeadValue(hTable, "pk_org")); + String orgLocalCurrPK = getIVApplicationService().getOrgLocalCurrPK(pk_org); + if (orgLocalCurrPK != null) { + scale = getIVApplicationService().getCurrDigit(orgLocalCurrPK); + } + + if (rows != null && rows.length > 0) { + for(Row row : rows) { + if (VOStatus.Deleted.intValue() != row.getStatus().intValue()) { + UFDouble xmjein = getBodyValueByRow(row, "xmje") == null ? new UFDouble((double)0.0F) : new UFDouble(String.valueOf(getBodyValueByRow(row, "xmje"))); + UFDouble sein = getBodyValueByRow(row, "se") == null ? new UFDouble((double)0.0F) : new UFDouble(String.valueOf(getBodyValueByRow(row, "se"))); + UFDouble xmjshjin = getBodyValueByRow(row, "xmjshj") == null ? new UFDouble((double)0.0F) : new UFDouble(String.valueOf(getBodyValueByRow(row, "xmjshj"))); + xmje = xmje.add(xmjein); + se = se.add(sein); + xmjshj = xmjshj.add(xmjshjin); + } + } + } + + setHeadValue(hTable, "hjje", xmje.setScale(scale, 4)); + setHeadValue(hTable, "caninvoice_hjje", xmje.setScale(scale, 4)); + setHeadValue(hTable, "hjse", se.setScale(scale, 4)); + setHeadValue(hTable, "caninvoice_hjse", se.setScale(scale, 4)); + setHeadValue(hTable, "jshj", xmjshj.setScale(scale, 4)); + setHeadValue(hTable, "caninvoice_jshj", xmjshj.setScale(scale, 4)); + } + + private static void setHeadScaleValue(Form table, String itemKey, int value) { + try { + if (table.getModel() != null && table.getModel().getRows() != null && table.getModel().getRows().length > 0) { + Row row = table.getModel().getRows()[0]; + if (null != row.getCell(itemKey)) { + row.getCell(itemKey).setScale(value); + } + } + + } catch (Exception e) { + throw e; + } + } + + private static void setRowScaleValue(Row row, String itemKey, int value) { + try { + if (row != null && row.getCell(itemKey) != null) { + row.getCell(itemKey).setScale(value); + } + + } catch (Exception e) { + throw e; + } + } + + public static Object getHeadValue(Form table, String field) { + if (table != null) { + Object value = null; + Row[] rows = table.getModel().getRows(); + if (rows != null && rows.length > 0 && rows[0].getCell(field) != null && rows[0].getCell(field).getValue() != null && String.valueOf(rows[0].getCell(field).getValue()).length() > 0) { + value = rows[0].getCell(field).getValue(); + } + + return value; + } else { + return null; + } + } + + public static Object getBodyValue(Grid table, String field, int i) { + return table.getModel() != null && table.getModel().getRows() != null && table.getModel().getRows().length > 0 && table.getValue(field, i) != null ? table.getValue(field, i) : null; + } + + public static Object getBodyValueByRow(Row row, String field) { + return row.getCell(field) != null && row.getCell(field).getValue() != null && String.valueOf(row.getCell(field).getValue()).length() > 0 ? row.getCell(field).getValue() : null; + } + + public static int getBodyScaleByRow(Row row, String field) { + return row.getCell(field) != null && Integer.valueOf(row.getCell(field).getScale()) > 0 ? row.getCell(field).getScale() : 2; + } + + public static void setHeadValue(Form table, String itemKey, Object value) { + if (table != null && table.getModel() != null && table.getModel().getRows() != null && table.getModel().getRows().length > 0) { + Row[] rows = table.getModel().getRows(); + if (rows[0].getCell(itemKey) != null) { + rows[0].getCell(itemKey).setValue(value == null ? "" : value); + } + } + + } + + public static void setBodyValue(Grid table, String itemKey, Object value) { + try { + if (table.getModel() != null && table.getModel().getRows() != null && table.getModel().getRows().length > 0) { + Row[] rows = table.getModel().getRows(); + + for(Row row : rows) { + if (null != row.getCell(itemKey)) { + row.getCell(itemKey).setValue(value); + row.getCell(itemKey).setDisplay(String.valueOf(value == null ? "" : value)); + } + } + } + } catch (Exception e) { + String var10000 = table.getPageid(); + SSCIVMLogger.error("set tableID:" + var10000 + "[" + itemKey + "] error ," + e.getMessage()); + } + + } + + public static void setBodyValueByRow(Row row, String itemKey, Object value) { + try { + if (row != null && row.getCell(itemKey) != null) { + row.getCell(itemKey).setValue(value); + row.getCell(itemKey).setDisplay(value == null ? null : String.valueOf(value)); + } + } catch (Exception e) { + String var10000 = row.getRowid(); + SSCIVMLogger.error("set rowID:" + var10000 + "[" + itemKey + "] error ," + e.getMessage()); + } + + } + + public static String toString(Object val) { + String ref = null; + if (val != null) { + ref = val.toString(); + } + + return ref; + } + + protected static IVApplicationService getIVApplicationService() throws ComponentException { + return (IVApplicationService)ServiceLocator.find(IVApplicationService.class); + } +}