Procházet zdrojové kódy

银行对账回写到账通知及贷款付息取消生单及付款结算settletype=11

pancy před 3 roky
rodič
revize
8e7512624a

+ 729 - 0
zjcmp_cd/zjcmp_cd/src/client/nccloud/web/cmp/bankcontrast/actions/BankContrastAutoAction.java

@@ -0,0 +1,729 @@
+package nccloud.web.cmp.bankcontrast.actions;
+
+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 java.util.Vector;
+
+import nc.bs.dao.BaseDAO;
+import nc.bs.framework.common.NCLocator;
+import nc.bs.logging.Logger;
+import nc.cmp.tools.ContrastUtils;
+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.CQueryVO;
+import nc.vo.cmp.cb.CTransferVO;
+import nc.vo.cmp.cb.ContrastVO;
+import nc.vo.cmp.cb.GLQueryVO;
+import nc.vo.cmp.cb.GlContrastVO;
+import nc.vo.cmp.cb.QConditionVO;
+import nc.vo.cmp.informer.InformerVO;
+import nc.vo.glpub.IVoAccess;
+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 nc.vo.tmpub.util.StringUtil;
+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.pubitf.cmp.bankcontrast.IBankContrastSerivce;
+import nccloud.web.cmp.bankcontrast.vo.BankContrastAutoJsonToVo;
+import nccloud.web.cmp.billmanagement.paybills.common.NCCClientInfo;
+import nccloud.web.cmp.contrastcommon.actions.BankContrastUtils;
+
+public class BankContrastAutoAction implements ICommonAction {
+	IUAPQueryBS iuap=(IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
+	BaseDAO basedao =new BaseDAO();
+	NCCClientInfo clientInfo = new NCCClientInfo();
+	String user = clientInfo.getClientInfo().getUserid();
+	private IVoAccess[] banks = null;
+	private IVoAccess[] units = null;
+
+	public IVoAccess[] getBanks() {
+		return this.banks;
+	}
+
+	public void setBanks(IVoAccess[] banks) {
+		this.banks = banks;
+	}
+
+	public IVoAccess[] getUnits() {
+		return this.units;
+	}
+
+	public void setUnits(IVoAccess[] units) {
+		this.units = units;
+	}
+
+	public Object doAction(IRequest request) {
+		String read = request.read();
+		IJson iJon = JsonFactory.create();
+		BankContrastAutoJsonToVo jSonVo = (BankContrastAutoJsonToVo) iJon.fromJson(read,
+				BankContrastAutoJsonToVo.class);
+
+		String pk_org = jSonVo.getQueryVO().getPk_Corp();
+
+		UFDate businessDate = new UFDate(SessionContext.getInstance().getClientInfo().getBizDateTime());
+		String year = null;
+
+		try {
+			year = ((IBankContrastSerivce) ServiceLocator.find(IBankContrastSerivce.class)).getAccountYear(pk_org,
+					businessDate, null);
+		} catch (BusinessException e1) {
+			e1.printStackTrace();
+
+		}
+		CQueryVO cqueryVo = jSonVo.getQueryVO();
+
+		GLQueryVO query = new GLQueryVO();
+		query.setPK_contrastaccount(new String[] { jSonVo.getGlContrastVo().getPk_contrastaccount() });
+		query.setPk_user(SessionContext.getInstance().getClientInfo().getUserid());
+		query.setYears(year);
+
+		cqueryVo.setYear(year);
+		cqueryVo.setChecked(Boolean.valueOf(false));
+
+		GlContrastVO[] glContrastArr = null;
+		GlContrastVO caccount = null;
+
+		try {
+			glContrastArr = ((IContrastAccountPrv) ServiceLocator.find(IContrastAccountPrv.class))
+					.queryContrastAccount(query);
+			if (glContrastArr == null || glContrastArr.length == 0)
+				return null;
+
+			caccount = glContrastArr[0];
+		} catch (BusinessException e1) {
+			e1.printStackTrace();
+
+		}
+		CQueryVO bqvo = BankContrastUtils.getQueryBank(cqueryVo, 0, glContrastArr[0]);
+
+		CQueryVO cqvo = BankContrastUtils.getQueryCorp(cqueryVo, 0, glContrastArr[0]);
+
+		if (null == bqvo || null == cqvo)
+			return null;
+
+		Map<String, CTransferVO[]> results = null;
+		try {
+			results = ((IContrastPrv) ServiceLocator.find(IContrastPrv.class)).getReceiptBoth(bqvo, cqvo);
+
+		} catch (BusinessException e) {
+			e.printStackTrace();
+
+		}
+		QConditionVO qconvo = jSonVo.getQconvo();
+		if (caccount.getContrastaspect().intValue() == 0) {
+			qconvo.blnSimeDirection = true;
+		} else {
+			qconvo.blnSimeDirection = false;
+		}
+		if (caccount.getMemo() != null && caccount.getMemo().trim().equals("one")) {
+			qconvo.m_bManyCorp = false;
+		} else if (caccount.getMemo() != null && caccount.getMemo().trim().equals("many")) {
+			qconvo.m_bManyCorp = true;
+		}
+		if (caccount.getSource().intValue() == 1) {
+			qconvo.m_bSource = true;
+		} else {
+			qconvo.m_bSource = false;
+
+		}
+		CTransferVO[] units = results.get("corp");
+		CTransferVO[] banks = results.get("bank");
+		if (units == null || units.length == 0)
+
+			ExceptionUtils.wrapBusinessException(
+					NCLangRes4VoTransl.getNCLangRes().getStrByID("3607nccloud_ncc_0", "03607nccloud_ncc-0045"));
+
+		if (banks == null || banks.length == 0)
+
+			ExceptionUtils.wrapBusinessException(
+					NCLangRes4VoTransl.getNCLangRes().getStrByID("3607nccloud_ncc_0", "03607nccloud_ncc-0046"));
+
+		try {
+			String batchNumber = ((IContrastPrv) ServiceLocator.find(IContrastPrv.class)).getNewBatchNumber(
+					caccount.getPk_contrastaccount(),
+					new UFDate(SessionContext.getInstance().getClientInfo().getBizDateTime()), true);
+			doContrast(filterVO(units), filterVO(banks), qconvo);
+			IVoAccess[] banksArr = getBanks();
+			IVoAccess[] unitsArr = getUnits();
+			saveContrast(unitsArr, banksArr, batchNumber, caccount);
+		} catch (BusinessException e) {
+			e.printStackTrace();
+
+		}
+		return null;
+	}
+
+	public CTransferVO[] filterVO(CTransferVO[] vo) {
+		CTransferVO[] result = null;
+		try {
+			Vector<CTransferVO> v = new Vector();
+			if (vo != null && vo.length > 0)
+				for (int i = 0; i < vo.length; i++) {
+					if (!vo[i].isCaved().booleanValue()
+							&& (null == vo[i].getStyleflag() || !vo[i].getStyleflag().equals("B")))
+						v.add(vo[i]);
+
+				}
+			if (v != null && v.size() > 0) {
+				result = new CTransferVO[v.size()];
+				v.copyInto((Object[]) result);
+			}
+		} catch (Exception exception) {
+		}
+
+		return result;
+	}
+
+	public void doContrast(CTransferVO[] units, CTransferVO[] banks, QConditionVO qconvo) throws BusinessException {
+		ArrayList<CTransferVO> unitVOs = new ArrayList<>();
+		ArrayList<CTransferVO> bankVOs = new ArrayList<>();
+		if (null == units || null == banks)
+
+			return;
+		boolean[] bUnits = new boolean[units.length];
+		boolean[] bBanks = new boolean[banks.length];
+
+		try {
+			if (qconvo.isM_bSameNumber() || qconvo.isM_bSameTranserial()) {
+
+				units = validFilterVO(units);
+				banks = validFilterVO(banks);
+				if (null == units || null == banks)
+					ExceptionUtils.wrapBusinessException(
+							NCLangRes4VoTransl.getNCLangRes().getStrByID("3607002_0", "03607002-0000"));
+
+				Set<String> numAndTrans = new HashSet<>();
+
+				Map<String, UFDouble> bankMoney = new HashMap<>();
+
+				Map<String, UFDouble> unitMoney = new HashMap<>();
+
+				for (CTransferVO bank : banks) {
+					String Number = null;
+					if (StringUtil.isNotNull(bank.getValue(180))) {
+						Number = bank.getValue(180).toString();
+					} else {
+						Number = bank.getValue(140).toString();
+
+					}
+					UFDouble bankAmount = ((UFDouble) bank.getValue(5)).sub((UFDouble) bank.getValue(6));
+
+					if (bankMoney.containsKey(Number)) {
+						bankMoney.put(Number, ((UFDouble) bankMoney.get(Number)).add(bankAmount));
+					} else {
+						bankMoney.put(Number, bankAmount);
+
+					}
+				}
+				for (CTransferVO unit : units) {
+					String Number = null;
+					if (StringUtil.isNotNull(unit.getValue(180))) {
+						Number = unit.getValue(180).toString();
+					} else {
+						Number = unit.getValue(140).toString();
+
+					}
+					UFDouble unitAmount = ((UFDouble) unit.getValue(5)).sub((UFDouble) unit.getValue(6));
+
+					if (unitMoney.containsKey(Number)) {
+						unitMoney.put(Number, ((UFDouble) unitMoney.get(Number)).add(unitAmount));
+					} else {
+						unitMoney.put(Number, unitAmount);
+
+					}
+				}
+				for (Map.Entry<String, UFDouble> entry : bankMoney.entrySet()) {
+					if (unitMoney.containsKey(entry.getKey())
+							&& ((UFDouble) entry.getValue()).equals(unitMoney.get(entry.getKey())))
+						numAndTrans.add(entry.getKey());
+
+				}
+				for (String key : numAndTrans) {
+
+					for (CTransferVO bank : banks) {
+						String Number = null;
+						if (StringUtil.isNotNull(bank.getValue(180))) {
+							Number = bank.getValue(180).toString();
+						} else {
+							Number = bank.getValue(140).toString();
+
+						}
+						if (key.equals(Number))
+							bankVOs.add(bank);
+
+					}
+					for (CTransferVO unit : units) {
+						String Number = null;
+						if (StringUtil.isNotNull(unit.getValue(180))) {
+							Number = unit.getValue(180).toString();
+						} else {
+							Number = unit.getValue(140).toString();
+						}
+						if (key.equals(Number))
+							unitVOs.add(unit);
+
+					}
+				}
+			} else {
+				for (int i = 0; i < banks.length; i++) {
+					if (!bBanks[i]) {
+
+						UFDouble bankAmount = ((UFDouble) banks[i].getValue(5)).sub((UFDouble) banks[i].getValue(6));
+						for (int j = 0; j < units.length; j++) {
+
+							UFDouble unitAmount = ((UFDouble) units[j].getValue(5))
+									.sub((UFDouble) units[j].getValue(6));
+							if (qconvo.blnSimeDirection) {
+
+								if (unitAmount.equals(UFDouble.ZERO_DBL) || bankAmount.equals(UFDouble.ZERO_DBL)
+										|| (!unitAmount.equals(UFDouble.ZERO_DBL)
+												&& !bankAmount.equals(UFDouble.ZERO_DBL)
+												&& !unitAmount.equals(bankAmount)))
+
+									continue;
+							} else if (unitAmount.equals(UFDouble.ZERO_DBL) || bankAmount.equals(UFDouble.ZERO_DBL)
+									|| (!unitAmount.equals(UFDouble.ZERO_DBL) && !bankAmount.equals(UFDouble.ZERO_DBL)
+											&& !unitAmount.add(bankAmount).equals(UFDouble.ZERO_DBL))) {
+
+								continue;
+							}
+							if (qconvo.m_blnSameCheckStyle) {
+
+								String unitCheckStyle = (units[j].getValue(3) == null) ? ""
+										: units[j].getValue(3).toString().trim();
+
+								String bankCheckStyle = (banks[i].getValue(3) == null) ? ""
+										: banks[i].getValue(3).toString().trim();
+								if (!unitCheckStyle.equals(bankCheckStyle) || "".equals(unitCheckStyle)
+										|| "".equals(bankCheckStyle))
+
+									continue;
+							}
+							if (qconvo.m_blnSameVoucherNo) {
+
+								String unitVouchNo = (units[j].getValue(7) == null) ? ""
+										: units[j].getValue(7).toString().trim();
+
+								String bankNoteNo = (banks[i].getValue(4) == null) ? ""
+										: banks[i].getValue(4).toString().trim();
+								if (!unitVouchNo.equals(bankNoteNo) || unitVouchNo.equals(""))
+
+									continue;
+							}
+							if (qconvo.isM_bOppUnitName()) {
+
+								String unitOppUnit = (units[j].getValue(143) == null) ? ""
+										: units[j].getValue(143).toString().trim();
+
+								String bankOppUnit = (banks[i].getValue(141) == null) ? ""
+										: banks[i].getValue(141).toString().trim();
+								if (!unitOppUnit.equals(bankOppUnit) || unitOppUnit.equals(""))
+
+									continue;
+							}
+							if (qconvo.m_blnSameCheckNo) {
+
+								String unitCheckNO = (units[j].getValue(4) == null) ? ""
+										: units[j].getValue(4).toString().trim();
+
+								String bankCheckNO = (banks[i].getValue(4) == null) ? ""
+										: banks[i].getValue(4).toString().trim();
+
+								if (bankCheckNO.equals("") || unitCheckNO.equals(""))
+									continue;
+								if (qconvo.m_iAfterBit == -1) {
+									if (!unitCheckNO.equals(bankCheckNO))
+										continue;
+								} else {
+									if (bankCheckNO.length() >= qconvo.m_iAfterBit
+											&& unitCheckNO.length() >= qconvo.m_iAfterBit) {
+
+										bankCheckNO = bankCheckNO.substring(bankCheckNO.length() - qconvo.m_iAfterBit);
+
+										unitCheckNO = unitCheckNO.substring(unitCheckNO.length() - qconvo.m_iAfterBit);
+
+									}
+									if (!bankCheckNO.equals(unitCheckNO))
+
+										continue;
+								}
+							}
+							if (qconvo.m_iDateSpan > 0) {
+
+								UFDate bankDate = (banks[i].getValue(1) == null) ? new UFDate("1949-10-1")
+										: new UFDate(banks[i].getValue(1).toString());
+
+								UFDate unitDate = (units[j].getValue(1) == null) ? new UFDate("1949-10-1")
+										: new UFDate(units[j].getValue(1).toString());
+								if (qconvo.m_date) {
+									if (Math.abs(UFDate.getDaysBetween(bankDate, unitDate)) > qconvo.m_iDateSpan)
+
+										continue;
+								} else {
+									unitDate = (units[j].getValue(8) == null) ? new UFDate("1949-10-1")
+											: new UFDate(units[j].getValue(8).toString());
+									if (unitDate.after(bankDate)
+											|| UFDate.getDaysBetween(unitDate, bankDate) > qconvo.m_iDateSpan)
+
+										continue;
+								}
+							}
+							if (qconvo.blnSimeDirection) {
+
+								UFDouble money = unitAmount.sub(bankAmount);
+								if (!bUnits[j] && !bBanks[i] && unitAmount
+
+										.doubleValue() != 0.0D && bankAmount.doubleValue() != 0.0D
+										&& money.equals(UFDouble.ZERO_DBL)) {
+
+									unitVOs.add(units[j]);
+									bUnits[j] = true;
+									bankVOs.add(banks[i]);
+									bBanks[i] = true;
+
+								}
+							} else if (!bUnits[j] && !bBanks[i] && unitAmount
+
+									.doubleValue() != 0.0D && bankAmount.doubleValue() != 0.0D
+									&& (new UFDouble(unitAmount.add(bankAmount).doubleValue(), qconvo.getPrecision()))
+											.equals(UFDouble.ZERO_DBL)) {
+								unitVOs.add(units[j]);
+								bUnits[j] = true;
+								bankVOs.add(banks[i]);
+								bBanks[i] = true;
+							}
+							continue;
+						}
+					}
+				}
+			}
+		} catch (Exception e) {
+			Logger.error(e.getMessage(), e);
+			throw new BusinessException(e.getMessage(), e);
+		}
+		if (bankVOs.size() > 0) {
+			this.banks = new IVoAccess[bankVOs.size()];
+			bankVOs.toArray(this.banks);
+		}
+		if (unitVOs.size() > 0) {
+			this.units = new IVoAccess[unitVOs.size()];
+			unitVOs.toArray(this.units);
+		}
+	}
+
+	public void saveContrast(IVoAccess[] unit, IVoAccess[] bank, String batchNumber, GlContrastVO caccount) {
+		ContrastVO[] vos = null;
+		if (unit == null || bank == null)
+
+			return;
+		int countUnit = unit.length;
+		int countBank = bank.length;
+		Object[] unitArray = new Object[countUnit];
+		Object[] bankArray = new Object[countBank];
+		ContrastVO[] units = new ContrastVO[countUnit];
+		ContrastVO[] banks = new ContrastVO[countBank];
+		try {
+			int i;
+			for (i = 0; i < countUnit; i++)
+				unitArray[i] = unit[i].getValue(10);
+
+			for (i = 0; i < countBank; i++)
+				bankArray[i] = bank[i].getValue(10);
+
+			vos = new ContrastVO[countUnit + countBank];
+
+			List<String> batchNumList = ContrastUtils.generateBatchNum(batchNumber, countUnit);
+
+			int j;
+			for (j = 0; j < countUnit; j++) {
+				ContrastVO vo = new ContrastVO();
+				vo.setFk_detail(unitArray[j].toString());
+				vo.setPk_contrastaccount(caccount.getPk_contrastaccount());
+				vo.setContrastdate(new UFDate(SessionContext.getInstance().getClientInfo().getBizDateTime()));
+				vo.setCorpdate((unit[j].getValue(1) == null) ? null : new UFDate(unit[j].getValue(1).toString()));
+				vo.setMoney((UFDouble) unit[j].getValue(51));
+				if (unit[j].getValue(5) != null && Double.parseDouble(unit[j].getValue(5).toString()) != 0.0D) {
+					vo.setIsDebit(UFBoolean.TRUE);
+				} else {
+					vo.setIsDebit(UFBoolean.FALSE);
+				}
+				vo.setBatchNumber(batchNumList.get(j));
+				vos[j] = vo;
+				units[j] = vo;
+			}
+			for (j = 0; j < countBank; j++) {
+				ContrastVO vo = new ContrastVO();
+				vo.setPk_bankreceipt(bankArray[j].toString());
+				vo.setPk_contrastaccount(caccount.getPk_contrastaccount());
+				vo.setContrastdate(new UFDate(SessionContext.getInstance().getClientInfo().getBizDateTime()));
+				vo.setCorpdate((bank[j].getValue(1) == null) ? null : new UFDate(bank[j].getValue(1).toString()));
+				vo.setMoney((UFDouble) bank[j].getValue(51));
+				if (bank[j].getValue(5) != null && Double.parseDouble(bank[j].getValue(5).toString()) != 0.0D) {
+					vo.setIsDebit(UFBoolean.TRUE);
+				} else {
+					vo.setIsDebit(UFBoolean.FALSE);
+				}
+				vo.setBatchNumber(batchNumList.get(j));
+				vos[j + countUnit] = vo;
+				banks[j] = vo;
+			}
+			if (vos.length > 0) {
+				if (caccount.getSource().intValue() == 2)
+					vos = splitVoFromDJ(vos);
+
+				((IContrastPrv) ServiceLocator.find(IContrastPrv.class)).insertContrasts(vos, caccount);
+
+			}
+			
+			for(int k = 0;k < banks.length;k++) {
+				String pk_src = banks[k].getPk_bankreceipt();//银行对账单主键
+				String fk_detail = units[k].getFk_detail();
+				String money = !banks[k].getMoney().toString().equals("0.00")?banks[k].getMoney().toString():banks[k].getMoney().toString();
+				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();
+					}
+				}
+			}
+			
+			for(String str : batchNumList) {
+				doSyFile(str);
+			}
+			
+		} catch (Throwable e) {
+			Logger.error(e.getMessage(), e);
+			return;
+		}
+	}
+
+	private ContrastVO[] splitVoFromDJ(ContrastVO[] vos) {
+		ArrayList<ContrastVO> voList = new ArrayList<>();
+		for (int i = 0; i < vos.length; i++) {
+			String strfks = vos[i].getFk_detail();
+			if (StringUtil.isNotNull(strfks)) {
+				String[] fks = strfks.split("@@");
+				if (fks != null && fks.length > 0)
+					for (int j = 0; j < fks.length; j++) {
+						ContrastVO tempvo = (ContrastVO) vos[i].clone();
+						tempvo.setFk_detail(fks[j]);
+						voList.add(tempvo);
+					}
+			} else {
+				voList.add(vos[i]);
+			}
+		}
+		vos = new ContrastVO[voList.size()];
+		voList.toArray(vos);
+		return vos;
+	}
+
+	public CTransferVO[] validFilterVO(CTransferVO[] vos) {
+		ArrayList<CTransferVO> result = new ArrayList<>();
+		try {
+			for (CTransferVO vo : vos) {
+				if (StringUtil.isNotNull(vo.getValue(140)) || StringUtil.isNotNull(vo.getValue(180)))
+
+					result.add(vo);
+
+			}
+		} catch (Exception e) {
+			return null;
+		}
+		if (null != result && result.size() > 0)
+			return result.<CTransferVO>toArray(new CTransferVO[0]);
+
+		return null;
+	}
+	
+	/**
+	 * @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");
+	}
+}

+ 541 - 0
zjcmp_cd/zjcmp_cd/src/client/nccloud/web/cmp/bankcontrast/actions/BankContrastCancelAction.java

@@ -0,0 +1,541 @@
+package nccloud.web.cmp.bankcontrast.actions;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import nc.bs.dao.BaseDAO;
+import nc.bs.framework.common.NCLocator;
+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.ColumnListProcessor;
+import nc.jdbc.framework.processor.ColumnProcessor;
+import nc.vo.cmp.bankaccbook.BankAccDetailVO;
+import nc.vo.cmp.cb.ContrastVO;
+import nc.vo.cmp.cb.GLQueryVO;
+import nc.vo.cmp.cb.GlContrastVO;
+import nc.vo.cmp.informer.InformerVO;
+import nc.vo.pub.BusinessException;
+import nc.vo.pub.lang.UFDate;
+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.BankContrastCancelJsonToVo;
+import nccloud.web.cmp.contrastcommon.actions.BankContrastUtils;
+
+public class BankContrastCancelAction implements ICommonAction {
+	public Object doAction(IRequest request) {
+		String read = request.read();
+		IJson iJon = JsonFactory.create();
+		BankContrastCancelJsonToVo jSonVo = (BankContrastCancelJsonToVo) iJon.fromJson(read,
+				BankContrastCancelJsonToVo.class);
+
+		ContrastVO[] contrastVoArr = { jSonVo.getContrastVo() };
+		int flag = jSonVo.getFlag();
+		GlContrastVO glContrastVo = null;
+		BaseDAO basedao = new BaseDAO();
+		IUAPQueryBS iuap=(IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
+		GLQueryVO query = new GLQueryVO();
+		query.setPK_contrastaccount(new String[] { jSonVo.getGlContrastVo().getPk_contrastaccount() });
+		query.setPk_user(SessionContext.getInstance().getClientInfo().getUserid());
+		String year = BankContrastUtils.getAccountYear(jSonVo.getGlContrastVo().getPk_corp(),
+		new UFDate(SessionContext.getInstance().getClientInfo().getBizDateTime()), null);
+
+		query.setYears(year);
+
+		GlContrastVO[] glContrastArr = null;
+		try {
+			glContrastArr = ((IContrastAccountPrv) ServiceLocator.find(IContrastAccountPrv.class))
+					.queryContrastAccount(query);
+			if (glContrastArr == null || glContrastArr.length == 0)
+				return null;
+
+			glContrastVo = glContrastArr[0];
+
+		} catch (BusinessException e) {
+			e.printStackTrace();
+
+		}
+		try {
+			//回写到账通知
+			ContrastVO[] newConts = null;
+			if(contrastVoArr[0].getContrastdate()!=null) {
+				String enddate = contrastVoArr[0].getContrastdate().toString().substring(0, 11).concat("23:59:59");
+				newConts = (ContrastVO[]) getSer().queryByCondition(ContrastVO.class, " pk_contrastaccount = '" + contrastVoArr[0].getPk_contrastaccount() + "' and contrastdate >= '"+contrastVoArr[0].getContrastdate().toString()+"' and contrastdate <= '"+enddate+"'");
+			}
+			else if(contrastVoArr[0].getBatchNumber()!=null) {
+				newConts = (ContrastVO[]) getSer().queryByCondition(ContrastVO.class, " pk_contrastaccount = '" + contrastVoArr[0].getPk_contrastaccount() + "' and batchnumber = '"+contrastVoArr[0].getBatchNumber()+"'");
+			}
+			for(int i = 0;i < newConts.length; i++) {
+				String fk_detail = newConts[i].getFk_detail();//下游单据主键
+				String qrysql = "select * from cmp_bankaccdetail where dr=0 and pk_bankaccdetail = '"+fk_detail+"'";
+				if(!(fk_detail==null)&&!(fk_detail.equals(""))) {
+					try {
+						BankAccDetailVO detailvo = (BankAccDetailVO) iuap.executeQuery(qrysql,new BeanProcessor(BankAccDetailVO.class));
+						String vbillno = detailvo.getVbillno();
+						String billtypecode = detailvo.getPk_billtype();
+						//根据不同单据类型去查对应来源单据主键,如果来源单据主键为空则为手工单,执行回写操作
+						if(vbillno.startsWith("3641")) {
+							String applysql = "select vdef5,pk_apply from ifm_apply where dr=0 and vbillno = '"+vbillno+"' ";
+							String billsource = (String) iuap.executeQuery(applysql,new ColumnProcessor("vdef5"));
+							String pk_lower = (String) iuap.executeQuery(applysql,new ColumnProcessor("pk_apply"));
+							String existqry = "select pk_informer from cmp_informer where dr=0 and pk_lower = '"+pk_lower+"'";
+							String pk_informer = (String) iuap.executeQuery(existqry, new ColumnProcessor());
+							if((billsource==null||billsource=="~")&&pk_informer!=null) {
+								String updatesql = "update cmp_informer set generateflag = 'hasnogenerate',usemoney = '0',pk_claimer='',claimdate='',pk_lower='',lowerbilltype='' where dr=0 and pk_lower = '"+pk_lower+"'";
+								try {
+									basedao.executeUpdate(updatesql);
+									continue;
+								} catch (Exception e) {
+									// TODO Auto-generated catch block
+									e.printStackTrace();
+								}
+							}
+						}
+						else if(vbillno.startsWith("3642")) {
+							String redeemsql = "select vdef8,pk_redeem from ifm_redeem where dr=0 and vbillno = '"+vbillno+"' ";
+							String billsource = (String) iuap.executeQuery(redeemsql,new ColumnProcessor("vdef8"));
+							String pk_lower = (String) iuap.executeQuery(redeemsql,new ColumnProcessor("pk_redeem"));
+							String existqry = "select pk_informer from cmp_informer where dr=0 and pk_lower = '"+pk_lower+"'";
+							String pk_informer = (String) iuap.executeQuery(existqry, new ColumnProcessor());
+							if((billsource==null||billsource=="~")&&pk_informer!=null) {
+								String updatesql = "update cmp_informer set generateflag = 'hasnogenerate',usemoney = '0',pk_claimer='',claimdate='',pk_lower='',lowerbilltype='' where dr=0 and pk_lower = '"+pk_lower+"'";
+								try {
+									basedao.executeUpdate(updatesql);
+									continue;
+								} catch (Exception e) {
+									// TODO Auto-generated catch block
+									e.printStackTrace();
+								}
+							}
+						}
+						else if(vbillno.startsWith("3643")) {
+							String incomesql = "select pk_srcbill,pk_income from ifm_income where dr=0 and vbillno = '"+vbillno+"' ";
+							String billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
+							String pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_income"));
+							String existqry = "select pk_informer from cmp_informer where dr=0 and pk_lower = '"+pk_lower+"'";
+							String pk_informer = (String) iuap.executeQuery(existqry, new ColumnProcessor());
+							if((billsource==null||billsource=="~")&&pk_informer!=null) {
+								String updatesql = "update cmp_informer set generateflag = 'hasnogenerate',usemoney = '0',pk_claimer='',claimdate='',pk_lower='',lowerbilltype='' where dr=0 and pk_lower = '"+pk_lower+"'";
+								try {
+									basedao.executeUpdate(updatesql);
+									continue;
+								} catch (Exception e) {
+									// TODO Auto-generated catch block
+									e.printStackTrace();
+								}
+							}
+						}
+						else if(vbillno.startsWith("36CO")||billtypecode=="0001Z610000000036COA") {
+							String incomesql = "select pk_srcbill,pk_repayprcplr_h from icdmc_repayprcplreceipt where dr=0 and vbillno = '"+vbillno+"' ";
+							String billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
+							String pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_repayprcplr_h"));
+							String existqry = "select pk_informer from cmp_informer where dr=0 and pk_lower = '"+pk_lower+"'";
+							String pk_informer = (String) iuap.executeQuery(existqry, new ColumnProcessor());
+							if((billsource==null||billsource=="~")&&pk_informer!=null) {
+								String updatesql = "update cmp_informer set generateflag = 'hasnogenerate',usemoney = '0',pk_claimer='',claimdate='',pk_lower='',lowerbilltype='' where dr=0 and pk_lower = '"+pk_lower+"'";
+								try {
+									basedao.executeUpdate(updatesql);
+									continue;
+								} catch (Exception e) {
+									// TODO Auto-generated catch block
+									e.printStackTrace();
+								}
+							}
+						}
+						else if(vbillno.startsWith("36CP")||billtypecode=="0001Z610000000036CPA") {
+							String incomesql = "select pk_srcbill,pk_financepayreceipt from icdmc_financepayreceipt where dr=0 and vbillno = '"+vbillno+"' ";
+							String billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
+							String pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_financepayreceipt"));
+							String existqry = "select pk_informer from cmp_informer where dr=0 and pk_lower = '"+pk_lower+"'";
+							String pk_informer = (String) iuap.executeQuery(existqry, new ColumnProcessor());
+							if((billsource==null||billsource=="~")&&pk_informer!=null) {
+								String updatesql = "update cmp_informer set generateflag = 'hasnogenerate',usemoney = '0',pk_claimer='',claimdate='',pk_lower='',lowerbilltype='' where dr=0 and pk_lower = '"+pk_lower+"'";
+								try {
+									basedao.executeUpdate(updatesql);
+									continue;
+								} catch (Exception e) {
+									// TODO Auto-generated catch block
+									e.printStackTrace();
+								}
+							}
+						}
+						else if(vbillno.startsWith("36K2")) {
+							String incomesql = "select pk_srcbill,pk_allocate_h from sf_allocate_h where dr=0 and vbillno = '"+vbillno+"' ";
+							String billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
+							String pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_allocate_h"));
+							String existqry = "select pk_informer from cmp_informer where dr=0 and pk_lower = '"+pk_lower+"'";
+							String pk_informer = (String) iuap.executeQuery(existqry, new ColumnProcessor());
+							if((billsource==null||billsource=="~")&&pk_informer!=null) {
+								String updatesql = "update cmp_informer set generateflag = 'hasnogenerate',usemoney = '0',pk_claimer='',claimdate='',pk_lower='',lowerbilltype='' where dr=0 and pk_lower = '"+pk_lower+"'";
+								try {
+									basedao.executeUpdate(updatesql);
+									continue;
+								} catch (Exception e) {
+									// TODO Auto-generated catch block
+									e.printStackTrace();
+								}
+							}
+						}
+						else if(vbillno.startsWith("36K4")) {
+							String incomesql = "select pk_srcbill,pk_delivery_h from sf_delivery_h where dr=0 and vbillno = '"+vbillno+"' ";
+							String billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
+							String pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_delivery_h"));
+							String existqry = "select pk_informer from cmp_informer where dr=0 and pk_lower = '"+pk_lower+"'";
+							String pk_informer = (String) iuap.executeQuery(existqry, new ColumnProcessor());
+							if((billsource==null||billsource=="~")&&pk_informer!=null) {
+								String updatesql = "update cmp_informer set generateflag = 'hasnogenerate',usemoney = '0',pk_claimer='',claimdate='',pk_lower='',lowerbilltype='' where dr=0 and pk_lower = '"+pk_lower+"'";
+								try {
+									basedao.executeUpdate(updatesql);
+									continue;
+								} catch (Exception e) {
+									// TODO Auto-generated catch block
+									e.printStackTrace();
+								}
+							}
+						}
+						else if(vbillno.startsWith("36K8")) {
+							String incomesql = "select pk_srcbill,pk_allocatereceipt  from sf_allocatereceipt where dr=0 and vbillno = '"+vbillno+"' ";
+							String billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
+							String pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_allocatereceipt"));
+							String existqry = "select pk_informer from cmp_informer where dr=0 and pk_lower = '"+pk_lower+"'";
+							String pk_informer = (String) iuap.executeQuery(existqry, new ColumnProcessor());
+							if((billsource==null||billsource=="~")&&pk_informer!=null) {
+								String updatesql = "update cmp_informer set generateflag = 'hasnogenerate',usemoney = '0',pk_claimer='',claimdate='',pk_lower='',lowerbilltype='' where dr=0 and pk_lower = '"+pk_lower+"'";
+								try {
+									basedao.executeUpdate(updatesql);
+									continue;
+								} catch (Exception e) {
+									// TODO Auto-generated catch block
+									e.printStackTrace();
+								}
+							}
+						}
+						else if(vbillno.startsWith("36K9")) {
+							String incomesql = "select pk_srcbill,pk_deliveryreceipt from sf_deliveryreceipt where dr=0 and vbillno = '"+vbillno+"' ";
+							String billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
+							String pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_deliveryreceipt"));
+							String existqry = "select pk_informer from cmp_informer where dr=0 and pk_lower = '"+pk_lower+"'";
+							String pk_informer = (String) iuap.executeQuery(existqry, new ColumnProcessor());
+							if((billsource==null||billsource=="~")&&pk_informer!=null) {
+								String updatesql = "update cmp_informer set generateflag = 'hasnogenerate',usemoney = '0',pk_claimer='',claimdate='',pk_lower='',lowerbilltype='' where dr=0 and pk_lower = '"+pk_lower+"'";
+								try {
+									basedao.executeUpdate(updatesql);
+									continue;
+								} catch (Exception e) {
+									// TODO Auto-generated catch block
+									e.printStackTrace();
+								}
+							}
+						}
+						else if(vbillno.startsWith("36LJ")) {
+							String incomesql = "select pk_srcbill,pk_fixdepositreceipt from ifac_fixdepositreceipt where dr=0 and vbillno = '"+vbillno+"' ";
+							String billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
+							String pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_fixdepositreceipt"));
+							String existqry = "select pk_informer from cmp_informer where dr=0 and pk_lower = '"+pk_lower+"'";
+							String pk_informer = (String) iuap.executeQuery(existqry, new ColumnProcessor());
+							if((billsource==null||billsource=="~")&&pk_informer!=null) {
+								String updatesql = "update cmp_informer set generateflag = 'hasnogenerate',usemoney = '0',pk_claimer='',claimdate='',pk_lower='',lowerbilltype='' where dr=0 and pk_lower = '"+pk_lower+"'";
+								try {
+									basedao.executeUpdate(updatesql);
+									continue;
+								} catch (Exception e) {
+									// TODO Auto-generated catch block
+									e.printStackTrace();
+								}
+							}
+						}
+						else if(vbillno.startsWith("36LK")) {
+							String incomesql = "select pk_srcbill,pk_receipt from ifac_fixeddatewithdrawreceipt where dr=0 and vbillno = '"+vbillno+"' ";
+							String billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
+							String pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_receipt"));
+							String existqry = "select pk_informer from cmp_informer where dr=0 and pk_lower = '"+pk_lower+"'";
+							String pk_informer = (String) iuap.executeQuery(existqry, new ColumnProcessor());
+							if((billsource==null||billsource=="~")&&pk_informer!=null) {
+								String updatesql = "update cmp_informer set generateflag = 'hasnogenerate',usemoney = '0',pk_claimer='',claimdate='',pk_lower='',lowerbilltype='' where dr=0 and pk_lower = '"+pk_lower+"'";
+								try {
+									basedao.executeUpdate(updatesql);
+									continue;
+								} catch (Exception e) {
+									// TODO Auto-generated catch block
+									e.printStackTrace();
+								}
+							}
+						}
+						else if(vbillno.startsWith("36S1")) {
+							String incomesql = "select pk_srcbill,pk_cashdeposit from cmp_cashdeposit where dr=0 and bill_no = '"+vbillno+"' ";
+							String billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
+							String pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_cashdeposit"));
+							String existqry = "select pk_informer from cmp_informer where dr=0 and pk_lower = '"+pk_lower+"'";
+							String pk_informer = (String) iuap.executeQuery(existqry, new ColumnProcessor());
+							if((billsource==null||billsource=="~")&&pk_informer!=null) {
+								String updatesql = "update cmp_informer set generateflag = 'hasnogenerate',usemoney = '0',pk_claimer='',claimdate='',pk_lower='',lowerbilltype='' where dr=0 and pk_lower = '"+pk_lower+"'";
+								try {
+									basedao.executeUpdate(updatesql);
+									continue;
+								} catch (Exception e) {
+									// TODO Auto-generated catch block
+									e.printStackTrace();
+								}
+							}
+						}
+						else if(vbillno.startsWith("36S2")) {
+							String incomesql = "select pk_srcbill,pk_cashdraw from cmp_cashdraw where dr=0 and billno = '"+vbillno+"' ";
+							String billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
+							String pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_cashdraw"));
+							String existqry = "select pk_informer from cmp_informer where dr=0 and pk_lower = '"+pk_lower+"'";
+							String pk_informer = (String) iuap.executeQuery(existqry, new ColumnProcessor());
+							if((billsource==null||billsource=="~")&&pk_informer!=null) {
+								String updatesql = "update cmp_informer set generateflag = 'hasnogenerate',usemoney = '0',pk_claimer='',claimdate='',pk_lower='',lowerbilltype='' where dr=0 and pk_lower = '"+pk_lower+"'";
+								try {
+									basedao.executeUpdate(updatesql);
+									continue;
+								} catch (Exception e) {
+									// TODO Auto-generated catch block
+									e.printStackTrace();
+								}
+							}
+						}
+						else if(vbillno.startsWith("36S4")) {
+							String incomesql = "select pk_srcbill,pk_transformbill from cmp_transformbill where dr=0 and vbillno = '"+vbillno+"' ";
+							String billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
+							String pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_transformbill"));
+							String existqry = "select pk_informer from cmp_informer where dr=0 and pk_lower = '"+pk_lower+"'";
+							String pk_informer = (String) iuap.executeQuery(existqry, new ColumnProcessor());
+							if((billsource==null||billsource=="~")&&pk_informer!=null) {
+								String updatesql = "update cmp_informer set generateflag = 'hasnogenerate',usemoney = '0',pk_claimer='',claimdate='',pk_lower='',lowerbilltype='' where dr=0 and pk_lower = '"+pk_lower+"'";
+								try {
+									basedao.executeUpdate(updatesql);
+									continue;
+								} catch (Exception e) {
+									// TODO Auto-generated catch block
+									e.printStackTrace();
+								}
+							}
+						}
+						else if(billtypecode.equals("36Z3")) {
+							String incomesql = "select pk_srcbill,pk_financepay from cdmc_financepay where dr=0 and vbillno = '"+vbillno+"' ";
+							String billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
+							String pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_financepay"));
+							String existqry = "select pk_informer from cmp_informer where dr=0 and pk_lower = '"+pk_lower+"'";
+							String pk_informer = (String) iuap.executeQuery(existqry, new ColumnProcessor());
+							if((billsource==null||billsource=="~")&&pk_informer!=null) {
+								String updatesql = "update cmp_informer set generateflag = 'hasnogenerate',usemoney = '0',pk_claimer='',claimdate='',pk_lower='',lowerbilltype='' where dr=0 and pk_lower = '"+pk_lower+"'";
+								try {
+									basedao.executeUpdate(updatesql);
+									continue;
+								} catch (Exception e) {
+									// TODO Auto-generated catch block
+									e.printStackTrace();
+								}
+							}
+						}
+						else if(billtypecode.equals("36Z4")||billtypecode=="0001Z61000000003D2O3") {
+							String incomesql = "select vdef4,pk_repayprcpl from cdmc_repayprcpl where dr=0 and vbillno = '"+vbillno+"' ";
+							String billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("vdef4"));
+							String pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_repayprcpl"));
+							String existqry = "select pk_informer from cmp_informer where dr=0 and pk_lower = '"+pk_lower+"'";
+							String pk_informer = (String) iuap.executeQuery(existqry, new ColumnProcessor());
+							if((billsource==null||billsource=="~")&&pk_informer!=null) {
+								String updatesql = "update cmp_informer set generateflag = 'hasnogenerate',usemoney = '0',pk_claimer='',claimdate='',pk_lower='',lowerbilltype='' where dr=0 and pk_lower = '"+pk_lower+"'";
+								try {
+									basedao.executeUpdate(updatesql);
+									continue;
+								} catch (Exception e) {
+									// TODO Auto-generated catch block
+									e.printStackTrace();
+								}
+							}
+						}
+						else if(billtypecode.equals("36Z5")||billtypecode=="0001Z61000000003CWBP") {
+							String incomesql = "select pk_srcbill,pk_repayintst from cdmc_repinterest where dr=0 and vbillno = '"+vbillno+"' ";
+							String billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_srcbill"));
+							String pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_repayintst"));
+							String existqry = "select pk_informer from cmp_informer where dr=0 and pk_lower = '"+pk_lower+"'";
+							String pk_informer = (String) iuap.executeQuery(existqry, new ColumnProcessor());
+							if((billsource==null||billsource=="~")&&pk_informer!=null) {
+								String updatesql = "update cmp_informer set generateflag = 'hasnogenerate',usemoney = '0',pk_claimer='',claimdate='',pk_lower='',lowerbilltype='' where dr=0 and pk_lower = '"+pk_lower+"'";
+								try {
+									basedao.executeUpdate(updatesql);
+									continue;
+								} catch (Exception e) {
+									// TODO Auto-generated catch block
+									e.printStackTrace();
+								}
+							}
+						}
+						else if(vbillno.startsWith("D2")) {
+							String incomesql = "select def11,pk_gatherbill from ar_gatherbill where dr=0 and billno = '"+vbillno+"' ";
+							String billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("def11"));
+							String pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_gatherbill"));
+							String existqry = "select pk_informer from cmp_informer where dr=0 and pk_lower = '"+pk_lower+"'";
+							String pk_informer = (String) iuap.executeQuery(existqry, new ColumnProcessor());
+							if((billsource==null||billsource=="~")&&pk_informer!=null) {
+								String updatesql = "update cmp_informer set generateflag = 'hasnogenerate',usemoney = '0',pk_claimer='',claimdate='',pk_lower='',lowerbilltype='' where dr=0 and pk_lower = '"+pk_lower+"'";
+								try {
+									basedao.executeUpdate(updatesql);
+									continue;
+								} catch (Exception e) {
+									// TODO Auto-generated catch block
+									e.printStackTrace();
+								}
+							}
+						}
+						else if(vbillno.startsWith("D3")) {
+							String incomesql = "select pk_paybill from ap_paybill where dr=0 and billno = '"+vbillno+"' ";
+							String pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor());
+							String existqry = "select pk_informer from cmp_informer where dr=0 and pk_lower = '"+pk_lower+"'";
+							String pk_informer = (String) iuap.executeQuery(existqry, new ColumnProcessor());
+							if(pk_informer!=null) {
+								String updatesql = "update cmp_informer set generateflag = 'hasnogenerate',usemoney = '0',pk_claimer='',claimdate='',pk_lower='',lowerbilltype='' where dr=0 and pk_lower = '"+pk_lower+"'";
+								try {
+									basedao.executeUpdate(updatesql);
+									continue;
+								} catch (Exception e) {
+									// TODO Auto-generated catch block
+									e.printStackTrace();
+								}
+							}
+						}
+						else if(vbillno.startsWith("F4")) {
+							String incomesql = "select pk_upbill,pk_recbill from cmp_recbill where dr=0 and bill_no = '"+vbillno+"' ";
+							String billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_upbill"));
+							String pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_recbill"));
+							String existqry = "select pk_informer from cmp_informer where dr=0 and pk_lower = '"+pk_lower+"'";
+							String pk_informer = (String) iuap.executeQuery(existqry, new ColumnProcessor());
+							if((billsource==null||billsource=="~")&&pk_informer!=null) {
+								String updatesql = "update cmp_informer set generateflag = 'hasnogenerate',usemoney = '0',pk_claimer='',claimdate='',pk_lower='',lowerbilltype='' where dr=0 and pk_lower = '"+pk_lower+"'";
+								try {
+									basedao.executeUpdate(updatesql);
+									continue;
+								} catch (Exception e) {
+									// TODO Auto-generated catch block
+									e.printStackTrace();
+								}
+							}
+						}
+						else if(vbillno.startsWith("F5")) {
+							String incomesql = "select def11,pk_paybill from cmp_paybill where dr=0 and bill_no = '"+vbillno+"' ";
+							String billsource = (String) iuap.executeQuery(incomesql,new ColumnProcessor("def11"));
+							String pk_lower = (String) iuap.executeQuery(incomesql,new ColumnProcessor("pk_paybill"));
+							String existqry = "select pk_informer from cmp_informer where dr=0 and pk_lower = '"+pk_lower+"'";
+							String pk_informer = (String) iuap.executeQuery(existqry, new ColumnProcessor());
+							if((billsource==null||billsource=="~")&&pk_informer!=null) {
+								String updatesql = "update cmp_informer set generateflag = 'hasnogenerate',usemoney = '0',pk_claimer='',claimdate='',pk_lower='',lowerbilltype='' where dr=0 and pk_lower = '"+pk_lower+"'";
+								try {
+									basedao.executeUpdate(updatesql);
+									continue;
+								} catch (Exception e) {
+									// TODO Auto-generated catch block
+									e.printStackTrace();
+								}
+							}
+						}
+					} catch (Exception e) {
+						// TODO Auto-generated catch block
+						e.printStackTrace();
+					}
+				}
+			}
+				
+			// 这里改完全是图省事了,考虑量不会太大 代码效率拉一点也不影响。
+			Map<String, Map<String, String[]>> oldMap = null;
+			List<Map<String, Map<String, String[]>>> newList = new ArrayList<Map<String, Map<String, String[]>>>();
+			if(contrastVoArr.length > 0) {
+				String where = " select batchnumber from gl_contrast where pk_contrastaccount = '" + contrastVoArr[0].getPk_contrastaccount() + "' ";
+				// 1、按批次号
+				if(contrastVoArr.length > 0 && contrastVoArr[0].getBatchNumber() != null) {
+					where += " and batchNumber = '" + contrastVoArr[0].getBatchNumber() + "' ";
+					
+				}
+				// 2、按日期
+				if(contrastVoArr.length > 0 && contrastVoArr[0].getContrastdate() != null) {
+					if(flag == 0) {
+						where += " and nvl(cavdate,'~')='~' and contrastdate  >= '" + contrastVoArr[0].getContrastdate() + "' ";
+					} 
+					if(flag == 1) {
+						where += " and nvl(cavdate,'~')='~' and contrastcode in  (select contrastcode from gl_contrast where corpdate >= '" + contrastVoArr[0].getContrastdate() + "' group by contrastcode)";
+					}
+				}
+				
+				where += " group by batchnumber";
+				
+				// 查询本次取消的对账记录
+				List<String> numList = (List<String>) getDao().executeQuery(where, new ColumnListProcessor());
+				for(String batnum : numList) {
+					ContrastVO[] oldConts = (ContrastVO[]) getSer().queryByCondition(ContrastVO.class, " batchNumber = '" + batnum + "' ");
+					oldMap = getSySer().getConts_RequiresNew(oldConts);
+					newList.add(oldMap);
+				}
+					
+				
+				
+				((IContrastPrv)ServiceLocator.find(IContrastPrv.class)).deleteContrast(contrastVoArr, flag, glContrastVo);
+				
+				
+				
+				// 回退附件
+				for(Map<String, Map<String, String[]>> m : newList) {
+					doSyFile(m);
+				}
+				
+				
+			}
+			
+		} catch (BusinessException e) {
+			e.printStackTrace();
+
+		}
+		return null;
+	}
+	
+	/**
+	 * @Title:doSyFile
+	 * @Description: [method] TODO whz 2022.3.4.15 取消对账触发回退附件
+	 * @return void
+	 * @param billPK
+	 * @throws BusinessException 
+	 * @Create: whz
+	 * @date: 2022年3月4日 下午3:30:17
+	 */
+	private void doSyFile(Map<String, Map<String, String[]>> map) throws BusinessException {
+		// 开始回退
+		for(String key : map.keySet()) {
+			getSySer().delBillFile_RequiresNew(map.get(key), "cmp");
+		}
+	}
+	
+	private ISyFileRequiresNew sySer;
+	
+	private ISyFileRequiresNew getSySer() {
+		if(sySer == null) {
+			sySer = NCLocator.getInstance().lookup(ISyFileRequiresNew.class);
+		}
+		return sySer;
+	}
+	
+	private IUifService service;
+	
+	private IUifService getSer() {
+		if(service == null) {
+			service = NCLocator.getInstance().lookup(IUifService.class);
+		}
+		return service;
+	}
+	private IUAPQueryBS dao;
+	
+	private IUAPQueryBS getDao() {
+		if(dao == null) {
+			dao = NCLocator.getInstance().lookup(IUAPQueryBS.class);
+		}
+		return dao;
+	}
+}

+ 784 - 0
zjcmp_cd/zjcmp_cd/src/client/nccloud/web/cmp/bankcontrast/actions/BankContrastSaveAction.java

@@ -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");
+	}
+}

+ 11 - 2
zjcmp_cd/zjcmp_cd/src/client/nccloud/web/cmp/billmanagement/paybills/action/PaybillsInsertAction.java

@@ -1,7 +1,9 @@
 package nccloud.web.cmp.billmanagement.paybills.action;
 
+import nc.bs.dao.BaseDAO;
 import nc.bs.framework.common.NCLocator;
 import nc.impl.pubapp.pattern.data.vo.VOQuery;
+import nc.itf.uap.IUAPQueryBS;
 import nc.itf.uap.IVOPersistence;
 import nc.vo.cmp.bill.BillAggVO;
 import nc.vo.cmp.bill.BillDetailVO;
@@ -28,13 +30,13 @@ public class PaybillsInsertAction extends PaybillsCommonAction {
 		plog.start("paybillzhuanhuan-vo");
 		BillAggVO vo = super.aggVOConvert(request);
 		plog.end("paybill-zhuanhuanvo");
+		BaseDAO basedao = new BaseDAO();
 		if (null != vo.getParentVO()) {
 			((BillVO) vo.getParentVO()).setBill_status(-10);
 			((BillVO) vo.getParentVO()).setBill_type("F5");
 			BillDetailVO[] detailvos = (BillDetailVO[]) vo.getChildrenVO();
 			for (BillDetailVO detailvo: detailvos) {
 				detailvo.setBill_type("F5");
-				
 			}
 		}
 //		if(null == ((BillVO)vo.getParentVO()).getCustomerName()) {
@@ -99,7 +101,14 @@ public class PaybillsInsertAction extends PaybillsCommonAction {
 					// TODO Auto-generated catch block
 				   ExceptionUtils.wrapBusinessException(e.getMessage());
 				}
-		    	 
+		    	 String bill_no = headvo.getBill_no();
+		    	String updatesql = "update cmp_settlement set settletype = '11' where dr=0 and billcode = '"+bill_no+"'";
+		    	try {
+					basedao.executeUpdate(updatesql);
+				} catch (Exception e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
 		      }
 
 		  }

+ 88 - 17
zjcmp_cd/zjcmp_cd/src/client/nccloud/web/cmp/informer/informer/action/ListCancelGenerateAction.java

@@ -4,6 +4,7 @@ import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import nc.vo.cdmc.cdm.repayintst.AggRepayIntstVO;
+import nc.vo.cdmc.cdm.repayintst.RepayIntstVO;
 import nc.vo.cdmc.cdm.repayprcpl.AggRepayPrcplVO;
 import nc.bs.framework.common.NCLocator;
 import nc.bs.framework.json.core.exception.BusinessException;
@@ -16,10 +17,14 @@ import nc.jdbc.framework.processor.BeanProcessor;
 import nc.jdbc.framework.processor.ColumnProcessor;
 import nc.md.persist.framework.IMDPersistenceQueryService;
 import nc.ui.trade.business.HYPubBO_Client;
+import nc.vo.arap.gathering.AggGatheringBillVO;
+import nc.vo.arap.gathering.GatheringBillVO;
 import nc.vo.cdmc.cdm.contract.ContractVO;
 import nc.vo.cdmc.cdm.contract.PayPlanVO;
 import nc.vo.cdmc.cdm.financepay.AggFinancepayVO;
 import nc.vo.cdmc.cdm.financepay.FinancepayVO;
+import nc.vo.cmp.bill.BillAggVO;
+import nc.vo.cmp.bill.BillVO;
 import nc.vo.cmp.informer.GenerateFlagEnum;
 import nc.vo.cmp.informer.InformerAppendVO;
 import nc.vo.cmp.informer.InformerVO;
@@ -131,29 +136,76 @@ public Object doAction(IRequest request)
 				IVOPersistence.updateVO(cancelvos[i]);
 			}
 			
-			if("36Z5".equals(cancelvos[i].getLowerbilltype())) {
-	        	try {
-	        		AggRepayIntstVO aggrepayintstvo = (AggRepayIntstVO) service.queryBillOfNCObjectByPK(AggRepayIntstVO.class,cancelvos[i].getPk_lower()).getContainmentObject();
-					ipf.processAction("DELETE", "36Z5", null, aggrepayintstvo, null, null);//删除贷款付息单
-				} catch (Exception e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
+			
+			
+			if("F2".equals(cancelvos[i].getLowerbilltype())) {
+				AggGatheringBillVO agggatheringbill = (AggGatheringBillVO) service.queryBillOfNCObjectByPK(AggGatheringBillVO.class, cancelvos[i].getPk_lower()).getContainmentObject();
+				GatheringBillVO gatheringbillvo = agggatheringbill.getHeadVO();
+				String billstatus = gatheringbillvo.getBillstatus().toString();
+				if(billstatus.equals("1")||billstatus.equals("8")) {
+					ExceptionUtils.wrapBusinessException("单据已经签字确认,不能删除!");
+					return null;
 				}
-	        	
-	        	cancelvos[i].setGenerateflag("hasnogenerate");
-	        	cancelvos[i].setUsemoney(new UFDouble(0));
-	        	cancelvos[i].setPk_claimer("");
-	        	cancelvos[i].setUsemoney(new UFDouble(0));
-	        	cancelvos[i].setClaimdate(null);
-	        	cancelvos[i].setPk_lower("");
-	        	cancelvos[i].setLowerbilltype("");
-	        	IVOPersistence.updateVO(cancelvos[i]);//修改到账通知单
-	        }
+			}
+			
+			if("F5".equals(cancelvos[i].getLowerbilltype())) {
+				BillAggVO aggbillvo = (BillAggVO) service.queryBillOfNCObjectByPK(BillAggVO.class, cancelvos[i].getPk_lower()).getContainmentObject();
+				BillVO billvo =  (BillVO) aggbillvo.getParent();
+				String billstatus = billvo.getBill_status().toString();
+				if(billstatus.equals("1")||billstatus.equals("8")) {
+					ExceptionUtils.wrapBusinessException("单据已经签字确认,不能删除!");
+					return null;
+				}
+			}
 			
+			if("36Z5".equals(cancelvos[i].getLowerbilltype())) {
+				AggRepayIntstVO aggrepayintstvo = (AggRepayIntstVO) service.queryBillOfNCObjectByPK(AggRepayIntstVO.class, cancelvos[i].getPk_lower()).getContainmentObject();
+				RepayIntstVO repayintstvo = aggrepayintstvo.getParentVO();
+				String billstatus = repayintstvo.getVbillstatus().toString();
+				if(!billstatus.equals("-1")) {
+					ExceptionUtils.wrapBusinessException("单据已经签字确认,不能删除!");
+					return null;
+				}
+			}
 
 			list.add(cancelvos[i].getPk_informer());
 			appendvos[i] = getInformerManageService().cancelMakeBill(cancelvos[i]);
 			
+			if("F2".equals(cancelvos[i].getLowerbilltype())) {
+				try {
+					AggGatheringBillVO agggatheringbill = (AggGatheringBillVO) service.queryBillOfNCObjectByPK(AggGatheringBillVO.class, cancelvos[i].getPk_lower()).getContainmentObject();
+					ipf.processAction("DELETE", "F2", null, agggatheringbill, null, null);//删除收款单
+				} catch (Exception e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+				cancelvos[i].setGenerateflag("hasnogenerate");
+				cancelvos[i].setUsemoney(new UFDouble(0));
+				cancelvos[i].setPk_claimer("");
+				cancelvos[i].setUsemoney(new UFDouble(0));
+				cancelvos[i].setClaimdate(null);
+				cancelvos[i].setPk_lower("");
+				cancelvos[i].setLowerbilltype("");
+				IVOPersistence.updateVO(cancelvos[i]);//修改到账通知单
+			}
+			
+			if("F5".equals(cancelvos[i].getLowerbilltype())) {
+				try {
+					BillAggVO aggbillvo = (BillAggVO) service.queryBillOfNCObjectByPK(BillAggVO.class, cancelvos[i].getPk_lower()).getContainmentObject();
+					ipf.processAction("DELETE", "F5", null, aggbillvo, null, null);//删除付款结算单
+				} catch (Exception e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+				cancelvos[i].setGenerateflag("hasnogenerate");
+				cancelvos[i].setUsemoney(new UFDouble(0));
+				cancelvos[i].setPk_claimer("");
+				cancelvos[i].setUsemoney(new UFDouble(0));
+				cancelvos[i].setClaimdate(null);
+				cancelvos[i].setPk_lower("");
+				cancelvos[i].setLowerbilltype("");
+				IVOPersistence.updateVO(cancelvos[i]);//修改到账通知单
+			}
 			
 			if("36Z3".equals(cancelvos[i].getLowerbilltype())) {
 				String qrysql = "select vbillstatus from cdmc_financepay where dr=0 and pk_financepay = '"+cancelvos[i].getPk_lower()+"'";
@@ -206,6 +258,25 @@ public Object doAction(IRequest request)
 				IVOPersistence.updateVO(cancelvos[i]);//修改到账通知单
 			} 
 			
+			if("36Z5".equals(cancelvos[i].getLowerbilltype())) {
+	        	try {
+	        		AggRepayIntstVO aggrepayintstvo = (AggRepayIntstVO) service.queryBillOfNCObjectByPK(AggRepayIntstVO.class,cancelvos[i].getPk_lower()).getContainmentObject();
+					ipf.processAction("DELETE", "36Z5", null, aggrepayintstvo, null, null);//删除贷款付息单
+				} catch (Exception e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+	        	
+	        	cancelvos[i].setGenerateflag("hasnogenerate");
+	        	cancelvos[i].setUsemoney(new UFDouble(0));
+	        	cancelvos[i].setPk_claimer("");
+	        	cancelvos[i].setUsemoney(new UFDouble(0));
+	        	cancelvos[i].setClaimdate(null);
+	        	cancelvos[i].setPk_lower("");
+	        	cancelvos[i].setLowerbilltype("");
+	        	IVOPersistence.updateVO(cancelvos[i]);//修改到账通知单
+	        }
+			
 			if (cancelvos[i].getTranserial() != null) {
 				hs.add(cancelvos[i].getTranserial());
 			}