From 7fc8f495ffec61e5935ae6d4d023ac9181d23b0b Mon Sep 17 00:00:00 2001 From: WendyYang Date: Thu, 29 Feb 2024 20:40:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E7=94=B3=E6=8A=A5=E5=8D=95?= =?UTF-8?q?=E4=BD=8D=E9=A2=86=E5=9F=9F=E7=BC=96=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/enumeration/MhUnitStripEnum.java | 21 +++++++++-- .../pm/api/projectlib/model/entity/MhProject.java | 3 ++ .../model/req/DeclaredProjectListReq.java | 6 +++ .../projectlib/model/vo/DeclaredProjectListVO.java | 6 +++ .../pm/api/user/controller/MhUnitController.java | 8 ++++ .../com/hz/pm/api/user/manage/MhUnitManage.java | 43 ++++++++++++++++++++-- .../hz/pm/api/user/manage/SyncMhUserOrgManage.java | 7 ++++ .../com/hz/pm/api/todocenter/FlowableTest.java | 21 +++++++++++ 8 files changed, 108 insertions(+), 7 deletions(-) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/external/model/enumeration/MhUnitStripEnum.java b/hz-pm-api/src/main/java/com/hz/pm/api/external/model/enumeration/MhUnitStripEnum.java index 45f7da8..290386a 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/external/model/enumeration/MhUnitStripEnum.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/external/model/enumeration/MhUnitStripEnum.java @@ -3,6 +3,9 @@ package com.hz.pm.api.external.model.enumeration; import lombok.AllArgsConstructor; import lombok.Getter; +import java.util.Arrays; +import java.util.Optional; + /** *

* MhUnitStripEnum @@ -15,12 +18,22 @@ import lombok.Getter; @AllArgsConstructor public enum MhUnitStripEnum { - GOV_COMPANY("国有企业"), + GOV_COMPANY("国有企业", 1), + + PARTY_GOV("党政领域", 2), + + INDUSTRY("重点行业", 3); + + private final String val; + private final Integer code; - PARTY_GOV("党政领域"), + public static Optional get(Integer code) { + return Arrays.stream(values()).filter(w -> w.getCode().equals(code)).findFirst(); + } - INDUSTRY("重点行业"); + public boolean eq(Integer code) { + return this.getCode().equals(code); + } - private final String name; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/MhProject.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/MhProject.java index 790672d..f15cd94 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/MhProject.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/MhProject.java @@ -57,6 +57,9 @@ public class MhProject implements Serializable { @ApiModelProperty("项目编码") private String projectCode; + @ApiModelProperty("申报单位领域") + private Integer unitStrip; + private LocalDateTime createTime; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/DeclaredProjectListReq.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/DeclaredProjectListReq.java index b65c41c..46d4a59 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/DeclaredProjectListReq.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/DeclaredProjectListReq.java @@ -31,4 +31,10 @@ public class DeclaredProjectListReq extends PagePo { @ApiModelProperty("创建时间(结束)") private LocalDate createDateMax; + @ApiModelProperty("申报单位领域") + private Integer unitStrip; + + @ApiModelProperty("申报单位ID") + private Long declaredUnitId; + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/DeclaredProjectListVO.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/DeclaredProjectListVO.java index 6ab19a8..8d1f8ac 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/DeclaredProjectListVO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/DeclaredProjectListVO.java @@ -23,6 +23,12 @@ public class DeclaredProjectListVO { @ApiModelProperty("申报单位") private String declaredUnit; + @ApiModelProperty("申报单位领域") + private Integer unitStrip; + + @ApiModelProperty("申报单位领域") + private String unitStripName; + @ApiModelProperty("项目申报金额(万元)") private BigDecimal declaredAmount; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/controller/MhUnitController.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/controller/MhUnitController.java index 05551e0..814c5ac 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/controller/MhUnitController.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/controller/MhUnitController.java @@ -1,5 +1,6 @@ package com.hz.pm.api.user.controller; +import com.hz.pm.api.external.model.enumeration.MhUnitStripEnum; import com.hz.pm.api.user.manage.MhUnitManage; import com.hz.pm.api.user.model.dto.MhUnitTreeDTO; import com.hz.pm.api.user.model.dto.MhUnitUserTreeDTO; @@ -38,6 +39,12 @@ public class MhUnitController { return mhUnitManage.getMhUnitTree(); } + @GetMapping("/treeByStrip") + @ApiOperation("按照领域查询单位树") + public List getMhUnitTreeByStrip(Integer unitStrip) { + return mhUnitManage.getMhUnitTreeByStrip(unitStrip); + } + @GetMapping("/page") @ApiOperation("单位列表") public PageVo page(MhUnitListReq req) { @@ -50,4 +57,5 @@ public class MhUnitController { return mhUnitManage.getUserTree(req); } + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java index 4dab607..66a4421 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/MhUnitManage.java @@ -1,7 +1,7 @@ package com.hz.pm.api.user.manage; import cn.hutool.core.bean.BeanUtil; -import com.baomidou.mybatisplus.core.conditions.Wrapper; +import cn.hutool.core.lang.Assert; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -51,12 +51,26 @@ public class MhUnitManage { List allUnits = mhUnitCache.all(); List nodes = allUnits.stream().map(w -> { MhUnitTreeDTO node = BeanUtil.copyProperties(w, MhUnitTreeDTO.class); - node.setStrip(node.getStrip()); + node.setStrip(node.getType().getStrip()); return node; }).collect(Collectors.toList()); return TreeUtil.convertToTree(nodes, 0L); } + public List getMhUnitTreeByStrip(Integer unitStrip) { + Assert.notNull(unitStrip, "领域不能为空"); + + List allUnits = mhUnitCache.all(); + List nodes = allUnits.stream() + .filter(w -> w.getType() != null && w.getType().getStrip().eq(unitStrip)) + .map(w -> { + MhUnitTreeDTO node = BeanUtil.copyProperties(w, MhUnitTreeDTO.class); + node.setStrip(node.getStrip()); + return node; + }).collect(Collectors.toList()); + return convertToTree(nodes); + } + public PageVo page(MhUnitListReq req) { LambdaQueryWrapper query = Wrappers.lambdaQuery(MhUnit.class) .like(StrUtils.isNotBlank(req.getName()), MhUnit::getName, req.getName()); @@ -70,7 +84,7 @@ public class MhUnitManage { unit.setType(type); unit.setStrip(type.getStrip()); unit.setTypeName(type.getVal()); - unit.setStripName(type.getStrip().getName()); + unit.setStripName(type.getStrip().getVal()); }); return unit; }).collect(Collectors.toList()); @@ -146,4 +160,27 @@ public class MhUnitManage { return node; } + public static List convertToTree(List units) { + List ids = CollUtils.fieldList(units, MhUnitTreeDTO::getId); + List roots = new ArrayList<>(); + for (MhUnitTreeDTO node : units) { + if (!ids.contains(node.getParentId())) { + roots.add(node); + } else { + for (MhUnitTreeDTO parent : units) { + if (parent.getId().equals(node.getParentId())) { + List children = parent.getChildren(); + if (children == null) { + children = new ArrayList<>(); + parent.setChildren(children); + } + children.add(node); + break; + } + } + } + } + return roots; + } + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/SyncMhUserOrgManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/SyncMhUserOrgManage.java index e6611c0..ebcfd9a 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/SyncMhUserOrgManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/SyncMhUserOrgManage.java @@ -24,6 +24,8 @@ import com.hz.pm.api.projectlib.model.entity.MhProject; import com.hz.pm.api.projectlib.model.entity.MhProjectSchemaTargetData; import com.hz.pm.api.projectlib.service.IMhProjectSchemaTargetDataService; import com.hz.pm.api.projectlib.service.IMhProjectService; +import com.hz.pm.api.user.helper.MhUnitCache; +import com.hz.pm.api.user.model.dto.UnitDTO; import com.hz.pm.api.user.model.entity.MhCompany; import com.hz.pm.api.user.model.entity.MhUnit; import com.hz.pm.api.user.model.entity.UserInfo; @@ -69,6 +71,7 @@ public class SyncMhUserOrgManage { private final IExpertDictionaryService expertDictionaryService; private final IMhProjectService mhProjectService; private final IMhProjectSchemaTargetDataService mhProjectSchemaTargetDataService; + private final MhUnitCache unitCache; @Transactional(rollbackFor = Exception.class) public void syncMhProjects() { @@ -89,6 +92,10 @@ public class SyncMhUserOrgManage { } else { preProject = BeanUtil.copyProperties(v, MhProject.class); } + UnitDTO unit = unitCache.getById(preProject.getUnitId()); + if (unit != null && unit.getType() != null) { + preProject.setUnitStrip(unit.getType().getStrip().getCode()); + } mhProjectService.saveOrUpdate(preProject); if (v.getSchemeTargetData() != null) { MhProjectSchemaTargetData schemaTargetData = new MhProjectSchemaTargetData(); diff --git a/hz-pm-api/src/test/java/com/hz/pm/api/todocenter/FlowableTest.java b/hz-pm-api/src/test/java/com/hz/pm/api/todocenter/FlowableTest.java index 0d5a299..9af1a6d 100644 --- a/hz-pm-api/src/test/java/com/hz/pm/api/todocenter/FlowableTest.java +++ b/hz-pm-api/src/test/java/com/hz/pm/api/todocenter/FlowableTest.java @@ -1,7 +1,12 @@ package com.hz.pm.api.todocenter; +import cn.hutool.core.io.FileUtil; import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hz.pm.api.external.model.dto.MhUnitDTO; +import com.hz.pm.api.user.model.entity.MhUnit; +import com.hz.pm.api.user.service.IMhUnitService; import com.ningdatech.basic.exception.BizException; import com.hz.pm.api.AppTests; import com.wflow.bean.entity.WflowCcTasks; @@ -309,4 +314,20 @@ public class FlowableTest extends AppTests { } + @Autowired + private IMhUnitService mhUnitService; + + @Test + public void test(){ + String s = FileUtil.readUtf8String("/Users/wendy/Desktop/response.json"); + List units = JSONUtil.parseObj(s).getBeanList("data", MhUnitDTO.class); + for (MhUnitDTO unit : units) { + LambdaUpdateWrapper set = Wrappers.lambdaUpdate(MhUnit.class) + .eq(MhUnit::getId, unit.getUnitId()) + .set(MhUnit::getUnifiedSocialCreditCode,unit.getUnifiedSocialCreditCode()) + .set(MhUnit::getType, unit.getType()); + mhUnitService.update(set); + } + } + }