|
@@ -44,6 +44,7 @@ import org.springblade.manager.mapper.WbsTreePrivateMapper;
|
|
|
import org.springblade.manager.service.*;
|
|
|
import org.springblade.manager.utils.FileUtils;
|
|
|
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;
|
|
@@ -68,6 +69,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
import java.io.*;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
@@ -2299,6 +2301,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
return reportResult;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 清单支付报表获取PDF CR3
|
|
|
* @param url
|
|
@@ -2340,10 +2343,184 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //清单支付报表对象
|
|
|
- MeterInventoryVO1 vo=new MeterInventoryVO1();
|
|
|
+ List<MeterInventoryVO1>list1=new ArrayList<>();
|
|
|
+ String sql="SELECT * FROM s_contract_inventory_form WHERE project_id="+projectId+" and contract_id="+contractId+" and is_deleted=0";
|
|
|
+ //合同清单的对应明细
|
|
|
+ List<ContractInventoryForm> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ContractInventoryForm.class));
|
|
|
+ for (MeterInventoryDetailVO detailVO : formDetail) {
|
|
|
+ //清单支付报表对象
|
|
|
+ MeterInventoryVO1 vo=new MeterInventoryVO1();
|
|
|
+ for (ContractInventoryForm form : query) {
|
|
|
+ if(ObjectUtil.isNotEmpty(form.getFormNumber())&&detailVO.getFormNumber().equals(form.getFormNumber())){
|
|
|
+ //原合同工程量
|
|
|
+ vo.setCurrentMeterTotal(form.getContractTotal());
|
|
|
+ //原合同单价
|
|
|
+ vo.setCurrentMeterPrice(form.getBidPrice());
|
|
|
+ //原合同金额
|
|
|
+ vo.setCurrentMeterMoney(form.getContractMoney());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ vo.setId(detailVO.getId());
|
|
|
+ vo.setFormNumber(detailVO.getFormNumber());
|
|
|
+ vo.setFormName(detailVO.getFormName());
|
|
|
+ //变更后工程量
|
|
|
+ vo.setAfterCurrentTotal(detailVO.getChangeTotal());
|
|
|
+ //变更后金额 变更后工程量*单价
|
|
|
+ vo.setAfterCurrentMeterMoney(vo.getAfterCurrentTotal().multiply(detailVO.getCurrentPrice()));
|
|
|
+ //工程变更工程量 变更后工程量-原合同工程量
|
|
|
+ BigDecimal subtract = vo.getAfterCurrentTotal().subtract(vo.getCurrentMeterTotal());
|
|
|
+ if(subtract==BigDecimal.ZERO){
|
|
|
+ subtract=null;
|
|
|
+ }
|
|
|
+ vo.setChangeTotal(subtract);
|
|
|
+ //工程变更金额 变更后金额-原合同金额
|
|
|
+ BigDecimal subtract1 = vo.getAfterCurrentMeterMoney().subtract(vo.getCurrentMeterMoney());
|
|
|
+ if(subtract1==BigDecimal.ZERO){
|
|
|
+ subtract1=null;
|
|
|
+ }
|
|
|
+ vo.setChangeMeterMoney(subtract1);
|
|
|
+ //工程变更单价
|
|
|
+ if(vo.getChangeMeterMoney()==null&&vo.getChangeTotal()==null){
|
|
|
+ vo.setChangeMeterPrice(null);
|
|
|
+ }else {
|
|
|
+ vo.setChangeMeterPrice(detailVO.getCurrentPrice());
|
|
|
+ }
|
|
|
+ //本期完成工程量
|
|
|
+ vo.setNowTotal(detailVO.getCurrentMeterTotal());
|
|
|
+ //本期完成金额
|
|
|
+ vo.setNowMoney(detailVO.getAllMeterMoney());
|
|
|
+ //大于0表示有上期的 需要添加上期末数据
|
|
|
+ if(changeFormDetail.size()>0){
|
|
|
+ for (MeterInventoryDetailVO changevo : changeFormDetail) {
|
|
|
+ if(changevo.getFormNumber().equals(vo.getFormNumber())){
|
|
|
+ //到上期末完成工程量
|
|
|
+ vo.setBeforeEndTotal(changevo.getAllMeterTotal());
|
|
|
+ //到上期末完成金额
|
|
|
+ vo.setBeforeEndMoney(changevo.getAllMeterMoney());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //到本期末完成工程量
|
|
|
+ if(vo.getBeforeEndTotal()!=null){
|
|
|
+ vo.setNowEndTotal(vo.getBeforeEndTotal().add(vo.getNowTotal()));
|
|
|
+ }else {
|
|
|
+ vo.setNowEndTotal(vo.getNowTotal());
|
|
|
+ }
|
|
|
+ //到本期末完成金额
|
|
|
+ if(vo.getBeforeEndMoney()!=null){
|
|
|
+ vo.setNowEndMoney(vo.getBeforeEndMoney().add(vo.getNowMoney()));
|
|
|
+ }else {
|
|
|
+ vo.setNowEndMoney(vo.getNowMoney());
|
|
|
+ }
|
|
|
+ list1.add(vo);
|
|
|
+ }
|
|
|
+ if(list1.size()>0){
|
|
|
+ //先根据根据前三个字符排序
|
|
|
+ list1.sort(Comparator.comparingInt(MeterInventoryVO1::getFirstThreeCharsAsInt));
|
|
|
+ //根据编号的第一个字符,分类
|
|
|
+ Map<Character, List<MeterInventoryVO1>> groupedMeter = new HashMap<>();
|
|
|
+ for (MeterInventoryVO1 vo1 : list1) {
|
|
|
+ char firstChar = vo1.getFormNumber().charAt(0);
|
|
|
+ groupedMeter.computeIfAbsent(firstChar, k -> new ArrayList<>()).add(vo1);
|
|
|
+ }
|
|
|
+ //根据编号的不同建立不同的excel
|
|
|
+ for (Map.Entry<Character, List<MeterInventoryVO1>> listEntry : groupedMeter.entrySet()) {
|
|
|
+ List<MeterInventoryVO1> value = listEntry.getValue();
|
|
|
+ //编号来划分
|
|
|
+ for (int i = 0; i < value.size(); i+=16) {
|
|
|
+ int endIndex = Math.min(i + 16, list.size());
|
|
|
+ List<MeterInventoryVO1> subList = value.subList(i, endIndex);
|
|
|
+ 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);
|
|
|
+ // 起始行号
|
|
|
+ int startRow = 8;
|
|
|
+ int endRow = 23;
|
|
|
+ for (int ii = 0; ii < subList.size() && startRow <= endRow; ii++, startRow++) {
|
|
|
+ Row row = sheet.createRow(startRow - 1); // 行号从0开始
|
|
|
+ MeterInventoryVO1 obj = subList.get(ii);
|
|
|
+ for (int j = 0; j < 17; j++) {
|
|
|
+ Cell cell = row.createCell(j);
|
|
|
+ String attributeValue = getAttributeValue(obj, j);
|
|
|
+ if(StringUtil.isNotBlank(attributeValue)){
|
|
|
+ cell.setCellValue(attributeValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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();
|
|
|
+ CompletableFuture<String> stringCompletableFuture = new CompletableFuture<>();
|
|
|
+ stringCompletableFuture.complete(bladeFile.getLink());
|
|
|
+ reportResult.setPdfOssPath(stringCompletableFuture);
|
|
|
+ return reportResult;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
return null;
|
|
|
}
|
|
|
+ private static String getAttributeValue(MeterInventoryVO1 obj, int index) {
|
|
|
+ switch (index) {
|
|
|
+ case 0:
|
|
|
+ return obj.getFormNumber();
|
|
|
+ case 1:
|
|
|
+ return obj.getFormName();
|
|
|
+ case 2:
|
|
|
+ return obj.getUnit();
|
|
|
+ case 3:
|
|
|
+ return obj.getCurrentMeterTotal().toString();
|
|
|
+ case 4:
|
|
|
+ return obj.getCurrentMeterPrice().toString();
|
|
|
+ case 5:
|
|
|
+ return obj.getCurrentMeterMoney().toString();
|
|
|
+ case 6:
|
|
|
+ return obj.getChangeTotal().toString();
|
|
|
+ case 7:
|
|
|
+ return obj.getChangeMeterPrice().toString();
|
|
|
+ case 8:
|
|
|
+ return obj.getChangeMeterMoney().toString();
|
|
|
+ case 9:
|
|
|
+ return obj.getAfterCurrentTotal().toString();
|
|
|
+ case 10:
|
|
|
+ return obj.getAfterCurrentMeterMoney().toString();
|
|
|
+ case 11:
|
|
|
+ return obj.getBeforeEndTotal().toString();
|
|
|
+ case 12:
|
|
|
+ return obj.getBeforeEndMoney().toString();
|
|
|
+ case 13:
|
|
|
+ return obj.getNowTotal().toString();
|
|
|
+ case 14:
|
|
|
+ return obj.getNowMoney().toString();
|
|
|
+ case 15:
|
|
|
+ return obj.getNowEndTotal().toString();
|
|
|
+ case 16:
|
|
|
+ return obj.getNowEndMoney().toString();
|
|
|
+ default:
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//根据单元格地址获取单元格对象
|
|
|
private static Cell getCellByAddress(Sheet sheet, String cellAddress) {
|
|
|
CellReference cellRef = new CellReference(cellAddress);
|