package com.ufgov.zc.server.zc.service.impl;
Exemple #2
0
  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;
  }