From 52f195a0a28fd1daec85071e48757ccee80c8c02 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Thu, 2 Mar 2023 14:18:40 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=A0=87=E7=AD=BE=E8=AE=B0=E5=BD=95orgIdPa?= =?UTF-8?q?th?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/dto/TagCustomerDTO.java | 16 +++++++++++ .../epmet/dto/form/TagCustomerFormDTO.java | 2 +- .../java/com/epmet/dao/TagCustomerDao.java | 1 + .../main/java/com/epmet/dao/TagScopeDao.java | 5 ++++ .../com/epmet/service/TagCustomerService.java | 13 --------- .../service/impl/TagCustomerServiceImpl.java | 28 +++---------------- .../main/resources/mapper/TagCustomerDao.xml | 11 +++++++- .../src/main/resources/mapper/TagScopeDao.xml | 12 ++++++++ 8 files changed, 49 insertions(+), 39 deletions(-) diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagCustomerDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagCustomerDTO.java index 84080d204e..15e4d22232 100644 --- a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagCustomerDTO.java +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagCustomerDTO.java @@ -18,12 +18,14 @@ package com.epmet.dto; import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.Date; +import java.util.List; /** @@ -54,6 +56,10 @@ public class TagCustomerDTO implements Serializable { * 标签名称 */ private String tagName; + /** + * 标签颜色 + */ + private String tagColor; /** * 使用计数 @@ -69,31 +75,41 @@ public class TagCustomerDTO implements Serializable { /** * 删除标识 0.未删除 1.已删除 */ + @JsonIgnore private Integer delFlag; /** * 乐观锁 */ + @JsonIgnore private Integer revision; /** * 创建人 */ + @JsonIgnore private String createdBy; /** * 创建时间 */ + @JsonIgnore private Date createdTime; /** * 更新人 */ + @JsonIgnore private String updatedBy; /** * 更新时间 */ + @JsonIgnore private Date updatedTime; + /** + * 应用范围 + */ + private List agencyList; } diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerFormDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerFormDTO.java index 403b30094d..d27d57e3f4 100644 --- a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerFormDTO.java +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerFormDTO.java @@ -47,7 +47,7 @@ public class TagCustomerFormDTO implements Serializable { /** * 应用范围,只能选社区 */ - private List agencyIds; + private List agencyList; /** * 客户ID */ diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagCustomerDao.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagCustomerDao.java index 70c29ec8a2..cf3ccefc3a 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagCustomerDao.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagCustomerDao.java @@ -64,4 +64,5 @@ public interface TagCustomerDao extends BaseDao { * @return */ List pageList(@Param("customerId") String customerId, @Param("tagName")String tagName); + } diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagScopeDao.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagScopeDao.java index 3aecba1d55..411801f4b5 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagScopeDao.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagScopeDao.java @@ -1,10 +1,13 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.TagScopeDTO; import com.epmet.entity.TagScopeEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * 标签应用范围表 * @@ -15,4 +18,6 @@ import org.apache.ibatis.annotations.Param; public interface TagScopeDao extends BaseDao { int deleteByTagId(@Param("tagId") String tagId, @Param("customerId") String customerId); + + List selectScope(String tagId); } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/TagCustomerService.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/TagCustomerService.java index 099df16cab..eccf691c7f 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/TagCustomerService.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/TagCustomerService.java @@ -25,9 +25,6 @@ import com.epmet.dto.form.TagCustomerPageFormDTO; import com.epmet.dto.result.UpdateTagUseCountsResultDTO; import com.epmet.entity.TagCustomerEntity; -import java.util.List; -import java.util.Map; - /** * 客户标签表 * @@ -46,16 +43,6 @@ public interface TagCustomerService extends BaseService { */ PageData page(TagCustomerPageFormDTO formDTO); - /** - * 默认查询 - * - * @param params - * @return java.util.List - * @author generator - * @date 2020-06-02 - */ - List list(Map params); - /** * 单条查询 * diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java index 219cc7616c..7c1befb4f2 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java @@ -18,10 +18,8 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; -import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; @@ -43,7 +41,6 @@ import com.epmet.utils.TagColorUtils; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -51,7 +48,6 @@ import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; import java.util.Date; import java.util.List; -import java.util.Map; /** * 客户标签表 @@ -78,22 +74,6 @@ public class TagCustomerServiceImpl extends BaseServiceImpl(list, pageInfo.getTotal()); } - @Override - public List list(Map params) { - List entityList = baseDao.selectList(getWrapper(params)); - - return ConvertUtils.sourceToTarget(entityList, TagCustomerDTO.class); - } - - private QueryWrapper getWrapper(Map params){ - String id = (String)params.get(FieldConstant.ID_HUMP); - - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); - - return wrapper; - } - @Override public TagCustomerDTO get(String id) { TagCustomerEntity entity = baseDao.selectById(id); @@ -119,8 +99,8 @@ public class TagCustomerServiceImpl extends BaseServiceImpl{ + if(CollectionUtils.isNotEmpty(dto.getAgencyList())){ + dto.getAgencyList().forEach(tagScopeDTO->{ TagScopeEntity tagScopeEntity=new TagScopeEntity(); tagScopeEntity.setCustomerId(entity.getCustomerId()); tagScopeEntity.setTagId(entity.getId()); @@ -151,8 +131,8 @@ public class TagCustomerServiceImpl extends BaseServiceImpl{ + if(CollectionUtils.isNotEmpty(dto.getAgencyList())){ + dto.getAgencyList().forEach(tagScopeDTO->{ TagScopeEntity tagScopeEntity=new TagScopeEntity(); tagScopeEntity.setCustomerId(entity.getCustomerId()); tagScopeEntity.setTagId(entity.getId()); diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagCustomerDao.xml b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagCustomerDao.xml index a73ca7d5b8..2900561bd4 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagCustomerDao.xml +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagCustomerDao.xml @@ -56,8 +56,17 @@ ORDER BY CUSTOMER_ID + + + + + + + + + - select tc.* from tag_customer tc where tc.del_flag='0' diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagScopeDao.xml b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagScopeDao.xml index ed8f0b052a..1da2fc6eca 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagScopeDao.xml +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagScopeDao.xml @@ -8,6 +8,8 @@ + + @@ -21,4 +23,14 @@ where TAG_ID=#{tagId} and CUSTOMER_ID=#{customerId} + + \ No newline at end of file From 8be4ecfaf24200219875f7c5c41e5a025537d2e0 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Thu, 2 Mar 2023 14:24:46 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=8E=BB=E6=8E=89agencyName?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/dto/TagScopeDTO.java | 5 ----- .../src/main/java/com/epmet/entity/TagScopeEntity.java | 4 ---- .../java/com/epmet/service/impl/TagCustomerServiceImpl.java | 2 -- .../src/main/resources/db/migration/V0.0.13__tag_scope.sql | 1 - .../src/main/resources/mapper/TagScopeDao.xml | 4 +--- 5 files changed, 1 insertion(+), 15 deletions(-) diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagScopeDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagScopeDTO.java index a4e5052273..e5bf3d021a 100644 --- a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagScopeDTO.java +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagScopeDTO.java @@ -24,10 +24,5 @@ public class TagScopeDTO implements Serializable { * agency_id全路径,包含自身 */ private String orgIdPath; - - /** - * 组织名称 - */ - private String agencyName; } diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/TagScopeEntity.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/TagScopeEntity.java index 6747b64835..7e00ef4919 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/TagScopeEntity.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/TagScopeEntity.java @@ -38,8 +38,4 @@ public class TagScopeEntity extends BaseEpmetEntity { */ private String orgIdPath; - /** - * 组织名称 - */ - private String agencyName; } diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java index 7c1befb4f2..cad48f6eeb 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java @@ -105,7 +105,6 @@ public class TagCustomerServiceImpl extends BaseServiceImpl - @@ -27,8 +26,7 @@ + + + diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/TagController.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/TagController.java index b73213752b..028897d4a0 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/TagController.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/TagController.java @@ -134,4 +134,15 @@ public class TagController { return new Result(); } + /** + * 初始化标签应用范围, + * 每个标签,和当前客户下所有社区关联 + * @param tokenDto + * @return + */ + @PostMapping("initTagScope") + public Result initTagScope(@LoginUser TokenDto tokenDto){ + tagCustomerService.initTagScope(tokenDto.getCustomerId()); + return new Result(); + } } diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/TagCustomerService.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/TagCustomerService.java index eccf691c7f..670393895e 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/TagCustomerService.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/TagCustomerService.java @@ -96,4 +96,12 @@ public interface TagCustomerService extends BaseService { * @param showFlag */ void changeShowFlag(String id, Integer showFlag); + + /** + * 初始化标签应用范围, + * 每个标签,和当前客户下所有社区关联 + * @param tokenDto + * @return + */ + void initTagScope(String customerId); } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java index cad48f6eeb..28997231cc 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java @@ -27,21 +27,27 @@ import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.EpmetRequestHolder; +import com.epmet.commons.tools.utils.Result; import com.epmet.dao.TagCustomerDao; import com.epmet.dao.TagScopeDao; import com.epmet.dto.TagCustomerDTO; import com.epmet.dto.form.TagCustomerFormDTO; import com.epmet.dto.form.TagCustomerPageFormDTO; import com.epmet.dto.form.UpdateTagFormDTO; +import com.epmet.dto.result.AgencyResultDTO; import com.epmet.dto.result.UpdateTagUseCountsResultDTO; import com.epmet.entity.TagCustomerEntity; import com.epmet.entity.TagScopeEntity; +import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.service.TagCustomerService; import com.epmet.utils.TagColorUtils; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -55,10 +61,13 @@ import java.util.List; * @author generator generator@elink-cn.com * @since v1.0.0 2020-06-02 */ +@Slf4j @Service public class TagCustomerServiceImpl extends BaseServiceImpl implements TagCustomerService { @Autowired private TagScopeDao tagScopeDao; + @Autowired + private GovOrgOpenFeignClient govOrgOpenFeignClient; /** @@ -191,4 +200,45 @@ public class TagCustomerServiceImpl extends BaseServiceImpl queryWrapper = new LambdaQueryWrapper(); + queryWrapper.eq(TagCustomerEntity::getCustomerId, customerId); + List tagList = baseDao.selectList(queryWrapper); + if (CollectionUtils.isEmpty(tagList)) { + return; + } + int tagTotal = tagList.size(); + // 获取当前客户下所有的社区组织 + Result> communityRes = govOrgOpenFeignClient.getAllCommunity(customerId); + if (communityRes.success() && CollectionUtils.isNotEmpty(communityRes.getData())) { + int communityTotal = communityRes.getData().size(); + int num = 1; + for (TagCustomerEntity tag : tagList) { + for (AgencyResultDTO agencyResultDTO : communityRes.getData()) { + TagScopeEntity tagScopeEntity = new TagScopeEntity(); + tagScopeEntity.setCustomerId(tag.getCustomerId()); + tagScopeEntity.setTagId(tag.getId()); + tagScopeEntity.setAgencyId(agencyResultDTO.getAgencyId()); + tagScopeEntity.setOrgIdPath(agencyResultDTO.getOrgIdPath()); + tagScopeDao.insert(tagScopeEntity); + num++; + } + } + log.error(String.format("customerId:%s,已经将%s个标签应用给%s个社区,tag_scope产生%s条记录", customerId, tagTotal, communityTotal, num)); + } + + } + }