Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
906fc81dc5
@ -2,10 +2,7 @@ package com.xdap.self_development.controller;
|
||||
|
||||
import com.definesys.mpaas.common.http.Response;
|
||||
import com.definesys.mpaas.query.db.PageQueryResult;
|
||||
import com.xdap.self_development.controller.form.BenchmarkingReportPageForm;
|
||||
import com.xdap.self_development.controller.form.HandleApprovalRequest;
|
||||
import com.xdap.self_development.controller.form.SaveBenchmarkingReportForm;
|
||||
import com.xdap.self_development.controller.form.UpdateBenchmarkingReportForm;
|
||||
import com.xdap.self_development.controller.form.*;
|
||||
import com.xdap.self_development.exception.CommonException;
|
||||
import com.xdap.self_development.pojo.BenchmarkingReport;
|
||||
import com.xdap.self_development.pojo.view.ApprovalFlowView;
|
||||
@ -37,9 +34,9 @@ public class BenchmarkingReportController {
|
||||
return Response.ok().data(fileUrl);
|
||||
}
|
||||
|
||||
// 新增对标报告并发起审批
|
||||
@PostMapping("/startReportApproval")
|
||||
public Response startReportApproval(
|
||||
// 保存对标报告
|
||||
@PostMapping("/insertReport")
|
||||
public Response saveReportApproval(
|
||||
@Valid @RequestBody SaveBenchmarkingReportForm form,
|
||||
BindingResult bindingResult
|
||||
) {
|
||||
@ -48,12 +45,21 @@ public class BenchmarkingReportController {
|
||||
throw new CommonException(error.getDefaultMessage());
|
||||
});
|
||||
}
|
||||
benchmarkingReportService.saveBenchmarkingReport(form);
|
||||
benchmarkingReportService.insertReport(form);
|
||||
return Response.ok().setMessage("保存成功");
|
||||
}
|
||||
|
||||
// 修改对标报告并发起审批
|
||||
@PostMapping("/restartReportApproval")
|
||||
// 发起审批
|
||||
@PostMapping("/startReportApproval")
|
||||
public Response startReportApproval(
|
||||
@Valid @RequestBody ApprovalPersonForm form
|
||||
) {
|
||||
benchmarkingReportService.startReportApproval(form);
|
||||
return Response.ok().setMessage("保存成功");
|
||||
}
|
||||
|
||||
// 修改对标报告
|
||||
@PostMapping("/updateReport")
|
||||
public Response restartReportApproval(
|
||||
@Valid @RequestBody UpdateBenchmarkingReportForm form,
|
||||
BindingResult bindingResult
|
||||
@ -63,7 +69,7 @@ public class BenchmarkingReportController {
|
||||
throw new CommonException(error.getDefaultMessage());
|
||||
});
|
||||
}
|
||||
benchmarkingReportService.restartReportApproval(form);
|
||||
benchmarkingReportService.updateReport(form);
|
||||
return Response.ok().setMessage("重新提交成功");
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.xdap.self_development.controller;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.definesys.mpaas.common.http.Response;
|
||||
import com.definesys.mpaas.query.MpaasQueryFactory;
|
||||
import com.xdap.motor.entity.SnowflakeIdWorker;
|
||||
@ -14,12 +15,14 @@ import com.xdap.self_development.schedule.ParameterValueCalculationTimer;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@ -51,27 +54,57 @@ public class DeleteController {
|
||||
return Response.ok().data(myResponse);
|
||||
}
|
||||
|
||||
@GetMapping("/getTC")
|
||||
public Response getTC(
|
||||
@RequestParam String productNumber,
|
||||
@RequestParam String partsName,
|
||||
@RequestParam String parameterName
|
||||
@PostMapping("/exportCompare")
|
||||
public void exportTemplateCompare(
|
||||
// @RequestBody CompareRequest request,
|
||||
// HttpServletResponse response
|
||||
) {
|
||||
EnginePartsCollection enginePartsCollection = bd.getTCDatabase()
|
||||
.eq("ztj", productNumber)
|
||||
.eq("lbjmc", partsName)
|
||||
.doQueryFirst(EnginePartsCollection.class);
|
||||
if (enginePartsCollection == null || enginePartsCollection.getLbjth() == null) {
|
||||
return Response.error("无法找到图号");
|
||||
// try {
|
||||
// // 1. 查询对比数据
|
||||
// List<ParamCompareDTO> data = compareService.compareMultipleTemplates(
|
||||
// request.getTemplateNames(),
|
||||
// request.getQueryParams()
|
||||
// );
|
||||
//
|
||||
// // 2. 设置响应头
|
||||
// String fileName = "模板参数对比_" + System.currentTimeMillis() + ".xlsx";
|
||||
// response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
// response.setCharacterEncoding("utf-8");
|
||||
// response.setHeader("Content-disposition",
|
||||
// "attachment;filename*=utf-8''" + URLEncoder.encode(fileName, "UTF-8"));
|
||||
//
|
||||
// // 3. 动态生成表头
|
||||
// List<List<String>> head = generateDynamicHeader(request.getTemplateNames());
|
||||
//
|
||||
// // 4. 使用EasyExcel写入数据
|
||||
// EasyExcel.write(response.getOutputStream())
|
||||
// .head(head) // 动态表头
|
||||
// .sheet("参数对比")
|
||||
// .doWrite(data);
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// throw new RuntimeException("导出失败", e);
|
||||
// }
|
||||
}
|
||||
ClassificationAttribute classificationAttribute = bd.getTCDatabase()
|
||||
.eq("pitemId", enginePartsCollection.getLbjth())
|
||||
.eq("idattrtbutehame", parameterName)
|
||||
.doQueryFirst(ClassificationAttribute.class);
|
||||
if (classificationAttribute != null && classificationAttribute.getFieldvalue() != null) {
|
||||
String fieldvalue = classificationAttribute.getFieldvalue();
|
||||
return Response.ok().data(fieldvalue);
|
||||
|
||||
/**
|
||||
* 动态生成表头
|
||||
*/
|
||||
private List<List<String>> generateDynamicHeader(List<String> templateNames) {
|
||||
List<List<String>> head = new ArrayList<>();
|
||||
|
||||
// 固定列
|
||||
head.add(Collections.singletonList("参数名称"));
|
||||
head.add(Collections.singletonList("参数编码"));
|
||||
|
||||
// 动态模板列
|
||||
for (String templateName : templateNames) {
|
||||
head.add(Collections.singletonList(templateName));
|
||||
}
|
||||
return Response.error("无法找到参数值");
|
||||
|
||||
// 差异标识列
|
||||
head.add(Collections.singletonList("差异标识"));
|
||||
|
||||
return head;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
package com.xdap.self_development.controller.form;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ApprovalPersonForm {
|
||||
@NotEmpty(message = "报告不能为空")
|
||||
private String reportId;
|
||||
|
||||
@NotEmpty(message = "校对人员不能为空")
|
||||
private List<String> proofreadUsers;
|
||||
@NotEmpty(message = "审核人员不能为空")
|
||||
private List<String> reviewUsers;
|
||||
private List<String> countersignUsers; // 可选
|
||||
@NotEmpty(message = "批准人员不能为空")
|
||||
private List<String> approveUsers;
|
||||
private String explanation;
|
||||
|
||||
@NotEmpty(message = "创建者不能为空")
|
||||
private String userId;
|
||||
}
|
||||
@ -10,41 +10,20 @@ import java.util.List;
|
||||
public class SaveBenchmarkingReportForm {
|
||||
@NotBlank(message = "标题不能为空")
|
||||
private String title;
|
||||
@NotBlank(message = "厂家名称不能为空")
|
||||
private String manufacturerName;
|
||||
@NotBlank(message = "产品型号不能为空")
|
||||
private String modelName;
|
||||
@NotBlank(message = "厂家简称不能为空")
|
||||
private String manufacturerAbbreviation;
|
||||
@NotBlank(message = "产品型号简称不能为空")
|
||||
private String modelAbbreviation;
|
||||
@NotBlank(message = "产品编号不能为空")
|
||||
private String productNumber;
|
||||
@NotBlank(message = "模块不能为空")
|
||||
private String module;
|
||||
@NotBlank(message = "板块不能为空")
|
||||
private String manufacturerAbbreviation;
|
||||
private String modelAbbreviation;
|
||||
private String productNumber;
|
||||
private String plate;
|
||||
@NotBlank(message = "平台不能为空")
|
||||
private String platform;
|
||||
@NotBlank(message = "系列不能为空")
|
||||
private String series;
|
||||
@NotBlank(message = "细分市场不能为空")
|
||||
private String marketSegment;
|
||||
@NotBlank(message = "项目名称不能为空")
|
||||
private String projectName;
|
||||
@NotBlank(message = "项目编号不能为空")
|
||||
private String projectNumber;
|
||||
|
||||
private String fileUrl;
|
||||
|
||||
@NotEmpty(message = "校对人员不能为空")
|
||||
private List<String> proofreadUsers;
|
||||
@NotEmpty(message = "审核人员不能为空")
|
||||
private List<String> reviewUsers;
|
||||
private List<String> countersignUsers; // 可选
|
||||
@NotEmpty(message = "批准人员不能为空")
|
||||
private List<String> approveUsers;
|
||||
@NotBlank(message = "发起人不能为空")
|
||||
private String userId;
|
||||
private String explanation;
|
||||
private String fileUrl;
|
||||
}
|
||||
|
||||
@ -8,46 +8,25 @@ import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UpdateBenchmarkingReportForm {
|
||||
@NotBlank(message = "原对标报告id不能为空")
|
||||
@NotBlank(message = "原对标报告不能为空")
|
||||
private String reportId;
|
||||
|
||||
@NotBlank(message = "标题不能为空")
|
||||
private String title;
|
||||
@NotBlank(message = "厂家名称不能为空")
|
||||
private String manufacturerName;
|
||||
@NotBlank(message = "产品型号不能为空")
|
||||
private String modelName;
|
||||
@NotBlank(message = "厂家简称不能为空")
|
||||
private String manufacturerAbbreviation;
|
||||
@NotBlank(message = "产品型号简称不能为空")
|
||||
private String modelAbbreviation;
|
||||
@NotBlank(message = "产品编号不能为空")
|
||||
private String productNumber;
|
||||
@NotBlank(message = "模块不能为空")
|
||||
private String module;
|
||||
@NotBlank(message = "板块不能为空")
|
||||
private String plate;
|
||||
@NotBlank(message = "平台不能为空")
|
||||
private String platform;
|
||||
@NotBlank(message = "系列不能为空")
|
||||
private String series;
|
||||
@NotBlank(message = "细分市场不能为空")
|
||||
private String marketSegment;
|
||||
@NotBlank(message = "项目名称不能为空")
|
||||
private String projectName;
|
||||
@NotBlank(message = "项目编号不能为空")
|
||||
private String projectNumber;
|
||||
|
||||
private String fileUrl;
|
||||
|
||||
@NotEmpty(message = "校对人员不能为空")
|
||||
private List<String> proofreadUsers;
|
||||
@NotEmpty(message = "审核人员不能为空")
|
||||
private List<String> reviewUsers;
|
||||
private List<String> countersignUsers; // 可选
|
||||
@NotEmpty(message = "批准人员不能为空")
|
||||
private List<String> approveUsers;
|
||||
@NotBlank(message = "发起人不能为空")
|
||||
private String createBy;
|
||||
private String explanation;
|
||||
private String userId;
|
||||
}
|
||||
|
||||
@ -23,7 +23,6 @@ public class SheetDataListener implements ReadListener<Parameter> {
|
||||
private List<Parameter> cachedDataList;
|
||||
private String currentSheetName;
|
||||
MyResponse problems;
|
||||
Integer maxOrder;
|
||||
|
||||
// 用于存储表头
|
||||
private Set<String> actualHeaders = new HashSet<>();
|
||||
@ -35,14 +34,13 @@ public class SheetDataListener implements ReadListener<Parameter> {
|
||||
private boolean validSheet = false;
|
||||
|
||||
public SheetDataListener(TemplateService templateService,
|
||||
String templateRowId, String createBy, MyResponse problems, Integer maxOrder) {
|
||||
String templateRowId, String createBy, MyResponse problems) {
|
||||
this.templateService = templateService;
|
||||
this.templateRowId = templateRowId;
|
||||
this.createBy = createBy;
|
||||
this.cachedDataList = new ArrayList<>(BATCH_SIZE);
|
||||
this.problems = problems;
|
||||
this.requiredHeaders = getIncludeColumnFieldNames();
|
||||
this.maxOrder = maxOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -104,8 +102,7 @@ public class SheetDataListener implements ReadListener<Parameter> {
|
||||
currentSheetName,
|
||||
templateRowId,
|
||||
createBy,
|
||||
problems,
|
||||
maxOrder
|
||||
problems
|
||||
);
|
||||
cachedDataList.clear();
|
||||
}
|
||||
@ -147,7 +144,6 @@ public class SheetDataListener implements ReadListener<Parameter> {
|
||||
headerChecked = false;
|
||||
validSheet = false;
|
||||
actualHeaders.clear();
|
||||
maxOrder += 1;
|
||||
}
|
||||
|
||||
private static Set<String> getIncludeColumnFieldNames() {
|
||||
|
||||
@ -34,9 +34,9 @@ public class BenchmarkingReport extends MpaasBasePojo {
|
||||
private String marketSegment;
|
||||
private String projectName;
|
||||
private String projectNumber;
|
||||
|
||||
private String createBy;
|
||||
private Integer isDelete;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Timestamp uploadTime;
|
||||
private String filePath;
|
||||
|
||||
@ -35,14 +35,14 @@ public class Template extends MpaasBasePojo {
|
||||
private Timestamp createdTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Timestamp publishedTime;
|
||||
private Integer orderNum;
|
||||
private Long orderNum;
|
||||
private String createBy;
|
||||
|
||||
|
||||
@Column(type = ColumnType.CALCULATE)
|
||||
private Integer maxOrder;
|
||||
|
||||
public Template(String templateName, Integer version, String status, Timestamp createdTime, Timestamp publishedTime, String createBy, Integer orderNum) {
|
||||
public Template(String templateName, Integer version, String status, Timestamp createdTime, Timestamp publishedTime, String createBy, Long orderNum) {
|
||||
this.templateName = templateName;
|
||||
this.version = version;
|
||||
this.status = status;
|
||||
|
||||
@ -10,11 +10,11 @@ import java.util.List;
|
||||
|
||||
@SQLQuery(value = {
|
||||
@SQL(view = "getAllReportApproval",
|
||||
sql = "SELECT br.id AS \"reportId\", af.id AS \"flowId\", br.* FROM yfsjglpt_model_approval_flow af JOIN yfsjglpt_model_benchmarking_report br ON af.template_id = br.id WHERE br.is_delete = 0 and br.title like CONCAT('%', #title, '%') and br.manufacturer_name like CONCAT('%', #manufacturerName, '%') and br.model_name like CONCAT('%', #modelName, '%') and br.product_number like CONCAT('%', #productNumber, '%') and br.module like CONCAT('%', #module, '%') and br.plate like CONCAT('%', #plate, '%') and br.platform like CONCAT('%', #platform, '%') and br.series like CONCAT('%', #series, '%') and br.market_segment like CONCAT('%', #marketSegment, '%') and br.project_name like CONCAT('%', #projectName, '%') and br.project_number like CONCAT('%', #projectNumber, '%') and br.status like CONCAT('%', #status, '%') and af.flow_type = 2 ORDER BY CASE br.status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'REJECTED' THEN 3 ELSE 4 END ASC"),
|
||||
sql = "SELECT br.id AS \"reportId\", af.id AS \"flowId\", br.* FROM yfsjglpt_model_approval_flow af RIGHT JOIN yfsjglpt_model_benchmarking_report br ON af.template_id = br.id AND af.flow_type = 2 WHERE br.is_delete = 0 and br.title like CONCAT('%', #title, '%') and br.manufacturer_name like CONCAT('%', #manufacturerName, '%') and br.model_name like CONCAT('%', #modelName, '%') and br.product_number like CONCAT('%', #productNumber, '%') and br.module like CONCAT('%', #module, '%') and br.plate like CONCAT('%', #plate, '%') and br.platform like CONCAT('%', #platform, '%') and br.series like CONCAT('%', #series, '%') and br.market_segment like CONCAT('%', #marketSegment, '%') and br.project_name like CONCAT('%', #projectName, '%') and br.project_number like CONCAT('%', #projectNumber, '%') and br.status like CONCAT('%', #status, '%') ORDER BY CASE br.status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'REJECTED' THEN 3 ELSE 4 END ASC"),
|
||||
@SQL(view = "getReportByUserIdAndIds",
|
||||
sql = "SELECT br.id AS \"reportId\", af.id AS \"flowId\", br.* FROM yfsjglpt_model_approval_flow af JOIN yfsjglpt_model_benchmarking_report br ON af.template_id = br.id WHERE br.title like CONCAT('%', #title, '%') and br.manufacturer_name like CONCAT('%', #manufacturerName, '%') and br.model_name like CONCAT('%', #modelName, '%') and br.product_number like CONCAT('%', #productNumber, '%') and br.module like CONCAT('%', #module, '%') and br.plate like CONCAT('%', #plate, '%') and br.platform like CONCAT('%', #platform, '%') and br.series like CONCAT('%', #series, '%') and br.market_segment like CONCAT('%', #marketSegment, '%') and br.project_name like CONCAT('%', #projectName, '%') and br.project_number like CONCAT('%', #projectNumber, '%') and br.status like CONCAT('%', #status, '%') and af.flow_type = 2 AND af.id NOT IN (#ids) AND af.create_by = #createBy"),
|
||||
sql = "SELECT br.id AS \"reportId\", af.id AS \"flowId\", br.* FROM yfsjglpt_model_approval_flow af LEFT JOIN yfsjglpt_model_benchmarking_report br ON af.template_id = br.id WHERE br.title like CONCAT('%', #title, '%') and br.manufacturer_name like CONCAT('%', #manufacturerName, '%') and br.model_name like CONCAT('%', #modelName, '%') and br.product_number like CONCAT('%', #productNumber, '%') and br.module like CONCAT('%', #module, '%') and br.plate like CONCAT('%', #plate, '%') and br.platform like CONCAT('%', #platform, '%') and br.series like CONCAT('%', #series, '%') and br.market_segment like CONCAT('%', #marketSegment, '%') and br.project_name like CONCAT('%', #projectName, '%') and br.project_number like CONCAT('%', #projectNumber, '%') and br.status like CONCAT('%', #status, '%') and af.flow_type = 2 AND af.id NOT IN (#ids) AND af.create_by = #createBy"),
|
||||
@SQL(view = "getTodoAndReport",
|
||||
sql = "SELECT br.id AS \"reportId\", af.id AS \"flowId\", br.* FROM yfsjglpt_model_approval_flow af JOIN yfsjglpt_model_benchmarking_report br ON af.template_id = br.id WHERE br.title like CONCAT('%', #title, '%') and br.manufacturer_name like CONCAT('%', #manufacturerName, '%') and br.model_name like CONCAT('%', #modelName, '%') and br.product_number like CONCAT('%', #productNumber, '%') and br.module like CONCAT('%', #module, '%') and br.plate like CONCAT('%', #plate, '%') and br.platform like CONCAT('%', #platform, '%') and br.series like CONCAT('%', #series, '%') and br.market_segment like CONCAT('%', #marketSegment, '%') and br.project_name like CONCAT('%', #projectName, '%') and br.project_number like CONCAT('%', #projectNumber, '%') and br.status like CONCAT('%', #status, '%') and af.flow_type = 2 AND (af.id IN (#ids) OR af.create_by = #createBy) ORDER BY CASE br.status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'REJECTED' THEN 3 ELSE 4 END ASC")
|
||||
sql = "SELECT br.id AS \"reportId\", af.id AS \"flowId\", br.* FROM yfsjglpt_model_approval_flow af LEFT JOIN yfsjglpt_model_benchmarking_report br ON af.template_id = br.id WHERE br.title like CONCAT('%', #title, '%') and br.manufacturer_name like CONCAT('%', #manufacturerName, '%') and br.model_name like CONCAT('%', #modelName, '%') and br.product_number like CONCAT('%', #productNumber, '%') and br.module like CONCAT('%', #module, '%') and br.plate like CONCAT('%', #plate, '%') and br.platform like CONCAT('%', #platform, '%') and br.series like CONCAT('%', #series, '%') and br.market_segment like CONCAT('%', #marketSegment, '%') and br.project_name like CONCAT('%', #projectName, '%') and br.project_number like CONCAT('%', #projectNumber, '%') and br.status like CONCAT('%', #status, '%') and af.flow_type = 2 AND (af.id IN (#ids) OR af.create_by = #createBy) ORDER BY CASE br.status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'REJECTED' THEN 3 ELSE 4 END ASC")
|
||||
})
|
||||
@Data
|
||||
public class TodoAndReportView {
|
||||
|
||||
@ -1,99 +0,0 @@
|
||||
package com.xdap.self_development.schedule;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.xdap.self_development.config.BusinessDatabase;
|
||||
import com.xdap.self_development.exception.CommonException;
|
||||
import com.xdap.self_development.pojo.ApprovalFlow;
|
||||
import com.xdap.self_development.pojo.ApprovalRecord;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = CommonException.class)
|
||||
public class ModifiedTodoTimer {
|
||||
@Resource
|
||||
private BusinessDatabase bd;
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
private static final String TODO_PREFIX = "approval:todo:";
|
||||
private static final String TODO_PREFIX_2 = "report:todo:";
|
||||
|
||||
private static final String NODE_PROCESSED_PREFIX = "approval:node:processed:";
|
||||
private static final String NODE_PROCESSED_PREFIX_2 = "report:node:processed:";
|
||||
|
||||
// @Scheduled(cron = "0 */1 * * * *")
|
||||
public void modifiedTodo() {
|
||||
// 获取审批中的所有流程
|
||||
List<ApprovalFlow> flows1 = bd.getBusinessDatabase()
|
||||
.eq("flow_status", "APPROVING")
|
||||
.eq("flow_type", 1)
|
||||
.doQuery(ApprovalFlow.class);
|
||||
checkFlows(flows1, TODO_PREFIX, NODE_PROCESSED_PREFIX);
|
||||
|
||||
List<ApprovalFlow> flows2 = bd.getBusinessDatabase()
|
||||
.eq("flow_status", "APPROVING")
|
||||
.eq("flow_type", 2)
|
||||
.doQuery(ApprovalFlow.class);
|
||||
checkFlows(flows2, TODO_PREFIX_2, NODE_PROCESSED_PREFIX_2);
|
||||
}
|
||||
|
||||
// 检查流程
|
||||
private void checkFlows(List<ApprovalFlow> flows, String todoFlag, String prefixFlag) {
|
||||
// 遍历每一个流程
|
||||
flows.forEach(flow -> {
|
||||
List<String> nodeUsers = getNodeUsers(flow, flow.getCurrentNode());
|
||||
List<String> records = bd.getBusinessDatabase()
|
||||
.eq("flow_id", flow.getId())
|
||||
.eq("node", flow.getCurrentNode())
|
||||
.doQuery(ApprovalRecord.class)
|
||||
.stream().map(ApprovalRecord::getUserId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (Objects.equals(flow.getCurrentNode(), "COUNTERSIGN")) {
|
||||
log.info("{}审批流,的COUNTERSIGN的已完成的人:{}", flow.getId(), records);
|
||||
records.forEach(record -> {
|
||||
Boolean isMember = redisTemplate.opsForSet()
|
||||
.isMember(prefixFlag + flow.getId() + ":" + flow.getCurrentNode(), record);
|
||||
if (Boolean.FALSE.equals(isMember)) {
|
||||
redisTemplate.opsForSet().add(prefixFlag + flow.getId() + ":" + flow.getCurrentNode(), record);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 未完成当前节点审批任务的人
|
||||
List<String> collected = nodeUsers.stream()
|
||||
.filter(element -> !records.contains(element))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
collected.forEach(element -> {
|
||||
// 检查redis是否存在该待办节点
|
||||
Boolean isMember = redisTemplate.opsForSet().isMember(todoFlag + element, flow.getId());
|
||||
log.info("{}{} is member: {}", todoFlag + element, flow.getId(), isMember);
|
||||
if (Boolean.FALSE.equals(isMember)) {
|
||||
redisTemplate.opsForSet().add(todoFlag + element, flow.getId());
|
||||
log.info("{}{} is added", todoFlag, element);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private List<String> getNodeUsers(ApprovalFlow flow, String node) {
|
||||
switch (node) {
|
||||
case "PROOFREAD": return JSON.parseArray(flow.getProofreadUsers()).toJavaList(String.class);
|
||||
case "REVIEW": return JSON.parseArray(flow.getReviewUsers()).toJavaList(String.class);
|
||||
case "COUNTERSIGN": return JSON.parseArray(flow.getCountersignUsers()).toJavaList(String.class);
|
||||
case "APPROVE": return JSON.parseArray(flow.getApproveUsers()).toJavaList(String.class);
|
||||
default: return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,7 @@
|
||||
package com.xdap.self_development.service;
|
||||
|
||||
import com.definesys.mpaas.query.db.PageQueryResult;
|
||||
import com.xdap.self_development.controller.form.BenchmarkingReportPageForm;
|
||||
import com.xdap.self_development.controller.form.HandleApprovalRequest;
|
||||
import com.xdap.self_development.controller.form.SaveBenchmarkingReportForm;
|
||||
import com.xdap.self_development.controller.form.UpdateBenchmarkingReportForm;
|
||||
import com.xdap.self_development.controller.form.*;
|
||||
import com.xdap.self_development.pojo.BenchmarkingReport;
|
||||
import com.xdap.self_development.pojo.view.ApprovalFlowView;
|
||||
import com.xdap.self_development.pojo.view.TodoAndReportView;
|
||||
@ -17,9 +14,11 @@ import java.util.List;
|
||||
public interface BenchmarkingReportService {
|
||||
PageQueryResult<TodoAndReportView> getBenchmarkingReportByCondition(@Valid BenchmarkingReportPageForm form);
|
||||
|
||||
void saveBenchmarkingReport(@Valid SaveBenchmarkingReportForm form);
|
||||
void insertReport(@Valid SaveBenchmarkingReportForm form);
|
||||
|
||||
void restartReportApproval(@Valid UpdateBenchmarkingReportForm form);
|
||||
void startReportApproval(ApprovalPersonForm form);
|
||||
|
||||
void updateReport(@Valid UpdateBenchmarkingReportForm form);
|
||||
|
||||
void handleReportApproval(@Valid HandleApprovalRequest request);
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ public interface TemplateService {
|
||||
MyResponse importTemplate(MultipartFile file, String templateRowId, String userId);
|
||||
|
||||
void processSheetData(List<Parameter> dataList, String sheetName,
|
||||
String templateRowId, String createBy, MyResponse problems,Integer maxOrder);
|
||||
String templateRowId, String createBy, MyResponse problems);
|
||||
|
||||
void insertTemplate(InsertTemplateForm form);
|
||||
|
||||
|
||||
@ -7,10 +7,7 @@ import com.definesys.mpaas.query.db.PageQueryResult;
|
||||
import com.xdap.runtime.service.RuntimeAppContextService;
|
||||
import com.xdap.self_development.common.UserPermissionGetter;
|
||||
import com.xdap.self_development.config.BusinessDatabase;
|
||||
import com.xdap.self_development.controller.form.BenchmarkingReportPageForm;
|
||||
import com.xdap.self_development.controller.form.HandleApprovalRequest;
|
||||
import com.xdap.self_development.controller.form.SaveBenchmarkingReportForm;
|
||||
import com.xdap.self_development.controller.form.UpdateBenchmarkingReportForm;
|
||||
import com.xdap.self_development.controller.form.*;
|
||||
import com.xdap.self_development.exception.CommonException;
|
||||
import com.xdap.self_development.feign.ApaasMyTokenFeign;
|
||||
import com.xdap.self_development.feign.dto.AppTokenDTO;
|
||||
@ -37,6 +34,7 @@ import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class BenchmarkingReportServiceImpl implements BenchmarkingReportService {
|
||||
@ -63,55 +61,6 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
private static final String FLOW_LOCK_PREFIX = "report:lock:";
|
||||
private static final int FLOW_LOCK_EXPIRE_SECONDS = 15;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = CommonException.class)
|
||||
public void saveBenchmarkingReport(SaveBenchmarkingReportForm form) {
|
||||
BenchmarkingReport report = new BenchmarkingReport();
|
||||
// 1. 创建对标报告并保存
|
||||
BeanUtils.copyProperties(form, report);
|
||||
report.setFilePath(form.getFileUrl() == null ? "" : form.getFileUrl());
|
||||
report.setUploadTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||
report.setStatus("APPROVING");
|
||||
report.setCreateBy(form.getUserId());
|
||||
report.setIsDelete(0);
|
||||
bd.getBusinessDatabase().doInsert(report);
|
||||
// 2. 创建审批流程
|
||||
ApprovalFlow flow = new ApprovalFlow();
|
||||
flow.setTemplateId(report.getId());
|
||||
flow.setCurrentNode("PROOFREAD");
|
||||
flow.setFlowStatus("APPROVING");
|
||||
flow.setProofreadUsers(JSON.toJSONString(form.getProofreadUsers()));
|
||||
flow.setReviewUsers(JSON.toJSONString(form.getReviewUsers()));
|
||||
flow.setCountersignUsers(JSON.toJSONString(form.getCountersignUsers()));
|
||||
flow.setApproveUsers(JSON.toJSONString(form.getApproveUsers()));
|
||||
flow.setCreateBy(form.getUserId());
|
||||
flow.setCreatedTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||
flow.setFlowType(2); // 设置为报告审批流程
|
||||
flow.setExplanation(form.getExplanation());
|
||||
bd.getBusinessDatabase().doInsert(flow);
|
||||
|
||||
// 新增待办
|
||||
List<TodoTaskPojo> list = new ArrayList<>();
|
||||
for (String person : form.getProofreadUsers()) {
|
||||
TodoTaskPojo todoTask = new TodoTaskPojo();
|
||||
todoTask.setCreatedById(form.getUserId());
|
||||
todoTask.setCreatedBy(xdapDeptUsersService.selectUserByID(form.getUserId()).getUsername());
|
||||
todoTask.setCurrentNode(getNodeName(flow.getCurrentNode()));
|
||||
todoTask.setDataType("-");
|
||||
todoTask.setDocumentNo(flow.getId());
|
||||
todoTask.setCreationDate(Timestamp.valueOf(LocalDateTime.now()));
|
||||
todoTask.setIsDelete(0);
|
||||
todoTask.setModelId(report.getId());
|
||||
todoTask.setModelName(report.getProjectName()+"对标报告");
|
||||
todoTask.setProcessTitle("对标报告审核");
|
||||
todoTask.setStatusCode(flow.getFlowStatus());
|
||||
todoTask.setVersionNumber(1);
|
||||
todoTask.setOwnerId(person);
|
||||
list.add(todoTask);
|
||||
}
|
||||
bd.getBusinessDatabase().doBatchInsert(list);
|
||||
}
|
||||
|
||||
private String getNodeName(String node) {
|
||||
switch (node) {
|
||||
case "PROOFREAD": return "校对";
|
||||
@ -121,57 +70,6 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restartReportApproval(UpdateBenchmarkingReportForm form) {
|
||||
bd.getBusinessDatabase()
|
||||
.eq("id", form.getReportId())
|
||||
.update("is_delete", 1)
|
||||
.doUpdate(BenchmarkingReport.class);
|
||||
BenchmarkingReport report = new BenchmarkingReport();
|
||||
BeanUtils.copyProperties(form, report);
|
||||
report.setFilePath(form.getFileUrl() == null ? "" : form.getFileUrl());
|
||||
report.setUploadTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||
report.setStatus("APPROVING");
|
||||
report.setCreateBy(form.getCreateBy());
|
||||
report.setIsDelete(0);
|
||||
bd.getBusinessDatabase().doInsert(report);
|
||||
|
||||
ApprovalFlow flow = new ApprovalFlow();
|
||||
flow.setTemplateId(report.getId());
|
||||
flow.setCurrentNode("PROOFREAD");
|
||||
flow.setFlowStatus("APPROVING");
|
||||
flow.setProofreadUsers(JSON.toJSONString(form.getProofreadUsers()));
|
||||
flow.setReviewUsers(JSON.toJSONString(form.getReviewUsers()));
|
||||
flow.setCountersignUsers(JSON.toJSONString(form.getCountersignUsers()));
|
||||
flow.setApproveUsers(JSON.toJSONString(form.getApproveUsers()));
|
||||
flow.setCreateBy(form.getCreateBy());
|
||||
flow.setCreatedTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||
flow.setFlowType(2); // 设置为报告审批流程
|
||||
flow.setExplanation(form.getExplanation());
|
||||
bd.getBusinessDatabase().doInsert(flow);
|
||||
|
||||
List<TodoTaskPojo> list = new ArrayList<>();
|
||||
for (String person : form.getProofreadUsers()) {
|
||||
TodoTaskPojo todoTask = new TodoTaskPojo();
|
||||
todoTask.setCreatedById(form.getCreateBy());
|
||||
todoTask.setCreatedBy(xdapDeptUsersService.selectUserByID(form.getCreateBy()).getUsername());
|
||||
todoTask.setCurrentNode(getNodeName(flow.getCurrentNode()));
|
||||
todoTask.setDataType("-");
|
||||
todoTask.setDocumentNo(flow.getId());
|
||||
todoTask.setCreationDate(Timestamp.valueOf(LocalDateTime.now()));
|
||||
todoTask.setIsDelete(0);
|
||||
todoTask.setModelId(report.getId());
|
||||
todoTask.setModelName(report.getProjectName()+"对标报告");
|
||||
todoTask.setProcessTitle("对标报告审核");
|
||||
todoTask.setStatusCode(flow.getFlowStatus());
|
||||
todoTask.setVersionNumber(1);
|
||||
todoTask.setOwnerId(person);
|
||||
list.add(todoTask);
|
||||
}
|
||||
bd.getBusinessDatabase().doBatchInsert(list);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String uploadFile(MultipartFile file, String userId) {
|
||||
String currentTenantId = runtimeAppContextService.getCurrentTenantId();
|
||||
@ -245,6 +143,79 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertReport(SaveBenchmarkingReportForm form) {
|
||||
BenchmarkingReport report = new BenchmarkingReport();
|
||||
BeanUtils.copyProperties(form, report);
|
||||
report.setFilePath(form.getFileUrl() == null ? "" : form.getFileUrl());
|
||||
report.setUploadTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||
// 草稿状态
|
||||
report.setStatus("DRAFT");
|
||||
report.setCreateBy(form.getUserId());
|
||||
report.setIsDelete(0);
|
||||
bd.getBusinessDatabase().doInsert(report);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startReportApproval(ApprovalPersonForm form) {
|
||||
BenchmarkingReport report = bd.getBusinessDatabase()
|
||||
.eq("id", form.getReportId())
|
||||
.doQueryFirst(BenchmarkingReport.class);
|
||||
|
||||
ApprovalFlow flow = new ApprovalFlow();
|
||||
flow.setTemplateId(report.getId());
|
||||
flow.setCurrentNode("PROOFREAD");
|
||||
flow.setFlowStatus("APPROVING");
|
||||
flow.setProofreadUsers(JSON.toJSONString(form.getProofreadUsers()));
|
||||
flow.setReviewUsers(JSON.toJSONString(form.getReviewUsers()));
|
||||
flow.setCountersignUsers(JSON.toJSONString(form.getCountersignUsers()));
|
||||
flow.setApproveUsers(JSON.toJSONString(form.getApproveUsers()));
|
||||
flow.setCreateBy(form.getUserId());
|
||||
flow.setCreatedTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||
flow.setFlowType(2); // 设置为报告审批流程
|
||||
flow.setExplanation(form.getExplanation());
|
||||
bd.getBusinessDatabase().doInsert(flow);
|
||||
|
||||
List<TodoTaskPojo> list = new ArrayList<>();
|
||||
for (String person : form.getProofreadUsers()) {
|
||||
TodoTaskPojo todoTask = new TodoTaskPojo();
|
||||
todoTask.setCreatedById(form.getUserId());
|
||||
todoTask.setCreatedBy(xdapDeptUsersService.selectUserByID(form.getUserId()).getUsername());
|
||||
todoTask.setCurrentNode(getNodeName(flow.getCurrentNode()));
|
||||
todoTask.setDataType("-");
|
||||
todoTask.setDocumentNo(flow.getId());
|
||||
todoTask.setCreationDate(Timestamp.valueOf(LocalDateTime.now()));
|
||||
todoTask.setIsDelete(0);
|
||||
todoTask.setModelId(report.getId());
|
||||
todoTask.setModelName(report.getProjectName()+"对标报告");
|
||||
todoTask.setProcessTitle("对标报告审核");
|
||||
todoTask.setStatusCode(flow.getFlowStatus());
|
||||
todoTask.setVersionNumber(1);
|
||||
todoTask.setOwnerId(person);
|
||||
list.add(todoTask);
|
||||
}
|
||||
bd.getBusinessDatabase().doBatchInsert(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateReport(UpdateBenchmarkingReportForm form) {
|
||||
BenchmarkingReport report = bd.getBusinessDatabase()
|
||||
.eq("id", form.getReportId())
|
||||
.doQueryFirst(BenchmarkingReport.class);
|
||||
if (!Objects.equals(report.getStatus(), "DRAFT")) {
|
||||
throw new CommonException("报告非草稿状态不可修改");
|
||||
}
|
||||
if (!Objects.equals(report.getCreateBy(), form.getUserId())) {
|
||||
throw new CommonException("非创建者不能修改");
|
||||
}
|
||||
BeanUtils.copyProperties(form, report);
|
||||
report.setFilePath(form.getFileUrl() == null ? "" : form.getFileUrl());
|
||||
report.setUploadTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||
bd.getBusinessDatabase()
|
||||
.eq("id", report.getId())
|
||||
.doUpdate(report);
|
||||
}
|
||||
|
||||
private void setCurrentApprovers(PageQueryResult<TodoAndReportView> result) {
|
||||
result.getResult().forEach(item -> {
|
||||
ApprovalXdapUsers approvalXdapUser = bd.getBusinessDatabase()
|
||||
@ -308,77 +279,97 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
ApprovalFlowView approvalFlowView = new ApprovalFlowView();
|
||||
ApprovalFlow flow = bd.getBusinessDatabase()
|
||||
.eq("id", flowId)
|
||||
.eq("flow_type", 2)
|
||||
.eq("flow_type", 1)
|
||||
.doQueryFirst(ApprovalFlow.class);
|
||||
|
||||
if (flow == null) {
|
||||
return approvalFlowView;
|
||||
}
|
||||
approvalFlowView.setExplanation(flow.getExplanation());
|
||||
List<ApprovalNodeView> proofread = getNodeList(flowId, "PROOFREAD");
|
||||
if (proofread.isEmpty()) {
|
||||
List<ApprovalNodeView> list = new ArrayList<>();
|
||||
StringBuilder usernames = new StringBuilder();
|
||||
JSON.parseArray(flow.getProofreadUsers()).toJavaList(String.class).forEach(id -> {
|
||||
ApprovalXdapUsers user = bd.getBusinessDatabase()
|
||||
.eq("id", id)
|
||||
.doQueryFirst(ApprovalXdapUsers.class);
|
||||
usernames.append(user.getUsername()).append(" ");
|
||||
});
|
||||
ApprovalNodeView approvalNodeView = new ApprovalNodeView();
|
||||
approvalNodeView.setNode("APPROVING");
|
||||
approvalNodeView.setUserName(usernames.toString());
|
||||
approvalNodeView.setResult("APPROVING");
|
||||
approvalNodeView.setApprovalTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||
list.add(approvalNodeView);
|
||||
approvalFlowView.setProofreadNodes(list);
|
||||
approvalFlowView.setReviewNodes(new ArrayList<>());
|
||||
approvalFlowView.setApproveNodes(new ArrayList<>());
|
||||
approvalFlowView.setFlowStatus(flow.getFlowStatus());
|
||||
if (!"APPROVING".equals(flow.getFlowStatus())) {
|
||||
setAllCompletedNodes(approvalFlowView, flow);
|
||||
return approvalFlowView;
|
||||
}
|
||||
approvalFlowView.setProofreadNodes(proofread);
|
||||
List<ApprovalNodeView> review = getNodeList(flowId, "REVIEW");
|
||||
if (review.isEmpty()) {
|
||||
List<ApprovalNodeView> list = new ArrayList<>();
|
||||
StringBuilder usernames = new StringBuilder();
|
||||
JSON.parseArray(flow.getReviewUsers()).toJavaList(String.class).forEach(id -> {
|
||||
ApprovalXdapUsers user = bd.getBusinessDatabase()
|
||||
.eq("id", id)
|
||||
.doQueryFirst(ApprovalXdapUsers.class);
|
||||
usernames.append(user.getUsername()).append(" ");
|
||||
});
|
||||
ApprovalNodeView approvalNodeView = new ApprovalNodeView();
|
||||
approvalNodeView.setNode("APPROVING");
|
||||
approvalNodeView.setUserName(usernames.toString());
|
||||
approvalNodeView.setResult("APPROVING");
|
||||
approvalNodeView.setApprovalTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||
list.add(approvalNodeView);
|
||||
approvalFlowView.setReviewNodes(list);
|
||||
approvalFlowView.setApproveNodes(new ArrayList<>());
|
||||
approvalFlowView.setFlowStatus(flow.getFlowStatus());
|
||||
processApprovalNodes(approvalFlowView, flow);
|
||||
return approvalFlowView;
|
||||
}
|
||||
approvalFlowView.setReviewNodes(review);
|
||||
List<ApprovalNodeView> approve = getNodeList(flowId, "APPROVE");
|
||||
if (approve.isEmpty()) {
|
||||
List<ApprovalNodeView> list = new ArrayList<>();
|
||||
StringBuilder usernames = new StringBuilder();
|
||||
JSON.parseArray(flow.getApproveUsers()).toJavaList(String.class).forEach(id -> {
|
||||
ApprovalXdapUsers user = bd.getBusinessDatabase()
|
||||
.eq("id", id)
|
||||
.doQueryFirst(ApprovalXdapUsers.class);
|
||||
usernames.append(user.getUsername()).append(" ");
|
||||
});
|
||||
ApprovalNodeView approvalNodeView = new ApprovalNodeView();
|
||||
approvalNodeView.setNode("APPROVING");
|
||||
approvalNodeView.setUserName(usernames.toString());
|
||||
approvalNodeView.setResult("APPROVING");
|
||||
approvalNodeView.setApprovalTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||
list.add(approvalNodeView);
|
||||
approvalFlowView.setApproveNodes(list);
|
||||
approvalFlowView.setFlowStatus(flow.getFlowStatus());
|
||||
return approvalFlowView;
|
||||
|
||||
private void setAllCompletedNodes(ApprovalFlowView view, ApprovalFlow flow) {
|
||||
view.setProofreadNodes(getNodeList(flow.getId(), "PROOFREAD"));
|
||||
view.setReviewNodes(getNodeList(flow.getId(), "REVIEW"));
|
||||
view.setApproveNodes(getNodeList(flow.getId(), "APPROVE"));
|
||||
}
|
||||
approvalFlowView.setApproveNodes(approve);
|
||||
approvalFlowView.setFlowStatus(flow.getFlowStatus());
|
||||
return approvalFlowView;
|
||||
|
||||
private void processApprovalNodes(ApprovalFlowView view, ApprovalFlow flow) {
|
||||
// 处理校对节点
|
||||
List<ApprovalNodeView> proofreadNodes = getNodeList(flow.getId(), "PROOFREAD");
|
||||
if (proofreadNodes.isEmpty()) {
|
||||
view.setProofreadNodes(createApprovingNode(flow.getProofreadUsers()));
|
||||
view.setReviewNodes(new ArrayList<>());
|
||||
view.setApproveNodes(new ArrayList<>());
|
||||
return;
|
||||
}
|
||||
view.setProofreadNodes(proofreadNodes);
|
||||
|
||||
// 处理审核节点
|
||||
List<ApprovalNodeView> reviewNodes = getNodeList(flow.getId(), "REVIEW");
|
||||
if (reviewNodes.isEmpty()) {
|
||||
view.setReviewNodes(createApprovingNode(flow.getReviewUsers()));
|
||||
view.setApproveNodes(new ArrayList<>());
|
||||
return;
|
||||
}
|
||||
view.setReviewNodes(reviewNodes);
|
||||
|
||||
List<ApprovalNodeView> approveNodes = getNodeList(flow.getId(), "APPROVE");
|
||||
if (approveNodes.isEmpty()) {
|
||||
view.setApproveNodes(createApprovingNode(flow.getApproveUsers()));
|
||||
} else {
|
||||
view.setApproveNodes(approveNodes);
|
||||
}
|
||||
}
|
||||
|
||||
private List<ApprovalNodeView> createApprovingNode(String userJsonArray) {
|
||||
List<ApprovalNodeView> list = new ArrayList<>();
|
||||
|
||||
if (userJsonArray == null || userJsonArray.trim().isEmpty()) {
|
||||
return list;
|
||||
}
|
||||
|
||||
List<String> userIds = JSON.parseArray(userJsonArray).toJavaList(String.class);
|
||||
if (userIds.isEmpty()) {
|
||||
return list;
|
||||
}
|
||||
Map<String, ApprovalXdapUsers> usersMap = batchQueryUsers(userIds);
|
||||
StringBuilder usernames = new StringBuilder();
|
||||
for (String id : userIds) {
|
||||
ApprovalXdapUsers user = usersMap.get(id);
|
||||
if (user != null) {
|
||||
usernames.append(user.getUsername()).append(" ");
|
||||
}
|
||||
}
|
||||
if (usernames.length() > 0) {
|
||||
ApprovalNodeView node = new ApprovalNodeView();
|
||||
node.setNode("APPROVING");
|
||||
node.setUserName(usernames.toString().trim());
|
||||
node.setResult("APPROVING");
|
||||
node.setApprovalTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||
list.add(node);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private Map<String, ApprovalXdapUsers> batchQueryUsers(List<String> userIds) {
|
||||
if (userIds == null || userIds.isEmpty()) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
List<ApprovalXdapUsers> users = bd.getBusinessDatabase()
|
||||
.in("id", userIds)
|
||||
.doQuery(ApprovalXdapUsers.class);
|
||||
|
||||
return users.stream()
|
||||
.collect(Collectors.toMap(ApprovalXdapUsers::getId, user -> user));
|
||||
}
|
||||
|
||||
private List<ApprovalNodeView> getNodeList(String flowId, String node) {
|
||||
|
||||
@ -97,7 +97,7 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
|
||||
)
|
||||
));
|
||||
ArrayList<Template> templatesMax = new ArrayList<>(latestTemplateMap.values());
|
||||
Map<String, Integer> systemOrderMap = templatesMax.stream()
|
||||
Map<String, Long> systemOrderMap = templatesMax.stream()
|
||||
.collect(Collectors.toMap(
|
||||
Template::getTemplateName, // key: 子系统编码
|
||||
Template::getOrderNum, // value: 排序号
|
||||
@ -112,7 +112,7 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
|
||||
)
|
||||
));
|
||||
if (ObjectUtils.isNotEmpty(modelID)) {
|
||||
systemOrderMap.put("整车参数", 0);
|
||||
systemOrderMap.put("整车参数", (long) 0);
|
||||
DataEntryEngineModelPojo dataEntryEngineModelPojo = dataEntryEngineModelService.selectBymodelId(modelID);
|
||||
//状态代号
|
||||
String productNumber = dataEntryEngineModelPojo.getProductNumber();
|
||||
@ -156,7 +156,7 @@ public class EngineParamDetailServiceImpl implements EngineParamDetailService {
|
||||
}
|
||||
HashMap<String, List<String>> sortedCollect2 = collect.entrySet().stream()
|
||||
.sorted(Comparator.comparing(entry ->
|
||||
systemOrderMap.getOrDefault(entry.getKey(), Integer.MAX_VALUE)
|
||||
systemOrderMap.getOrDefault(entry.getKey(), Long.MAX_VALUE)
|
||||
))
|
||||
.collect(Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
|
||||
@ -284,154 +284,136 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApprovalFlowView getApprovalProcess(
|
||||
ApprovalFlowForm form
|
||||
) {
|
||||
public ApprovalFlowView getApprovalProcess(ApprovalFlowForm form) {
|
||||
ApprovalFlowView approvalFlowView = new ApprovalFlowView();
|
||||
|
||||
// 查询流程基本信息
|
||||
ApprovalFlow flow = bd.getBusinessDatabase()
|
||||
.eq("id", form.getFlowId())
|
||||
.eq("flow_type", 1)
|
||||
.doQueryFirst(ApprovalFlow.class);
|
||||
|
||||
if (flow == null) {
|
||||
return approvalFlowView;
|
||||
}
|
||||
approvalFlowView.setExplanation(flow.getExplanation());
|
||||
approvalFlowView.setFlowStatus(flow.getFlowStatus());
|
||||
|
||||
// 初始化所有节点列表
|
||||
approvalFlowView.setProofreadNodes(new ArrayList<>());
|
||||
approvalFlowView.setReviewNodes(new ArrayList<>());
|
||||
approvalFlowView.setCountersignNodes(new ArrayList<>());
|
||||
approvalFlowView.setApproveNodes(new ArrayList<>());
|
||||
|
||||
// 第一步:获取校对节点
|
||||
List<ApprovalNodeView> proofread = getNodeList(form.getFlowId(), "PROOFREAD");
|
||||
if (!proofread.isEmpty()) {
|
||||
approvalFlowView.setProofreadNodes(proofread);
|
||||
} else if ("APPROVING".equals(flow.getFlowStatus())) {
|
||||
// 如果流程还在审批中且没有校对记录,添加待处理节点
|
||||
approvalFlowView.setProofreadNodes(createPendingNodeList(flow.getProofreadUsers(), "PROOFREAD"));
|
||||
return approvalFlowView;
|
||||
}
|
||||
|
||||
// 第二步:如果流程还在审批中,继续查询审阅节点
|
||||
if (!"APPROVING".equals(flow.getFlowStatus())) {
|
||||
setAllCompletedNodes(approvalFlowView, flow);
|
||||
return approvalFlowView;
|
||||
}
|
||||
processApprovalNodes(approvalFlowView, flow);
|
||||
return approvalFlowView;
|
||||
}
|
||||
|
||||
List<ApprovalNodeView> review = getNodeList(flow.getId(), "REVIEW");
|
||||
if (!review.isEmpty()) {
|
||||
approvalFlowView.setReviewNodes(review);
|
||||
private void setAllCompletedNodes(ApprovalFlowView view, ApprovalFlow flow) {
|
||||
view.setProofreadNodes(getNodeList(flow.getId(), "PROOFREAD"));
|
||||
view.setReviewNodes(getNodeList(flow.getId(), "REVIEW"));
|
||||
view.setCountersignNodes(getNodeList(flow.getId(), "COUNTERSIGN"));
|
||||
view.setApproveNodes(getNodeList(flow.getId(), "APPROVE"));
|
||||
}
|
||||
|
||||
private void processApprovalNodes(ApprovalFlowView view, ApprovalFlow flow) {
|
||||
// 处理校对节点
|
||||
List<ApprovalNodeView> proofreadNodes = getNodeList(flow.getId(), "PROOFREAD");
|
||||
if (proofreadNodes.isEmpty()) {
|
||||
view.setProofreadNodes(createApprovingNode(flow.getProofreadUsers()));
|
||||
view.setReviewNodes(new ArrayList<>());
|
||||
view.setCountersignNodes(new ArrayList<>());
|
||||
view.setApproveNodes(new ArrayList<>());
|
||||
return;
|
||||
}
|
||||
view.setProofreadNodes(proofreadNodes);
|
||||
|
||||
// 处理审核节点
|
||||
List<ApprovalNodeView> reviewNodes = getNodeList(flow.getId(), "REVIEW");
|
||||
if (reviewNodes.isEmpty()) {
|
||||
view.setReviewNodes(createApprovingNode(flow.getReviewUsers()));
|
||||
view.setCountersignNodes(new ArrayList<>());
|
||||
view.setApproveNodes(new ArrayList<>());
|
||||
return;
|
||||
}
|
||||
view.setReviewNodes(reviewNodes);
|
||||
|
||||
// 处理会签节点
|
||||
List<String> countersignUserIds = JSON.parseArray(flow.getCountersignUsers()).toJavaList(String.class);
|
||||
if (countersignUserIds.isEmpty()) {
|
||||
view.setCountersignNodes(new ArrayList<>());
|
||||
} else {
|
||||
// 添加待处理的审阅节点
|
||||
approvalFlowView.setReviewNodes(createPendingNodeList(flow.getReviewUsers(), "REVIEW"));
|
||||
return approvalFlowView;
|
||||
}
|
||||
|
||||
// 第三步:如果流程还在审批中,继续查询会签节点
|
||||
if (!"APPROVING".equals(flow.getFlowStatus())) {
|
||||
return approvalFlowView;
|
||||
}
|
||||
|
||||
List<String> countersignUsers = JSON.parseArray(flow.getCountersignUsers()).toJavaList(String.class);
|
||||
if (!countersignUsers.isEmpty()) {
|
||||
List<ApprovalNodeView> countersign = getNodeList(flow.getId(), "COUNTERSIGN");
|
||||
|
||||
if (countersign.isEmpty()) {
|
||||
// 添加待处理的会签节点
|
||||
approvalFlowView.setCountersignNodes(createPendingNodeList(flow.getCountersignUsers(), "COUNTERSIGN"));
|
||||
return approvalFlowView;
|
||||
} else if (countersign.size() < countersignUsers.size()) {
|
||||
// 部分会签完成,添加未处理的会签节点
|
||||
approvalFlowView.setCountersignNodes(getPartialCountersignNodes(countersign, countersignUsers));
|
||||
return approvalFlowView;
|
||||
List<ApprovalNodeView> countersignNodes = getNodeList(flow.getId(), "COUNTERSIGN");
|
||||
if (countersignNodes.isEmpty()) {
|
||||
view.setCountersignNodes(createApprovingNode(flow.getCountersignUsers()));
|
||||
view.setApproveNodes(new ArrayList<>());
|
||||
return;
|
||||
} else {
|
||||
approvalFlowView.setCountersignNodes(countersign);
|
||||
}
|
||||
}
|
||||
|
||||
// 第四步:如果流程还在审批中,继续查询批准节点
|
||||
if (!"APPROVING".equals(flow.getFlowStatus())) {
|
||||
return approvalFlowView;
|
||||
}
|
||||
|
||||
List<ApprovalNodeView> approve = getNodeList(flow.getId(), "APPROVE");
|
||||
if (!approve.isEmpty()) {
|
||||
approvalFlowView.setApproveNodes(approve);
|
||||
if (countersignNodes.size() == countersignUserIds.size()) {
|
||||
view.setCountersignNodes(countersignNodes);
|
||||
} else {
|
||||
// 添加待处理的批准节点
|
||||
approvalFlowView.setApproveNodes(createPendingNodeList(flow.getApproveUsers(), "APPROVE"));
|
||||
}
|
||||
|
||||
return approvalFlowView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建待处理节点列表
|
||||
*/
|
||||
private List<ApprovalNodeView> createPendingNodeList(
|
||||
String userJson, String nodeType
|
||||
) {
|
||||
List<ApprovalNodeView> list = new ArrayList<>();
|
||||
StringBuilder usernames = new StringBuilder();
|
||||
|
||||
JSON.parseArray(userJson).toJavaList(String.class).forEach(id -> {
|
||||
ApprovalXdapUsers user = bd.getBusinessDatabase()
|
||||
.eq("id", id)
|
||||
.doQueryFirst(ApprovalXdapUsers.class);
|
||||
usernames.append(user.getUsername()).append(" ");
|
||||
});
|
||||
|
||||
ApprovalNodeView approvalNodeView = new ApprovalNodeView();
|
||||
approvalNodeView.setNode(nodeType);
|
||||
approvalNodeView.setUserName(usernames.toString().trim());
|
||||
approvalNodeView.setResult("APPROVING");
|
||||
approvalNodeView.setApprovalTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||
list.add(approvalNodeView);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部分完成的会签节点(包含已处理和未处理的)
|
||||
*/
|
||||
private List<ApprovalNodeView> getPartialCountersignNodes(
|
||||
List<ApprovalNodeView> existingCountersign,
|
||||
List<String> allCountersignUserIds
|
||||
) {
|
||||
|
||||
List<String> completedUserIds = existingCountersign.stream()
|
||||
List<String> completedUserIds = countersignNodes.stream()
|
||||
.map(ApprovalNodeView::getUserId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 找出未处理的用户ID
|
||||
List<String> pendingUserIds = allCountersignUserIds.stream()
|
||||
List<String> pendingUserIds = countersignUserIds.stream()
|
||||
.filter(id -> !completedUserIds.contains(id))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 获取未处理用户的用户名
|
||||
StringBuilder pendingUsernames = new StringBuilder();
|
||||
pendingUserIds.forEach(id -> {
|
||||
ApprovalXdapUsers user = bd.getBusinessDatabase()
|
||||
.eq("id", id)
|
||||
.doQueryFirst(ApprovalXdapUsers.class);
|
||||
if (user != null) {
|
||||
pendingUsernames.append(user.getUsername()).append(" ");
|
||||
if (!pendingUserIds.isEmpty()) {
|
||||
countersignNodes.addAll(createApprovingNode(JSON.toJSONString(pendingUserIds)));
|
||||
}
|
||||
view.setCountersignNodes(countersignNodes);
|
||||
view.setApproveNodes(new ArrayList<>());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 创建待处理节点
|
||||
ApprovalNodeView pendingNode = new ApprovalNodeView();
|
||||
pendingNode.setNode("COUNTERSIGN");
|
||||
pendingNode.setUserName(pendingUsernames.toString().trim());
|
||||
pendingNode.setResult("APPROVING");
|
||||
pendingNode.setApprovalTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||
List<ApprovalNodeView> approveNodes = getNodeList(flow.getId(), "APPROVE");
|
||||
if (approveNodes.isEmpty()) {
|
||||
view.setApproveNodes(createApprovingNode(flow.getApproveUsers()));
|
||||
} else {
|
||||
view.setApproveNodes(approveNodes);
|
||||
}
|
||||
}
|
||||
|
||||
// 合并已处理和待处理节点
|
||||
List<ApprovalNodeView> allNodes = new ArrayList<>(existingCountersign);
|
||||
allNodes.add(pendingNode);
|
||||
private List<ApprovalNodeView> createApprovingNode(String userJsonArray) {
|
||||
List<ApprovalNodeView> list = new ArrayList<>();
|
||||
|
||||
return allNodes;
|
||||
if (userJsonArray == null || userJsonArray.trim().isEmpty()) {
|
||||
return list;
|
||||
}
|
||||
|
||||
List<String> userIds = JSON.parseArray(userJsonArray).toJavaList(String.class);
|
||||
if (userIds.isEmpty()) {
|
||||
return list;
|
||||
}
|
||||
Map<String, ApprovalXdapUsers> usersMap = batchQueryUsers(userIds);
|
||||
StringBuilder usernames = new StringBuilder();
|
||||
for (String id : userIds) {
|
||||
ApprovalXdapUsers user = usersMap.get(id);
|
||||
if (user != null) {
|
||||
usernames.append(user.getUsername()).append(" ");
|
||||
}
|
||||
}
|
||||
if (usernames.length() > 0) {
|
||||
ApprovalNodeView node = new ApprovalNodeView();
|
||||
node.setNode("APPROVING");
|
||||
node.setUserName(usernames.toString().trim());
|
||||
node.setResult("APPROVING");
|
||||
node.setApprovalTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||
list.add(node);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private Map<String, ApprovalXdapUsers> batchQueryUsers(List<String> userIds) {
|
||||
if (userIds == null || userIds.isEmpty()) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
List<ApprovalXdapUsers> users = bd.getBusinessDatabase()
|
||||
.in("id", userIds)
|
||||
.doQuery(ApprovalXdapUsers.class);
|
||||
|
||||
return users.stream()
|
||||
.collect(Collectors.toMap(ApprovalXdapUsers::getId, user -> user));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -480,7 +462,6 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
|
||||
.eq("id", approvalNodeView.getUserId())
|
||||
.doQueryFirst(ApprovalXdapUsers.class);
|
||||
approvalNodeView.setUserName(user.getUsername());
|
||||
approvalNodeView.setUserId(null);
|
||||
});
|
||||
}
|
||||
return list;
|
||||
|
||||
@ -28,6 +28,7 @@ import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@ -62,7 +63,7 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
// 创建新模板
|
||||
Template newTemplate = new Template(
|
||||
form.getTemplateName(), 1, "DRAFT", Timestamp.valueOf(LocalDateTime.now()),
|
||||
null, form.getUserId(), getMaxOrder()
|
||||
null, form.getUserId(), System.currentTimeMillis()
|
||||
);
|
||||
|
||||
bd.getBusinessDatabase().doInsert(newTemplate);
|
||||
@ -79,24 +80,36 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
|
||||
if (template != null) {
|
||||
if (Objects.equals(form.getTemplateName(), template.getTemplateName()) && form.getOrderNum() != null) {
|
||||
List<Long> sorted = bd.getBusinessDatabase()
|
||||
.groupBy("order_num")
|
||||
.orderBy("order_num", "asc")
|
||||
.doQuery(Template.class)
|
||||
.stream().map(Template::getOrderNum)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Long num = sorted.get(form.getOrderNum());
|
||||
if (num == null) {
|
||||
num = sorted.get(sorted.size() - 1);
|
||||
}
|
||||
|
||||
List<String> originalTemplateId = bd.getBusinessDatabase()
|
||||
.eq("order_num", template.getOrderNum())
|
||||
.doQuery(Template.class).stream().map(Template::getId)
|
||||
.collect(Collectors.toList());
|
||||
List<String> updateTemplateId = bd.getBusinessDatabase()
|
||||
.eq("order_num", form.getOrderNum())
|
||||
.eq("order_num", num)
|
||||
.doQuery(Template.class).stream().map(Template::getId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (updateTemplateId.isEmpty()) {
|
||||
bd.getBusinessDatabase()
|
||||
.in("id", updateTemplateId)
|
||||
.update("order_num", getMaxOrder())
|
||||
.update("order_num", template.getOrderNum())
|
||||
.doUpdate(Template.class);
|
||||
} else {
|
||||
bd.getBusinessDatabase()
|
||||
.in("id", updateTemplateId)
|
||||
.update("order_num", template.getOrderNum())
|
||||
.update("order_num", num)
|
||||
.doUpdate(Template.class);
|
||||
bd.getBusinessDatabase()
|
||||
.in("id", originalTemplateId)
|
||||
@ -110,7 +123,7 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
|
||||
Template newTemplate = new Template(
|
||||
form.getTemplateName(), 1, "DRAFT", Timestamp.valueOf(LocalDateTime.now()),
|
||||
null, form.getUserId(), 1
|
||||
null, form.getUserId(), System.currentTimeMillis()
|
||||
);
|
||||
|
||||
bd.getBusinessDatabase()
|
||||
@ -140,7 +153,7 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
EasyExcel.read(
|
||||
inputStream,
|
||||
Parameter.class,
|
||||
new SheetDataListener(this, templateRowId, userId, problems, maxOrder)
|
||||
new SheetDataListener(this, templateRowId, userId, problems)
|
||||
).doReadAll();
|
||||
|
||||
} catch (IOException e) {
|
||||
@ -226,7 +239,7 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
|
||||
@Override
|
||||
public void processSheetData(List<Parameter> dataList, String sheetName,
|
||||
String templateRowId, String createBy, MyResponse problems, Integer maxOrder) {
|
||||
String templateRowId, String createBy, MyResponse problems) {
|
||||
if (dataList.isEmpty()) {
|
||||
log.warn("Sheet {} 没有数据", sheetName);
|
||||
return;
|
||||
@ -297,7 +310,7 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
default:
|
||||
lastTemplate = new Template(
|
||||
templateName, lastTemplate.getVersion()+1, "DRAFT",
|
||||
Timestamp.valueOf(LocalDateTime.now()), null, createBy, maxOrder
|
||||
Timestamp.valueOf(LocalDateTime.now()), null, createBy, System.currentTimeMillis()
|
||||
);
|
||||
bd.getBusinessDatabase()
|
||||
.doInsert(lastTemplate);
|
||||
@ -305,7 +318,7 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
} else {
|
||||
lastTemplate = new Template(
|
||||
templateName, 1, "DRAFT", Timestamp.valueOf(LocalDateTime.now()),
|
||||
null, createBy, maxOrder
|
||||
null, createBy, System.currentTimeMillis()
|
||||
);
|
||||
bd.getBusinessDatabase()
|
||||
.doInsert(lastTemplate);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user