修改:对标流程修改和下载全部模板
This commit is contained in:
parent
689e7742a0
commit
4590e404a3
@ -16,10 +16,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@ -120,4 +117,10 @@ public class TemplateController {
|
||||
}
|
||||
templateService.exportTemplate(form, response);
|
||||
}
|
||||
|
||||
// 导出所有模板
|
||||
@GetMapping("/exportMultiple")
|
||||
public void exportMultipleTemplates(HttpServletResponse response) {
|
||||
templateService.exportMultipleTemplates(response);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.xdap.self_development.controller.form;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
@ -9,7 +10,8 @@ import java.util.List;
|
||||
public class ApprovalPersonForm {
|
||||
@NotEmpty(message = "报告不能为空")
|
||||
private String reportId;
|
||||
|
||||
@NotBlank(message = "流程标题不能为空")
|
||||
private String processTitle;
|
||||
@NotEmpty(message = "校对人员不能为空")
|
||||
private List<String> proofreadUsers;
|
||||
@NotEmpty(message = "审核人员不能为空")
|
||||
|
||||
@ -2,13 +2,8 @@ package com.xdap.self_development.controller.form;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class ExportTemplateForm {
|
||||
@NotBlank(message = "请选择模板")
|
||||
private String templateRowId;
|
||||
@NotNull(message = "请选择是否下载空模板")
|
||||
private boolean templateEmpty;
|
||||
}
|
||||
|
||||
@ -27,4 +27,5 @@ public class SaveBenchmarkingReportForm {
|
||||
@NotBlank(message = "发起人不能为空")
|
||||
private String userId;
|
||||
private String fileUrl;
|
||||
private String fileName;
|
||||
}
|
||||
|
||||
@ -40,5 +40,6 @@ public class BenchmarkingReport extends MpaasBasePojo {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Timestamp uploadTime;
|
||||
private String filePath;
|
||||
private String fileName;
|
||||
private String status;
|
||||
}
|
||||
|
||||
@ -10,8 +10,7 @@ import lombok.NoArgsConstructor;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@SQLQuery(value = {
|
||||
@SQL(view = "getLatestTemplateOrder",
|
||||
sql = "SELECT ranked.order_num, ranked.id, ranked.template_name, ranked.version, ranked.status , ranked.created_time, ranked.published_time, xu.username AS \"createBy\" FROM ( SELECT t.*, ROW_NUMBER() OVER (PARTITION BY template_name ORDER BY CASE WHEN status = 'COMPLETE' THEN 1 WHEN status = 'APPROVING' THEN 2 ELSE 3 END, version DESC) AS rn FROM ( SELECT DISTINCT id, template_name, version, status, created_time , published_time, order_num, create_by FROM yfsjglpt_model_template WHERE status IN ('COMPLETE', 'DRAFT', 'APPROVING') ) t ) ranked LEFT JOIN xdap_users xu ON xu.id = ranked.create_by WHERE rn = 1 ORDER BY CASE status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'DRAFT' THEN 3 WHEN 'RETURNED' THEN 4 WHEN 'REJECTED' THEN 5 ELSE 6 END ASC, ranked.order_num DESC"),
|
||||
|
||||
// 查找每个模板的最新版本并且优先级按照已发布、审核中、草稿状态转变(只有这三种状态)
|
||||
@SQL(view = "getLatestTemplate",
|
||||
sql = "SELECT ROW_NUMBER() OVER (ORDER BY CASE ranked.status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'DRAFT' THEN 3 WHEN 'RETURNED' THEN 4 WHEN 'REJECTED' THEN 5 ELSE 6 END ASC, ranked.order_num DESC) AS order_num, ranked.id, ranked.template_name, ranked.version , ranked.status, ranked.created_time, ranked.published_time, xu.username AS \"createBy\" FROM ( SELECT t.*, ROW_NUMBER() OVER (PARTITION BY template_name ORDER BY CASE WHEN status = 'COMPLETE' THEN 1 WHEN status = 'APPROVING' THEN 2 ELSE 3 END, version DESC) AS rn FROM yfsjglpt_model_template t WHERE status IN ('COMPLETE', 'DRAFT', 'APPROVING') ) ranked LEFT JOIN xdap_users xu ON xu.id = ranked.create_by WHERE rn = 1 ORDER BY CASE ranked.status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'DRAFT' THEN 3 WHEN 'RETURNED' THEN 4 WHEN 'REJECTED' THEN 5 ELSE 6 END ASC, ranked.order_num DESC"
|
||||
|
||||
@ -11,7 +11,7 @@ import java.util.List;
|
||||
|
||||
@SQLQuery(value = {
|
||||
@SQL(view = "getAllReportApprovalList",
|
||||
sql = "SELECT af.id AS \"flowId\", r.id AS \"reportId\", r.title AS \"title\", af.flow_status AS \"status\", af.create_by AS \"createBy\" , xu.username AS \"username\", af.created_time AS \"createdTime\" , CASE WHEN current_node = 'PROOFREAD' THEN proofread_users WHEN current_node = 'REVIEW' THEN review_users WHEN current_node = 'COUNTERSIGN' THEN countersign_users WHEN current_node = 'APPROVE' THEN approve_users END AS current_users FROM yfsjglpt_model_approval_flow af JOIN yfsjglpt_model_benchmarking_report r ON af.template_id = r.id LEFT JOIN xdap_users xu ON xu.id = af.create_by WHERE af.flow_type = 2 AND r.title LIKE CONCAT('%', #title, '%') AND af.flow_status LIKE CONCAT('%', #status, '%') AND af.created_time LIKE CONCAT('%', #createdTime, '%') AND xu.username LIKE CONCAT('%', #username, '%') ORDER BY CASE af.flow_status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'DRAFT' THEN 3 WHEN 'REJECTED' THEN 4 ELSE 5 END ASC")
|
||||
sql = "SELECT af.id AS \"flowId\", r.id AS \"reportId\", r.title AS \"title\", af.flow_status AS \"status\", af.create_by AS \"createBy\" , xu.username AS \"username\", af.created_time AS \"createdTime\" , CASE WHEN current_node = 'PROOFREAD' THEN proofread_users WHEN current_node = 'REVIEW' THEN review_users WHEN current_node = 'COUNTERSIGN' THEN countersign_users WHEN current_node = 'APPROVE' THEN approve_users END AS current_users FROM yfsjglpt_model_approval_flow af JOIN yfsjglpt_model_benchmarking_report r ON af.template_id = r.id LEFT JOIN xdap_users xu ON xu.id = af.create_by WHERE af.flow_type = 2 AND r.title LIKE CONCAT('%', #title, '%') AND af.flow_status LIKE CONCAT('%', #status, '%') AND af.created_time LIKE CONCAT('%', #createdTime, '%') AND xu.username LIKE CONCAT('%', #username, '%') ORDER BY CASE af.flow_status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'DRAFT' THEN 3 WHEN 'REJECTED' THEN 4 ELSE 5 END ASC, af.created_time DESC")
|
||||
})
|
||||
@Data
|
||||
public class TodoAndReportListView {
|
||||
|
||||
@ -32,5 +32,6 @@ public class TodoAndReportView {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Timestamp uploadTime;
|
||||
private String filePath;
|
||||
private String fileName;
|
||||
private String status;
|
||||
}
|
||||
|
||||
@ -8,7 +8,6 @@ import com.xdap.self_development.pojo.Template;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
|
||||
public interface TemplateService {
|
||||
@ -25,7 +24,8 @@ public interface TemplateService {
|
||||
|
||||
void exportTemplate(ExportTemplateForm form, HttpServletResponse response);
|
||||
|
||||
void exportMultipleTemplates(HttpServletResponse response);
|
||||
|
||||
List<Template> getTemplateVersion(TemplateRowIdForm form);
|
||||
|
||||
void updateTemplateStatus(@NotBlank String templateId, @NotBlank String status);
|
||||
}
|
||||
|
||||
@ -5,7 +5,6 @@ import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
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.*;
|
||||
import com.xdap.self_development.exception.CommonException;
|
||||
@ -25,7 +24,6 @@ import org.bson.types.ObjectId;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -41,8 +39,6 @@ import java.util.stream.Collectors;
|
||||
public class BenchmarkingReportServiceImpl implements BenchmarkingReportService {
|
||||
@Resource
|
||||
private BusinessDatabase bd;
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
@Resource
|
||||
private RuntimeAppContextService runtimeAppContextService;
|
||||
@Autowired
|
||||
@ -50,8 +46,6 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
@Resource
|
||||
private RedisLockUtil redisLockUtil;
|
||||
@Resource
|
||||
private UserPermissionGetter permissionGetter;
|
||||
@Resource
|
||||
private XdapDeptUsersService xdapDeptUsersService;
|
||||
|
||||
@Value("${apaas.token.clientId}")
|
||||
@ -163,6 +157,7 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
report.setStatus("DRAFT");
|
||||
report.setCreateBy(form.getUserId());
|
||||
report.setIsDelete(0);
|
||||
report.setFileName(form.getFileName());
|
||||
bd.getBusinessDatabase().doInsert(report);
|
||||
}
|
||||
|
||||
@ -191,6 +186,7 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
flow.setCreatedTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||
flow.setFlowType(2); // 设置为报告审批流程
|
||||
flow.setExplanation(form.getExplanation());
|
||||
flow.setProcessTitle(form.getProcessTitle());
|
||||
bd.getBusinessDatabase().doInsert(flow);
|
||||
|
||||
bd.getBusinessDatabase()
|
||||
@ -204,16 +200,17 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
todoTask.setCreatedById(form.getUserId());
|
||||
todoTask.setCreatedBy(xdapDeptUsersService.selectUserByID(form.getUserId()).getUsername());
|
||||
todoTask.setCurrentNode(getNodeName(flow.getCurrentNode()));
|
||||
todoTask.setDataType("-");
|
||||
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.setProcessTitle(form.getProcessTitle());
|
||||
todoTask.setStatusCode(flow.getFlowStatus());
|
||||
todoTask.setVersionNumber(1);
|
||||
todoTask.setOwnerId(person);
|
||||
todoTask.setCurrentProcessor(JSON.toJSONString(getNodeUsers(flow, flow.getCurrentNode())));
|
||||
list.add(todoTask);
|
||||
}
|
||||
bd.getBusinessDatabase().doBatchInsert(list);
|
||||
@ -477,6 +474,11 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
.rowid("id", report.getRowId())
|
||||
.update("status", report.getStatus())
|
||||
.doUpdate(BenchmarkingReport.class);
|
||||
// 待办环节修改
|
||||
bd.getBusinessDatabase()
|
||||
.eq("document_no", flow.getId())
|
||||
.update("node", "已完成")
|
||||
.doUpdate(ApprovalNodeView.class);
|
||||
} else {
|
||||
flow.setCurrentNode(nextNode);
|
||||
addNodeTodo(flow, nextNode, report, userId);
|
||||
@ -494,22 +496,32 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
// 新增待办
|
||||
List<TodoTaskPojo> list = new ArrayList<>();
|
||||
for (String person : users) {
|
||||
TodoTaskPojo todoTaskPojo = bd.getBusinessDatabase()
|
||||
.eq("document_no", flow.getId())
|
||||
.eq("owner_id", person).doQueryFirst(TodoTaskPojo.class);
|
||||
if (todoTaskPojo != null) {
|
||||
todoTaskPojo.setCurrentNode(getNodeName(node));
|
||||
todoTaskPojo.setCurrentProcessor(JSON.toJSONString(getNodeUsers(flow, node)));
|
||||
bd.getBusinessDatabase().doUpdate(todoTaskPojo);
|
||||
} else {
|
||||
TodoTaskPojo todoTask = new TodoTaskPojo();
|
||||
todoTask.setCreatedById(createBy);
|
||||
todoTask.setCreatedBy(xdapDeptUsersService.selectUserByID(createBy).getUsername());
|
||||
todoTask.setCurrentNode(getNodeName(flow.getCurrentNode()));
|
||||
todoTask.setDataType("-");
|
||||
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.setModelName(report.getProjectName() + "对标报告");
|
||||
todoTask.setProcessTitle(flow.getProcessTitle());
|
||||
todoTask.setStatusCode(flow.getFlowStatus());
|
||||
todoTask.setVersionNumber(1);
|
||||
todoTask.setOwnerId(person);
|
||||
todoTask.setCurrentProcessor(JSON.toJSONString(getNodeUsers(flow, flow.getCurrentNode())));
|
||||
list.add(todoTask);
|
||||
}
|
||||
}
|
||||
bd.getBusinessDatabase().doBatchInsert(list);
|
||||
}
|
||||
|
||||
@ -541,6 +553,11 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
.rowid("id", report.getRowId())
|
||||
.update("status", report.getStatus())
|
||||
.doUpdate(BenchmarkingReport.class);
|
||||
|
||||
bd.getBusinessDatabase()
|
||||
.eq("document_no", flow.getId())
|
||||
.update("node", "已拒绝")
|
||||
.doUpdate(ApprovalNodeView.class);
|
||||
// 清除所有待办
|
||||
clearAllTodo(flow, userId);
|
||||
}
|
||||
|
||||
@ -600,9 +600,6 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
|
||||
|
||||
private void addNodeTodo(ApprovalFlow flow, String node, Template template, String createBy) {
|
||||
List<String> users = getNodeUsers(flow, node);
|
||||
String processTitle = bd.getBusinessDatabase()
|
||||
.eq("document_no", flow.getId())
|
||||
.doQueryFirst(TodoTaskPojo.class).getProcessTitle();
|
||||
// 新增待办
|
||||
List<TodoTaskPojo> list = new ArrayList<>();
|
||||
for (String person : users) {
|
||||
@ -624,7 +621,7 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
|
||||
todoTask.setIsDelete(0);
|
||||
todoTask.setModelId(template.getId());
|
||||
todoTask.setModelName(template.getTemplateName());
|
||||
todoTask.setProcessTitle(processTitle);
|
||||
todoTask.setProcessTitle(flow.getProcessTitle());
|
||||
todoTask.setStatusCode(flow.getFlowStatus());
|
||||
todoTask.setVersionNumber(template.getVersion());
|
||||
todoTask.setOwnerId(person);
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package com.xdap.self_development.service.impl;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelWriter;
|
||||
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
||||
import com.definesys.mpaas.query.db.PageQueryResult;
|
||||
import com.xdap.self_development.common.MyResponse;
|
||||
@ -224,22 +226,6 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
.doQuery(Template.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateTemplateStatus(String templateId, String status) {
|
||||
if (Objects.equals(status, "COMPLETE")) {// 更新之前模板为历史
|
||||
Template template = bd.getBusinessDatabase().eq("id", templateId).doQueryFirst(Template.class);
|
||||
bd.getBusinessDatabase()
|
||||
.eq("template_name", template.getTemplateName())
|
||||
.update("status", "HISTORY")
|
||||
.doUpdate(Template.class);
|
||||
}
|
||||
bd.getBusinessDatabase()
|
||||
.eq("id", templateId)
|
||||
.update("status", status)
|
||||
.doUpdate(Template.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processSheetData(List<Parameter> dataList, String sheetName,
|
||||
String templateRowId, String createBy, MyResponse problems) {
|
||||
@ -564,4 +550,45 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
}
|
||||
return new ProcessResult(toAdd, toUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportMultipleTemplates(HttpServletResponse response) {
|
||||
try {
|
||||
String fileName = "全部模板_" +
|
||||
LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss"));
|
||||
|
||||
String encodedFileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20");
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("Content-Disposition", "attachment;filename*=utf-8''" + encodedFileName + ".xlsx");
|
||||
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||
response.setHeader("Pragma", "no-cache");
|
||||
response.setDateHeader("Expires", 0);
|
||||
|
||||
// 获取所有模板
|
||||
List<Template> templates = bd.getBusinessDatabase()
|
||||
.eq("status", "COMPLETE")
|
||||
.doQuery(Template.class);
|
||||
|
||||
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream(), Parameter.class)
|
||||
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
||||
.includeColumnFieldNames(getIncludeColumnFieldNames())
|
||||
.build()) {
|
||||
|
||||
for (Template template : templates) {
|
||||
List<Parameter> parameters = new ArrayList<>();
|
||||
parameters.add(new Parameter());
|
||||
|
||||
WriteSheet writeSheet = EasyExcel
|
||||
.writerSheet(template.getTemplateName())
|
||||
.build();
|
||||
|
||||
// 写入数据到对应的sheet
|
||||
excelWriter.write(parameters, writeSheet);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new CommonException("导出Excel失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user