Explorar el Código

万盛计量日志适应所有万盛计量模板项目

DengLinLang hace 8 meses
padre
commit
747276db86

+ 5 - 5
blade-service/blade-business/src/main/java/org/springblade/business/controller/UserViewProjectContractController.java

@@ -103,13 +103,13 @@ public class UserViewProjectContractController {
                 if(ObjectUtil.isNotEmpty(wide) && ObjectUtil.isNotEmpty(high)){
                     int w = cmToPx(wide);
                     int h = cmToPx(high);
-                    /*BigDecimal wideBigDecimal = new BigDecimal(wide);
-                    BigDecimal highBigDecimal = new BigDecimal(high);
+                    BigDecimal wideBigDecimal = new BigDecimal(w);
+                    BigDecimal highBigDecimal = new BigDecimal(h);
                     //分别乘以1.29 保留两位小数
                     BigDecimal wideDecima = wideBigDecimal.multiply(new BigDecimal(1.29)).setScale(2, BigDecimal.ROUND_HALF_UP);
-                    BigDecimal highDecima = highBigDecimal.multiply(new BigDecimal(1.29)).setScale(2, BigDecimal.ROUND_HALF_UP);*/
-                    wide = Integer.valueOf(w).doubleValue();
-                    high = Integer.valueOf(h).doubleValue();
+                    BigDecimal highDecima = highBigDecimal.multiply(new BigDecimal(1.29)).setScale(2, BigDecimal.ROUND_HALF_UP);
+                    wide = wideDecima.doubleValue();
+                    high = highDecima.doubleValue();
                 }else {
                     //获取图片本身大小 设置默认值
                     URL url = new URL(signatureFileUrl);

+ 139 - 41
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java

@@ -26,7 +26,6 @@ import org.jsoup.select.Elements;
 import org.springblade.common.constant.MeasurementStorage;
 import org.springblade.common.utils.BaseUtils;
 import org.springblade.common.utils.CommonUtil;
-import org.springblade.manager.utils.PeriodContractUtil;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.mp.base.BaseEntity;
 import org.springblade.core.mp.base.BaseServiceImpl;
@@ -48,6 +47,7 @@ import org.springblade.manager.mapper.WbsTreePrivateMapper;
 import org.springblade.manager.service.*;
 import org.springblade.manager.utils.AmountToChineseConverter;
 import org.springblade.manager.utils.FileUtils;
+import org.springblade.manager.utils.PeriodContractUtil;
 import org.springblade.manager.vo.*;
 import org.springblade.meter.entity.*;
 import org.springblade.meter.feign.CertificateItemClient;
@@ -55,8 +55,6 @@ import org.springblade.meter.feign.CollectionUtilsClient;
 import org.springblade.meter.feign.IContractInventoryFormClient;
 import org.springblade.meter.feign.MiddleMeterApplyClient;
 import org.springblade.meter.vo.*;
-import org.springblade.meter.vo.MeterInventoryDetailVO;
-import org.springblade.meter.vo.MeterInventoryVO1;
 import org.springblade.resource.feign.CommonFileClient;
 import org.springblade.resource.feign.NewIOSSClient;
 import org.springblade.resource.vo.NewBladeFile;
@@ -2181,21 +2179,39 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         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));
 
+        //获取所有excel报表源数据
+        String sqlForExcel = "SELECT id,file_url from m_excel_tab where parent_id =1780876295486361601 and is_deleted = 0";
+        List<ExcelTab> excelTabs = jdbcTemplate.query(sqlForExcel, new BeanPropertyRowMapper<>(ExcelTab.class));
+
         ArrayList<ReportResult> reportResults = new ArrayList<>();
         //中期支付报表封面
-        String url = "https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20240828/3ee50ef54005c95bd724bcabae54058c.XLSX";
+        Optional<ExcelTab> excel = excelTabs.stream().filter(e -> e.getId().toString().equals("1780876698961629186")).findFirst();
+        //String url = "https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20240828/3ee50ef54005c95bd724bcabae54058c.XLSX";
+        String url = excel.get().getFileUrl();
         //中间支付审核表
-        String url1 = "https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20241120/ea6c945827dd2990a9c7b1957fe201c4.XLSX";
+        Optional<ExcelTab> excel1 = excelTabs.stream().filter(e -> e.getId().toString().equals("1780876742800494593")).findFirst();
+        //String url1 = "https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20241120/ea6c945827dd2990a9c7b1957fe201c4.XLSX";
+        String url1 = excel1.get().getFileUrl();
         //补助款申请支付审核表
-        String url2 = "https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20241120/970eec0eb3cf3d215263a0e2f24c142e.xlsx";
+        Optional<ExcelTab> excel2 = excelTabs.stream().filter(e -> e.getId().toString().equals("1780876780238852097")).findFirst();
+        //String url2 = "https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20241120/970eec0eb3cf3d215263a0e2f24c142e.xlsx";
+        String url2 = excel2.get().getFileUrl();
         //中间计量支付证书
-        String url3 = "https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20240828/fb1110ae6aab7295759775206e5b44b8.XLSX";
+        Optional<ExcelTab> excel3 = excelTabs.stream().filter(e -> e.getId().toString().equals("1780876814359515138")).findFirst();
+        //String url3 = "https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20240828/fb1110ae6aab7295759775206e5b44b8.XLSX";
+        String url3 = excel3.get().getFileUrl();
         //中间计量支付申请表
-        String url4="https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20240828/bff82dd0a1b7394f5fdab1322a3e6023.XLSX";
+        Optional<ExcelTab> excel4 = excelTabs.stream().filter(e -> e.getId().toString().equals("1780876859939016705")).findFirst();
+        //String url4="https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20240828/bff82dd0a1b7394f5fdab1322a3e6023.XLSX";
+        String url4=excel4.get().getFileUrl();
         //工程支付月报
-        String url5="https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20240903/c8a5b424eace6c26b2edf9b9b33f088a.XLSX";
+        Optional<ExcelTab> excel5 = excelTabs.stream().filter(e -> e.getId().toString().equals("1780876896593039362")).findFirst();
+        //String url5="https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20240903/c8a5b424eace6c26b2edf9b9b33f088a.XLSX";
+        String url5=excel5.get().getFileUrl();
         //清单支付报表
-        String url6="https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20241120/e168f024c8055362664a276ad3721cb7.XLSX";
+        Optional<ExcelTab> excel6 = excelTabs.stream().filter(e -> e.getId().toString().equals("1780876940398350338")).findFirst();
+        //String url6="https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20241120/e168f024c8055362664a276ad3721cb7.XLSX";
+        String url6=excel6.get().getFileUrl();
         // 获取中期支付报表封面的pdfurl
         ReportResult CoverOfMidtermPaymentReportPDF = getCoverOfMidtermPaymentReportPDF(url,contractId,periodId);
         //获取中间支付审核表的pdfurl
@@ -2204,7 +2220,6 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         ReportResult subsidyApplicationPaymentReviewPDF = getSubsidyApplicationPaymentReviewPDF(url2,contractId,periodId,list);
         //获取中间计量支付证书pdfUrl
         ReportResult intermediateMeasurementPaymentCertificatePDF = getIntermediateMeasurementPaymentCertificatePDF(url3,contractId,periodId,list);
-
         //获取清单支付报表PDF
         ReportResult inventoryPayReportPDF=getInventoryPayReportPDF(url6,contractId,periodId,projectId,list,redisId);
         //获取工程支付月报pdfUrl
@@ -2227,6 +2242,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
      * 中期支付报表封面
      */
     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));
@@ -2247,16 +2263,25 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
             Sheet sheet = workbook.getSheetAt(0);
             //期号
             String periodNumber = contractMeterPeriodNow.getPeriodNumber();
-            if (ObjectUtil.isNotEmpty(periodNumber)){
-                Cell d4 = getCellByAddress(sheet, "D4");
-                d4.setCellValue(periodNumber);
+            if(ObjectUtil.isNotEmpty(periodNumber) && periodNumber.contains("第")){
+                int i = periodNumber.indexOf("第");
+                periodNumber = periodNumber.substring(i+1,i+2);
+
+            }
+            Cell d4 = getCellByAddress(sheet, "D4");
+            d4.setCellValue(periodNumber);
+
+
+            if(ObjectUtil.isNotEmpty(contractId)){
+                //获取合同段信息
+                ContractInfo contractInfo = getContractInfo(contractId);
+                //施工单位
+                Cell c9 = getCellByAddress(sheet, "C9");
+                c9.setCellValue(contractInfo.getConstructionUnitName());
+                //监理单位
+                Cell c10 = getCellByAddress(sheet, "C10");
+                c10.setCellValue(contractInfo.getContractorUnitName());
             }
-            //施工单位
-            Cell c9 = getCellByAddress(sheet, "C9");
-            c9.setCellValue("重庆交通建设(集团)有限责任公司");
-            //监理单位
-            Cell c10 = getCellByAddress(sheet, "C10");
-            c10.setCellValue("重庆市交通工程监理咨询有限责任公司");
             //日期
             Cell c11 = getCellByAddress(sheet, "C11");
             c11.setCellValue(endDate.toString());
@@ -2293,6 +2318,13 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         return reportResult;
     }
 
+
+    private ContractInfo getContractInfo(Long contractId) {
+        String sqlForContractSectionById = "SELECT id,p_id,contract_number,contractor_unit_name,construction_unit_name,supervision_unit_name FROM m_contract_info WHERE is_deleted = 0 and id='"+ contractId+"'";
+        ContractInfo contractInfo = jdbcTemplate.queryForObject(sqlForContractSectionById, new BeanPropertyRowMapper<>(ContractInfo.class));
+        return contractInfo;
+    }
+
     /**
      *中间计量支付证书获取PDFurl
      */
@@ -2367,9 +2399,13 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
             /*Cell f25 = getCellByAddress(sheet, "F25");
             f25.setCellValue(endDate.toString());*/
             //工程名称
-            Cell c3 = getCellByAddress(sheet, "C3");
-            c3.setCellValue("S104金桥至万盛城区段升级改造工程一期(田顶至滩子口段)");
-
+            if (ObjectUtil.isNotEmpty(contractId)){
+                ContractInfo contractInfo = getContractInfo(contractId);
+                String pId = contractInfo.getPId();
+                String projectName = getProjectName(pId);
+                Cell c3 = getCellByAddress(sheet, "C3");
+                c3.setCellValue(projectName);
+            }
             for (Sheet sheet1 : workbook) {
                 for (Row row : sheet1) {
                     // 遍历所有单元格
@@ -2403,6 +2439,12 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         return reportResult;
     }
 
+    private String getProjectName(String pId) {
+        String sqlForProjectName = "SELECT project_name FROM m_project_info WHERE id = '"+ pId +"'";
+        ProjectInfo projectInfo = jdbcTemplate.queryForObject(sqlForProjectName, new BeanPropertyRowMapper<>(ProjectInfo.class));
+        return projectInfo.getProjectName();
+    }
+
     /**
      *补助款申请支付审核表获取PDFurl
      */
@@ -2565,14 +2607,19 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
             m27.setCellValue(endDate.toString());*/
             //***************************************************************标题*************************************************************************
             String periodNumber = contractMeterPeriodNow.getPeriodNumber();
-            if(ObjectUtil.isNotEmpty(periodNumber)){
-                Cell e3 = getCellByAddress(sheet, "E3");
-                e3.setCellValue(periodNumber);
+            if(ObjectUtil.isNotEmpty(periodNumber) && periodNumber.contains("第")){
+                int i = periodNumber.indexOf("第");
+                periodNumber = periodNumber.substring(i+1,i+2);
             }
-            //填报单位
-            Cell d4 = getCellByAddress(sheet, "D4");
-            d4.setCellValue("重庆市万盛经济开发区交通建设事务中心");
+            Cell e3 = getCellByAddress(sheet, "E3");
+            e3.setCellValue(periodNumber);
 
+            if(ObjectUtil.isNotEmpty(contractId)){
+                ContractInfo contractInfo = getContractInfo(contractId);
+                //填报单位
+                Cell d4 = getCellByAddress(sheet, "D4");
+                d4.setCellValue(contractInfo.getContractorUnitName());
+            }
             for (Sheet sheet1 : workbook) {
                 for (Row row : sheet1) {
                     // 遍历所有单元格
@@ -2783,14 +2830,21 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
             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("重庆交通建设(集团)有限责任公司");
+            if(ObjectUtil.isNotEmpty(periodNumber) && periodNumber.contains("第")){
+                int i = periodNumber.indexOf("第");
+                periodNumber = periodNumber.substring(i+1,i+2);
+            }
+            Cell e2 = getCellByAddress(sheet, "E2");
+            //e2.setCellStyle(cellStyle);
+            e2.setCellValue(periodNumber);
+
+            if(ObjectUtil.isNotEmpty(contractId)){
+                ContractInfo contractInfo = getContractInfo(contractId);
+                //施工单位
+                Cell b3 = getCellByAddress(sheet, "B3");
+                b3.setCellValue(contractInfo.getConstructionUnitName());
+            }
+
             for (Sheet sheet1 : workbook) {
                 for (Row row : sheet1) {
                     // 遍历所有单元格
@@ -2934,8 +2988,9 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
     public ReportResult getIntermediateApplyPDF(String url,Long periodId,Long projectId){
         String projectName = null;
         try {
-            String sql="Select project_name from m_project_info where id="+projectId;
-            projectName = jdbcTemplate.queryForObject(sql, String.class);
+            String sql="Select project_name from m_project_info where id='"+projectId+"'";
+            ProjectInfo projectInfo = jdbcTemplate.queryForObject(sql,new BeanPropertyRowMapper<>(ProjectInfo.class));
+            projectName = projectInfo.getProjectName();
         } catch (DataAccessException e) {
             projectName=null;
         }
@@ -2949,8 +3004,8 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
             modInput = CommonUtil.getOSSInputStream(url);
             workbook = WorkbookFactory.create(modInput);
             Sheet sheet = workbook.getSheetAt(0);
-            Cell d=getCellByAddress(sheet,"D5");
-            d.setCellValue(projectName);
+            Cell c3=getCellByAddress(sheet,"C3");
+            c3.setCellValue(projectName);
             //根据坐标获取单元格
             Cell c = getCellByAddress(sheet, "E6");
             //本期计量
@@ -3007,6 +3062,11 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
      * @return
      */
     public ReportResult getMonthlyReportPDF(String url, Long reportId,Long contractId, Long periodId, Long projectId,List<ContractMeterPeriod> list,Long redisId) throws IllegalAccessException {
+        //获取本期计量期
+        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));
+        LocalDate endDate = contractMeterPeriodNow.getEndDate();
+
         String sql="SELECT id from s_contract_inventory_form where contract_id="+contractId+" and parent_id=0";
         Long id = jdbcTemplate.queryForObject(sql, Long.class);
         InventoryFormDetailVO detail = iContractInventoryFormClient.detail(id);
@@ -3261,6 +3321,27 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                                     }
                                 }
                             }
+
+            if(ObjectUtil.isNotEmpty(contractId)){
+                ContractInfo contractInfo = getContractInfo(contractId);
+                String projectName = getProjectName(contractInfo.getPId());
+                //项目名称
+                Cell b3 = getCellByAddress(sheet, "B3");
+                b3.setCellValue(projectName);
+                //合同号
+                Cell b4 = getCellByAddress(sheet, "B4");
+                b4.setCellValue(contractInfo.getContractNumber());
+                //承包单位
+                Cell g3 = getCellByAddress(sheet, "G3");
+                g3.setCellValue(contractInfo.getConstructionUnitName());
+                //监理单位
+                Cell g4 = getCellByAddress(sheet, "G4");
+                g4.setCellValue(contractInfo.getSupervisionUnitName());
+                //截至时间
+                Cell m_3 = getCellByAddress(sheet, "M3");
+                m_3.setCellValue(endDate.toString());
+
+            }
             String file_path = FileUtils.getSysLocalFileUrl();
             String locationFile = file_path + SnowFlakeUtil.getId() + ".xlsx";
             outputStream = new FileOutputStream(locationFile);
@@ -3543,6 +3624,23 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                                 q23.setCellValue(totalNowMoney.toString());
                                 Cell s23=getCellByAddress(sheet,"S23");
                                 s23.setCellValue(totalNowEndMoney.toString());
+                                if(ObjectUtil.isNotEmpty(contractId)){
+                                    ContractInfo contractInfo = getContractInfo(contractId);
+                                    String projectName = getProjectName(contractInfo.getPId());
+                                    //项目名称
+                                    Cell b3=getCellByAddress(sheet,"B3");
+                                    b3.setCellValue(projectName);
+                                    //合同号
+                                    Cell b4=getCellByAddress(sheet,"B4");
+                                    b4.setCellValue(contractInfo.getContractNumber());
+                                    //承包单位
+                                    Cell l3=getCellByAddress(sheet,"L3");
+                                    l3.setCellValue(contractInfo.getConstructionUnitName());
+                                    //监理单位
+                                    Cell l4=getCellByAddress(sheet,"L4");
+                                    l4.setCellValue(contractInfo.getSupervisionUnitName());
+                                }
+
                         String file_path = FileUtils.getSysLocalFileUrl();
                         String locationFile = file_path + SnowFlakeUtil.getId() + ".xlsx";
                         outputStream = new FileOutputStream(locationFile);

+ 20 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/TaskController.java

@@ -3671,7 +3671,12 @@ public class TaskController extends BladeController {
         /*如果数据没有变化,则各表的PDF可以不用更新*/
         ExecutionTime executionTime = new ExecutionTime();
         List<ReportResult> reportResults;
-        if(ObjectUtil.isNotEmpty(report.getProjectId())&&report.getProjectId().equals(1764484458576179201L)){
+        //查询出当前项目使用的计量模板是否是万盛计量模板
+        boolean judge = false;
+        if(ObjectUtil.isNotEmpty(report.getProjectId())){
+            judge = isWanShengTemplate(report.getProjectId());
+        }
+        if(judge){
              reportResults=formulaClient.formulaExecute4(report.getId(),report.getContractId(),report.getPeriodId(),report.getType(),report.getProjectId());
             /*合并所有表*/
             String file_path = CollectionUtils.getSysLocalFileUrl();
@@ -3941,6 +3946,20 @@ public class TaskController extends BladeController {
         return R.data(fileUrl);
     }
 
+    private boolean isWanShengTemplate(Long projectId) {
+        String sql = "select id,reference_wbs_template_id_meter from m_project_info where id = "+projectId;
+        ProjectInfo projectInfo = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(ProjectInfo.class));
+        if(ObjectUtil.isNotEmpty(projectInfo) && ObjectUtil.isNotEmpty(projectInfo.getReferenceWbsTemplateIdMeter())){
+            if(projectInfo.getReferenceWbsTemplateIdMeter().toString().equals("1781150898360209410")){
+                return true;
+            }else {
+                return false;
+            }
+        }else{
+            return false;
+        }
+    }
+
     public void deleteRows(Sheet sheet, int startRow, int endRow) {
         for (int i = startRow; i <= endRow; i++) {
             int lastRowNum = sheet.getLastRowNum();