光伏EPC合同内容复制方法详解

本文将介绍如何复制光伏EPC合同内容,包括附件、收款计划和付款计划。

代码示例:

Map<String, Object> epcContractMap = new HashMap<String, Object>();
epcContractMap.put('purchaseOrderId', purchaseOrderId);
List<PvEpcContract> epcContractList = epcContractService.findPvEpcContractByParam(epcContractMap);
if(epcContractList != null && epcContractList.size()>0){
  PvEpcContract epcContract = epcContractList.get(0);
  String epcContractId = epcContract.getId();
  //复制光伏epc合同附件
  Map<String, Object> epcContractAttaMap = new HashMap<String, Object>();
epcContractAttaMap.put('epcContractId', epcContractId);
  List<PvEpcContractAtta> epcContractAttaList = epcContractAttaService.findPvEpcContractAttaByParam(epcContractAttaMap);
  if(epcContractAttaList != null && epcContractAttaList.size()>0){
    for (int i = 0; i < epcContractAttaList.size(); i++) {
      PvEpcContractAtta epcContractAtta = epcContractAttaList.get(i);
      String sourceId = epcContractAtta.getId();
      String sourceName = epcContractAtta.getName();
      String sourcePath = epcContractAtta.getPath();
      String sourceUploadTime = epcContractAtta.getUploadTime();
      //设置新的附件id
      String newId = UUID.randomUUID().toString();
      PvEpcContractAtta newEpcContractAtta = new PvEpcContractAtta();
      newEpcContractAtta.setId(newId);
      newEpcContractAtta.setEpcContractId(epcContractId);
      newEpcContractAtta.setName(sourceName);
      newEpcContractAtta.setPath(sourcePath);
      newEpcContractAtta.setUploadTime(sourceUploadTime);
      newEpcContractAtta.setCreater(userId);
      newEpcContractAtta.setCreateTime(currentTime);
      newEpcContractAtta.setUpdater(userId);
      newEpcContractAtta.setUpdateTime(currentTime);
      epcContractAttaService.addPvEpcContractAtta(newEpcContractAtta);
      
      //复制附件
      File sourceFile = new File(sourcePath);
      String destPath = sourcePath.replace(sourceId, newId);
      File destFile = new File(destPath);
      try {
        FileUtils.copyFile(sourceFile, destFile);
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }
  
  //复制光伏epc合同收款计划
  Map<String, Object> epcRecePlanMap = new HashMap<String, Object>();
epcRecePlanMap.put('epcContractId', epcContractId);
  List<PvEpcRecePlan> epcRecePlanList = epcRecePlanService.findPvEpcRecePlanByParam(epcRecePlanMap);
  if(epcRecePlanList != null && epcRecePlanList.size()>0){
    for (int j = 0; j < epcRecePlanList.size(); j++) {
      PvEpcRecePlan epcRecePlan = epcRecePlanList.get(j);
      String sourceId = epcRecePlan.getId();
      String sourceName = epcRecePlan.getName();
      String sourceMoney = epcRecePlan.getMoney();
      String sourceReceTime = epcRecePlan.getReceTime();
      String sourceReceStatus = epcRecePlan.getReceStatus();
      String sourceRemark = epcRecePlan.getRemark();
      //设置新的收款计划id
      String newId = UUID.randomUUID().toString();
      PvEpcRecePlan newEpcRecePlan = new PvEpcRecePlan();
      newEpcRecePlan.setId(newId);
      newEpcRecePlan.setEpcContractId(epcContractId);
      newEpcRecePlan.setName(sourceName);
      newEpcRecePlan.setMoney(sourceMoney);
      newEpcRecePlan.setReceTime(sourceReceTime);
      newEpcRecePlan.setReceStatus(sourceReceStatus);
      newEpcRecePlan.setRemark(sourceRemark);
      newEpcRecePlan.setCreater(userId);
      newEpcRecePlan.setCreateTime(currentTime);
      newEpcRecePlan.setUpdater(userId);
      newEpcRecePlan.setUpdateTime(currentTime);
      epcRecePlanService.addPvEpcRecePlan(newEpcRecePlan);
    }
  }
  
  //复制光伏epc合同付款计划
  Map<String, Object> epcPayPlanMap = new HashMap<String, Object>();
epcPayPlanMap.put('epcContractId', epcContractId);
  List<PvEpcPayPlan> epcPayPlanList = epcPayPlanService.findPvEpcPayPlanByParam(epcPayPlanMap);
  if(epcPayPlanList != null && epcPayPlanList.size()>0){
    for (int k = 0; k < epcPayPlanList.size(); k++) {
      PvEpcPayPlan epcPayPlan = epcPayPlanList.get(k);
      String sourceId = epcPayPlan.getId();
      String sourceName = epcPayPlan.getName();
      String sourceMoney = epcPayPlan.getMoney();
      String sourcePayTime = epcPayPlan.getPayTime();
      String sourcePayStatus = epcPayPlan.getPayStatus();
      String sourceRemark = epcPayPlan.getRemark();
      
      //设置新的付款计划id
      String newId = UUID.randomUUID().toString();
      PvEpcPayPlan newEpcPayPlan = new PvEpcPayPlan();
      newEpcPayPlan.setId(newId);
      newEpcPayPlan.setEpcContractId(epcContractId);
      newEpcPayPlan.setName(sourceName);
      newEpcPayPlan.setMoney(sourceMoney);
      newEpcPayPlan.setPayTime(sourcePayTime);
      newEpcPayPlan.setPayStatus(sourcePayStatus);
      newEpcPayPlan.setRemark(sourceRemark);
      newEpcPayPlan.setCreater(userId);
      newEpcPayPlan.setCreateTime(currentTime);
      newEpcPayPlan.setUpdater(userId);
      newEpcPayPlan.setUpdateTime(currentTime);
      epcPayPlanService.addPvEpcPayPlan(newEpcPayPlan);
    }
  }
}

代码解析:

  1. 首先获取目标EPC合同信息,包括合同ID、附件、收款计划和付款计划。
  2. 循环遍历附件列表,并为每个附件生成一个新的ID。
  3. 将附件信息复制到新的附件对象中,并设置新的ID和相关信息。
  4. 将新的附件对象保存到数据库中。
  5. 复制附件文件到新的路径。
  6. 重复步骤2-5,复制收款计划和付款计划。

注意事项:

  1. 在复制附件文件时,需要确保目标路径存在。
  2. 在保存新的附件、收款计划和付款计划时,需要设置创建者、创建时间、更新者和更新时间。
  3. 可以根据实际情况修改代码,例如,在复制附件文件时可以使用其他文件复制方法。

通过以上步骤,可以轻松复制光伏EPC合同内容,并确保数据的一致性。

其他相关知识:

  • 光伏EPC
  • 合同复制
  • 附件复制
  • 收款计划复制
  • 付款计划复制
  • 代码示例
  • Java编程

原文地址: https://www.cveoy.top/t/topic/ll0f 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录