修改:模板序号小修改
This commit is contained in:
parent
47f5e9df7f
commit
c712995e79
@ -15,7 +15,8 @@ import java.sql.Timestamp;
|
||||
// 查找每个模板的最新版本并且优先级按照已发布、审核中、草稿状态转变(只有这三种状态)
|
||||
// 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,
|
||||
@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 ranked.order_num DESC"
|
||||
sql = "SELECT ROW_NUMBER() OVER (ORDER BY ranked.order_num DESC) AS display_order_num, ranked.id, ranked.template_name, ranked.version , ranked.status, ranked.created_time, ranked.published_time, ROW_NUMBER() OVER (ORDER BY ranked.order_num DESC) AS order_num , 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 ranked.order_num DESC"
|
||||
// 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 ranked.order_num DESC"
|
||||
),
|
||||
// 获取所有模板的最新版本号(包括所有状态)
|
||||
@SQL(view = "getNewTemplate",
|
||||
|
||||
@ -10,11 +10,12 @@ import java.sql.Timestamp;
|
||||
@SQLQuery(value = {
|
||||
// CASE br.status WHEN 'COMPLETE' THEN 1 WHEN 'APPROVING' THEN 2 WHEN 'REJECTED' THEN 3 ELSE 4 END ASC ,
|
||||
@SQL(view = "getAllReport",
|
||||
sql = "SELECT br.id AS \"reportId\", br.* FROM yfsjglpt_model_benchmarking_report br 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 br.upload_time DESC")
|
||||
sql = "SELECT br.id AS \"reportId\", br.*, af.id AS \"flowId\" FROM yfsjglpt_model_benchmarking_report br LEFT JOIN yfsjglpt_model_approval_flow af 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, '%') ORDER BY br.upload_time DESC")
|
||||
})
|
||||
@Data
|
||||
public class TodoAndReportView {
|
||||
private String reportId;
|
||||
private String flowId;
|
||||
|
||||
private String title;
|
||||
private String manufacturerName;
|
||||
|
||||
@ -246,8 +246,8 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
BenchmarkingReport report = bd.getBusinessDatabase()
|
||||
.eq("id", form.getReportId())
|
||||
.doQueryFirst(BenchmarkingReport.class);
|
||||
if (!Objects.equals(report.getStatus(), "DRAFT")) {
|
||||
throw new CommonException("报告非草稿状态不可修改");
|
||||
if (!"DRAFT".equals(report.getStatus()) && !"REJECT".equals(report.getStatus())) {
|
||||
throw new CommonException("报告非草稿或拒绝状态不可修改");
|
||||
}
|
||||
if (!Objects.equals(report.getCreateBy(), form.getUserId())) {
|
||||
throw new CommonException("非创建者不能修改");
|
||||
@ -255,6 +255,7 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
||||
BeanUtils.copyProperties(form, report);
|
||||
report.setFilePath(form.getFileUrl() == null ? "" : form.getFileUrl());
|
||||
report.setUploadTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||
report.setStatus("DRAFT");
|
||||
bd.getBusinessDatabase()
|
||||
.eq("id", report.getId())
|
||||
.doUpdate(report);
|
||||
|
||||
@ -83,56 +83,56 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
.doQueryFirst(Template.class);
|
||||
|
||||
if (template != null) {
|
||||
// if (Objects.equals(form.getTemplateName(), template.getTemplateName()) && form.getOrderNum() != null) {
|
||||
// List<Long> sorted = bd.getBusinessDatabase()
|
||||
// .groupBy("order_num")
|
||||
// .orderBy("order_num", "desc")
|
||||
// .doQuery(Template.class)
|
||||
// .stream().map(Template::getOrderNum)
|
||||
// .collect(Collectors.toList());
|
||||
//
|
||||
// Long num = sorted.get(form.getOrderNum() - 1);
|
||||
// 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", num)
|
||||
// .doQuery(Template.class).stream().map(Template::getId)
|
||||
// .collect(Collectors.toList());
|
||||
//
|
||||
// if (updateTemplateId.isEmpty()) {
|
||||
// bd.getBusinessDatabase()
|
||||
// .in("id", originalTemplateId)
|
||||
// .update("order_num", System.currentTimeMillis())
|
||||
// .doUpdate(Template.class);
|
||||
// } else {
|
||||
// bd.getBusinessDatabase()
|
||||
// .in("id", updateTemplateId)
|
||||
// .update("order_num", template.getOrderNum())
|
||||
// .doUpdate(Template.class);
|
||||
// bd.getBusinessDatabase()
|
||||
// .in("id", originalTemplateId)
|
||||
// .update("order_num", num)
|
||||
// .doUpdate(Template.class);
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
if (Objects.equals(form.getTemplateName(), template.getTemplateName()) && form.getOrderNum() != null) {
|
||||
List<Long> sorted = bd.getBusinessDatabase()
|
||||
.groupBy("order_num")
|
||||
.orderBy("order_num", "desc")
|
||||
.doQuery(Template.class)
|
||||
.stream().map(Template::getOrderNum)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Long num = sorted.get(form.getOrderNum() - 1);
|
||||
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", num)
|
||||
.doQuery(Template.class).stream().map(Template::getId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (updateTemplateId.isEmpty()) {
|
||||
bd.getBusinessDatabase()
|
||||
.in("id", originalTemplateId)
|
||||
.update("order_num", System.currentTimeMillis())
|
||||
.doUpdate(Template.class);
|
||||
} else {
|
||||
bd.getBusinessDatabase()
|
||||
.in("id", updateTemplateId)
|
||||
.update("order_num", template.getOrderNum())
|
||||
.doUpdate(Template.class);
|
||||
bd.getBusinessDatabase()
|
||||
.in("id", originalTemplateId)
|
||||
.update("order_num", num)
|
||||
.doUpdate(Template.class);
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new CommonException("不可修改为已有模板");
|
||||
}
|
||||
|
||||
Template newTemplate = new Template(
|
||||
form.getTemplateName(), 1, "DRAFT", Timestamp.valueOf(LocalDateTime.now()),
|
||||
null, form.getUserId(), System.currentTimeMillis(), 0
|
||||
);
|
||||
String templateName = bd.getBusinessDatabase()
|
||||
.rowid("id", form.getTemplateRowId())
|
||||
.doQueryFirst(Template.class)
|
||||
.getTemplateName();
|
||||
|
||||
bd.getBusinessDatabase()
|
||||
.rowid("id", form.getTemplateRowId())
|
||||
.doUpdate(newTemplate);
|
||||
.eq("template_name", templateName)
|
||||
.update("template_name", form.getTemplateName())
|
||||
.doUpdate(Template.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -604,21 +604,38 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
.eq("status", "COMPLETE")
|
||||
.doQuery(Template.class);
|
||||
|
||||
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream(), Parameter.class)
|
||||
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
||||
.includeColumnFieldNames(getIncludeColumnFieldNames())
|
||||
.build()) {
|
||||
if (templates.isEmpty()) {
|
||||
try {
|
||||
List<Parameter> list = new ArrayList<>();
|
||||
list.add(new Parameter());
|
||||
|
||||
for (Template template : templates) {
|
||||
List<Parameter> parameters = new ArrayList<>();
|
||||
parameters.add(new Parameter());
|
||||
EasyExcel.write(response.getOutputStream(), Parameter.class)
|
||||
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
||||
.includeColumnFieldNames(getIncludeColumnFieldNames())
|
||||
.sheet("xxx")
|
||||
.doWrite(list);
|
||||
} catch (Exception e) {
|
||||
throw new CommonException("导出Excel失败: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream(), Parameter.class)
|
||||
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
||||
.includeColumnFieldNames(getIncludeColumnFieldNames())
|
||||
.build()) {
|
||||
|
||||
WriteSheet writeSheet = EasyExcel
|
||||
.writerSheet(template.getTemplateName())
|
||||
.build();
|
||||
for (Template template : templates) {
|
||||
List<Parameter> parameters = new ArrayList<>();
|
||||
parameters.add(new Parameter());
|
||||
|
||||
// 写入数据到对应的sheet
|
||||
excelWriter.write(parameters, writeSheet);
|
||||
WriteSheet writeSheet = EasyExcel
|
||||
.writerSheet(template.getTemplateName())
|
||||
.build();
|
||||
|
||||
// 写入数据到对应的sheet
|
||||
excelWriter.write(parameters, writeSheet);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new CommonException("导出Excel失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user