package com.jeeplus.modules.sg.overheadline.web;

import com.alibaba.fastjson.JSONArray;
import com.jeeplus.common.utils.DateUtils;
import com.jeeplus.common.utils.excel.ExportExcel;
import com.jeeplus.common.utils.excel.ImportExcel;
import com.jeeplus.common.utils.sg.ExcelUtil;
import com.jeeplus.core.web.BaseController;
import com.jeeplus.modules.sg.overheadline.entity.*;
import com.jeeplus.modules.sg.overheadline.service.FeeAdjustService;
import com.jeeplus.modules.sg.overheadline.service.OverheadLineService;
import com.jeeplus.modules.sg.overheadline.service.RuleRatioService;
import com.jeeplus.modules.sg.overheadline.service.SettlementService;
import com.jeeplus.modules.sg.overheadline.util.BashInfo;
import com.jeeplus.modules.sg.project.entity.WbsItem;
import com.jeeplus.modules.sg.project.service.ItemService;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 架空线路
 */
@Controller
@RequestMapping(value = "${adminPath}/jkxl")
public class OverheadLineController extends BaseController {
  @Autowired
  private OverheadLineService overheadLineService;
  @Autowired
  private FeeAdjustService feeAdjustService;
  @Autowired
  private SettlementService settlementService;
  @Autowired
  private ItemService itemService;


  /**
   * 首页跳转
   */
  @RequestMapping("/index")
  public String toImport(){
    return "modules/sg/free/indexProject";
  }

  /**
   *数据导入
   */
//  @RequestMapping("/import")
//  public String importFile(MultipartFile file, RedirectAttributes redirectAttributes, HttpServletRequest request, Model model) {
//    String projectName = request.getParameter("name");     //项目名称
//    String projectId = request.getParameter("projectId");    //工程ID
//    String type = request.getParameter("type");     //工程类型
//    String id = getId();
//    try {
//      //保存数据到数据库
//      overheadLineService.saveJk(file,projectName,id,projectId,type);
//    } catch (RuntimeException e) {
//      addMessage(redirectAttributes, "导入失败,"+e.getMessage());
//      return "redirect:/a/project/list";
//    }   catch (Exception e){
//      addMessage(redirectAttributes, "导入失败");
//      return "redirect:/a/project/list";
//    }
//    addMessage(redirectAttributes, "导入成功");
//    return "redirect:/a/jkxl/list?id="+id;
//  }


  @RequestMapping("/list")
  public String list(HttpServletRequest request,Model model){
    String id = request.getParameter("id");
    String type = request.getParameter("type");
    WbsItem wbsItem = new WbsItem();
    JkxlAdjustFee jkxlAdjustFee = new JkxlAdjustFee();
    wbsItem.setId(id);
    wbsItem.setType(type);
    jkxlAdjustFee.setId(id);
    List<WbsItem> list1 = new ArrayList<>();
    list1.add(wbsItem);
    //查询费用明细
    List<JkxlDetailFee> list = overheadLineService.getList(id,type);
    //求和
    list.addAll(getTotal(list,type));
    //查询未识别数据
    List<JkxlAdjustFee> list2 = feeAdjustService.getTzFee(jkxlAdjustFee);
    //数据校验展示
    List<Settlement> list3 = settlementService.selectSettlementService(id,type);
    HashMap map = new HashMap();
    map.put("list1",list1);
    map.put("list",list);
    map.put("list2",list2);
    map.put("list3",list3);
    model.addAttribute("map",map);
    return "modules/sg/free/wbslist";
  }


  /**
   *金额分摊调整
   */
  @RequestMapping("/fttz")
  public String reList(FtData ftData, Model model,RedirectAttributes redirectAttributes){
      String id = ftData.getId();
      String code = ftData.getCode();   //分摊费用类型
      String state = ftData.getState();  //1：增加 2：减少
      String type = ftData.getType();   //分摊费用名
      String itemType = ftData.getItemType();   //项目类型
      double fee = ftData.getFee();
      double total = 0.00;
      try {
        List<JkxlDetailFee> jkxl = overheadLineService.getList(id,itemType);
        //获取本体部分费用明细
        List<JkxlDetailFee> jkxlDetailFees = new ArrayList<>();
        for(JkxlDetailFee jkxlDetailFee : jkxl){
          if(jkxlDetailFee.getOriginalTotalCost() != null){
            jkxlDetailFees.add(jkxlDetailFee);
          }
        }
        //人工费
        if(code.equals(BashInfo.TZ_RGF)){
            for(JkxlDetailFee jkxlDetailFee : jkxlDetailFees) {
                total += jkxlDetailFee.getRgCost();
          }
            for(JkxlDetailFee jkxlDetailFee1 : jkxlDetailFees){
              JkxlDetailFee jkxlDetailFee = new JkxlDetailFee();
              jkxlDetailFee.setId(id);
              jkxlDetailFee.setWbsCode(jkxlDetailFee1.getWbsCode());
              double rgFee = jkxlDetailFee1.getRgCost();
              double totalFee = jkxlDetailFee1.getTotalFee();
              double ftFee = rgFee/total*fee;
              jkxlDetailFee.setRgFtFee(ftFee);
              if(state.equals("1")){
                double zFee = totalFee+ftFee;
                jkxlDetailFee.setTotalFee(zFee);
              }else {
                double zFee = totalFee-ftFee;
                jkxlDetailFee.setTotalFee(zFee);
              }
              overheadLineService.updataDate(jkxlDetailFee);
            }
        }
        //承包人采购
        if(code.equals(BashInfo.TZ_CBRCG)){
          for(JkxlDetailFee jkxlDetailFee : jkxlDetailFees) {
            total += jkxlDetailFee.getCbrCost();
          }
          for(JkxlDetailFee jkxlDetailFee1 : jkxlDetailFees){
            JkxlDetailFee jkxlDetailFee = new JkxlDetailFee();
            jkxlDetailFee.setId(id);
            jkxlDetailFee.setWbsCode(jkxlDetailFee1.getWbsCode());
            double rgFee = jkxlDetailFee1.getCbrCost();
            double totalFee = jkxlDetailFee1.getTotalFee();
            double ftFee = rgFee/total*fee;
            jkxlDetailFee.setCbrFtFee(ftFee);
            if(state.equals("1")){
              double zFee = totalFee+ftFee;
              jkxlDetailFee.setTotalFee(zFee);
            }else {
              double zFee = totalFee-ftFee;
              jkxlDetailFee.setTotalFee(zFee);
            }
            overheadLineService.updataDate(jkxlDetailFee);
          }
        }
        //发包人采购
        if(code.equals(BashInfo.TZ_FBRCG)){
          for(JkxlDetailFee jkxlDetailFee : jkxlDetailFees) {
            total += jkxlDetailFee.getFbrCost();
          }
          for(JkxlDetailFee jkxlDetailFee1 : jkxlDetailFees){
            JkxlDetailFee jkxlDetailFee = new JkxlDetailFee();
            jkxlDetailFee.setId(id);
            jkxlDetailFee.setWbsCode(jkxlDetailFee1.getWbsCode());
            double rgFee = jkxlDetailFee1.getFbrCost();
            double totalFee = jkxlDetailFee1.getTotalFee();
            double ftFee = rgFee/total*fee;
            jkxlDetailFee.setFbrFtFee(ftFee);
            if(state.equals("1")){
              double zFee = totalFee+ftFee;
              jkxlDetailFee.setTotalFee(zFee);
            }else {
              double zFee = totalFee-ftFee;
              jkxlDetailFee.setTotalFee(zFee);
            }
            overheadLineService.updataDate(jkxlDetailFee);
          }
        }
        //机械费
        if(code.equals(BashInfo.TZ_JX)){
          for(JkxlDetailFee jkxlDetailFee : jkxlDetailFees) {
            total += jkxlDetailFee.getJxCost();
          }
          for(JkxlDetailFee jkxlDetailFee1 : jkxlDetailFees){
            JkxlDetailFee jkxlDetailFee = new JkxlDetailFee();
            jkxlDetailFee.setId(id);
            jkxlDetailFee.setWbsCode(jkxlDetailFee1.getWbsCode());
            double rgFee = jkxlDetailFee1.getJxCost();
            double totalFee = jkxlDetailFee1.getTotalFee();
            double ftFee = rgFee/total*fee;
            jkxlDetailFee.setJxFtFee(ftFee);
            if(state.equals("1")){
              double zFee = totalFee+ftFee;
              jkxlDetailFee.setTotalFee(zFee);
            }else {
              double zFee = totalFee-ftFee;
              jkxlDetailFee.setTotalFee(zFee);
            }
            overheadLineService.updataDate(jkxlDetailFee);
          }
        }
        //措施费一（1）
        if(code.equals(BashInfo.TZ_CSF1)){
          for(JkxlDetailFee jkxlDetailFee : jkxlDetailFees) {
            total += jkxlDetailFee.getMeasuresFee1();
          }
          for(JkxlDetailFee jkxlDetailFee1 : jkxlDetailFees){
            JkxlDetailFee jkxlDetailFee = new JkxlDetailFee();
            jkxlDetailFee.setId(id);
            jkxlDetailFee.setWbsCode(jkxlDetailFee1.getWbsCode());
            double rgFee = jkxlDetailFee1.getMeasuresFee1();
            double totalFee = jkxlDetailFee1.getTotalFee();
            double ftFee = rgFee/total*fee;
            if(state.equals("1")){
              double zFee = totalFee+ftFee;
              jkxlDetailFee.setMeasuresFee1(rgFee+ftFee);
              jkxlDetailFee.setTotalFee(zFee);
            }else {
              double zFee = totalFee-ftFee;
              jkxlDetailFee.setMeasuresFee1(rgFee-ftFee);
              jkxlDetailFee.setTotalFee(zFee);
            }
            overheadLineService.updataDate(jkxlDetailFee);
          }
        }
        //措施费一（2）
        if(code.equals(BashInfo.TZ_CSF2)){
          for(JkxlDetailFee jkxlDetailFee : jkxlDetailFees) {
            total += jkxlDetailFee.getMeasuresFee2();
          }
          for(JkxlDetailFee jkxlDetailFee1 : jkxlDetailFees){
            JkxlDetailFee jkxlDetailFee = new JkxlDetailFee();
            jkxlDetailFee.setId(id);
            jkxlDetailFee.setWbsCode(jkxlDetailFee1.getWbsCode());
            double rgFee = jkxlDetailFee1.getMeasuresFee2();
            double totalFee = jkxlDetailFee1.getTotalFee();
            double ftFee = rgFee/total*fee;
            if(state.equals("1")){
              double zFee = totalFee+ftFee;
              jkxlDetailFee.setMeasuresFee1(rgFee+ftFee);
              jkxlDetailFee.setTotalFee(zFee);
            }else {
              double zFee = totalFee-ftFee;
              jkxlDetailFee.setMeasuresFee1(rgFee-ftFee);
              jkxlDetailFee.setTotalFee(zFee);
            }
            overheadLineService.updataDate(jkxlDetailFee);
          }
        }
        //措施费二
        if(code.equals(BashInfo.TZ_CSF3)){
          for(JkxlDetailFee jkxlDetailFee : jkxlDetailFees) {
            total += jkxlDetailFee.getMeasuresFee3();
          }
          for(JkxlDetailFee jkxlDetailFee1 : jkxlDetailFees){
            JkxlDetailFee jkxlDetailFee = new JkxlDetailFee();
            jkxlDetailFee.setId(id);
            jkxlDetailFee.setWbsCode(jkxlDetailFee1.getWbsCode());
            double rgFee = jkxlDetailFee1.getMeasuresFee3();
            double totalFee = jkxlDetailFee1.getTotalFee();
            double ftFee = rgFee/total*fee;
            if(state.equals("1")){
              double zFee = totalFee+ftFee;
              jkxlDetailFee.setMeasuresFee1(rgFee+ftFee);
              jkxlDetailFee.setTotalFee(zFee);
            }else {
              double zFee = totalFee-ftFee;
              jkxlDetailFee.setMeasuresFee1(rgFee-ftFee);
              jkxlDetailFee.setTotalFee(zFee);
            }
            overheadLineService.updataDate(jkxlDetailFee);
          }
        }
        //其他费
        if(code.equals(BashInfo.TZ_QTF)){
          for(JkxlDetailFee jkxlDetailFee : jkxlDetailFees) {
            total += jkxlDetailFee.getOtherCost();
          }
          for(JkxlDetailFee jkxlDetailFee1 : jkxlDetailFees){
            JkxlDetailFee jkxlDetailFee = new JkxlDetailFee();
            jkxlDetailFee.setId(id);
            jkxlDetailFee.setWbsCode(jkxlDetailFee1.getWbsCode());
            double rgFee = jkxlDetailFee1.getOtherCost();
            double totalFee = jkxlDetailFee1.getTotalFee();
            double ftFee = rgFee/total*fee;
            if(state.equals("1")){
              double zFee = totalFee+ftFee;
              jkxlDetailFee.setMeasuresFee1(rgFee+ftFee);
              jkxlDetailFee.setTotalFee(zFee);
            }else {
              double zFee = totalFee-ftFee;
              jkxlDetailFee.setMeasuresFee1(rgFee-ftFee);
              jkxlDetailFee.setTotalFee(zFee);
            }
            overheadLineService.updataDate(jkxlDetailFee);
          }
        }
        //规费
        if(code.equals(BashInfo.TZ_GF)){
          for(JkxlDetailFee jkxlDetailFee : jkxlDetailFees) {
            total += jkxlDetailFee.getFees();
          }
          for(JkxlDetailFee jkxlDetailFee1 : jkxlDetailFees){
            JkxlDetailFee jkxlDetailFee = new JkxlDetailFee();
            jkxlDetailFee.setId(id);
            jkxlDetailFee.setWbsCode(jkxlDetailFee1.getWbsCode());
            double rgFee = jkxlDetailFee1.getFees();
            double totalFee = jkxlDetailFee1.getTotalFee();
            double ftFee = rgFee/total*fee;
            if(state.equals("1")){
              double zFee = totalFee+ftFee;
              jkxlDetailFee.setMeasuresFee1(rgFee+ftFee);
              jkxlDetailFee.setTotalFee(zFee);
            }else {
              double zFee = totalFee-ftFee;
              jkxlDetailFee.setMeasuresFee1(rgFee-ftFee);
              jkxlDetailFee.setTotalFee(zFee);
            }
            overheadLineService.updataDate(jkxlDetailFee);
          }
        }
        //税费
        if(code.equals(BashInfo.TZ_SF)){
          for(JkxlDetailFee jkxlDetailFee : jkxlDetailFees) {
            total += jkxlDetailFee.getTex();
          }
          for(JkxlDetailFee jkxlDetailFee1 : jkxlDetailFees){
            JkxlDetailFee jkxlDetailFee = new JkxlDetailFee();
            jkxlDetailFee.setId(id);
            jkxlDetailFee.setWbsCode(jkxlDetailFee1.getWbsCode());
            double rgFee = jkxlDetailFee1.getTex();
            double totalFee = jkxlDetailFee1.getTotalFee();
            double ftFee = rgFee/total*fee;
            if(state.equals("1")){
              double zFee = totalFee+ftFee;
              jkxlDetailFee.setMeasuresFee1(rgFee+ftFee);
              jkxlDetailFee.setTotalFee(zFee);
            }else {
              double zFee = totalFee-ftFee;
              jkxlDetailFee.setMeasuresFee1(rgFee-ftFee);
              jkxlDetailFee.setTotalFee(zFee);
            }
            overheadLineService.updataDate(jkxlDetailFee);
          }
        }
        //更新未识别费用表
        JkxlAdjustFee jkxlAdjustFee = new JkxlAdjustFee();
        jkxlAdjustFee.setType(type);
        jkxlAdjustFee.setId(id);
        feeAdjustService.updateFee(jkxlAdjustFee);
      } catch (Exception e){
        addMessage(redirectAttributes, "调整失败");
      }
    addMessage(redirectAttributes, "调整成功");
    return "redirect:/a/jkxl/list?id="+id+"&type="+itemType;
  }


  /**
   * 分摊表
   */
  @RequestMapping("/getft")
  public String getft(HttpServletRequest request,Model model){
    String id = request.getParameter("id");
    List<JkxlDetailFee> list = overheadLineService.getAdjust(id);
    model.addAttribute("list",list);
    return "modules/sg/free/alongst";
  }


  /**
   *金额单独调整
   */
  @RequestMapping("/ddtz")
  public String ddtz(FtData ftData, Model model, RedirectAttributes redirectAttributes){
    String id = ftData.getId();
    String itemType = ftData.getItemType();
    String state  = ftData.getState();  // 1:增加 2:减少
    String data1 = ftData.getTableData();   //表格数据JOSN字符串
    String row = data1.replaceAll("&quot;","\\\"");
    //将JSON字符串转为list
    List<DdtzData> ts = (List<DdtzData>) JSONArray.parseArray(row, DdtzData.class);
    try {
      //更新细节费用表
      for(DdtzData ddtzData: ts){
        double tzFee = Double.valueOf(ddtzData.getFee());
        String wbsCode = ddtzData.getWbsCode();
        double otherFee = overheadLineService.getDate(id,wbsCode).getOtherCost();
        double totalFee = overheadLineService.getDate(id,wbsCode).getTotalFee();
        if(state.equals("1")){
          otherFee = otherFee+tzFee;
          totalFee = totalFee+tzFee;
        }
        if(state.equals("2")){
          otherFee = otherFee-tzFee;
          totalFee = totalFee-tzFee;
        }
        JkxlDetailFee jkxlDetailFee = new JkxlDetailFee();
        jkxlDetailFee.setId(id);
        jkxlDetailFee.setWbsCode(wbsCode);
        jkxlDetailFee.setOtherCost(otherFee);
        jkxlDetailFee.setTotalFee(totalFee);
        overheadLineService.updataDate(jkxlDetailFee);
      }
      //更新未识别费用表
      JkxlAdjustFee jkxlAdjustFee = new JkxlAdjustFee();
      jkxlAdjustFee.setType(ftData.getType());
      jkxlAdjustFee.setId(id);
      feeAdjustService.updateFee(jkxlAdjustFee);

    }catch (Exception e){
      addMessage(redirectAttributes, "调整失败");
    }
    addMessage(redirectAttributes, "调整成功");
    return "redirect:/a/jkxl/list?id="+id+"&type="+itemType;
  }





  /**
   *导出
   */
  @RequestMapping("/export")
  public String export(HttpServletRequest request, HttpServletResponse response,Model model,RedirectAttributes redirectAttributes) {
    String id = request.getParameter("id");
    String type = request.getParameter("type");
    try{
      WbsItem wbsItem = itemService.get(id);
      String file = wbsItem.getItemName();
      String fileName = file+ DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
      List<JkxlDetailFee> list = overheadLineService.findList(id,type);
      //导出
      new ExportExcel(null, JkxlDetailFee.class).setDataList(list).write(response, fileName).dispose();
      return null;
    }catch (Exception e){
      addMessage(redirectAttributes, "导出失败");
    }
     addMessage(redirectAttributes, "导出成功");
    return "redirect:/a/jkxl/list?id="+id+"&type="+type;
  }



//    /**
//     * 创建项目ID
//     */
//  public String getId() {
//     SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddHHmmss");
//     String newDate=sdf.format(new Date());
//     String result="";
//      Random random=new Random();
//     for(int i=0;i<3;i++){
//       result+=random.nextInt(10);
//     }
//     return newDate+result;
// }


  /**
   *求和
   */
  private List<JkxlDetailFee> getTotal(List<JkxlDetailFee> list,String type) {
    List<JkxlDetailFee> list1 = new ArrayList<>();
    List<JkxlDetailFee> list2  = new ArrayList<>();
    //获取主体部分list集合
    for(JkxlDetailFee jkxlDetailFee : list){
      if(jkxlDetailFee.getOriginalTotalCost() != null){
        list1.add(jkxlDetailFee);
      }
    }
    //获取其他费用list集合
    for(JkxlDetailFee jkxlDetailFee : list){
      if(jkxlDetailFee.getOriginalTotalCost() == null && jkxlDetailFee.getTotalFee() != null){
        list2.add(jkxlDetailFee);
      }
    }
    double total1 = 0.00;
    for (JkxlDetailFee jkxlDetailFee :list2){
      total1 += jkxlDetailFee.getTotalFee();
    }
    double [] zFee = new double[22];
    for(JkxlDetailFee jkxlDetailFee :list1){
      zFee[0] += jkxlDetailFee.getOriginalTotalCost();
      zFee[1] += jkxlDetailFee.getZjgcFee();
      zFee[2] += jkxlDetailFee.getOriginalRgCost();
      zFee[3] += jkxlDetailFee.getOriginalCbrCost();
      zFee[4] += jkxlDetailFee.getOriginalFbrCost();
      zFee[5] += jkxlDetailFee.getOriginalJxCost();
      zFee[6] += jkxlDetailFee.getRgCost();
      zFee[7] += jkxlDetailFee.getCbrCost();
      zFee[8] += jkxlDetailFee.getFbrCost();
      zFee[9] += jkxlDetailFee.getJxCost();
      zFee[10] += jkxlDetailFee.getRgFtFee()!=null? jkxlDetailFee.getRgFtFee():0.00;
      zFee[11] += jkxlDetailFee.getCbrFtFee()!=null? jkxlDetailFee.getCbrFtFee():0.00;
      zFee[12] += jkxlDetailFee.getFbrFtFee()!=null? jkxlDetailFee.getFbrFtFee():0.00;
      zFee[13] += jkxlDetailFee.getJxFtFee()!=null? jkxlDetailFee.getJxFtFee():0.00;
      zFee[14] += jkxlDetailFee.getMeasuresFee1();
      zFee[15] += jkxlDetailFee.getMeasuresFee2();
      zFee[16] += jkxlDetailFee.getMeasuresFee3()!=null? jkxlDetailFee.getMeasuresFee3():0.00;
      zFee[17] += jkxlDetailFee.getOtherCost();
      zFee[18] += jkxlDetailFee.getFees();
      zFee[19] += jkxlDetailFee.getTex();
//      zFee[20] += jkxlDetailFee.getGxFee();
      zFee[21] += jkxlDetailFee.getTotalFee();
    }
    JkxlDetailFee jkxlDetailFee = new JkxlDetailFee();
    JkxlDetailFee jkxlDetailFee1 = new JkxlDetailFee();
    java.text.NumberFormat NF = java.text.NumberFormat.getInstance();
    NF.setGroupingUsed(false);//去掉科学计数法显示
//    jkxlDetailFee.setOriginalTotalCost(new BigDecimal(NF.format(zFee[0])).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    jkxlDetailFee.setOriginalTotalCost(Double.valueOf(NF.format(zFee[0])));
    jkxlDetailFee.setZjgcFee(new BigDecimal(zFee[1]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    jkxlDetailFee.setOriginalRgCost(new BigDecimal(zFee[2]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    jkxlDetailFee.setOriginalCbrCost(new BigDecimal(zFee[3]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    jkxlDetailFee.setOriginalFbrCost(new BigDecimal(zFee[4]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    jkxlDetailFee.setOriginalJxCost(new BigDecimal(zFee[5]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    jkxlDetailFee.setRgCost(new BigDecimal(zFee[6]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    jkxlDetailFee.setCbrCost(new BigDecimal(zFee[7]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    jkxlDetailFee.setFbrCost(new BigDecimal(zFee[8]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    jkxlDetailFee.setJxCost(new BigDecimal(zFee[9]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    jkxlDetailFee.setRgFtFee(new BigDecimal(zFee[10]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    jkxlDetailFee.setCbrFtFee(new BigDecimal(zFee[11]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    jkxlDetailFee.setFbrFtFee(new BigDecimal(zFee[12]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    jkxlDetailFee.setJxFtFee(new BigDecimal(zFee[13]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    jkxlDetailFee.setMeasuresFee1(new BigDecimal(zFee[14]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    jkxlDetailFee.setMeasuresFee2(new BigDecimal(zFee[15]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    jkxlDetailFee.setMeasuresFee3(new BigDecimal(zFee[16]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    jkxlDetailFee.setOtherCost(new BigDecimal(zFee[17]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    jkxlDetailFee.setFees(new BigDecimal(zFee[18]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    jkxlDetailFee.setTex(new BigDecimal(zFee[19]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
//    jkxlDetailFee.setGxFee(new BigDecimal(zFee[20]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    jkxlDetailFee.setTotalFee(new BigDecimal(NF.format(zFee[21])).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
    jkxlDetailFee.setWbsCode("合计");
    if(type.equals("1")) {
      jkxlDetailFee.setParentNode("30000000");
    }
    if(type.equals("2")) {
      jkxlDetailFee.setParentNode("40000000");
    }
    jkxlDetailFee.setFeeType("1");
    jkxlDetailFee1.setWbsCode("合计");
    if(type.equals("1")) {
      jkxlDetailFee1.setParentNode("34000000");
    }
    if(type.equals("2")) {
      jkxlDetailFee1.setParentNode("44000000");
    }
    jkxlDetailFee1.setFeeType("0");
    jkxlDetailFee1.setTotalFee(total1);
    List<JkxlDetailFee> list3 = new ArrayList<>();
    list3.add(jkxlDetailFee);
    list3.add(jkxlDetailFee1);
     return list3;


  }







}
