|
@@ -0,0 +1,784 @@
|
|
|
+package nccloud.web.cmp.bankcontrast.actions;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Vector;
|
|
|
+
|
|
|
+import nc.bs.dao.BaseDAO;
|
|
|
+import nc.bs.dao.DAOException;
|
|
|
+import nc.bs.framework.common.NCLocator;
|
|
|
+import nc.bs.logging.Logger;
|
|
|
+import nc.itf.br.syfile.ISyFileRequiresNew;
|
|
|
+import nc.itf.gl.contrast.IContrastAccountPrv;
|
|
|
+import nc.itf.gl.contrast.IContrastPrv;
|
|
|
+import nc.itf.uap.IUAPQueryBS;
|
|
|
+import nc.itf.uif.pub.IUifService;
|
|
|
+import nc.jdbc.framework.processor.BeanProcessor;
|
|
|
+import nc.jdbc.framework.processor.ColumnProcessor;
|
|
|
+import nc.vo.cmp.bankaccbook.BankAccDetailVO;
|
|
|
+import nc.vo.cmp.cb.ContrastVO;
|
|
|
+import nc.vo.cmp.cb.GlContrastVO;
|
|
|
+import nc.vo.cmp.informer.InformerVO;
|
|
|
+import nc.vo.jcom.lang.StringUtil;
|
|
|
+import nc.vo.ml.NCLangRes4VoTransl;
|
|
|
+import nc.vo.pub.BusinessException;
|
|
|
+import nc.vo.pub.lang.UFBoolean;
|
|
|
+import nc.vo.pub.lang.UFDate;
|
|
|
+import nc.vo.pub.lang.UFDateTime;
|
|
|
+import nc.vo.pub.lang.UFDouble;
|
|
|
+import nccloud.framework.core.exception.ExceptionUtils;
|
|
|
+import nccloud.framework.core.json.IJson;
|
|
|
+import nccloud.framework.service.ServiceLocator;
|
|
|
+import nccloud.framework.web.action.itf.ICommonAction;
|
|
|
+import nccloud.framework.web.container.IRequest;
|
|
|
+import nccloud.framework.web.container.SessionContext;
|
|
|
+import nccloud.framework.web.json.JsonFactory;
|
|
|
+import nccloud.web.cmp.bankcontrast.vo.BankContrastSaveArrVo;
|
|
|
+import nccloud.web.cmp.bankcontrast.vo.BankContrastSaveJsonToVo;
|
|
|
+import nccloud.web.cmp.billmanagement.paybills.common.NCCClientInfo;
|
|
|
+import nccloud.web.cmp.contrastcommon.actions.BankContrastUtils;
|
|
|
+
|
|
|
+public class BankContrastSaveAction implements ICommonAction {
|
|
|
+ private int compareFlag = 0;
|
|
|
+
|
|
|
+ private BankContrastSaveArrVo[] banks = null;
|
|
|
+
|
|
|
+ private BankContrastSaveArrVo[] units = null;
|
|
|
+
|
|
|
+ private GlContrastVO glContrastVo = null;
|
|
|
+
|
|
|
+ private String adjustFlag = "0";
|
|
|
+
|
|
|
+ private int precision = 2;
|
|
|
+
|
|
|
+ private final String errMsgByMultMoney = NCLangRes4VoTransl.getNCLangRes().getStrByID("3607con_0", "03607con-0182");
|
|
|
+
|
|
|
+ private final String errMsgByMoney = NCLangRes4VoTransl.getNCLangRes().getStrByID("3607con_0", "03607con-0183");
|
|
|
+
|
|
|
+ public Object doAction(IRequest request) {
|
|
|
+ String read = request.read();
|
|
|
+ IJson iJon = JsonFactory.create();
|
|
|
+ BankContrastSaveJsonToVo jsonVo = (BankContrastSaveJsonToVo) iJon.fromJson(read,
|
|
|
+ BankContrastSaveJsonToVo.class);
|
|
|
+ NCCClientInfo clientInfo = new NCCClientInfo();
|
|
|
+ String user = clientInfo.getClientInfo().getUserid();
|
|
|
+ IUAPQueryBS iuap=(IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
|
|
|
+ BaseDAO basedao =new BaseDAO();
|
|
|
+ this.compareFlag = jsonVo.getCompareFlag();
|
|
|
+ this.banks = jsonVo.getBanks();
|
|
|
+ this.units = jsonVo.getUnits();
|
|
|
+ this.glContrastVo = jsonVo.getGlContrastVo();
|
|
|
+ this.adjustFlag = jsonVo.getAdjustFlag();
|
|
|
+ this.glContrastVo = BankContrastUtils
|
|
|
+ .queryContrastAcct(new String[] { this.glContrastVo.getPk_contrastaccount() }, null)[0];
|
|
|
+
|
|
|
+ try {
|
|
|
+ setPrecision(this.glContrastVo.getPk_currtype());
|
|
|
+ } catch (BusinessException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ ExceptionUtils.wrapBusinessException(
|
|
|
+ NCLangRes4VoTransl.getNCLangRes().getStrByID("3607nccloud_ncc_0", "03607nccloud_ncc-0049"));
|
|
|
+
|
|
|
+ }
|
|
|
+ if (!checkBeforeSave(this.glContrastVo))
|
|
|
+ return null;
|
|
|
+
|
|
|
+ if (this.compareFlag > 0) {
|
|
|
+ newSaveCompare(this.glContrastVo);
|
|
|
+ return "success";
|
|
|
+
|
|
|
+ }
|
|
|
+ saveMethod();
|
|
|
+ for(int i = 0;i < banks.length;i++) {
|
|
|
+ String pk_src = banks[i].getPk_bankreceipt();//银行对账单主键
|
|
|
+ String fk_detail = "";
|
|
|
+ if(banks.length==units.length) {
|
|
|
+ fk_detail = units[i].getFk_detail();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ fk_detail = units[0].getFk_detail();
|
|
|
+ }
|
|
|
+ String money = !banks[i].getCreditamount().equals("0.00")?banks[i].getCreditamount():banks[i].getDebitamount();
|
|
|
+ UFDateTime date = new UFDateTime();
|
|
|
+ String billtype = "";
|
|
|
+ String pk_lower = "";
|
|
|
+ String billsource = "";
|
|
|
+ String qrybilltype = "select * from cmp_bankaccdetail where dr=0 and pk_bankaccdetail = '"+fk_detail+"'";
|
|
|
+ if(!(fk_detail==null)&&!(fk_detail.equals(""))) {
|
|
|
+ BankAccDetailVO detailvo;
|
|
|
+ try {
|
|
|
+ detailvo = (BankAccDetailVO) iuap.executeQuery(qrybilltype,new BeanProcessor(BankAccDetailVO.class));
|
|
|
+ String vbillno = detailvo.getVbillno();
|
|
|
+ String billtypecode = detailvo.getPk_billtype();
|
|
|
+ if(vbillno.startsWith("3641")) {
|
|
|
+ billtype = "3641";
|
|
|
+ String applysql = "select vdef5,pk_apply from ifm_apply where dr=0 and vbillno = '"+vbillno+"' ";
|
|
|
+ pk_lower = (String) iuap.executeQuery(applysql,new ColumnProcessor("pk_apply"));
|
|
|
+ billsource = (String) iuap.executeQuery(applysql,new ColumnProcessor("vdef5"));
|
|
|
+ }
|
|
|
+ else if(vbillno.startsWith("3642")) {
|
|
|
+ billtype = "3642";
|
|
|
+ String redeemsql = "select vdef8,pk_redeem from ifm_redeem where dr=0 and vbillno = '"+vbillno+"' ";
|
|
|
+ pk_lower = (String) iuap.executeQuery(redeemsql,new ColumnProcessor("pk_redeem"));
|
|
|
+ billsource = (String) iuap.executeQuery(redeemsql,new ColumnProcessor("vdef8"));
|
|
|
+ }
|
|
|
+ else if(vbillno.startsWith("3643")) {
|
|
|
+ billtype = "3643";
|
|
|
+ String incomesql = "select pk_srcbill,pk_income from ifm_income where dr=0 and vbillno = '"+vbillno+"' ";
|
|
|
+ pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_income"));
|
|
|
+ billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
|
|
|
+ }
|
|
|
+ else if(vbillno.startsWith("36CO")||billtypecode=="0001Z610000000036COA") {
|
|
|
+ billtype = "36CO";
|
|
|
+ String incomesql = "select pk_srcbill,pk_repayprcplr_h from icdmc_repayprcplreceipt where dr=0 and vbillno = '"+vbillno+"' ";
|
|
|
+ pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_repayprcplr_h"));
|
|
|
+ billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
|
|
|
+ }
|
|
|
+ else if(vbillno.startsWith("36CP")||billtypecode=="0001Z610000000036CPA") {
|
|
|
+ billtype = "36CP";
|
|
|
+ String incomesql = "select pk_srcbill,pk_financepayreceipt from icdmc_financepayreceipt where dr=0 and vbillno = '"+vbillno+"' ";
|
|
|
+ pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_financepayreceipt"));
|
|
|
+ billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
|
|
|
+ }
|
|
|
+ else if(vbillno.startsWith("36K2")) {
|
|
|
+ billtype = "36K2";
|
|
|
+ String incomesql = "select pk_srcbill,pk_allocate_h from sf_allocate_h where dr=0 and vbillno = '"+vbillno+"' ";
|
|
|
+ pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_allocate_h"));
|
|
|
+ billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
|
|
|
+ }
|
|
|
+ else if(vbillno.startsWith("36K4")) {
|
|
|
+ billtype = "36K4";
|
|
|
+ String incomesql = "select pk_srcbill,pk_delivery_h from sf_delivery_h where dr=0 and vbillno = '"+vbillno+"' ";
|
|
|
+ pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_delivery_h"));
|
|
|
+ billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
|
|
|
+ }
|
|
|
+ else if(vbillno.startsWith("36K8")) {
|
|
|
+ billtype = "36K8";
|
|
|
+ String incomesql = "select pk_srcbill,pk_allocatereceipt from sf_allocatereceipt where dr=0 and vbillno = '"+vbillno+"' ";
|
|
|
+ pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_allocatereceipt"));
|
|
|
+ billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
|
|
|
+ }
|
|
|
+ else if(vbillno.startsWith("36K9")) {
|
|
|
+ billtype = "36K9";
|
|
|
+ String incomesql = "select pk_srcbill,pk_deliveryreceipt from sf_deliveryreceipt where dr=0 and vbillno = '"+vbillno+"' ";
|
|
|
+ pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_deliveryreceipt"));
|
|
|
+ billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
|
|
|
+ }
|
|
|
+ else if(vbillno.startsWith("36LJ")) {
|
|
|
+ billtype = "36LJ";
|
|
|
+ String incomesql = "select pk_srcbill,pk_fixdepositreceipt from ifac_fixdepositreceipt where dr=0 and vbillno = '"+vbillno+"' ";
|
|
|
+ pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_fixdepositreceipt"));
|
|
|
+ billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
|
|
|
+ }
|
|
|
+ else if(vbillno.startsWith("36LK")) {
|
|
|
+ billtype = "36LK";
|
|
|
+ String incomesql = "select pk_srcbill,pk_receipt from ifac_fixeddatewithdrawreceipt where dr=0 and vbillno = '"+vbillno+"' ";
|
|
|
+ pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_receipt"));
|
|
|
+ billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
|
|
|
+ }
|
|
|
+ else if(vbillno.startsWith("36S1")) {
|
|
|
+ billtype = "36S1";
|
|
|
+ String incomesql = "select pk_srcbill,pk_cashdeposit from cmp_cashdeposit where dr=0 and bill_no = '"+vbillno+"' ";
|
|
|
+ pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_cashdeposit"));
|
|
|
+ billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
|
|
|
+ }
|
|
|
+ else if(vbillno.startsWith("36S2")) {
|
|
|
+ billtype = "36S2";
|
|
|
+ String incomesql = "select pk_srcbill,pk_cashdraw from cmp_cashdraw where dr=0 and billno = '"+vbillno+"' ";
|
|
|
+ pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_cashdraw"));
|
|
|
+ billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
|
|
|
+ }
|
|
|
+ else if(vbillno.startsWith("36S4")) {
|
|
|
+ billtype = "36S4";
|
|
|
+ String incomesql = "select pk_srcbill,pk_transformbill from cmp_transformbill where dr=0 and vbillno = '"+vbillno+"' ";
|
|
|
+ pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_transformbill"));
|
|
|
+ billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
|
|
|
+ }
|
|
|
+ else if(billtypecode.equals("36Z3")) {
|
|
|
+ billtype = "36Z3";
|
|
|
+ String incomesql = "select pk_srcbill,pk_financepay from cdmc_financepay where dr=0 and vbillno = '"+vbillno+"' ";
|
|
|
+ pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_financepay"));
|
|
|
+ billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
|
|
|
+ }
|
|
|
+ else if(billtypecode.equals("36Z4")||billtypecode=="0001Z61000000003D2O3") {
|
|
|
+ billtype = "36Z4";
|
|
|
+ String incomesql = "select vdef4,pk_repayprcpl from cdmc_repayprcpl where dr=0 and vbillno = '"+vbillno+"' ";
|
|
|
+ pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_repayprcpl"));
|
|
|
+ billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("vdef4"));
|
|
|
+ }
|
|
|
+ else if(billtypecode.equals("36Z5")||billtypecode=="0001Z61000000003CWBP") {
|
|
|
+ billtype = "36Z5";
|
|
|
+ String incomesql = "select pk_srcbill,pk_repayintst from cdmc_repinterest where dr=0 and vbillno = '"+vbillno+"' ";
|
|
|
+ pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_repayintst"));
|
|
|
+ billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
|
|
|
+ }
|
|
|
+ else if(vbillno.startsWith("D2")) {
|
|
|
+ billtype = "F2";
|
|
|
+ String incomesql = "select def11,pk_gatherbill from ar_gatherbill where dr=0 and billno = '"+vbillno+"' ";
|
|
|
+ pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_gatherbill"));
|
|
|
+ billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("def11"));
|
|
|
+ }
|
|
|
+ else if(vbillno.startsWith("D3")) {
|
|
|
+ billtype = "F3";
|
|
|
+ String incomesql = "select pk_paybill from ap_paybill where dr=0 and billno = '"+vbillno+"' ";
|
|
|
+ pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor());
|
|
|
+ }
|
|
|
+ else if(vbillno.startsWith("F4")) {
|
|
|
+ billtype = "F4";
|
|
|
+ String incomesql = "select pk_upbill,pk_recbill from cmp_recbill where dr=0 and bill_no = '"+vbillno+"' ";
|
|
|
+ pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_recbill"));
|
|
|
+ billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_upbill"));
|
|
|
+ }
|
|
|
+ else if(vbillno.startsWith("F5")) {
|
|
|
+ billtype = "F5";
|
|
|
+ String incomesql = "select def11,pk_paybill from cmp_paybill where dr=0 and bill_no = '"+vbillno+"' ";
|
|
|
+ pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_paybill"));
|
|
|
+ billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("def11"));
|
|
|
+ }
|
|
|
+ } catch (BusinessException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ String qrysql = "select * from cmp_informer where dr=0 and pk_src = '"+pk_src+"'";
|
|
|
+ if(!pk_src.equals("")&&!pk_src.equals(null)) {
|
|
|
+ try {
|
|
|
+ InformerVO informervo = (InformerVO) iuap.executeQuery(qrysql,new BeanProcessor(InformerVO.class));
|
|
|
+ String lower = informervo.getPk_lower();
|
|
|
+ if(lower==null&&billtype!=""&&pk_lower!=""&&pk_lower!=null&&(billsource==""||billsource==null||billsource=="~")) {
|
|
|
+ String updatesql = "update cmp_informer set generateflag = 'hasgenerate',usemoney = '"+money+"',pk_claimer='"+user+"',claimdate='"+date.toString()+"',pk_lower='"+pk_lower+"',lowerbilltype='"+billtype+"' where dr=0 and pk_src = '"+pk_src+"'";
|
|
|
+ basedao.executeUpdate(updatesql);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } catch (BusinessException e1) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e1.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return "success";
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean checkBeforeSave(GlContrastVO account) {
|
|
|
+ boolean flag = true;
|
|
|
+ boolean flag2 = false;
|
|
|
+ try {
|
|
|
+ flag2 = ((IContrastAccountPrv) ServiceLocator.find(IContrastAccountPrv.class)).isExceptional(account);
|
|
|
+ } catch (BusinessException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (flag2) {
|
|
|
+ flag = false;
|
|
|
+ ExceptionUtils
|
|
|
+ .wrapBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("3607con_0", "03607con-0222"));
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setPrecision(String key) throws BusinessException {
|
|
|
+ if (key == null)
|
|
|
+
|
|
|
+ return;
|
|
|
+ this.precision = BankContrastUtils.getPrecision(key);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void newSaveCompare(GlContrastVO glContrastVo) {
|
|
|
+ ContrastVO[] vos = null;
|
|
|
+ ContrastVO[] vosd = null;
|
|
|
+ Vector<ContrastVO> vov = new Vector();
|
|
|
+ Vector<ContrastVO> vovd = new Vector();
|
|
|
+ ArrayList<String> bankNumbers = new ArrayList<>();
|
|
|
+ ArrayList<String> unitNumbers = new ArrayList<>();
|
|
|
+
|
|
|
+ String batchNumber = "";
|
|
|
+ try {
|
|
|
+ batchNumber = ((IContrastPrv) ServiceLocator.find(IContrastPrv.class))
|
|
|
+ .getMaxBatchNumber(glContrastVo.getPk_contrastaccount(), false);
|
|
|
+ } catch (BusinessException e) {
|
|
|
+ Logger.error(e.getMessage(), (Throwable) e);
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (!isBalance(checkDataWhenCompare())) {
|
|
|
+ ExceptionUtils.wrapBusinessException(getErrMsg());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ int i;
|
|
|
+ for (i = 0; i < this.banks.length; i++) {
|
|
|
+ if (this.banks[i].isContrast() && !this.banks[i].isContrastOld()) {
|
|
|
+ String flag = this.banks[i].getStyleflag();
|
|
|
+ if (flag != null && flag.equals("B"))
|
|
|
+ ExceptionUtils.wrapBusinessException(
|
|
|
+ NCLangRes4VoTransl.getNCLangRes().getStrByID("3607con_0", "03607con-0220"));
|
|
|
+
|
|
|
+ ContrastVO vo = new ContrastVO();
|
|
|
+ vo.setPk_bankreceipt(this.banks[i].getPk_bankreceipt());
|
|
|
+ vo.setPk_contrastaccount(glContrastVo.getPk_contrastaccount());
|
|
|
+ vo.setContrastdate(getDate());
|
|
|
+ vo.setCorpdate(new UFDate(this.banks[i].getCheckdate()));
|
|
|
+ vo.setBatchNumber(batchNumber);
|
|
|
+ vo.setPk_org(glContrastVo.getPk_corp());
|
|
|
+ vo.setPk_group(getPk_group(glContrastVo.getPk_corp()));
|
|
|
+
|
|
|
+ if (this.banks[i].getDebitamount() != null
|
|
|
+ && Double.parseDouble(this.banks[i].getDebitamount()) != 0.0D) {
|
|
|
+ vo.setMoney(new UFDouble(this.banks[i].getDebitamount()));
|
|
|
+ vo.setIsDebit(UFBoolean.TRUE);
|
|
|
+ } else {
|
|
|
+ vo.setMoney(new UFDouble(this.banks[i].getCreditamount()));
|
|
|
+ vo.setIsDebit(UFBoolean.FALSE);
|
|
|
+ }
|
|
|
+ vov.addElement(vo);
|
|
|
+ }
|
|
|
+ if (!this.banks[i].isContrast() && this.banks[i].isContrastOld()) {
|
|
|
+ ContrastVO vod = new ContrastVO();
|
|
|
+ vod.setPk_contrastaccount(glContrastVo.getPk_contrastaccount());
|
|
|
+ vod.setPk_bankreceipt(this.banks[i].getPk_bankreceipt());
|
|
|
+ vod.setBatchNumber(this.banks[i].getBatchNumber());
|
|
|
+ bankNumbers.add(this.banks[i].getBatchNumber());
|
|
|
+ vovd.addElement(vod);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (i = 0; i < this.units.length; i++) {
|
|
|
+ if (this.units[i].isContrast() && !this.units[i].isContrastOld()) {
|
|
|
+ ContrastVO vo = new ContrastVO();
|
|
|
+ vo.setFk_detail(this.units[i].getFk_detail());
|
|
|
+ vo.setPk_contrastaccount(glContrastVo.getPk_contrastaccount());
|
|
|
+ vo.setContrastdate(getDate());
|
|
|
+ if (this.units[i].getCheckdate() != null)
|
|
|
+ vo.setCorpdate(new UFDate(this.units[i].getCheckdate()));
|
|
|
+
|
|
|
+ vo.setBatchNumber(batchNumber);
|
|
|
+ vo.setPk_org(glContrastVo.getPk_corp());
|
|
|
+ vo.setPk_group(getPk_group(glContrastVo.getPk_corp()));
|
|
|
+
|
|
|
+ if (this.units[i].getDebitamount() != null
|
|
|
+ && Double.parseDouble(this.units[i].getDebitamount()) != 0.0D) {
|
|
|
+ vo.setMoney(new UFDouble(this.units[i].getDebitamount()));
|
|
|
+ vo.setIsDebit(UFBoolean.TRUE);
|
|
|
+ } else {
|
|
|
+ vo.setMoney(new UFDouble(this.units[i].getCreditamount()));
|
|
|
+ vo.setIsDebit(UFBoolean.FALSE);
|
|
|
+ }
|
|
|
+ vov.addElement(vo);
|
|
|
+ }
|
|
|
+ if (!this.units[i].isContrast() && this.units[i].isContrastOld()) {
|
|
|
+ ContrastVO vod = new ContrastVO();
|
|
|
+ vod.setPk_contrastaccount(glContrastVo.getPk_contrastaccount());
|
|
|
+ vod.setFk_detail(this.units[i].getFk_detail());
|
|
|
+ vod.setBatchNumber(this.units[i].getBatchNumber());
|
|
|
+ unitNumbers.add(this.units[i].getBatchNumber());
|
|
|
+ vovd.addElement(vod);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Throwable e) {
|
|
|
+ Logger.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
+ vos = new ContrastVO[vov.size()];
|
|
|
+ vov.copyInto((Object[]) vos);
|
|
|
+
|
|
|
+ vosd = new ContrastVO[vovd.size()];
|
|
|
+ vovd.copyInto((Object[]) vosd);
|
|
|
+
|
|
|
+ try {
|
|
|
+ if (vos.length > 0) {
|
|
|
+ Vector<String> vt = new Vector();
|
|
|
+ Object[] vot = null;
|
|
|
+ for (int i = 0; i < vos.length; i++) {
|
|
|
+ if (vos[i].getFk_detail() != null)
|
|
|
+ vt.add(vos[i].getFk_detail());
|
|
|
+
|
|
|
+ }
|
|
|
+ if (vt != null) {
|
|
|
+ vot = new Object[vt.size()];
|
|
|
+ vt.copyInto(vot);
|
|
|
+
|
|
|
+ }
|
|
|
+ if (glContrastVo.getSource().intValue() == 2) {
|
|
|
+ ArrayList<ContrastVO> voList = new ArrayList<>();
|
|
|
+ for (int j = 0; j < vos.length; j++) {
|
|
|
+ String strfks = vos[j].getFk_detail();
|
|
|
+ if (!StringUtil.isEmptyWithTrim(strfks)) {
|
|
|
+ String[] fks = strfks.split("@@");
|
|
|
+ if (fks != null && fks.length > 0)
|
|
|
+ for (int k = 0; k < fks.length; k++) {
|
|
|
+ ContrastVO tempvo = (ContrastVO) vos[j].clone();
|
|
|
+ tempvo.setFk_detail(fks[k]);
|
|
|
+ tempvo.setBatchNumber(batchNumber);
|
|
|
+ voList.add(tempvo);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ voList.add(vos[j]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ vos = new ContrastVO[voList.size()];
|
|
|
+ voList.toArray(vos);
|
|
|
+ }
|
|
|
+ ((IContrastPrv) ServiceLocator.find(IContrastPrv.class)).insertContrasts(vos, glContrastVo);
|
|
|
+ }
|
|
|
+ if (vosd.length > 0) {
|
|
|
+
|
|
|
+ if (glContrastVo.getSource().intValue() == 2) {
|
|
|
+ ArrayList<ContrastVO> vodList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < vosd.length; i++) {
|
|
|
+ String strfks = vosd[i].getFk_detail();
|
|
|
+ if (!StringUtil.isEmptyWithTrim(strfks)) {
|
|
|
+ String[] fks = strfks.split("@@");
|
|
|
+ if (fks != null && fks.length > 0)
|
|
|
+ for (int j = 0; j < fks.length; j++) {
|
|
|
+ ContrastVO tempvo = (ContrastVO) vosd[i].clone();
|
|
|
+ tempvo.setFk_detail(fks[j]);
|
|
|
+ vodList.add(tempvo);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ vodList.add(vosd[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ vosd = new ContrastVO[vodList.size()];
|
|
|
+ vodList.toArray(vosd);
|
|
|
+ }
|
|
|
+ ((IContrastPrv) ServiceLocator.find(IContrastPrv.class)).deleteContrast(vosd, 0, glContrastVo);
|
|
|
+ }
|
|
|
+ } catch (Throwable e) {
|
|
|
+ Logger.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void saveMethod() {
|
|
|
+ ContrastVO[] vos = null;
|
|
|
+ ContrastVO[] vosd = null;
|
|
|
+ Vector<ContrastVO> vov = new Vector();
|
|
|
+ Vector<ContrastVO> vovd = new Vector();
|
|
|
+ ArrayList<String> addBankNumber = new ArrayList<>();
|
|
|
+ ArrayList<String> delBankNumber = new ArrayList<>();
|
|
|
+ ArrayList<String> addUnitNumber = new ArrayList<>();
|
|
|
+ ArrayList<String> delUnitNumber = new ArrayList<>();
|
|
|
+
|
|
|
+ String batchNumber = "";
|
|
|
+ try {
|
|
|
+ batchNumber = ((IContrastPrv) ServiceLocator.find(IContrastPrv.class))
|
|
|
+ .getNewBatchNumber(this.glContrastVo.getPk_contrastaccount(), getDate(), false);
|
|
|
+ } catch (BusinessException e) {
|
|
|
+ Logger.error(e.getMessage(), (Throwable) e);
|
|
|
+ }
|
|
|
+ if (!isBalance(checkData())) {
|
|
|
+ ExceptionUtils.wrapBusinessException(getErrMsg());
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int rows = this.banks.length;
|
|
|
+ try {
|
|
|
+ int i;
|
|
|
+ for (i = 0; i < rows; i++) {
|
|
|
+ if (this.banks[i].isContrast() && !this.banks[i].isContrastOld()) {
|
|
|
+ String flag = this.banks[i].getStyleflag();
|
|
|
+ if (flag != null && flag.equals("B")) {
|
|
|
+ ExceptionUtils.wrapBusinessException(
|
|
|
+ NCLangRes4VoTransl.getNCLangRes().getStrByID("3607con_0", "03607con-0220"));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ContrastVO vo = new ContrastVO();
|
|
|
+ vo.setPk_bankreceipt(this.banks[i].getPk_bankreceipt());
|
|
|
+ vo.setPk_contrastaccount(this.glContrastVo.getPk_contrastaccount().toString());
|
|
|
+ vo.setContrastdate(getDate());
|
|
|
+ vo.setCorpdate(new UFDate(this.banks[i].getCheckdate()));
|
|
|
+ vo.setBatchNumber(batchNumber);
|
|
|
+ addBankNumber.add(batchNumber);
|
|
|
+ vo.setPk_org(this.glContrastVo.getPk_org());
|
|
|
+ vo.setPk_group(getPk_group(this.glContrastVo.getPk_org()));
|
|
|
+
|
|
|
+ if (this.banks[i].getDebitamount() != null
|
|
|
+ && Double.parseDouble(this.banks[i].getDebitamount()) != 0.0D) {
|
|
|
+ vo.setMoney(new UFDouble(this.banks[i].getDebitamount()));
|
|
|
+ vo.setIsDebit(UFBoolean.TRUE);
|
|
|
+ } else {
|
|
|
+ vo.setMoney(new UFDouble(this.banks[i].getCreditamount()));
|
|
|
+ vo.setIsDebit(UFBoolean.FALSE);
|
|
|
+ }
|
|
|
+ vov.addElement(vo);
|
|
|
+ }
|
|
|
+ if (!this.banks[i].isContrast() && this.banks[i].isContrastOld()) {
|
|
|
+ ContrastVO vod = new ContrastVO();
|
|
|
+ vod.setPk_contrastaccount(this.glContrastVo.getPk_contrastaccount().toString());
|
|
|
+ vod.setPk_bankreceipt(this.banks[i].getPk_bankreceipt());
|
|
|
+
|
|
|
+ if (this.banks[i].getBatchNumber() != null) {
|
|
|
+ vod.setBatchNumber(this.banks[i].getBatchNumber());
|
|
|
+ delBankNumber.add(this.banks[i].getBatchNumber());
|
|
|
+ }
|
|
|
+ vod.setPk_org(this.glContrastVo.getPk_corp());
|
|
|
+ vod.setPk_group(getPk_group(this.glContrastVo.getPk_corp()));
|
|
|
+ vovd.addElement(vod);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rows = this.units.length;
|
|
|
+ for (i = 0; i < rows; i++) {
|
|
|
+ if (this.units[i].isContrast() && !this.units[i].isContrastOld()) {
|
|
|
+ ContrastVO vo = new ContrastVO();
|
|
|
+ vo.setFk_detail(this.units[i].getFk_detail());
|
|
|
+ vo.setPk_contrastaccount(this.glContrastVo.getPk_contrastaccount().toString());
|
|
|
+ vo.setContrastdate(getDate());
|
|
|
+ if (this.units[i].getCheckdate() != null)
|
|
|
+ vo.setCorpdate(new UFDate(this.units[i].getCheckdate()));
|
|
|
+
|
|
|
+ vo.setBatchNumber(batchNumber);
|
|
|
+ addUnitNumber.add(batchNumber);
|
|
|
+ vo.setPk_org(this.glContrastVo.getPk_corp());
|
|
|
+ vo.setPk_group(getPk_group(this.glContrastVo.getPk_corp()));
|
|
|
+
|
|
|
+ if (this.units[i].getDebitamount() != null
|
|
|
+ && Double.parseDouble(this.units[i].getDebitamount()) != 0.0D) {
|
|
|
+ vo.setMoney(new UFDouble(this.units[i].getDebitamount()));
|
|
|
+ vo.setIsDebit(UFBoolean.TRUE);
|
|
|
+ } else {
|
|
|
+ vo.setMoney(new UFDouble(this.units[i].getCreditamount()));
|
|
|
+ vo.setIsDebit(UFBoolean.FALSE);
|
|
|
+ }
|
|
|
+ vov.addElement(vo);
|
|
|
+ }
|
|
|
+ if (!this.units[i].isContrast() && this.units[i].isContrastOld()) {
|
|
|
+ ContrastVO vod = new ContrastVO();
|
|
|
+ vod.setPk_contrastaccount(this.glContrastVo.getPk_contrastaccount().toString());
|
|
|
+ vod.setFk_detail(this.units[i].getFk_detail());
|
|
|
+ if (this.units[i].getBatchNumber() != null) {
|
|
|
+ vod.setBatchNumber(this.units[i].getBatchNumber());
|
|
|
+ delUnitNumber.add(this.units[i].getBatchNumber());
|
|
|
+ }
|
|
|
+ vod.setPk_org(this.glContrastVo.getPk_corp());
|
|
|
+ vod.setPk_group(getPk_group(this.glContrastVo.getPk_corp()));
|
|
|
+ vovd.addElement(vod);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Throwable e) {
|
|
|
+ Logger.error(e.getMessage(), e);
|
|
|
+
|
|
|
+ }
|
|
|
+ vos = new ContrastVO[vov.size()];
|
|
|
+ vov.copyInto((Object[]) vos);
|
|
|
+
|
|
|
+ vosd = new ContrastVO[vovd.size()];
|
|
|
+ vovd.copyInto((Object[]) vosd);
|
|
|
+
|
|
|
+ try {
|
|
|
+ if (vos.length > 0) {
|
|
|
+ Vector<String> vt = new Vector();
|
|
|
+ Object[] vot = null;
|
|
|
+ for (int i = 0; i < vos.length; i++) {
|
|
|
+ if (vos[i].getFk_detail() != null)
|
|
|
+ vt.add(vos[i].getFk_detail());
|
|
|
+
|
|
|
+ }
|
|
|
+ if (vt != null) {
|
|
|
+ vot = new Object[vt.size()];
|
|
|
+ vt.copyInto(vot);
|
|
|
+
|
|
|
+ }
|
|
|
+ if (this.glContrastVo.getSource().intValue() == 2) {
|
|
|
+ ArrayList<ContrastVO> voList = new ArrayList<>();
|
|
|
+ for (int j = 0; j < vos.length; j++) {
|
|
|
+ String strfks = vos[j].getFk_detail();
|
|
|
+ if (!StringUtil.isEmptyWithTrim(strfks)) {
|
|
|
+ String[] fks = strfks.split("@@");
|
|
|
+ if (fks != null && fks.length > 0)
|
|
|
+ for (int k = 0; k < fks.length; k++) {
|
|
|
+ ContrastVO tempvo = (ContrastVO) vos[j].clone();
|
|
|
+ tempvo.setFk_detail(fks[k]);
|
|
|
+ tempvo.setBatchNumber(batchNumber);
|
|
|
+ voList.add(tempvo);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ voList.add(vos[j]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ vos = new ContrastVO[voList.size()];
|
|
|
+ voList.toArray(vos);
|
|
|
+ }
|
|
|
+ ((IContrastPrv) ServiceLocator.find(IContrastPrv.class)).insertContrasts(vos, this.glContrastVo);
|
|
|
+ }
|
|
|
+ if (vosd.length > 0) {
|
|
|
+
|
|
|
+ if (this.glContrastVo.getSource().intValue() == 2) {
|
|
|
+ ArrayList<ContrastVO> vodList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < vosd.length; i++) {
|
|
|
+ String strfks = vosd[i].getFk_detail();
|
|
|
+ if (!StringUtil.isEmptyWithTrim(strfks)) {
|
|
|
+ String[] fks = strfks.split("@@");
|
|
|
+ if (fks != null && fks.length > 0)
|
|
|
+ for (int j = 0; j < fks.length; j++) {
|
|
|
+ ContrastVO tempvo = (ContrastVO) vosd[i].clone();
|
|
|
+ tempvo.setFk_detail(fks[j]);
|
|
|
+ vodList.add(tempvo);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ vodList.add(vosd[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ vosd = new ContrastVO[vodList.size()];
|
|
|
+ vodList.toArray(vosd);
|
|
|
+ }
|
|
|
+ ((IContrastPrv) ServiceLocator.find(IContrastPrv.class)).deleteContrast(vosd, 0, this.glContrastVo);
|
|
|
+ }
|
|
|
+ this.compareFlag = 0;
|
|
|
+
|
|
|
+ doSyFile(batchNumber);
|
|
|
+
|
|
|
+ } catch (Throwable e) {
|
|
|
+ Logger.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private UFDate getDate() {
|
|
|
+ return new UFDate(SessionContext.getInstance().getClientInfo().getBizDateTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getPk_group(String pkOrg) {
|
|
|
+ return BankContrastUtils.getGroupByOrg(pkOrg);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getErrMsg() {
|
|
|
+ if (this.adjustFlag.equals("0"))
|
|
|
+ return this.errMsgByMultMoney;
|
|
|
+ if (this.adjustFlag.equals("1"))
|
|
|
+ return this.errMsgByMoney;
|
|
|
+
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ public UFDouble[] checkDataWhenCompare() {
|
|
|
+ UFDouble result1 = new UFDouble(0);
|
|
|
+ UFDouble result2 = new UFDouble(0);
|
|
|
+ UFDouble result3 = new UFDouble(0);
|
|
|
+ UFDouble result4 = new UFDouble(0);
|
|
|
+ try {
|
|
|
+ if (this.units != null && this.units.length > 0)
|
|
|
+
|
|
|
+ for (int i = 0; i < this.units.length; i++) {
|
|
|
+ if (this.units[i].isContrast() != this.units[i].isContrastOld()) {
|
|
|
+ Object temp = this.units[i].getDebitamount();
|
|
|
+ if (temp != null)
|
|
|
+ result1 = result1.add(new UFDouble(temp.toString()));
|
|
|
+ temp = this.units[i].getCreditamount();
|
|
|
+ if (temp != null)
|
|
|
+ result2 = result2.add(new UFDouble(temp.toString()));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (this.banks != null && this.banks.length > 0)
|
|
|
+ for (int i = 0; i < this.banks.length; i++) {
|
|
|
+ if (this.banks[i].isContrast() != this.banks[i].isContrastOld()) {
|
|
|
+ Object temp = this.banks[i].getDebitamount();
|
|
|
+ if (temp != null)
|
|
|
+ result3 = result3.add(new UFDouble(temp.toString()));
|
|
|
+ temp = this.banks[i].getCreditamount();
|
|
|
+ if (temp != null)
|
|
|
+ result4 = result4.add(new UFDouble(temp.toString()));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ Logger.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
+ UFDouble[] result = new UFDouble[4];
|
|
|
+ result[0] = new UFDouble(result1.doubleValue(), this.precision);
|
|
|
+ result[1] = new UFDouble(result2.doubleValue(), this.precision);
|
|
|
+ result[2] = new UFDouble(result3.doubleValue(), this.precision);
|
|
|
+ result[3] = new UFDouble(result4.doubleValue(), this.precision);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean isBalance(UFDouble[] data) {
|
|
|
+ UFDouble result1 = (data[0] == null) ? new UFDouble(0) : data[0];
|
|
|
+ UFDouble result2 = (data[1] == null) ? new UFDouble(0) : data[1];
|
|
|
+ UFDouble result3 = (data[2] == null) ? new UFDouble(0) : data[2];
|
|
|
+ UFDouble result4 = (data[3] == null) ? new UFDouble(0) : data[3];
|
|
|
+ if (this.adjustFlag.equals("0")) {
|
|
|
+ if (this.glContrastVo.getContrastaspect().intValue() == 0) {
|
|
|
+
|
|
|
+ if (result1.doubleValue() == result3.doubleValue() && result2.doubleValue() == result4.doubleValue())
|
|
|
+ return true;
|
|
|
+
|
|
|
+ return false;
|
|
|
+
|
|
|
+ }
|
|
|
+ if (result1.doubleValue() == result4.doubleValue() && result2.doubleValue() == result3.doubleValue())
|
|
|
+ return true;
|
|
|
+
|
|
|
+ return false;
|
|
|
+
|
|
|
+ }
|
|
|
+ if (this.glContrastVo.getContrastaspect().intValue() == 0) {
|
|
|
+ if (result1.sub(result2).sub(result3).add(result4).doubleValue() == 0.0D)
|
|
|
+ return true;
|
|
|
+
|
|
|
+ return false;
|
|
|
+
|
|
|
+ }
|
|
|
+ if (result1.sub(result2).sub(result4).add(result3).doubleValue() == 0.0D)
|
|
|
+ return true;
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public UFDouble[] checkData() {
|
|
|
+ UFDouble result1 = new UFDouble(0);
|
|
|
+ UFDouble result2 = new UFDouble(0);
|
|
|
+ UFDouble result3 = new UFDouble(0);
|
|
|
+ UFDouble result4 = new UFDouble(0);
|
|
|
+
|
|
|
+ if (this.units.length > 0)
|
|
|
+ for (int i = 0; i < this.units.length; i++) {
|
|
|
+ Object pay = this.units[i].getCreditamount();
|
|
|
+ Object receipt = this.units[i].getDebitamount();
|
|
|
+ if (null != pay && !"".equals(pay)) {
|
|
|
+ result2 = result2.add(new UFDouble(pay.toString()));
|
|
|
+ } else if (null != receipt && !"".equals(receipt)) {
|
|
|
+ result1 = result1.add(new UFDouble(receipt.toString()));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (this.banks.length > 0)
|
|
|
+ for (int i = 0; i < this.banks.length; i++) {
|
|
|
+ Object pay = this.banks[i].getCreditamount();
|
|
|
+ Object receipt = this.banks[i].getDebitamount();
|
|
|
+
|
|
|
+ if (null != pay && !"".equals(pay)) {
|
|
|
+
|
|
|
+ result4 = result4.add(new UFDouble(pay.toString()));
|
|
|
+ } else if (null != receipt && !"".equals(receipt)) {
|
|
|
+ result3 = result3.add(new UFDouble(receipt.toString()));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ UFDouble[] result = new UFDouble[4];
|
|
|
+ result[0] = new UFDouble(result1.doubleValue(), this.precision);
|
|
|
+ result[1] = new UFDouble(result2.doubleValue(), this.precision);
|
|
|
+ result[2] = new UFDouble(result3.doubleValue(), this.precision);
|
|
|
+ result[3] = new UFDouble(result4.doubleValue(), this.precision);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Title:doSyFile
|
|
|
+ * @Description: [method] TODO whz 2022.3.4.15 手动对账触发附件传输
|
|
|
+ * @return void
|
|
|
+ * @param batchNumber
|
|
|
+ * @throws BusinessException
|
|
|
+ * @Create: whz
|
|
|
+ * @date: 2022年3月4日 下午3:30:17
|
|
|
+ */
|
|
|
+ private void doSyFile(String batchNumber) throws BusinessException {
|
|
|
+ ContrastVO[] conts = (ContrastVO[]) ServiceLocator.find(IUifService.class).queryByCondition(ContrastVO.class, " batchnumber = '" + batchNumber + "' ");
|
|
|
+ ISyFileRequiresNew ser = ServiceLocator.find(ISyFileRequiresNew.class);
|
|
|
+
|
|
|
+ // 转换参数
|
|
|
+ Map<String, String[]> map = ser.toParam_RequiresNew(conts);
|
|
|
+ // 开始同步
|
|
|
+ ser.syBill_RequiresNew(map, "cmp");
|
|
|
+ }
|
|
|
+}
|