yangyj 3 ヶ月 前
コミット
9560073e0a

+ 2 - 4
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/ExecutionTime.java

@@ -1,14 +1,12 @@
 package org.springblade.manager.vo;
 
-import cn.hutool.json.JSONUtil;
-
 /**
  * @author yangyj
  * @Date 2024/1/23 16:14
  * @description 执行耗时统计
  */
 public class ExecutionTime {
-    public static final String template="耗时:$1\n 总耗时:$2";
+    public static final String TEMPLATE ="耗时:$1\n 总耗时:$2";
     private final Long start;
     private Long last;
     private final StringBuffer summary= new StringBuffer();
@@ -23,7 +21,7 @@ public class ExecutionTime {
         long total=cur-start;
         long part= cur-last;
         last=cur;
-        String s = str+template.replace("$1",String.valueOf(part)).replace("$2",String.valueOf(total));
+        String s = str+ TEMPLATE.replace("$1",String.valueOf(part)).replace("$2",String.valueOf(total));
         summary.append(s).append("\n");
         System.out.println(s);
     }

+ 1 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/MeterInfo.java

@@ -70,6 +70,7 @@ public class MeterInfo {
     private CompletableFuture<List<InventoryForm>> inventoryForms;
     /***/
     private List<InventoryForm> inventoryFormList;
+    private List<MeterApply> meterApplyList;
 
 
     /*章节排序*/

+ 2 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/ReportResult.java

@@ -43,6 +43,8 @@ public class ReportResult {
     private Map<String,Object> commonData =new HashMap<>();
     /**电签信息*/
     private Map<String,String> eSignMap = new HashMap<>();
+    /*定位信息*/
+    private Map<String, String> coordinateMap = new HashMap<>();
     /**合并单元格,格式:{页码@x@y}*/
     private Set<String> mergeCellsSet = new HashSet<>();
     /**删除行号1-3表示1到3行,1,3表示1和3行*/

+ 1 - 0
blade-service/blade-manager/src/main/java/com/mixsmart/utils/FormulaUtils.java

@@ -925,6 +925,7 @@ public class FormulaUtils {
         return result;
     }
 
+
     public static List<ElementData> setScale(Integer scale, List<ElementData> data){
         if(scale==null){
             scale=StringUtils.getScale(data.stream().map(ElementData::getValue).filter(StringUtils::isDouble).collect(Collectors.toList()));

+ 2 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorInit.java

@@ -51,6 +51,7 @@ public class ExecutorInit extends FormulaExecutor {
     private Function<Long, List<InventoryForm>> inventoryFormFc;
     private Function<Long, List<MaterialAdjust>> materialAdjustFc;
     private Function<String, List<InterimPayCertificateItem>> interimPayCertificateItemFc;
+    private Function<Long, List<MeterApply>> meterApplyFc;
 
 
     public static final String SZ="[ 一二三四五六七八九十]+";
@@ -110,6 +111,7 @@ public class ExecutorInit extends FormulaExecutor {
                 materialList=materialList.stream().filter(e->BaseUtils.inChain(periodIds,e.getPeriodId().toString())).collect(Collectors.toList());
                 tec.meterInfo.setMaterialsAll(materialList);
             }
+            tec.meterInfo.setMeterApplyList(meterApplyFc.apply(tec.periodInfo.getId()));
         }
         /*支付项信息*/
         tec.meterInfo.setMidPayItemList(midPayItemListFc.apply(tec.getContractId()));

+ 42 - 15
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorMeter.java

@@ -43,7 +43,7 @@ import java.util.stream.IntStream;
 @EqualsAndHashCode(callSuper = true)
 @Data
 public class ExecutorMeter extends FormulaExecutor {
-    private Function<Long, List<MeterApply>> meterApplyFc;
+    /*private Function<Long, List<MeterApply>> meterApplyFc;*/
     private Function<Long, List<StartPayForm>> stayPayFormFc;
     private Function<String, List<ChapterSchedule>> chapterScheduleFc;
 
@@ -158,7 +158,7 @@ public class ExecutorMeter extends FormulaExecutor {
         return "NULL";
     }
 
-    /*获取章编号*/
+    /**获取章编号*/
     Function<InventoryForm,String> chapterPreFixFc=inventoryForm->{
         if(inventoryForm.getFormName().contains(BTDL)||inventoryForm.getFormNumber().contains(BTDL)){
             return inventoryForm.getChapter()+":"+BTDL;
@@ -166,7 +166,7 @@ public class ExecutorMeter extends FormulaExecutor {
         return inventoryForm.getFormNumber();
     } ;
 
-    /*章节排序*/
+    /**章节排序*/
     ToIntFunction<InventoryForm> toIntFc=itf->{
         String chapter = itf.getChapter();
         if(BaseUtils.isNumber(chapter)){
@@ -2028,18 +2028,45 @@ public class ExecutorMeter extends FormulaExecutor {
             return current.size()>0;
         }
 
+       private Function<Payment,String> chapterPreFixFc=payment -> {
+            String pnb=  payment.getNumber().split("-")[0];
+            if(BaseUtils.isNumber(pnb)){
+                return 100 * (Integer.parseInt(pnb) / 100)+"";
+            }
+            return pnb;
+        };
+
         @Override
         public void parse() {
             builderFormDatas(InterimMeterPaySummary.class);
-            for(Payment payment:current){
-                InterimMeterPaySummary imps = new InterimMeterPaySummary();
-                BeanUtils.copyProperties(payment,imps);
-                imps.setItemName(payment.getName());
-                imps.setFormNumber(payment.getNumber());
-                imps.setCompleted(StringUtils.handleNull(payment.getCompleted()));
-                dataList.add(imps);
-            }
-            if(dataList.size()>0){
+            List<MeterApply> meterApplyList=tec.meterInfo.getMeterApplyList();
+            Map<Long,MeterApply> meterApplyGroup = meterApplyList.stream().collect(Collectors.toMap(MeterApply::getId,m->m,(v1,v2)->v1));
+           LinkedHashMap<String,List<Payment>>  group= current.stream().collect(Collectors.groupingBy(chapterPreFixFc,LinkedHashMap::new,Collectors.toList()));
+           group.forEach((k,v)->{
+               MeterApply meterApply = meterApplyGroup.get(v.get(0).getMiddleMeterId());
+               for(Payment payment:v){
+                   InterimMeterPaySummary imps = new InterimMeterPaySummary();
+                   BeanUtils.copyProperties(payment,imps);
+                   imps.setItemName(payment.getName());
+                   imps.setFormNumber(payment.getNumber());
+                   imps.setCompleted(StringUtils.handleNull(payment.getCompleted()));
+                   dataList.add(imps);
+                   InterimMeterPaySummary part = new InterimMeterPaySummary();
+                   part.setItemName(meterApply.getPartName());
+                   part.setFormNumber(meterApply.getMeterNumber());
+                   dataList.add(part);
+               }
+               int add= capacity-v.size()%capacity-1;
+               if(add>0){
+                   dataList.addAll(Collections.nCopies(add,new InterimMeterPaySummary()));
+               }
+               InterimMeterPaySummary chapter = new InterimMeterPaySummary("章小计");
+               double sum=v.stream().map(Payment::getMoney).filter(StringUtils::isNumber).mapToDouble(Double::parseDouble).sum();
+               chapter.setMoney(StringUtils.number2StringZero(sum,tec.getScale()));
+               dataList.add(chapter);
+               tec.periodInfo.setSummaryNumber(String.valueOf(BaseUtils.sliceNumber(dataList.size(),capacity)));
+           });
+/*            if(dataList.size()>0){
                 int add= capacity-dataList.size()%capacity-1;
                 for(int i=0;i<add;i++){
                     dataList.add(new InterimMeterPaySummary());
@@ -2049,7 +2076,7 @@ public class ExecutorMeter extends FormulaExecutor {
                 summary.setMoney(StringUtils.number2StringZero(sum,tec.getScale()));
                 dataList.add(summary);
                 tec.periodInfo.setSummaryNumber(String.valueOf(BaseUtils.sliceNumber(dataList.size(),capacity)));
-            }
+            }*/
             putOut(InterimMeterPaySummary.class);
         }
     }
@@ -2080,7 +2107,7 @@ public class ExecutorMeter extends FormulaExecutor {
         @Override
         public void parse() {
             builderFormDatas(InterimMeter.class);
-            List<MeterApply> meterApplyList=meterApplyFc.apply(tec.getPeriodId());
+            List<MeterApply> meterApplyList=tec.meterInfo.getMeterApplyList();
             paymentGroup = current.stream().collect(Collectors.groupingBy(Payment::getMiddleMeterId));
             LinkedHashMap<String,List<MeterApply>> meterApplyGroup = meterApplyList.stream().filter(e-> paymentGroup.containsKey(e.getId())).collect(Collectors.groupingBy(e->chapterNumberFc.apply(e,paymentGroup),LinkedHashMap::new,Collectors.toList()));
             /*删除没有计量的章节,返回需要显示的章节*/
@@ -2197,7 +2224,7 @@ public class ExecutorMeter extends FormulaExecutor {
         @Override
         public void parse() {
             builderFormDatas(InterimMeter.class);
-            List<MeterApply> meterApplyList=meterApplyFc.apply(tec.getPeriodId());
+            List<MeterApply> meterApplyList=tec.meterInfo.getMeterApplyList();
             Map<Long,List<Payment>> paymentGroup = current.stream().collect(Collectors.groupingBy(Payment::getMiddleMeterId));
             for(MeterApply meterApply:meterApplyList){
                 List<Payment> paymentList = paymentGroup.get(meterApply.getId());

+ 1 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/TableElementConverter.java

@@ -490,6 +490,7 @@ public class TableElementConverter implements ITableElementConverter {
                    rt.setUrl(report.getHtmlUrl());
                    rt.setInitTableName(report.getInitTableName());
                    rt.setESignMap(eSignMaps.get(report.getInitTableName()));
+                   rt.setCoordinateMap(coordinateMap.get(report.getInitTableName()));
                    rt.setName(report.getNodeName());
                    rt.setExcelId(report.getExcelId());
                    if(mergeCellMaps.containsKey(rt.getInitTableName())){

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

@@ -48,6 +48,7 @@ import org.springblade.common.constant.CommonConstant;
 import org.springblade.common.utils.BaseUtils;
 import org.springblade.common.utils.CommonUtil;
 import org.springblade.common.utils.SnowFlakeUtil;
+import org.springblade.common.utils.SystemUtils;
 import org.springblade.common.vo.DataVO;
 import org.springblade.core.boot.ctrl.BladeController;
 import org.springblade.core.log.exception.ServiceException;
@@ -65,6 +66,7 @@ import org.springblade.evisa.vo.SigInfoVO;
 import org.springblade.feign.ArchiveFileTaskClient;
 import org.springblade.manager.entity.*;
 import org.springblade.manager.feign.*;
+import org.springblade.manager.vo.ExecutionTime;
 import org.springblade.manager.vo.ReportMergeCellsConfig;
 import org.springblade.manager.vo.ReportResult;
 import org.springblade.meter.config.MyJdbcTemplate;
@@ -3555,9 +3557,12 @@ public class TaskController extends BladeController {
         /*数据完全独立互不影响,可以并发生成,预估PDF的总大小来决定是否全部在内存中生成PDF*/
         /*分为新增和更新*/
         /*如果数据没有变化,则各表的PDF可以不用更新*/
+        ExecutionTime executionTime = new ExecutionTime();
         List<ReportResult> reportResults = formulaClient.formulaExecute3(report.getContractId(), report.getId(), report.getType());
+        executionTime.info("公式执行");
         String fileUrl = null;
         if (Func.isNotEmpty(reportResults)) {
+            CompletableFuture<Map<Long ,List<DqTime>>> dqTimeMap=getDqTime(reportResults.stream().map(s->s.getPkeyId().toString()).collect(Collectors.joining(",")), report.getContractId(), report.getPeriodId());
             /*List<String> dataListPdf = new ArrayList<>();*/
             String file_path = CollectionUtils.getSysLocalFileUrl();
             Map<String, Object> projectMap = jdbcTemplate.queryForMap("select b.project_name projectName from m_contract_info a  join  m_project_info b on a.p_id=b.id where a.id= " + report.getContractId());
@@ -3576,6 +3581,7 @@ public class TaskController extends BladeController {
                     rawDataMap.put("C",rs.getCommonData());
                     rawDataMap.put("D",rs.getData());
                     rawListMap.put(rs.getInitTableName(),rawDataMap);
+                    /*动态隐藏行*/
                     if (rs.getInitTableName().equals("m_20240325154016_1772166597482381312")||rs.getInitTableName().equals("m_20240710170847_1810964374177710080")) {
                         List<Map.Entry<String,Object>> entries=rs.getData().get(0).entrySet().stream().filter(e->Integer.parseInt(e.getKey().split("_")[1])==1).sorted(Comparator.comparingInt(e->Integer.parseInt(e.getKey().split("_")[0]))).collect(Collectors.toList());
                         List<String> list =entries.stream().map(e->e.getValue().toString()).collect(Collectors.toList());
@@ -3623,6 +3629,16 @@ public class TaskController extends BladeController {
                         doc.open();
                         /* String tile = rs.getName().contains("封面") ? projectName : projectName + StringPool.DASH + rs.getName();*/
                         String title = rs.createTitle(projectName);
+                        // 添加签字时间
+                        List<DqTime> dqTimes= dqTimeMap.get().get(rs.getPkeyId());
+                        if(dqTimes!=null&&dqTimes.size()>0){
+                             Map<String,Object> commonData= rs.getCommonData();
+                             Map<String,String> coordsMap=rs.getCoordinateMap();
+                             dqTimes.forEach(s->{
+                                 String coords = coordsMap.get(s.getColKey().split("__")[0]);
+                                 commonData.put(coords,s.getCreateTime());
+                             });
+                        }
                         /*把公共部分内容释放到每一页*/
                         rs.putCommon();
                         /*合并单元格的配置信息*/
@@ -3636,7 +3652,7 @@ public class TaskController extends BladeController {
                                 Sheet sheet = workbook.getSheetAt(0);
                                 sheet.setForceFormulaRecalculation(true);
                                 // 添加签字时间
-                                dataMap = setDQTimeInfo(dataMap,rs.getPkeyId(),report.getContractId(),report.getPeriodId(),rs.getUrl());
+                               /* dataMap = setDQTimeInfo(dataMap, rs.getPkeyId(), report.getContractId(), report.getPeriodId(), rs.getUrl());*/
                                 if (Func.isNotEmpty(dataMap)) {
                                     for (String keys : dataMap.keySet()) {
                                         int y1 = Func.toInt(keys.split("_")[0]);
@@ -3924,6 +3940,29 @@ public class TaskController extends BladeController {
             StaticLog.error(e.getMessage());
         }
     }
+
+
+    @Data
+    public static class DqTime{
+        private Long pkeyId;
+        private String colKey;
+        private String createTime;
+        public DqTime() {
+        }
+    }
+
+    public CompletableFuture<Map<Long ,List<DqTime>>> getDqTime(String pkeyIds,Long contractId,Long perId){
+      return   CompletableFuture.supplyAsync(() -> {
+            String timeSql = "SELECT DISTINCT a.time_col_key colKey,DATE_FORMAT(c.create_time, '%Y年%m月%d日')as create_time ,a.tab_id pkeyId from m_textdict_info a ,m_project_assignment_user b,u_task_parallel c ,u_task d  where a.sig_role_id=b.role_id and b.user_id=c.task_user and c.process_instance_id=d.process_instance_id and  b.contract_id="+contractId+" and LENGTH(a.time_col_key)>=2 " +
+                    "and d.form_data_id="+perId+" and a.tab_id in ("+pkeyIds+")";
+            List<DqTime> dqTimeList= jdbcTemplate.query(timeSql, new BeanPropertyRowMapper<>(DqTime.class));
+            if(dqTimeList.size()>0){
+                return  dqTimeList.stream().collect(Collectors.groupingBy(DqTime::getPkeyId));
+            }
+            return new HashMap<>();
+        });
+    }
+
     // 添加签字时间
     public Map<String, Object> setDQTimeInfo(Map<String, Object> dataMap, Long pkeyId,Long contractId,Long perId,String htmlUrl) {
         String timeSql = "SELECT DISTINCT a.time_col_key,DATE_FORMAT(c.create_time, '%Y年%m月%d日') as create_time from m_textdict_info a ,m_project_assignment_user b,u_task_parallel c ,u_task d  where a.sig_role_id=b.role_id and b.user_id=c.task_user and c.process_instance_id=d.process_instance_id and  b.contract_id="+contractId+" and LENGTH(a.time_col_key)>=2 " +