瀏覽代碼

Merge branch 'master' of http://39.108.216.210:3000/zhuwei/bladex

huangtf 6 月之前
父節點
當前提交
6d55a1feb5
共有 28 個文件被更改,包括 722 次插入50 次删除
  1. 5 3
      blade-ops/blade-resource/src/main/java/org/springblade/resource/builder/oss/OssBuilder.java
  2. 3 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/CustomAddContractNodeDTO.java
  3. 36 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/ScrSignInfoVO.java
  4. 5 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/dto/MeterApprovalDTO.java
  5. 0 2
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ChangeTokenForm.java
  6. 3 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/TaskDetailVO.java
  7. 11 1
      blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java
  8. 1 1
      blade-service/blade-business/src/main/java/org/springblade/business/controller/TaskController.java
  9. 2 0
      blade-service/blade-business/src/main/java/org/springblade/business/mapper/ContractLogMapper.xml
  10. 7 4
      blade-service/blade-business/src/main/java/org/springblade/business/mapper/EntrustInfoMapper.xml
  11. 1 1
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/controller/EVController.java
  12. 0 2
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/controller/EVisaController.java
  13. 82 0
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/controller/ScrController.java
  14. 12 0
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/service/ScrDataService.java
  15. 171 0
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/service/impl/ScrDataServiceImpl.java
  16. 1 3
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/utils/PDFUtils.java
  17. 9 2
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/utils/PdfAddimgUtil.java
  18. 128 0
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/utils/PdfSignatureInfo.java
  19. 1 0
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/utils/SignFtpUtil.java
  20. 109 16
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java
  21. 3 1
      blade-service/blade-manager/src/main/java/org/springblade/manager/feign/WbsTreeContractClientImpl.java
  22. 11 2
      blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorInit.java
  23. 2 2
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaDaoImpl.java
  24. 18 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/utils/FileUtils.java
  25. 61 9
      blade-service/blade-meter/src/main/java/org/springblade/meter/controller/TaskController.java
  26. 1 1
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/MiddleMeterApplyMapper.xml
  27. 4 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/MiddleMeterApplyTaskMapper.java
  28. 35 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/MiddleMeterApplyTaskMapper.xml

+ 5 - 3
blade-ops/blade-resource/src/main/java/org/springblade/resource/builder/oss/OssBuilder.java

@@ -19,6 +19,7 @@ package org.springblade.resource.builder.oss;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import org.springblade.common.constant.CommonConstant;
 import org.springblade.core.cache.utils.CacheUtil;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.oss.enums.OssEnum;
@@ -33,6 +34,7 @@ import org.springblade.core.tool.utils.WebUtil;
 import org.springblade.resource.builder.ossre.OssTemplateRe;
 import org.springblade.resource.entity.Oss;
 import org.springblade.resource.service.IOssService;
+import org.springblade.system.cache.ParamCache;
 
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
@@ -84,9 +86,9 @@ public class OssBuilder {
     public OssTemplateRe template(String code) {
         String tenantId = AuthUtil.getTenantId();
         Oss oss = getOss(tenantId, code);
-        oss.setEndpoint("http://183.247.216.148:9000/");
-       // oss.setEndpoint("https://oss-cn-shenzhen.aliyuncs.com/");
-        System.out.println("3333333"+oss.getEndpoint());
+     //   oss.setEndpoint("http://183.247.216.148:9000/");
+        oss.setEndpoint("https://oss-cn-shenzhen.aliyuncs.com/");
+
         Oss ossCached = ossPool.get(tenantId);
         OssTemplateRe template = templatePool.get(tenantId);
         // 若为空或者不一致,则重新加载

+ 3 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/CustomAddContractNodeDTO.java

@@ -42,4 +42,7 @@ public class CustomAddContractNodeDTO implements Serializable {
     @ApiModelProperty(value = "自定义数字化节点的时间")
     private String digitizeTime;
 
+    @ApiModelProperty(value = "自定义数字化节点的内页资料类型")
+    private Integer majorDataType;
+
 }

+ 36 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/ScrSignInfoVO.java

@@ -0,0 +1,36 @@
+package org.springblade.business.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+
+@Data
+public class ScrSignInfoVO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "主键信息")
+    @TableId(value = "id", type = IdType.ASSIGN_ID)
+    private Long id;
+
+    @ApiModelProperty("待审批列表中对应的taskId字段值")
+    private String eVisaPdfUrl;
+
+    @ApiModelProperty("合同段Id")
+    private String contractId;
+
+    @ApiModelProperty("项目ID")
+    private String projectId;
+
+    @ApiModelProperty("流程节点Id")
+    private String processInstanceId;
+
+}

+ 5 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/dto/MeterApprovalDTO.java

@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 
 @Data
 public class MeterApprovalDTO implements Serializable {
@@ -41,4 +42,8 @@ public class MeterApprovalDTO implements Serializable {
     @ApiModelProperty("是否生成审计意见单 1是0否")
     private Integer isBuildAudit;
 
+    @ApiModelProperty("施工单位送审金额")
+    private BigDecimal submitApprovalMoney;
+
+
 }

+ 0 - 2
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ChangeTokenForm.java

@@ -130,6 +130,4 @@ public class ChangeTokenForm extends BaseEntity {
     @ApiModelProperty(value = "下达日期")
     private LocalDateTime commandDate;
 
-
-
 }

+ 3 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/TaskDetailVO.java

@@ -23,6 +23,9 @@ public class TaskDetailVO implements Serializable {
     @ApiModelProperty(value = "上报总金额")
     private BigDecimal reportAllMoney;
 
+    @ApiModelProperty(value = "施工单位送审金额")
+    private BigDecimal submitApprovalMoney;
+
     @ApiModelProperty(value = "本期审核进度款")
     private BigDecimal progressMoney;
 

+ 11 - 1
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -2696,7 +2696,7 @@ public class InformationWriteQueryController extends BladeController {
     public R<Boolean> updateContractNodeParameter(@RequestParam Long pKeyId, @RequestParam String
         nodeName, @RequestParam String partitionCode, @RequestParam(required = false) Integer className,
                                                   @RequestParam(required = false) Integer unitName, @RequestParam(required = false) Integer excellentNum,
-                                                  @RequestParam(required = false) Integer unitNum,@RequestParam(required = false)String digitizeTime) {
+                                                  @RequestParam(required = false) Integer unitNum,@RequestParam(required = false)String digitizeTime,@RequestParam(required =false)Integer majorDataType) {
         WbsTreeContract node = new WbsTreeContract();
         node.setPKeyId(pKeyId);
         node.setNodeName(nodeName);
@@ -2742,6 +2742,11 @@ public class InformationWriteQueryController extends BladeController {
                 node.setUnitNum(unitNum);
             }
         }
+        if(ObjectUtil.isNotEmpty(queries.getNodeClass())&&queries.getNodeClass()==Integer.valueOf(2)){
+            if(majorDataType!=null&&majorDataType!=0){
+                node.setMajorDataType(majorDataType);
+            }
+        }
         //保存操作记录
         try {
             JSONObject json = new JSONObject();
@@ -4066,7 +4071,12 @@ public class InformationWriteQueryController extends BladeController {
                 if (ObjectUtil.isEmpty(dto.getDigitizeTime())) {
                     throw new ServiceException("请选择节点时间");
                 }
+                if(dto.getMajorDataType()==null||dto.getMajorDataType().equals("0")){
+                    throw new ServiceException("请选择内页资料类型");
+                }
                 obj.setDigitizeTime(dto.getDigitizeTime());
+                obj.setMajorDataType(dto.getMajorDataType());
+
             }
                 if (wbsTreeContractClient.saveBatch(Collections.singletonList(obj))) {
                     informationQueryService.delAsyncWbsTree(parentNode.getContractId());

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

@@ -1237,7 +1237,7 @@ public class TaskController extends BladeController {
         int size = dto.getSize();
         //封装入参SQL
         List<Object> params = new ArrayList<>();
-        StringBuilder sqlString = new StringBuilder("SELECT * FROM u_task WHERE 1=1 AND is_deleted = 0 AND approval_type not in(4,5)");
+        StringBuilder sqlString = new StringBuilder("SELECT * FROM u_task WHERE 1=1 AND is_deleted = 0 AND approval_type in(1,2,3,4,8)");
         if (ObjectUtil.isNotEmpty(dto.getTypeValue())) {
             sqlString.append(" AND type = ?");
             params.add(dto.getTypeValue());

+ 2 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/ContractLogMapper.xml

@@ -84,6 +84,8 @@
         from u_contract_log
         where is_deleted = 0
           and wbs_node_id = #{vo.wbsNodeId}
+          and contract_id = #{vo.contractId}
+          and pdf_url is not null
     </select>
 
     <select id="constructionLogPage" resultMap="contractLogVoResultMap">

+ 7 - 4
blade-service/blade-business/src/main/java/org/springblade/business/mapper/EntrustInfoMapper.xml

@@ -134,18 +134,21 @@
 
 
     <select id="selectDataInfoPage" resultType="org.springblade.business.vo.LoadDataInfoVO">
-        select * from u_view_gather_data_info a where 1=1
-
+        SELECT  * FROM (
+            select * from u_view_gather_data_info
+            union all
+        select * from u_view_gather_data_info2
+        ) a where 1=1
         <if test="param2.testTypeName != null and param2.testTypeName != ''">
             AND a.testTypeName like CONCAT(CONCAT('%', #{param2.testTypeName}), '%')
         </if>
 
        <if test="param2.startTime != null and param2.startTime != '' ">
-            and a.playTime &gt;= #{param2.startTime}
+            and a.testDate &gt;= #{param2.startTime}
         </if>
 
         <if test="param2.endTime != null and param2.endTime != '' ">
-            and a.playTime &lt;= #{param2.endTime}
+            and a.testDate &lt;= #{param2.endTime}
         </if>
         order by testDate desc;
 

+ 1 - 1
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/controller/EVController.java

@@ -56,7 +56,7 @@ public class EVController {
     @Resource(name = "taskExecutor1")
     private ThreadPoolExecutor executor;
 
-     @Scheduled(cron = "0/10 * * * * ?")
+    //@Scheduled(cron = "0/10 * * * * ?")
     public void SignInfo() {
         //执行代码
         log.info("扫描开始");

+ 0 - 2
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/controller/EVisaController.java

@@ -9,14 +9,12 @@ import org.apache.commons.lang.StringUtils;
 import org.springblade.business.entity.Task;
 import org.springblade.business.feign.TaskClient;
 import org.springblade.business.vo.TaskApprovalVO;
-import org.springblade.common.utils.CommonUtil;
 import org.springblade.common.utils.SystemUtils;
 import org.springblade.evisa.service.EVisaService;
 import org.springblade.evisa.vo.EVisaTaskApprovalVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;

+ 82 - 0
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/controller/ScrController.java

@@ -0,0 +1,82 @@
+package org.springblade.evisa.controller;
+
+import com.alibaba.fastjson.JSON;
+import io.swagger.annotations.Api;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springblade.business.vo.ScrSignInfoVO;
+import org.springblade.business.vo.TaskSignInfoVO;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.evisa.service.EVDataService;
+import org.springblade.evisa.service.ScrDataService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 清表基础数据表 控制器
+ *
+ * @author BladeX
+ * @since 2022-05-18
+ */
+@RestController
+@AllArgsConstructor
+@Api(value = "电签类", tags = "电签类接口")
+@Slf4j
+public class ScrController {
+
+    @Autowired
+    StringRedisTemplate RedisTemplate;
+    // jdbc
+    private final JdbcTemplate jdbcTemplate;
+    //电签服务类
+    private final ScrDataService scrDataService;
+    // 线程池
+    @Resource(name = "taskExecutor1")
+    private ThreadPoolExecutor executor;
+
+    @Scheduled(cron = "0/10 * * * * ?")
+    public void SignInfo() {
+        //执行代码
+
+        // 质检SQL
+        //String sql = "SELECT a.id as ,a.e_visa_pdf_url,b.process_instance_id,a.contract_id,a.project_id from u_information_query a ,u_task b  where a.id=1848624592908722177 and a.`status` in(1,2) and a.is_deleted=0 and a.e_visa_pdf_url is not null  and b.form_data_id = a.id and b.`status` in(1,2) ";
+        String sql = "SELECT a.id ,a.e_visa_pdf_url,b.process_instance_id,a.contract_id,a.project_id  from u_information_query a ,u_task b  where a.id=1848624592908722177 and a.`status` in(1,2) and a.is_deleted=0 and a.e_visa_pdf_url is not null  and b.form_data_id = a.id and b.`status` in(1,2) ";
+
+        List<ScrSignInfoVO> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ScrSignInfoVO.class));
+        if (query != null && query.size() >= 1 ) {
+            for (ScrSignInfoVO dataInfo : query) {
+                if (executor.getQueue().size()<=6 ) {
+                    Long nodeId = dataInfo.getId();
+                    Boolean aBoolean = RedisTemplate.hasKey("sign-" + nodeId);
+
+                    if (!aBoolean) {
+                        RedisTemplate.opsForValue().set("sign-" + nodeId, "1",1800, TimeUnit.SECONDS);
+                        CompletableFuture<Void> runAsync = CompletableFuture.runAsync(() -> {
+                            try {
+                                /*===============执行批量任务===============*/
+                                scrDataService.sctTaskBatch(dataInfo);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            }
+                        }, executor);
+                    }
+                }
+            }
+        }
+        System.out.println("队列数量" + executor.getQueue().size());
+        System.out.println("活跃数量" + executor.getActiveCount());
+        System.out.println("总共数量" + executor.getTaskCount());
+        System.out.println("完成数量" + executor.getCompletedTaskCount());
+    }
+}

+ 12 - 0
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/service/ScrDataService.java

@@ -0,0 +1,12 @@
+package org.springblade.evisa.service;
+
+import org.springblade.business.vo.ScrSignInfoVO;
+import org.springblade.business.vo.TaskSignInfoVO;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+public interface ScrDataService {
+
+   void sctTaskBatch(ScrSignInfoVO taskApp) throws IOException, Exception;
+}

+ 171 - 0
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/service/impl/ScrDataServiceImpl.java

@@ -0,0 +1,171 @@
+package org.springblade.evisa.service.impl;
+
+import lombok.AllArgsConstructor;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.PDPage;
+import org.apache.pdfbox.pdmodel.common.PDRectangle;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget;
+import org.springblade.business.vo.ScrSignInfoVO;
+import org.springblade.common.utils.CommonUtil;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.evisa.service.ScrDataService;
+import org.springblade.evisa.utils.PdfAddimgUtil;
+import org.springblade.manager.vo.PDFIndexInfo;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Service;
+import java.io.*;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Service
+@AllArgsConstructor
+public class ScrDataServiceImpl implements ScrDataService {
+
+    private final JdbcTemplate jdbcTemplate;
+
+    // 主流程
+    @Override
+    public void sctTaskBatch(ScrSignInfoVO taskApp) throws Exception {
+        // 电签检查
+
+
+
+
+    }
+
+    /**
+     * 电签检查
+     */
+    public void sctTaskBatch2(ScrSignInfoVO taskApp) throws Exception {
+        int threshold = 5;
+
+        String fileUrl = CommonUtil.replaceOssUrl(taskApp.getEVisaPdfUrl());
+        String pdfUrl = taskApp.getEVisaPdfUrl();
+        InputStream inputStream = CommonUtil.getOSSInputStream(fileUrl);
+        InputStream inputStream2 = CommonUtil.getOSSInputStream(fileUrl);
+        //转换
+        byte[] pdfData = CommonUtil.InputStreamToBytes(inputStream);
+
+        PDDocument document = PDDocument.load(inputStream2);
+        List<String> positions = PdfAddimgUtil.getPdfSignIds(pdfUrl);
+
+        List<String> sucess = new ArrayList<>();
+        String ids = String.join(",", positions);
+        List<Map<String, Object>> strategyListByDFZX = getStrategyListByDFZX(taskApp,ids);
+
+        positions = strategyListByDFZX.stream().map(map -> map.get("keyWord").toString()).collect(Collectors.toList());
+        String keyWord = String.join(",", positions);
+        List<PDFIndexInfo> pdfIndexInfo = PdfAddimgUtil.findKeywordPostions(pdfData, keyWord);
+
+        //根据id分组
+        List<Map<String, Object>> list2 = strategyListByDFZX.stream().collect(
+                Collectors.collectingAndThen(
+                        Collectors.toCollection(
+                                () ->new TreeSet<>(Comparator.comparing(m->m.get("keyWord").toString()))
+                        ),ArrayList::new
+                )
+        );
+
+        Map<String, List<Map<String, Object>>> newMap = list2.stream().collect(Collectors.groupingBy(b -> Func.toStr(b.get("keyWord"))));
+
+        Map<String, List<PDFIndexInfo>> groupBy = pdfIndexInfo.stream().collect(Collectors.groupingBy(da -> Func.toStr(da.getDataInfo()[0])));
+
+        for (int i = 0; i < document.getPages().getCount(); i++) {
+            PDPage page = document.getPage(i);
+            List<PDAnnotation> annotations = page.getAnnotations();
+            for (PDAnnotation annotation : annotations) {
+                if (annotation instanceof PDAnnotationWidget) {
+                    PDRectangle rect = annotation.getRectangle();
+
+                    float imgW = rect.getWidth();
+                    float imgH = rect.getHeight();
+                    float imgX = rect.getLowerLeftX() + imgW / 2;
+                    float imgY = rect.getLowerLeftY() + imgH / 2;
+                    List<PDFIndexInfo> pdfIndexInfos = groupBy.get((i + 1) + ".0");
+
+                    for (PDFIndexInfo pdfInfo : pdfIndexInfos) {
+                        String pkeyid = pdfInfo.getPkeyid();
+
+                        float[] dataInfo = pdfInfo.getDataInfo();
+
+                        float keyX = dataInfo[1];
+                        float keyY = dataInfo[2];
+
+                        float pageHeight = page.getMediaBox().getHeight();
+                        float pageWidth = page.getMediaBox().getWidth();
+
+                        float keyw = keyX * pageWidth;
+                        float keyh = pageHeight - keyY * pageHeight;
+
+                        List<Map<String, Object>> mapList = newMap.get(pkeyid);
+                        if(mapList!=null && mapList.size()>=0){
+                            Map<String, Object> map = mapList.get(0);
+                            Float pyzbx = Func.toFloat(map.get("pyzbx"));
+                            Float pyzby = Func.toFloat(map.get("pyzby"));
+                            keyw = keyw + pyzbx;
+                            keyh = keyh + pyzby;
+                        }
+
+                        if (Math.abs(imgX - keyw) <= threshold && Math.abs(imgY - keyh) <= threshold) {
+                            sucess.add(pkeyid);
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+
+        Set<String> differentElements = new HashSet<>(positions);
+        // 使用retainAll方法来移除两个集合中相同的元素,留下不同的元素
+        differentElements.removeAll(sucess);
+
+        System.out.println("总共:"+positions.size()+"-剩下-"+differentElements.size());
+    }
+
+
+    // 添加电签策略 -- 东方中讯
+    public List<Map<String, Object>> getStrategyListByDFZX(ScrSignInfoVO taskApp,String ids) {
+        List<Map<String, Object>> maps = new ArrayList<>();
+        List<Map<String, Object>> maps2 = new ArrayList<>();
+        String sql = "select * from u_task_parallel where process_instance_id = '" + taskApp.getProcessInstanceId() + "' and initiative=2 and status=2";
+        List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
+        if(mapList!=null && mapList.size()>0){
+            for(Map<String, Object> task : mapList){
+                String taskUserId = Func.toStr(task.get("task_user"));
+                String sqlinfo = " SELECT * from ( SELECT a.id as keyWord,a.project_id,a.pyzbx ,a.pyzby,(SELECT acc_code from blade_user where id='" + taskUserId + "' and is_deleted=0  ) as sealId from m_textdict_info a where  a.type =2 and a.id in (" + ids + ")  and sig_role_id in (SELECT DISTINCT c.role_id from m_project_assignment_user c  where c.contract_id=" + taskApp.getContractId() + " and user_id=" + taskUserId + " and c.is_deleted=0 ) ) x where x.sealId is not null ";
+                List<Map<String, Object>> maps3 = jdbcTemplate.queryForList(sqlinfo);
+                maps2.addAll(maps3);
+            }
+        }
+        // 添加章
+        String sqlinfo = "SELECT a.id as keyWord,a.pyzbx,a.pyzby,b.certificate_number as sealId from m_textdict_info a ,m_sign_pfx_file b where a.sig_role_id = b.pfx_type and b.project_contract_role like '%" + taskApp.getContractId() + "%' and a.is_deleted=0 and b.is_deleted=0 and a.type=6 and a.id in(" + ids + ")";
+        List<Map<String, Object>> maps3 = jdbcTemplate.queryForList(sqlinfo);
+        if(mapList!=null && mapList.size()>0){
+            maps2.addAll(maps3);
+        }
+
+        Map<String, List<Map<String, Object>>> peopleByAge = maps2.stream()
+                .collect(Collectors.groupingBy(hada -> (Func.toStr(hada.get("keyWord")))));
+        for (String keyId : peopleByAge.keySet()) {
+            int exId = 0;
+            List<Map<String, Object>> keyList = peopleByAge.get(keyId);
+            if (keyList != null && keyList.size() == 1) {
+                maps.addAll(keyList);
+                exId = 1;
+            } else if (keyList != null && keyList.size() >= 2) {
+                for (Map<String, Object> datax : keyList) {
+                    if ((datax.get("project_id") + "").equals(taskApp.getProjectId())) {
+                        maps.add(datax);
+                        exId = 1;
+                    }
+                }
+            }
+            if (exId == 0) {
+                maps.add(keyList.get(0));
+            }
+        }
+        return maps;
+    }
+
+}

+ 1 - 3
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/utils/PDFUtils.java

@@ -71,6 +71,7 @@ public class PDFUtils {
         }
     }
 
+
     public static List<String>  getPdfSignIds(String pdfUrl) {
         List<String> eVisaConfigList = new ArrayList<>();
         try  {
@@ -84,9 +85,6 @@ public class PDFUtils {
                 if(textStr.indexOf("*")>=0){
                     textStr = textStr.substring(textStr.lastIndexOf("*")+1,textStr.length());
                 }
-                if(textStr.indexOf("1867379428376444928")>=0){
-                    System.out.println("");
-                }
 
                 String[] textS = Func.toStrArray("\\|\\|",textStr);
                 for(String txt : textS){

+ 9 - 2
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/utils/PdfAddimgUtil.java

@@ -11,6 +11,7 @@ import org.apache.pdfbox.text.PDFTextStripper;
 import org.springblade.common.constant.CommonConstant;
 import org.springblade.common.utils.CommonUtil;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.ResourceUtil;
 import org.springblade.manager.vo.PDFIndexInfo;
 import org.springblade.system.cache.ParamCache;
 
@@ -171,6 +172,7 @@ public class PdfAddimgUtil {
         return result;
     }
 
+
     /**
      * findKeywordPostions
      *
@@ -256,6 +258,7 @@ public class PdfAddimgUtil {
                 if (positionIndex == -1) {
                     break;
                 }
+
                 float[] postions = charPositions.get(positionIndex);
                 data.setDataInfo(postions);
                 data.setPkeyid(text);
@@ -388,8 +391,13 @@ public class PdfAddimgUtil {
 
     public static List<String>  getPdfSignIds(String pdfUrl) {
         List<String> eVisaConfigList = new ArrayList<>();
+        InputStream inputStream;
         try  {
-            InputStream inputStream = CommonUtil.getOSSInputStream(pdfUrl);
+            if(pdfUrl.indexOf("http")>=0){
+                inputStream = CommonUtil.getOSSInputStream(pdfUrl);
+            }else{
+                inputStream = new FileInputStream(new File(pdfUrl));
+            }
             PDDocument document = PDDocument.load(inputStream);
             PDFTextStripper stripper = new PDFTextStripper();
             String text = stripper.getText(document);
@@ -407,7 +415,6 @@ public class PdfAddimgUtil {
                         }
                     }
                     if (txt.length() >= 15 && Func.isNumeric(txt)) {
-                        System.out.println(txt);
                         eVisaConfigList.add(txt);
                     }
                 }

+ 128 - 0
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/utils/PdfSignatureInfo.java

@@ -0,0 +1,128 @@
+package org.springblade.evisa.utils;
+
+import io.lettuce.core.ScriptOutputType;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.PDPage;
+import org.apache.pdfbox.pdmodel.common.PDRectangle;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget;
+import org.springblade.common.utils.CommonUtil;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.manager.vo.PDFIndexInfo;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.*;
+import java.util.stream.Collectors;
+
+public class PdfSignatureInfo{
+
+
+
+
+    //
+    public static void main(String[] args) throws IOException {
+        String pdfUrl = "/Users/hongchuangyanfa/Downloads/727dd864f9569e802692294f9b8fbb97.pdf";
+        PDDocument document = PDDocument.load(new File(pdfUrl));
+        for (int i=0 ;i<document.getPages().getCount();i++) {
+            PDPage page = document.getPage(i);
+            List<PDAnnotation> annotations = page.getAnnotations();
+            for (PDAnnotation annotation : annotations) {
+                if (annotation instanceof PDAnnotationWidget) {
+                    PDRectangle rect = annotation.getRectangle();
+
+                    float imgW = rect.getWidth();
+                    float imgH = rect.getHeight();
+                    float imgX = rect.getLowerLeftX() + imgW / 2;
+                    float imgY = rect.getLowerLeftY() + imgH / 2;
+
+                    System.out.println("imgX:"+imgX+"--imgY:"+imgY+"--imgW:"+imgW+"--imgH:"+imgH);
+                }
+            }
+        }
+
+        String ids = "1847105950746411008";
+        byte[] pdfData = CommonUtil.InputStreamToBytes(new FileInputStream(new File(pdfUrl)));
+        List<PDFIndexInfo> pdfIndexInfo = PdfAddimgUtil.findKeywordPostions(pdfData, ids);
+        for (PDFIndexInfo pdfInfo : pdfIndexInfo) {
+            String pkeyid = pdfInfo.getPkeyid();
+            float[] dataInfo = pdfInfo.getDataInfo();
+
+            float keyX = dataInfo[1];
+            float keyY = dataInfo[2];
+            PDPage page = document.getPage(0);
+            float pageHeight = page.getMediaBox().getHeight();
+            float pageWidth = page.getMediaBox().getWidth();
+
+            float keyw = keyX * pageWidth + (-15);
+            float keyh = pageHeight - keyY * pageHeight + 36;
+            System.out.println("pkeyid:"+pkeyid+"--keyw:"+keyw+"--keyh:"+keyh);
+        }
+    }
+
+
+
+    public static void main2(String[] args) throws Exception {
+        String pdfUrl = "/Users/hongchuangyanfa/Downloads/277af927eb766a06186397d46fd9c4ce.pdf";
+        //阈值
+        int threshold = 5 ;
+        File file = new File(pdfUrl);
+        FileInputStream inputStream = new FileInputStream(file);
+        //转换
+        byte[] pdfData = CommonUtil.InputStreamToBytes(new FileInputStream(new File(pdfUrl)));
+
+        PDDocument document = PDDocument.load(new File(pdfUrl));
+        List<String> positions = PdfAddimgUtil.getPdfSignIds(pdfUrl);
+
+        List<String> sucess = new ArrayList<>();
+        String ids = String.join(",", positions);
+        List<PDFIndexInfo> pdfIndexInfo = PdfAddimgUtil.findKeywordPostions(pdfData, ids);
+
+        Map<String, List<PDFIndexInfo>> groupBy = pdfIndexInfo.stream().collect(Collectors.groupingBy(da -> Func.toStr(da.getDataInfo()[0])));
+
+        for (int i=0 ;i<document.getPages().getCount();i++) {
+            PDPage page = document.getPage(i);
+            List<PDAnnotation> annotations = page.getAnnotations();
+            for (PDAnnotation annotation : annotations) {
+                if (annotation instanceof PDAnnotationWidget) {
+                    PDRectangle rect = annotation.getRectangle();
+
+                    float imgW = rect.getWidth();
+                    float imgH = rect.getHeight();
+                    float imgX = rect.getLowerLeftX() + imgW/2;
+                    float imgY = rect.getLowerLeftY() + imgH/2;
+                    List<PDFIndexInfo> pdfIndexInfos = groupBy.get((i+1)+".0");
+
+                    for (PDFIndexInfo pdfInfo : pdfIndexInfos) {
+                        String pkeyid = pdfInfo.getPkeyid();
+                        System.out.println(pkeyid);
+                        float[] dataInfo = pdfInfo.getDataInfo();
+
+                        float keyX = dataInfo[1];
+                        float keyY = dataInfo[2];
+
+                        float pageHeight = page.getMediaBox().getHeight();
+                        float pageWidth = page.getMediaBox().getWidth();
+
+                        float keyw = keyX * pageWidth;
+                        float keyh = pageHeight - keyY * pageHeight;
+
+
+                        if(Math.abs(imgX - keyw) <= threshold && Math.abs(imgY - keyh) <= threshold ){
+                            System.out.println(imgX+"--"+imgY +"--"+keyw+"--"+keyh);
+                            sucess.add(pkeyid);
+                        }
+                    }
+                }
+            }
+        }
+
+        Set<String> differentElements = new HashSet<>(positions);
+        // 使用retainAll方法来移除两个集合中相同的元素,留下不同的元素
+        differentElements.removeAll(sucess);
+
+        System.out.println(differentElements.size());
+    }
+
+}

+ 1 - 0
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/utils/SignFtpUtil.java

@@ -37,6 +37,7 @@ public class SignFtpUtil {
             if("20".equals(sys_isonline) || SystemUtils.isWindows() || SystemUtils.isMacOs()){
                 SERVER = "47.115.117.246";
             }
+            System.out.println("ftp上传ip地址:"+SERVER);
             ftp.connect(SERVER, PORT);
             ftp.setControlEncoding("UTF-8");
             ftp.enterLocalPassiveMode();

+ 109 - 16
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java

@@ -72,6 +72,7 @@ import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -1820,7 +1821,7 @@ public class ExcelTabController extends BladeController {
             @ApiImplicitParam(name = "classify", value = "填报的类型(施工或监理)", required = true),
             @ApiImplicitParam(name = "contractId", value = "合同段Id", required = true)
     })
-    public R getPdfS(String nodeId, String classify, String contractId) throws FileNotFoundException {
+    public R getPdfS(String nodeId, String classify, String contractId) throws IOException {
         String file_path = FileUtils.getSysLocalFileUrl();
         String sys_isonline = ParamCache.getValue(CommonConstant.SYS_ISONLINE);
         Boolean aBoolean = RedisTemplate.hasKey("pdf-" + nodeId + "-" + classify);
@@ -1887,15 +1888,25 @@ public class ExcelTabController extends BladeController {
                     }
                     FileUtils.mergePdfPublicMethods(datainfo, listPdf);
                     String netUrl = "";
-                    if(sys_isonline.equals("20")){
                         BladeFile bladeFile = this.newIOSSClient.uploadFile(nodeId + ".pdf", listPdf);
                         if (bladeFile != null && ObjectUtils.isNotEmpty(bladeFile.getLink())) {
                             netUrl = bladeFile.getLink();
                         }
-                    }else{
-                        netUrl = FileUtils.getNetUrl(listPdf);
+                    //数字化节点附件处理
+                    String sqll="SELECT * FROM m_wbs_tree_contract WHERE p_key_id="+nodeId;
+                    WbsTreeContract wbsTreeContract = jdbcTemplate.queryForObject(sqll, new BeanPropertyRowMapper<>(WbsTreeContract.class));
+                    if(ObjectUtil.isNotEmpty(wbsTreeContract.getNodeClass())&&wbsTreeContract.getNodeClass().equals(2)){
+                        InformationQuery iq= informationQueryClient.getInfoByWbsId(wbsTreeContract.getPKeyId());
+                        if(iq.getNodePdfUrl()==null||iq.getEVisaPdfPage()==null||iq.getEVisaPdfPage()==0||iq.getEVisaPdfSize()==null||!iq.getNodePdfUrl().equals(netUrl)){
+                            String pdfPage = FileUtils.getPdfNum(netUrl);
+                            if(pdfPage!=null&&pdfPage.equals("")){
+                                pdfPage="0";
+                            }
+                            Long  pdfSize = CommonUtil.getResourceLength(netUrl);
+                            String sql1="update u_information_query set node_pdf_url='"+netUrl+"',e_visa_pdf_page="+pdfPage+" ,e_visa_pdf_size="+pdfSize+" where classify='" + classify + "' and wbs_id='" + nodeId + "' and contract_id='" + contractId + "'";
+                            jdbcTemplate.execute(sql1);
+                        }
                     }
-                    jdbcTemplate.execute(" update  u_information_query set node_pdf_url='"+netUrl+"' where classify='" + classify + "' and wbs_id='" + nodeId + "' and contract_id='" + contractId + "'");
                     return R.data(netUrl);
                 } else {
                     jdbcTemplate.execute(" update  u_information_query set node_pdf_url='"+pdfUrl+"' where classify='" + classify + "' and wbs_id='" + nodeId + "' and contract_id='" + contractId + "'");
@@ -2443,18 +2454,26 @@ public class ExcelTabController extends BladeController {
                                         String textainfo = element.text();
                                         if(textainfo ==null || textainfo == "" || Func.isEmpty(textainfo)){
                                             int x1, y1;
-                                            if (element.html().indexOf("el-tooltip") >= 0) {
-                                                x1 = Integer.parseInt(element.children().get(0).children().get(0).attr("x1"));
-                                                y1 = Integer.parseInt(element.children().get(0).children().get(0).attr("y1"));
-                                            } else {
-                                                x1 = Integer.parseInt(element.children().get(0).attr("x1"));
-                                                y1 = Integer.parseInt(element.children().get(0).attr("y1"));
-                                            }
-                                            if (x1 == 0) {
-                                                x1 = 1;
+                                            if (element.html().indexOf("x1")>=0 && element.html().indexOf("y1")>=0) {
+                                                if (element.html().indexOf("el-tooltip") >= 0) {
+                                                    x1 = Integer.parseInt(element.children().get(0).children().get(0).attr("x1"));
+                                                    y1 = Integer.parseInt(element.children().get(0).children().get(0).attr("y1"));
+                                                } else {
+                                                    Elements children = element.children();
+                                                    if (children.size() >= 1) {
+                                                        x1 = Integer.parseInt(element.children().get(0).attr("x1"));
+                                                        y1 = Integer.parseInt(element.children().get(0).attr("y1"));
+                                                    } else {
+                                                        x1 = Integer.parseInt(element.attr("x1"));
+                                                        y1 = Integer.parseInt(element.attr("y1"));
+                                                    }
+                                                }
+                                                if (x1 == 0) {
+                                                    x1 = 1;
+                                                }
+                                                final CellRange cellRange = sheet.getCellRange(y1, x1);
+                                                cellRange.setText(projectInfo.getProjectName());
                                             }
-                                            final CellRange cellRange = sheet.getCellRange(y1, x1);
-                                            cellRange.setText(projectInfo.getProjectName());
                                             break;
                                         }
                                     }
@@ -4106,6 +4125,51 @@ public class ExcelTabController extends BladeController {
         }
     }
 
+    //手动处理数字化节点pdf地址,evisaPage,evIsaSize
+    //@Scheduled(fixedDelay = 10000000)
+    public void checkNodeFile() throws IOException {
+        String sql="SELECT * from m_table_file WHERE tab_id IN (SELECT p_key_id FROM m_wbs_tree_contract WHERE node_class=2 AND is_deleted=0)";
+        String sql1="SELECT * from u_information_query where wbs_id IN (SELECT p_key_id FROM m_wbs_tree_contract WHERE node_class=2 AND is_deleted=0)";
+        List<TableFile> tableFiles = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TableFile.class));
+        List<InformationQuery> querys = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(InformationQuery.class));
+
+        Map<String, List<TableFile>> tableFileMap = tableFiles.stream().collect(Collectors.groupingBy(TableFile::getTabId));
+        for (InformationQuery query : querys) {
+            if(query.getNodePdfUrl()==null||query.getEVisaPdfPage()==null||query.getEVisaPdfPage().equals(0)||query.getEVisaPdfSize()==null){
+                List<TableFile> tableFiles1 = tableFileMap.get(query.getWbsId()+"");
+                if(tableFiles1==null){
+                    continue;
+                }
+                if(!tableFiles1.isEmpty()){
+                    List<String> datainfo = new ArrayList<>();
+                    for (TableFile tableFile : tableFiles1) {
+                        datainfo.add(tableFile.getDomainPdfUrl());
+                    }
+                    String file_path = FileUtils.getSysLocalFileUrl();
+                    String listPdf = file_path + "/nodePDF/" + query.getWbsId() + ".pdf";
+                    File tabpdf2 = ResourceUtil.getFile(listPdf);
+                    if (tabpdf2.exists()) {
+                        tabpdf2.delete();
+                    }
+                    FileUtils.mergePdfPublicMethods(datainfo, listPdf);
+                    String netUrl = "";
+                    BladeFile bladeFile = this.newIOSSClient.uploadFile(query.getWbsId() + ".pdf", listPdf);
+                    if (bladeFile != null && ObjectUtils.isNotEmpty(bladeFile.getLink())) {
+                        netUrl = bladeFile.getLink();
+                    }
+                    String pdfPage = FileUtils.getPdfNum(netUrl);
+                    Long  pdfSize = CommonUtil.getResourceLength(netUrl);
+                    query.setNodePdfUrl(netUrl);
+                    query.setEVisaPdfPage(Integer.parseInt(pdfPage));
+                    query.setEVisaPdfSize(pdfSize);
+                    informationQueryClient.update(query);
+                }
+            }
+        }
+        System.out.println("检查完毕");
+
+
+    }
 
     /**
      * 质检附件追加
@@ -4145,6 +4209,29 @@ public class ExcelTabController extends BladeController {
                 fileList.add(tableFile);
             }
             tableFileService.saveOrUpdateBatch(fileList);
+            String file_path = FileUtils.getSysLocalFileUrl();
+            String sys_isonline = ParamCache.getValue(CommonConstant.SYS_ISONLINE);
+            List<TableFileVO> data = tableFileService.selectTableFileListByTen(Long.valueOf(nodeId + ""), Integer.valueOf(classify));
+            List<String> datainfo = new ArrayList<>();
+                for (TableFileVO tabsx : data) {
+                    datainfo.add(tabsx.getUrl());
+                }
+                String listPdf = file_path + "/nodePDF/" + nodeId + ".pdf";
+                File tabpdf2 = ResourceUtil.getFile(listPdf);
+                if (tabpdf2.exists()) {
+                    tabpdf2.delete();
+                }
+                FileUtils.mergePdfPublicMethods(datainfo, listPdf);
+                String netUrl = "";
+                BladeFile bladeFile = this.newIOSSClient.uploadFile(nodeId + ".pdf", listPdf);
+                if (bladeFile != null && ObjectUtils.isNotEmpty(bladeFile.getLink())) {
+                    netUrl = bladeFile.getLink();
+                }
+                String pdfPage = FileUtils.getPdfNum(netUrl);
+                Long  pdfSize = CommonUtil.getResourceLength(netUrl);
+                if(ObjectUtil.isNotEmpty(pdfPage)&&pdfPage.equals("")){
+                    pdfPage="0";
+                }
             String sql="SELECT * FROM m_wbs_tree_contract WHERE p_key_id="+nodeId;
             WbsTreeContract wbsTreeContract = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
             if(ObjectUtil.isNotEmpty(wbsTreeContract.getNodeClass())){
@@ -4161,6 +4248,9 @@ public class ExcelTabController extends BladeController {
                     iq.setFileUserIdAndName(b.getUserId()+"-"+b.getUserName());
                     iq.setType(1);
                     iq.setSourceType(2);
+                    iq.setEVisaPdfPage(pdfPage.equals("")?0:Integer.parseInt(pdfPage));
+                    iq.setEVisaPdfSize(pdfSize);
+                    iq.setNodePdfUrl(netUrl);
                     iq.setCreateUser(wbsTreeContract.getCreateUser());
                     iq.setCreateTime(new Date());
                     iq.setUpdateUser(b.getUserId());
@@ -4169,6 +4259,9 @@ public class ExcelTabController extends BladeController {
                     iq.setIsDeleted(0);
                     informationQueryClient.insert(iq);
                 }else {
+                    iq.setEVisaPdfPage(pdfPage.equals("")?0:Integer.parseInt(pdfPage));
+                    iq.setEVisaPdfSize(pdfSize);
+                    iq.setNodePdfUrl(netUrl);
                     iq.setUpdateTime(new Date());
                     iq.setUpdateUser(b.getUserId());
                     informationQueryClient.update(iq);

+ 3 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/WbsTreeContractClientImpl.java

@@ -163,7 +163,9 @@ public class WbsTreeContractClientImpl implements WbsTreeContractClient {
         if(StringUtils.isNotEmpty(node.getDigitizeTime())){
             wrappers.set(WbsTreeContract::getDigitizeTime,node.getDigitizeTime());
         }
-
+        if(StringUtils.isNotEmpty(node.getMajorDataType())){
+            wrappers.set(WbsTreeContract::getMajorDataType,node.getMajorDataType());
+        }
         return this.wbsTreeContractService.update(wrappers.eq(WbsTreeContract::getPKeyId, node.getPKeyId()));
     }
 

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

@@ -86,10 +86,19 @@ public class ExecutorInit extends FormulaExecutor {
         /*加载合同材料、材料清单*/
        /* tec.meterInfo.setMaterialsAll(materialFormFc.apply(tec.getContractId())); 中期计量支取关联的部分*/
         if(MeterType.MATERIAL.equals(tec.getMeterType())||MeterType.START.equals(tec.getMeterType())||MeterType.START_JL.equals(tec.getMeterType())){
-            /*加载合同材料、材料清单*/
-            tec.meterInfo.setMaterialsAll(materialFormFc.apply(tec.getContractId()));
+
             /*加载计量期信息*/
             tec.periodInfo=meterPeriodFc.apply(tec.getReportId());
+
+            /*加载合同材料、材料清单*/
+            if(MeterType.MATERIAL.equals(tec.getMeterType())){
+                tec.meterInfo.setMaterialsAll(materialFormFc.apply(tec.getContractId()));
+                // 由于材料 只需要计算材料支付,其他不需要
+                tec.meterInfo.setMaterialsAll(tec.meterInfo.getMaterialsAll().stream().filter(m->m.getPeriodId().equals(tec.periodInfo.getId())).collect(Collectors.toList()));
+            }else{
+                tec.meterInfo.setMaterialsAll(materialFormFc.apply(tec.getContractId()));
+            }
+
         }else if(MeterType.INTERIM.equals(tec.getMeterType())||MeterType.INTERIM_JL.equals(tec.getMeterType())){
             /*计量期*/
             periodInfo();;

+ 2 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaDaoImpl.java

@@ -128,8 +128,8 @@ public class FormulaDaoImpl implements IFormulaDao {
     @Override
     public Function<Long, List<Material>> getMaterialFormFc() {
         //and a.contract_id="+contractId+"
-        return periodId ->{
-            String sql="select a.certificate,a.material_arrive_number,a.contract_material_name  formMaterialName,b.material_name materialName,b.unit,a.price,b.price price_base,a.meter_amount meterAmount,meter_money sum,a.material_source source,material_conform  materialConform,a.storage_place storagePlace,a.storage_status storageStatus,a.storage_conform storageConform,a.remark,c.sort,c.id period_id from s_material_meter_form a left join s_contract_material b on a.contract_material_id = b.id join s_meter_period c  on a.meter_period_id=c.id where a.meter_period_id="+periodId+" and a.is_deleted=0 ";
+        return contractId ->{
+            String sql="select a.certificate,a.material_arrive_number,a.contract_material_name  formMaterialName,b.material_name materialName,b.unit,a.price,b.price price_base,a.meter_amount meterAmount,meter_money sum,a.material_source source,material_conform  materialConform,a.storage_place storagePlace,a.storage_status storageStatus,a.storage_conform storageConform,a.remark,c.sort,c.id period_id from s_material_meter_form a left join s_contract_material b on a.contract_material_id = b.id join s_meter_period c  on a.meter_period_id=c.id where a.contract_id="+contractId+" and a.is_deleted=0 ";
             return  getEntityList(sql,Material.class);
         };
     }

+ 18 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/utils/FileUtils.java

@@ -13,6 +13,7 @@ import com.spire.xls.core.spreadsheet.HTMLOptions;
 import com.sun.image.codec.jpeg.JPEGCodec;
 import com.sun.image.codec.jpeg.JPEGImageEncoder;
 import org.apache.commons.lang.StringUtils;
+import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.poi.hssf.usermodel.HSSFPrintSetup;
 import org.apache.poi.ss.usermodel.ClientAnchor;
 import org.apache.poi.ss.usermodel.PrintSetup;
@@ -995,4 +996,21 @@ public class FileUtils {
         }
     }
 
+    public static String getPdfNum(String url) {
+        try {
+            if (url.isEmpty() || url.equals("")) {
+                return "0";
+            }
+            InputStream pdfInputStream = CommonUtil.getOSSInputStream(url);
+            //获取这份文件的页数并设置签章策略
+            //获取PDF文件
+            PDDocument document = PDDocument.load(pdfInputStream);
+            int page = document.getPages().getCount();
+            return page + "";
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return "";
+    }
+
 }

+ 61 - 9
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/TaskController.java

@@ -72,6 +72,7 @@ import org.springblade.meter.config.MyJdbcTemplate;
 import org.springblade.meter.dto.*;
 import org.springblade.meter.entity.*;
 import org.springblade.meter.mapper.*;
+import org.springblade.meter.service.IInterimPayCertificateItemService;
 import org.springblade.meter.service.IInterimPayCertificateService;
 import org.springblade.meter.service.IMaterialStartStatementService;
 import org.springblade.meter.service.ITaskRepealMessageService;
@@ -107,6 +108,7 @@ import java.util.concurrent.ExecutionException;
 import java.util.function.Function;
 import java.util.regex.Matcher;
 import java.util.stream.Collectors;
+import java.util.stream.IntStream;
 
 @RestController
 @AllArgsConstructor
@@ -159,6 +161,7 @@ public class TaskController extends BladeController {
 
     private final IMaterialStartStatementService materialStartStatementService;
     private final IInterimPayCertificateService interimPayCertificateService;
+    private final IInterimPayCertificateItemService interimPayCertificateItemService;
     // 计量公式入口
     private final FormulaClient formulaClient;
 
@@ -172,6 +175,7 @@ public class TaskController extends BladeController {
     @ApiOperation(value = "获取任务名称", notes = "传入合同段contractId、期数id(变更令传勾选的id字符串英文逗号拼接)、type=1(中间计量申请)、=2(材料计量单)、3=(开工预付款计量单)、=4(变更令)")
     public R<Object> name(@RequestParam String contractId, @RequestParam String id, @RequestParam String type) {
         String name = null;
+        BigDecimal bigDecimal=null;
         if (ObjectUtil.isNotEmpty(contractId) && ObjectUtil.isNotEmpty(id)) {
             ContractInfo contractInfo = jdbcTemplate.query("SELECT contract_name FROM m_contract_info WHERE id = " + contractId, new BeanPropertyRowMapper<>(ContractInfo.class)).stream().findAny().orElse(null);
             String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
@@ -200,10 +204,15 @@ public class TaskController extends BladeController {
                     }
                 }
             }
+             bigDecimal = middleMeterApplyTaskMapper.selectSubmitApprovalMoney(Long.valueOf(contractId), Long.valueOf(id));
         }
-        return R.data(200, name, "操作成功");
+        Map<String,Object> map=new HashMap<>();
+        map.put("name",name);
+        map.put("submitApprovalMoney",bigDecimal);
+        return R.data(200, map, "操作成功");
     }
 
+
     @PostMapping("/report")
     @ApiOperationSupport(order = 2)
     @ApiOperation(value = "任务上报", notes = "(中期计量申请、材料计量单、开工预付款计量单、变更令)传入MeterApprovalDTO")
@@ -320,7 +329,41 @@ public class TaskController extends BladeController {
                     /*修改计量期的审批状态=待审批*/
                     contractMeterPeriodService.update(Wrappers.<ContractMeterPeriod>lambdaUpdate().set(ContractMeterPeriod::getApproveStatus, 1).eq(ContractMeterPeriod::getId, approvalDTO.getPeriodId()));
                     //修改报表状态,如果不存在则创建报表,因为任务要查看报表
-                    this.updateStatement(Long.valueOf(approvalDTO.getPeriodId()),1,1);
+                    Long id = this.updateStatement(Long.valueOf(approvalDTO.getPeriodId()), 1, 1);
+                    //修改报表项
+                    if(ObjectUtil.isNotEmpty(id)){
+                        InterimPayCertificateItem item = new InterimPayCertificateItem();
+                        item.setId(SnowFlakeUtil.getId());
+                        item.setCertificateId(id);
+                        item.setChapterSeq("施工单位送审金额");
+                        item.setCurrentPeriodPay(approvalDTO.getSubmitApprovalMoney()+"");
+                        String sql="Select * from s_contract_meter_period where contract_id="+approvalDTO.getContractId()+" and is_deleted=0"+" order by start_date";
+                        List<ContractMeterPeriod> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ContractMeterPeriod.class));
+                        if (list.size()>0) {
+                            //上期末施工单位金额
+                            BigDecimal shangqimo=BigDecimal.ZERO;
+                            OptionalInt index= IntStream.range(0, list.size())
+                                .filter(i -> list.get(i).getId().equals(approvalDTO.getPeriodId()))
+                                .findFirst();
+                            if(index.isPresent()){
+                                int j = index.getAsInt();
+                                //j>0表示前面有数据
+                                if(j>0){
+                                    //上一期的到本期末
+                                    BigDecimal  bigDecimal = middleMeterApplyTaskMapper.selectSubmitApprovalMoneyPre(approvalDTO.getContractId(), list.get(j - 1).getId());
+                                    if(ObjectUtil.isNotEmpty(bigDecimal)){
+                                        shangqimo=shangqimo.add(bigDecimal);
+                                    }
+                                }
+                            }
+                            if(shangqimo.compareTo(BigDecimal.ZERO)!=0){
+                                item.setPreviousPeriodEndPay(shangqimo+"");
+                            }
+                            item.setCurrentPeriodEndPay(shangqimo.add(approvalDTO.getSubmitApprovalMoney())+"");
+                        }
+                        item.setSort(24);
+                        interimPayCertificateItemService.saveOrUpdate(item);
+                    }
                     return R.data(200, aopParamsSet, "操作成功");
                 }
 
@@ -1040,7 +1083,7 @@ public class TaskController extends BladeController {
         int current = dto.getCurrent();
         int size = dto.getSize();
         List<Object> params = new ArrayList<>();
-        StringBuilder sqlString = new StringBuilder("SELECT * FROM u_task WHERE 1=1 AND is_deleted = 0 AND approval_type in (5,6,7) "); //approval_type = 5 计量任务
+        StringBuilder sqlString = new StringBuilder("SELECT * FROM u_task WHERE 1=1 AND is_deleted = 0 AND approval_type in (5,6,7,8) "); //approval_type = 5 计量任务
 
         ContractInfo contractInfo = jdbcTemplate.queryForObject("select contract_type from m_contract_info where id = " + dto.getContractId(), new BeanPropertyRowMapper<>(ContractInfo.class));
         if (contractInfo != null && Arrays.asList(1, 4).contains(contractInfo.getContractType())) {
@@ -1484,6 +1527,12 @@ public class TaskController extends BladeController {
                 }
                 reportAllMoney = reportAllMoney.setScale(0, RoundingMode.HALF_UP);
                 vo.setReportAllMoney(reportAllMoney);
+                //施工单位送审金额
+                BigDecimal submitApprovalMoney = null;
+                if(task.getMeterTaskType() == 1){
+                    submitApprovalMoney=middleMeterApplyTaskMapper.selectSubmitApprovalMoney(Long.valueOf(task.getContractId()),Long.valueOf(task.getFormDataId()));
+                }
+                vo.setSubmitApprovalMoney(submitApprovalMoney);
                 if (task.getIsBuildAudit() == 1) {
                     PeriodVO periodVO = null;
                     if (task.getMeterTaskType() == 1) {
@@ -1784,7 +1833,8 @@ public class TaskController extends BladeController {
      * @param
      * @return
      */
-    private void updateStatement(Long periodId,Integer type,Integer status) {
+    private Long updateStatement(Long periodId,Integer type,Integer status) {
+        Long InterimPayCertificateId=null;
         if (type == 1) {
             List<InterimPayCertificate> list = interimPayCertificateService.list(new LambdaQueryWrapper<InterimPayCertificate>().eq(InterimPayCertificate::getContractPeriodId, periodId));
             if (list.size() > 1) {
@@ -1793,6 +1843,7 @@ public class TaskController extends BladeController {
                 interimPayCertificateService.update(new LambdaUpdateWrapper<InterimPayCertificate>()
                         .eq(InterimPayCertificate::getId,list.get(0).getId())
                         .set(InterimPayCertificate::getApproveStatus,status));
+                InterimPayCertificateId=list.get(0).getId();
             } else {
                 ContractMeterPeriod period = contractMeterPeriodService.getById(periodId);
                 //新增报表
@@ -1809,7 +1860,7 @@ public class TaskController extends BladeController {
                 interimPayCertificateService.save(certificate);
                 //10代表不走电签,其他都会自动审批
                 this.calculate(certificate.getId() + "", 0, 10);
-
+                InterimPayCertificateId=certificate.getId();
             }
         } else {
             List<MaterialStartStatement> list = materialStartStatementService.list(new LambdaQueryWrapper<MaterialStartStatement>().eq(MaterialStartStatement::getMeterPeriodId, periodId));
@@ -1838,6 +1889,7 @@ public class TaskController extends BladeController {
                 this.calculate(statement.getId() + "", 1, 10);
             }
         }
+        return InterimPayCertificateId;
     }
 
     @GetMapping("/data/detail")
@@ -3701,10 +3753,10 @@ public class TaskController extends BladeController {
         try {
             String delTaskPall = "DELETE from u_task_parallel where process_instance_id in (SELECT process_instance_id from u_task where form_data_id ='" + periodId + "') ";
             String delTask = "DELETE from u_task where form_data_id ='" + periodId + "'";
-
+            Integer type1=type+5;
             //查询出当前计量期对应的任务
-            String selectTask = "SELECT * from u_task WHERE approval_type = 5 and form_data_id = ? and is_deleted = 0 and status in (1,2)";
-            List<Task> list = jdbcTemplate.query(selectTask, new BeanPropertyRowMapper<>(Task.class), periodId);
+            String selectTask = "SELECT * from u_task WHERE approval_type =? and form_data_id = ? and is_deleted = 0 and status in (1,2)";
+            List<Task> list = jdbcTemplate.query(selectTask, new BeanPropertyRowMapper<>(Task.class), type1,periodId);
             if (list.size() == 0){
                 return R.fail("撤销失败:未查出当前计量期对应任务信息");
             }
@@ -4481,7 +4533,7 @@ public class TaskController extends BladeController {
             List<Map<String, Object>> mapList = jdbcTemplate.queryForList(selSql);
             if(Func.isEmpty(mapList) || mapList.size()==0) {
                 // 修改个人电签状态
-                String UPSql = "update u_task_parallel a set a.e_visa_status=null,e_visa_content=null where a.process_instance_id = (select b.process_instance_id from u_task b where  b.`status` in(1,2) and b.form_data_id=" + report.getPeriodId() + ") ";
+                String UPSql = "update u_task_parallel a set a.e_visa_status=null,e_visa_content=null,initiative=1 where a.process_instance_id = (select b.process_instance_id from u_task b where  b.`status` in(1,2) and b.form_data_id=" + report.getPeriodId() + ") ";
                 String UPSqlJL = " update u_task_parallel a set a.e_visa_status=1,e_visa_content='电签成功',initiative=2 where sort in( SELECT a.fixed_flow_branch_sort from u_task b,u_fixed_flow_link a where b.`status` in(1,2) and b.form_data_id='" + report.getPeriodId() + "' and a.fixed_flow_id=b.fixed_flow_id and a.flow_task_type=2 ) and a.process_instance_id in(SELECT process_instance_id from u_task b where b.`status` in(1,2) and b.form_data_id='" + report.getPeriodId() + "')";
                 String DeSql = "delete from u_task_batch where task_parallel_id in(select b.process_instance_id from u_task b where b.`status` in(1,2) and b.form_data_id=" + report.getPeriodId() + ")";
                 //删除以前存在的电签

+ 1 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/MiddleMeterApplyMapper.xml

@@ -126,7 +126,7 @@
                  WHEN a.approve_status = 2 THEN
                     '已审批' ELSE '已废除'
                  END AS approveStatusName ,
-            (SELECT id from u_task c where b.id=c.form_data_id AND c.STATUS != 3 ) as task_id,
+            (SELECT id from u_task c where CONVERT(b.id, CHAR) =c.form_data_id AND c.STATUS != 3 ) as task_id,
             ( SELECT raw_url FROM s_interim_pay_certificate WHERE contract_id = #{apply.contractId} AND contract_period_id =
             a.contract_period_id AND is_deleted = 0 ) AS periodPdfUrl
             from

+ 4 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/MiddleMeterApplyTaskMapper.java

@@ -9,4 +9,8 @@ import java.math.BigDecimal;
 public interface MiddleMeterApplyTaskMapper extends BaseMapper<MiddleMeterApplyTask> {
 
     BigDecimal selectAllMoney(@Param("contractId") Long contractId,@Param("contractPeriodId") Long contractPeriodId);
+
+    BigDecimal selectSubmitApprovalMoney(@Param("contractId") Long contractId,@Param("periodId") Long periodId);
+
+    BigDecimal selectSubmitApprovalMoneyPre(@Param("contractId")Long contractId, @Param("contractPeriodId")Long contractPeriodId);
 }

+ 35 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/MiddleMeterApplyTaskMapper.xml

@@ -14,4 +14,39 @@
                                                    WHERE contract_id = #{contractId} and contract_period_id = #{contractPeriodId} and is_deleted = 0
                                                   )
     </select>
+    <select id="selectSubmitApprovalMoney" resultType="java.math.BigDecimal">
+        SELECT COALESCE(
+                   (SELECT current_period_pay
+                    FROM s_interim_pay_certificate_item
+                    WHERE chapter_seq = '施工单位送审金额'
+                      AND is_deleted = 0
+                      AND certificate_id = (
+                        SELECT id
+                        FROM s_interim_pay_certificate
+                        WHERE contract_id = #{contractId}
+                          AND contract_period_id = #{periodId}
+                          AND is_deleted = 0
+                    )),
+                   (SELECT current_period_pay
+                    FROM s_interim_pay_certificate_item
+                    WHERE chapter_seq = '实际支付'
+                      AND is_deleted = 0
+                      AND certificate_id = (
+                        SELECT id
+                        FROM s_interim_pay_certificate
+                        WHERE contract_id = #{contractId}
+                          AND contract_period_id = #{periodId}
+                          AND is_deleted = 0
+                    ))
+               ) AS current_period_pay;
+    </select>
+    <select id="selectSubmitApprovalMoneyPre" resultType="java.math.BigDecimal">
+        select current_period_end_pay
+        from s_interim_pay_certificate_item where  chapter_seq='施工单位送审金额' and is_deleted = 0
+                                              and certificate_id =
+                                                  (select id from s_interim_pay_certificate
+                                                   WHERE contract_id = #{contractId} and contract_period_id = #{contractPeriodId} and is_deleted = 0
+                                                  )
+
+    </select>
 </mapper>