|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package cn.iocoder.yudao.module.accounting.controller.admin.accountingreport;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.io.IoUtil;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
|
|
|
|
|
import cn.iocoder.yudao.framework.file.core.client.s3.S3FileClient;
|
|
|
|
@ -12,6 +13,7 @@ import cn.iocoder.yudao.module.accounting.convert.accountingreport.AccountingRep
|
|
|
|
|
import cn.iocoder.yudao.module.accounting.dal.dataobject.accountingbook.AccountingBookDO;
|
|
|
|
|
import cn.iocoder.yudao.module.accounting.dal.dataobject.accountingreport.AccountingReportDO;
|
|
|
|
|
import cn.iocoder.yudao.module.accounting.service.accountingreport.AccountingReportService;
|
|
|
|
|
import cn.iocoder.yudao.module.infra.service.file.FileService;
|
|
|
|
|
import cn.iocoder.yudao.module.setting.service.passwords.PasswordsService;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
@ -45,12 +47,10 @@ public class AccountingReportController {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private AccountingReportService accountingReportService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private RedisTemplate redisTemplate;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private PasswordsService passwordsService;
|
|
|
|
|
@Resource
|
|
|
|
|
private FileService fileService;
|
|
|
|
|
|
|
|
|
|
@PostMapping("/create")
|
|
|
|
|
@Operation(summary = "创建会计报表")
|
|
|
|
@ -65,30 +65,20 @@ public class AccountingReportController {
|
|
|
|
|
@PostMapping("/upload")
|
|
|
|
|
@Operation(summary = "上传会计报表")
|
|
|
|
|
@PreAuthorize("@ss.hasPermission('archives:accounting-report:create')")
|
|
|
|
|
public String uploadAccountingBook(@RequestPart("file") MultipartFile multipartFile, @RequestParam("type") String type) {
|
|
|
|
|
public String uploadAccountingBook(@RequestPart("file") MultipartFile multipartFile, @RequestParam("type") String type,
|
|
|
|
|
@RequestParam("companyId") Long companyId,
|
|
|
|
|
@RequestParam("company") String company,
|
|
|
|
|
@RequestParam("year") String year,
|
|
|
|
|
@RequestParam("period") String period) {
|
|
|
|
|
try {
|
|
|
|
|
//TODO minio配置 后续修改
|
|
|
|
|
S3FileClientConfig config = new S3FileClientConfig();
|
|
|
|
|
// 配置成你自己的
|
|
|
|
|
config.setAccessKey("minioadmin");
|
|
|
|
|
config.setAccessSecret("minioadmin");
|
|
|
|
|
config.setBucket("ktg-mes");
|
|
|
|
|
config.setDomain(null);
|
|
|
|
|
// 默认 9000 endpoint
|
|
|
|
|
config.setEndpoint("https://www.lyrfp.com");
|
|
|
|
|
|
|
|
|
|
// 执行上传
|
|
|
|
|
String uri = testExecuteUpload(config, multipartFile);
|
|
|
|
|
// String uri = fileService.createFile(multipartFile.getOriginalFilename(), multipartFile.getOriginalFilename(), multipartFile.getBytes());
|
|
|
|
|
//加入redis缓存
|
|
|
|
|
redisTemplate.boundValueOps("reportFileUrlKey").set(uri);
|
|
|
|
|
redisTemplate.boundValueOps("reportFileKeyName").set(multipartFile.getOriginalFilename());
|
|
|
|
|
redisTemplate.boundValueOps("reportFileKeyType").set(type);
|
|
|
|
|
String uri = fileService.createFile(multipartFile.getOriginalFilename(), null, IoUtil.readBytes(multipartFile.getInputStream()));
|
|
|
|
|
AccountingReportCreateReqVO vo = new AccountingReportCreateReqVO();
|
|
|
|
|
vo.setCompany(company).setCompanyId(companyId).setType(type).setYear(year).setPeriod(period).setUrl(uri).setName(multipartFile.getOriginalFilename());
|
|
|
|
|
return uri;
|
|
|
|
|
} catch (Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return "vo";
|
|
|
|
|
return "上传失败";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TODO minio上传函数 后续封装为公用方法
|
|
|
|
|