|
@@ -8,7 +8,9 @@ import com.hotent.base.exception.BaseException;
|
|
|
import com.hotent.base.query.PageList;
|
|
import com.hotent.base.query.PageList;
|
|
|
import com.hotent.base.util.PinyinUtil;
|
|
import com.hotent.base.util.PinyinUtil;
|
|
|
import com.hotent.baseInfo.manager.CostCatalogManager;
|
|
import com.hotent.baseInfo.manager.CostCatalogManager;
|
|
|
|
|
+import com.hotent.baseInfo.manager.CostCatalogSurveyManager;
|
|
|
import com.hotent.baseInfo.model.CostCatalog;
|
|
import com.hotent.baseInfo.model.CostCatalog;
|
|
|
|
|
+import com.hotent.baseInfo.model.CostCatalogSurvey;
|
|
|
import com.hotent.common.CrudService;
|
|
import com.hotent.common.CrudService;
|
|
|
import com.hotent.resp.PageResp;
|
|
import com.hotent.resp.PageResp;
|
|
|
import com.hotent.surveyinfo.dao.CostSurveyTemplateDao;
|
|
import com.hotent.surveyinfo.dao.CostSurveyTemplateDao;
|
|
@@ -86,6 +88,9 @@ public class CostSurveyTemplateController extends BaseController<CostSurveyTempl
|
|
|
// 创建通用服务实例
|
|
// 创建通用服务实例
|
|
|
private final CrudService crudService = new CrudService();
|
|
private final CrudService crudService = new CrudService();
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private CostCatalogSurveyManager costCatalogSurveyManager;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取所有成本调查表模板数据
|
|
* 获取所有成本调查表模板数据
|
|
|
*
|
|
*
|
|
@@ -162,10 +167,64 @@ public class CostSurveyTemplateController extends BaseController<CostSurveyTempl
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
baseService.createOrUpdate(costSurveyTemplate);
|
|
baseService.createOrUpdate(costSurveyTemplate);
|
|
|
|
|
+
|
|
|
|
|
+ // 同步更新监审目录-成本调查表关联关系
|
|
|
|
|
+ syncCatalogSurveyRelation(costSurveyTemplate);
|
|
|
|
|
+
|
|
|
return CommonResult.<String>ok().message(msg);
|
|
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删除成本调查表模板数据
|
|
* 根据id删除成本调查表模板数据
|
|
|
*
|
|
*
|
|
|
* @param id
|
|
* @param id
|
|
@@ -175,6 +234,8 @@ public class CostSurveyTemplateController extends BaseController<CostSurveyTempl
|
|
|
@ApiOperation(value = "根据id删除成本调查表模板数据", httpMethod = "GET", notes = "根据id删除成本调查表模板数据")
|
|
@ApiOperation(value = "根据id删除成本调查表模板数据", httpMethod = "GET", notes = "根据id删除成本调查表模板数据")
|
|
|
@GetMapping(value = "/remove")
|
|
@GetMapping(value = "/remove")
|
|
|
public CommonResult<String> remove(@ApiParam(name = "id", value = "业务对象主键", required = true) @RequestParam(required = true) String id) throws Exception {
|
|
public CommonResult<String> remove(@ApiParam(name = "id", value = "业务对象主键", required = true) @RequestParam(required = true) String id) throws Exception {
|
|
|
|
|
+ // 删除关联记录
|
|
|
|
|
+ removeCatalogSurveyRelation(id);
|
|
|
baseService.remove(id);
|
|
baseService.remove(id);
|
|
|
return CommonResult.<String>ok().message("删除成本调查表模板成功");
|
|
return CommonResult.<String>ok().message("删除成本调查表模板成功");
|
|
|
}
|
|
}
|
|
@@ -195,6 +256,10 @@ public class CostSurveyTemplateController extends BaseController<CostSurveyTempl
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
|
+ // 批量删除关联记录
|
|
|
|
|
+ for (String id : ids) {
|
|
|
|
|
+ removeCatalogSurveyRelation(id);
|
|
|
|
|
+ }
|
|
|
baseService.batchRemove(ids);
|
|
baseService.batchRemove(ids);
|
|
|
return CommonResult.<String>ok().message("成功删除" + ids.size() + "条数据");
|
|
return CommonResult.<String>ok().message("成功删除" + ids.size() + "条数据");
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -624,6 +689,9 @@ public class CostSurveyTemplateController extends BaseController<CostSurveyTempl
|
|
|
|
|
|
|
|
baseService.createOrUpdate(template);
|
|
baseService.createOrUpdate(template);
|
|
|
|
|
|
|
|
|
|
+ // 同步更新监审目录-成本调查表关联关系
|
|
|
|
|
+ syncCatalogSurveyRelation(template);
|
|
|
|
|
+
|
|
|
return CommonResult.<String>ok().message(message);
|
|
return CommonResult.<String>ok().message(message);
|
|
|
}
|
|
}
|
|
|
|
|
|