模板管理bug修复
This commit is contained in:
parent
cf058a1734
commit
8d70d7e0e5
@ -160,7 +160,7 @@ public class ResponsiblePersonController {
|
||||
}
|
||||
|
||||
responsiblePersonService.updateResponsiblePerson(form);
|
||||
return Response.ok().setMessage(form.toString());
|
||||
return Response.ok().setMessage("添加成功");
|
||||
}
|
||||
|
||||
// 删除部门责任人
|
||||
|
||||
@ -7,6 +7,7 @@ import com.xdap.api.moudle.department.pojo.entity.XdapDepartments;
|
||||
import com.xdap.runtime.service.RuntimeDatasourceService;
|
||||
import com.xdap.self_development.controller.form.*;
|
||||
import com.xdap.self_development.pojo.Template;
|
||||
import com.xdap.self_development.pojo.view.TemplateImportProblemView;
|
||||
import com.xdap.self_development.service.TemplateService;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -23,7 +24,6 @@ public class TemplateController {
|
||||
@Resource
|
||||
private TemplateService templateService;
|
||||
|
||||
|
||||
// 模板名的模糊搜索
|
||||
@GetMapping("/getTemplateByCondition")
|
||||
public Response getTemplateByCondition(
|
||||
@ -40,15 +40,19 @@ public class TemplateController {
|
||||
return Response.ok().data(page);
|
||||
}
|
||||
|
||||
// 导入模板 导入全部模板参数和单页模板参数
|
||||
@PostMapping("/import")
|
||||
public Response importTemplate(
|
||||
@RequestPart("file") MultipartFile file,
|
||||
@RequestPart(value = "templateRowId", required = false) String templateRowId,
|
||||
@RequestPart("createBy") String createBy
|
||||
// 查看版本 某个模板的全部版本
|
||||
@GetMapping("getTemplateVersion")
|
||||
public Response getTemplateVersion(
|
||||
@Valid TemplateRowIdForm form,
|
||||
BindingResult bindingResult
|
||||
) {
|
||||
templateService.importTemplate(file, templateRowId, createBy);
|
||||
return Response.ok().setMessage("导入成功");
|
||||
if (bindingResult.hasErrors()) {
|
||||
bindingResult.getFieldErrors().forEach(error -> {
|
||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
||||
});
|
||||
}
|
||||
List<Template> list = templateService.getTemplateVersion(form);
|
||||
return Response.ok().data(list);
|
||||
}
|
||||
|
||||
// 添加模板
|
||||
@ -66,6 +70,22 @@ public class TemplateController {
|
||||
return Response.ok().setMessage("添加成功");
|
||||
}
|
||||
|
||||
// 导入模板 导入全部模板参数和单页模板参数
|
||||
@PostMapping("/import")
|
||||
public Response importTemplate(
|
||||
@RequestPart("file") MultipartFile file,
|
||||
@RequestPart(value = "templateRowId", required = false) String templateRowId,
|
||||
@RequestPart("createBy") String createBy
|
||||
) {
|
||||
|
||||
TemplateImportProblemView templateImportProblemView = templateService.importTemplate(file, templateRowId, createBy);
|
||||
if (templateImportProblemView.getFlag()) {
|
||||
return Response.error("导入失败").data(templateImportProblemView);
|
||||
} else {
|
||||
return Response.ok().setMessage("导入成功");
|
||||
}
|
||||
}
|
||||
|
||||
// 修改模板
|
||||
@PostMapping("/updateTemplate")
|
||||
public Response updateTemplate(
|
||||
@ -95,19 +115,4 @@ public class TemplateController {
|
||||
}
|
||||
templateService.exportTemplate(form, response);
|
||||
}
|
||||
|
||||
// 查看版本 某个模板的全部版本
|
||||
@GetMapping("getTemplateVersion")
|
||||
public Response getTemplateVersion(
|
||||
@Valid TemplateRowIdForm form,
|
||||
BindingResult bindingResult
|
||||
) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
bindingResult.getFieldErrors().forEach(error -> {
|
||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
||||
});
|
||||
}
|
||||
List<Template> list = templateService.getTemplateVersion(form);
|
||||
return Response.ok().data(list);
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,6 +33,6 @@ public class ParameterForm {
|
||||
|
||||
private String remarks;
|
||||
|
||||
@NotNull
|
||||
@NotNull(message = "操作不能为null")
|
||||
private String operation;
|
||||
}
|
||||
|
||||
@ -14,7 +14,6 @@ public class UpdateParameterForm {
|
||||
private String templateRowId;
|
||||
@NotBlank(message = "创建者不能为空")
|
||||
private String createBy;
|
||||
@Valid
|
||||
@NotEmpty(message = "请至少修改一项参数")
|
||||
@Valid @NotEmpty(message = "请至少修改一项参数")
|
||||
private List<ParameterForm> parameterForms;
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||
import com.alibaba.excel.read.listener.ReadListener;
|
||||
import com.xdap.self_development.pojo.Parameter;
|
||||
import com.xdap.self_development.pojo.view.TemplateImportProblemView;
|
||||
import com.xdap.self_development.service.TemplateService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@ -13,20 +14,22 @@ import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class SheetDataListener implements ReadListener<Parameter> {
|
||||
private static final int BATCH_SIZE = 100;
|
||||
private static final int BATCH_SIZE = 1000;
|
||||
|
||||
private final TemplateService templateService;
|
||||
private final String templateRowId;
|
||||
private final String createBy;
|
||||
private List<Parameter> cachedDataList;
|
||||
private String currentSheetName;
|
||||
TemplateImportProblemView problems;
|
||||
|
||||
public SheetDataListener(TemplateService templateService,
|
||||
String templateRowId, String createBy) {
|
||||
String templateRowId, String createBy, TemplateImportProblemView problems) {
|
||||
this.templateService = templateService;
|
||||
this.templateRowId = templateRowId;
|
||||
this.createBy = createBy;
|
||||
this.cachedDataList = new ArrayList<>(BATCH_SIZE);
|
||||
this.problems = problems;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -45,23 +48,24 @@ public class SheetDataListener implements ReadListener<Parameter> {
|
||||
|
||||
// 达到批处理大小时提前处理
|
||||
if (cachedDataList.size() >= BATCH_SIZE) {
|
||||
processBatch(context);
|
||||
processBatch();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAfterAllAnalysed(AnalysisContext context) {
|
||||
if (!cachedDataList.isEmpty()) {
|
||||
processBatch(context);
|
||||
processBatch();
|
||||
}
|
||||
}
|
||||
|
||||
private void processBatch(AnalysisContext context) {
|
||||
private void processBatch() {
|
||||
templateService.processSheetData(
|
||||
new ArrayList<>(cachedDataList),
|
||||
currentSheetName,
|
||||
templateRowId,
|
||||
createBy
|
||||
createBy,
|
||||
problems
|
||||
);
|
||||
cachedDataList.clear();
|
||||
}
|
||||
|
||||
@ -10,9 +10,11 @@ import lombok.NoArgsConstructor;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@SQLQuery(value = {
|
||||
// 查找每个模板的最新版本并且优先级按照已发布、审核中、草稿状态转变(只有这三种状态)
|
||||
@SQL(view = "getLatestTemplate",
|
||||
sql = "SELECT * FROM ( SELECT t.*, ROW_NUMBER() OVER (PARTITION BY template_name ORDER BY CASE WHEN status = 'COMPLETE' THEN 1 WHEN status = 'DRAFT' THEN 2 ELSE 3 END, version DESC) AS rn FROM yfsjglpt_model_template t WHERE status IN ('COMPLETE', 'DRAFT') ) ranked WHERE rn = 1"
|
||||
sql = "SELECT * 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 WHERE rn = 1"
|
||||
),
|
||||
// 获取所有模板的最新版本号(包括所有状态)
|
||||
@SQL(view = "getNewTemplate",
|
||||
sql = "SELECT t.* FROM yfsjglpt_model_template t JOIN ( SELECT template_name, MAX(version) AS latest_version FROM yfsjglpt_model_template GROUP BY template_name ) latest_template ON t.template_name = latest_template.template_name AND t.version = latest_template.latest_version")
|
||||
})
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
package com.xdap.self_development.pojo.view;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TemplateImportProblemView {
|
||||
private Boolean flag;
|
||||
private List<String> errors;
|
||||
private StringBuilder hasImported;
|
||||
}
|
||||
@ -4,18 +4,20 @@ import com.definesys.mpaas.query.db.PageQueryResult;
|
||||
import com.xdap.self_development.controller.form.*;
|
||||
import com.xdap.self_development.pojo.Parameter;
|
||||
import com.xdap.self_development.pojo.Template;
|
||||
import com.xdap.self_development.pojo.view.TemplateImportProblemView;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface TemplateService {
|
||||
PageQueryResult<Template> getTemplateByCondition(TemplatePageForm form);
|
||||
|
||||
void importTemplate(MultipartFile file, String templateRowId, String createBy);
|
||||
TemplateImportProblemView importTemplate(MultipartFile file, String templateRowId, String createBy);
|
||||
|
||||
void processSheetData(List<Parameter> dataList, String sheetName,
|
||||
String templateRowId, String createBy);
|
||||
String templateRowId, String createBy, TemplateImportProblemView problems);
|
||||
|
||||
void insertTemplate(InsertTemplateForm form);
|
||||
|
||||
|
||||
@ -169,6 +169,9 @@ public class ParameterServiceImpl implements ParameterService {
|
||||
List<RevisionRecord> revisionRecords = new ArrayList<>();
|
||||
|
||||
for (ParameterForm parameterForm : parameterForms) {
|
||||
if (parameterForm.getOperation() == null) {
|
||||
parameterForm.setOperation("");
|
||||
}
|
||||
ParameterOperation operation = ParameterOperation.fromCode(parameterForm.getOperation());
|
||||
|
||||
switch (operation) {
|
||||
@ -216,8 +219,6 @@ public class ParameterServiceImpl implements ParameterService {
|
||||
) {
|
||||
Parameter newParameter = new Parameter();
|
||||
BeanUtils.copyProperties(form, newParameter);
|
||||
|
||||
//TODO:编号问题(目前是前端传入编号,后端检查编号是否重复;或者我可以给他自动生成最大值)
|
||||
if (form.getParameterNumber() == null ) {
|
||||
Parameter parameter = bd.getBusinessDatabase()
|
||||
.viewQueryMode(true)
|
||||
|
||||
@ -29,6 +29,15 @@ public class ResponsiblePersonServiceImpl implements ResponsiblePersonService {
|
||||
|
||||
@Override
|
||||
public void saveResponsiblePerson(ResponsiblePersonForm form) {
|
||||
List<ResponsiblePerson> responsiblePeople = bd.getBusinessDatabase()
|
||||
.eq("userId", form.getUserId())
|
||||
.eq("personLevel", 1)
|
||||
.doQuery(ResponsiblePerson.class);
|
||||
|
||||
if (!responsiblePeople.isEmpty()) {
|
||||
throw new MpaasBusinessException("请不要重复新增责任人");
|
||||
}
|
||||
|
||||
ResponsiblePerson responsiblePerson = new ResponsiblePerson();
|
||||
responsiblePerson.setDepartment(form.getDepartment());
|
||||
responsiblePerson.setDepartmentId(form.getDepartmentId());
|
||||
@ -40,6 +49,15 @@ public class ResponsiblePersonServiceImpl implements ResponsiblePersonService {
|
||||
|
||||
@Override
|
||||
public void saveFilledPerson(ResponsiblePersonForm form) {
|
||||
List<ResponsiblePerson> responsiblePeople = bd.getBusinessDatabase()
|
||||
.eq("userId", form.getUserId())
|
||||
.eq("personLevel", 2)
|
||||
.doQuery(ResponsiblePerson.class);
|
||||
|
||||
if (!responsiblePeople.isEmpty()) {
|
||||
throw new MpaasBusinessException("请不要重复新增填写人");
|
||||
}
|
||||
|
||||
ResponsiblePerson responsiblePerson = new ResponsiblePerson();
|
||||
responsiblePerson.setDepartment(form.getDepartment());
|
||||
responsiblePerson.setDepartmentId(form.getDepartmentId());
|
||||
|
||||
@ -1,7 +1,11 @@
|
||||
package com.xdap.self_development.service.impl;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.event.AnalysisEventListener;
|
||||
import com.alibaba.excel.exception.ExcelAnalysisException;
|
||||
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.definesys.mpaas.common.exception.MpaasBusinessException;
|
||||
import com.definesys.mpaas.common.exception.MpaasRuntimeException;
|
||||
import com.definesys.mpaas.query.db.PageQueryResult;
|
||||
@ -12,6 +16,7 @@ import com.xdap.self_development.pojo.Parameter;
|
||||
import com.xdap.self_development.pojo.RevisionRecord;
|
||||
import com.xdap.self_development.pojo.Template;
|
||||
import com.xdap.self_development.pojo.TemplateAndParameter;
|
||||
import com.xdap.self_development.pojo.view.TemplateImportProblemView;
|
||||
import com.xdap.self_development.service.TemplateService;
|
||||
import com.xdap.self_development.utils.FormulaValidator;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -37,6 +42,7 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
|
||||
@Override
|
||||
public PageQueryResult<Template> getTemplateByCondition(TemplatePageForm form) {
|
||||
// TODO: 将用户id转为用户名
|
||||
return bd.getBusinessDatabase()
|
||||
.viewQueryMode(true)
|
||||
.view("getLatestTemplate")
|
||||
@ -52,13 +58,25 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
.eq("template_name", form.getTemplateName())
|
||||
.doQueryFirst(Template.class);
|
||||
|
||||
// 创建新模板
|
||||
Template newTemplate = new Template(
|
||||
form.getTemplateName(), 1, "DRAFT", Timestamp.valueOf(LocalDateTime.now()),
|
||||
null, form.getCreateBy()
|
||||
);
|
||||
|
||||
// 如果有同名称模板
|
||||
if (template != null) {
|
||||
newTemplate.setVersion(template.getVersion()+1);
|
||||
switch (template.getStatus()) {
|
||||
// 最新版本为草稿,提示已有草稿
|
||||
case "DRAFT":
|
||||
throw new MpaasRuntimeException("最新版本已为草稿,请勿重复新增");
|
||||
case "APPROVING":
|
||||
throw new MpaasRuntimeException("最新版本正在审核中,请勿重复新增");
|
||||
case "RETURNED":
|
||||
throw new MpaasRuntimeException("最新版本已被退回,请重新修改模板");
|
||||
}
|
||||
// 可新增版本
|
||||
newTemplate.setVersion(template.getVersion() + 1);
|
||||
}
|
||||
|
||||
bd.getBusinessDatabase().doInsert(newTemplate);
|
||||
@ -71,9 +89,9 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
.view("getLatestTemplate")
|
||||
.eq("template_name", form.getTemplateName())
|
||||
.doQueryFirst(Template.class);
|
||||
|
||||
if (template != null) {
|
||||
//TODO:可能要在修改为其他模板名也要成功
|
||||
throw new MpaasBusinessException("模板重复");
|
||||
throw new MpaasBusinessException("不可修改为已有模板");
|
||||
}
|
||||
|
||||
Template newTemplate = new Template(
|
||||
@ -88,20 +106,35 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = MpaasBusinessException.class)
|
||||
public void importTemplate(MultipartFile file, String templateRowId, String createBy) {
|
||||
if (file == null) {
|
||||
throw new MpaasBusinessException("模板文件异常");
|
||||
public TemplateImportProblemView importTemplate(MultipartFile file, String templateRowId, String createBy) {
|
||||
// 验证文件是否为工作表
|
||||
if (file == null || file.isEmpty()) {
|
||||
throw new MpaasBusinessException("文件不能为空");
|
||||
}
|
||||
|
||||
String filename = file.getOriginalFilename();
|
||||
if (filename == null ||
|
||||
!(filename.toLowerCase().endsWith(".xls") ||
|
||||
filename.toLowerCase().endsWith(".xlsx"))) {
|
||||
throw new MpaasBusinessException("只支持 .xls 或 .xlsx 格式的文件");
|
||||
}
|
||||
|
||||
TemplateImportProblemView problems =
|
||||
new TemplateImportProblemView(false, new ArrayList<>(), new StringBuilder("已完成导入:无"));
|
||||
|
||||
|
||||
try (InputStream inputStream = file.getInputStream()){
|
||||
EasyExcel.read(
|
||||
inputStream,
|
||||
Parameter.class,
|
||||
new SheetDataListener(this, templateRowId, createBy)
|
||||
new SheetDataListener(this, templateRowId, createBy, problems)
|
||||
).doReadAll();
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new MpaasRuntimeException("读取文件失败");
|
||||
}
|
||||
|
||||
return problems;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -162,59 +195,91 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
.doQuery(Template.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processSheetData(List<Parameter> dataList, String sheetName,
|
||||
String templateRowId, String createBy) {
|
||||
String templateRowId, String createBy, TemplateImportProblemView problems) {
|
||||
if (dataList.isEmpty()) {
|
||||
log.warn("Sheet {} 没有数据", sheetName);
|
||||
return;
|
||||
}
|
||||
|
||||
// 验证公式
|
||||
for (Parameter data : dataList) {
|
||||
if (Objects.equals(data.getParameterSource(), "公式计算")||Objects.equals(data.getParameterSource(), "公式运算")) {
|
||||
if (Objects.equals(data.getParameterSource(), "公式计算")) {
|
||||
Map<String, Object> validationResult = FormulaValidator.validateFormulaDetailed(
|
||||
data.getNumberOrFormula());
|
||||
if (!(Boolean) validationResult.get("isValid")) {
|
||||
String errorMsg = String.format("Sheet '%s' 的参数 '%s' 公式格式错误: %s",
|
||||
String errorMsg = String.format("模板'%s'的参数'%s'公式格式错误, %s",
|
||||
sheetName, data.getParameterName(),
|
||||
validationResult.get("errorMessage"));
|
||||
throw new MpaasBusinessException(errorMsg);
|
||||
problems.setFlag(true);
|
||||
problems.getErrors().add(errorMsg);
|
||||
// throw new MpaasRuntimeException(errorMsg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理模板版本
|
||||
String templateName = sheetName;
|
||||
// 指定模板导入
|
||||
if (templateRowId != null && !templateRowId.isEmpty()) {
|
||||
Template t = bd.getBusinessDatabase()
|
||||
.rowid("id", templateRowId)
|
||||
.doQueryFirst(Template.class);
|
||||
templateName = t.getTemplateName();
|
||||
|
||||
// 页名和模板名不一致不允许导入
|
||||
if (!Objects.equals(templateName, sheetName)) {
|
||||
throw new MpaasBusinessException("Excel页名不正确或模板名不正确");
|
||||
problems.setFlag(true);
|
||||
problems.getErrors().add("Excel页名与模板名不一致");
|
||||
return;
|
||||
// throw new MpaasBusinessException("Excel页名不正确或模板名不正确");
|
||||
}
|
||||
}
|
||||
|
||||
// 获取模板的最新版本
|
||||
Template lastTemplate = bd.getBusinessDatabase()
|
||||
.viewQueryMode(true)
|
||||
.view("getNewTemplate")
|
||||
.eq("template_name", templateName)
|
||||
.orderBy("version", "desc")
|
||||
.doQueryFirst(Template.class);
|
||||
|
||||
// 有最新版本
|
||||
// 如果有同名称模板
|
||||
if (lastTemplate != null) {
|
||||
switch (lastTemplate.getStatus()) {
|
||||
// 最新版本为草稿
|
||||
case "DRAFT":
|
||||
// 查询最新模板参数
|
||||
List<TemplateAndParameter> list = bd.getBusinessDatabase()
|
||||
.eq("template_id", lastTemplate.getId())
|
||||
.doQuery(TemplateAndParameter.class);
|
||||
// 最新版本不为空,创建新版本
|
||||
// 最新模板有参数
|
||||
if (!list.isEmpty()) {
|
||||
Integer v = lastTemplate.getVersion()+1;
|
||||
problems.setFlag(true);
|
||||
problems.getErrors().add("模板‘"+templateName+"’已有参数,无法导入");
|
||||
return;
|
||||
// throw new MpaasBusinessException("模板‘"+templateName+"’已有参数,无法导入");
|
||||
}
|
||||
case "APPROVING":
|
||||
problems.setFlag(true);
|
||||
problems.getErrors().add("模板‘"+templateName+"‘的最新版本正在审核中,无法导入");
|
||||
return;
|
||||
// throw new MpaasRuntimeException("模板‘"+templateName+"‘最新版本正在审核中,无法导入");
|
||||
case "RETURNED":
|
||||
problems.setFlag(true);
|
||||
problems.getErrors().add("模板‘"+templateName+"’的最新版本已被退回,无法导入");
|
||||
return;
|
||||
// throw new MpaasRuntimeException("模板‘"+templateName+"’最新版本已被退回,无法导入");
|
||||
// 最新版本已发布或已退回,增加版本号新增
|
||||
default:
|
||||
lastTemplate = new Template(
|
||||
templateName, v, "DRAFT", Timestamp.valueOf(LocalDateTime.now()),
|
||||
null, createBy
|
||||
templateName, lastTemplate.getVersion()+1, "DRAFT",
|
||||
Timestamp.valueOf(LocalDateTime.now()), null, createBy
|
||||
);
|
||||
bd.getBusinessDatabase()
|
||||
.doInsert(lastTemplate);
|
||||
}
|
||||
// 否则延用该版本
|
||||
} else {
|
||||
lastTemplate = new Template(
|
||||
templateName, 1, "DRAFT", Timestamp.valueOf(LocalDateTime.now()),
|
||||
@ -224,9 +289,7 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
.doInsert(lastTemplate);
|
||||
}
|
||||
|
||||
|
||||
// TODO:导入参数时的日志先不记录
|
||||
// 保存参数和关联关系
|
||||
// 保存参数
|
||||
bd.getBusinessDatabase().doBatchInsert(dataList);
|
||||
|
||||
Template finalLastTemplate = lastTemplate;
|
||||
@ -238,6 +301,7 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
return relation;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<RevisionRecord> revisionRecords = dataList.stream()
|
||||
.map(parameter -> {
|
||||
RevisionRecord revision = new RevisionRecord();
|
||||
@ -250,8 +314,19 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 保存关联关系
|
||||
bd.getBusinessDatabase().doBatchInsert(relations);
|
||||
|
||||
// 保存修改记录
|
||||
bd.getBusinessDatabase().doBatchInsert(revisionRecords);
|
||||
|
||||
// 返回问题
|
||||
if (problems.getHasImported().toString().equals("已完成导入:无")) {
|
||||
problems.setHasImported(new StringBuilder("已完成导入:"));
|
||||
problems.getHasImported().append(templateName);
|
||||
} else {
|
||||
problems.getHasImported().append("、").append(templateName);
|
||||
}
|
||||
log.info("Sheet '{}' 导入完成,共处理 {} 个参数", sheetName, dataList.size());
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user