|
|
@@ -6,10 +6,12 @@ import com.hotent.base.constants.ApiGroupConsts;
|
|
|
import com.hotent.base.controller.BaseController;
|
|
|
import com.hotent.base.model.CommonResult;
|
|
|
import com.hotent.base.util.StringUtil;
|
|
|
+import com.hotent.project.manager.CostProjectTaskManager;
|
|
|
import com.hotent.project.manager.CostProjectTaskMaterialSummaryDetailManager;
|
|
|
import com.hotent.project.manager.CostProjectTaskMaterialSummaryManager;
|
|
|
import com.hotent.project.model.CostProjectTask;
|
|
|
import com.hotent.project.model.CostProjectTaskMaterialSummary;
|
|
|
+import com.hotent.project.model.CostProjectTaskMaterialSummaryDetail;
|
|
|
import com.hotent.project.req.MaterialSummarySortReq;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
@@ -18,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -28,14 +31,17 @@ import java.util.List;
|
|
|
* @since 2025-01-27
|
|
|
*/
|
|
|
@RestController
|
|
|
-@RequestMapping("/api/materialSummary/v1/")
|
|
|
+@RequestMapping("/api/materialSummary/v1")
|
|
|
@Api(tags = "资料归纳主表")
|
|
|
@ApiGroup(group = {ApiGroupConsts.GROUP_COST})
|
|
|
public class CostProjectTaskMaterialSummaryController extends BaseController<CostProjectTaskMaterialSummaryManager, CostProjectTaskMaterialSummary> {
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
- private com.hotent.project.manager.CostProjectTaskManager costProjectTaskManager;
|
|
|
+ private CostProjectTaskManager costProjectTaskManager;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CostProjectTaskMaterialSummaryDetailManager costProjectTaskMaterialSummaryDetailManager;
|
|
|
|
|
|
/**
|
|
|
* 根据taskId获取资料归纳列表
|
|
|
@@ -60,7 +66,7 @@ public class CostProjectTaskMaterialSummaryController extends BaseController<Cos
|
|
|
new LambdaQueryWrapper<CostProjectTask>().eq(CostProjectTask::getPid, taskId)
|
|
|
);
|
|
|
// 同步生成资料归纳
|
|
|
- asyncMaterialSummaryService.generateMaterialSummarySync(mainTask, childTasks);
|
|
|
+ asyncMaterialSummaryService.generateMaterialSummary(mainTask, childTasks);
|
|
|
asyncMaterialSummaryService.calculatePageCountAsync(mainTask.getId());
|
|
|
// 重新查询
|
|
|
summaryList = baseService.listByTaskId(taskId);
|
|
|
@@ -70,6 +76,20 @@ public class CostProjectTaskMaterialSummaryController extends BaseController<Cos
|
|
|
return CommonResult.<List<CostProjectTaskMaterialSummary>>ok().value(summaryList);
|
|
|
}
|
|
|
|
|
|
+ @GetMapping(value = "/DetailistlByMasterId")
|
|
|
+ @ApiOperation(value = "根据taskId获取资料归纳列表", httpMethod = "GET", notes = "根据taskId获取资料归纳列表(包含明细)")
|
|
|
+ @Transactional
|
|
|
+ public CommonResult<List<CostProjectTaskMaterialSummaryDetail>> listByMasetId(
|
|
|
+ @ApiParam(name = "masterId", value = "主文件夹ID", required = true)
|
|
|
+ @RequestParam(required = true) String masterId) {
|
|
|
+
|
|
|
+ List<CostProjectTaskMaterialSummaryDetail> list = costProjectTaskMaterialSummaryDetailManager.list(
|
|
|
+ new LambdaQueryWrapper<CostProjectTaskMaterialSummaryDetail>()
|
|
|
+ .eq(CostProjectTaskMaterialSummaryDetail::getMasterId, masterId)
|
|
|
+ );
|
|
|
+ return CommonResult.<List<CostProjectTaskMaterialSummaryDetail>>ok().value(list);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据id获取资料归纳详情
|
|
|
* @param id 主表ID
|
|
|
@@ -100,6 +120,91 @@ public class CostProjectTaskMaterialSummaryController extends BaseController<Cos
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 新增、更新资料归纳子表
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/saveDetail")
|
|
|
+ @ApiOperation(value = "新增、更新资料归纳子表", httpMethod = "POST", notes = "新增、更新资料归纳主表")
|
|
|
+ @Transactional
|
|
|
+ public CommonResult<String> saveDetail(
|
|
|
+ @ApiParam(name = "summary", value = "资料归纳主表", required = true)
|
|
|
+ @RequestBody CostProjectTaskMaterialSummaryDetail detail) {
|
|
|
+ if (detail.getMasterId()==null){
|
|
|
+ return CommonResult.<String>error().message("请选择资料归纳");
|
|
|
+ }
|
|
|
+ CostProjectTaskMaterialSummary summary = baseService.getById(detail.getMasterId());
|
|
|
+ if (summary==null){
|
|
|
+ return CommonResult.<String>error().message("请选择资料归纳");
|
|
|
+ }
|
|
|
+ detail.setTaskId(summary.getTaskId());
|
|
|
+
|
|
|
+ // 如果有附件URL,自动解析文件页数
|
|
|
+ if (StringUtil.isNotEmpty(detail.getAttachmentUrl())) {
|
|
|
+ try {
|
|
|
+ int pageCount = asyncMaterialSummaryService.calculateFilePageCount(detail.getAttachmentUrl());
|
|
|
+ detail.setPageCount(pageCount);
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.err.println("解析文件页数失败:" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String msg = StringUtil.isEmpty(detail.getId()) ? "添加资料归纳成功" : "更新资料归纳成功";
|
|
|
+ if (detail.getId()==null){
|
|
|
+ detail.setCreateTime(LocalDateTime.now());
|
|
|
+ }
|
|
|
+ detail.setUpdateTime(LocalDateTime.now());
|
|
|
+ costProjectTaskMaterialSummaryDetailManager.createOrUpdate(detail);
|
|
|
+
|
|
|
+ // 保存明细后,更新主表的总页数
|
|
|
+ try {
|
|
|
+ asyncMaterialSummaryService.updateMasterTotalPageCount(detail.getMasterId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.err.println("更新主表总页数失败:" + e.getMessage());
|
|
|
+ // 更新失败不影响返回结果
|
|
|
+ }
|
|
|
+
|
|
|
+ return CommonResult.<String>ok().message(msg);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除资料归纳明细
|
|
|
+ * @param id 明细ID
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @DeleteMapping(value = "/deleteDetail")
|
|
|
+ @ApiOperation(value = "删除资料归纳明细", httpMethod = "DELETE", notes = "删除资料归纳明细并同步更新主表总页数")
|
|
|
+ @Transactional
|
|
|
+ public CommonResult<String> deleteDetail(
|
|
|
+ @ApiParam(name = "id", value = "明细ID", required = true)
|
|
|
+ @RequestParam(required = true) String id) {
|
|
|
+
|
|
|
+ // 先查询明细信息,获取主表ID
|
|
|
+ CostProjectTaskMaterialSummaryDetail detail = costProjectTaskMaterialSummaryDetailManager.getById(id);
|
|
|
+ if (detail == null) {
|
|
|
+ return CommonResult.<String>error().message("资料归纳明细不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ String masterId = detail.getMasterId();
|
|
|
+
|
|
|
+ // 删除明细(物理删除)
|
|
|
+ costProjectTaskMaterialSummaryDetailManager.deleteById(id);
|
|
|
+
|
|
|
+ // 删除后,更新主表的总页数
|
|
|
+ try {
|
|
|
+ if (StringUtil.isNotEmpty(masterId)) {
|
|
|
+ asyncMaterialSummaryService.updateMasterTotalPageCount(masterId);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.err.println("更新主表总页数失败:" + e.getMessage());
|
|
|
+ // 更新失败不影响删除结果
|
|
|
+ }
|
|
|
+
|
|
|
+ return CommonResult.<String>ok().message("删除资料归纳明细成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 批量保存资料归纳(主表+明细)
|
|
|
* @param summary 资料归纳主表(包含detailList)
|
|
|
* @return
|