|
@@ -0,0 +1,101 @@
|
|
|
|
+package com.dayou.controller;
|
|
|
|
+
|
|
|
|
+import cn.dev33.satoken.annotation.SaCheckLogin;
|
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
|
+import com.dayou.config.FileNetConfig;
|
|
|
|
+import com.dayou.entity.AssetsCalculate;
|
|
|
|
+import com.dayou.entity.DocumentProduction;
|
|
|
|
+import com.dayou.result.Result;
|
|
|
|
+import com.dayou.result.Status;
|
|
|
|
+import com.dayou.service.AssetsCalculateService;
|
|
|
|
+import com.dayou.service.DocumentProductionService;
|
|
|
|
+import com.dayou.utils.FileNetUtil;
|
|
|
|
+import com.dayou.vo.AssetsCalculateVO;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
+
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.util.Objects;
|
|
|
|
+
|
|
|
|
+import static com.dayou.enums.DocumentType.CR_CALCULATE;
|
|
|
|
+import static com.dayou.enums.DocumentType.EQPT_CALCULATE;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 资产债权测算数据
|
|
|
|
+ *
|
|
|
|
+ * @author GouGengquan
|
|
|
|
+ * @since 2024-11-18
|
|
|
|
+ */
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("assetsCalculateCRData")
|
|
|
|
+@Slf4j
|
|
|
|
+@CrossOrigin
|
|
|
|
+@SaCheckLogin
|
|
|
|
+public class AssetsCalculateCRDataController {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private FileNetConfig fileNetConfig;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private AssetsCalculateService assetsCalculateService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private DocumentProductionService documentProductionService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 上传债权测算表
|
|
|
|
+ * @param multipartFile 文件
|
|
|
|
+ * @param calculateId 测算表id
|
|
|
|
+ * @return Boolean
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ @PostMapping("/uploadCalculate")
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public Result<Boolean> uploadCalculate(MultipartFile multipartFile, Long calculateId) throws IOException {
|
|
|
|
+ // 判断文件类型
|
|
|
|
+ String name;
|
|
|
|
+ if (Objects.equals(multipartFile.getContentType(), "application/vnd.ms-excel") || Objects.equals(multipartFile.getContentType(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) {
|
|
|
|
+ // 上传文件
|
|
|
|
+ name = System.currentTimeMillis() + "_债权测算表.xlsx";
|
|
|
|
+ FileNetUtil.uploadToServer(multipartFile, fileNetConfig.getBaseDir(), fileNetConfig.getAssetOutputCalculatePath(), name);
|
|
|
|
+
|
|
|
|
+ // 更新测算表进度
|
|
|
|
+ AssetsCalculate assetsCalculate = new AssetsCalculate();
|
|
|
|
+ assetsCalculate.setId(calculateId);
|
|
|
|
+ assetsCalculate.setProgress("FINISHED");
|
|
|
|
+ assetsCalculateService.updateById(assetsCalculate);
|
|
|
|
+
|
|
|
|
+ // 设置文档信息
|
|
|
|
+ AssetsCalculateVO assetsCalculateVO = assetsCalculateService.getCalculateInfoForDoc(calculateId);
|
|
|
|
+ DocumentProduction documentProduction = documentProductionService.getDocProdByBusinessId(assetsCalculateVO.getProjectId(), calculateId);
|
|
|
|
+
|
|
|
|
+ if (ObjectUtil.isNotNull(documentProduction)) { // 判断文档信息是否为空,不为空说明以前生成过文档,则更新文档版本号
|
|
|
|
+ documentProduction.setDocVersion(documentProduction.getDocVersion() + 1);
|
|
|
|
+ } else { // 为空重新new对象
|
|
|
|
+ documentProduction = new DocumentProduction();
|
|
|
|
+ }
|
|
|
|
+ documentProduction.setBusinessType("ASSETS")
|
|
|
|
+ .setBusinessId(assetsCalculateVO.getProjectId())
|
|
|
|
+ .setDocType(CR_CALCULATE.getName())
|
|
|
|
+ .setDocName(assetsCalculateVO.getCalculateName() + ".xlsx")
|
|
|
|
+ .setConsignor(assetsCalculateVO.getPrincipal())
|
|
|
|
+ .setDocUrl(fileNetConfig.getAssetOutputCalculatePath() + name)
|
|
|
|
+ .setCreateUserId(StpUtil.getLoginIdAsLong())
|
|
|
|
+ .setBusinessCate(assetsCalculateVO.getProjectTypeName())
|
|
|
|
+ .setDocNo("")
|
|
|
|
+ .setBusinessSubId(calculateId);
|
|
|
|
+ documentProductionService.saveDocumentProduction(documentProduction);
|
|
|
|
+ }else {
|
|
|
|
+ return Result.build(Status.PARAM_ERROR, "请上传xls或xlsx类型的excel文档!");
|
|
|
|
+ }
|
|
|
|
+ return Result.build(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|