diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/MHTodoClient.java b/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/MHTodoClient.java index b087715..ad1240a 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/MHTodoClient.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/external/todo/MHTodoClient.java @@ -10,6 +10,7 @@ import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hz.pm.api.common.util.EnvironmentUtil; import com.hz.pm.api.external.todo.dto.MhTodoRequestDTO; import com.hz.pm.api.external.todo.dto.MhTodoRetDTO; import com.hz.pm.api.external.todo.enumerization.MHTodoTypeEnum; @@ -42,6 +43,7 @@ public class MHTodoClient { */ private static final String TODO_ADD = "/single_wk_handle/addWkhandle"; + /** * 完成待办接口地址 */ @@ -55,6 +57,7 @@ public class MHTodoClient { //================================================================================================================== private final IMhTodoRecordService todoRecordService; + private final EnvironmentUtil environmentUtil; /** @@ -65,6 +68,9 @@ public class MHTodoClient { @Transactional(rollbackFor = Exception.class) public void addTodo(Object paramObj, UserFullInfoDTO receiver, MHTodoTypeEnum type, String bizId, String content) { + if (environmentUtil.isDevEnv()) { + return; + } String url = mhApiHost + TODO_ADD; String paramObjs = JSON.toJSONString(paramObj); MhTodoRequestDTO todoReq = MhTodoRequestDTO.builder() @@ -97,7 +103,10 @@ public class MHTodoClient { * * @param wkhandleId 待办ID */ - public void complete(String wkhandleId) { + private void complete(String wkhandleId) { + if (environmentUtil.isDevEnv()) { + return; + } String url = mhApiHost + TODO_COMPLETE; // 发送PUT请求 HttpRequest request = HttpUtil.createRequest(Method.PUT, url) @@ -114,6 +123,9 @@ public class MHTodoClient { public void completeTodo(MHTodoTypeEnum todoType, Collection bizIds) { + if (environmentUtil.isDevEnv()) { + return; + } LambdaQueryWrapper query = Wrappers.lambdaQuery(MhTodoRecord.class) .eq(MhTodoRecord::getType, todoType.name()) .in(MhTodoRecord::getBizId, bizIds) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/fiscal/controller/CompanyFiscalCodeController.java b/hz-pm-api/src/main/java/com/hz/pm/api/fiscal/controller/CompanyFiscalCodeController.java index 7acccdb..2ec47dd 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/fiscal/controller/CompanyFiscalCodeController.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/fiscal/controller/CompanyFiscalCodeController.java @@ -27,7 +27,7 @@ import javax.validation.Valid; @RestController @RequestMapping("/api/v1/fiscal-code") @RequiredArgsConstructor -@Api(tags = "印章配置-财政编码配置") +@Api(tags = "印章配置-财政编码配置", hidden = true) public class CompanyFiscalCodeController { private final CompanyFiscalCodeManage companyFiscalCodeManage; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/MhSystemReplaceController.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/MhSystemReplaceController.java index 6ae7138..d9058e4 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/MhSystemReplaceController.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/MhSystemReplaceController.java @@ -2,6 +2,7 @@ package com.hz.pm.api.projectlib.controller; import com.hz.pm.api.projectlib.manage.MhSystemReplaceManage; import com.hz.pm.api.projectlib.model.dto.MhSystemReplaceInfoVO; +import com.hz.pm.api.projectlib.model.dto.MhSystemStoppedRecordDTO; import com.hz.pm.api.projectlib.model.req.MhSystemReplaceReq; import com.ningdatech.basic.model.PageVo; import com.ningdatech.log.annotation.WebLog; @@ -9,10 +10,9 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import javax.validation.Valid; import java.util.List; /** @@ -51,4 +51,11 @@ public class MhSystemReplaceController { mhSystemReplaceManage.syncMhSystemReplaceInfo(); } + @PostMapping("/submitStoppedRecord") + @ApiOperation("提交停用备案") + @WebLog("提交停用备案") + public void submitStoppedRecord(@RequestBody @Valid MhSystemStoppedRecordDTO req) { + mhSystemReplaceManage.submitStoppedRecord(req); + } + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/QxProjectController.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/QxProjectController.java index c87315e..db2dee7 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/QxProjectController.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/controller/QxProjectController.java @@ -1,6 +1,7 @@ package com.hz.pm.api.projectlib.controller; import com.hz.pm.api.projectlib.manage.QxProjectManage; +import com.hz.pm.api.projectlib.model.dto.MhSystemReplaceInfoVO; import com.hz.pm.api.projectlib.model.req.*; import com.hz.pm.api.projectlib.model.vo.QxProjectDetailVO; import com.hz.pm.api.projectlib.model.vo.QxProjectVO; @@ -12,6 +13,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; +import java.util.List; /** *

@@ -69,4 +71,10 @@ public class QxProjectController { return qxProjectManage.page(req); } + @GetMapping("/systemReplaceInfos/{projectId}") + @ApiOperation("项目替换系统列表") + public List listSystemReplaceInfos(@PathVariable Long projectId) { + return qxProjectManage.listReplaceInfo(projectId); + } + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/entity/MhSystemReplaceInfo.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/entity/MhSystemReplaceInfo.java index bfbc7a3..0611c4c 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/entity/MhSystemReplaceInfo.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/entity/MhSystemReplaceInfo.java @@ -71,4 +71,7 @@ public class MhSystemReplaceInfo implements Serializable { @ApiModelProperty("开始时间") private LocalDateTime createOn; + @ApiModelProperty("是否停用") + private Boolean stopped; + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/MhSystemReplaceManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/MhSystemReplaceManage.java index 9cac0a0..f9b659a 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/MhSystemReplaceManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/MhSystemReplaceManage.java @@ -2,20 +2,24 @@ package com.hz.pm.api.projectlib.manage; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.hz.pm.api.common.model.constant.MhUnitConst; +import com.hz.pm.api.common.util.BizUtils; import com.hz.pm.api.external.MhApiClient; import com.hz.pm.api.projectlib.entity.*; import com.hz.pm.api.projectlib.model.dto.MhSystemReplaceInfoDTO; import com.hz.pm.api.projectlib.model.dto.MhSystemReplaceInfoVO; +import com.hz.pm.api.projectlib.model.dto.MhSystemStoppedRecordDTO; import com.hz.pm.api.projectlib.model.entity.Project; +import com.hz.pm.api.projectlib.model.enumeration.MhSystemReplaceType; import com.hz.pm.api.projectlib.model.req.MhSystemReplaceReq; import com.hz.pm.api.projectlib.service.*; -import com.hz.pm.api.user.helper.MhUnitCache; +import com.hz.pm.api.user.helper.MhUnitQueryHelper; +import com.hz.pm.api.user.helper.MhUnitQueryHelper.UnitQueryState; import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.util.CollUtils; import lombok.RequiredArgsConstructor; @@ -23,6 +27,7 @@ import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; @@ -41,13 +46,13 @@ import java.util.stream.Collectors; public class MhSystemReplaceManage { private final IMhSystemReplaceInfoService mhSystemReplaceInfoService; - private final MhUnitCache mhUnitCache; private final MhApiClient mhApiClient; private final IQxProjectService qxProjectService; private final IProjectGovSystemReplaceInfosService projectGovSystemReplaceInfosService; - private final IQxProjectSystemReplaceInfosService qxProjectSystemReplaceInfosService; private final IProjectService projectService; private final IQxProjectSystemReplaceInfosRelationService qxProjectSystemReplaceInfosRelationService; + private final MhUnitQueryHelper mhUnitQueryHelper; + private final IMhSystemReplaceInfoStoppedRecordService mhSystemReplaceInfoStoppedRecordService; @Transactional(rollbackFor = Exception.class) public synchronized void syncMhSystemReplaceInfo() { @@ -56,6 +61,12 @@ public class MhSystemReplaceManage { if (CollUtil.isEmpty(systemReplaceInfos)) { return; } + List ids = CollUtils.fieldList(systemReplaceInfos, MhSystemReplaceInfoDTO::getId); + for (List strings : ListUtil.partition(ids, 1000)) { + Wrapper removeWrapper = Wrappers.lambdaQuery(MhSystemReplaceInfo.class) + .notIn(MhSystemReplaceInfo::getId, strings); + mhSystemReplaceInfoService.remove(removeWrapper); + } LocalDateTime now = LocalDateTime.now(); List newData = systemReplaceInfos.stream().map(w -> { MhSystemReplaceInfo replaceInfo = new MhSystemReplaceInfo(); @@ -76,23 +87,43 @@ public class MhSystemReplaceManage { replaceInfo.setTargetName(w.getAlternativeName()); return replaceInfo; }).collect(Collectors.toList()); - mhSystemReplaceInfoService.saveBatch(newData); + mhSystemReplaceInfoService.saveOrUpdateBatch(newData); } public PageVo page(MhSystemReplaceReq req) { LambdaQueryWrapper query = buildMhSystemReplaceInfoQuery(req); - if (req.getBuildOrgCode() != null && req.getBuildOrgCode() != MhUnitConst.ROOT_UNIT_ID) { - query.in(MhSystemReplaceInfo::getBuildOrgCode, mhUnitCache.getViewChildIdsRecursion(req.getBuildOrgCode())); + UnitQueryState state = mhUnitQueryHelper.listCanViewUnitIds(req.getBuildOrgCode()); + if (!state.isState()) { + return PageVo.empty(); } + BizUtils.notEmpty(state.getUnitIds(), w -> query.in(MhSystemReplaceInfo::getBuildOrgCode, w)); Page page = mhSystemReplaceInfoService.page(req.page(), query); if (page.getTotal() == 0) { return PageVo.empty(); } List data = BeanUtil.copyToList(page.getRecords(), MhSystemReplaceInfoVO.class); + List stoppedIds = data.stream() + .filter(w -> Boolean.TRUE.equals(w.getStopped())) + .map(MhSystemReplaceInfoVO::getId) + .collect(Collectors.toList()); + Map stoppedRecordMap; + if (stoppedIds.isEmpty()) { + stoppedRecordMap = Collections.emptyMap(); + } else { + Wrapper stoppedQuery = Wrappers.lambdaQuery(MhSystemReplaceInfoStoppedRecord.class) + .in(MhSystemReplaceInfoStoppedRecord::getSystemReplaceInfosId, stoppedIds); + List stoppedRecords = mhSystemReplaceInfoStoppedRecordService.list(stoppedQuery); + stoppedRecordMap = CollUtils.listToMap(stoppedRecords, + MhSystemReplaceInfoStoppedRecord::getSystemReplaceInfosId, + w -> BeanUtil.copyProperties(w, MhSystemStoppedRecordDTO.class)); + } List sourceSystemIds = CollUtils.fieldList(data, MhSystemReplaceInfoVO::getId); Map projectMap = listProjectMapBySourceSystemIds(sourceSystemIds); Map qxProjectMap = listQxProjectBySourceSystemIds(sourceSystemIds); for (MhSystemReplaceInfoVO datum : data) { + if (Boolean.TRUE.equals(datum.getStopped())) { + datum.setStoppedRecord(stoppedRecordMap.get(datum.getId())); + } String sourceSystemId = datum.getId(); Project project = projectMap.get(sourceSystemId); if (project != null) { @@ -137,9 +168,15 @@ public class MhSystemReplaceManage { public List option(MhSystemReplaceReq req) { LambdaQueryWrapper query = buildMhSystemReplaceInfoQuery(req); - if (req.getBuildOrgCode() != null && req.getBuildOrgCode() != MhUnitConst.ROOT_UNIT_ID) { - query.in(MhSystemReplaceInfo::getBuildOrgCode, mhUnitCache.getViewChildIdsRecursion(req.getBuildOrgCode())); + query.eq(MhSystemReplaceInfo::getStopped, Boolean.FALSE); + if (StrUtil.isBlank(req.getReplaceType())) { + query.in(MhSystemReplaceInfo::getReplaceType, Arrays.asList(MhSystemReplaceType.IM, MhSystemReplaceType.IT)); } + UnitQueryState state = mhUnitQueryHelper.listCanViewUnitIds(req.getBuildOrgCode()); + if (!state.isState()) { + return Collections.emptyList(); + } + BizUtils.notEmpty(state.getUnitIds(), w -> query.in(MhSystemReplaceInfo::getBuildOrgCode, w)); query.notExists("select 1 from qx_project_system_replace_infos_relation qpr " + "where qpr.source_system_id = mh_system_replace_info.id"); query.notExists("select 1 from nd_project_gov_system_replace_infos npr " + @@ -191,5 +228,17 @@ public class MhSystemReplaceManage { return CollUtils.listToMap(relationMap.entrySet(), Map.Entry::getKey, w -> qxProjectMap.get(w.getValue())); } + @Transactional(rollbackFor = Exception.class) + public synchronized void submitStoppedRecord(MhSystemStoppedRecordDTO req) { + MhSystemReplaceInfo replaceInfo = mhSystemReplaceInfoService.getById(req.getSystemReplaceInfosId()); + if (replaceInfo == null || Boolean.TRUE.equals(replaceInfo.getStopped())) { + return; + } + MhSystemReplaceInfoStoppedRecord stoppedRecord = new MhSystemReplaceInfoStoppedRecord(); + BeanUtil.copyProperties(replaceInfo, stoppedRecord); + mhSystemReplaceInfoStoppedRecordService.save(stoppedRecord); + replaceInfo.setStopped(Boolean.TRUE); + mhSystemReplaceInfoService.updateById(replaceInfo); + } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java index 9398c15..6148645 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectLibManage.java @@ -954,15 +954,15 @@ public class ProjectLibManage { List replaceInfos = new ArrayList<>(); for (int i = 0; i < systemReplaceInfos.size(); i++) { GovSystemReplaceInfoDTO curr = systemReplaceInfos.get(i); - for (String systemName : curr.getSourceSystemNames()) { + for (int i1 = 0; i1 < curr.getSourceSystemNames().size(); i1++) { ProjectGovSystemReplaceInfos replaceInfo = new ProjectGovSystemReplaceInfos(); replaceInfo.setProjectId(projectId); replaceInfo.setProjectCode(projectCode); replaceInfo.setReplaceType(curr.getReplaceType()); - replaceInfo.setSourceSystem(systemName); + replaceInfo.setSourceSystem(curr.getSourceSystemNames().get(i1)); replaceInfo.setTargetSystem(curr.getTargetSystemName()); replaceInfo.setBatchNo(i + 1); - replaceInfo.setSourceSystemId(curr.getSourceSystemId()); + replaceInfo.setSourceSystemId(curr.getSourceSystemIds().get(i1)); replaceInfos.add(replaceInfo); } } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/QxProjectManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/QxProjectManage.java index 159e5c6..fbc596e 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/QxProjectManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/QxProjectManage.java @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hz.pm.api.common.util.BizUtils; import com.hz.pm.api.projectlib.entity.*; +import com.hz.pm.api.projectlib.model.dto.MhSystemReplaceInfoVO; import com.hz.pm.api.projectlib.model.dto.QxProjectSystemReplaceInfosDTO; import com.hz.pm.api.projectlib.model.enumeration.MhSystemReplaceType; import com.hz.pm.api.projectlib.model.enumeration.QxProjectStatus; @@ -30,6 +31,7 @@ import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -214,4 +216,16 @@ public class QxProjectManage { return PageVo.of(BeanUtil.copyToList(page.getRecords(), QxProjectVO.class), page.getTotal()); } + public List listReplaceInfo(Long projectId) { + Wrapper query = Wrappers.lambdaQuery(QxProjectSystemReplaceInfosRelation.class) + .eq(QxProjectSystemReplaceInfosRelation::getProjectId, projectId); + List relations = qxProjectSystemReplaceInfosRelationService.list(query); + if (CollUtil.isEmpty(relations)) { + return Collections.emptyList(); + } + List systemIds = CollUtils.fieldList(relations, QxProjectSystemReplaceInfosRelation::getSourceSystemId); + List replaceInfos = mhSystemReplaceInfoService.listByIds(systemIds); + return BeanUtil.copyToList(replaceInfos, MhSystemReplaceInfoVO.class); + } + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/GovSystemReplaceInfoDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/GovSystemReplaceInfoDTO.java index 47b592b..5dee496 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/GovSystemReplaceInfoDTO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/GovSystemReplaceInfoDTO.java @@ -37,7 +37,7 @@ public class GovSystemReplaceInfoDTO implements Serializable { private String replaceType; @ApiModelProperty("替代前系统id") - private String sourceSystemId; + private List sourceSystemIds; @Override public boolean equals(Object o) { @@ -51,7 +51,7 @@ public class GovSystemReplaceInfoDTO implements Serializable { return CollUtil.isEqualList(sourceSystemNames, that.sourceSystemNames) && Objects.equals(targetSystemName, that.targetSystemName) && Objects.equals(replaceType, that.replaceType) - && Objects.equals(sourceSystemId, that.sourceSystemId); + && CollUtil.isEqualList(sourceSystemIds, that.sourceSystemIds); } @Override diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/MhSystemReplaceInfoVO.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/MhSystemReplaceInfoVO.java index dd07d9f..ba7b772 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/MhSystemReplaceInfoVO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/MhSystemReplaceInfoVO.java @@ -60,4 +60,10 @@ public class MhSystemReplaceInfoVO { @ApiModelProperty("项目ID") private Long projectId; + @ApiModelProperty("是否停用") + private Boolean stopped; + + @ApiModelProperty("停用备案") + private MhSystemStoppedRecordDTO stoppedRecord; + } diff --git a/hz-pm-gen/src/main/java/com/hz/pm/gen/config/CodeGen.java b/hz-pm-gen/src/main/java/com/hz/pm/gen/config/CodeGen.java index 5c3ff84..4df9a3f 100644 --- a/hz-pm-gen/src/main/java/com/hz/pm/gen/config/CodeGen.java +++ b/hz-pm-gen/src/main/java/com/hz/pm/gen/config/CodeGen.java @@ -55,7 +55,7 @@ public class CodeGen { } public static void main(String[] args) { - generate("WendyYang", "projectlib", PATH_YYD, "QX_PROJECT_SYSTEM_REPLACE_INFOS_RELATION"); + generate("WendyYang", "projectlib", PATH_YYD, "MH_SYSTEM_REPLACE_INFO_STOPPED_RECORD"); } }