|
@@ -2257,6 +2257,18 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
Cell c11 = getCellByAddress(sheet, "C11");
|
|
|
c11.setCellValue(endDate.toString());
|
|
|
|
|
|
+ for (Sheet sheet1 : workbook) {
|
|
|
+ for (Row row : sheet1) {
|
|
|
+ // 遍历所有单元格
|
|
|
+ for (Cell cell : row) {
|
|
|
+ String stringCellValue = cell.getStringCellValue();
|
|
|
+ if("0".equals(stringCellValue)){
|
|
|
+ cell.setCellValue("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
String file_path = FileUtils.getSysLocalFileUrl();
|
|
|
String locationFile = file_path + SnowFlakeUtil.getId() + ".xlsx";
|
|
|
outputStream = new FileOutputStream(locationFile);
|
|
@@ -2315,59 +2327,14 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
if(isOnePeriod){
|
|
|
lastEndMeasurement = "0";
|
|
|
}else {
|
|
|
- //根据开始时间获取当前计量期之前的所有计量期
|
|
|
- List<Long> lastAllPeriodIds = list.stream().filter(item -> item.getStartDate().isBefore(startDate)).map(ContractMeterPeriod::getId).collect(Collectors.toList());
|
|
|
- //获取之前所有计量期的本期计量之和=上期末累计计量
|
|
|
- String lastAllPeriodIdsStr = org.apache.commons.lang.StringUtils.join(lastAllPeriodIds, ",");
|
|
|
- String sql2 = "SELECT id,contract_form_id,contract_meter_id,contract_id,current_price,current_meter_total,contract_period_id FROM `s_inventory_form_apply` WHERE contract_period_id in ("+lastAllPeriodIdsStr+") and contract_id = '"+contractId+"' and is_deleted = 0";
|
|
|
- List<InventoryFormApply> inventoryFormApplies = jdbcTemplate.query(sql2, new BeanPropertyRowMapper<>(InventoryFormApply.class));
|
|
|
- //根据计量期id进行分类
|
|
|
- Map<Long, List<InventoryFormApply>> collect = inventoryFormApplies.stream().collect(Collectors.groupingBy(InventoryFormApply::getContractPeriodId));
|
|
|
- for (Long l : collect.keySet()) {
|
|
|
- //某一计量期的本期计量
|
|
|
- BigDecimal money = new BigDecimal(0);
|
|
|
- //某一计量期的所有数据
|
|
|
- List<InventoryFormApply> inventoryFormApplies1 = collect.get(l);
|
|
|
- //按照清单id分组
|
|
|
- Map<Long, List<InventoryFormApply>> map = inventoryFormApplies1.stream().collect(Collectors.groupingBy(InventoryFormApply::getContractFormId));
|
|
|
- for (Long aLong : map.keySet()) {
|
|
|
- //同一清单的数据
|
|
|
- List<InventoryFormApply> inventoryFormApplies2 = map.get(aLong);
|
|
|
- //同一清单的累计计量数量
|
|
|
- BigDecimal sum = new BigDecimal(0);
|
|
|
- for (InventoryFormApply inventoryFormApply : inventoryFormApplies2) {
|
|
|
- BigDecimal currentMeterTotal = inventoryFormApply.getCurrentMeterTotal();
|
|
|
- sum = sum.add(currentMeterTotal);
|
|
|
- }
|
|
|
- //计算当前清单集合的计量金额 = 累计计量数量 * 单价 四舍五入保留整数
|
|
|
- money = money.add(sum.multiply(inventoryFormApplies2.get(0).getCurrentPrice()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
- }
|
|
|
- //本期支付
|
|
|
- BigDecimal nowPeriodPay = money.multiply(new BigDecimal(0.75)).setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
- //上期末累计支付
|
|
|
- lastEndPay = lastEndPay.add(nowPeriodPay);
|
|
|
- //上期末累计扣取保留金
|
|
|
- lastEndDeduct = lastEndDeduct.add(money.subtract(nowPeriodPay));
|
|
|
- //上期末累计计量
|
|
|
- allMoney = allMoney.add(money);
|
|
|
- }
|
|
|
- }
|
|
|
- String sql3 = "SELECT id,contract_form_id,contract_meter_id,contract_id,current_price,current_meter_total FROM `s_inventory_form_apply` " +
|
|
|
- "WHERE contract_id = '"+contractId+"' and contract_period_id = "+contractMeterPeriodNowId;
|
|
|
- List<InventoryFormApply> inventoryFormAppliesNow = jdbcTemplate.query(sql3, new BeanPropertyRowMapper<>(InventoryFormApply.class));
|
|
|
- //按照清单id分组
|
|
|
- Map<Long, List<InventoryFormApply>> map = inventoryFormAppliesNow.stream().collect(Collectors.groupingBy(InventoryFormApply::getContractFormId));
|
|
|
- //本期计量量
|
|
|
- BigDecimal AllcurrentMeterTotal = new BigDecimal(0);
|
|
|
- for (Long l : map.keySet()) {
|
|
|
- List<InventoryFormApply> inventoryFormApplies = map.get(l);
|
|
|
- BigDecimal metetTotal = new BigDecimal(0);
|
|
|
- for (InventoryFormApply inventoryFormApply : inventoryFormApplies) {
|
|
|
- BigDecimal metetnum = inventoryFormApply.getCurrentMeterTotal();
|
|
|
- metetTotal = metetTotal.add(metetnum);
|
|
|
- }
|
|
|
- AllcurrentMeterTotal = AllcurrentMeterTotal.add(metetTotal.multiply(inventoryFormApplies.get(0).getCurrentPrice()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ HashMap<String, BigDecimal> lastEndData = getLastEndData(list, startDate, contractId, lastEndPay, lastEndDeduct, allMoney);
|
|
|
+ lastEndPay = lastEndData.get("lastEndPay");
|
|
|
+ lastEndDeduct = lastEndData.get("lastEndDeduct");
|
|
|
+ allMoney = lastEndData.get("allMoney");
|
|
|
}
|
|
|
+ /*String sql3 = "SELECT id,contract_form_id,contract_meter_id,contract_id,current_price,current_meter_total FROM `s_inventory_form_apply` " +
|
|
|
+ "WHERE contract_id = '"+contractId+"' and contract_period_id = "+contractMeterPeriodNowId;*/
|
|
|
+ BigDecimal AllcurrentMeterTotal = getCurrentMeter(contractId, periodId, jdbcTemplate);
|
|
|
//------------------------------------------------------------同意本期支付工程款------------------------------------------------------------
|
|
|
BigDecimal currentPay = AllcurrentMeterTotal.multiply(new BigDecimal(0.75)).setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
//小写
|
|
@@ -2381,7 +2348,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
e10.setCellValue(AllcurrentMeterTotal.toString());
|
|
|
//-----------------------------------------------------------经审核承包单位应得款--------------------------------------------------------------------
|
|
|
Cell e11 = getCellByAddress(sheet, "E11");
|
|
|
- e11.setCellValue(currentPay.toString());
|
|
|
+ e11.setCellValue(AllcurrentMeterTotal.toString());
|
|
|
//------------------------------------------------------------本期应扣款------------------------------------------------------------
|
|
|
//本期扣取保留金=本期计量 - 本期支付
|
|
|
BigDecimal deductionMoney = AllcurrentMeterTotal.subtract(currentPay);
|
|
@@ -2392,13 +2359,25 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
e13.setCellValue(currentPay.toString());
|
|
|
|
|
|
//***************************************************************所有日期*************************************************************************
|
|
|
- //顶部日期
|
|
|
- Cell f25 = getCellByAddress(sheet, "F25");
|
|
|
- f25.setCellValue(endDate.toString());
|
|
|
+ //底部日期
|
|
|
+ /*Cell f25 = getCellByAddress(sheet, "F25");
|
|
|
+ f25.setCellValue(endDate.toString());*/
|
|
|
//工程名称
|
|
|
Cell c3 = getCellByAddress(sheet, "C3");
|
|
|
c3.setCellValue("S104金桥至万盛城区段升级改造工程一期(田顶至滩子口段)");
|
|
|
|
|
|
+ for (Sheet sheet1 : workbook) {
|
|
|
+ for (Row row : sheet1) {
|
|
|
+ // 遍历所有单元格
|
|
|
+ for (Cell cell : row) {
|
|
|
+ String stringCellValue = cell.getStringCellValue();
|
|
|
+ if("0".equals(stringCellValue)){
|
|
|
+ cell.setCellValue("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
String file_path = FileUtils.getSysLocalFileUrl();
|
|
|
String locationFile = file_path + SnowFlakeUtil.getId() + ".xlsx";
|
|
|
outputStream = new FileOutputStream(locationFile);
|
|
@@ -2467,42 +2446,10 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
if(isOnePeriod){
|
|
|
lastEndMeasurement = "0";
|
|
|
}else {
|
|
|
- //根据开始时间获取当前计量期之前的所有计量期
|
|
|
- List<Long> lastAllPeriodIds = list.stream().filter(item -> item.getStartDate().isBefore(startDate)).map(ContractMeterPeriod::getId).collect(Collectors.toList());
|
|
|
- //获取之前所有计量期的本期计量之和=上期末累计计量
|
|
|
- String lastAllPeriodIdsStr = org.apache.commons.lang.StringUtils.join(lastAllPeriodIds, ",");
|
|
|
- String sql2 = "SELECT id,contract_form_id,contract_meter_id,contract_id,current_price,current_meter_total,contract_period_id FROM `s_inventory_form_apply` WHERE contract_period_id in ("+lastAllPeriodIdsStr+") and contract_id = '"+contractId+"' and is_deleted = 0";
|
|
|
- List<InventoryFormApply> inventoryFormApplies = jdbcTemplate.query(sql2, new BeanPropertyRowMapper<>(InventoryFormApply.class));
|
|
|
- //根据计量期id进行分类
|
|
|
- Map<Long, List<InventoryFormApply>> collect = inventoryFormApplies.stream().collect(Collectors.groupingBy(InventoryFormApply::getContractPeriodId));
|
|
|
- for (Long l : collect.keySet()) {
|
|
|
- //某一计量期的本期计量
|
|
|
- BigDecimal money = new BigDecimal(0);
|
|
|
- //某一计量期的所有数据
|
|
|
- List<InventoryFormApply> inventoryFormApplies1 = collect.get(l);
|
|
|
- //按照清单id分组
|
|
|
- Map<Long, List<InventoryFormApply>> map = inventoryFormApplies1.stream().collect(Collectors.groupingBy(InventoryFormApply::getContractFormId));
|
|
|
- for (Long aLong : map.keySet()) {
|
|
|
- //同一清单的数据
|
|
|
- List<InventoryFormApply> inventoryFormApplies2 = map.get(aLong);
|
|
|
- //同一清单的累计计量数量
|
|
|
- BigDecimal sum = new BigDecimal(0);
|
|
|
- for (InventoryFormApply inventoryFormApply : inventoryFormApplies2) {
|
|
|
- BigDecimal currentMeterTotal = inventoryFormApply.getCurrentMeterTotal();
|
|
|
- sum = sum.add(currentMeterTotal);
|
|
|
- }
|
|
|
- //计算当前清单集合的计量金额 = 累计计量数量 * 单价 四舍五入保留整数
|
|
|
- money = money.add(sum.multiply(inventoryFormApplies2.get(0).getCurrentPrice()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
- }
|
|
|
- //本期支付
|
|
|
- BigDecimal nowPeriodPay = money.multiply(new BigDecimal(0.75)).setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
- //上期末累计支付
|
|
|
- lastEndPay = lastEndPay.add(nowPeriodPay);
|
|
|
- //上期末累计扣取保留金
|
|
|
- lastEndDeduct = lastEndDeduct.add(money.subtract(nowPeriodPay));
|
|
|
- //上期末累计计量
|
|
|
- allMoney = allMoney.add(money);
|
|
|
- }
|
|
|
+ HashMap<String, BigDecimal> lastEndData = getLastEndData(list, startDate, contractId, lastEndPay, lastEndDeduct, allMoney);
|
|
|
+ lastEndPay = lastEndData.get("lastEndPay");
|
|
|
+ lastEndDeduct = lastEndData.get("lastEndDeduct");
|
|
|
+ allMoney = lastEndData.get("allMoney");
|
|
|
}
|
|
|
Cell d6 = getCellByAddress(sheet, "D6");
|
|
|
d6.setCellValue(allMoney.toString());
|
|
@@ -2510,22 +2457,9 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
Cell e6 = getCellByAddress(sheet, "E6");
|
|
|
e6.setCellValue(lastEndPay.toString());
|
|
|
//------------------------------------------------------------本期计量金额------------------------------------------------------------
|
|
|
- String sql3 = "SELECT id,contract_form_id,contract_meter_id,contract_id,current_price,current_meter_total FROM `s_inventory_form_apply` " +
|
|
|
- "WHERE contract_id = '"+contractId+"' and contract_period_id = "+contractMeterPeriodNowId;
|
|
|
- List<InventoryFormApply> inventoryFormAppliesNow = jdbcTemplate.query(sql3, new BeanPropertyRowMapper<>(InventoryFormApply.class));
|
|
|
- //按照清单id分组
|
|
|
- Map<Long, List<InventoryFormApply>> map = inventoryFormAppliesNow.stream().collect(Collectors.groupingBy(InventoryFormApply::getContractFormId));
|
|
|
- //本期计量量
|
|
|
- BigDecimal AllcurrentMeterTotal = new BigDecimal(0);
|
|
|
- for (Long l : map.keySet()) {
|
|
|
- List<InventoryFormApply> inventoryFormApplies = map.get(l);
|
|
|
- BigDecimal metetTotal = new BigDecimal(0);
|
|
|
- for (InventoryFormApply inventoryFormApply : inventoryFormApplies) {
|
|
|
- BigDecimal metetnum = inventoryFormApply.getCurrentMeterTotal();
|
|
|
- metetTotal = metetTotal.add(metetnum);
|
|
|
- }
|
|
|
- AllcurrentMeterTotal = AllcurrentMeterTotal.add(metetTotal.multiply(inventoryFormApplies.get(0).getCurrentPrice()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
- }
|
|
|
+ /*String sql3 = "SELECT id,contract_form_id,contract_meter_id,contract_id,current_price,current_meter_total FROM `s_inventory_form_apply` " +
|
|
|
+ "WHERE contract_id = '"+contractId+"' and contract_period_id = "+contractMeterPeriodNowId;*/
|
|
|
+ BigDecimal AllcurrentMeterTotal = getCurrentMeter(contractId, periodId, jdbcTemplate);
|
|
|
Cell g6 = getCellByAddress(sheet, "G6");
|
|
|
g6.setCellValue(AllcurrentMeterTotal.toString());
|
|
|
//------------------------------------------------------------本期累计计量金额------------------------------------------------------------
|
|
@@ -2607,7 +2541,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
//顶部日期
|
|
|
Cell j4 = getCellByAddress(sheet, "J4");
|
|
|
j4.setCellValue(endDate.toString());
|
|
|
- //交通建设事务中心审核意见日期
|
|
|
+ /*//交通建设事务中心审核意见日期
|
|
|
Cell m12 = getCellByAddress(sheet, "M12");
|
|
|
m12.setCellValue(endDate.toString());
|
|
|
//业务科室审核意见
|
|
@@ -2624,7 +2558,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
m24.setCellValue(endDate.toString());
|
|
|
//财务分管领导审核意见
|
|
|
Cell m27 = getCellByAddress(sheet, "M27");
|
|
|
- m27.setCellValue(endDate.toString());
|
|
|
+ m27.setCellValue(endDate.toString());*/
|
|
|
//***************************************************************标题*************************************************************************
|
|
|
String periodNumber = contractMeterPeriodNow.getPeriodNumber();
|
|
|
if(ObjectUtil.isNotEmpty(periodNumber)){
|
|
@@ -2635,6 +2569,18 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
Cell d4 = getCellByAddress(sheet, "D4");
|
|
|
d4.setCellValue("重庆市万盛经济开发区交通建设事务中心");
|
|
|
|
|
|
+ for (Sheet sheet1 : workbook) {
|
|
|
+ for (Row row : sheet1) {
|
|
|
+ // 遍历所有单元格
|
|
|
+ for (Cell cell : row) {
|
|
|
+ String stringCellValue = cell.getStringCellValue();
|
|
|
+ if("0".equals(stringCellValue)){
|
|
|
+ cell.setCellValue("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
String file_path = FileUtils.getSysLocalFileUrl();
|
|
|
String locationFile = file_path + SnowFlakeUtil.getId() + ".xlsx";
|
|
|
outputStream = new FileOutputStream(locationFile);
|
|
@@ -2757,42 +2703,10 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
if(isOnePeriod){
|
|
|
lastEndMeasurement = "0";
|
|
|
}else {
|
|
|
- //根据开始时间获取当前计量期之前的所有计量期
|
|
|
- List<Long> lastAllPeriodIds = list.stream().filter(item -> item.getStartDate().isBefore(startDate)).map(ContractMeterPeriod::getId).collect(Collectors.toList());
|
|
|
- //获取之前所有计量期的本期计量之和=上期末累计计量
|
|
|
- String lastAllPeriodIdsStr = org.apache.commons.lang.StringUtils.join(lastAllPeriodIds, ",");
|
|
|
- String sql2 = "SELECT id,contract_form_id,contract_meter_id,contract_id,current_price,current_meter_total,contract_period_id FROM `s_inventory_form_apply` WHERE contract_period_id in ("+lastAllPeriodIdsStr+") and contract_id = '"+contractId+"' and is_deleted = 0";
|
|
|
- List<InventoryFormApply> inventoryFormApplies = jdbcTemplate.query(sql2, new BeanPropertyRowMapper<>(InventoryFormApply.class));
|
|
|
- //根据计量期id进行分类
|
|
|
- Map<Long, List<InventoryFormApply>> collect = inventoryFormApplies.stream().collect(Collectors.groupingBy(InventoryFormApply::getContractPeriodId));
|
|
|
- for (Long l : collect.keySet()) {
|
|
|
- //某一计量期的本期计量
|
|
|
- BigDecimal money = new BigDecimal(0);
|
|
|
- //某一计量期的所有数据
|
|
|
- List<InventoryFormApply> inventoryFormApplies1 = collect.get(l);
|
|
|
- //按照清单id分组
|
|
|
- Map<Long, List<InventoryFormApply>> map = inventoryFormApplies1.stream().collect(Collectors.groupingBy(InventoryFormApply::getContractFormId));
|
|
|
- for (Long aLong : map.keySet()) {
|
|
|
- //同一清单的数据
|
|
|
- List<InventoryFormApply> inventoryFormApplies2 = map.get(aLong);
|
|
|
- //同一清单的累计计量数量
|
|
|
- BigDecimal sum = new BigDecimal(0);
|
|
|
- for (InventoryFormApply inventoryFormApply : inventoryFormApplies2) {
|
|
|
- BigDecimal currentMeterTotal = inventoryFormApply.getCurrentMeterTotal();
|
|
|
- sum = sum.add(currentMeterTotal);
|
|
|
- }
|
|
|
- //计算当前清单集合的计量金额 = 累计计量数量 * 单价 四舍五入保留整数
|
|
|
- money = money.add(sum.multiply(inventoryFormApplies2.get(0).getCurrentPrice()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
- }
|
|
|
- //本期支付
|
|
|
- BigDecimal nowPeriodPay = money.multiply(new BigDecimal(0.75)).setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
- //上期末累计支付
|
|
|
- lastEndPay = lastEndPay.add(nowPeriodPay);
|
|
|
- //上期末累计扣取保留金
|
|
|
- lastEndDeduct = lastEndDeduct.add(money.subtract(nowPeriodPay));
|
|
|
- //上期末累计计量
|
|
|
- allMoney = allMoney.add(money);
|
|
|
- }
|
|
|
+ HashMap<String, BigDecimal> lastEndData = getLastEndData(list, startDate, contractId, lastEndPay, lastEndDeduct, allMoney);
|
|
|
+ lastEndPay = lastEndData.get("lastEndPay");
|
|
|
+ lastEndDeduct = lastEndData.get("lastEndDeduct");
|
|
|
+ allMoney = lastEndData.get("allMoney");
|
|
|
}
|
|
|
Cell a7 = getCellByAddress(sheet, "A7");
|
|
|
a7.setCellValue(allMoney.toString());
|
|
@@ -2800,22 +2714,9 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
Cell c7 = getCellByAddress(sheet, "C7");
|
|
|
c7.setCellValue(lastEndPay.toString());
|
|
|
//---------------------------------------------------------------本期计量-----------------------------------------------------------------------------------------------------------
|
|
|
- String sql3 = "SELECT id,contract_form_id,contract_meter_id,contract_id,current_price,current_meter_total FROM `s_inventory_form_apply` " +
|
|
|
- "WHERE contract_id = '"+contractId+"' and contract_period_id = "+contractMeterPeriodNowId;
|
|
|
- List<InventoryFormApply> inventoryFormAppliesNow = jdbcTemplate.query(sql3, new BeanPropertyRowMapper<>(InventoryFormApply.class));
|
|
|
- //按照清单id分组
|
|
|
- Map<Long, List<InventoryFormApply>> map = inventoryFormAppliesNow.stream().collect(Collectors.groupingBy(InventoryFormApply::getContractFormId));
|
|
|
- //本期计量量
|
|
|
- BigDecimal AllcurrentMeterTotal = new BigDecimal(0);
|
|
|
- for (Long l : map.keySet()) {
|
|
|
- List<InventoryFormApply> inventoryFormApplies = map.get(l);
|
|
|
- BigDecimal metetTotal = new BigDecimal(0);
|
|
|
- for (InventoryFormApply inventoryFormApply : inventoryFormApplies) {
|
|
|
- BigDecimal metetnum = inventoryFormApply.getCurrentMeterTotal();
|
|
|
- metetTotal = metetTotal.add(metetnum);
|
|
|
- }
|
|
|
- AllcurrentMeterTotal = AllcurrentMeterTotal.add(metetTotal.multiply(inventoryFormApplies.get(0).getCurrentPrice()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
- }
|
|
|
+ /*String sql3 = "SELECT id,contract_form_id,contract_meter_id,contract_id,current_price,current_meter_total FROM `s_inventory_form_apply` " +
|
|
|
+ "WHERE contract_id = '"+contractId+"' and contract_period_id = "+contractMeterPeriodNowId;*/
|
|
|
+ BigDecimal AllcurrentMeterTotal = getCurrentMeter(contractId, periodId, jdbcTemplate);
|
|
|
Cell e7 = getCellByAddress(sheet, "E7");
|
|
|
e7.setCellValue(AllcurrentMeterTotal.toString());
|
|
|
//------------------------------------------------------------本期末累计计量------------------------------------------------------------
|
|
@@ -2856,7 +2757,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
//顶部日期
|
|
|
Cell g3 = getCellByAddress(sheet, "G3");
|
|
|
g3.setCellValue(endDate.toString());
|
|
|
- //施工单位申报意见
|
|
|
+ /*//施工单位申报意见
|
|
|
Cell j11 = getCellByAddress(sheet, "J11");
|
|
|
j11.setCellValue(endDate.toString());
|
|
|
//监理单位审核
|
|
@@ -2873,7 +2774,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
j22.setCellValue(endDate.toString());
|
|
|
//主要领导审核意见
|
|
|
Cell j25 = getCellByAddress(sheet, "J25");
|
|
|
- j25.setCellValue(endDate.toString());
|
|
|
+ j25.setCellValue(endDate.toString());*/
|
|
|
//------------------------------------------------------------标题------------------------------------------------------------
|
|
|
CellStyle cellStyle = workbook.createCellStyle();
|
|
|
cellStyle.setWrapText(false);
|
|
@@ -2886,6 +2787,17 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
//施工单位
|
|
|
Cell b3 = getCellByAddress(sheet, "B3");
|
|
|
b3.setCellValue("重庆交通建设(集团)有限责任公司");
|
|
|
+ for (Sheet sheet1 : workbook) {
|
|
|
+ for (Row row : sheet1) {
|
|
|
+ // 遍历所有单元格
|
|
|
+ for (Cell cell : row) {
|
|
|
+ String stringCellValue = cell.getStringCellValue();
|
|
|
+ if("0".equals(stringCellValue)){
|
|
|
+ cell.setCellValue("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//---------------------------结果存储redis---------------------------------
|
|
|
//上期末累计扣取保留金
|
|
|
redisTemplate.opsForValue().set(MeasurementStorage.PRE_END_RESERVE_MONEY +redisId, lastEndDeduct.toString());
|
|
@@ -2917,6 +2829,99 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取上期末的数据
|
|
|
+ * @param list
|
|
|
+ * @param startDate
|
|
|
+ * @param contractId
|
|
|
+ * @param lastEndPay
|
|
|
+ * @param lastEndDeduct
|
|
|
+ * @param allMoney
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+
|
|
|
+ public HashMap<String,BigDecimal> getLastEndData(List<ContractMeterPeriod> list,LocalDate startDate,Long contractId,BigDecimal lastEndPay, BigDecimal lastEndDeduct ,BigDecimal allMoney){
|
|
|
+ //根据开始时间获取当前计量期之前的所有计量期
|
|
|
+ List<Long> lastAllPeriodIds = list.stream().filter(item -> item.getStartDate().isBefore(startDate)).map(ContractMeterPeriod::getId).collect(Collectors.toList());
|
|
|
+ //获取之前所有计量期的本期计量之和=上期末累计计量
|
|
|
+ String lastAllPeriodIdsStr = org.apache.commons.lang.StringUtils.join(lastAllPeriodIds, ",");
|
|
|
+// String sql2 = "SELECT id,contract_form_id,contract_meter_id,contract_id,current_price,current_meter_total,contract_period_id FROM `s_inventory_form_apply` WHERE contract_period_id in ("+lastAllPeriodIdsStr+") and contract_id = '"+contractId+"' and is_deleted = 0";
|
|
|
+ String sql2 = " SELECT cif.id,ifa.contract_period_id,ifa.meter_number,cif.form_number,cif.form_name,cif.unit,cif.current_price,cif.change_total,ifa.current_meter_total,ifa.current_meter_money,ifa.contract_form_id,\n" +
|
|
|
+ " (select period_number from s_contract_meter_period cmp where cmp.id = ifa.contract_period_id) as meterPeriodName,\n" +
|
|
|
+ " (select engineer_divide from s_middle_meter_apply mma where mma.id = ifa.middle_meter_id) as engineerDivide,\n" +
|
|
|
+ " CASE when (select approve_status from s_middle_meter_apply mma where mma.id = ifa.middle_meter_id) = 0 then '未上报' when (select approve_status from s_middle_meter_apply mma where mma.id = ifa.middle_meter_id) = 1 then '待审批' when (select approve_status from s_middle_meter_apply mma where mma.id = ifa.middle_meter_id) = 2 then '已审批'\n" +
|
|
|
+ " else '已废除' end as approveStatusName\n" +
|
|
|
+ " from s_inventory_form_apply ifa left join s_contract_inventory_form cif on ifa.contract_form_id = cif.id\n" +
|
|
|
+ " WHERE ifa.contract_id = '"+contractId+"' and ifa.contract_period_id in("+lastAllPeriodIdsStr+") and ifa.is_deleted = 0";
|
|
|
+ List<InventoryFormApply> inventoryFormApplies = jdbcTemplate.query(sql2, new BeanPropertyRowMapper<>(InventoryFormApply.class));
|
|
|
+ //根据计量期id进行分类
|
|
|
+ Map<Long, List<InventoryFormApply>> collect = inventoryFormApplies.stream().collect(Collectors.groupingBy(InventoryFormApply::getContractPeriodId));
|
|
|
+ for (Long l : collect.keySet()) {
|
|
|
+ //某一计量期的本期计量
|
|
|
+ BigDecimal money = new BigDecimal(0);
|
|
|
+ //某一计量期的所有数据
|
|
|
+ List<InventoryFormApply> inventoryFormApplies1 = collect.get(l);
|
|
|
+ //按照清单id分组
|
|
|
+ Map<Long, List<InventoryFormApply>> map = inventoryFormApplies1.stream().collect(Collectors.groupingBy(InventoryFormApply::getContractFormId));
|
|
|
+ for (Long aLong : map.keySet()) {
|
|
|
+ //根据清单id查询处价格
|
|
|
+ String selectSql= "select current_price from s_contract_inventory_form where id = "+aLong;
|
|
|
+ ContractInventoryForm contractInventoryFormNow = jdbcTemplate.queryForObject(selectSql, new BeanPropertyRowMapper<>(ContractInventoryForm.class));
|
|
|
+ //同一清单的数据
|
|
|
+ List<InventoryFormApply> inventoryFormApplies2 = map.get(aLong);
|
|
|
+ //同一清单的累计计量数量
|
|
|
+ BigDecimal sum = new BigDecimal(0);
|
|
|
+ for (InventoryFormApply inventoryFormApply : inventoryFormApplies2) {
|
|
|
+ BigDecimal currentMeterTotal = inventoryFormApply.getCurrentMeterTotal();
|
|
|
+ sum = sum.add(currentMeterTotal);
|
|
|
+ }
|
|
|
+ //计算当前清单集合的计量金额 = 累计计量数量 * 单价 四舍五入保留整数
|
|
|
+ money = money.add(sum.multiply(contractInventoryFormNow.getCurrentPrice()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
+ //本期支付
|
|
|
+ BigDecimal nowPeriodPay = money.multiply(new BigDecimal(0.75)).setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
+ //上期末累计支付
|
|
|
+ lastEndPay = lastEndPay.add(nowPeriodPay);
|
|
|
+ //上期末累计扣取保留金
|
|
|
+ lastEndDeduct = lastEndDeduct.add(money.subtract(nowPeriodPay));
|
|
|
+ //上期末累计计量
|
|
|
+ allMoney = allMoney.add(money);
|
|
|
+ }
|
|
|
+ HashMap<String, BigDecimal> map = new HashMap<>();
|
|
|
+ map.put("lastEndPay",lastEndPay);
|
|
|
+ map.put("lastEndDeduct",lastEndDeduct);
|
|
|
+ map.put("allMoney",allMoney);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ public static BigDecimal getCurrentMeter(Long contractId, Long periodId ,JdbcTemplate jdbcTemplate){
|
|
|
+ String sql3 = " SELECT cif.id,ifa.meter_number,cif.form_number,cif.form_name,cif.unit,cif.current_price,cif.change_total,ifa.current_meter_total,ifa.current_meter_money,ifa.contract_form_id,\n" +
|
|
|
+ " (select period_number from s_contract_meter_period cmp where cmp.id = ifa.contract_period_id) as meterPeriodName,\n" +
|
|
|
+ " (select engineer_divide from s_middle_meter_apply mma where mma.id = ifa.middle_meter_id) as engineerDivide,\n" +
|
|
|
+ " CASE when (select approve_status from s_middle_meter_apply mma where mma.id = ifa.middle_meter_id) = 0 then '未上报' when (select approve_status from s_middle_meter_apply mma where mma.id = ifa.middle_meter_id) = 1 then '待审批' when (select approve_status from s_middle_meter_apply mma where mma.id = ifa.middle_meter_id) = 2 then '已审批'\n" +
|
|
|
+ " else '已废除' end as approveStatusName\n" +
|
|
|
+ " from s_inventory_form_apply ifa left join s_contract_inventory_form cif on ifa.contract_form_id = cif.id\n" +
|
|
|
+ " WHERE ifa.contract_id = '"+contractId+"' and ifa.contract_period_id ='"+periodId+"' and ifa.is_deleted = 0";
|
|
|
+ List<InventoryFormApply> inventoryFormAppliesNow = jdbcTemplate.query(sql3, new BeanPropertyRowMapper<>(InventoryFormApply.class));
|
|
|
+ //按照清单id分组
|
|
|
+ Map<Long, List<InventoryFormApply>> map = inventoryFormAppliesNow.stream().collect(Collectors.groupingBy(InventoryFormApply::getContractFormId));
|
|
|
+ //本期计量量
|
|
|
+ BigDecimal AllcurrentMeterTotal = new BigDecimal(0);
|
|
|
+ for (Long l : map.keySet()) {
|
|
|
+ //根据清单id查询处价格
|
|
|
+ String selectSql= "select current_price from s_contract_inventory_form where id = "+l;
|
|
|
+ ContractInventoryForm contractInventoryFormNow = jdbcTemplate.queryForObject(selectSql, new BeanPropertyRowMapper<>(ContractInventoryForm.class));
|
|
|
+ List<InventoryFormApply> inventoryFormApplies = map.get(l);
|
|
|
+ BigDecimal metetTotal = new BigDecimal(0);
|
|
|
+ for (InventoryFormApply inventoryFormApply : inventoryFormApplies) {
|
|
|
+ BigDecimal metetnum = inventoryFormApply.getCurrentMeterTotal();
|
|
|
+ metetTotal = metetTotal.add(metetnum);
|
|
|
+ }
|
|
|
+ AllcurrentMeterTotal = AllcurrentMeterTotal.add(metetTotal.multiply(contractInventoryFormNow.getCurrentPrice()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
+ return AllcurrentMeterTotal;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 中间支付申请表获取pdfUrl CR1
|
|
|
* @param url
|