|
@@ -18,23 +18,25 @@ package org.springblade.business.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springblade.business.entity.ContractLog;
|
|
|
-import org.springblade.business.vo.ContractLogVO;
|
|
|
+import org.springblade.business.entity.Task;
|
|
|
+import org.springblade.business.entity.TaskParallel;
|
|
|
import org.springblade.business.mapper.ContractLogMapper;
|
|
|
import org.springblade.business.service.IContractLogService;
|
|
|
+import org.springblade.business.vo.ContractLogVO;
|
|
|
import org.springblade.business.vo.FileUserVO;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Comparator;
|
|
|
-import java.util.LinkedList;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -46,6 +48,12 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class ContractLogServiceImpl extends BaseServiceImpl<ContractLogMapper, ContractLog> implements IContractLogService {
|
|
|
|
|
|
+ private final JdbcTemplate jdbcTemplate;
|
|
|
+
|
|
|
+ public ContractLogServiceImpl(JdbcTemplate jdbcTemplate) {
|
|
|
+ this.jdbcTemplate = jdbcTemplate;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<String> queryReportLogTimeTree(String contractId, String nodePrimaryKeyId) {
|
|
|
return this.baseMapper.queryReportLogTimeTree(contractId, nodePrimaryKeyId);
|
|
@@ -112,6 +120,71 @@ public class ContractLogServiceImpl extends BaseServiceImpl<ContractLogMapper, C
|
|
|
|
|
|
IPage<ContractLogVO> iPage = Condition.getPage(query);
|
|
|
iPage.setTotal(count);
|
|
|
+
|
|
|
+ //待审批和已审批的id集合
|
|
|
+ List<Long> ids = deduplicatedList.stream().filter(vo -> vo.getStatus() == 1 || vo.getStatus() == 2).map(ContractLogVO::getId).collect(Collectors.toList());
|
|
|
+ //构造map
|
|
|
+ HashMap<String, String> taskMap = new HashMap<>();
|
|
|
+ Map<String, List<TaskParallel>> taskParallelMap = new HashMap<>();
|
|
|
+ if(ObjectUtil.isNotEmpty(ids)){
|
|
|
+ List<Task> tasks = jdbcTemplate.query("select form_data_id ,process_instance_id from u_task where status != 3 and form_data_id in (" + StringUtils.join(ids, ",") + ")"
|
|
|
+ , new BeanPropertyRowMapper<>(Task.class));
|
|
|
+ if(ObjectUtil.isNotEmpty(tasks)){
|
|
|
+ taskMap = tasks.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ Task::getFormDataId,
|
|
|
+ Task::getProcessInstanceId,
|
|
|
+ (existingValue, newValue) -> existingValue,
|
|
|
+ HashMap::new
|
|
|
+ ));
|
|
|
+
|
|
|
+ String processInstanceIds = taskMap.values().stream().collect(Collectors.joining("\',\'"));
|
|
|
+ processInstanceIds = "\'" + processInstanceIds+"\'";
|
|
|
+
|
|
|
+ List<TaskParallel> taskParallels = jdbcTemplate.query("select * from u_task_parallel where process_instance_id in (" + processInstanceIds + ")"
|
|
|
+ , new BeanPropertyRowMapper<>(TaskParallel.class));
|
|
|
+ if (ObjectUtil.isNotEmpty(taskParallels)){
|
|
|
+ taskParallelMap = taskParallels.stream().collect(Collectors.groupingBy(
|
|
|
+ TaskParallel::getProcessInstanceId
|
|
|
+ ));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (Long id : ids) {
|
|
|
+ String processInstanceId = taskMap.get(id.toString());
|
|
|
+ /*判断签字人的验证 2=绿色 3=黄色 999=红色 其他代表=灰色*/
|
|
|
+ List<TaskParallel> statList = new ArrayList<>();
|
|
|
+ if(StringUtils.isNotEmpty(processInstanceId)){
|
|
|
+ List<TaskParallel> taskParallels = taskParallelMap.get(processInstanceId);
|
|
|
+ if(ObjectUtil.isNotEmpty(taskParallels)){
|
|
|
+ for (TaskParallel taskPa : taskParallels) {
|
|
|
+ if (taskPa.getStatus() == 2 && ObjectUtil.isNotEmpty(taskPa.getEVisaStatus()) && taskPa.getEVisaStatus() == 1) {
|
|
|
+ taskPa.setEVisaStatus(2);
|
|
|
+ } else if (taskPa.getStatus() == 3) {
|
|
|
+ if (taskPa.getInitiative() == 2) {
|
|
|
+ taskPa.setEVisaStatus(3);
|
|
|
+ }
|
|
|
+ } else if (ObjectUtil.isNotEmpty(taskPa.getEVisaStatus()) && taskPa.getEVisaStatus() == 99) {
|
|
|
+ taskPa.setEVisaStatus(999);
|
|
|
+ } else {
|
|
|
+ taskPa.setEVisaStatus(1);
|
|
|
+ }
|
|
|
+ statList.add(taskPa);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Object> objectList = statList.stream().map(taskPa -> (Object) taskPa).collect(Collectors.toList());
|
|
|
+ Optional<ContractLogVO> first = deduplicatedList.stream().filter(vo -> vo.getId().equals(id)).findFirst();
|
|
|
+ first.ifPresent(vo -> vo.setTaskApproveUserNamesList(objectList));
|
|
|
+ /*if (statList.size() > 0) {
|
|
|
+ List<Object> objectList = statList.stream().map(taskPa -> (Object) taskPa).collect(Collectors.toList());
|
|
|
+ ContractLogVO contractLogVO = deduplicatedMap.get(id);
|
|
|
+ if(ObjectUtil.isNotEmpty(contractLogVO)){
|
|
|
+ contractLogVO.setTaskApproveUserNamesList(objectList);
|
|
|
+ resultList.add(contractLogVO);
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ }
|
|
|
+ }
|
|
|
return iPage.setRecords(deduplicatedList);
|
|
|
}
|
|
|
|