异常返回问题修复
This commit is contained in:
parent
8d70d7e0e5
commit
7645274ead
@ -0,0 +1,30 @@
|
|||||||
|
package com.xdap.self_development.common;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
// 处理复杂错误信息返回
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class MyResponse {
|
||||||
|
// 报错标识
|
||||||
|
private Boolean flag;
|
||||||
|
// 报错信息
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
|
||||||
|
// 模板导入的错误列表
|
||||||
|
private List<String> errors;
|
||||||
|
// 模板导入的已导入模板
|
||||||
|
private StringBuilder hasImported;
|
||||||
|
|
||||||
|
public MyResponse(Boolean flag, List<String> errors, StringBuilder hasImported) {
|
||||||
|
this.flag = flag;
|
||||||
|
this.errors = errors;
|
||||||
|
this.hasImported = hasImported;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,10 +1,10 @@
|
|||||||
package com.xdap.self_development.controller;
|
package com.xdap.self_development.controller;
|
||||||
|
|
||||||
import com.definesys.mpaas.common.exception.MpaasBusinessException;
|
|
||||||
import com.definesys.mpaas.common.http.Response;
|
import com.definesys.mpaas.common.http.Response;
|
||||||
import com.xdap.self_development.controller.form.BenchmarkingReportPageForm;
|
import com.xdap.self_development.controller.form.BenchmarkingReportPageForm;
|
||||||
import com.xdap.self_development.controller.form.HandleApprovalRequest;
|
import com.xdap.self_development.controller.form.HandleApprovalRequest;
|
||||||
import com.xdap.self_development.controller.form.SaveBenchmarkingReportForm;
|
import com.xdap.self_development.controller.form.SaveBenchmarkingReportForm;
|
||||||
|
import com.xdap.self_development.exception.CommonException;
|
||||||
import com.xdap.self_development.pojo.BenchmarkingReport;
|
import com.xdap.self_development.pojo.BenchmarkingReport;
|
||||||
import com.xdap.self_development.pojo.view.ApprovalFlowView;
|
import com.xdap.self_development.pojo.view.ApprovalFlowView;
|
||||||
import com.xdap.self_development.pojo.view.TodoAndReportView;
|
import com.xdap.self_development.pojo.view.TodoAndReportView;
|
||||||
@ -43,7 +43,7 @@ public class BenchmarkingReportController {
|
|||||||
) {
|
) {
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
bindingResult.getFieldErrors().forEach(error -> {
|
bindingResult.getFieldErrors().forEach(error -> {
|
||||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
throw new CommonException(error.getDefaultMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
benchmarkingReportService.saveBenchmarkingReport(form);
|
benchmarkingReportService.saveBenchmarkingReport(form);
|
||||||
@ -58,7 +58,7 @@ public class BenchmarkingReportController {
|
|||||||
) {
|
) {
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
bindingResult.getFieldErrors().forEach(error -> {
|
bindingResult.getFieldErrors().forEach(error -> {
|
||||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
throw new CommonException(error.getDefaultMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
List<TodoAndReportView> list = benchmarkingReportService
|
List<TodoAndReportView> list = benchmarkingReportService
|
||||||
@ -74,7 +74,7 @@ public class BenchmarkingReportController {
|
|||||||
) {
|
) {
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
bindingResult.getFieldErrors().forEach(error -> {
|
bindingResult.getFieldErrors().forEach(error -> {
|
||||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
throw new CommonException(error.getDefaultMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
benchmarkingReportService.handleReportApproval(request);
|
benchmarkingReportService.handleReportApproval(request);
|
||||||
|
|||||||
@ -3,8 +3,6 @@ package com.xdap.self_development.controller;
|
|||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.Base64;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.definesys.mpaas.common.http.Response;
|
import com.definesys.mpaas.common.http.Response;
|
||||||
import com.xdap.runtime.service.RuntimeAppContextService;
|
|
||||||
import com.xdap.runtime.service.RuntimeUserService;
|
|
||||||
import com.xdap.self_development.config.BusinessDatabase;
|
import com.xdap.self_development.config.BusinessDatabase;
|
||||||
import com.xdap.self_development.feign.ApaasMyTokenFeign;
|
import com.xdap.self_development.feign.ApaasMyTokenFeign;
|
||||||
import com.xdap.self_development.feign.dto.AppTokenDTO;
|
import com.xdap.self_development.feign.dto.AppTokenDTO;
|
||||||
@ -30,10 +28,6 @@ import java.util.stream.Collectors;
|
|||||||
public class DeleteController {
|
public class DeleteController {
|
||||||
@Resource
|
@Resource
|
||||||
private BusinessDatabase bd;
|
private BusinessDatabase bd;
|
||||||
@Resource
|
|
||||||
private RuntimeAppContextService runtimeAppContextService;
|
|
||||||
@Resource
|
|
||||||
private RuntimeUserService runtimeUserService;
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApaasMyTokenFeign apaasMyTokenFeign;
|
private ApaasMyTokenFeign apaasMyTokenFeign;
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
package com.xdap.self_development.controller;
|
package com.xdap.self_development.controller;
|
||||||
|
|
||||||
import com.definesys.mpaas.common.exception.MpaasBusinessException;
|
|
||||||
import com.definesys.mpaas.common.http.Response;
|
import com.definesys.mpaas.common.http.Response;
|
||||||
import com.definesys.mpaas.query.db.PageQueryResult;
|
import com.definesys.mpaas.query.db.PageQueryResult;
|
||||||
import com.xdap.self_development.controller.form.ParameterPageForm;
|
import com.xdap.self_development.controller.form.ParameterPageForm;
|
||||||
import com.xdap.self_development.controller.form.UpdateParameterForm;
|
import com.xdap.self_development.controller.form.UpdateParameterForm;
|
||||||
|
import com.xdap.self_development.exception.CommonException;
|
||||||
import com.xdap.self_development.pojo.Parameter;
|
import com.xdap.self_development.pojo.Parameter;
|
||||||
import com.xdap.self_development.pojo.view.TemplateInfoView;
|
import com.xdap.self_development.pojo.view.TemplateInfoView;
|
||||||
import com.xdap.self_development.service.ParameterService;
|
import com.xdap.self_development.service.ParameterService;
|
||||||
@ -28,7 +28,7 @@ public class ParameterController {
|
|||||||
) {
|
) {
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
bindingResult.getFieldErrors().forEach(error -> {
|
bindingResult.getFieldErrors().forEach(error -> {
|
||||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
throw new CommonException(error.getDefaultMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
PageQueryResult<Parameter> list = parameterService.getParameterByCondition(form);
|
PageQueryResult<Parameter> list = parameterService.getParameterByCondition(form);
|
||||||
@ -44,7 +44,7 @@ public class ParameterController {
|
|||||||
) {
|
) {
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
bindingResult.getFieldErrors().forEach(error -> {
|
bindingResult.getFieldErrors().forEach(error -> {
|
||||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
throw new CommonException(error.getDefaultMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
TemplateInfoView templateRowIdForm = parameterService.maintenanceParameters(form);
|
TemplateInfoView templateRowIdForm = parameterService.maintenanceParameters(form);
|
||||||
|
|||||||
@ -1,18 +1,15 @@
|
|||||||
package com.xdap.self_development.controller;
|
package com.xdap.self_development.controller;
|
||||||
|
|
||||||
import com.definesys.mpaas.common.exception.MpaasBusinessException;
|
|
||||||
import com.definesys.mpaas.common.http.Response;
|
import com.definesys.mpaas.common.http.Response;
|
||||||
import com.definesys.mpaas.query.db.PageQueryResult;
|
import com.definesys.mpaas.query.db.PageQueryResult;
|
||||||
import com.xdap.api.moudle.department.pojo.entity.XdapDepartments;
|
import com.xdap.api.moudle.department.pojo.entity.XdapDepartments;
|
||||||
import com.xdap.api.moudle.user.pojo.XdapUsers;
|
|
||||||
import com.xdap.runtime.service.RuntimeDatasourceService;
|
import com.xdap.runtime.service.RuntimeDatasourceService;
|
||||||
import com.xdap.self_development.config.BusinessDatabase;
|
|
||||||
import com.xdap.self_development.controller.form.DepartmentUserForm;
|
import com.xdap.self_development.controller.form.DepartmentUserForm;
|
||||||
import com.xdap.self_development.controller.form.DeptResponsiblePageForm;
|
import com.xdap.self_development.controller.form.DeptResponsiblePageForm;
|
||||||
import com.xdap.self_development.controller.form.ResponsiblePersonForm;
|
import com.xdap.self_development.controller.form.ResponsiblePersonForm;
|
||||||
import com.xdap.self_development.controller.form.UpdateResponsiblePersonForm;
|
import com.xdap.self_development.controller.form.UpdateResponsiblePersonForm;
|
||||||
|
import com.xdap.self_development.exception.CommonException;
|
||||||
import com.xdap.self_development.pojo.ResponsiblePerson;
|
import com.xdap.self_development.pojo.ResponsiblePerson;
|
||||||
import com.xdap.self_development.pojo.Template;
|
|
||||||
import com.xdap.self_development.pojo.view.DepartmentUserView;
|
import com.xdap.self_development.pojo.view.DepartmentUserView;
|
||||||
import com.xdap.self_development.service.ResponsiblePersonService;
|
import com.xdap.self_development.service.ResponsiblePersonService;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
@ -48,7 +45,7 @@ public class ResponsiblePersonController {
|
|||||||
) {
|
) {
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
bindingResult.getFieldErrors().forEach(error -> {
|
bindingResult.getFieldErrors().forEach(error -> {
|
||||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
throw new CommonException(error.getDefaultMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
PageQueryResult<ResponsiblePerson> deptResponsible =
|
PageQueryResult<ResponsiblePerson> deptResponsible =
|
||||||
@ -64,7 +61,7 @@ public class ResponsiblePersonController {
|
|||||||
) {
|
) {
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
bindingResult.getFieldErrors().forEach(error -> {
|
bindingResult.getFieldErrors().forEach(error -> {
|
||||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
throw new CommonException(error.getDefaultMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
PageQueryResult<ResponsiblePerson> deptResponsible =
|
PageQueryResult<ResponsiblePerson> deptResponsible =
|
||||||
@ -125,7 +122,7 @@ public class ResponsiblePersonController {
|
|||||||
) {
|
) {
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
bindingResult.getFieldErrors().forEach(error -> {
|
bindingResult.getFieldErrors().forEach(error -> {
|
||||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
throw new CommonException(error.getDefaultMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
responsiblePersonService.saveResponsiblePerson(form);
|
responsiblePersonService.saveResponsiblePerson(form);
|
||||||
@ -140,7 +137,7 @@ public class ResponsiblePersonController {
|
|||||||
) {
|
) {
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
bindingResult.getFieldErrors().forEach(error -> {
|
bindingResult.getFieldErrors().forEach(error -> {
|
||||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
throw new CommonException(error.getDefaultMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
responsiblePersonService.saveFilledPerson(form);
|
responsiblePersonService.saveFilledPerson(form);
|
||||||
@ -155,7 +152,7 @@ public class ResponsiblePersonController {
|
|||||||
) {
|
) {
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
bindingResult.getFieldErrors().forEach(error -> {
|
bindingResult.getFieldErrors().forEach(error -> {
|
||||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
throw new CommonException(error.getDefaultMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
package com.xdap.self_development.controller;
|
package com.xdap.self_development.controller;
|
||||||
|
|
||||||
import com.definesys.mpaas.common.exception.MpaasBusinessException;
|
|
||||||
import com.definesys.mpaas.common.http.Response;
|
import com.definesys.mpaas.common.http.Response;
|
||||||
import com.definesys.mpaas.query.db.PageQueryResult;
|
import com.definesys.mpaas.query.db.PageQueryResult;
|
||||||
import com.xdap.runtime.service.RuntimeDatasourceService;
|
import com.xdap.runtime.service.RuntimeDatasourceService;
|
||||||
import com.xdap.self_development.controller.form.*;
|
import com.xdap.self_development.controller.form.*;
|
||||||
|
import com.xdap.self_development.exception.CommonException;
|
||||||
import com.xdap.self_development.pojo.view.ApprovalFlowView;
|
import com.xdap.self_development.pojo.view.ApprovalFlowView;
|
||||||
import com.xdap.self_development.pojo.view.DepartmentUserView;
|
import com.xdap.self_development.pojo.view.DepartmentUserView;
|
||||||
import com.xdap.self_development.pojo.view.TemplateChangeView;
|
import com.xdap.self_development.pojo.view.TemplateChangeView;
|
||||||
@ -44,7 +44,7 @@ public class TemplateApprovalController {
|
|||||||
) {
|
) {
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
bindingResult.getFieldErrors().forEach(error -> {
|
bindingResult.getFieldErrors().forEach(error -> {
|
||||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
throw new CommonException(error.getDefaultMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return Response.ok().data(templateApprovalService.startApproval(request));
|
return Response.ok().data(templateApprovalService.startApproval(request));
|
||||||
@ -58,7 +58,7 @@ public class TemplateApprovalController {
|
|||||||
) {
|
) {
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
bindingResult.getFieldErrors().forEach(error -> {
|
bindingResult.getFieldErrors().forEach(error -> {
|
||||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
throw new CommonException(error.getDefaultMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return Response.ok().data(templateApprovalService.getApprovalList(form));
|
return Response.ok().data(templateApprovalService.getApprovalList(form));
|
||||||
@ -72,7 +72,7 @@ public class TemplateApprovalController {
|
|||||||
) {
|
) {
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
bindingResult.getFieldErrors().forEach(error -> {
|
bindingResult.getFieldErrors().forEach(error -> {
|
||||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
throw new CommonException(error.getDefaultMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
templateApprovalService.handleApproval(request);
|
templateApprovalService.handleApproval(request);
|
||||||
@ -87,7 +87,7 @@ public class TemplateApprovalController {
|
|||||||
) {
|
) {
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
bindingResult.getFieldErrors().forEach(error -> {
|
bindingResult.getFieldErrors().forEach(error -> {
|
||||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
throw new CommonException(error.getDefaultMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
PageQueryResult<TemplateChangeView> result = templateApprovalService.getTemplateChanges(form);
|
PageQueryResult<TemplateChangeView> result = templateApprovalService.getTemplateChanges(form);
|
||||||
@ -102,7 +102,7 @@ public class TemplateApprovalController {
|
|||||||
) {
|
) {
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
bindingResult.getFieldErrors().forEach(error -> {
|
bindingResult.getFieldErrors().forEach(error -> {
|
||||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
throw new CommonException(error.getDefaultMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
ApprovalFlowView approvalFlowView = templateApprovalService.getApprovalProcess(form);
|
ApprovalFlowView approvalFlowView = templateApprovalService.getApprovalProcess(form);
|
||||||
|
|||||||
@ -1,13 +1,11 @@
|
|||||||
package com.xdap.self_development.controller;
|
package com.xdap.self_development.controller;
|
||||||
|
|
||||||
import com.definesys.mpaas.common.exception.MpaasBusinessException;
|
|
||||||
import com.definesys.mpaas.common.http.Response;
|
import com.definesys.mpaas.common.http.Response;
|
||||||
import com.definesys.mpaas.query.db.PageQueryResult;
|
import com.definesys.mpaas.query.db.PageQueryResult;
|
||||||
import com.xdap.api.moudle.department.pojo.entity.XdapDepartments;
|
import com.xdap.self_development.common.MyResponse;
|
||||||
import com.xdap.runtime.service.RuntimeDatasourceService;
|
|
||||||
import com.xdap.self_development.controller.form.*;
|
import com.xdap.self_development.controller.form.*;
|
||||||
|
import com.xdap.self_development.exception.CommonException;
|
||||||
import com.xdap.self_development.pojo.Template;
|
import com.xdap.self_development.pojo.Template;
|
||||||
import com.xdap.self_development.pojo.view.TemplateImportProblemView;
|
|
||||||
import com.xdap.self_development.service.TemplateService;
|
import com.xdap.self_development.service.TemplateService;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -32,7 +30,7 @@ public class TemplateController {
|
|||||||
) {
|
) {
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
bindingResult.getFieldErrors().forEach(error -> {
|
bindingResult.getFieldErrors().forEach(error -> {
|
||||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
throw new CommonException(error.getDefaultMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +46,7 @@ public class TemplateController {
|
|||||||
) {
|
) {
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
bindingResult.getFieldErrors().forEach(error -> {
|
bindingResult.getFieldErrors().forEach(error -> {
|
||||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
throw new CommonException(error.getDefaultMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
List<Template> list = templateService.getTemplateVersion(form);
|
List<Template> list = templateService.getTemplateVersion(form);
|
||||||
@ -63,7 +61,7 @@ public class TemplateController {
|
|||||||
) {
|
) {
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
bindingResult.getFieldErrors().forEach(error -> {
|
bindingResult.getFieldErrors().forEach(error -> {
|
||||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
throw new CommonException(error.getDefaultMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
templateService.insertTemplate(form);
|
templateService.insertTemplate(form);
|
||||||
@ -78,7 +76,7 @@ public class TemplateController {
|
|||||||
@RequestPart("createBy") String createBy
|
@RequestPart("createBy") String createBy
|
||||||
) {
|
) {
|
||||||
|
|
||||||
TemplateImportProblemView templateImportProblemView = templateService.importTemplate(file, templateRowId, createBy);
|
MyResponse templateImportProblemView = templateService.importTemplate(file, templateRowId, createBy);
|
||||||
if (templateImportProblemView.getFlag()) {
|
if (templateImportProblemView.getFlag()) {
|
||||||
return Response.error("导入失败").data(templateImportProblemView);
|
return Response.error("导入失败").data(templateImportProblemView);
|
||||||
} else {
|
} else {
|
||||||
@ -94,7 +92,7 @@ public class TemplateController {
|
|||||||
) {
|
) {
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
bindingResult.getFieldErrors().forEach(error -> {
|
bindingResult.getFieldErrors().forEach(error -> {
|
||||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
throw new CommonException(error.getDefaultMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
templateService.updateTemplate(form);
|
templateService.updateTemplate(form);
|
||||||
@ -110,7 +108,7 @@ public class TemplateController {
|
|||||||
) {
|
) {
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
bindingResult.getFieldErrors().forEach(error -> {
|
bindingResult.getFieldErrors().forEach(error -> {
|
||||||
throw new MpaasBusinessException(error.getDefaultMessage());
|
throw new CommonException(error.getDefaultMessage());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
templateService.exportTemplate(form, response);
|
templateService.exportTemplate(form, response);
|
||||||
|
|||||||
@ -0,0 +1,19 @@
|
|||||||
|
package com.xdap.self_development.exception;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class CommonException extends RuntimeException {
|
||||||
|
private Object data;
|
||||||
|
|
||||||
|
public CommonException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommonException(String message, Object data) {
|
||||||
|
super(message);
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.xdap.self_development.exception;
|
||||||
|
|
||||||
|
import com.definesys.mpaas.common.http.Response;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
|
||||||
|
// 自定义异常处理类
|
||||||
|
@RestControllerAdvice
|
||||||
|
@Order(-2)
|
||||||
|
public class MyGlobalExceptionHandler {
|
||||||
|
@ExceptionHandler(CommonException.class)
|
||||||
|
public Response handleMpaasBusinessException(CommonException e) {
|
||||||
|
if (e.getData() != null) {
|
||||||
|
return Response.error(e.getMessage()).setData(e.getData());
|
||||||
|
} else {
|
||||||
|
return Response.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,8 +3,8 @@ package com.xdap.self_development.listener;
|
|||||||
import com.alibaba.excel.context.AnalysisContext;
|
import com.alibaba.excel.context.AnalysisContext;
|
||||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||||
import com.alibaba.excel.read.listener.ReadListener;
|
import com.alibaba.excel.read.listener.ReadListener;
|
||||||
|
import com.xdap.self_development.common.MyResponse;
|
||||||
import com.xdap.self_development.pojo.Parameter;
|
import com.xdap.self_development.pojo.Parameter;
|
||||||
import com.xdap.self_development.pojo.view.TemplateImportProblemView;
|
|
||||||
import com.xdap.self_development.service.TemplateService;
|
import com.xdap.self_development.service.TemplateService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@ -21,10 +21,10 @@ public class SheetDataListener implements ReadListener<Parameter> {
|
|||||||
private final String createBy;
|
private final String createBy;
|
||||||
private List<Parameter> cachedDataList;
|
private List<Parameter> cachedDataList;
|
||||||
private String currentSheetName;
|
private String currentSheetName;
|
||||||
TemplateImportProblemView problems;
|
MyResponse problems;
|
||||||
|
|
||||||
public SheetDataListener(TemplateService templateService,
|
public SheetDataListener(TemplateService templateService,
|
||||||
String templateRowId, String createBy, TemplateImportProblemView problems) {
|
String templateRowId, String createBy, MyResponse problems) {
|
||||||
this.templateService = templateService;
|
this.templateService = templateService;
|
||||||
this.templateRowId = templateRowId;
|
this.templateRowId = templateRowId;
|
||||||
this.createBy = createBy;
|
this.createBy = createBy;
|
||||||
|
|||||||
@ -1,16 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
@ -1,14 +1,13 @@
|
|||||||
package com.xdap.self_development.schedule;
|
package com.xdap.self_development.schedule;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.definesys.mpaas.common.exception.MpaasBusinessException;
|
|
||||||
import com.xdap.self_development.config.BusinessDatabase;
|
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.ApprovalFlow;
|
||||||
import com.xdap.self_development.pojo.ApprovalRecord;
|
import com.xdap.self_development.pojo.ApprovalRecord;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -20,7 +19,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Transactional(rollbackFor = MpaasBusinessException.class)
|
@Transactional(rollbackFor = CommonException.class)
|
||||||
public class ModifiedTodoTimer {
|
public class ModifiedTodoTimer {
|
||||||
@Resource
|
@Resource
|
||||||
private BusinessDatabase bd;
|
private BusinessDatabase bd;
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
package com.xdap.self_development.schedule;
|
package com.xdap.self_development.schedule;
|
||||||
|
|
||||||
import com.definesys.mpaas.common.exception.MpaasBusinessException;
|
|
||||||
import com.xdap.self_development.config.BusinessDatabase;
|
import com.xdap.self_development.config.BusinessDatabase;
|
||||||
|
import com.xdap.self_development.exception.CommonException;
|
||||||
import com.xdap.self_development.pojo.view.CalculationParameterView;
|
import com.xdap.self_development.pojo.view.CalculationParameterView;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -18,7 +17,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Transactional(rollbackFor = MpaasBusinessException.class)
|
@Transactional(rollbackFor = CommonException.class)
|
||||||
public class ParameterValueCalculationTimer {
|
public class ParameterValueCalculationTimer {
|
||||||
@Resource
|
@Resource
|
||||||
private BusinessDatabase bd;
|
private BusinessDatabase bd;
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
package com.xdap.self_development.service;
|
package com.xdap.self_development.service;
|
||||||
|
|
||||||
import com.definesys.mpaas.query.db.PageQueryResult;
|
import com.definesys.mpaas.query.db.PageQueryResult;
|
||||||
|
import com.xdap.self_development.common.MyResponse;
|
||||||
import com.xdap.self_development.controller.form.*;
|
import com.xdap.self_development.controller.form.*;
|
||||||
import com.xdap.self_development.pojo.Parameter;
|
import com.xdap.self_development.pojo.Parameter;
|
||||||
import com.xdap.self_development.pojo.Template;
|
import com.xdap.self_development.pojo.Template;
|
||||||
import com.xdap.self_development.pojo.view.TemplateImportProblemView;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@ -14,10 +14,10 @@ import java.util.Map;
|
|||||||
public interface TemplateService {
|
public interface TemplateService {
|
||||||
PageQueryResult<Template> getTemplateByCondition(TemplatePageForm form);
|
PageQueryResult<Template> getTemplateByCondition(TemplatePageForm form);
|
||||||
|
|
||||||
TemplateImportProblemView importTemplate(MultipartFile file, String templateRowId, String createBy);
|
MyResponse importTemplate(MultipartFile file, String templateRowId, String createBy);
|
||||||
|
|
||||||
void processSheetData(List<Parameter> dataList, String sheetName,
|
void processSheetData(List<Parameter> dataList, String sheetName,
|
||||||
String templateRowId, String createBy, TemplateImportProblemView problems);
|
String templateRowId, String createBy, MyResponse problems);
|
||||||
|
|
||||||
void insertTemplate(InsertTemplateForm form);
|
void insertTemplate(InsertTemplateForm form);
|
||||||
|
|
||||||
|
|||||||
@ -3,12 +3,12 @@ package com.xdap.self_development.service.impl;
|
|||||||
import cn.hutool.core.codec.Base64;
|
import cn.hutool.core.codec.Base64;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.definesys.mpaas.common.exception.MpaasBusinessException;
|
|
||||||
import com.xdap.runtime.service.RuntimeAppContextService;
|
import com.xdap.runtime.service.RuntimeAppContextService;
|
||||||
import com.xdap.self_development.config.BusinessDatabase;
|
import com.xdap.self_development.config.BusinessDatabase;
|
||||||
import com.xdap.self_development.controller.form.BenchmarkingReportPageForm;
|
import com.xdap.self_development.controller.form.BenchmarkingReportPageForm;
|
||||||
import com.xdap.self_development.controller.form.HandleApprovalRequest;
|
import com.xdap.self_development.controller.form.HandleApprovalRequest;
|
||||||
import com.xdap.self_development.controller.form.SaveBenchmarkingReportForm;
|
import com.xdap.self_development.controller.form.SaveBenchmarkingReportForm;
|
||||||
|
import com.xdap.self_development.exception.CommonException;
|
||||||
import com.xdap.self_development.feign.ApaasMyTokenFeign;
|
import com.xdap.self_development.feign.ApaasMyTokenFeign;
|
||||||
import com.xdap.self_development.feign.dto.AppTokenDTO;
|
import com.xdap.self_development.feign.dto.AppTokenDTO;
|
||||||
import com.xdap.self_development.feign.dto.FileUploadDTO;
|
import com.xdap.self_development.feign.dto.FileUploadDTO;
|
||||||
@ -59,7 +59,7 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
|||||||
private static final int FLOW_LOCK_EXPIRE_SECONDS = 5;
|
private static final int FLOW_LOCK_EXPIRE_SECONDS = 5;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional(rollbackFor = CommonException.class)
|
||||||
public void saveBenchmarkingReport(SaveBenchmarkingReportForm form) {
|
public void saveBenchmarkingReport(SaveBenchmarkingReportForm form) {
|
||||||
// 1. 创建对标报告并保存
|
// 1. 创建对标报告并保存
|
||||||
BenchmarkingReport report = new BenchmarkingReport();
|
BenchmarkingReport report = new BenchmarkingReport();
|
||||||
@ -190,20 +190,20 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
|||||||
.eq("flow_type", 2)
|
.eq("flow_type", 2)
|
||||||
.doQueryFirst(ApprovalFlow.class);
|
.doQueryFirst(ApprovalFlow.class);
|
||||||
if (flow == null || !"APPROVING".equals(flow.getFlowStatus())) {
|
if (flow == null || !"APPROVING".equals(flow.getFlowStatus())) {
|
||||||
throw new MpaasBusinessException("流程不存在或已结束");
|
throw new CommonException("流程不存在或已结束");
|
||||||
}
|
}
|
||||||
|
|
||||||
String currentNode = flow.getCurrentNode();
|
String currentNode = flow.getCurrentNode();
|
||||||
// 验证当前用户是否有权限处理
|
// 验证当前用户是否有权限处理
|
||||||
if (!hasPermission(flow, currentNode, request.getUserId())) {
|
if (!hasPermission(flow, currentNode, request.getUserId())) {
|
||||||
throw new MpaasBusinessException("无权限处理或已被处理");
|
throw new CommonException("无权限处理或已被处理");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!"COUNTERSIGN".equals(currentNode)) {
|
if (!"COUNTERSIGN".equals(currentNode)) {
|
||||||
String lockKey = FLOW_LOCK_PREFIX + flow.getId() + ":" + currentNode;
|
String lockKey = FLOW_LOCK_PREFIX + flow.getId() + ":" + currentNode;
|
||||||
Boolean lock = redisTemplate.opsForValue().setIfAbsent(lockKey, "1", FLOW_LOCK_EXPIRE_SECONDS, TimeUnit.SECONDS);
|
Boolean lock = redisTemplate.opsForValue().setIfAbsent(lockKey, "1", FLOW_LOCK_EXPIRE_SECONDS, TimeUnit.SECONDS);
|
||||||
if (Boolean.FALSE.equals(lock)) {
|
if (Boolean.FALSE.equals(lock)) {
|
||||||
throw new MpaasBusinessException("当前节点正在处理,请稍后重试");
|
throw new CommonException("当前节点正在处理,请稍后重试");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// 校验抢签节点是否已被处理
|
// 校验抢签节点是否已被处理
|
||||||
@ -211,7 +211,7 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
|||||||
long result = Optional.ofNullable(redisTemplate.opsForSet().size(processedKey))
|
long result = Optional.ofNullable(redisTemplate.opsForSet().size(processedKey))
|
||||||
.orElse(0L);
|
.orElse(0L);
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
throw new MpaasBusinessException("此节点已被他人处理");
|
throw new CommonException("此节点已被他人处理");
|
||||||
}
|
}
|
||||||
processApprovalLogic(flow, request, currentNode);
|
processApprovalLogic(flow, request, currentNode);
|
||||||
} finally {
|
} finally {
|
||||||
@ -225,9 +225,8 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BenchmarkingReport getReportDetail(String reportId) {
|
public BenchmarkingReport getReportDetail(String reportId) {
|
||||||
BenchmarkingReport report = bd.getBusinessDatabase().eq("id", reportId)
|
return bd.getBusinessDatabase().eq("id", reportId)
|
||||||
.doQueryFirst(BenchmarkingReport.class);
|
.doQueryFirst(BenchmarkingReport.class);
|
||||||
return report;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -1,12 +1,11 @@
|
|||||||
package com.xdap.self_development.service.impl;
|
package com.xdap.self_development.service.impl;
|
||||||
|
|
||||||
import com.definesys.mpaas.common.exception.MpaasBusinessException;
|
|
||||||
import com.definesys.mpaas.query.db.PageQueryResult;
|
import com.definesys.mpaas.query.db.PageQueryResult;
|
||||||
import com.xdap.self_development.config.BusinessDatabase;
|
import com.xdap.self_development.config.BusinessDatabase;
|
||||||
import com.xdap.self_development.controller.form.ParameterForm;
|
import com.xdap.self_development.controller.form.ParameterForm;
|
||||||
import com.xdap.self_development.controller.form.ParameterPageForm;
|
import com.xdap.self_development.controller.form.ParameterPageForm;
|
||||||
import com.xdap.self_development.controller.form.TemplateRowIdForm;
|
|
||||||
import com.xdap.self_development.controller.form.UpdateParameterForm;
|
import com.xdap.self_development.controller.form.UpdateParameterForm;
|
||||||
|
import com.xdap.self_development.exception.CommonException;
|
||||||
import com.xdap.self_development.pojo.Parameter;
|
import com.xdap.self_development.pojo.Parameter;
|
||||||
import com.xdap.self_development.pojo.RevisionRecord;
|
import com.xdap.self_development.pojo.RevisionRecord;
|
||||||
import com.xdap.self_development.pojo.Template;
|
import com.xdap.self_development.pojo.Template;
|
||||||
@ -39,7 +38,7 @@ public class ParameterServiceImpl implements ParameterService {
|
|||||||
.doQueryFirst(Template.class);
|
.doQueryFirst(Template.class);
|
||||||
|
|
||||||
if (template == null) {
|
if (template == null) {
|
||||||
throw new MpaasBusinessException("模板未找到");
|
throw new CommonException("模板未找到");
|
||||||
}
|
}
|
||||||
|
|
||||||
return bd.getBusinessDatabase()
|
return bd.getBusinessDatabase()
|
||||||
@ -53,7 +52,7 @@ public class ParameterServiceImpl implements ParameterService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = MpaasBusinessException.class)
|
@Transactional(rollbackFor = CommonException.class)
|
||||||
public TemplateInfoView maintenanceParameters(UpdateParameterForm form) {
|
public TemplateInfoView maintenanceParameters(UpdateParameterForm form) {
|
||||||
// 公式格式检查
|
// 公式格式检查
|
||||||
form.getParameterForms().forEach(parameter -> {
|
form.getParameterForms().forEach(parameter -> {
|
||||||
@ -64,7 +63,7 @@ public class ParameterServiceImpl implements ParameterService {
|
|||||||
String errorMsg = String.format("参数 '%s' 公式格式错误: %s",
|
String errorMsg = String.format("参数 '%s' 公式格式错误: %s",
|
||||||
parameter.getParameterName(),
|
parameter.getParameterName(),
|
||||||
validationResult.get("errorMessage"));
|
validationResult.get("errorMessage"));
|
||||||
throw new MpaasBusinessException(errorMsg);
|
throw new CommonException(errorMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -243,7 +242,7 @@ public class ParameterServiceImpl implements ParameterService {
|
|||||||
.eq("parameter_number", newParameter.getParameterNumber())
|
.eq("parameter_number", newParameter.getParameterNumber())
|
||||||
.doQuery(Parameter.class);
|
.doQuery(Parameter.class);
|
||||||
if (parameters != null && !parameters.isEmpty()) {
|
if (parameters != null && !parameters.isEmpty()) {
|
||||||
throw new MpaasBusinessException("参数编号重复");
|
throw new CommonException("参数编号重复");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,21 +1,18 @@
|
|||||||
package com.xdap.self_development.service.impl;
|
package com.xdap.self_development.service.impl;
|
||||||
|
|
||||||
|
|
||||||
import com.definesys.mpaas.common.exception.MpaasBusinessException;
|
|
||||||
import com.definesys.mpaas.query.db.PageQueryResult;
|
import com.definesys.mpaas.query.db.PageQueryResult;
|
||||||
import com.xdap.runtime.service.RuntimeDatasourceService;
|
import com.xdap.runtime.service.RuntimeDatasourceService;
|
||||||
import com.xdap.self_development.config.BusinessDatabase;
|
import com.xdap.self_development.config.BusinessDatabase;
|
||||||
import com.xdap.self_development.controller.form.DeptResponsiblePageForm;
|
import com.xdap.self_development.controller.form.DeptResponsiblePageForm;
|
||||||
import com.xdap.self_development.controller.form.ResponsiblePersonForm;
|
import com.xdap.self_development.controller.form.ResponsiblePersonForm;
|
||||||
import com.xdap.self_development.controller.form.UpdateResponsiblePersonForm;
|
import com.xdap.self_development.controller.form.UpdateResponsiblePersonForm;
|
||||||
import com.xdap.self_development.pojo.ApprovalXdapUsers;
|
import com.xdap.self_development.exception.CommonException;
|
||||||
import com.xdap.self_development.pojo.ResponsiblePerson;
|
import com.xdap.self_development.pojo.ResponsiblePerson;
|
||||||
import com.xdap.self_development.pojo.Template;
|
import com.xdap.self_development.pojo.Template;
|
||||||
import com.xdap.self_development.service.ResponsiblePersonService;
|
import com.xdap.self_development.service.ResponsiblePersonService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -35,7 +32,7 @@ public class ResponsiblePersonServiceImpl implements ResponsiblePersonService {
|
|||||||
.doQuery(ResponsiblePerson.class);
|
.doQuery(ResponsiblePerson.class);
|
||||||
|
|
||||||
if (!responsiblePeople.isEmpty()) {
|
if (!responsiblePeople.isEmpty()) {
|
||||||
throw new MpaasBusinessException("请不要重复新增责任人");
|
throw new CommonException("请不要重复新增责任人");
|
||||||
}
|
}
|
||||||
|
|
||||||
ResponsiblePerson responsiblePerson = new ResponsiblePerson();
|
ResponsiblePerson responsiblePerson = new ResponsiblePerson();
|
||||||
@ -55,7 +52,7 @@ public class ResponsiblePersonServiceImpl implements ResponsiblePersonService {
|
|||||||
.doQuery(ResponsiblePerson.class);
|
.doQuery(ResponsiblePerson.class);
|
||||||
|
|
||||||
if (!responsiblePeople.isEmpty()) {
|
if (!responsiblePeople.isEmpty()) {
|
||||||
throw new MpaasBusinessException("请不要重复新增填写人");
|
throw new CommonException("请不要重复新增填写人");
|
||||||
}
|
}
|
||||||
|
|
||||||
ResponsiblePerson responsiblePerson = new ResponsiblePerson();
|
ResponsiblePerson responsiblePerson = new ResponsiblePerson();
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
package com.xdap.self_development.service.impl;
|
package com.xdap.self_development.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.definesys.mpaas.common.exception.MpaasBusinessException;
|
|
||||||
import com.definesys.mpaas.query.db.PageQueryResult;
|
import com.definesys.mpaas.query.db.PageQueryResult;
|
||||||
import com.xdap.runtime.service.RuntimeDatasourceService;
|
import com.xdap.runtime.service.RuntimeDatasourceService;
|
||||||
import com.xdap.self_development.config.BusinessDatabase;
|
import com.xdap.self_development.config.BusinessDatabase;
|
||||||
import com.xdap.self_development.controller.form.*;
|
import com.xdap.self_development.controller.form.*;
|
||||||
|
import com.xdap.self_development.exception.CommonException;
|
||||||
import com.xdap.self_development.pojo.*;
|
import com.xdap.self_development.pojo.*;
|
||||||
import com.xdap.self_development.pojo.view.ApprovalFlowView;
|
import com.xdap.self_development.pojo.view.ApprovalFlowView;
|
||||||
import com.xdap.self_development.pojo.view.ApprovalNodeView;
|
import com.xdap.self_development.pojo.view.ApprovalNodeView;
|
||||||
@ -52,11 +52,11 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
|
|||||||
.rowid("id", request.getTemplateRowId())
|
.rowid("id", request.getTemplateRowId())
|
||||||
.doQueryFirst(Template.class);
|
.doQueryFirst(Template.class);
|
||||||
if (template == null) {
|
if (template == null) {
|
||||||
throw new MpaasBusinessException("模板不存在");
|
throw new CommonException("模板不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Objects.equals("DRAFT", template.getStatus())) {
|
if (!Objects.equals("DRAFT", template.getStatus())) {
|
||||||
throw new MpaasBusinessException("非草稿不允许发起审批");
|
throw new CommonException("非草稿不允许发起审批");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ApprovalFlow> templateFlows = bd.getBusinessDatabase()
|
List<ApprovalFlow> templateFlows = bd.getBusinessDatabase()
|
||||||
@ -64,7 +64,7 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
|
|||||||
.eq("flow_type", 1)
|
.eq("flow_type", 1)
|
||||||
.doQuery(ApprovalFlow.class);
|
.doQuery(ApprovalFlow.class);
|
||||||
if (templateFlows != null && !templateFlows.isEmpty()) {
|
if (templateFlows != null && !templateFlows.isEmpty()) {
|
||||||
throw new MpaasBusinessException("模板已发起审批");
|
throw new CommonException("模板已发起审批");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 创建审批流程
|
// 2. 创建审批流程
|
||||||
@ -159,20 +159,20 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
|
|||||||
.eq("flow_type", 1)
|
.eq("flow_type", 1)
|
||||||
.doQueryFirst(ApprovalFlow.class);
|
.doQueryFirst(ApprovalFlow.class);
|
||||||
if (flow == null || !"APPROVING".equals(flow.getFlowStatus())) {
|
if (flow == null || !"APPROVING".equals(flow.getFlowStatus())) {
|
||||||
throw new MpaasBusinessException("流程不存在或已结束");
|
throw new CommonException("流程不存在或已结束");
|
||||||
}
|
}
|
||||||
|
|
||||||
String currentNode = flow.getCurrentNode();
|
String currentNode = flow.getCurrentNode();
|
||||||
// 验证当前用户是否有权限处理
|
// 验证当前用户是否有权限处理
|
||||||
if (!hasPermission(flow, currentNode, request.getUserId())) {
|
if (!hasPermission(flow, currentNode, request.getUserId())) {
|
||||||
throw new MpaasBusinessException("无权限处理或已被处理");
|
throw new CommonException("无权限处理或已被处理");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!"COUNTERSIGN".equals(currentNode)) {
|
if (!"COUNTERSIGN".equals(currentNode)) {
|
||||||
String lockKey = FLOW_LOCK_PREFIX + flow.getId() + ":" + currentNode;
|
String lockKey = FLOW_LOCK_PREFIX + flow.getId() + ":" + currentNode;
|
||||||
Boolean lock = redisTemplate.opsForValue().setIfAbsent(lockKey, "1", FLOW_LOCK_EXPIRE_SECONDS, TimeUnit.SECONDS);
|
Boolean lock = redisTemplate.opsForValue().setIfAbsent(lockKey, "1", FLOW_LOCK_EXPIRE_SECONDS, TimeUnit.SECONDS);
|
||||||
if (Boolean.FALSE.equals(lock)) {
|
if (Boolean.FALSE.equals(lock)) {
|
||||||
throw new MpaasBusinessException("当前节点正在处理,请稍后重试");
|
throw new CommonException("当前节点正在处理,请稍后重试");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// 校验抢签节点是否已被处理
|
// 校验抢签节点是否已被处理
|
||||||
@ -180,7 +180,7 @@ public class TemplateApprovalServiceImpl implements TemplateApprovalService {
|
|||||||
long result = Optional.ofNullable(redisTemplate.opsForSet().size(processedKey))
|
long result = Optional.ofNullable(redisTemplate.opsForSet().size(processedKey))
|
||||||
.orElse(0L);
|
.orElse(0L);
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
throw new MpaasBusinessException("此节点已被他人处理");
|
throw new CommonException("此节点已被他人处理");
|
||||||
}
|
}
|
||||||
processApprovalLogic(flow, request, currentNode);
|
processApprovalLogic(flow, request, currentNode);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@ -1,22 +1,17 @@
|
|||||||
package com.xdap.self_development.service.impl;
|
package com.xdap.self_development.service.impl;
|
||||||
|
|
||||||
import com.alibaba.excel.EasyExcel;
|
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.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;
|
import com.definesys.mpaas.query.db.PageQueryResult;
|
||||||
|
import com.xdap.self_development.common.MyResponse;
|
||||||
import com.xdap.self_development.config.BusinessDatabase;
|
import com.xdap.self_development.config.BusinessDatabase;
|
||||||
import com.xdap.self_development.controller.form.*;
|
import com.xdap.self_development.controller.form.*;
|
||||||
|
import com.xdap.self_development.exception.CommonException;
|
||||||
import com.xdap.self_development.listener.SheetDataListener;
|
import com.xdap.self_development.listener.SheetDataListener;
|
||||||
import com.xdap.self_development.pojo.Parameter;
|
import com.xdap.self_development.pojo.Parameter;
|
||||||
import com.xdap.self_development.pojo.RevisionRecord;
|
import com.xdap.self_development.pojo.RevisionRecord;
|
||||||
import com.xdap.self_development.pojo.Template;
|
import com.xdap.self_development.pojo.Template;
|
||||||
import com.xdap.self_development.pojo.TemplateAndParameter;
|
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.service.TemplateService;
|
||||||
import com.xdap.self_development.utils.FormulaValidator;
|
import com.xdap.self_development.utils.FormulaValidator;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -69,11 +64,11 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
switch (template.getStatus()) {
|
switch (template.getStatus()) {
|
||||||
// 最新版本为草稿,提示已有草稿
|
// 最新版本为草稿,提示已有草稿
|
||||||
case "DRAFT":
|
case "DRAFT":
|
||||||
throw new MpaasRuntimeException("最新版本已为草稿,请勿重复新增");
|
throw new CommonException("最新版本已为草稿,请勿重复新增");
|
||||||
case "APPROVING":
|
case "APPROVING":
|
||||||
throw new MpaasRuntimeException("最新版本正在审核中,请勿重复新增");
|
throw new CommonException("最新版本正在审核中,请勿重复新增");
|
||||||
case "RETURNED":
|
case "RETURNED":
|
||||||
throw new MpaasRuntimeException("最新版本已被退回,请重新修改模板");
|
throw new CommonException("最新版本已被退回,请重新修改模板");
|
||||||
}
|
}
|
||||||
// 可新增版本
|
// 可新增版本
|
||||||
newTemplate.setVersion(template.getVersion() + 1);
|
newTemplate.setVersion(template.getVersion() + 1);
|
||||||
@ -91,7 +86,7 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
.doQueryFirst(Template.class);
|
.doQueryFirst(Template.class);
|
||||||
|
|
||||||
if (template != null) {
|
if (template != null) {
|
||||||
throw new MpaasBusinessException("不可修改为已有模板");
|
throw new CommonException("不可修改为已有模板");
|
||||||
}
|
}
|
||||||
|
|
||||||
Template newTemplate = new Template(
|
Template newTemplate = new Template(
|
||||||
@ -105,22 +100,22 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = MpaasBusinessException.class)
|
@Transactional(rollbackFor = CommonException.class)
|
||||||
public TemplateImportProblemView importTemplate(MultipartFile file, String templateRowId, String createBy) {
|
public MyResponse importTemplate(MultipartFile file, String templateRowId, String createBy) {
|
||||||
// 验证文件是否为工作表
|
// 验证文件是否为工作表
|
||||||
if (file == null || file.isEmpty()) {
|
if (file == null || file.isEmpty()) {
|
||||||
throw new MpaasBusinessException("文件不能为空");
|
throw new CommonException("文件不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
String filename = file.getOriginalFilename();
|
String filename = file.getOriginalFilename();
|
||||||
if (filename == null ||
|
if (filename == null ||
|
||||||
!(filename.toLowerCase().endsWith(".xls") ||
|
!(filename.toLowerCase().endsWith(".xls") ||
|
||||||
filename.toLowerCase().endsWith(".xlsx"))) {
|
filename.toLowerCase().endsWith(".xlsx"))) {
|
||||||
throw new MpaasBusinessException("只支持 .xls 或 .xlsx 格式的文件");
|
throw new CommonException("只支持 .xls 或 .xlsx 格式的文件");
|
||||||
}
|
}
|
||||||
|
|
||||||
TemplateImportProblemView problems =
|
MyResponse problems =
|
||||||
new TemplateImportProblemView(false, new ArrayList<>(), new StringBuilder("已完成导入:无"));
|
new MyResponse(false, new ArrayList<>(), new StringBuilder("已完成导入:无"));
|
||||||
|
|
||||||
|
|
||||||
try (InputStream inputStream = file.getInputStream()){
|
try (InputStream inputStream = file.getInputStream()){
|
||||||
@ -131,7 +126,7 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
).doReadAll();
|
).doReadAll();
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new MpaasRuntimeException("读取文件失败");
|
throw new CommonException("读取文件失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
return problems;
|
return problems;
|
||||||
@ -180,7 +175,7 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
.doWrite(list);
|
.doWrite(list);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new MpaasRuntimeException("导出Excel失败: " + e.getMessage());
|
throw new CommonException("导出Excel失败: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +192,7 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processSheetData(List<Parameter> dataList, String sheetName,
|
public void processSheetData(List<Parameter> dataList, String sheetName,
|
||||||
String templateRowId, String createBy, TemplateImportProblemView problems) {
|
String templateRowId, String createBy, MyResponse problems) {
|
||||||
if (dataList.isEmpty()) {
|
if (dataList.isEmpty()) {
|
||||||
log.warn("Sheet {} 没有数据", sheetName);
|
log.warn("Sheet {} 没有数据", sheetName);
|
||||||
return;
|
return;
|
||||||
@ -214,7 +209,6 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
validationResult.get("errorMessage"));
|
validationResult.get("errorMessage"));
|
||||||
problems.setFlag(true);
|
problems.setFlag(true);
|
||||||
problems.getErrors().add(errorMsg);
|
problems.getErrors().add(errorMsg);
|
||||||
// throw new MpaasRuntimeException(errorMsg);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,7 +228,6 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
problems.setFlag(true);
|
problems.setFlag(true);
|
||||||
problems.getErrors().add("Excel页名与模板名不一致");
|
problems.getErrors().add("Excel页名与模板名不一致");
|
||||||
return;
|
return;
|
||||||
// throw new MpaasBusinessException("Excel页名不正确或模板名不正确");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,18 +252,15 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
problems.setFlag(true);
|
problems.setFlag(true);
|
||||||
problems.getErrors().add("模板‘"+templateName+"’已有参数,无法导入");
|
problems.getErrors().add("模板‘"+templateName+"’已有参数,无法导入");
|
||||||
return;
|
return;
|
||||||
// throw new MpaasBusinessException("模板‘"+templateName+"’已有参数,无法导入");
|
|
||||||
}
|
}
|
||||||
case "APPROVING":
|
case "APPROVING":
|
||||||
problems.setFlag(true);
|
problems.setFlag(true);
|
||||||
problems.getErrors().add("模板‘"+templateName+"‘的最新版本正在审核中,无法导入");
|
problems.getErrors().add("模板‘"+templateName+"‘的最新版本正在审核中,无法导入");
|
||||||
return;
|
return;
|
||||||
// throw new MpaasRuntimeException("模板‘"+templateName+"‘最新版本正在审核中,无法导入");
|
|
||||||
case "RETURNED":
|
case "RETURNED":
|
||||||
problems.setFlag(true);
|
problems.setFlag(true);
|
||||||
problems.getErrors().add("模板‘"+templateName+"’的最新版本已被退回,无法导入");
|
problems.getErrors().add("模板‘"+templateName+"’的最新版本已被退回,无法导入");
|
||||||
return;
|
return;
|
||||||
// throw new MpaasRuntimeException("模板‘"+templateName+"’最新版本已被退回,无法导入");
|
|
||||||
// 最新版本已发布或已退回,增加版本号新增
|
// 最新版本已发布或已退回,增加版本号新增
|
||||||
default:
|
default:
|
||||||
lastTemplate = new Template(
|
lastTemplate = new Template(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user