|
|
@@ -98,7 +98,7 @@ public class FapFeeCatalogController {
|
|
|
List<FapFeeCatalogHistory> history = catalogHistoryManager.getHistoryByCatalogId(id);
|
|
|
for (FapFeeCatalogHistory historyRecord : history) {
|
|
|
if (historyRecord.getDocumentBasis() != null && !historyRecord.getDocumentBasis().trim().isEmpty()
|
|
|
- && !"无关联文件".equals(historyRecord.getDocumentBasis())) {
|
|
|
+ && !"无关联文件".equals(historyRecord.getDocumentBasis())) {
|
|
|
String[] docIds = historyRecord.getDocumentBasis().split(",");
|
|
|
List<String> docNumbers = new ArrayList<>();
|
|
|
for (String docId : docIds) {
|
|
|
@@ -192,25 +192,23 @@ public class FapFeeCatalogController {
|
|
|
catalogManager.updateById(catalog);
|
|
|
|
|
|
// 根据状态类型记录相应的历史
|
|
|
- String adjustmentType = getAdjustmentTypeByStatus(request.getStatus());
|
|
|
- if (adjustmentType != null) {
|
|
|
- String documentBasis = "无关联文件";
|
|
|
- if (request.getDocuments() != null && !request.getDocuments().isEmpty()) {
|
|
|
- // 添加新关联
|
|
|
- documentRelationManager.addDocumentRelations("OPERATION", catalogId, request.getDocuments());
|
|
|
- documentBasis = request.getDocuments().stream()
|
|
|
- .map(FapPolicyDocument::getId)
|
|
|
- .collect(Collectors.joining(","));
|
|
|
- }
|
|
|
- catalogHistoryManager.addHistoryRecord(
|
|
|
- catalogId,
|
|
|
- adjustmentType,
|
|
|
- request.getReason() != null ? request.getReason() : "",
|
|
|
- null,
|
|
|
- documentBasis,
|
|
|
- request.getReason()
|
|
|
- );
|
|
|
+ String documentBasis = "无关联文件";
|
|
|
+ if (request.getDocuments() != null && !request.getDocuments().isEmpty()) {
|
|
|
+ // 添加新关联
|
|
|
+ documentRelationManager.addDocumentRelations("OPERATION", catalogId, request.getDocuments());
|
|
|
+ documentBasis = request.getDocuments().stream()
|
|
|
+ .map(FapPolicyDocument::getId)
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
}
|
|
|
+ catalogHistoryManager.addHistoryRecord(
|
|
|
+ catalogId,
|
|
|
+ request.getStatus(),
|
|
|
+ request.getReason() != null ? request.getReason() : "",
|
|
|
+ null,
|
|
|
+ documentBasis,
|
|
|
+ request.getReason()
|
|
|
+ );
|
|
|
+
|
|
|
}
|
|
|
return CommonResult.ok();
|
|
|
}
|
|
|
@@ -244,91 +242,57 @@ public class FapFeeCatalogController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @ApiOperation("新增标准信息")
|
|
|
- @PostMapping("/standard/add")
|
|
|
- public CommonResult<Void> addStandard(
|
|
|
+ @ApiOperation("保存标准信息(新增或更新)")
|
|
|
+ @PostMapping("/standard/save")
|
|
|
+ public CommonResult<Void> saveStandard(
|
|
|
@ApiParam(value = "标准信息及关联文件", required = true) @RequestBody FapFeeStandard standard) {
|
|
|
|
|
|
- // 检查是否已存在相同的标准信息(同一目录+同一地区)
|
|
|
- FapFeeStandard existingStandard = standardManager.lambdaQuery()
|
|
|
- .eq(FapFeeStandard::getCatalogId, standard.getCatalogId())
|
|
|
- .eq(FapFeeStandard::getRegion, standard.getRegion())
|
|
|
- .eq(FapFeeStandard::getIsDeleted, "0")
|
|
|
- .one();
|
|
|
-
|
|
|
- if (existingStandard == null) {
|
|
|
- // 保存标准信息
|
|
|
- String operatorOrgId = AuthenticationUtil.getCurrentUserMainOrgId();
|
|
|
- standard.setRegion(operatorOrgId);
|
|
|
- standardManager.save(standard);
|
|
|
-
|
|
|
- // 记录标准新增历史
|
|
|
- String documentBasis = "无关联文件";
|
|
|
- if (standard.getDocuments() != null && !standard.getDocuments().isEmpty()) {
|
|
|
- documentBasis = standard.getDocuments().stream()
|
|
|
- .map(FapDocumentRelation::getPolicyDocId)
|
|
|
- .filter(docId -> docId != null && !docId.trim().isEmpty())
|
|
|
- .collect(Collectors.joining(","));
|
|
|
- }
|
|
|
-
|
|
|
- // 记录到标准历史表
|
|
|
- historyManager.recordUpdateHistory(
|
|
|
- standard.getId(),
|
|
|
- "",
|
|
|
- standard.getFeeStandardContent(),
|
|
|
- "新增标准信息"
|
|
|
- );
|
|
|
-
|
|
|
- // 处理政策文件关联
|
|
|
- List<FapDocumentRelation> documents = standard.getDocuments();
|
|
|
- if (documents != null && !documents.isEmpty()) {
|
|
|
- for (FapDocumentRelation document : documents) {
|
|
|
- documentRelationManager.addDocumentRelation("STANDARD", standard.getId(), document.getPolicyDocId(), document.getRemark());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ String operationType = "";
|
|
|
+ String oldContent = "";
|
|
|
+ boolean isUpdate = false;
|
|
|
|
|
|
+ // 判断是新增还是更新:有ID就是更新,没ID就是新增
|
|
|
+ if (standard.getId() != null && !standard.getId().trim().isEmpty()) {
|
|
|
+ // 更新操作
|
|
|
+ isUpdate = true;
|
|
|
+ operationType = "更新标准信息";
|
|
|
|
|
|
- return CommonResult.ok();
|
|
|
- }
|
|
|
+ // 获取更新前的内容用于历史记录
|
|
|
+ FapFeeStandard existingStandard = standardManager.getById(standard.getId());
|
|
|
+ oldContent = existingStandard != null ? existingStandard.getFeeStandardContent() : "";
|
|
|
|
|
|
- @ApiOperation("更新标准信息")
|
|
|
- @PutMapping("/standard/update")
|
|
|
- public CommonResult<Void> updateStandard(
|
|
|
- @ApiParam(value = "标准信息及关联文件", required = true) @RequestBody FapFeeStandard standard) {
|
|
|
+ // 执行更新
|
|
|
+ standardManager.updateById(standard);
|
|
|
|
|
|
- // 获取更新前的标准信息
|
|
|
- FapFeeStandard oldStandard = standardManager.getById(standard.getId());
|
|
|
+ // 删除现有的政策文件关联
|
|
|
+ documentRelationManager.removeAllRelationsBySource("STANDARD", standard.getId());
|
|
|
+ } else {
|
|
|
+ // 新增操作
|
|
|
+ isUpdate = false;
|
|
|
+ operationType = "新增标准信息";
|
|
|
+ oldContent = "";
|
|
|
|
|
|
- // 更新标准信息
|
|
|
- standardManager.updateById(standard);
|
|
|
+ // 设置当前用户组织为地区
|
|
|
+ String operatorOrgId = AuthenticationUtil.getCurrentUserMainOrgId();
|
|
|
+ standard.setRegion(operatorOrgId);
|
|
|
|
|
|
- // 记录标准更新历史
|
|
|
- String documentBasis = "无关联文件";
|
|
|
- if (standard.getDocuments() != null && !standard.getDocuments().isEmpty()) {
|
|
|
- documentBasis = standard.getDocuments().stream()
|
|
|
- .map(FapDocumentRelation::getPolicyDocId)
|
|
|
- .filter(docId -> docId != null && !docId.trim().isEmpty())
|
|
|
- .collect(Collectors.joining(","));
|
|
|
+ // 执行新增
|
|
|
+ standardManager.save(standard);
|
|
|
}
|
|
|
|
|
|
// 记录到标准历史表
|
|
|
historyManager.recordUpdateHistory(
|
|
|
standard.getId(),
|
|
|
- oldStandard != null ? oldStandard.getFeeStandardContent() : "",
|
|
|
+ oldContent,
|
|
|
standard.getFeeStandardContent(),
|
|
|
- "更新标准信息"
|
|
|
+ operationType
|
|
|
);
|
|
|
|
|
|
- // 处理政策文件关联更新
|
|
|
- // 1. 删除现有关联
|
|
|
- documentRelationManager.removeAllRelationsBySource("STANDARD", standard.getId());
|
|
|
-
|
|
|
- // 2. 添加新关联
|
|
|
- List<FapDocumentRelation> documents = standard.getDocuments();
|
|
|
+ // 处理政策文件关联
|
|
|
+ List<FapPolicyDocument> documents = standard.getDocuments();
|
|
|
if (documents != null && !documents.isEmpty()) {
|
|
|
- for (FapDocumentRelation document : documents) {
|
|
|
- documentRelationManager.addDocumentRelation("STANDARD", standard.getId(), document.getPolicyDocId(), document.getRemark());
|
|
|
+ for (FapPolicyDocument document : documents) {
|
|
|
+ documentRelationManager.addDocumentRelation("STANDARD", standard.getId(), document.getId(), document.getRemark());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -364,7 +328,9 @@ public class FapFeeCatalogController {
|
|
|
FapFeeStandard feeStandard = standardManager.getOne(
|
|
|
new QueryWrapper<FapFeeStandard>().eq("catalog_id", id)
|
|
|
);
|
|
|
- feeStandard.setDocuments(documentRelationManager.getDocumentRelationsBySource("STANDARD", id));
|
|
|
+ if (feeStandard != null){
|
|
|
+ feeStandard.setDocuments(documentRelationManager.getPolicyDocumentsBySource("STANDARD", feeStandard.getId()));
|
|
|
+ }
|
|
|
return CommonResult.<FapFeeStandard>ok().value(feeStandard);
|
|
|
}
|
|
|
|
|
|
@@ -383,7 +349,7 @@ public class FapFeeCatalogController {
|
|
|
// 转换文件依据为汉字
|
|
|
for (FapFeeStandardHistory historyRecord : historyList) {
|
|
|
if (historyRecord.getNewDocumentBasis() != null && !historyRecord.getNewDocumentBasis().trim().isEmpty()
|
|
|
- && !"无关联文件".equals(historyRecord.getNewDocumentBasis())) {
|
|
|
+ && !"无关联文件".equals(historyRecord.getNewDocumentBasis())) {
|
|
|
// 将文件ID转换为文件文号
|
|
|
String[] docIds = historyRecord.getNewDocumentBasis().split(",");
|
|
|
List<String> docNumbers = new ArrayList<>();
|
|
|
@@ -401,24 +367,4 @@ public class FapFeeCatalogController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 根据状态获取调整类型
|
|
|
- *
|
|
|
- * @param status 状态值
|
|
|
- * @return 调整类型
|
|
|
- */
|
|
|
- private String getAdjustmentTypeByStatus(String status) {
|
|
|
- switch (status) {
|
|
|
- case "1": // 暂停状态
|
|
|
- return "SUSPEND";
|
|
|
- case "2": // 取消状态
|
|
|
- return "CANCEL";
|
|
|
- case "0": // 正常状态
|
|
|
- return "RESTORE";
|
|
|
- default:
|
|
|
- return null;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
}
|