|
@@ -23,6 +23,7 @@ import org.jsoup.Jsoup;
|
|
import org.jsoup.nodes.Document;
|
|
import org.jsoup.nodes.Document;
|
|
import org.jsoup.nodes.Element;
|
|
import org.jsoup.nodes.Element;
|
|
import org.jsoup.select.Elements;
|
|
import org.jsoup.select.Elements;
|
|
|
|
+import org.springblade.common.constant.MeasurementStorage;
|
|
import org.springblade.common.utils.BaseUtils;
|
|
import org.springblade.common.utils.BaseUtils;
|
|
import org.springblade.common.utils.CommonUtil;
|
|
import org.springblade.common.utils.CommonUtil;
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
@@ -42,16 +43,13 @@ import org.springblade.manager.mapper.FormulaMapper;
|
|
import org.springblade.manager.mapper.WbsTreeContractMapper;
|
|
import org.springblade.manager.mapper.WbsTreeContractMapper;
|
|
import org.springblade.manager.mapper.WbsTreePrivateMapper;
|
|
import org.springblade.manager.mapper.WbsTreePrivateMapper;
|
|
import org.springblade.manager.service.*;
|
|
import org.springblade.manager.service.*;
|
|
|
|
+import org.springblade.manager.utils.AmountToChineseConverter;
|
|
import org.springblade.manager.utils.FileUtils;
|
|
import org.springblade.manager.utils.FileUtils;
|
|
import org.springblade.manager.vo.*;
|
|
import org.springblade.manager.vo.*;
|
|
-import org.springblade.meter.entity.ContractInventoryForm;
|
|
|
|
-import org.springblade.meter.entity.ContractMeterPeriod;
|
|
|
|
-import org.springblade.meter.entity.InterimPayCertificateItem;
|
|
|
|
-import org.springblade.meter.entity.MiddleMeterApply;
|
|
|
|
|
|
+import org.springblade.meter.entity.*;
|
|
import org.springblade.meter.feign.CertificateItemClient;
|
|
import org.springblade.meter.feign.CertificateItemClient;
|
|
import org.springblade.meter.feign.MiddleMeterApplyClient;
|
|
import org.springblade.meter.feign.MiddleMeterApplyClient;
|
|
import org.springblade.meter.vo.MeterInventoryDetailVO;
|
|
import org.springblade.meter.vo.MeterInventoryDetailVO;
|
|
-import org.springblade.meter.vo.MeterInventoryVO;
|
|
|
|
import org.springblade.meter.vo.MeterInventoryVO1;
|
|
import org.springblade.meter.vo.MeterInventoryVO1;
|
|
import org.springblade.resource.feign.CommonFileClient;
|
|
import org.springblade.resource.feign.CommonFileClient;
|
|
import org.springblade.resource.feign.NewIOSSClient;
|
|
import org.springblade.resource.feign.NewIOSSClient;
|
|
@@ -60,6 +58,7 @@ import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.dao.EmptyResultDataAccessException;
|
|
import org.springframework.dao.EmptyResultDataAccessException;
|
|
|
|
+import org.springframework.data.redis.core.StringRedisTemplate;
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.mock.web.MockMultipartFile;
|
|
import org.springframework.mock.web.MockMultipartFile;
|
|
@@ -70,6 +69,8 @@ import org.springframework.web.multipart.MultipartFile;
|
|
import javax.validation.constraints.NotNull;
|
|
import javax.validation.constraints.NotNull;
|
|
import java.io.*;
|
|
import java.io.*;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.math.RoundingMode;
|
|
|
|
+import java.time.LocalDate;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.CompletableFuture;
|
|
import java.util.concurrent.CompletableFuture;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
@@ -130,6 +131,8 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
@Lazy
|
|
@Lazy
|
|
@Autowired
|
|
@Autowired
|
|
private IExcelTabService excelTabService;
|
|
private IExcelTabService excelTabService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private StringRedisTemplate redisTemplate;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void execute(TableElementConverter tec) {
|
|
public void execute(TableElementConverter tec) {
|
|
@@ -895,7 +898,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
efm.setParamId(d.getId());
|
|
efm.setParamId(d.getId());
|
|
efm.setElementId(e.getId());
|
|
efm.setElementId(e.getId());
|
|
efm.setFormulaId(tf.getId());
|
|
efm.setFormulaId(tf.getId());
|
|
- this.elementFormulaMappingService.save(efm);
|
|
|
|
|
|
+ //this.elementFormulaMappingService.save(efm);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
});
|
|
@@ -915,7 +918,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
efm.setParamId(d.getId());
|
|
efm.setParamId(d.getId());
|
|
efm.setElementId(e.getId());
|
|
efm.setElementId(e.getId());
|
|
efm.setFormulaId(tf.getId());
|
|
efm.setFormulaId(tf.getId());
|
|
- this.elementFormulaMappingService.save(efm);
|
|
|
|
|
|
+ //this.elementFormulaMappingService.save(efm);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
});
|
|
@@ -2158,11 +2161,28 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<ReportResult> execute4(Long contractId, Long periodId, Integer type,Long projectId) {
|
|
public List<ReportResult> execute4(Long contractId, Long periodId, Integer type,Long projectId) {
|
|
|
|
+
|
|
|
|
+ Long redisId = SnowFlakeUtil.getId();
|
|
//判断计算的是哪一期。
|
|
//判断计算的是哪一期。
|
|
String sql="Select * from s_contract_meter_period where contract_id="+contractId+" and is_deleted=0"+" order by start_date";
|
|
String sql="Select * from s_contract_meter_period where contract_id="+contractId+" and is_deleted=0"+" order by start_date";
|
|
List<ContractMeterPeriod> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ContractMeterPeriod.class));
|
|
List<ContractMeterPeriod> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ContractMeterPeriod.class));
|
|
|
|
+ ArrayList<ReportResult> reportResults = new ArrayList<>();
|
|
|
|
+ //中期支付报表封面
|
|
|
|
+ String url = "https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20240828/3ee50ef54005c95bd724bcabae54058c.XLSX";
|
|
//中间支付审核表
|
|
//中间支付审核表
|
|
String url1 = "https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20241120/ea6c945827dd2990a9c7b1957fe201c4.XLSX";
|
|
String url1 = "https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20241120/ea6c945827dd2990a9c7b1957fe201c4.XLSX";
|
|
|
|
+ //补助款申请支付审核表
|
|
|
|
+ String url2 = "https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20241120/970eec0eb3cf3d215263a0e2f24c142e.xlsx";
|
|
|
|
+ //中间计量支付证书
|
|
|
|
+ String url3 = "https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20240828/fb1110ae6aab7295759775206e5b44b8.XLSX";
|
|
|
|
+ // 获取中期支付报表封面的pdfurl
|
|
|
|
+ ReportResult CoverOfMidtermPaymentReportPDF = getCoverOfMidtermPaymentReportPDF(url,contractId,periodId);
|
|
|
|
+ //获取中间支付审核表的pdfurl
|
|
|
|
+ ReportResult intermediatePaymentPDF = getIntermediatePaymentPDF(url1,contractId,periodId,list,redisId);
|
|
|
|
+ //获取补助款申请支付审核表pdfUrl
|
|
|
|
+ ReportResult subsidyApplicationPaymentReviewPDF = getSubsidyApplicationPaymentReviewPDF(url2,contractId,periodId,list);
|
|
|
|
+ //获取中间计量支付证书pdfUrl
|
|
|
|
+ ReportResult intermediateMeasurementPaymentCertificatePDF = getIntermediateMeasurementPaymentCertificatePDF(url3,contractId,periodId,list);
|
|
//中间计量支付申请表
|
|
//中间计量支付申请表
|
|
String url4="https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20240828/bff82dd0a1b7394f5fdab1322a3e6023.XLSX";
|
|
String url4="https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20240828/bff82dd0a1b7394f5fdab1322a3e6023.XLSX";
|
|
//工程支付月报
|
|
//工程支付月报
|
|
@@ -2176,18 +2196,468 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
//获取工程支付月报pdfUrl
|
|
//获取工程支付月报pdfUrl
|
|
//ReportResult monthlyReportPDF=getMonthlyReportPDF(url5);
|
|
//ReportResult monthlyReportPDF=getMonthlyReportPDF(url5);
|
|
//获取清单支付报表PDF
|
|
//获取清单支付报表PDF
|
|
- ReportResult inventoryPayReportPDF=getInventoryPayReportPDF(url6,contractId,periodId,projectId,list);
|
|
|
|
- return null;
|
|
|
|
|
|
+ //ReportResult inventoryPayReportPDF=getInventoryPayReportPDF(url6,contractId,periodId,projectId,list);
|
|
|
|
+ reportResults.add(CoverOfMidtermPaymentReportPDF);
|
|
|
|
+ reportResults.add(intermediatePaymentPDF);
|
|
|
|
+ reportResults.add(subsidyApplicationPaymentReviewPDF);
|
|
|
|
+ reportResults.add(intermediateMeasurementPaymentCertificatePDF);
|
|
|
|
+ //reportResults.add(inventoryPayReportPDF);
|
|
|
|
+ return reportResults;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 中期支付报表封面
|
|
|
|
+ */
|
|
|
|
+ private ReportResult getCoverOfMidtermPaymentReportPDF(String url, Long contractId, Long periodId) {
|
|
|
|
+ //获取本期计量期
|
|
|
|
+ String sqlForMeterPeriodById = "SELECT id,period_number,start_date,end_date FROM s_contract_meter_period WHERE id="+periodId+" and is_deleted = 0 ";
|
|
|
|
+ ContractMeterPeriod contractMeterPeriodNow = jdbcTemplate.queryForObject(sqlForMeterPeriodById, new BeanPropertyRowMapper<>(ContractMeterPeriod.class));
|
|
|
|
+ //本期计量期id
|
|
|
|
+ Long contractMeterPeriodNowId = contractMeterPeriodNow.getId();
|
|
|
|
+ //本期计量开始时间
|
|
|
|
+ LocalDate startDate = contractMeterPeriodNow.getStartDate();
|
|
|
|
+ //本期计量开始时间
|
|
|
|
+ LocalDate endDate = contractMeterPeriodNow.getEndDate();
|
|
|
|
+ InputStream modInput = null;
|
|
|
|
+ FileInputStream excelFileInput = null;
|
|
|
|
+ FileOutputStream outputStream = null;
|
|
|
|
+ Workbook workbook = null;
|
|
|
|
+ MultipartFile files = null;
|
|
|
|
+ try {
|
|
|
|
+ modInput = CommonUtil.getOSSInputStream(url);
|
|
|
|
+ workbook = WorkbookFactory.create(modInput);
|
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
|
+ //期号
|
|
|
|
+ String periodNumber = contractMeterPeriodNow.getPeriodNumber();
|
|
|
|
+ if (ObjectUtil.isNotEmpty(periodNumber)){
|
|
|
|
+ Cell d4 = getCellByAddress(sheet, "D4");
|
|
|
|
+ d4.setCellValue(periodNumber);
|
|
|
|
+ }
|
|
|
|
+ //施工单位
|
|
|
|
+ Cell c9 = getCellByAddress(sheet, "C9");
|
|
|
|
+ c9.setCellValue("重庆交通建设(集团)有限责任公司");
|
|
|
|
+ //监理单位
|
|
|
|
+ Cell c10 = getCellByAddress(sheet, "C10");
|
|
|
|
+ c10.setCellValue("重庆市交通工程监理咨询有限责任公司");
|
|
|
|
+ //日期
|
|
|
|
+ Cell c11 = getCellByAddress(sheet, "C11");
|
|
|
|
+ c11.setCellValue(endDate.toString());
|
|
|
|
+
|
|
|
|
+ String file_path = FileUtils.getSysLocalFileUrl();
|
|
|
|
+ String locationFile = file_path + SnowFlakeUtil.getId() + ".xlsx";
|
|
|
|
+ outputStream = new FileOutputStream(locationFile);
|
|
|
|
+ //生成一份新的excel
|
|
|
|
+ workbook.write(outputStream);
|
|
|
|
+ //将excel转PDF
|
|
|
|
+ File excelFile = new File(locationFile);
|
|
|
|
+ excelFileInput = new FileInputStream(excelFile);
|
|
|
|
+ files = new MockMultipartFile("file", excelFile.getName(), "text/plain", IOUtils.toByteArray(excelFileInput));
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ NewBladeFile bladeFile = this.commonFileClient.excelToPdf(files);
|
|
|
|
+ ReportResult reportResult = new ReportResult();
|
|
|
|
+ reportResult.setOssPdfUrl(bladeFile.getPdfUrl());
|
|
|
|
+ reportResult.setPdfPath(bladeFile.getPdfUrl());
|
|
|
|
+ reportResult.setName("中期支付报表封面");
|
|
|
|
+ return reportResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ *中间计量支付证书获取PDFurl
|
|
|
|
+ */
|
|
|
|
+ private ReportResult getIntermediateMeasurementPaymentCertificatePDF(String url3, Long contractId, Long periodId, List<ContractMeterPeriod> list) {
|
|
|
|
+ //判断当前是否是只有1期计量
|
|
|
|
+ Boolean isOnePeriod = false;
|
|
|
|
+ if(list.size() ==1 ){
|
|
|
|
+ isOnePeriod = true;
|
|
|
|
+ }
|
|
|
|
+ //获取本期计量期
|
|
|
|
+ String sqlForMeterPeriodById = "SELECT id,period_number,start_date,end_date FROM s_contract_meter_period WHERE id="+periodId+" and is_deleted = 0 ";
|
|
|
|
+ ContractMeterPeriod contractMeterPeriodNow = jdbcTemplate.queryForObject(sqlForMeterPeriodById, new BeanPropertyRowMapper<>(ContractMeterPeriod.class));
|
|
|
|
+ //本期计量期id
|
|
|
|
+ Long contractMeterPeriodNowId = contractMeterPeriodNow.getId();
|
|
|
|
+ //本期计量开始时间
|
|
|
|
+ LocalDate startDate = contractMeterPeriodNow.getStartDate();
|
|
|
|
+ //本期计量开始时间
|
|
|
|
+ LocalDate endDate = contractMeterPeriodNow.getEndDate();
|
|
|
|
+ InputStream modInput = null;
|
|
|
|
+ FileInputStream excelFileInput = null;
|
|
|
|
+ FileOutputStream outputStream = null;
|
|
|
|
+ Workbook workbook = null;
|
|
|
|
+ MultipartFile files = null;
|
|
|
|
+ try {
|
|
|
|
+ modInput = CommonUtil.getOSSInputStream(url3);
|
|
|
|
+ workbook = WorkbookFactory.create(modInput);
|
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
|
+ //------------------------------------------------------------上期末累计计量金额------------------------------------------------------------
|
|
|
|
+ BigDecimal allMoney = new BigDecimal(0);
|
|
|
|
+ //顺便计算上期末累计支付
|
|
|
|
+ BigDecimal lastEndPay = new BigDecimal(0);
|
|
|
|
+ //顺便计算上期末累计扣取保留金
|
|
|
|
+ BigDecimal lastEndDeduct = new BigDecimal(0);
|
|
|
|
+ String lastEndMeasurement = "";
|
|
|
|
+ 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));
|
|
|
|
+ }
|
|
|
|
+ //------------------------------------------------------------同意本期支付工程款------------------------------------------------------------
|
|
|
|
+ BigDecimal currentPay = AllcurrentMeterTotal.multiply(new BigDecimal(0.75)).setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ //小写
|
|
|
|
+ Cell c7 = getCellByAddress(sheet, "C7");
|
|
|
|
+ c7.setCellValue(currentPay.toString());
|
|
|
|
+ //大写
|
|
|
|
+ Cell d6 = getCellByAddress(sheet, "D6");
|
|
|
|
+ d6.setCellValue(AmountToChineseConverter.convertToChinese(currentPay));
|
|
|
|
+ //-----------------------------------------------------------承包单位申报款--------------------------------------------------------------------
|
|
|
|
+ Cell e10 = getCellByAddress(sheet, "E10");
|
|
|
|
+ e10.setCellValue(AllcurrentMeterTotal.toString());
|
|
|
|
+ //-----------------------------------------------------------经审核承包单位应得款--------------------------------------------------------------------
|
|
|
|
+ Cell e11 = getCellByAddress(sheet, "E11");
|
|
|
|
+ e11.setCellValue(currentPay.toString());
|
|
|
|
+ //------------------------------------------------------------本期应扣款------------------------------------------------------------
|
|
|
|
+ //本期扣取保留金=本期计量 - 本期支付
|
|
|
|
+ BigDecimal deductionMoney = AllcurrentMeterTotal.subtract(currentPay);
|
|
|
|
+ Cell e12 = getCellByAddress(sheet, "E12");
|
|
|
|
+ e12.setCellValue(deductionMoney.toString());
|
|
|
|
+ //------------------------------------------------------------本期应付款------------------------------------------------------------
|
|
|
|
+ Cell e13 = getCellByAddress(sheet, "E13");
|
|
|
|
+ e13.setCellValue(currentPay.toString());
|
|
|
|
+
|
|
|
|
+ //***************************************************************所有日期*************************************************************************
|
|
|
|
+ //顶部日期
|
|
|
|
+ Cell f25 = getCellByAddress(sheet, "F25");
|
|
|
|
+ f25.setCellValue(endDate.toString());
|
|
|
|
+ //工程名称
|
|
|
|
+ Cell c3 = getCellByAddress(sheet, "C3");
|
|
|
|
+ c3.setCellValue("S104金桥至万盛城区段升级改造工程一期(田顶至滩子口段)");
|
|
|
|
+
|
|
|
|
+ String file_path = FileUtils.getSysLocalFileUrl();
|
|
|
|
+ String locationFile = file_path + SnowFlakeUtil.getId() + ".xlsx";
|
|
|
|
+ outputStream = new FileOutputStream(locationFile);
|
|
|
|
+ //生成一份新的excel
|
|
|
|
+ workbook.write(outputStream);
|
|
|
|
+ //将excel转PDF
|
|
|
|
+ File excelFile = new File(locationFile);
|
|
|
|
+ excelFileInput = new FileInputStream(excelFile);
|
|
|
|
+ files = new MockMultipartFile("file", excelFile.getName(), "text/plain", IOUtils.toByteArray(excelFileInput));
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ NewBladeFile bladeFile = this.commonFileClient.excelToPdf(files);
|
|
|
|
+ ReportResult reportResult = new ReportResult();
|
|
|
|
+ reportResult.setOssPdfUrl(bladeFile.getPdfUrl());
|
|
|
|
+ reportResult.setPdfPath(bladeFile.getPdfUrl());
|
|
|
|
+ reportResult.setName("中间计量支付证书");
|
|
|
|
+ return reportResult;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ *补助款申请支付审核表获取PDFurl
|
|
|
|
+ */
|
|
|
|
+ private ReportResult getSubsidyApplicationPaymentReviewPDF(String url2, Long contractId, Long periodId, List<ContractMeterPeriod> list) {
|
|
|
|
+ //判断当前是否是只有1期计量
|
|
|
|
+ Boolean isOnePeriod = false;
|
|
|
|
+ if(list.size() ==1 ){
|
|
|
|
+ isOnePeriod = true;
|
|
|
|
+ }
|
|
|
|
+ //获取本期计量期
|
|
|
|
+ String sqlForMeterPeriodById = "SELECT id,period_number,start_date,end_date FROM s_contract_meter_period WHERE id="+periodId+" and is_deleted = 0 ";
|
|
|
|
+ ContractMeterPeriod contractMeterPeriodNow = jdbcTemplate.queryForObject(sqlForMeterPeriodById, new BeanPropertyRowMapper<>(ContractMeterPeriod.class));
|
|
|
|
+ //本期计量期id
|
|
|
|
+ Long contractMeterPeriodNowId = contractMeterPeriodNow.getId();
|
|
|
|
+ //本期计量开始时间
|
|
|
|
+ LocalDate startDate = contractMeterPeriodNow.getStartDate();
|
|
|
|
+ //本期计量开始时间
|
|
|
|
+ LocalDate endDate = contractMeterPeriodNow.getEndDate();
|
|
|
|
+ InputStream modInput = null;
|
|
|
|
+ FileInputStream excelFileInput = null;
|
|
|
|
+ FileOutputStream outputStream = null;
|
|
|
|
+ Workbook workbook = null;
|
|
|
|
+ MultipartFile files = null;
|
|
|
|
+ try {
|
|
|
|
+ modInput = CommonUtil.getOSSInputStream(url2);
|
|
|
|
+ workbook = WorkbookFactory.create(modInput);
|
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
|
+ //***************************************************************建安费*************************************************************************
|
|
|
|
+ Cell a6 = getCellByAddress(sheet, "A6");
|
|
|
|
+ a6.setCellValue("建安费");
|
|
|
|
+ //------------------------------------------------------------项目总投资------------------------------------------------------------
|
|
|
|
+ String sql1 = "SELECT SUM(contract_money) FROM `s_contract_inventory_form` WHERE contract_id="+contractId+" and is_deleted = 0 ";
|
|
|
|
+ BigDecimal totalMoney = jdbcTemplate.queryForObject(sql1, BigDecimal.class);
|
|
|
|
+ totalMoney = totalMoney.setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ Cell b6 = getCellByAddress(sheet, "B6");
|
|
|
|
+ b6.setCellValue(totalMoney.toString());
|
|
|
|
+ //------------------------------------------------------------上期末累计计量金额------------------------------------------------------------
|
|
|
|
+ BigDecimal allMoney = new BigDecimal(0);
|
|
|
|
+ //顺便计算上期末累计支付
|
|
|
|
+ BigDecimal lastEndPay = new BigDecimal(0);
|
|
|
|
+ //顺便计算上期末累计扣取保留金
|
|
|
|
+ BigDecimal lastEndDeduct = new BigDecimal(0);
|
|
|
|
+ String lastEndMeasurement = "";
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Cell d6 = getCellByAddress(sheet, "D6");
|
|
|
|
+ d6.setCellValue(allMoney.toString());
|
|
|
|
+ //------------------------------------------------------------上期末累计支付金额------------------------------------------------------------
|
|
|
|
+ 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));
|
|
|
|
+ }
|
|
|
|
+ Cell g6 = getCellByAddress(sheet, "G6");
|
|
|
|
+ g6.setCellValue(AllcurrentMeterTotal.toString());
|
|
|
|
+ //------------------------------------------------------------本期累计计量金额------------------------------------------------------------
|
|
|
|
+ //上期末累计计量金额+本期计量金额
|
|
|
|
+ BigDecimal allMoneyNow = allMoney.add(AllcurrentMeterTotal);
|
|
|
|
+ Cell h6 = getCellByAddress(sheet, "H6");
|
|
|
|
+ h6.setCellValue(allMoneyNow.toString());
|
|
|
|
+ //------------------------------------------------------------本期支付金额------------------------------------------------------------
|
|
|
|
+ BigDecimal currentPay = AllcurrentMeterTotal.multiply(new BigDecimal(0.75)).setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ Cell i6 = getCellByAddress(sheet, "I6");
|
|
|
|
+ i6.setCellValue(currentPay.toString());
|
|
|
|
+ //------------------------------------------------------------本期末累计支付金额------------------------------------------------------------
|
|
|
|
+ //上期末累计支付+本期支付
|
|
|
|
+ BigDecimal endPay = lastEndPay.add(currentPay);
|
|
|
|
+ Cell k6 = getCellByAddress(sheet, "K6");
|
|
|
|
+ k6.setCellValue(endPay.toString());
|
|
|
|
+ //------------------------------------------------------------支付比例------------------------------------------------------------
|
|
|
|
+ Cell m6 = getCellByAddress(sheet, "M6");
|
|
|
|
+ m6.setCellValue("75.00%");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //***************************************************************其他费用*************************************************************************
|
|
|
|
+ Cell a7 = getCellByAddress(sheet, "A7");
|
|
|
|
+ a7.setCellValue("其他费用");
|
|
|
|
+ //------------------------------------------------------------项目总投资------------------------------------------------------------
|
|
|
|
+ Cell b7 = getCellByAddress(sheet, "B7");
|
|
|
|
+ b7.setCellValue("");
|
|
|
|
+ //------------------------------------------------------------上期末累计计量金额------------------------------------------------------------
|
|
|
|
+ Cell d7 = getCellByAddress(sheet, "D7");
|
|
|
|
+ d7.setCellValue("0");
|
|
|
|
+ //------------------------------------------------------------上期末累计支付金额------------------------------------------------------------
|
|
|
|
+ Cell e7 = getCellByAddress(sheet, "E7");
|
|
|
|
+ e7.setCellValue("0");
|
|
|
|
+ //------------------------------------------------------------本期计量金额------------------------------------------------------------
|
|
|
|
+ Cell g7 = getCellByAddress(sheet, "G7");
|
|
|
|
+ g7.setCellValue("0");
|
|
|
|
+ //------------------------------------------------------------本期累计计量金额------------------------------------------------------------
|
|
|
|
+ //上期末累计计量金额+本期计量金额
|
|
|
|
+ Cell h7 = getCellByAddress(sheet, "H7");
|
|
|
|
+ h7.setCellValue("0");
|
|
|
|
+ //------------------------------------------------------------本期支付金额------------------------------------------------------------
|
|
|
|
+ Cell i7 = getCellByAddress(sheet, "I7");
|
|
|
|
+ i7.setCellValue("0");
|
|
|
|
+ //------------------------------------------------------------本期末累计支付金额------------------------------------------------------------
|
|
|
|
+ Cell k7 = getCellByAddress(sheet, "K7");
|
|
|
|
+ k7.setCellValue("0");
|
|
|
|
+ //------------------------------------------------------------支付比例------------------------------------------------------------
|
|
|
|
+ Cell m7 = getCellByAddress(sheet, "M7");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //***************************************************************合计*************************************************************************
|
|
|
|
+ //------------------------------------------------------------项目总投资------------------------------------------------------------
|
|
|
|
+ Cell b8 = getCellByAddress(sheet, "B8");
|
|
|
|
+ b8.setCellValue(totalMoney.toString());
|
|
|
|
+ //------------------------------------------------------------上期末累计计量金额------------------------------------------------------------
|
|
|
|
+ Cell d8 = getCellByAddress(sheet, "D8");
|
|
|
|
+ d8.setCellValue(allMoney.toString());
|
|
|
|
+ //------------------------------------------------------------上期末累计支付金额------------------------------------------------------------
|
|
|
|
+ Cell e8 = getCellByAddress(sheet, "E8");
|
|
|
|
+ e8.setCellValue(lastEndPay.toString());
|
|
|
|
+ //------------------------------------------------------------本期计量金额------------------------------------------------------------
|
|
|
|
+ Cell g8 = getCellByAddress(sheet, "G8");
|
|
|
|
+ g8.setCellValue(AllcurrentMeterTotal.toString());
|
|
|
|
+ //------------------------------------------------------------本期累计计量金额------------------------------------------------------------
|
|
|
|
+ //上期末累计计量金额+本期计量金额
|
|
|
|
+ Cell h8 = getCellByAddress(sheet, "H8");
|
|
|
|
+ h8.setCellValue(allMoneyNow.toString());
|
|
|
|
+ //------------------------------------------------------------本期支付金额------------------------------------------------------------
|
|
|
|
+ Cell i8 = getCellByAddress(sheet, "I8");
|
|
|
|
+ i8.setCellValue(currentPay.toString());
|
|
|
|
+ //------------------------------------------------------------本期末累计支付金额------------------------------------------------------------
|
|
|
|
+ Cell k8 = getCellByAddress(sheet, "K8");
|
|
|
|
+ k8.setCellValue(endPay.toString());
|
|
|
|
+ //------------------------------------------------------------支付比例------------------------------------------------------------
|
|
|
|
+ Cell m8 = getCellByAddress(sheet, "M8");
|
|
|
|
+
|
|
|
|
+ //***************************************************************所有日期*************************************************************************
|
|
|
|
+ //顶部日期
|
|
|
|
+ Cell j4 = getCellByAddress(sheet, "J4");
|
|
|
|
+ j4.setCellValue(endDate.toString());
|
|
|
|
+ //交通建设事务中心审核意见日期
|
|
|
|
+ Cell m12 = getCellByAddress(sheet, "M12");
|
|
|
|
+ m12.setCellValue(endDate.toString());
|
|
|
|
+ //业务科室审核意见
|
|
|
|
+ Cell m15 = getCellByAddress(sheet, "M15");
|
|
|
|
+ m15.setCellValue(endDate.toString());
|
|
|
|
+ //财务科审核意见
|
|
|
|
+ Cell m18 = getCellByAddress(sheet, "M18");
|
|
|
|
+ m18.setCellValue(endDate.toString());
|
|
|
|
+ //业务科室分管领导审核意见
|
|
|
|
+ Cell m21 = getCellByAddress(sheet, "M21");
|
|
|
|
+ m21.setCellValue(endDate.toString());
|
|
|
|
+ //财务分管领导审核意见
|
|
|
|
+ Cell m24 = getCellByAddress(sheet, "M24");
|
|
|
|
+ m24.setCellValue(endDate.toString());
|
|
|
|
+ //财务分管领导审核意见
|
|
|
|
+ Cell m27 = getCellByAddress(sheet, "M27");
|
|
|
|
+ m27.setCellValue(endDate.toString());
|
|
|
|
+ //***************************************************************标题*************************************************************************
|
|
|
|
+ String periodNumber = contractMeterPeriodNow.getPeriodNumber();
|
|
|
|
+ if(ObjectUtil.isNotEmpty(periodNumber)){
|
|
|
|
+ Cell e3 = getCellByAddress(sheet, "E3");
|
|
|
|
+ e3.setCellValue(periodNumber);
|
|
|
|
+ }
|
|
|
|
+ //填报单位
|
|
|
|
+ Cell d4 = getCellByAddress(sheet, "D4");
|
|
|
|
+ d4.setCellValue("重庆市万盛经济开发区交通建设事务中心");
|
|
|
|
+
|
|
|
|
+ String file_path = FileUtils.getSysLocalFileUrl();
|
|
|
|
+ String locationFile = file_path + SnowFlakeUtil.getId() + ".xlsx";
|
|
|
|
+ outputStream = new FileOutputStream(locationFile);
|
|
|
|
+ //生成一份新的excel
|
|
|
|
+ workbook.write(outputStream);
|
|
|
|
+ //将excel转PDF
|
|
|
|
+ File excelFile = new File(locationFile);
|
|
|
|
+ excelFileInput = new FileInputStream(excelFile);
|
|
|
|
+ files = new MockMultipartFile("file", excelFile.getName(), "text/plain", IOUtils.toByteArray(excelFileInput));
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ NewBladeFile bladeFile = this.commonFileClient.excelToPdf(files);
|
|
|
|
+ ReportResult reportResult = new ReportResult();
|
|
|
|
+ reportResult.setOssPdfUrl(bladeFile.getPdfUrl());
|
|
|
|
+ reportResult.setPdfPath(bladeFile.getPdfUrl());
|
|
|
|
+ reportResult.setName("补助款申请支付审核表");
|
|
|
|
+ return reportResult;
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 中间支付审核表获取PDFurl
|
|
* 中间支付审核表获取PDFurl
|
|
- *
|
|
|
|
- * @param url
|
|
|
|
- * @return
|
|
|
|
*/
|
|
*/
|
|
- public ReportResult getIntermediatePaymentPDF(String url) {
|
|
|
|
|
|
+ public ReportResult getIntermediatePaymentPDF(String url,Long contractId,Long periodId,List<ContractMeterPeriod> list,Long redisId) {
|
|
|
|
+ //判断当前是否是只有1期计量
|
|
|
|
+ Boolean isOnePeriod = false;
|
|
|
|
+ if(list.size() ==1 ){
|
|
|
|
+ isOnePeriod = true;
|
|
|
|
+ }
|
|
|
|
+ //获取本期计量期
|
|
|
|
+ String sqlForMeterPeriodById = "SELECT id,period_number,start_date,end_date FROM s_contract_meter_period WHERE id="+periodId+" and is_deleted = 0 ";
|
|
|
|
+ ContractMeterPeriod contractMeterPeriodNow = jdbcTemplate.queryForObject(sqlForMeterPeriodById, new BeanPropertyRowMapper<>(ContractMeterPeriod.class));
|
|
|
|
+ //本期计量期id
|
|
|
|
+ Long contractMeterPeriodNowId = contractMeterPeriodNow.getId();
|
|
|
|
+ //本期计量开始时间
|
|
|
|
+ LocalDate startDate = contractMeterPeriodNow.getStartDate();
|
|
|
|
+ //本期计量开始时间
|
|
|
|
+ LocalDate endDate = contractMeterPeriodNow.getEndDate();
|
|
InputStream modInput = null;
|
|
InputStream modInput = null;
|
|
FileInputStream excelFileInput = null;
|
|
FileInputStream excelFileInput = null;
|
|
FileOutputStream outputStream = null;
|
|
FileOutputStream outputStream = null;
|
|
@@ -2197,11 +2667,219 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
modInput = CommonUtil.getOSSInputStream(url);
|
|
modInput = CommonUtil.getOSSInputStream(url);
|
|
workbook = WorkbookFactory.create(modInput);
|
|
workbook = WorkbookFactory.create(modInput);
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
- //根据坐标获取单元格
|
|
|
|
|
|
+ //------------------------------------------------------------签约合同价------------------------------------------------------------
|
|
|
|
+ String sql1 = "SELECT SUM(contract_money) FROM `s_contract_inventory_form` WHERE contract_id="+contractId+" and is_deleted = 0 ";
|
|
|
|
+ BigDecimal totalMoney = jdbcTemplate.queryForObject(sql1, BigDecimal.class);
|
|
|
|
+ totalMoney = totalMoney.setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ Cell a5 = getCellByAddress(sheet, "A5");
|
|
|
|
+ a5.setCellValue(totalMoney.toString());
|
|
|
|
+ //------------------------------------------------------------上期末累计变更------------------------------------------------------------
|
|
|
|
+ BigDecimal lastEndChangeMoney = new BigDecimal(0);
|
|
|
|
+
|
|
|
|
+ if (isOnePeriod){
|
|
|
|
+ lastEndChangeMoney = lastEndChangeMoney;
|
|
|
|
+ }else {
|
|
|
|
+ //根据开始时间获取当前计量期之前的所有计量期
|
|
|
|
+ List<ContractMeterPeriod> listFlitered = list.stream().filter(item -> item.getStartDate().isBefore(startDate)).collect(Collectors.toList());
|
|
|
|
+ for (ContractMeterPeriod contractMeterPeriod : listFlitered) {
|
|
|
|
+ //本期变更
|
|
|
|
+ BigDecimal changeMoneyNow = new BigDecimal(0);
|
|
|
|
+ String sql2 = "SELECT change_money, change_approval_date FROM `s_change_token_form` WHERE contract_id = '"+contractId +"' and approve_status = 2 and command_status = 1 and is_deleted = 0 ";
|
|
|
|
+ List<ChangeToken> changeTokens = jdbcTemplate.query(sql2, new BeanPropertyRowMapper<>(ChangeToken.class));
|
|
|
|
+ List<ChangeToken> collect = changeTokens.stream()
|
|
|
|
+ .filter(c -> c.getChangeApprovalDate().isAfter(contractMeterPeriod.getStartDate()) && c.getChangeApprovalDate().isBefore(contractMeterPeriod.getEndDate()))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ if(ObjectUtil.isNotEmpty(collect)){
|
|
|
|
+ for (ChangeToken changeToken : collect) {
|
|
|
|
+ changeMoneyNow = changeMoneyNow.add(changeToken.getChangeMoney());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ changeMoneyNow = changeMoneyNow.setScale(0, RoundingMode.HALF_UP);
|
|
|
|
+ lastEndChangeMoney = lastEndChangeMoney.add(changeMoneyNow);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
Cell c5 = getCellByAddress(sheet, "C5");
|
|
Cell c5 = getCellByAddress(sheet, "C5");
|
|
- c5.setCellValue("大笨熊二号");
|
|
|
|
|
|
+ c5.setCellValue(lastEndChangeMoney.toString());
|
|
|
|
+ //------------------------------------------------------------本期变更------------------------------------------------------------
|
|
|
|
+ //获取当前合同段的所有已审批并且已下达的变更令
|
|
|
|
+ String sql4 = "SELECT id,change_money,change_approval_date from s_change_token_form where contract_id = '"+contractId +"' and approve_status = 2 and command_status = 1 and is_deleted = 0";
|
|
|
|
+ List<ChangeTokenForm> changeTokenForms = jdbcTemplate.query(sql4, new BeanPropertyRowMapper<>(ChangeTokenForm.class));
|
|
|
|
+ //筛选出时间在本期计量开始和结束时间之内的数据
|
|
|
|
+ List<ChangeTokenForm> changeTokenForms1 = changeTokenForms.stream()
|
|
|
|
+ .filter(changeTokenForm -> changeTokenForm.getChangeApprovalDate().isAfter(startDate) && changeTokenForm.getChangeApprovalDate().isBefore(endDate))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ //本期变更金额
|
|
|
|
+ BigDecimal changeMoneySum = new BigDecimal(0);
|
|
|
|
+ if(ObjectUtil.isNotEmpty(changeTokenForms1)){
|
|
|
|
+ for (ChangeTokenForm changeTokenForm : changeTokenForms1) {
|
|
|
|
+ changeMoneySum = changeMoneySum.add(changeTokenForm.getChangeMoney());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ changeMoneySum = changeMoneySum.setScale(0, RoundingMode.HALF_UP);
|
|
|
|
+ Cell e5 = getCellByAddress(sheet, "E5");
|
|
|
|
+ e5.setCellValue(changeMoneySum.toString());
|
|
|
|
+ //------------------------------------------------------------本期末累计变更------------------------------------------------------------
|
|
|
|
+ //上期末累计变更+本期变更
|
|
|
|
+ BigDecimal lastEndChangeMoneySum = lastEndChangeMoney.add(changeMoneySum);
|
|
|
|
+ Cell g5 = getCellByAddress(sheet, "G5");
|
|
|
|
+ g5.setCellValue(lastEndChangeMoneySum.toString());
|
|
|
|
+ //------------------------------------------------------------变更后合同价------------------------------------------------------------
|
|
|
|
+ //签约合同价+本期末累计变更(可能是负数)
|
|
|
|
+ BigDecimal changeMoney = totalMoney.add(lastEndChangeMoneySum);
|
|
|
|
+
|
|
|
|
+ Cell i5 = getCellByAddress(sheet, "I5");
|
|
|
|
+ i5.setCellValue(changeMoney.toString());
|
|
|
|
+ //------------------------------------------------------------上期末累计计量-------------------------------------------------------------
|
|
|
|
+ BigDecimal allMoney = new BigDecimal(0);
|
|
|
|
+ //顺便计算上期末累计支付
|
|
|
|
+ BigDecimal lastEndPay = new BigDecimal(0);
|
|
|
|
+ //顺便计算上期末累计扣取保留金
|
|
|
|
+ BigDecimal lastEndDeduct = new BigDecimal(0);
|
|
|
|
+ String lastEndMeasurement = "";
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Cell a7 = getCellByAddress(sheet, "A7");
|
|
|
|
+ a7.setCellValue(allMoney.toString());
|
|
|
|
+ //---------------------------------------------------------------上期末累计支付---------------------------------------------------------------------------------------------------------
|
|
|
|
+ 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));
|
|
|
|
+ }
|
|
|
|
+ Cell e7 = getCellByAddress(sheet, "E7");
|
|
|
|
+ e7.setCellValue(AllcurrentMeterTotal.toString());
|
|
|
|
+ //------------------------------------------------------------本期末累计计量------------------------------------------------------------
|
|
|
|
+ //上期末+本期
|
|
|
|
+ BigDecimal endMoney = allMoney.add(AllcurrentMeterTotal);
|
|
|
|
+ Cell g7 = getCellByAddress(sheet, "G7");
|
|
|
|
+ g7.setCellValue(endMoney.toString());
|
|
|
|
+ //------------------------------------------------------------本期支付------------------------------------------------------------
|
|
|
|
+ //本期计量 * 0.75
|
|
|
|
+ BigDecimal currentPay = AllcurrentMeterTotal.multiply(new BigDecimal(0.75)).setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ Cell i7 = getCellByAddress(sheet, "I7");
|
|
|
|
+ i7.setCellValue(currentPay.toString());
|
|
|
|
+ //------------------------------------------------------------本期末累计支付------------------------------------------------------------
|
|
|
|
+ //上期末累计支付+本期支付
|
|
|
|
+ BigDecimal endPay = lastEndPay.add(currentPay);
|
|
|
|
+ Cell a9 = getCellByAddress(sheet, "A9");
|
|
|
|
+ a9.setCellValue(endPay.toString());
|
|
|
|
+ //------------------------------------------------------------累计支付百分数%------------------------------------------------------------
|
|
|
|
+ //本期末累计支付/变更后合同价 保留两位小数
|
|
|
|
+ BigDecimal percent = endPay.divide(changeMoney,2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ BigDecimal multiply100 = percent.multiply(new BigDecimal(100));
|
|
|
|
+ Cell c9 = getCellByAddress(sheet, "C9");
|
|
|
|
+ c9.setCellValue(multiply100+"%");
|
|
|
|
+ //------------------------------------------------------------上期末累计扣取保留金------------------------------------------------------------
|
|
|
|
+ Cell e9 = getCellByAddress(sheet, "E9");
|
|
|
|
+ e9.setCellValue(lastEndDeduct.toString());
|
|
|
|
+ //------------------------------------------------------------本期扣取保留金------------------------------------------------------------
|
|
|
|
+ //本期扣取保留金=本期计量 - 本期支付
|
|
|
|
+ BigDecimal deductionMoney = AllcurrentMeterTotal.subtract(currentPay);
|
|
|
|
+ Cell g9 = getCellByAddress(sheet, "G9");
|
|
|
|
+ g9.setCellValue(deductionMoney.toString());
|
|
|
|
+ //------------------------------------------------------------本期末累计扣取保留金------------------------------------------------------------
|
|
|
|
+ //本期末累计扣取保留金=上期末累计扣取保留金+本期累计扣取保留金
|
|
|
|
+ BigDecimal endDeductionMoney = lastEndDeduct.add(deductionMoney);
|
|
|
|
+ Cell i9 = getCellByAddress(sheet, "I9");
|
|
|
|
+ i9.setCellValue(endDeductionMoney.toString());
|
|
|
|
+ //------------------------------------------------------------日期------------------------------------------------------------
|
|
|
|
+ //顶部日期
|
|
|
|
+ Cell g3 = getCellByAddress(sheet, "G3");
|
|
|
|
+ g3.setCellValue(endDate.toString());
|
|
|
|
+ //施工单位申报意见
|
|
|
|
+ Cell j11 = getCellByAddress(sheet, "J11");
|
|
|
|
+ j11.setCellValue(endDate.toString());
|
|
|
|
+ //监理单位审核
|
|
|
|
+ Cell j13 = getCellByAddress(sheet, "J13");
|
|
|
|
+ j13.setCellValue(endDate.toString());
|
|
|
|
+ //业务部门审核意见
|
|
|
|
+ Cell j16 = getCellByAddress(sheet, "J16");
|
|
|
|
+ j16.setCellValue(endDate.toString());
|
|
|
|
+ //财务部门审核意见
|
|
|
|
+ Cell j19 = getCellByAddress(sheet, "J19");
|
|
|
|
+ j19.setCellValue(endDate.toString());
|
|
|
|
+ //分管领导审核意见
|
|
|
|
+ Cell j22 = getCellByAddress(sheet, "J22");
|
|
|
|
+ j22.setCellValue(endDate.toString());
|
|
|
|
+ //主要领导审核意见
|
|
|
|
+ Cell j25 = getCellByAddress(sheet, "J25");
|
|
|
|
+ j25.setCellValue(endDate.toString());
|
|
|
|
+ //------------------------------------------------------------标题------------------------------------------------------------
|
|
|
|
+ CellStyle cellStyle = workbook.createCellStyle();
|
|
|
|
+ cellStyle.setWrapText(false);
|
|
|
|
+ String periodNumber = contractMeterPeriodNow.getPeriodNumber();
|
|
|
|
+ if(ObjectUtil.isNotEmpty(periodNumber)){
|
|
|
|
+ Cell e2 = getCellByAddress(sheet, "E2");
|
|
|
|
+ e2.setCellStyle(cellStyle);
|
|
|
|
+ e2.setCellValue(periodNumber);
|
|
|
|
+ }
|
|
|
|
+ //施工单位
|
|
|
|
+ Cell b3 = getCellByAddress(sheet, "B3");
|
|
|
|
+ b3.setCellValue("重庆交通建设(集团)有限责任公司");
|
|
|
|
+ //---------------------------结果存储redis---------------------------------
|
|
|
|
+ //上期末累计扣取保留金
|
|
|
|
+ redisTemplate.opsForValue().set(MeasurementStorage.PRE_END_RESERVE_MONEY +redisId, lastEndDeduct.toString());
|
|
|
|
+ //本期扣取保留金
|
|
|
|
+ redisTemplate.opsForValue().set(MeasurementStorage.CUR_END_RESERVE_MONEY +redisId, deductionMoney.toString());
|
|
|
|
+ //本期末累计扣取保留金
|
|
|
|
+ redisTemplate.opsForValue().set(MeasurementStorage.CUR_END_RESERVE_MONEY_SUM +redisId, endDeductionMoney.toString());
|
|
|
|
+ //本期计量
|
|
|
|
+ redisTemplate.opsForValue().set(MeasurementStorage.CUR_MEASUREMENT +redisId, AllcurrentMeterTotal.toString());
|
|
|
|
+
|
|
String file_path = FileUtils.getSysLocalFileUrl();
|
|
String file_path = FileUtils.getSysLocalFileUrl();
|
|
- //String file_path = "C://upload1//";
|
|
|
|
String locationFile = file_path + SnowFlakeUtil.getId() + ".xlsx";
|
|
String locationFile = file_path + SnowFlakeUtil.getId() + ".xlsx";
|
|
outputStream = new FileOutputStream(locationFile);
|
|
outputStream = new FileOutputStream(locationFile);
|
|
//生成一份新的excel
|
|
//生成一份新的excel
|
|
@@ -2215,9 +2893,9 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
}
|
|
}
|
|
NewBladeFile bladeFile = this.commonFileClient.excelToPdf(files);
|
|
NewBladeFile bladeFile = this.commonFileClient.excelToPdf(files);
|
|
ReportResult reportResult = new ReportResult();
|
|
ReportResult reportResult = new ReportResult();
|
|
- CompletableFuture<String> stringCompletableFuture = new CompletableFuture<>();
|
|
|
|
- stringCompletableFuture.complete(bladeFile.getLink());
|
|
|
|
- reportResult.setPdfOssPath(stringCompletableFuture);
|
|
|
|
|
|
+ reportResult.setOssPdfUrl(bladeFile.getPdfUrl());
|
|
|
|
+ reportResult.setPdfPath(bladeFile.getPdfUrl());
|
|
|
|
+ reportResult.setName("中间支付审核表");
|
|
return reportResult;
|
|
return reportResult;
|
|
|
|
|
|
}
|
|
}
|