Prechádzať zdrojové kódy

fix:监审对象提交资料清单-页面应自动关联财务表启用、现行的数据

zzw 6 dní pred
rodič
commit
aff6234b0d

+ 1 - 0
assistMg/src/main/java/com/hotent/enterpriseDeclare/controller/CostAuditReviewController.java

@@ -53,6 +53,7 @@ public class CostAuditReviewController {
     @PostMapping(value = "/pageList")
     @ApiOperation(value = "分页查询待审核任务列表", httpMethod = "POST", notes = "分页查询待审核任务列表")
     public CommonResult<IPage<CostProjectTask>> pageList(@RequestBody CostTaskReviewPageReq req) throws Exception {
+        req.setNCurrentNode(NodeConstant.guidang.getNodeKey());
         IPage<CostProjectTask> pageResult = costProjectTaskManager.pageListForReviewTask(req);
         return CommonResult.<IPage<CostProjectTask>>ok().value(pageResult);
     }

+ 68 - 0
assistMg/src/main/java/com/hotent/surveyinfo/controller/CostSurveyTemplateController.java

@@ -8,7 +8,9 @@ import com.hotent.base.exception.BaseException;
 import com.hotent.base.query.PageList;
 import com.hotent.base.util.PinyinUtil;
 import com.hotent.baseInfo.manager.CostCatalogManager;
+import com.hotent.baseInfo.manager.CostCatalogSurveyManager;
 import com.hotent.baseInfo.model.CostCatalog;
+import com.hotent.baseInfo.model.CostCatalogSurvey;
 import com.hotent.common.CrudService;
 import com.hotent.resp.PageResp;
 import com.hotent.surveyinfo.dao.CostSurveyTemplateDao;
@@ -86,6 +88,9 @@ public class CostSurveyTemplateController extends BaseController<CostSurveyTempl
     // 创建通用服务实例
     private final CrudService crudService = new CrudService();
 
+    @Autowired
+    private CostCatalogSurveyManager costCatalogSurveyManager;
+
     /**
      * 获取所有成本调查表模板数据
      *
@@ -162,10 +167,64 @@ public class CostSurveyTemplateController extends BaseController<CostSurveyTempl
         }
 
         baseService.createOrUpdate(costSurveyTemplate);
+
+        // 同步更新监审目录-成本调查表关联关系
+        syncCatalogSurveyRelation(costSurveyTemplate);
+
         return CommonResult.<String>ok().message(msg);
     }
 
     /**
+     * 同步监审目录与成本调查表的关联关系
+     * 启用状态(0)时添加关联记录,停用(-1/1)时删除关联记录
+     */
+    private void syncCatalogSurveyRelation(CostSurveyTemplate costSurveyTemplate) {
+        String catalogId = costSurveyTemplate.getCatalogId();
+        String surveyTemplateId = costSurveyTemplate.getSurveyTemplateId();
+        String status = costSurveyTemplate.getStatus();
+
+        if (StringUtil.isEmpty(catalogId) || StringUtil.isEmpty(surveyTemplateId)) {
+            return;
+        }
+
+        // 先查询是否已存在关联记录
+        QueryWrapper<CostCatalogSurvey> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("catalog_id", catalogId);
+        queryWrapper.eq("survey_id", surveyTemplateId);
+        CostCatalogSurvey existingRelation = costCatalogSurveyManager.getOne(queryWrapper);
+
+        if ("0".equals(status)) {
+            // 启用状态:添加关联记录(如果不存在)
+            if (existingRelation == null) {
+                CostCatalogSurvey catalogSurvey = new CostCatalogSurvey();
+                catalogSurvey.setCatalogId(catalogId);
+                catalogSurvey.setSurveyId(surveyTemplateId);
+                catalogSurvey.setCreateBy(ContextUtil.getCurrentUser().getAccount());
+                catalogSurvey.setCreateTime(LocalDateTime.now());
+                catalogSurvey.setYear(String.valueOf(LocalDateTime.now().getYear()));
+                costCatalogSurveyManager.createOrUpdate(catalogSurvey);
+            }
+        } else {
+            // 停用或草稿状态:删除关联记录(如果存在)
+            if (existingRelation != null) {
+                costCatalogSurveyManager.remove(queryWrapper);
+            }
+        }
+    }
+
+    /**
+     * 根据模板ID删除监审目录关联记录
+     */
+    private void removeCatalogSurveyRelation(String surveyTemplateId) {
+        if (StringUtil.isEmpty(surveyTemplateId)) {
+            return;
+        }
+        QueryWrapper<CostCatalogSurvey> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("survey_id", surveyTemplateId);
+        costCatalogSurveyManager.remove(queryWrapper);
+    }
+
+    /**
      * 根据id删除成本调查表模板数据
      *
      * @param id
@@ -175,6 +234,8 @@ public class CostSurveyTemplateController extends BaseController<CostSurveyTempl
     @ApiOperation(value = "根据id删除成本调查表模板数据", httpMethod = "GET", notes = "根据id删除成本调查表模板数据")
     @GetMapping(value = "/remove")
     public CommonResult<String> remove(@ApiParam(name = "id", value = "业务对象主键", required = true) @RequestParam(required = true) String id) throws Exception {
+        // 删除关联记录
+        removeCatalogSurveyRelation(id);
         baseService.remove(id);
         return CommonResult.<String>ok().message("删除成本调查表模板成功");
     }
@@ -195,6 +256,10 @@ public class CostSurveyTemplateController extends BaseController<CostSurveyTempl
         }
 
         try {
+            // 批量删除关联记录
+            for (String id : ids) {
+                removeCatalogSurveyRelation(id);
+            }
             baseService.batchRemove(ids);
             return CommonResult.<String>ok().message("成功删除" + ids.size() + "条数据");
         } catch (Exception e) {
@@ -624,6 +689,9 @@ public class CostSurveyTemplateController extends BaseController<CostSurveyTempl
 
         baseService.createOrUpdate(template);
 
+        // 同步更新监审目录-成本调查表关联关系
+        syncCatalogSurveyRelation(template);
+
         return CommonResult.<String>ok().message(message);
     }