蔡德晨 5 years ago
parent
commit
0d3574199f

+ 3 - 0
src/main/java/com/jeeplus/common/utils/excel/ImportExcel.java

@@ -179,6 +179,9 @@ public class ImportExcel {
 		}else{
 			throw new RuntimeException("文档格式不正确!");
 		}
+		if(this.wb.getSheet(sheetName) == null ){
+			throw new RuntimeException("缺少"+sheetName);
+		}
 		this.sheet = this.wb.getSheet(sheetName);
 		this.headerNum = headerNum;
 		log.debug("Initialize success.");

+ 59 - 3
src/main/java/com/jeeplus/common/utils/sg/ExcelUtil.java

@@ -3,9 +3,35 @@ package com.jeeplus.common.utils.sg;
 import com.jeeplus.common.utils.excel.ImportExcel;
 
 public class ExcelUtil {
+
     /**
      * 根据字段读取数据
-     * @param importExcel 文件
+     * @param importExcel
+     * @param st
+     * @param column1
+     * @param column2
+     * @return
+     */
+    public static double getDouble(ImportExcel importExcel,String st,int column1,int column2){
+        int lastRow = importExcel.getLastDataRowNum();
+        double d = 0.00;
+        for(int i=0;i<lastRow;i++){
+            String type = importExcel.getValue(i+1,column1);
+            if(type.equals("")){
+                continue;
+            }
+                if(type.equals(st)){
+                    d = importExcel.getDouble(i+1,column2);
+                    break;
+                }
+        }
+        return d;
+    }
+
+
+    /**
+     * 根据字段读取数据
+     * @param importExcel 文件对象
      * @param sts   字段
      * @param column1 字段列号
      * @param column2 读取数据列号
@@ -14,7 +40,7 @@ public class ExcelUtil {
     public static double[] getDoubleArray(ImportExcel importExcel,String[] sts,int column1,int column2){
         int lastRow = importExcel.getLastDataRowNum();
         int len = sts.length;
-        double[] d = new double[len+1];
+        double[] d = new double[len];
         for(int i=0;i<lastRow;i++){
             String type = importExcel.getValue(i+1,column1);
             if(type.equals("")){
@@ -25,12 +51,42 @@ public class ExcelUtil {
                     d[j] = importExcel.getDouble(i+1,column2);
                 }
             }
-//            d[len] += importExcel.getDouble(i+1,column2);
         }
         return d;
     }
 
 
+    /**
+     * 根据字段读取数据
+     * @param importExcel 文件对象
+     * @param sts  字段
+     * @param column1 字段列号
+     * @param column2 读取数据列号
+     * @return
+     */
+
+    public static double[][] getDoubleArrays(ImportExcel importExcel,String[] sts,int column1,int[] column2){
+        int lastRow = importExcel.getLastDataRowNum();
+        int len = sts.length;
+        int len1 = column2.length;
+        double[][] d = new double[len][len1];
+        for(int i=0;i<lastRow;i++){
+            String type = importExcel.getValue(i+1,column1);
+            if(type.equals("")){
+                continue;
+            }
+            for(int j=0;j<len;j++){
+                if(type.equals(sts[j])){
+                    for(int k=0;k<column2.length;k++)
+                    d[j][k] = importExcel.getDouble(i+1,column2[k]);
+                }
+            }
+        }
+        return d;
+    }
+
+
+
 
     /**
      * 读取税金

+ 10 - 0
src/main/java/com/jeeplus/modules/sg/overheadline/entity/FtData.java

@@ -6,6 +6,16 @@ public class FtData {
     private String state;  //调整类型  1:增加  2:减少
     private Double fee;   //调整费用
     private String type;  //分摊类型
+    private String tableData; //表格数据
+
+
+    public String getTableData() {
+        return tableData;
+    }
+
+    public void setTableData(String tableData) {
+        this.tableData = tableData;
+    }
 
     public String getType() {
         return type;

+ 3 - 30
src/main/java/com/jeeplus/modules/sg/overheadline/entity/JkxlAdjustFee.java

@@ -1,39 +1,12 @@
 package com.jeeplus.modules.sg.overheadline.entity;
 
 public class JkxlAdjustFee {
-    private String id;
-    private String type;
-    private Double fee;
-    private String state;
-    private String wbsCode;
-    private String data1;
+    private String id;  //项目ID
+    private String type;  //未识别费用名称
+    private Double fee;   //费用
 
 
 
-    public String getData1() {
-        return data1;
-    }
-
-    public void setData1(String data1) {
-        this.data1 = data1;
-    }
-
-    public String getState() {
-        return state;
-    }
-
-    public void setState(String state) {
-        this.state = state;
-    }
-
-    public String getWbsCode() {
-        return wbsCode;
-    }
-
-    public void setWbsCode(String wbsCode) {
-        this.wbsCode = wbsCode;
-    }
-
     public String getId() {
         return id;
     }

+ 5 - 5
src/main/java/com/jeeplus/modules/sg/overheadline/entity/JkxlDetailFee.java

@@ -36,7 +36,7 @@ public class JkxlDetailFee {
     private String mountMatter;   //挂接物料
     private String mountServer;   //挂接服务
     private String subjectAllocate;  //科目分配
-    private String state;   //1:主体部分  2:其他部分
+    private String feeType;   //1:主体部分  2:其他部分
 
 
     public Double getGxFee() {
@@ -55,12 +55,12 @@ public class JkxlDetailFee {
         this.subjectAllocate = subjectAllocate;
     }
 
-    public String getState() {
-        return state;
+    public String getFeeType() {
+        return feeType;
     }
 
-    public void setState(String state) {
-        this.state = state;
+    public void setFeeType(String feeType) {
+        this.feeType = feeType;
     }
 
     public Double getMeasuresFee3() {

+ 13 - 6
src/main/java/com/jeeplus/modules/sg/overheadline/mapper/xml/OverheadLineMapper.xml

@@ -4,10 +4,10 @@
 
 	<select id="getList" parameterType="String" resultType="com.jeeplus.modules.sg.overheadline.entity.JkxlDetailFee">
         SELECT
-         a.describe,
+         a.simple_describe as 'describe',
          a.short_id as wbsCode,
          a.parent_node as parentNode,
-         a.state,
+         a.fee_type as feeType,
          b.id,
          b.original_total_cost as originalTotalCost,
          b.original_rg_cost as originalRgCost,
@@ -31,16 +31,19 @@
          b.fbr_fee_ft as fbrFtFee,
          b.jx_fee_ft as jxFtFee,
          b.gx_fee as gxFee
-         FROM sg_wbs_elements_jkxl a LEFT JOIN sg_fee_detail_jkxl b on a.short_id = b.wbs_code
+         FROM sg_wbs_elements a LEFT JOIN sg_fee_detail_jkxl b on a.short_id = b.wbs_code
          and b.id = #{id}
+         <where>
+			 a.state = '1' and project_type = '1'
+		 </where>
 	</select>
 
 	<select id="getData"  resultType="com.jeeplus.modules.sg.overheadline.entity.JkxlDetailFee">
         SELECT
-         a.describe,
+         a.simple_describe as 'describe',
          a.short_id as wbsCode,
          a.parent_node as parentNode,
-         a.state,
+		 a.fee_type as feeType,
          b.id,
          b.original_total_cost as originalTotalCost,
          b.original_rg_cost as originalRgCost,
@@ -64,7 +67,7 @@
          b.cbr_fee_ft  as cbrFtFee,
          b.fbr_fee_ft  as fbrFtFee,
          b.jx_fee_ft as jxFtFee
-         FROM sg_wbs_elements_jkxl a LEFT JOIN sg_fee_detail_jkxl b on a.short_id = b.wbs_code
+         FROM sg_wbs_elements a LEFT JOIN sg_fee_detail_jkxl b on a.short_id = b.wbs_code
          <where>
          b.id = #{id}  and a.short_id = #{wbsCode}
 		 </where>
@@ -80,9 +83,13 @@
          a.subject_allocate as subjectAllocate,
          a.mount_matter as mountMatter,
          a.mount_server as mountServer,
+         b.original_total_cost as originalTotalCost,
          b.total_fee as totalFee
          FROM sg_wbs_elements a LEFT JOIN sg_fee_detail_jkxl b on a.short_id = b.wbs_code
          and b.id = #{id}
+         <where>
+			 project_type = '1'
+		 </where>
          order by a.id
 	</select>
 

+ 2 - 17
src/main/java/com/jeeplus/modules/sg/overheadline/service/FeeAdjustService.java

@@ -21,28 +21,13 @@ public class FeeAdjustService {
 
     @Transactional
    public void   updateFee(JkxlAdjustFee jkxlAdjustFee){
-       String type  = jkxlAdjustFee.getType();
-       if(type.equals("补增值税税率调整差额")){
-           type = "1";
-       } else {
-           type = "2";
-       }
-       jkxlAdjustFee.setType(type);
        jkxlAdjustFee.setFee(0.00);
         feeAdjustMapper.updateTzFee(jkxlAdjustFee);
    }
 
+
     @Transactional
-    public void saveTzFee(double[] wbs,String id){
-       JkxlAdjustFee jkxlAdjustFee = new JkxlAdjustFee();
-       JkxlAdjustFee jkxlAdjustFee1 = new JkxlAdjustFee();
-       jkxlAdjustFee.setId(id);
-       jkxlAdjustFee1.setId(id);
-       jkxlAdjustFee.setType("1");
-       jkxlAdjustFee1.setType("2");
-       jkxlAdjustFee.setFee(wbs[0]);
-       jkxlAdjustFee1.setFee(wbs[1]);
+    public void save(JkxlAdjustFee jkxlAdjustFee){
        feeAdjustMapper.saveTzFee(jkxlAdjustFee);
-       feeAdjustMapper.saveTzFee(jkxlAdjustFee1);
     }
 }

+ 175 - 15
src/main/java/com/jeeplus/modules/sg/overheadline/service/OverheadLineService.java

@@ -1,14 +1,22 @@
 package com.jeeplus.modules.sg.overheadline.service;
 
+import com.jeeplus.common.utils.excel.ImportExcel;
+import com.jeeplus.common.utils.sg.ExcelUtil;
+import com.jeeplus.modules.sg.overheadline.entity.JkxlAdjustFee;
 import com.jeeplus.modules.sg.overheadline.entity.JkxlDetailFee;
 import com.jeeplus.modules.sg.overheadline.entity.WbsProject;
 import com.jeeplus.modules.sg.overheadline.mapper.OverheadLineMapper;
+import com.jeeplus.modules.sg.overheadline.util.BashInfo;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
 
-import java.util.HashMap;
-import java.util.List;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 @Service
 public class OverheadLineService {
@@ -16,6 +24,8 @@ public class OverheadLineService {
     private OverheadLineMapper overheadLineMapper;
     @Autowired
     private FeeAdjustService feeAdjustService;
+    @Autowired
+    private RuleRatioService ruleRatioService;
 
 
 
@@ -25,25 +35,38 @@ public class OverheadLineService {
    }
 
    public List<JkxlDetailFee> findList(String id){
-       return overheadLineMapper.findList(id);
+       List<JkxlDetailFee> list = overheadLineMapper.findList(id);
+       double btTotal = 0.00;
+       double qtTotal = 0.00;
+       for(JkxlDetailFee jkxlDetailFee : list){
+           //本体费用求和
+           if(jkxlDetailFee.getOriginalTotalCost() != null){
+               btTotal += jkxlDetailFee.getTotalFee();
+           }
+           //其他费用求和
+           if(jkxlDetailFee.getOriginalTotalCost() == null && jkxlDetailFee.getTotalFee() != null){
+               qtTotal += jkxlDetailFee.getTotalFee();
+           }
+       }
+       for(JkxlDetailFee jkxlDetailFee : list){
+           if(jkxlDetailFee.getWbsCode().equals("30000000")){
+               jkxlDetailFee.setTotalFee(btTotal+qtTotal);
+           }
+           if(jkxlDetailFee.getWbsCode().equals("39000000")){
+               jkxlDetailFee.setTotalFee(btTotal);
+           }
+           if(jkxlDetailFee.getWbsCode().equals("34000000")){
+               jkxlDetailFee.setTotalFee(qtTotal);
+           }
+       }
+       return list;
+
    }
 
    public JkxlDetailFee getDate(String id, String wbsCode){
        return overheadLineMapper.getData(id,wbsCode);
    }
 
-   @Transactional
-   public void save(HashMap map){
-       String id = (String) map.get("id");
-       List<JkxlDetailFee> list = (List<JkxlDetailFee>) map.get("list");
-       double[] tzfee = (double[]) map.get("tzFee");
-       WbsProject wbsProject = (WbsProject) map.get("wbsProject");
-       overheadLineMapper.saveProject(wbsProject);
-       for(JkxlDetailFee jkxlDetailFee :list) {
-           overheadLineMapper.save(jkxlDetailFee);
-       }
-       feeAdjustService.saveTzFee(tzfee,id);
-   }
 
     @Transactional
     public void updataDate(JkxlDetailFee jkxlDetailFee){
@@ -55,4 +78,141 @@ public class OverheadLineService {
        overheadLineMapper.saveProject(wbsProject);
    }
 
+   public void save(MultipartFile file,double sl,String name,String id) throws IOException, InvalidFormatException {
+       WbsProject wbsProject = new WbsProject();
+       wbsProject.setId(id);
+       wbsProject.setName(name);
+       wbsProject.setCreateDate(new Date());
+       //保存项目
+       overheadLineMapper.saveProject(wbsProject);
+       //获取调差系数
+       double[] tcRate = new double[3];
+       tcRate[0] = ruleRatioService.getValueByName(BashInfo.RATIO_RGTC).getValue()/100;
+       tcRate[1] = ruleRatioService.getValueByName(BashInfo.RATIO_CLTC).getValue()/100;
+       tcRate[2] = ruleRatioService.getValueByName(BashInfo.RATIO_JXTC).getValue()/100;
+       //读取表格
+       ImportExcel importExcel = new ImportExcel(file,1,BashInfo.SHEET_FBFXJJ);  //分部分项工程量清单计价表
+       ImportExcel csqd = new ImportExcel(file,1,BashInfo.SHEET_CSB);  // 措施项目清单计价表(一)
+       ImportExcel gf = new ImportExcel(file,1,BashInfo.SHEET_GFQD);  //规费项目清单计价表
+       ImportExcel qt = new ImportExcel(file,1,BashInfo.SHEET_QTFY);  //其他项目清单计价表
+       ImportExcel total = new ImportExcel(file,1,BashInfo.SHEET_HZB );  //工程项目竣工结算汇总表
+       ImportExcel gzhz = new ImportExcel(file,1,BashInfo.SHEET_GCHZ );   //架空线路工程费用汇总表
+       //获取补增值税税率调整差额和扣减甲供材超供材料费
+       double[] wsbFees = ExcelUtil.getDoubleArray(total, new String[]{BashInfo.BZZSSL,BashInfo.KJJGCC},1,2);
+       double[] originalTotalFees = ExcelUtil.getDoubleArray(gzhz,BashInfo.HZ_ALL,1,2); //获取合计费
+       double[] zjgcFees = ExcelUtil.getDoubleArray(gzhz,BashInfo.HZ_ALL,1,3);  //获取直接工程费
+       double[][] originalFees = ExcelUtil.getDoubleArrays(importExcel,BashInfo.MX_ALL,2, new int[]{13, 14, 15, 17}); //获取原始费用
+       double texRate = ExcelUtil.getTexRate(total); //获取税率
+       double totalFee = ExcelUtil.getDouble(importExcel,BashInfo.PROJECTNAME,2,12);  //获取架空线路合计金额
+       double[] csRate = BashInfo.getCsRate(csqd); //获取措施费率
+       double[] gfRate = BashInfo.getGfRate(gf);  //获取规费率
+       double[] qtFees = BashInfo.getQtFees(qt);  //获取其他费用
+       double gcjsFee = BashInfo.getGcjsFee(total);  //获取工程结算价
+       //将本体工程费用明细存入集合
+       List<JkxlDetailFee> list = new ArrayList<>();
+       for(int i=0;i<originalTotalFees.length;i++){
+           JkxlDetailFee jkxlDetailFee = new JkxlDetailFee();
+           double originalTotalCost = originalTotalFees[i]; //原合计
+           double otherRate = originalTotalCost/totalFee;   //其他费用分摊比例
+           double orRate = new BigDecimal(otherRate).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue(); //四舍五入
+           double otherFee = qtFees[2]*otherRate;  //其他费用
+           double zjgcFee = zjgcFees[i];//直接工程费
+           double originalRgCost = originalFees[i][0];// 原人工费
+           double rgCost = originalRgCost/(1+tcRate[0]);  //后人工费
+           double originalCbrCost = originalFees[i][1];  //原承包人采购
+           double cbrCost = originalCbrCost/(1+tcRate[1]);  //后承包人采购
+           double originalFbrCost = originalFees[i][2];  //原发包人采购
+           double fbrCost = originalFbrCost/(1+sl); //后发包人采购
+           double originalJxrCost = originalFees[i][3];   //原机械费
+           double jxCost = originalJxrCost/(1+tcRate[2]); //后机械费
+           double measuresFee1 = (zjgcFee-fbrCost*sl)*csRate[0]; //措施费一(2)
+           double measuresFee2 = rgCost*csRate[1];   //措施费一(1)
+           double measuresFee3 = 0.00; //措施费二
+           double fees = rgCost*gfRate[1]*1.12+rgCost*gfRate[0];  //规费
+           double tax = (originalTotalCost+measuresFee1+measuresFee2+measuresFee3+fees+otherFee-originalFbrCost)*texRate; //税金
+           double totalfee = originalTotalCost+measuresFee1+measuresFee2+measuresFee3+fees+otherFee+tax-originalFbrCost; //合计
+           jkxlDetailFee.setOriginalTotalCost(originalTotalCost);
+           jkxlDetailFee.setOriginalRate(orRate);
+           jkxlDetailFee.setOriginalRgCost(originalRgCost);
+           jkxlDetailFee.setRgCost(rgCost);
+           jkxlDetailFee.setOriginalCbrCost(originalCbrCost);
+           jkxlDetailFee.setCbrCost(cbrCost);
+           jkxlDetailFee.setOriginalFbrCost(originalFbrCost);
+           jkxlDetailFee.setFbrCost(fbrCost);
+           jkxlDetailFee.setOriginalJxCost(originalJxrCost);
+           jkxlDetailFee.setJxCost(jxCost);
+           jkxlDetailFee.setMeasuresFee1(measuresFee1);
+           jkxlDetailFee.setMeasuresFee2(measuresFee2);
+           jkxlDetailFee.setMeasuresFee3(measuresFee3);
+           jkxlDetailFee.setFees(fees);
+           jkxlDetailFee.setOtherCost(otherFee);
+           jkxlDetailFee.setTex(tax);
+           jkxlDetailFee.setTotalFee(totalfee);
+           jkxlDetailFee.setZjgcFee(zjgcFee);
+           jkxlDetailFee.setWbsCode(BashInfo.WBSIDS[i]);
+           jkxlDetailFee.setId(id);
+           list.add(jkxlDetailFee);
+       }
+       //分摊费用到合计
+       double tz = 0.00;
+       for(JkxlDetailFee jkxlDetailFee : list){
+           tz += jkxlDetailFee.getTotalFee();
+       }
+       if(gcjsFee>tz){
+           double gxFee = gcjsFee-tz-qtFees[0]-qtFees[1]-wsbFees[0]-wsbFees[1];
+           double rate1 = 0.00;
+           double gxFee1 = 0.00;
+           double totalF = 0.00;
+           for(JkxlDetailFee jkxlDetailFee : list){
+               rate1 = jkxlDetailFee.getTotalFee()/tz;
+               gxFee1 = gxFee*rate1;
+               totalF = gxFee1 + jkxlDetailFee.getTotalFee();
+               jkxlDetailFee.setGxFee(Math.abs(gxFee1));
+               jkxlDetailFee.setTotalFee(totalF);
+           }
+       }else {
+           double gxFee = tz+qtFees[0]+qtFees[1]+wsbFees[0]+wsbFees[1]-gcjsFee;
+           double rate1 = 0.00;
+           double gxFee1 = 0.00;
+           double totalF = 0.00;
+           for(JkxlDetailFee jkxlDetailFee : list){
+               rate1 = jkxlDetailFee.getTotalFee()/tz;
+               gxFee1 = gxFee*rate1;
+               totalF = jkxlDetailFee.getTotalFee()-gxFee1;
+               jkxlDetailFee.setGxFee(Math.abs(gxFee1));
+               jkxlDetailFee.setTotalFee(totalF);
+           }
+
+       }
+       //将其他费用存入集合
+       JkxlDetailFee jkxlDetailFee1 = new JkxlDetailFee();
+       JkxlDetailFee jkxlDetailFee2 = new JkxlDetailFee();
+       jkxlDetailFee1.setId(id);
+       jkxlDetailFee1.setWbsCode("34120000");
+       jkxlDetailFee1.setTotalFee(qtFees[0]);
+       jkxlDetailFee2.setWbsCode("34220000");
+       jkxlDetailFee2.setTotalFee(qtFees[1]);
+       jkxlDetailFee2.setId(id);
+       list.add(jkxlDetailFee1);
+       list.add(jkxlDetailFee2);
+       //保存费用明细
+       for(JkxlDetailFee jkxlDetailFee:list){
+           overheadLineMapper.save(jkxlDetailFee);
+       }
+       //保存未识别费用
+       JkxlAdjustFee jkxlAdjustFee = new JkxlAdjustFee();
+       jkxlAdjustFee.setId(id);
+       jkxlAdjustFee.setType(BashInfo.BZZSSL);
+       jkxlAdjustFee.setFee(wsbFees[0]);
+       feeAdjustService.save(jkxlAdjustFee);
+       JkxlAdjustFee jkxlAdjustFee1 = new JkxlAdjustFee();
+       jkxlAdjustFee1.setId(id);
+       jkxlAdjustFee1.setType(BashInfo.KJJGCC);
+       jkxlAdjustFee1.setFee(wsbFees[1]);
+       feeAdjustService.save(jkxlAdjustFee1);
+   }
+
+
+
+
 }

+ 107 - 1
src/main/java/com/jeeplus/modules/sg/overheadline/util/BashInfo.java

@@ -1,5 +1,7 @@
 package com.jeeplus.modules.sg.overheadline.util;
 
+import com.jeeplus.common.utils.excel.ImportExcel;
+
 public class BashInfo {
     public static final String PROJECTNAME = "架空线路";
     public static final String SHEET_FBFXJJ = "分部分项工程量清单计价表";
@@ -37,10 +39,114 @@ public class BashInfo {
     public static final String HZ_JXGC = "架线工程";
     public static final String HZ_FJAZGC = "附件安装工程";
     public static final String HZ_FZ = "辅助工程";
+    public static final String TZ_RGF = "人工费";
+    public static final String TZ_CBRCG = "承包分采购";
+    public static final String TZ_FBRCG = "发包人采购";
+    public static final String TZ_JX = "机械费";
+    public static final String TZ_CSF1 = "措施费-1";
+    public static final String TZ_CSF2 = "措施费-2";
+    public static final String TZ_CSF3 = "措施费二";
+    public static final String TZ_QTF = "其他费";
+    public static final String TZ_GF = "规费";
+    public static final String TZ_SF = "税费";
+
+
+
+    //主体模块WBSID
+    public static final String[] WBSIDS = {"39100000","39200000","39300000","39400000","39500000","39600000"};
+
+    public static final String[] HZ_ALL = {HZ_JCGC,HZ_GTGC,HZ_JDGC,HZ_JXGC,HZ_FJAZGC,HZ_FZ};
+    public static final String[] MX_ALL ={JCGC,GTGC,JDGC,JXGC,FJAZGC,FZGC};
+
+
+    /**
+     *获取措施费率
+     */
+    public static double[] getCsRate(ImportExcel importExcel){
+        int lastRow = importExcel.getLastDataRowNum();
+        double lsRate = 0.00;
+        double aqRate = 0.00;
+        double totalRate = 0.00;
+        for(int i=2;i<lastRow;i++){
+            String type = importExcel.getValue(i+1,1);
+            if(type.equals(CS_LS)){
+                lsRate = importExcel.getDouble(i+1,3);
+            }
+            if(type.equals(CS_AQWM)){
+                aqRate = importExcel.getDouble(i+1,3);
+            }
+            totalRate += importExcel.getDouble(i+1,3);
+        }
+        double[] rate = new double[2];
+        rate[0] = (lsRate+aqRate)/100;
+        rate[1] = (totalRate-lsRate-aqRate)/100;
+        return  rate;
+    }
 
+    /**
+     *获取规费率
+     */
+    public static double[] getGfRate(ImportExcel importExcel) {
+        int lastRow = importExcel.getLastDataRowNum();
+        double totalRate = 0.00;
+        double wxzyRate = 0.00;
+        for (int i = 2; i < lastRow; i++) {
+            String type = importExcel.getValue(i + 1, 1);
+            if (type.equals(GF_WXZY)) {
+                wxzyRate = importExcel.getDouble(i + 1, 3);
+            }
+            if (!importExcel.getValue(i + 1, 2).equals("")) {
+                totalRate += importExcel.getDouble(i + 1, 3);
+            }
+        }
+        double[] rate = new double[2];
+        rate[0] = wxzyRate / 100;
+        rate[1] = (totalRate - wxzyRate) / 100;
+        return rate;
+    }
 
-    public static final String[] ids = {"39100000","39200000","39300000","39400000","39500000","39600000"};
+    /**
+     * 获取其他费用
+     */
+    public static double[] getQtFees(ImportExcel importExcel) {
+        int lastRow = importExcel.getLastDataRowNum();
+        double cdFree = 0.00;
+        double zbFree = 0.00;
+        double totalFree = 0.00;
+        for(int i=2;i<lastRow;i++){
+            String type = importExcel.getValue(i+1,1);
+            String type1 = importExcel.getValue(i+1,0);
+            if(type.equals(QT_SGCDZY)){
+                cdFree = importExcel.getDouble(i+1,2);
+            }
+            if(type.equals(QT_ZBDL)){
+                zbFree = importExcel.getDouble(i+1,2);
+            }
+            if(type1.equals(QT_HJ)){
+                totalFree = importExcel.getDouble(i+1,2);
+            }
+        }
+        double[] rate = new double[3];
+        rate[0] = cdFree;
+        rate[1] = zbFree;
+        rate[2] = totalFree-cdFree-zbFree;
+        return  rate;
+    }
 
+    /**
+     * 获取工程结算价
+     */
+    public static double getGcjsFee(ImportExcel importExcel){
+        int lastRow = importExcel.getLastDataRowNum();
+        double gcjs = 0.00;
+        for(int i=0;i<lastRow;i++){
+            String type = importExcel.getValue(i+1,1);
+            if(type.equals(BashInfo.TBJG) || type.equals(BashInfo.GCJS)){
+                gcjs = importExcel.getDouble(i+1,2);
+            }
+        }
+        return  gcjs;
 
+    }
 
 }

+ 0 - 150
src/main/java/com/jeeplus/modules/sg/overheadline/util/JkxlExcel.java

@@ -1,150 +0,0 @@
-package com.jeeplus.modules.sg.overheadline.util;
-
-import com.jeeplus.common.utils.excel.ImportExcel;
-import com.jeeplus.modules.sg.overheadline.entity.JkxlDetailFee;
-import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-public class JkxlExcel {
-    public static List<JkxlDetailFee> getData(String  file) throws IOException, InvalidFormatException {
-
-        ImportExcel importExcel = new ImportExcel(file,1,"分部分项工程量清单计价表");
-        List<JkxlDetailFee> list = new ArrayList<>();
-        int lastRow = importExcel.getLastDataRowNum();
-        int[] row = new int[6];
-        double totalFee = 0.00;
-        for(int i=0;i<lastRow;i++){
-            String type =  importExcel.getValue(i+1,2);
-            if(type.equals(BashInfo.PROJECTNAME)){
-                totalFee = importExcel.getDouble(i+1,12);
-            }
-            if(type.equals("1 基础工程")){
-                row[0] = i+1;
-                continue;
-            }
-            if(type.equals("2 杆塔工程")){
-                row[1] = i+1;
-                continue;
-            }
-            if(type.equals("3 接地工程")){
-                row[2] = i+1;
-                continue;
-            }
-            if(type.equals("4 架线工程")){
-                row[3] = i+1;
-                continue;
-            }
-            if(type.equals("5 附件安装工程")){
-                row[4] = i+1;
-                continue;
-            }
-            if(type.equals("6 辅助工程")){
-                row[5] = i+1;
-                break;
-            }
-        }
-        for(int i=0;i<6;i++){
-            JkxlDetailFee jkxlDetailFee = new JkxlDetailFee();
-            Double originalRgCost = importExcel.getDouble(row[i],13);
-//            Double rgCost = originalRgCost/(1+rate[0]);
-            Double originalCbrCost = importExcel.getDouble(row[i],14);
-//            Double cbrCost = originalCbrCost/(1+rate[1]);
-            Double originalFbrCost = importExcel.getDouble(row[i],15);
-//            Double fbrCost = originalFbrCost/(1+0.17);
-            Double originalJxrCost = importExcel.getDouble(row[i],17);
-//            Double jxCost = originalJxrCost/(1+rate[2]);
-            jkxlDetailFee.setOriginalTotalCost(importExcel.getDouble(row[i],12));
-            jkxlDetailFee.setOriginalRgCost(originalRgCost);
-//            jkxlData.setRgCost(rgCost);
-            jkxlDetailFee.setOriginalCbrCost(originalCbrCost);
-//            jkxlData.setCbrCost(cbrCost);
-            jkxlDetailFee.setOriginalFbrCost(originalFbrCost);
-//            jkxlData.setFbrCost(fbrCost);
-            jkxlDetailFee.setOriginalJxCost(originalJxrCost);
-//            jkxlData.setJxCost(jxCost);
-            list.add(jkxlDetailFee);
-        }
-        return list;
-    }
-
-
-//    public  static  double get(String file) throws IOException, InvalidFormatException {
-//        ImportExcel importExcel = new ImportExcel(file,1,1);
-//        int lastRow = importExcel.getLastDataRowNum();
-//        double lsRate = 0.00;
-//        double aqRate = 0.00;
-//        double totalRate = 0.00;
-//        for(int i=2;i<lastRow;i++){
-//            String type = importExcel.getValue(i+1,1);
-//            if(type.equals(BashInfo.CS_LS)){
-//                lsRate = importExcel.getDouble(i+1,3);
-//            }
-//            if(type.equals(BashInfo.CS_AQWM)){
-//                aqRate = importExcel.getDouble(i+1,3);
-//            }
-//            totalRate += importExcel.getDouble(i+1,3);
-//        }
-//        double[] rate = new double[2];
-//        rate[0] = (lsRate+aqRate)/100;
-//        rate[1] = (totalRate-lsRate-aqRate)/100;
-//        return  rate;
-//        double totalRate = 0.00;
-//        double wxzyRate = 0.00;
-//        for (int i = 2; i < lastRow; i++) {
-//            String type = importExcel.getValue(i + 1, 1);
-//            if (type.equals(BashInfo.GF_WXZY)) {
-//                wxzyRate = importExcel.getDouble(i + 1, 3);
-//            }
-//            if (!importExcel.getValue(i + 1, 2).equals("")) {
-//                totalRate += importExcel.getDouble(i + 1, 3);
-//            }
-//        }
-//        double[] rate = new double[2];
-//        rate[0] = wxzyRate / 100;
-//        rate[1] = (totalRate - wxzyRate) / 100;
-//        return rate;
-//        double cdFree = 0.00;
-//        double zbFree = 0.00;
-//        double totalFree = 0.00;
-//        for(int i=2;i<lastRow;i++){
-//            String type = importExcel.getValue(i+1,1);
-//            String type1 = importExcel.getValue(i+1,0);
-//            if(type.equals(BashInfo.QT_SGCDZY)){
-//                cdFree = importExcel.getDouble(i+1,2);
-//            }
-//            if(type.equals(BashInfo.QT_ZBDL)){
-//                zbFree = importExcel.getDouble(i+1,2);
-//            }
-////      totalFree += importExcel.getDouble(i+1,2);
-//            if(type1.equals(BashInfo.QT_HJ)){
-//                totalFree = importExcel.getDouble(i+1,2);
-//            }
-//        }
-//        double[] rate = new double[3];
-//        rate[0] = cdFree;
-//        rate[1] = zbFree;
-//        rate[2] = totalFree-cdFree-zbFree;
-//        return  rate;
-//        double bzFree = 0.00;
-//        double kcFree = 0.00;
-//        for(int i=0;i<lastRow;i++){
-//            String type = importExcel.getValue(i+1,1);
-//            if(type.equals(BashInfo.BZZSSL)){
-//                bzFree = importExcel.getDouble(i+1,2);
-//                continue;
-//            }
-//            if(type.equals(BashInfo.KJJGCC)){
-//                kcFree = importExcel.getDouble(i+1,2);
-//                break;
-//            }
-//        }
-//
-//        return  bzFree+kcFree;
-//    }
-
-
-
-}

+ 0 - 23
src/main/java/com/jeeplus/modules/sg/overheadline/util/Text.java

@@ -1,23 +0,0 @@
-package com.jeeplus.modules.sg.overheadline.util;
-
-import com.jeeplus.modules.sg.overheadline.entity.JkxlDetailFee;
-import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.util.List;
-
-public class Text {
- @Test
-  public void text() throws IOException, InvalidFormatException {
-      String file = "target/1.xls";
-//      double[] d = {0.17,0.0332,0.0322};
-      List<JkxlDetailFee> list = JkxlExcel.getData(file);
-//     double doubles = JkxlExcel.get(file);
-
-//     System.out.println(doubles);
-//     JkxlController jkxlController = new JkxlController();
-//     List<JkxlData> data = jkxlController.getData(file, d);
-     System.out.println(list);
- }
-}

+ 77 - 362
src/main/java/com/jeeplus/modules/sg/overheadline/web/OverheadLineController.java

@@ -35,10 +35,12 @@ public class OverheadLineController extends BaseController {
   @Autowired
   private OverheadLineService overheadLineService;
   @Autowired
-  private RuleRatioService ruleRatioService;
-  @Autowired
   private FeeAdjustService feeAdjustService;
 
+
+  /**
+   * 首页跳转
+   */
   @RequestMapping("/index")
   public String toImport(){
     return "modules/sg/free/indexProject";
@@ -49,40 +51,57 @@ public class OverheadLineController extends BaseController {
    */
   @RequestMapping("/import")
   public String importFile(MultipartFile file, RedirectAttributes redirectAttributes, HttpServletRequest request, Model model){
-    double sl = Double.valueOf(request.getParameter("jxsl"));
-    String projectName = request.getParameter("name");
+    double sl = Double.valueOf(request.getParameter("jxsl"));    //进项税率
+    String projectName = request.getParameter("name");     //项目名称
     String id = getId();
     try {
-      double[] rate = getRate();
-      WbsProject wbsProject = new WbsProject();
-      wbsProject.setId(id);
-      wbsProject.setName(projectName);
-      wbsProject.setCreateDate(new Date());
-      List<JkxlDetailFee> list = getData(file,rate,id,sl);
-      double[] tzfee = getTzFee(file);
-      HashMap<String,Object> map = new HashMap<String,Object>();
-      map.put("id",id);
-      map.put("list",list);
-      map.put("wbsProject",wbsProject);
-      map.put("tzFee",tzfee);
-      overheadLineService.save(map);
-    } catch (Exception e){
+      //保存数据到数据库
+      overheadLineService.save(file,sl,projectName,id);
+    } catch (RuntimeException e) {
+      addMessage(redirectAttributes, "导入失败"+e.getMessage());
+      return "modules/sg/free/indexProject";
+    }   catch (Exception e){
       addMessage(redirectAttributes, "导入失败");
+      return "modules/sg/free/indexProject";
     }
-
     addMessage(redirectAttributes, "导入成功");
     return "redirect:/a/jkxl/list?id="+id;
   }
 
+
+  @RequestMapping("/list")
+  public String list(HttpServletRequest request,Model model){
+    String id = request.getParameter("id");
+    JkxlDetailFee jkxlDetailFee = new JkxlDetailFee();
+    JkxlAdjustFee jkxlAdjustFee = new JkxlAdjustFee();
+    jkxlDetailFee.setId(id);
+    jkxlAdjustFee.setId(id);
+    List<JkxlDetailFee> list1 = new ArrayList<>();
+    list1.add(jkxlDetailFee);
+    //查询费用明细
+    List<JkxlDetailFee> list = overheadLineService.getList(id);
+    //求和
+    list.addAll(getTotal(list));
+    //查询未识别数据
+    List<JkxlAdjustFee> list2 = feeAdjustService.getTzFee(jkxlAdjustFee);
+    HashMap map = new HashMap();
+    map.put("list1",list1);
+    map.put("list",list);
+    map.put("list2",list2);
+    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();
-      String type = ftData.getType();
+      String code = ftData.getCode();   //分摊费用类型
+      String state = ftData.getState();  //1:增加 2:减少
+      String type = ftData.getType();   //分摊费用名
       double fee = ftData.getFee();
       double total = 0.00;
       try {
@@ -93,7 +112,8 @@ public class OverheadLineController extends BaseController {
             jkxlDetailFees.add(jkxlDetailFee);
           }
         }
-        if(code.equals("1")){
+        //人工费
+        if(code.equals(BashInfo.TZ_RGF)){
             for(JkxlDetailFee jkxlDetailFee : jkxlDetailFees) {
                 total += jkxlDetailFee.getRgCost();
           }
@@ -115,7 +135,8 @@ public class OverheadLineController extends BaseController {
               overheadLineService.updataDate(jkxlDetailFee);
             }
         }
-        if(code.equals("2")){
+        //承包人采购
+        if(code.equals(BashInfo.TZ_CBRCG)){
           for(JkxlDetailFee jkxlDetailFee : jkxlDetailFees) {
             total += jkxlDetailFee.getCbrCost();
           }
@@ -137,7 +158,8 @@ public class OverheadLineController extends BaseController {
             overheadLineService.updataDate(jkxlDetailFee);
           }
         }
-        if(code.equals("3")){
+        //发包人采购
+        if(code.equals(BashInfo.TZ_FBRCG)){
           for(JkxlDetailFee jkxlDetailFee : jkxlDetailFees) {
             total += jkxlDetailFee.getFbrCost();
           }
@@ -159,7 +181,8 @@ public class OverheadLineController extends BaseController {
             overheadLineService.updataDate(jkxlDetailFee);
           }
         }
-        if(code.equals("4")){
+        //机械费
+        if(code.equals(BashInfo.TZ_JX)){
           for(JkxlDetailFee jkxlDetailFee : jkxlDetailFees) {
             total += jkxlDetailFee.getJxCost();
           }
@@ -181,7 +204,8 @@ public class OverheadLineController extends BaseController {
             overheadLineService.updataDate(jkxlDetailFee);
           }
         }
-        if(code.equals("5")){
+        //措施费一(1)
+        if(code.equals(BashInfo.TZ_CSF1)){
           for(JkxlDetailFee jkxlDetailFee : jkxlDetailFees) {
             total += jkxlDetailFee.getMeasuresFee1();
           }
@@ -204,7 +228,8 @@ public class OverheadLineController extends BaseController {
             overheadLineService.updataDate(jkxlDetailFee);
           }
         }
-        if(code.equals("6")){
+        //措施费一(2)
+        if(code.equals(BashInfo.TZ_CSF2)){
           for(JkxlDetailFee jkxlDetailFee : jkxlDetailFees) {
             total += jkxlDetailFee.getMeasuresFee2();
           }
@@ -227,7 +252,8 @@ public class OverheadLineController extends BaseController {
             overheadLineService.updataDate(jkxlDetailFee);
           }
         }
-        if(code.equals("7")){
+        //措施费二
+        if(code.equals(BashInfo.TZ_CSF3)){
           for(JkxlDetailFee jkxlDetailFee : jkxlDetailFees) {
             total += jkxlDetailFee.getMeasuresFee3();
           }
@@ -250,7 +276,8 @@ public class OverheadLineController extends BaseController {
             overheadLineService.updataDate(jkxlDetailFee);
           }
         }
-        if(code.equals("8")){
+        //其他费
+        if(code.equals(BashInfo.TZ_QTF)){
           for(JkxlDetailFee jkxlDetailFee : jkxlDetailFees) {
             total += jkxlDetailFee.getOtherCost();
           }
@@ -273,7 +300,8 @@ public class OverheadLineController extends BaseController {
             overheadLineService.updataDate(jkxlDetailFee);
           }
         }
-        if(code.equals("9")){
+        //规费
+        if(code.equals(BashInfo.TZ_GF)){
           for(JkxlDetailFee jkxlDetailFee : jkxlDetailFees) {
             total += jkxlDetailFee.getFees();
           }
@@ -296,7 +324,8 @@ public class OverheadLineController extends BaseController {
             overheadLineService.updataDate(jkxlDetailFee);
           }
         }
-        if(code.equals("10")){
+        //税费
+        if(code.equals(BashInfo.TZ_SF)){
           for(JkxlDetailFee jkxlDetailFee : jkxlDetailFees) {
             total += jkxlDetailFee.getTex();
           }
@@ -319,6 +348,7 @@ public class OverheadLineController extends BaseController {
             overheadLineService.updataDate(jkxlDetailFee);
           }
         }
+        //更新未识别费用表
         JkxlAdjustFee jkxlAdjustFee = new JkxlAdjustFee();
         jkxlAdjustFee.setType(type);
         jkxlAdjustFee.setId(id);
@@ -335,15 +365,15 @@ public class OverheadLineController extends BaseController {
    *金额单独调整
    */
   @RequestMapping("/ddtz")
-  public String ddtz(JkxlAdjustFee jkxlAdjustFee, Model model, RedirectAttributes redirectAttributes){
-    String id = jkxlAdjustFee.getId();
-    String type = jkxlAdjustFee.getType();
-    String state  = jkxlAdjustFee.getState();
-    double fee = jkxlAdjustFee.getFee();
-    String data1 = jkxlAdjustFee.getData1();
+  public String ddtz(FtData ftData, Model model, RedirectAttributes redirectAttributes){
+    String id = ftData.getId();
+    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();
@@ -364,6 +394,10 @@ public class OverheadLineController extends BaseController {
         jkxlDetailFee.setTotalFee(totalFee);
         overheadLineService.updataDate(jkxlDetailFee);
       }
+      //更新未识别费用表
+      JkxlAdjustFee jkxlAdjustFee = new JkxlAdjustFee();
+      jkxlAdjustFee.setType(ftData.getType());
+      jkxlAdjustFee.setId(id);
       feeAdjustService.updateFee(jkxlAdjustFee);
 
     }catch (Exception e){
@@ -376,28 +410,6 @@ public class OverheadLineController extends BaseController {
 
 
 
-  @RequestMapping("/list")
-  public String list(HttpServletRequest request,Model model){
-    String id = request.getParameter("id");
-    JkxlDetailFee jkxlDetailFee = new JkxlDetailFee();
-    JkxlAdjustFee jkxlAdjustFee = new JkxlAdjustFee();
-    jkxlDetailFee.setId(id);
-    jkxlAdjustFee.setId(id);
-    List<JkxlDetailFee> list1 = new ArrayList<>();
-    list1.add(jkxlDetailFee);
-    List<JkxlDetailFee> list = overheadLineService.getList(id);
-    list.addAll(getTotal(list));
-    List<JkxlAdjustFee> list2 = feeAdjustService.getTzFee(jkxlAdjustFee);
-    HashMap map = new HashMap();
-    map.put("list1",list1);
-    map.put("list",list);
-    map.put("list2",list2);
-    model.addAttribute("map",map);
-    return "modules/sg/free/wbslist";
-  }
-
-
-
 
   /**
    *导出
@@ -408,6 +420,7 @@ public class OverheadLineController extends BaseController {
     try{
       String fileName = "架空线路"+ DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
       List<JkxlDetailFee> list = overheadLineService.findList(id);
+      //导出
       new ExportExcel(null, JkxlDetailFee.class).setDataList(list).write(response, fileName).dispose();
       return null;
     }catch (Exception e){
@@ -418,306 +431,6 @@ public class OverheadLineController extends BaseController {
   }
 
 
-  public List<JkxlDetailFee> getData(MultipartFile file, double[] rate, String id, double sl) throws IOException, InvalidFormatException {
-    ImportExcel importExcel = new ImportExcel(file,1,BashInfo.SHEET_FBFXJJ);  //分部分项工程量清单计价表
-    ImportExcel csqd = new ImportExcel(file,1,BashInfo.SHEET_CSB);  // 措施项目清单计价表(一)
-    ImportExcel gf = new ImportExcel(file,1,BashInfo.SHEET_GFQD);  //规费项目清单计价表
-    ImportExcel qt = new ImportExcel(file,1,BashInfo.SHEET_QTFY);  //其他项目清单计价表
-    ImportExcel total = new ImportExcel(file,1,BashInfo.SHEET_HZB );  //工程项目竣工结算汇总表
-    ImportExcel gzhz = new ImportExcel(file,1,BashInfo.SHEET_GCHZ );   //架空线路工程费用汇总表
-    double[] csRate = getCsRate(csqd);
-    double[] gfRate = getGfRate(gf);
-    double[] qtFees = getQtFees(qt);
-    //获取补增值税税率调整差额和扣减甲供材超供材料费和合计
-    double[] wsbFees = ExcelUtil.getDoubleArray(total, new String[]{BashInfo.BZZSSL,BashInfo.KJJGCC,BashInfo.GCJS},1,2);
-    int[] zjgcFee = getZjgcFee(gzhz);
-    double texRate = ExcelUtil.getTexRate(total); //获取税率
-    double totalFee = 0.00;
-    List<JkxlDetailFee> list = new ArrayList<>();
-    int lastRow = importExcel.getLastDataRowNum();
-    int[] row = new int[6];
-    for(int i=0;i<lastRow;i++){
-      String type =  importExcel.getValue(i+1,2);
-      if(type.equals(BashInfo.PROJECTNAME)){
-        totalFee = importExcel.getDouble(i+1,12);
-        continue;
-      }
-      if(type.equals(BashInfo.JCGC)){
-        row[0] = i+1;
-        continue;
-      }
-      if(type.equals(BashInfo.GTGC)){
-        row[1] = i+1;
-        continue;
-      }
-      if(type.equals(BashInfo.JDGC)){
-        row[2] = i+1;
-        continue;
-      }
-      if(type.equals(BashInfo.JXGC)){
-        row[3] = i+1;
-        continue;
-      }
-      if(type.equals(BashInfo.FJAZGC)){
-        row[4] = i+1;
-        continue;
-      }
-      if(type.equals(BashInfo.FZGC)){
-        row[5] = i+1;
-        break;
-      }
-    }
-    for(int i=0;i<6;i++){
-      JkxlDetailFee jkxlDetailFee = new JkxlDetailFee();
-      double originalTotalCost = gzhz.getDouble(zjgcFee[i],2); //原合计
-      double otherRate = originalTotalCost/totalFee;   //其他费用分摊比例
-      double orRate = new BigDecimal(otherRate).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue(); //四舍五入
-      double otherFee = qtFees[2]*otherRate;  //其他费用
-      double zjgcFees = gzhz.getDouble(zjgcFee[i],3);//直接工程费
-      double originalRgCost = importExcel.getDouble(row[i],13); //原人工费
-      double rgCost = originalRgCost/(1+rate[0]);  //后人工费
-      double originalCbrCost = importExcel.getDouble(row[i],14); //原承包人采购
-      double cbrCost = originalCbrCost/(1+rate[1]);  //后承包人采购
-      double originalFbrCost = importExcel.getDouble(row[i],15); //原发包人采购
-      double fbrCost = originalFbrCost/(1+sl); //后发包人采购
-      double originalJxrCost = importExcel.getDouble(row[i],17); //原机械费
-      double jxCost = originalJxrCost/(1+rate[2]); //后机械费
-      double measuresFee1 = (zjgcFees-fbrCost*sl)*csRate[0]; //措施费1
-      double measuresFee2 = rgCost*csRate[1];   //措施费2
-      double fees = rgCost*gfRate[1]*1.12+rgCost*gfRate[0];  //规费
-      double tax = (originalTotalCost+measuresFee1+measuresFee2+fees+otherFee-originalFbrCost)*texRate; //税金
-      double totalfee = originalTotalCost+measuresFee1+measuresFee2+fees+otherFee+tax-originalFbrCost; //合计
-      jkxlDetailFee.setOriginalTotalCost(originalTotalCost);
-      jkxlDetailFee.setOriginalRate(orRate);
-      jkxlDetailFee.setOriginalRgCost(originalRgCost);
-      jkxlDetailFee.setRgCost(rgCost);
-      jkxlDetailFee.setOriginalCbrCost(originalCbrCost);
-      jkxlDetailFee.setCbrCost(cbrCost);
-      jkxlDetailFee.setOriginalFbrCost(originalFbrCost);
-      jkxlDetailFee.setFbrCost(fbrCost);
-      jkxlDetailFee.setOriginalJxCost(originalJxrCost);
-      jkxlDetailFee.setJxCost(jxCost);
-      jkxlDetailFee.setMeasuresFee1(measuresFee1);
-      jkxlDetailFee.setMeasuresFee2(measuresFee2);
-      jkxlDetailFee.setFees(fees);
-      jkxlDetailFee.setOtherCost(otherFee);
-      jkxlDetailFee.setTex(tax);
-      jkxlDetailFee.setTotalFee(totalfee);
-      jkxlDetailFee.setZjgcFee(zjgcFees);
-      jkxlDetailFee.setWbsCode(BashInfo.ids[i]);
-      jkxlDetailFee.setId(id);
-      list.add(jkxlDetailFee);
-    }
-    double tz = 0.00;
-    for(JkxlDetailFee jkxlDetailFee : list){
-      tz += jkxlDetailFee.getTotalFee();
-    }
-    if(wsbFees[2]>tz){
-      double gxFee = wsbFees[2]-tz-qtFees[0]-qtFees[1]-wsbFees[0]-wsbFees[1];
-      double rate1 = 0.00;
-      double gxFee1 = 0.00;
-      double totalF = 0.00;
-      for(JkxlDetailFee jkxlDetailFee : list){
-        rate1 = jkxlDetailFee.getTotalFee()/tz;
-        gxFee1 = gxFee*rate1;
-        totalF = gxFee1 + jkxlDetailFee.getTotalFee();
-        jkxlDetailFee.setGxFee(Math.abs(gxFee1));
-        jkxlDetailFee.setTotalFee(totalF);
-      }
-    }else {
-      double gxFee = tz+qtFees[0]+qtFees[1]+wsbFees[0]+wsbFees[1]-wsbFees[2];
-      double rate1 = 0.00;
-      double gxFee1 = 0.00;
-      double totalF = 0.00;
-      for(JkxlDetailFee jkxlDetailFee : list){
-        rate1 = jkxlDetailFee.getTotalFee()/tz;
-        gxFee1 = gxFee*rate1;
-        totalF = jkxlDetailFee.getTotalFee()-gxFee1;
-        jkxlDetailFee.setGxFee(Math.abs(gxFee1));
-        jkxlDetailFee.setTotalFee(totalF);
-      }
-
-    }
-    JkxlDetailFee jkxlDetailFee1 = new JkxlDetailFee();
-    JkxlDetailFee jkxlDetailFee2 = new JkxlDetailFee();
-    jkxlDetailFee1.setId(id);
-    jkxlDetailFee1.setWbsCode("34120000");
-    jkxlDetailFee1.setTotalFee(qtFees[0]);
-    jkxlDetailFee2.setWbsCode("34220000");
-    jkxlDetailFee2.setTotalFee(qtFees[1]);
-    jkxlDetailFee2.setId(id);
-    list.add(jkxlDetailFee1);
-    list.add(jkxlDetailFee2);
-
-    return list;
-
-  }
-
-
-
-
-  /**
-   *获取措施费率
-   */
-  public double[] getCsRate(ImportExcel importExcel){
-    int lastRow = importExcel.getLastDataRowNum();
-    double lsRate = 0.00;
-    double aqRate = 0.00;
-    double totalRate = 0.00;
-    for(int i=2;i<lastRow;i++){
-      String type = importExcel.getValue(i+1,1);
-      if(type.equals(BashInfo.CS_LS)){
-          lsRate = importExcel.getDouble(i+1,3);
-      }
-      if(type.equals(BashInfo.CS_AQWM)){
-        aqRate = importExcel.getDouble(i+1,3);
-      }
-      totalRate += importExcel.getDouble(i+1,3);
-    }
-    double[] rate = new double[2];
-    rate[0] = (lsRate+aqRate)/100;
-    rate[1] = (totalRate-lsRate-aqRate)/100;
-    return  rate;
-  }
-
-
-
-  /**
-   *获取规费率
-   */
-  public double[] getGfRate(ImportExcel importExcel) {
-    int lastRow = importExcel.getLastDataRowNum();
-    double totalRate = 0.00;
-    double wxzyRate = 0.00;
-    for (int i = 2; i < lastRow; i++) {
-      String type = importExcel.getValue(i + 1, 1);
-      if (type.equals(BashInfo.GF_WXZY)) {
-        wxzyRate = importExcel.getDouble(i + 1, 3);
-      }
-      if (!importExcel.getValue(i + 1, 2).equals("")) {
-        totalRate += importExcel.getDouble(i + 1, 3);
-      }
-    }
-    double[] rate = new double[2];
-    rate[0] = wxzyRate / 100;
-    rate[1] = (totalRate - wxzyRate) / 100;
-    return rate;
-  }
-
-  /**
-   * 获取其他费用
-   */
-  public double[] getQtFees(ImportExcel importExcel) {
-    int lastRow = importExcel.getLastDataRowNum();
-    double cdFree = 0.00;
-    double zbFree = 0.00;
-    double totalFree = 0.00;
-    for(int i=2;i<lastRow;i++){
-      String type = importExcel.getValue(i+1,1);
-      String type1 = importExcel.getValue(i+1,0);
-      if(type.equals(BashInfo.QT_SGCDZY)){
-        cdFree = importExcel.getDouble(i+1,2);
-      }
-      if(type.equals(BashInfo.QT_ZBDL)){
-        zbFree = importExcel.getDouble(i+1,2);
-      }
-      if(type1.equals(BashInfo.QT_HJ)){
-        totalFree = importExcel.getDouble(i+1,2);
-      }
-    }
-    double[] rate = new double[3];
-    rate[0] = cdFree;
-    rate[1] = zbFree;
-    rate[2] = totalFree-cdFree-zbFree;
-    return  rate;
-  }
-
-  /**
-   * 获取调差系数
-   * @return
-   */
-  public double[] getRate(){
-    double[] rate = new double[3];
-    rate[0] = ruleRatioService.getValueByName(BashInfo.RATIO_RGTC).getValue()/100;
-    rate[1] = ruleRatioService.getValueByName(BashInfo.RATIO_CLTC).getValue()/100;
-    rate[2] = ruleRatioService.getValueByName(BashInfo.RATIO_JXTC).getValue()/100;
-    return rate;
-  }
-
-  /**
-   * 获取补增值税税率调整差额和扣减甲供材超供材料费
-   */
-  public double[] getFees(ImportExcel importExcel){
-    int lastRow = importExcel.getLastDataRowNum();
-    double bzFree = 0.00;
-    double kcFree = 0.00;
-    double gcjs = 0.00;
-    for(int i=0;i<lastRow;i++){
-      String type = importExcel.getValue(i+1,1);
-      if(type.equals(BashInfo.BZZSSL)){
-        bzFree = importExcel.getDouble(i+1,2);
-        continue;
-      }
-      if(type.equals(BashInfo.KJJGCC)){
-        kcFree = importExcel.getDouble(i+1,2);
-        continue;
-      }
-      if(type.equals(BashInfo.TBJG) || type.equals(BashInfo.GCJS)){
-        gcjs = importExcel.getDouble(i+1,2);
-      }
-    }
-    double[] wsb = new double[3];
-    wsb[0] = bzFree;
-    wsb[1] = kcFree;
-    wsb[2] = gcjs;
-    return  wsb;
-
-  }
-
-  /**
-   *获取直接工程费
-   */
-  public int[] getZjgcFee(ImportExcel importExcel) {
-    int lastRow = importExcel.getLastDataRowNum();
-    int[] row = new int[6];
-    for(int i=0;i<lastRow;i++){
-      String type =  importExcel.getValue(i+1,1);
-      if(type.equals(BashInfo.HZ_JCGC)){
-        row[0] = i+1;
-        continue;
-      }
-      if(type.equals(BashInfo.HZ_GTGC)){
-        row[1] = i+1;
-        continue;
-      }
-      if(type.equals(BashInfo.HZ_JDGC)){
-        row[2] = i+1;
-        continue;
-      }
-      if(type.equals(BashInfo.HZ_JXGC)){
-        row[3] = i+1;
-        continue;
-      }
-      if(type.equals(BashInfo.HZ_FJAZGC)){
-        row[4] = i+1;
-        continue;
-      }
-      if(type.equals(BashInfo.HZ_FZ)){
-        row[5] = i+1;
-        break;
-      }
-    }
-    return  row;
-
-  }
-
-
-
-  public double[] getTzFee(MultipartFile file) throws IOException, InvalidFormatException {
-    ImportExcel total = new ImportExcel(file,1,BashInfo.SHEET_HZB );
-    double[] wsb = getFees(total);
-    return wsb;
-  }
 
     /**
      * 创建项目ID
@@ -740,11 +453,13 @@ public class OverheadLineController extends BaseController {
   private List<JkxlDetailFee> getTotal(List<JkxlDetailFee> list) {
     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);
@@ -805,10 +520,10 @@ public class OverheadLineController extends BaseController {
     jkxlDetailFee.setTotalFee(new BigDecimal(zFee[21]).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
     jkxlDetailFee.setWbsCode("合计");
     jkxlDetailFee.setParentNode("30000000");
-    jkxlDetailFee.setState("1");
+    jkxlDetailFee.setFeeType("1");
     jkxlDetailFee1.setWbsCode("合计");
     jkxlDetailFee1.setParentNode("34000000");
-    jkxlDetailFee1.setState("0");
+    jkxlDetailFee1.setFeeType("0");
     jkxlDetailFee1.setTotalFee(total1);
     List<JkxlDetailFee> list3 = new ArrayList<>();
     list3.add(jkxlDetailFee);

+ 1 - 1
src/main/webapp/webpage/modules/sg/free/alongst.jsp

@@ -181,7 +181,7 @@
                     type:"post",
                     url:"${ctx}/jkxl/ddtz",
                     // data:JSON.stringify({id:newid2,type:xmmc2,fee:fyje2}),
-                    data:{id:newid2,type:xmmc2,fee:fyje2,data1:jsondata,state:val },
+                    data:{id:newid2,type:xmmc2,fee:fyje2,tableData:jsondata,state:val },
                     success:function(result){
                         parent.location.reload();
                     }

+ 10 - 10
src/main/webapp/webpage/modules/sg/free/avgpage.jsp

@@ -44,34 +44,34 @@
     </div>
     <div class="layui-form-item">
         <div class="layui-input-block">
-            <input type="radio" name="code" value="1" title="人工费" checked="checked">
+            <input type="radio" name="code" value="人工费" title="人工费" checked="checked">
         </div>
         <div class="layui-input-block">
-            <input type="radio" name="code" value="2" title="承包分采购">
+            <input type="radio" name="code" value="承包分采购" title="承包分采购">
         </div>
         <div class="layui-input-block">
-            <input type="radio" name="code" value="3" title="发包人采购">
+            <input type="radio" name="code" value="发包人采购" title="发包人采购">
         </div>
         <div class="layui-input-block">
-            <input type="radio" name="code" value="4" title="机械费">
+            <input type="radio" name="code" value="机械费" title="机械费">
         </div>
         <div class="layui-input-block">
-            <input type="radio" name="code" value="5" title="措施费-1">
+            <input type="radio" name="code" value="措施费-1" title="措施费-1">
         </div>
         <div class="layui-input-block">
-            <input type="radio" name="code" value="6" title="措施费-2">
+            <input type="radio" name="code" value="措施费-2" title="措施费-2">
         </div>
         <div class="layui-input-block">
-            <input type="radio" name="code" value="7" title="措施费二">
+            <input type="radio" name="code" value="措施费二" title="措施费二">
         </div>
         <div class="layui-input-block">
-            <input type="radio" name="code" value="8" title="其他费">
+            <input type="radio" name="code" value="其他费" title="其他费">
         </div>
         <div class="layui-input-block">
-            <input type="radio" name="code" value="9" title="规费">
+            <input type="radio" name="code" value="规费" title="规费">
         </div>
         <div class="layui-input-block">
-            <input type="radio" name="code" value="10" title="税费">
+            <input type="radio" name="code" value="税费" title="税费">
         </div>
     </div>
     <%--<div class="layui-form-item">--%>

+ 4 - 4
src/main/webapp/webpage/modules/sg/free/wbslist.jsp

@@ -136,7 +136,7 @@
                 ,data: [
                 <c:if test="${ not empty map.list}">
                 <c:forEach items="${map.list}" var="data" varStatus="index">
-                    <c:if test="${data.state eq '1'}">
+                    <c:if test="${data.feeType eq '1'}">
                 {
                     "id": "${data.wbsCode}",
                     "wbsys":"${data.describe}",
@@ -154,7 +154,6 @@
                     "fbrcg2":"${data.fbrCost}",
                     "jxf2": "${data.jxCost}",
 
-                    <%--"rgf3": "${data.rgFtFee}",--%>
                     "rgf3": "<c:if test="${ empty data.rgFtFee and not empty data.originalTotalCost}">0.0</c:if><c:if test="${ not empty data.rgFtFee}">${data.rgFtFee}</c:if> ",
                     "cbrcg3": "<c:if test="${ empty data.cbrFtFee and not empty data.originalTotalCost}">0.0</c:if><c:if test="${ not empty data.cbrFtFee}">${data.cbrFtFee}</c:if>",
                     "fbrcg3": "<c:if test="${ empty data.fbrFtFee and not empty data.originalTotalCost}">0.0</c:if><c:if test="${ not empty data.fbrFtFee}">${data.fbrFtFee}</c:if>",
@@ -213,7 +212,7 @@
                 ,data: [
                 <c:if test="${ not empty map.list}">
                 <c:forEach items="${map.list}" var="data" varStatus="index">
-                <c:if test="${data.state eq '0'}">
+                <c:if test="${data.feeType eq '0'}">
                 {
                     "d_id": "${data.wbsCode}",
                     "wbsys": "${data.describe}",
@@ -257,7 +256,8 @@
                <c:forEach items="${map.list2}" var="data" varStatus="index">
                 {
                     "id":"${data.id}",
-                    "xmmc": <c:if test="${data.type eq '1'}">"补增值税税率调整差额"</c:if><c:if test="${data.type eq '2'}">"扣减甲供材超供材料费"</c:if>,
+                    <%--"xmmc": <c:if test="${data.type eq '1'}">"补增值税税率调整差额"</c:if><c:if test="${data.type eq '2'}">"扣减甲供材超供材料费"</c:if>,--%>
+                    "xmmc": "${data.type}",
                     "fyje": "${data.fee}"
                 },
                 </c:forEach>