Browse Source

Merge remote-tracking branch 'origin/yantai_zhengwu_master' into dev

master
yinzuomei 3 years ago
parent
commit
01a4eeab9c
  1. 6
      epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/enums/OssTypeEnum.java
  2. 6
      epmet-module/epmet-oss/epmet-oss-server/pom.xml
  3. 39
      epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/cloud/CloudStorageConfig.java
  4. 106
      epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/cloud/MinioStorageService.java
  5. 2
      epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/cloud/OssFactory.java
  6. 5
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyResultDTO.java
  7. 4
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencySubResultDTO.java
  8. 12
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml
  9. 12
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagCustomerDTO.java
  10. 33
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/TagScopeDTO.java
  11. 56
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerFormDTO.java
  12. 44
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/TagCustomerPageFormDTO.java
  13. 61
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/TagController.java
  14. 9
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagCustomerDao.java
  15. 18
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/TagScopeDao.java
  16. 4
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/TagCustomerEntity.java
  17. 45
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/entity/TagScopeEntity.java
  18. 23
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/TagCustomerService.java
  19. 105
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/TagCustomerServiceImpl.java
  20. 19
      epmet-module/gov-voice/gov-voice-server/src/main/resources/db/migration/V0.0.13__tag_scope.sql
  21. 10
      epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagCustomerDao.xml
  22. 24
      epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagScopeDao.xml
  23. 51
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/CustomerInitFormDTO.java
  24. 36
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java
  25. 5
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java
  26. 69
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java

6
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;

6
epmet-module/epmet-oss/epmet-oss-server/pom.xml

@ -90,6 +90,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
<!--minio-->
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>8.4.2</version>
</dependency>
</dependencies>
<build>

39
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;
}
}

106
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;
}
}

2
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;

5
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;
}

4
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;
}

12
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

12
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.已删除
*/

33
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;
}

56
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<TagScopeDTO> agencyIds;
/**
* 客户ID
*/
private String customerId;
}

44
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;
}

61
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<Boolean>().ok(tagService.initTag(formDto));
}
/**
* pc标签管理-分页查询
* @param formDTO
* @return
*/
@PostMapping("page-list")
public Result<PageData<TagCustomerDTO>> pageList(@LoginUser TokenDto tokenDto,@RequestBody TagCustomerPageFormDTO formDTO){
tokenDto.setCustomerId(formDTO.getCustomerId());
ValidatorUtils.validateEntity(formDTO,TagCustomerPageFormDTO.PageUserInternalGroup.class,TagCustomerPageFormDTO.PageUserShowGroup.class);
return new Result<PageData<TagCustomerDTO>>().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();
}
}

9
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<TagCustomerEntity> {
* @return
*/
List<TagCustomerEntity> selectInitData(@Param("customerIdList") List<String> customerIdList);
/**
* pc标签管理-分页查询
* @param customerId
* @param tagName
* @return
*/
List<TagCustomerDTO> pageList(@Param("customerId") String customerId, @Param("tagName")String tagName);
}

18
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<TagScopeEntity> {
int deleteByTagId(@Param("tagId") String tagId, @Param("customerId") String customerId);
}

4
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;
}

45
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;
/**
* 客户ID0302因烟台需求增加此表
*/
private String customerId;
/**
* 标签ID
*/
private String tagId;
/**
* 应用范围这里只能是社区id
*/
private String agencyId;
/**
* agency_id全路径包含自身
*/
private String orgIdPath;
/**
* 组织名称
*/
private String agencyName;
}

23
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<TagCustomerEntity> {
/**
* 默认分页
* pc标签管理-分页查询
*
* @param params
* @param formDTO
* @return PageData<TagCustomerDTO>
* @author generator
* @date 2020-06-02
*/
PageData<TagCustomerDTO> page(Map<String, Object> params);
PageData<TagCustomerDTO> page(TagCustomerPageFormDTO formDTO);
/**
* 默认查询
@ -65,24 +67,24 @@ public interface TagCustomerService extends BaseService<TagCustomerEntity> {
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<TagCustomerEntity> {
* @author zxc
*/
UpdateTagUseCountsResultDTO checkTagInfo(String tagName,String customerId,String userId);
/**
* 隐藏显示
* @param id
* @param showFlag
*/
void changeShowFlag(String id, Integer showFlag);
}

105
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<TagCustomerDao, TagCustomerEntity> implements TagCustomerService {
@Autowired
private TagScopeDao tagScopeDao;
/**
* pc标签管理-分页查询
* @param formDTO
* @return
*/
@Override
public PageData<TagCustomerDTO> page(Map<String, Object> params) {
IPage<TagCustomerEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, TagCustomerDTO.class);
public PageData<TagCustomerDTO> page(TagCustomerPageFormDTO formDTO) {
PageHelper.startPage(formDTO.getPageNo(),formDTO.getPageSize());
List<TagCustomerDTO> list=baseDao.pageList(formDTO.getCustomerId(),formDTO.getTagName());
PageInfo<TagCustomerDTO> pageInfo = new PageInfo<>(list);
return new PageData<>(list, pageInfo.getTotal());
}
@Override
@ -78,18 +100,68 @@ public class TagCustomerServiceImpl extends BaseServiceImpl<TagCustomerDao, TagC
return ConvertUtils.sourceToTarget(entity, TagCustomerDTO.class);
}
/**
* pc标签管理-新增
* @param dto
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void save(TagCustomerDTO dto) {
public void save(TagCustomerFormDTO dto) {
// 标签名称是否存在
LambdaQueryWrapper<TagCustomerEntity> 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<TagCustomerEntity> 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<TagCustomerDao, TagC
return resultDTO;
}
/**
* 隐藏显示
*
* @param id
* @param showFlag
*/
@Override
public void changeShowFlag(String id, Integer showFlag) {
LambdaUpdateWrapper<TagCustomerEntity> 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);
}
}

19
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='标签应用范围表';

10
epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagCustomerDao.xml

@ -56,4 +56,14 @@
ORDER BY CUSTOMER_ID
</select>
<!-- pc标签管理-分页查询 -->
<select id="pageList" parameterType="map" resultType="com.epmet.dto.TagCustomerDTO">
select tc.*
from tag_customer tc
where tc.del_flag='0'
and tc.CUSTOMER_ID=#{customerId}
<if test='null != tagName and "" != tagName'>
and tc.TAG_NAME like concat('%',#{tagName},'%')
</if>
</select>
</mapper>

24
epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/TagScopeDao.xml

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.TagScopeDao">
<resultMap type="com.epmet.entity.TagScopeEntity" id="tagScopeMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="tagId" column="TAG_ID"/>
<result property="agencyId" column="AGENCY_ID"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<delete id="deleteByTagId" parameterType="map">
delete from tag_scope
where TAG_ID=#{tagId}
and CUSTOMER_ID=#{customerId}
</delete>
</mapper>

51
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;
}
}

36
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

5
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerService.java

@ -166,6 +166,11 @@ public interface CustomerService extends BaseService<CustomerEntity> {
**/
void init(CustomerInitFormDTO formDTO);
/**
* 本地初始化(不走小程序)
*/
void initLocal(CustomerInitFormDTO input);
/**
* desc获取所有客户列表
* @return

69
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<CustomerDao, CustomerEn
}
@Override
public void initLocal(CustomerInitFormDTO input) {
//1.调用epmet-third服务,根据客户Id查询第三方服务中的客户、组织、管理员等信息
//PaUserDTO paUser = ConvertUtils.mapToEntity(map3, PaUserDTO.class);
String customerId = IdWorker.getIdStr();
String agencyId = IdWorker.getIdStr();
//2.校验当前客户是否已初始化,不存在则初始客户信息
CustomerEntity entity = baseDao.selectById(customerId);
if (null != entity) {
throw new RenException(EpmetErrorCode.OPER_CUSTOMER_EXISTS.getCode());
}
CustomerInitFormDTO.PaCustomer paCustomer = input.getPaCustomer();
CustomerInitFormDTO.PaCustomerAgency paCustomerAgency = input.getPaAgency();
CustomerInitFormDTO.PaUser paUser = input.getPaUser();
paCustomerAgency.setId(agencyId);
//2-1.新增客户信息
CustomerEntity customerEntity = new CustomerEntity();
customerEntity.setId(customerId);
customerEntity.setCustomerName(paCustomer.getCustomerName());
customerEntity.setTitle("");
customerEntity.setOrganizationNumber("");
customerEntity.setOrganizationImg("");
customerEntity.setValidityTime(getValidityTime());
customerEntity.setOrganizationLevel(paCustomerAgency.getLevel());
customerEntity.setLogo("");
//新客户默认可以创建三个网格
customerEntity.setGridNumber(NumConstant.THREE);
if (baseDao.insert(customerEntity) < NumConstant.ONE) {
throw new RenException(EpmetErrorCode.OPER_ADD_CUSTOMER_ERROR.getCode());
}
// *.发送初始化客户信息到mq,让监听者完成初始化操作
InitCustomerMQMsg msgContent = new InitCustomerMQMsg();
msgContent.setCustomerId(customerId);
msgContent.setAgency(constructAgencyInfo4CustomerInit(ConvertUtils.sourceToTarget(paCustomerAgency, PaCustomerAgencyDTO.class)));
msgContent.setStaff(constructStaffInfo4CustomerInit(agencyId, ConvertUtils.sourceToTarget(paUser, PaUserDTO.class)));
SystemMsgFormDTO systemMsgFormDTO = new SystemMsgFormDTO();
systemMsgFormDTO.setMessageType(SystemMessageType.INIT_CUSTOMER);
systemMsgFormDTO.setContent(msgContent);
Result sendMsgResult = epmetMessageOpenFeignClient.sendSystemMsgByMQ(systemMsgFormDTO);
if (! sendMsgResult.success()) {
throw new RenException("发送(初始化客户信息)系统消息到message服务失败:{}", sendMsgResult.getInternalMsg());
}
//2021.1.25 sun 新增初始化客户积分规则和评价指标权重 start
//8.客户初始化已有的积分规则
Result<InitPointRuleResultDTO> resultPoint = epmetPointOpenFeignClient.initPointRule(customerId);
if (!resultPoint.success()) {
throw new RenException(resultPoint.getCode(), resultPoint.getInternalMsg());
}
//9.新客户初始化评价指标 权重
InitCustomerIndexForm indexForm = new InitCustomerIndexForm();
indexForm.setCustomerId(customerId);
Result<Boolean> 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);

Loading…
Cancel
Save