Browse Source

把不需要审批改为需要审批

chenr 5 months ago
parent
commit
86d7addf7b

+ 36 - 1
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/ArchiveFileServiceImpl.java

@@ -6,6 +6,8 @@ import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
 import org.springblade.archive.feign.ArchiveInspectionInfoClient;
 import org.springblade.business.entity.ArchiveFile;
+import org.springblade.business.entity.Task;
+import org.springblade.business.entity.TaskParallel;
 import org.springblade.business.vo.ArchiveFileVO;
 import org.springblade.business.mapper.ArchiveFileMapper;
 import org.springblade.business.service.IArchiveFileService;
@@ -16,6 +18,8 @@ import org.springblade.core.tool.utils.Func;
 import org.springblade.resource.feign.NewIOSSClient;
 import org.springblade.system.entity.DictBiz;
 import org.springblade.system.feign.IDictBizClient;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 
@@ -38,6 +42,8 @@ public class ArchiveFileServiceImpl extends BaseServiceImpl<ArchiveFileMapper, A
 
     private ExecutorService executorService;
     private final ArchiveInspectionInfoClient archiveInspectionInfoClient;
+    private final JdbcTemplate   jdbcTemplate;
+
 
     @Override
     public IPage<ArchiveFileVO> selectArchiveFilePage(ArchiveFileVO vo) {
@@ -162,10 +168,39 @@ public class ArchiveFileServiceImpl extends BaseServiceImpl<ArchiveFileMapper, A
             if (Func.isNotEmpty(vo.getIsNeedCertification()) && vo.getIsNeedCertification() == 0){
                 vo.setIsCertification(1);
             }
-            //循环查看是否把需要审批改为不需要审批,  不可能把不需要审批改为需要审批
+            //循环查看是否把需要审批改为不需要审批,  不可能把不需要审批改为需要审批 ,0不需要,1需要
             if (vo.getStatus() == 0 && vo.getIsApproval() == 0) {
                 vo.setStatus(2);
             }
+            if(vo.getIsApproval() == 1){
+                Set<String> aopParamsSet = new HashSet<>();
+                //判断现在的数据是否是待审批数据,只有上报状态、未认证状态的数据才能撤销
+                ArchiveFile archiveFile = jdbcTemplate.queryForObject("select * from u_archive_file where id = " + vo.getId(), new BeanPropertyRowMapper<>(ArchiveFile.class));
+                if (archiveFile != null) {
+                    if (archiveFile.getIsApproval() != null && archiveFile.getIsApproval() == 0) {
+                        //此文件为不需要审批文件,所以没有任务信息,直接修改状态
+                        jdbcTemplate.execute("update u_archive_file set status = 3,is_certification = 0,e_visa_file = null where id = " + vo.getId());
+                    } else {
+                        /*此处任务会查询出多条,因为存在多次废除任务,那么form_data_id指向同一个id,所以在新增的时候去重判断,status=1或2,有且只有一条*/
+                        Task task = jdbcTemplate.query("select id,status,process_instance_id from u_task where task_create_timestamp is not null and status in (1,2) and form_data_id = '" + vo.getId() + "'", new BeanPropertyRowMapper<>(Task.class)).stream().findAny().orElse(null);
+                        if (task != null) {
+                            //修改档案文件收集业务数据状态=已废除
+                            jdbcTemplate.execute("update u_archive_file set status = 3,is_certification = 0,e_visa_file = null where id = " + vo.getId());
+                            //待审批审批任务=已废除
+                            jdbcTemplate.execute("update u_task set status = 3 where id = " + task.getId());
+                            //审批任务详情=已废除
+                            jdbcTemplate.execute("update u_task_parallel set status = 3 where process_instance_id = '" + task.getProcessInstanceId() + "'");
+                            /*通知*/
+                            List<TaskParallel> taskParallelList = jdbcTemplate.query("SELECT task_user FROM u_task_parallel WHERE process_instance_id = '" + task.getProcessInstanceId() + "'", new BeanPropertyRowMapper<>(TaskParallel.class));
+                            for (TaskParallel taskParallel : taskParallelList) {
+                                String param = taskParallel.getTaskUser() + "," + vo.getProjectId() + "," + vo.getContractId();
+                                aopParamsSet.add(param);
+                            }
+                        }
+                    }
+                }
+                vo.setStatus(0);
+            }
         }
         this.updateBatchById(JSONArray.parseArray(JSONObject.toJSONString(list), ArchiveFile.class));
     }