diff --git a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/enums/OssTypeEnum.java b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/enums/OssTypeEnum.java index 1c43b7e121..6bb92ad38b 100644 --- a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/enums/OssTypeEnum.java +++ b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/enums/OssTypeEnum.java @@ -34,7 +34,11 @@ public enum OssTypeEnum { /** * 本地 */ - LOCAL(5); + LOCAL(5), + /** + * minio + */ + MINIO(6); private int value; diff --git a/epmet-module/epmet-oss/epmet-oss-server/pom.xml b/epmet-module/epmet-oss/epmet-oss-server/pom.xml index 951ea10bce..70b1540633 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/pom.xml +++ b/epmet-module/epmet-oss/epmet-oss-server/pom.xml @@ -90,6 +90,12 @@ org.springframework spring-test + + + io.minio + minio + 8.4.2 + diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/cloud/CloudStorageConfig.java b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/cloud/CloudStorageConfig.java index 9cd575cbcf..65e58c6a50 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/cloud/CloudStorageConfig.java +++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/cloud/CloudStorageConfig.java @@ -11,9 +11,11 @@ package com.epmet.cloud; import com.epmet.commons.tools.validator.group.AliyunGroup; import com.epmet.commons.tools.validator.group.QcloudGroup; import com.epmet.commons.tools.validator.group.QiniuGroup; +import com.epmet.constants.PrivacyType; import com.epmet.validator.group.FastDFSGroup; import com.epmet.validator.group.LocalGroup; import lombok.Data; +import org.apache.commons.lang3.StringUtils; import org.hibernate.validator.constraints.Range; import org.hibernate.validator.constraints.URL; @@ -101,6 +103,9 @@ public class CloudStorageConfig implements Serializable { private String localPath; private AliyunCloudStorageConfig aliyun; + + private MinioStorageConfig minio; + /** * 阿里云存储配置 */ @@ -110,6 +115,20 @@ public class CloudStorageConfig implements Serializable { private AliyunCloudStorageConfigProps external; } + @Data + public static class MinioStorageConfig { + private MinioStorageConfigProps internal; + private MinioStorageConfigProps external; + + public MinioStorageConfigProps getConfigByPrivacy(String privacy) { + if (StringUtils.isNotBlank(privacy) && PrivacyType.INTERNAL.equals(privacy)) { + return internal; + } else { + return external; + } + } + } + /** * 阿里云存储配置属性 */ @@ -134,4 +153,24 @@ public class CloudStorageConfig implements Serializable { private String aliyunBucketName; } + /** + * minio存储配置属性 + */ + @Data + public static class MinioStorageConfigProps { + /** + * 外部访问域名,用于用户直接访问minio服务 + */ + private String minioExternalDomain; + /** + * 内部访问域名,用于服务集群内部使用 + */ + private String minioInternalDomain; + private String minioEndPoint; + private String minioAccessKey; + private String minioSecretKey; + private String minioPrefix; + private String minioBucketName; + } + } diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/cloud/MinioStorageService.java b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/cloud/MinioStorageService.java new file mode 100644 index 0000000000..e9204c3623 --- /dev/null +++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/cloud/MinioStorageService.java @@ -0,0 +1,106 @@ +package com.epmet.cloud; + +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.exception.ExceptionUtils; +import io.minio.MinioClient; +import io.minio.ObjectWriteResponse; +import io.minio.PutObjectArgs; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.MediaType; +import org.springframework.http.MediaTypeFactory; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Paths; + +/** + * minio 文件服务 + */ +@Slf4j +public class MinioStorageService extends AbstractCloudStorageService { + + private MinioClient minioClient; + + public MinioStorageService(CloudStorageConfig config) { + this.config = config; + + CloudStorageConfig.MinioStorageConfigProps props = config.getMinio().getConfigByPrivacy(null); + + log.info("Minio客户端连接所用的域名:{}", props.getMinioInternalDomain()); + + /** + * minio和服务在同一个局域网,则可以使用内网域名上传,速度更快更稳定 + */ + minioClient = MinioClient.builder() + .endpoint(props.getMinioInternalDomain()) // 保证和nginx的proxy_set_header Host 一致 + .credentials(props.getMinioAccessKey(), props.getMinioSecretKey()) + .build(); + } + + @Override + public String getOssDomain(String privacy) { + return this.config.getMinio().getConfigByPrivacy(privacy).getMinioExternalDomain(); + } + + @Override + public String getOssPrefix(String privacy) { + return this.config.getMinio().getConfigByPrivacy(privacy).getMinioPrefix(); + } + + @Override + public String upload(byte[] data, String path, String privacyType) { + return upload(new ByteArrayInputStream(data), path, privacyType); + } + + @Override + public String uploadSuffix(byte[] data, String suffix, String privacyType) { + return uploadSuffix(new ByteArrayInputStream(data), suffix, privacyType); + } + + /** + * 此处bucket已经做为path + * @param inputStream 字节流 + * @param path 文件路径,包含文件名 + * @param privacyType + * @return + */ + @Override + public String upload(InputStream inputStream, String path, String privacyType) { + CloudStorageConfig.MinioStorageConfigProps props = this.config.getMinio().getConfigByPrivacy(privacyType); + String contentType = MediaTypeFactory.getMediaType(path).orElse(MediaType.APPLICATION_OCTET_STREAM).toString(); + try { + ObjectWriteResponse resp = minioClient.putObject(PutObjectArgs.builder() + .bucket(props.getMinioBucketName()) + .object(path) + .stream(inputStream, inputStream.available(), -1) + .contentType(contentType) + .build()); + + log.debug("minio上传文件成功。bucket:{}, object:{}, privacyType:{}", resp.bucket(), resp.object(), privacyType); + + // 返回值要存储到数据库,供用户访问,因此使用外网域名 + return props.getMinioExternalDomain() + "/" + Paths.get(resp.bucket()).resolve(resp.object()).toString(); + } catch (Exception e) { + String errorMsg = ExceptionUtils.getErrorStackTrace(e); + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), errorMsg); + } + } + + @Override + public String uploadSuffix(InputStream inputStream, String suffix, String privacyType) { + CloudStorageConfig.MinioStorageConfigProps props = this.config.getMinio().getConfigByPrivacy(privacyType); + return upload(inputStream, getPath(props.getMinioPrefix(), suffix, privacyType), privacyType); + } + + @Override + public void down(String privacyType) throws IOException { + + } + + @Override + public boolean delete(String objectName, String privacyType) { + return false; + } +} diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/cloud/OssFactory.java b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/cloud/OssFactory.java index 3d69543784..a9113d5fba 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/cloud/OssFactory.java +++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/cloud/OssFactory.java @@ -40,6 +40,8 @@ public final class OssFactory { abstractCloudStorageService = new FastDFSCloudStorageService(config); }else if(config.getType() == OssTypeEnum.LOCAL.value()){ abstractCloudStorageService = new LocalCloudStorageService(config); + }else if(config.getType() == OssTypeEnum.MINIO.value()){ + abstractCloudStorageService = new MinioStorageService(config); } } return abstractCloudStorageService; diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyResultDTO.java index a7aec4fa28..c40b7448d6 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyResultDTO.java @@ -47,5 +47,8 @@ public class AgencyResultDTO implements Serializable { private String longitude; //维度【没值则取跟客户的值】 private String latitude; - + /** + * agencyId的全路径,包含自身 + */ + private String orgIdPath; } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencySubResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencySubResultDTO.java index 08bd0683b1..1461c66fa1 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencySubResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencySubResultDTO.java @@ -61,4 +61,8 @@ public class AgencySubResultDTO implements Serializable { * 组织维度【没值取根组织的值】 */ private String latitude = ""; + /** + * agencyId的全路径,包含自身 + */ + private String orgIdPath; } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml index 37964a6e2c..a21e6e4e20 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml @@ -198,7 +198,11 @@ ca.pids AS "pids", ca.level level, IFNULL(ca.longitude, cc.longitude) longitude, - IFNULL(ca.latitude, cc.latitude) latitude + IFNULL(ca.latitude, cc.latitude) latitude, + ( + case when ca.pid is null or ca.pid='0' or ca.pid='' then ca.id + else concat(ca.pids,':',ca.id) + end)as orgIdPath FROM customer_agency ca INNER JOIN customer_agency cc ON cc.pid = '0' AND ca.customer_id = cc.customer_id WHERE ca.del_flag = '0' @@ -397,7 +401,11 @@ ca.pid pid, ca.level level, ca.longitude, - ca.latitude + ca.latitude, + ( + case when ca.pid is null or ca.pid='0' or ca.pid='' then ca.id + else concat(ca.pids,':',ca.id) + end)as orgIdPath FROM customer_agency ca INNER JOIN customer_staff_agency csa ON ca.id = csa.agency_id 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 0e7f1a5e20..84080d204e 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 @@ -17,8 +17,11 @@ package com.epmet.dto; +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; import lombok.Data; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import java.io.Serializable; import java.util.Date; @@ -34,9 +37,12 @@ public class TagCustomerDTO implements Serializable { private static final long serialVersionUID = 1L; + public interface ChangeShowFlagGroup extends CustomerClientShowGroup { + } /** * 主键ID */ + @NotBlank(message = "id不能为空",groups = ChangeShowFlagGroup.class) private String id; /** @@ -54,6 +60,12 @@ public class TagCustomerDTO implements Serializable { */ private Integer useCount; + /** + * 1:展示;0:隐藏;0302因烟台需求增加此列默认1 + */ + @NotNull(message = "showFlag不能为空",groups = ChangeShowFlagGroup.class) + private Integer showFlag; + /** * 删除标识 0.未删除 1.已删除 */ 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 new file mode 100644 index 0000000000..a4e5052273 --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagScopeDTO.java @@ -0,0 +1,33 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description + * @Author yzm + * @Date 2023/3/2 13:52 + */ +@Data +public class TagScopeDTO implements Serializable { + /** + * 标签ID + */ + private String tagId; + + /** + * 应用范围,这里只能是社区id + */ + private String agencyId; + /** + * agency_id全路径,包含自身 + */ + private String orgIdPath; + + /** + * 组织名称 + */ + private String agencyName; +} + 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 new file mode 100644 index 0000000000..403b30094d --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerFormDTO.java @@ -0,0 +1,56 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import com.epmet.dto.TagScopeDTO; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * @Description + * @Author yzm + * @Date 2023/3/2 12:47 + */ +@Data +public class TagCustomerFormDTO implements Serializable { + private static final long serialVersionUID = -5631868409077026783L; + + public interface AddUserInternalGroup { + } + + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + + public interface UpdateUserInternalGroup { + } + + public interface UpdateUserShowGroup extends CustomerClientShowGroup { + } + + + /** + * 主键ID + */ + @NotBlank(message = "id不能为空", groups = {UpdateUserInternalGroup.class}) + private String id; + + /** + * 标签名称 + */ + @Length(max = 30, message = "标签名称最多输入30字", groups = {AddUserShowGroup.class, UpdateUserShowGroup.class}) + @NotBlank(message = "标签名称不能为空", groups = {AddUserShowGroup.class, UpdateUserShowGroup.class}) + private String tagName; + + /** + * 应用范围,只能选社区 + */ + private List agencyIds; + /** + * 客户ID + */ + private String customerId; +} + diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerPageFormDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerPageFormDTO.java new file mode 100644 index 0000000000..04ee2370eb --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerPageFormDTO.java @@ -0,0 +1,44 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * @Description pc标签管理-分页查询入参 + * @Author yzm + * @Date 2023/3/2 11:34 + */ +@Data +public class TagCustomerPageFormDTO implements Serializable { + private static final long serialVersionUID = -2311491158902019019L; + + public interface PageUserInternalGroup { + } + + public interface PageUserShowGroup extends CustomerClientShowGroup { + } + + + /** + * 客户ID + */ + @NotBlank(message = "customerId不能为空", groups = PageUserInternalGroup.class) + private String customerId; + + /** + * 标签名称 + */ + private String tagName; + + + @NotNull(message = "页码不能为空", groups = PageUserInternalGroup.class) + private Integer pageNo; + + @NotNull(message = "每页数量不能为空", groups = PageUserInternalGroup.class) + private Integer pageSize; +} + 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 bd2603685b..b73213752b 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 @@ -1,15 +1,15 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.dto.form.CorrelationTagListFormDTO; -import com.epmet.dto.form.InitTagFormDTO; -import com.epmet.dto.form.ResiTagListFormDTO; -import com.epmet.dto.form.TagCascadeListFormDTO; +import com.epmet.dto.TagCustomerDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.CorrelationTagListResultDTO; import com.epmet.dto.result.TagInfoResultDTO; +import com.epmet.service.TagCustomerService; import com.epmet.service.TagService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -25,6 +25,8 @@ public class TagController { @Autowired private TagService tagService; + @Autowired + private TagCustomerService tagCustomerService; /** * @Description 已发布列表页的标签——政府端 @@ -81,4 +83,55 @@ public class TagController { return new Result().ok(tagService.initTag(formDto)); } + /** + * pc标签管理-分页查询 + * @param formDTO + * @return + */ + @PostMapping("page-list") + public Result> pageList(@LoginUser TokenDto tokenDto,@RequestBody TagCustomerPageFormDTO formDTO){ + tokenDto.setCustomerId(formDTO.getCustomerId()); + ValidatorUtils.validateEntity(formDTO,TagCustomerPageFormDTO.PageUserInternalGroup.class,TagCustomerPageFormDTO.PageUserShowGroup.class); + return new Result>().ok(tagCustomerService.page(formDTO)); + } + + /** + * 新增标签 + * @param tokenDto + * @param formDTO + * @return + */ + @PostMapping("save") + public Result save(@LoginUser TokenDto tokenDto,@RequestBody TagCustomerFormDTO formDTO){ + formDTO.setCustomerId(tokenDto.getCustomerId()); + ValidatorUtils.validateEntity(formDTO,TagCustomerFormDTO.AddUserShowGroup.class,TagCustomerFormDTO.AddUserInternalGroup.class); + tagCustomerService.save(formDTO); + return new Result(); + } + + /** + * 修改标签 + * @param tokenDto + * @param formDTO + * @return + */ + @PostMapping("update") + public Result update(@LoginUser TokenDto tokenDto,@RequestBody TagCustomerFormDTO formDTO){ + formDTO.setCustomerId(tokenDto.getCustomerId()); + ValidatorUtils.validateEntity(formDTO,TagCustomerFormDTO.UpdateUserShowGroup.class,TagCustomerFormDTO.UpdateUserInternalGroup.class); + tagCustomerService.update(formDTO); + return new Result(); + } + + /** + * 隐藏、显示 + * @param tagCustomerDTO + * @return + */ + @PostMapping("change-show-flag") + public Result changeShowFlag(@RequestBody TagCustomerDTO tagCustomerDTO){ + tagCustomerService.changeShowFlag(tagCustomerDTO.getId(),tagCustomerDTO.getShowFlag()); + return new Result(); + } + } 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 595f2a9a18..70c29ec8a2 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 @@ -18,6 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.TagCustomerDTO; import com.epmet.dto.form.InitTagsFormDTO; import com.epmet.dto.form.UpdateTagFormDTO; import com.epmet.entity.TagCustomerEntity; @@ -55,4 +56,12 @@ public interface TagCustomerDao extends BaseDao { * @return */ List selectInitData(@Param("customerIdList") List customerIdList); + + /** + * pc标签管理-分页查询 + * @param customerId + * @param tagName + * @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 new file mode 100644 index 0000000000..3aecba1d55 --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagScopeDao.java @@ -0,0 +1,18 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.TagScopeEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 标签应用范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-03-02 + */ +@Mapper +public interface TagScopeDao extends BaseDao { + + int deleteByTagId(@Param("tagId") String tagId, @Param("customerId") String customerId); +} \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/TagCustomerEntity.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/TagCustomerEntity.java index 7a2a54d7ae..e86fbb2231 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/TagCustomerEntity.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/TagCustomerEntity.java @@ -55,4 +55,8 @@ public class TagCustomerEntity extends BaseEpmetEntity { */ private Integer useCount; + /** + * 1:展示;0:隐藏;0302因烟台需求增加此列默认1 + */ + private Integer showFlag; } 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 new file mode 100644 index 0000000000..6747b64835 --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/TagScopeEntity.java @@ -0,0 +1,45 @@ +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 标签应用范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2023-03-02 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("tag_scope") +public class TagScopeEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID(0302因烟台需求增加此表) + */ + private String customerId; + + /** + * 标签ID + */ + private String tagId; + + /** + * 应用范围,这里只能是社区id + */ + private String agencyId; + + /** + * agency_id全路径,包含自身 + */ + private String orgIdPath; + + /** + * 组织名称 + */ + private String agencyName; +} 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 3ecb3c49c1..099df16cab 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 @@ -20,6 +20,8 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.TagCustomerDTO; +import com.epmet.dto.form.TagCustomerFormDTO; +import com.epmet.dto.form.TagCustomerPageFormDTO; import com.epmet.dto.result.UpdateTagUseCountsResultDTO; import com.epmet.entity.TagCustomerEntity; @@ -35,14 +37,14 @@ import java.util.Map; public interface TagCustomerService extends BaseService { /** - * 默认分页 + * pc标签管理-分页查询 * - * @param params + * @param formDTO * @return PageData * @author generator * @date 2020-06-02 */ - PageData page(Map params); + PageData page(TagCustomerPageFormDTO formDTO); /** * 默认查询 @@ -65,24 +67,24 @@ public interface TagCustomerService extends BaseService { TagCustomerDTO get(String id); /** - * 默认保存 + * 新增标签 * * @param dto * @return void * @author generator * @date 2020-06-02 */ - void save(TagCustomerDTO dto); + void save(TagCustomerFormDTO dto); /** - * 默认更新 + * 修改标签 * * @param dto * @return void * @author generator * @date 2020-06-02 */ - void update(TagCustomerDTO dto); + void update(TagCustomerFormDTO dto); /** * 批量删除 @@ -100,4 +102,11 @@ public interface TagCustomerService extends BaseService { * @author zxc */ UpdateTagUseCountsResultDTO checkTagInfo(String tagName,String customerId,String userId); + + /** + * 隐藏、显示 + * @param id + * @param showFlag + */ + void changeShowFlag(String id, Integer showFlag); } \ 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 b5c69d76c1..219cc7616c 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 @@ -17,24 +17,39 @@ 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.metadata.IPage; +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; +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.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.UpdateTagUseCountsResultDTO; import com.epmet.entity.TagCustomerEntity; +import com.epmet.entity.TagScopeEntity; import com.epmet.service.TagCustomerService; 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; import java.util.Arrays; +import java.util.Date; import java.util.List; import java.util.Map; @@ -46,14 +61,21 @@ import java.util.Map; */ @Service public class TagCustomerServiceImpl extends BaseServiceImpl implements TagCustomerService { + @Autowired + private TagScopeDao tagScopeDao; + + /** + * pc标签管理-分页查询 + * @param formDTO + * @return + */ @Override - public PageData page(Map params) { - IPage page = baseDao.selectPage( - getPage(params, FieldConstant.CREATED_TIME, false), - getWrapper(params) - ); - return getPageData(page, TagCustomerDTO.class); + public PageData page(TagCustomerPageFormDTO formDTO) { + PageHelper.startPage(formDTO.getPageNo(),formDTO.getPageSize()); + List list=baseDao.pageList(formDTO.getCustomerId(),formDTO.getTagName()); + PageInfo pageInfo = new PageInfo<>(list); + return new PageData<>(list, pageInfo.getTotal()); } @Override @@ -78,18 +100,68 @@ public class TagCustomerServiceImpl extends BaseServiceImpl queryWrapper=new LambdaQueryWrapper<>(); + queryWrapper.eq(TagCustomerEntity::getCustomerId,dto.getCustomerId()) + .eq(TagCustomerEntity::getTagName,dto.getTagName()); + if(baseDao.selectCount(queryWrapper)>0){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"标签名称已存在","标签名称已存在"); + } TagCustomerEntity entity = ConvertUtils.sourceToTarget(dto, TagCustomerEntity.class); + entity.setTagColor(StrConstant.EPMETY_STR); + entity.setUseCount(NumConstant.ZERO); + entity.setShowFlag(NumConstant.ONE); insert(entity); + if(CollectionUtils.isNotEmpty(dto.getAgencyIds())){ + dto.getAgencyIds().forEach(tagScopeDTO->{ + TagScopeEntity tagScopeEntity=new TagScopeEntity(); + tagScopeEntity.setCustomerId(entity.getCustomerId()); + tagScopeEntity.setTagId(entity.getId()); + tagScopeEntity.setAgencyId(tagScopeDTO.getAgencyId()); + tagScopeEntity.setAgencyName(tagScopeDTO.getAgencyName()); + tagScopeEntity.setOrgIdPath(tagScopeDTO.getOrgIdPath()); + tagScopeDao.insert(tagScopeEntity); + }); + } } + /** + * pc标签管理-修改 + * @param dto + */ @Override @Transactional(rollbackFor = Exception.class) - public void update(TagCustomerDTO dto) { + public void update(TagCustomerFormDTO dto) { + // 标签名称是否存在 + LambdaQueryWrapper queryWrapper=new LambdaQueryWrapper<>(); + queryWrapper.eq(TagCustomerEntity::getCustomerId,dto.getCustomerId()) + .eq(TagCustomerEntity::getTagName,dto.getTagName()) + .ne(TagCustomerEntity::getId,dto.getId()); + if(baseDao.selectCount(queryWrapper)>0){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"标签名称已存在","标签名称已存在"); + } TagCustomerEntity entity = ConvertUtils.sourceToTarget(dto, TagCustomerEntity.class); updateById(entity); + //删除应用范围 + tagScopeDao.deleteByTagId(entity.getId(),entity.getCustomerId()); + if(CollectionUtils.isNotEmpty(dto.getAgencyIds())){ + dto.getAgencyIds().forEach(tagScopeDTO->{ + TagScopeEntity tagScopeEntity=new TagScopeEntity(); + tagScopeEntity.setCustomerId(entity.getCustomerId()); + tagScopeEntity.setTagId(entity.getId()); + tagScopeEntity.setAgencyId(tagScopeDTO.getAgencyId()); + tagScopeEntity.setAgencyName(tagScopeDTO.getAgencyName()); + tagScopeEntity.setOrgIdPath(tagScopeDTO.getOrgIdPath()); + tagScopeDao.insert(tagScopeEntity); + }); + } } @Override @@ -126,4 +198,19 @@ public class TagCustomerServiceImpl extends BaseServiceImpl tagCustomerUpdateWrapper = new LambdaUpdateWrapper<>(); + tagCustomerUpdateWrapper.eq(TagCustomerEntity::getId, id) + .set(TagCustomerEntity::getUpdatedBy, EpmetRequestHolder.getLoginUserId()) + .set(TagCustomerEntity::getUpdatedTime, new Date()) + .set(TagCustomerEntity::getShowFlag,showFlag); + baseDao.update(null,tagCustomerUpdateWrapper); + } } diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/db/migration/V0.0.13__tag_scope.sql b/epmet-module/gov-voice/gov-voice-server/src/main/resources/db/migration/V0.0.13__tag_scope.sql new file mode 100644 index 0000000000..4eb48152f6 --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/db/migration/V0.0.13__tag_scope.sql @@ -0,0 +1,19 @@ +alter table tag_customer add COLUMN SHOW_FLAG TINYINT(1) DEFAULT 1 comment '1:展示;0:隐藏;0302因烟台需求增加此列默认1' after USE_COUNT; + +CREATE TABLE `tag_scope` ( + `ID` varchar(64) NOT NULL COMMENT '主键(0302因烟台需求增加此表)', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户ID(0302因烟台需求增加此表)', + `TAG_ID` varchar(64) NOT NULL COMMENT '标签ID', + `AGENCY_ID` varchar(64) NOT NULL COMMENT '应用范围,这里只能是社区id', + `ORG_ID_PATH` varchar(255) NOT NULL COMMENT 'agency_id全路径,包含自身', + `AGENCY_NAME` varchar(255) NOT NULL COMMENT '组织名称', + `DEL_FLAG` int(11) NOT NULL DEFAULT '0' COMMENT '删除标识 0.未删除 1.已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='标签应用范围表'; + + 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 83ed4289ad..a73ca7d5b8 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,4 +56,14 @@ ORDER BY CUSTOMER_ID + + 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 new file mode 100644 index 0000000000..ed8f0b052a --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagScopeDao.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + delete from tag_scope + where TAG_ID=#{tagId} + and CUSTOMER_ID=#{customerId} + + \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerInitFormDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerInitFormDTO.java index 04a40b5871..def7584d23 100644 --- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerInitFormDTO.java +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerInitFormDTO.java @@ -3,6 +3,7 @@ package com.epmet.dto.form; import lombok.Data; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import java.io.Serializable; /** @@ -12,11 +13,55 @@ import java.io.Serializable; @Data public class CustomerInitFormDTO implements Serializable { - public interface GetCustomerDetailGroup { - } + /** + * 初始化带小程序的客户 + */ + public interface InitMiniAppCustomerGroup {} + + /** + * 初始化本地客户 + */ + public interface InitLocalCustomerGroup {} - @NotBlank(message = "客户Id不能为空", groups = {GetCustomerDetailGroup.class}) + @NotBlank(message = "客户Id不能为空", groups = {InitMiniAppCustomerGroup.class}) private String customerId; + @NotNull(message = "缺少paCustomer信息", groups = InitLocalCustomerGroup.class) + private PaCustomer paCustomer; + @NotNull(message = "缺少paCustomerAgency信息", groups = InitLocalCustomerGroup.class) + private PaCustomerAgency paAgency; + @NotNull(message = "缺少paUser信息", groups = InitLocalCustomerGroup.class) + private PaUser paUser; + + + @Data + public static class PaCustomer { + private String customerName; + private String isInitialize; + private String source; + private String type; + } + + @Data + public static class PaCustomerAgency { + private String id; + private String agencyName; + private String areaCode; + private String city; + private String customerId; + private String district; + private String level; + private String levelNum; + private Integer partybranchnum; + private String province; + } + + @Data + public static class PaUser { + private String gender; + private String phone; + private String realName; + } + } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java index 907ffbc967..cc730f6223 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java @@ -257,11 +257,45 @@ public class CustomerController { **/ @PostMapping("init") public Result init(@RequestBody CustomerInitFormDTO formDTO) { - ValidatorUtils.validateEntity(formDTO, CustomerInitFormDTO.GetCustomerDetailGroup.class); + ValidatorUtils.validateEntity(formDTO, CustomerInitFormDTO.InitMiniAppCustomerGroup.class); customerService.init(formDTO); return new Result(); } + /** + * 本地初始化客户,不经过小程序 + * curl --location 'http://localhost:8090/oper/crm/customer/initLocally' \ + * --header 'Content-Type: application/json' \ + * --data '{ + * "paAgency": { + * "agencyName": "wxz测试001", + * "areaCode": "370666", + * "city": "青岛市", + * "district": "海马脑区", + * "level": "district", + * "levelNum": "2", + * "partybranchnum": 50, + * "province": "山东省" + * }, + * "paCustomer": { + * "customerName": "海马脑区" + * }, + * "paUser": { + * "gender": "1", + * "phone": "18560677960", + * "realName": "wang" + * } + * }' + * @param formDTO + * @return + */ + @PostMapping("initLocally") + public Result initLocally(@RequestBody CustomerInitFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, CustomerInitFormDTO.InitLocalCustomerGroup.class); + customerService.initLocal(formDTO); + return new Result(); + } + /** * desc:获取所有未删除的客户 * @return diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java index f1efa2d087..c0ae3c1309 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java @@ -166,6 +166,11 @@ public interface CustomerService extends BaseService { **/ void init(CustomerInitFormDTO formDTO); + /** + * 本地初始化(不走小程序) + */ + void initLocal(CustomerInitFormDTO input); + /** * desc:获取所有客户列表 * @return diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java index 856a72c96d..0c1c2a3d47 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java @@ -22,6 +22,7 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.rocketmq.messages.InitCustomerMQMsg; import com.epmet.commons.tools.constant.FieldConstant; @@ -585,6 +586,74 @@ public class CustomerServiceImpl extends BaseServiceImpl resultPoint = epmetPointOpenFeignClient.initPointRule(customerId); + if (!resultPoint.success()) { + throw new RenException(resultPoint.getCode(), resultPoint.getInternalMsg()); + } + + //9.新客户初始化评价指标 权重 + InitCustomerIndexForm indexForm = new InitCustomerIndexForm(); + indexForm.setCustomerId(customerId); + Result resultData = dataStatisticalOpenFeignClient.initCustomerIndex(indexForm); + if (!resultData.success()) { + throw new RenException(resultData.getCode(), resultData.getInternalMsg()); + } + //2021.1.25 end + + } + private InitCustomerMQMsg.InitCustomerStaff constructStaffInfo4CustomerInit(String agencyId, PaUserDTO paUser) { InitCustomerMQMsg.InitCustomerStaff staff = new InitCustomerMQMsg.InitCustomerStaff(); staff.setAgencyId(agencyId);