修改对标报告的附件上传
This commit is contained in:
parent
835a1e7c00
commit
9683489c3a
@ -1,19 +1,22 @@
|
|||||||
package com.xdap.self_development.controller;
|
package com.xdap.self_development.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.codec.Base64;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.definesys.mpaas.common.http.Response;
|
import com.definesys.mpaas.common.http.Response;
|
||||||
import com.xdap.api.moudle.user.vo.LoginUserVo;
|
|
||||||
import com.xdap.runtime.service.RuntimeAppContextService;
|
import com.xdap.runtime.service.RuntimeAppContextService;
|
||||||
import com.xdap.runtime.service.RuntimeUserService;
|
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;
|
||||||
|
import com.xdap.self_development.feign.dto.FileUploadDTO;
|
||||||
|
import com.xdap.self_development.feign.dto.UserTokenDT0;
|
||||||
import com.xdap.self_development.pojo.*;
|
import com.xdap.self_development.pojo.*;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.bson.types.ObjectId;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -21,6 +24,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/custom/delete")
|
@RequestMapping("/custom/delete")
|
||||||
public class DeleteController {
|
public class DeleteController {
|
||||||
@ -33,18 +37,50 @@ public class DeleteController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApaasMyTokenFeign apaasMyTokenFeign;
|
private ApaasMyTokenFeign apaasMyTokenFeign;
|
||||||
|
|
||||||
@GetMapping("/loginVo")
|
@PostMapping("/uploadFile")
|
||||||
public Response loginVo(@RequestParam String userId) {
|
public Response uploadFile(@RequestPart("file") MultipartFile file) {
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
AppTokenDTO token = apaasMyTokenFeign.getAppToken(
|
AppTokenDTO token = apaasMyTokenFeign.getAppToken(
|
||||||
"client_credentials",
|
"client_credentials",
|
||||||
"2b5b3de8-e7fd-406a-a59a-d5568457b1f4",
|
"2b5b3de8-e7fd-406a-a59a-d5568457b1f4",
|
||||||
"94bddc6a-27a4-4204-885b-b075812ec535"
|
"94bddc6a-27a4-4204-885b-b075812ec535"
|
||||||
);
|
);
|
||||||
map.put("token", token);
|
map.put("appToken", token);
|
||||||
|
log.info("loginVo token:{}", token);
|
||||||
|
|
||||||
|
UserTokenDT0 userToken = apaasMyTokenFeign.getUserToken(
|
||||||
|
token.getAccess_token(),
|
||||||
|
"100771325212057665536"
|
||||||
|
);
|
||||||
|
map.put("userToken", userToken);
|
||||||
|
log.info("loginVo userToken:{}", userToken);
|
||||||
|
|
||||||
|
String uploadId = new ObjectId().toHexString();
|
||||||
|
FileUploadDTO fileUploadDTO = apaasMyTokenFeign.uploadFile(
|
||||||
|
"Bearer " + userToken.getAccess_token(),
|
||||||
|
"application/x-www-form-urlencoded",
|
||||||
|
file,
|
||||||
|
uploadId,
|
||||||
|
"223770822127386625",
|
||||||
|
"100771325212057665536"
|
||||||
|
);
|
||||||
|
map.put("fileUploadDTO", fileUploadDTO);
|
||||||
|
log.info("loginVo fileUploadDTO:{}", fileUploadDTO);
|
||||||
return Response.ok().data(map);
|
return Response.ok().data(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/downloadFile")
|
||||||
|
public Response downloadFile(
|
||||||
|
@RequestParam String url
|
||||||
|
) {
|
||||||
|
Map<String, String> map = new HashMap<>();
|
||||||
|
map.put("xdaptenantid", "223770822127386625");
|
||||||
|
cn.hutool.json.JSON json = JSONUtil.parse(map);
|
||||||
|
String token = Base64.encode(json.toString());
|
||||||
|
String realUrl = url +"&download=download&token="+token;
|
||||||
|
return Response.ok().data(realUrl);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("getAll")
|
@GetMapping("getAll")
|
||||||
public Response getAll() {
|
public Response getAll() {
|
||||||
List<Template> templates = bd.getBusinessDatabase().doQuery(Template.class);
|
List<Template> templates = bd.getBusinessDatabase().doQuery(Template.class);
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.xdap.self_development.controller.form;
|
package com.xdap.self_development.controller.form;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
@ -35,7 +36,7 @@ public class SaveBenchmarkingReportForm {
|
|||||||
@NotBlank(message = "项目编号不能为空")
|
@NotBlank(message = "项目编号不能为空")
|
||||||
private String projectNumber;
|
private String projectNumber;
|
||||||
|
|
||||||
private String fileUrl;
|
private MultipartFile file;
|
||||||
|
|
||||||
@NotEmpty(message = "校对人员不能为空")
|
@NotEmpty(message = "校对人员不能为空")
|
||||||
private List<String> proofreadUsers;
|
private List<String> proofreadUsers;
|
||||||
|
|||||||
@ -1,13 +1,23 @@
|
|||||||
package com.xdap.self_development.feign;
|
package com.xdap.self_development.feign;
|
||||||
|
|
||||||
|
import com.xdap.common.config.FeignConfig;
|
||||||
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.UserTokenDT0;
|
import com.xdap.self_development.feign.dto.UserTokenDT0;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@FeignClient(name = "apaas-client", url = "${apaas.token.url}")
|
import java.util.Map;
|
||||||
|
|
||||||
|
@FeignClient(
|
||||||
|
name = "apaas-client",
|
||||||
|
url = "${apaas.token.url}",
|
||||||
|
configuration = FeignConfig.class
|
||||||
|
)
|
||||||
public interface ApaasMyTokenFeign {
|
public interface ApaasMyTokenFeign {
|
||||||
|
// 获取应用凭证
|
||||||
@PostMapping("/xdap-open/token")
|
@PostMapping("/xdap-open/token")
|
||||||
AppTokenDTO getAppToken(
|
AppTokenDTO getAppToken(
|
||||||
@RequestParam("grant_type") String grant_type,
|
@RequestParam("grant_type") String grant_type,
|
||||||
@ -15,9 +25,23 @@ public interface ApaasMyTokenFeign {
|
|||||||
@RequestParam("client_secret")String client_secret
|
@RequestParam("client_secret")String client_secret
|
||||||
);
|
);
|
||||||
|
|
||||||
@PostMapping("/xdap-open/token/userToken")
|
// 获取用户凭证
|
||||||
|
@GetMapping("/xdap-open/token/userToken")
|
||||||
UserTokenDT0 getUserToken(
|
UserTokenDT0 getUserToken(
|
||||||
@RequestParam("token") String token,
|
@RequestParam("token") String token,
|
||||||
@RequestParam("userid") String userid
|
@RequestParam("userId") String userId
|
||||||
|
);
|
||||||
|
|
||||||
|
// 上传文件
|
||||||
|
@PostMapping(value = "/xdap-open/open/attachments/v1/simpleUploadFile",
|
||||||
|
consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
|
FileUploadDTO uploadFile(
|
||||||
|
@RequestHeader(value = "Authorization") String access_token,
|
||||||
|
@RequestHeader("Content-Type") String type,
|
||||||
|
|
||||||
|
@RequestPart("file") MultipartFile file,
|
||||||
|
@RequestPart("uploadId") String uploadId,
|
||||||
|
@RequestPart("tenantId") String tenantId,
|
||||||
|
@RequestPart("userId") String userId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.xdap.self_development.feign.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class FileDataDTO {
|
||||||
|
private String id;
|
||||||
|
private String userId;
|
||||||
|
private String url;
|
||||||
|
private String fileName;
|
||||||
|
private String fileType;
|
||||||
|
private String fileSize;
|
||||||
|
private String fileSizeStr;
|
||||||
|
private String ossBucketName;
|
||||||
|
private String ossObjectName;
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
package com.xdap.self_development.feign.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class FileUploadDTO {
|
||||||
|
private String code;
|
||||||
|
private String message;
|
||||||
|
private FileDataDTO data;
|
||||||
|
}
|
||||||
@ -9,6 +9,10 @@ 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.feign.ApaasMyTokenFeign;
|
||||||
|
import com.xdap.self_development.feign.dto.AppTokenDTO;
|
||||||
|
import com.xdap.self_development.feign.dto.FileUploadDTO;
|
||||||
|
import com.xdap.self_development.feign.dto.UserTokenDT0;
|
||||||
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 com.xdap.self_development.pojo.ApprovalXdapUsers;
|
import com.xdap.self_development.pojo.ApprovalXdapUsers;
|
||||||
@ -17,11 +21,14 @@ import com.xdap.self_development.pojo.view.ApprovalFlowView;
|
|||||||
import com.xdap.self_development.pojo.view.ApprovalNodeView;
|
import com.xdap.self_development.pojo.view.ApprovalNodeView;
|
||||||
import com.xdap.self_development.pojo.view.TodoAndReportView;
|
import com.xdap.self_development.pojo.view.TodoAndReportView;
|
||||||
import com.xdap.self_development.service.BenchmarkingReportService;
|
import com.xdap.self_development.service.BenchmarkingReportService;
|
||||||
|
import org.bson.types.ObjectId;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
@ -37,6 +44,14 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
|||||||
private StringRedisTemplate redisTemplate;
|
private StringRedisTemplate redisTemplate;
|
||||||
@Resource
|
@Resource
|
||||||
private RuntimeAppContextService runtimeAppContextService;
|
private RuntimeAppContextService runtimeAppContextService;
|
||||||
|
@Autowired
|
||||||
|
private ApaasMyTokenFeign apaasMyTokenFeign;
|
||||||
|
|
||||||
|
@Value("${apaas.token.clientId}")
|
||||||
|
private String clientId;
|
||||||
|
@Value("${apaas.token.clientSecred}")
|
||||||
|
private String clientSecret;
|
||||||
|
|
||||||
|
|
||||||
private static final String TODO_PREFIX = "report:todo:";
|
private static final String TODO_PREFIX = "report:todo:";
|
||||||
private static final String NODE_PROCESSED_PREFIX = "report:node:processed:";
|
private static final String NODE_PROCESSED_PREFIX = "report:node:processed:";
|
||||||
@ -47,12 +62,14 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
|||||||
@Transactional
|
@Transactional
|
||||||
public void saveBenchmarkingReport(SaveBenchmarkingReportForm form) {
|
public void saveBenchmarkingReport(SaveBenchmarkingReportForm form) {
|
||||||
// 1. 创建对标报告并保存
|
// 1. 创建对标报告并保存
|
||||||
String currentTenantId = runtimeAppContextService.getCurrentTenantId();
|
String realUrl = "";
|
||||||
Map<String, String> map = new HashMap<>();
|
if (form.getFile() != null) {
|
||||||
map.put("xdaptenantid", currentTenantId);
|
realUrl = uploadFile(form.getFile(), form.getCreateBy());
|
||||||
cn.hutool.json.JSON json = JSONUtil.parse(map);
|
if (realUrl.isEmpty()) {
|
||||||
String token = Base64.encode(json.toString());
|
throw new MpaasBusinessException("附件上传失败");
|
||||||
String realUrl = form.getFileUrl()+"&download=download&token="+token;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BenchmarkingReport report = new BenchmarkingReport();
|
BenchmarkingReport report = new BenchmarkingReport();
|
||||||
BeanUtils.copyProperties(form, report);
|
BeanUtils.copyProperties(form, report);
|
||||||
report.setFilePath(realUrl);
|
report.setFilePath(realUrl);
|
||||||
@ -81,6 +98,35 @@ public class BenchmarkingReportServiceImpl implements BenchmarkingReportService
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String uploadFile(MultipartFile file, String userId) {
|
||||||
|
String currentTenantId = runtimeAppContextService.getCurrentTenantId();
|
||||||
|
AppTokenDTO token = apaasMyTokenFeign.getAppToken(
|
||||||
|
"client_credentials",
|
||||||
|
clientId,
|
||||||
|
clientSecret
|
||||||
|
);
|
||||||
|
|
||||||
|
UserTokenDT0 userToken = apaasMyTokenFeign.getUserToken(
|
||||||
|
token.getAccess_token(),
|
||||||
|
userId
|
||||||
|
);
|
||||||
|
|
||||||
|
String uploadId = new ObjectId().toHexString();
|
||||||
|
FileUploadDTO fileUploadDTO = apaasMyTokenFeign.uploadFile(
|
||||||
|
"Bearer " + userToken.getAccess_token(),
|
||||||
|
"application/x-www-form-urlencoded",
|
||||||
|
file,
|
||||||
|
uploadId,
|
||||||
|
currentTenantId,
|
||||||
|
userId
|
||||||
|
);
|
||||||
|
Map<String, String> map = new HashMap<>();
|
||||||
|
map.put("xdaptenantid", currentTenantId);
|
||||||
|
cn.hutool.json.JSON json = JSONUtil.parse(map);
|
||||||
|
String tokenXdap = Base64.encode(json.toString());
|
||||||
|
return fileUploadDTO.getData().getUrl() +"&download=download&token=" + tokenXdap;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TodoAndReportView> getBenchmarkingReportByCondition(BenchmarkingReportPageForm form) {
|
public List<TodoAndReportView> getBenchmarkingReportByCondition(BenchmarkingReportPageForm form) {
|
||||||
List<TodoAndReportView> approvalList = new ArrayList<>();
|
List<TodoAndReportView> approvalList = new ArrayList<>();
|
||||||
|
|||||||
@ -51,13 +51,6 @@ public class ResponsiblePersonServiceImpl implements ResponsiblePersonService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateResponsiblePerson(UpdateResponsiblePersonForm form) {
|
public void updateResponsiblePerson(UpdateResponsiblePersonForm form) {
|
||||||
List<ResponsiblePerson> responsiblePeople = bd.getBusinessDatabase()
|
|
||||||
.eq("department_id", form.getDepartmentId())
|
|
||||||
.doQuery(ResponsiblePerson.class);
|
|
||||||
if (!responsiblePeople.isEmpty()) {
|
|
||||||
throw new MpaasBusinessException("该部门已有责任人");
|
|
||||||
}
|
|
||||||
|
|
||||||
bd.getBusinessDatabase()
|
bd.getBusinessDatabase()
|
||||||
.rowid("id", form.getRowId())
|
.rowid("id", form.getRowId())
|
||||||
.update("department_id", form.getDepartmentId())
|
.update("department_id", form.getDepartmentId())
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
apaas.token.url=http://apaas-meim.app.yuchai.com/apaas/backend/a5e8e08/ycgf-yf-rddata
|
apaas.token.url=http://apaas-meim.app.yuchai.com/apaas/backend/a5e8e08/ycgf-yf-rddata
|
||||||
|
apaas.token.clientId=2b5b3de8-e7fd-406a-a59a-d5568457b1f4
|
||||||
|
apaas.token.clientSecred=94bddc6a-27a4-4204-885b-b075812ec535
|
||||||
|
|
||||||
feign.hystrix.enabled=false
|
feign.hystrix.enabled=false
|
||||||
deploy.backend.platform.port=30607
|
deploy.backend.platform.port=30607
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user