修改对标报告的附件上传问题

This commit is contained in:
zjh 2025-12-02 17:19:38 +08:00
parent 9683489c3a
commit cf058a1734
11 changed files with 103 additions and 19 deletions

View File

@ -11,10 +11,12 @@ import com.xdap.self_development.pojo.view.TodoAndReportView;
import com.xdap.self_development.service.BenchmarkingReportService;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
@RestController
@ -23,6 +25,16 @@ public class BenchmarkingReportController {
@Resource
private BenchmarkingReportService benchmarkingReportService;
// 上传附件
@PostMapping("/uploadFile")
public Response uploadFile(
@NotNull @RequestPart MultipartFile file,
@NotBlank @RequestPart String createBy
) {
String fileUrl = benchmarkingReportService.uploadFile(file, createBy);
return Response.ok().data(fileUrl);
}
// 新增对标报告并发起审批
@PostMapping("/startReportApproval")
public Response startReportApproval(

View File

@ -0,0 +1,10 @@
package com.xdap.self_development.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/custom/permission")
public class PermissionController {
// 查看
}

View File

@ -1,6 +1,7 @@
package com.xdap.self_development.controller.form;
import lombok.Data;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.NotBlank;
@ -36,7 +37,7 @@ public class SaveBenchmarkingReportForm {
@NotBlank(message = "项目编号不能为空")
private String projectNumber;
private MultipartFile file;
private String fileUrl;
@NotEmpty(message = "校对人员不能为空")
private List<String> proofreadUsers;

View File

@ -0,0 +1,19 @@
package com.xdap.self_development.pojo;
import com.definesys.mpaas.query.annotation.RowID;
import com.definesys.mpaas.query.annotation.RowIDType;
import com.definesys.mpaas.query.annotation.Table;
import com.definesys.mpaas.query.model.MpaasBasePojo;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
@Table("yfsjglpt_model_permissions")
public class Permissions extends MpaasBasePojo {
@RowID(value = "permissions_s", type = RowIDType.UUID)
private String id;
private String permissionName;
private String permPath;
private String description;
}

View File

@ -0,0 +1,18 @@
package com.xdap.self_development.pojo;
import com.definesys.mpaas.query.annotation.RowID;
import com.definesys.mpaas.query.annotation.RowIDType;
import com.definesys.mpaas.query.annotation.Table;
import com.definesys.mpaas.query.model.MpaasBasePojo;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
@Table("yfsjglpt_model_roles")
public class Role extends MpaasBasePojo {
@RowID(value = "roles_s", type = RowIDType.UUID)
private String id;
private String roleName;
private String description;
}

View File

@ -0,0 +1,18 @@
package com.xdap.self_development.pojo;
import com.definesys.mpaas.query.annotation.RowID;
import com.definesys.mpaas.query.annotation.RowIDType;
import com.definesys.mpaas.query.annotation.Table;
import com.definesys.mpaas.query.model.MpaasBasePojo;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
@Table("yfsjglpt_model_role_permissions")
public class RoleAndPermissions extends MpaasBasePojo {
@RowID(value = "role_permissions_s", type = RowIDType.UUID)
private String id;
private String roleId;
private String permissionId;
}

View File

@ -0,0 +1,18 @@
package com.xdap.self_development.pojo;
import com.definesys.mpaas.query.annotation.RowID;
import com.definesys.mpaas.query.annotation.RowIDType;
import com.definesys.mpaas.query.annotation.Table;
import com.definesys.mpaas.query.model.MpaasBasePojo;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
@Table("yfsjglpt_model_user_roles")
public class UserAndRoles extends MpaasBasePojo {
@RowID(value = "user_roles_s", type = RowIDType.UUID)
private String id;
private String roleId;
private String userId;
}

View File

@ -1,4 +0,0 @@
package com.xdap.self_development.pojo;
public class permissions {
}

View File

@ -1,4 +0,0 @@
package com.xdap.self_development.pojo;
public class role {
}

View File

@ -6,6 +6,7 @@ import com.xdap.self_development.controller.form.SaveBenchmarkingReportForm;
import com.xdap.self_development.pojo.BenchmarkingReport;
import com.xdap.self_development.pojo.view.ApprovalFlowView;
import com.xdap.self_development.pojo.view.TodoAndReportView;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
@ -21,4 +22,6 @@ public interface BenchmarkingReportService {
BenchmarkingReport getReportDetail(@NotBlank String reportId);
ApprovalFlowView getReportProcess(@NotBlank String flowId);
String uploadFile(MultipartFile file, @NotBlank String createBy);
}

View File

@ -62,17 +62,9 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
@Transactional
public void saveBenchmarkingReport(SaveBenchmarkingReportForm form) {
// 1. 创建对标报告并保存
String realUrl = "";
if (form.getFile() != null) {
realUrl = uploadFile(form.getFile(), form.getCreateBy());
if (realUrl.isEmpty()) {
throw new MpaasBusinessException("附件上传失败");
}
}
BenchmarkingReport report = new BenchmarkingReport();
BeanUtils.copyProperties(form, report);
report.setFilePath(realUrl);
report.setFilePath(form.getFileUrl() == null ? "" : form.getFileUrl());
report.setUploadTime(Timestamp.valueOf(LocalDateTime.now()));
report.setStatus("APPROVING");
report.setCreateBy(form.getCreateBy());
@ -98,7 +90,8 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
});
}
private String uploadFile(MultipartFile file, String userId) {
@Override
public String uploadFile(MultipartFile file, String userId) {
String currentTenantId = runtimeAppContextService.getCurrentTenantId();
AppTokenDTO token = apaasMyTokenFeign.getAppToken(
"client_credentials",