private List getBiLst(String ddCode) { // TCJLODO Auto-generated method stub List biLst = this.ddBiDao.getBiLst(ddCode); if (!isUseBudget()) { return biLst; } String ids = ""; for (int i = 0; i < biLst.size(); i++) { ZcDingdianBi bi = (ZcDingdianBi) biLst.get(i); if (bi.getZcBiNo() != null && bi.getZcBiNo().trim().length() > 0) { if (ids.length() == 0) { ids = "'" + bi.getZcBiNo() + "'"; } else { ids = ids + ",'" + bi.getZcBiNo() + "'"; } } } if (ids.trim().length() > 0) { List yuanBiLst = this.baseDao.query("VwBudgetGp.getVwBudgetGpByBiNoLst", ids); if (yuanBiLst == null) { throw new RuntimeException("获取以下指标信息报错:" + ids); } for (int i = 0; i < biLst.size(); i++) { ZcDingdianBi bi = (ZcDingdianBi) biLst.get(i); for (int j = 0; j < yuanBiLst.size(); j++) { VwBudgetGp gp = (VwBudgetGp) yuanBiLst.get(j); if (bi.getZcBiNo() != null && bi.getZcBiNo().equals("" + gp.getSumId())) { // 将指标的现有可用金额+当前计划占用的指标金额,作为当前指标的可用金额,这样定点计划单保存后,再修改,被本定点计划单占用的指标应该属于可用指标额度范围内, bi.setZcBiDoSum(gp.getCanuseMoney().add(bi.getZcBiJhuaSum())); } } } } return biLst; }
public ZcDingdian sendPayFN(ZcDingdian bill, RequestMeta requestMeta) throws Exception { bill = updateFN(bill, requestMeta); Map map = null; BudgetUtil bu = new BudgetUtil(); // 指标接口和支付接口分开,这样指标接口出错时则不掉用取消结冻指标操作 try { /* * 释放指标金额,本次支付金额10w,则应该修改采购计划金额=原采购计划金额-10w */ map = bu.getDingDianShiFangBudget(baseDao, true, bill); bu.callService(map, requestMeta.getSvNd()); Map rtn = new PayForZcUtil().PayByDingDian(bill, requestMeta); if (rtn == null) { // 目前没有处理,应该不会出现这种情况 // throw new RuntimeException(e1.getMessage()); } else { String rtnType = (String) rtn.get(PayForZcUtil.RTN_RESULT); String returnMsg = (String) rtn.get(PayForZcUtil.RTN_MESSAGE); if (rtnType.equalsIgnoreCase(PayForZcUtil.RTN_RESULT_FALSE)) { throw new RuntimeException("定点采购【" + bill.getDdCode() + "】生成支付出错:" + returnMsg); } else { // 保存支付凭证号与当前支付单的关联关系 String vouIds = (String) rtn.get(PayForZcUtil.RTN_DATA); _savePayVouId(vouIds, bill, requestMeta); } } } catch (ZcPayInterfaceException e) { try { bu.cancelCallService(map, requestMeta.getSvNd()); } catch (Exception e1) { String errorInfo = ""; errorInfo = "定点采购【" + bill.getDdCode() + "】生成支付出错时,取消结冻的指标出现异常\n"; List biLst = bill.getBiList(); for (int i = 0; i < biLst.size(); i++) { ZcDingdianBi bi = (ZcDingdianBi) biLst.get(i); errorInfo += "指标编号:" + bi.getZcBiNo() + " 金额:" + (bi.getZcBiJhuaSum() == null ? "" : bi.getZcBiJhuaSum().toString()) + "\n"; } System.err.println("异常信息如下:" + errorInfo); e1.printStackTrace(); throw new RuntimeException(e1.getMessage() + errorInfo); } e.printStackTrace(); throw new RuntimeException(e.getMessage()); } bill = auditFN(bill, requestMeta); // 支付指标 return bill; }
private ZcDingdian _updateFN(ZcDingdian bill, RequestMeta requestMeta, boolean isImportData) throws Exception { // System.out.println("before service 2="+bill.getCoCode()+bill.getCoName()); String code = ""; String temp_code = ""; List biList = bill.getBiList(); String userId = requestMeta.getSvUserID(); String compoId = requestMeta.getCompoId(); boolean isDraft = false; if (bill.getProcessInstId() == null || bill.getProcessInstId().longValue() == -1) { Long draftid = workflowDao.createDraftId(); bill.setProcessInstId(draftid); isDraft = true; } Map map = null; if ("".equals(ZcSUtil.safeString(bill.getDdCode())) || bill.getDdCode().equals("自动编号")) { // 当新建项目的时候,项目编码不进行正式编码,首先创建一个临时编码,等提交送审之后,进行正式编码 temp_code = NumUtil.getInstance().getNo("ZC_DINGDIAN", "DD_CODE", bill); code = temp_code; bill.setDdCode(code); map = new BudgetUtil() .getSaveBudgetByZcDingDian(ddBiDao, baseDao, ZcSUtil.isUseBi(), bill, biList); // System.out.println("before service 3="+bill.getCoCode()+bill.getCoName()); BigDecimal biSum = new BigDecimal(0); for (int i = 0; i < biList.size(); i++) { ZcDingdianBi bi = (ZcDingdianBi) biList.get(i); bi.setDdCode(code); if (bi.getZcBiNo() != null && bi.getZcBiNo().trim().length() > 0) { biSum = biSum.add(bi.getZcBiJhuaSum()); } } bill.setBiSum(biSum); for (int i = 0; i < bill.getItemList().size(); i++) { ZcDingdianItem item = (ZcDingdianItem) bill.getItemList().get(i); item.setDdCode(code); } // System.out.println("before service 4="+bill.getCoCode()+bill.getCoName()); ddDao.insert(bill); // System.out.println("before service 5="+bill.getCoCode()+bill.getCoName()); ddBiDao.insertList(biList); ddItemDao.insertList(bill.getItemList()); // System.out.println("before service 6="+bill.getCoCode()+bill.getCoName()); } else { code = bill.getDdCode(); BigDecimal biSum = new BigDecimal(0); for (int i = 0; i < biList.size(); i++) { ZcDingdianBi bi = (ZcDingdianBi) biList.get(i); bi.setDdCode(code); if (bi.getZcBiNo() != null && bi.getZcBiNo().trim().length() > 0) { biSum = biSum.add(bi.getZcBiJhuaSum()); } } bill.setBiSum(biSum); // 使用删除、插入,是考虑导入数据时,code已经有了,直接update没有用,所以采用删、插的模式 ddDao.deleteByPrimaryKey(bill.getDdCode()); // System.out.println("update before="+bill.getCoCode()+bill.getCoName()); ddDao.insert(bill); // System.out.println("666="+bill.getCoCode()+bill.getCoName()); map = new BudgetUtil() .getSaveBudgetByZcDingDian(ddBiDao, baseDao, ZcSUtil.isUseBi(), bill, biList); ddBiDao.deleteBiByDdCode(bill.getDdCode()); ddItemDao.deleteItemByDdCode(bill.getDdCode()); for (int i = 0; i < biList.size(); i++) { ZcDingdianBi mbi = (ZcDingdianBi) biList.get(i); mbi.setDdCode(code); } ddBiDao.insertList(biList); for (int i = 0; i < bill.getItemList().size(); i++) { ZcDingdianItem item = (ZcDingdianItem) bill.getItemList().get(i); item.setDdCode(code); } ddItemDao.insertList(bill.getItemList()); } if (isDraft) { AsWfDraft asWfDraft = new AsWfDraft(); asWfDraft.setCompoId(compoId); asWfDraft.setWfDraftName(bill.getDdCode()); asWfDraft.setUserId(userId); asWfDraft.setMasterTabId(compoId); asWfDraft.setWfDraftId(BigDecimal.valueOf(bill.getProcessInstId().longValue())); workflowDao.insertAsWfdraft(asWfDraft); } // 不是导入的数据,且使用指标接口 if (!isImportData) { // new BudgetUtil().callService(map, requestMeta.getSvNd()); } // System.out.println("return before="+bill.getCoCode()+bill.getCoName()); return bill; }