diff --git a/epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/form/CustomerInfoQueryFormDTO.java b/epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/form/CustomerInfoQueryFormDTO.java new file mode 100644 index 0000000000..f637cfd191 --- /dev/null +++ b/epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/form/CustomerInfoQueryFormDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * 009、根据客户id查询根客户信息入参DTO + * + * @author yinzuomei@elink-cn.com + * @date 2021/2/2 22:25 + */ +@Data +public class CustomerInfoQueryFormDTO { + + /** + * 客户id + */ + @NotBlank(message = "客户id不能为空") + private String customerId; +} diff --git a/epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/result/CustomerInfoQueryResultDTO.java b/epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/result/CustomerInfoQueryResultDTO.java new file mode 100644 index 0000000000..b091020000 --- /dev/null +++ b/epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/result/CustomerInfoQueryResultDTO.java @@ -0,0 +1,22 @@ +package com.epmet.dto.result; + +import lombok.Data; + +/** + * 009、根据客户id查询根客户信息 返参DTO + * + * @author yinzuomei@elink-cn.com + * @date 2021/2/2 22:26 + */ +@Data +public class CustomerInfoQueryResultDTO { + + /** + * 当前客户id的根级客户id,返回值0代表当前客户是根客户没有上级客户 + */ + private String rootCustomerId; + /** + * 客户id + */ + private String customerId; +} diff --git a/epmet-module/epmet-ext/epmet-ext-server/pom.xml b/epmet-module/epmet-ext/epmet-ext-server/pom.xml index 911e651f55..685a0e6a33 100644 --- a/epmet-module/epmet-ext/epmet-ext-server/pom.xml +++ b/epmet-module/epmet-ext/epmet-ext-server/pom.xml @@ -144,6 +144,12 @@ 5.1.12.RELEASE compile + + com.epmet + oper-crm-client + 2.0.0 + compile + diff --git a/epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/controller/OpenUpController.java b/epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/controller/OpenUpController.java index 162b493bd3..53bbed14b9 100644 --- a/epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/controller/OpenUpController.java +++ b/epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/controller/OpenUpController.java @@ -125,5 +125,16 @@ public class OpenUpController { return new Result().ok(openUpService.organizeTree(formDTO)); } + /** + * @param formDTO + * @author yinzuomei + * @description 009、根据客户id查询根客户信息 + * @Date 2021/2/2 22:29 + **/ + @PostMapping("querycustomerinfo") + public Result queryCustomerInfo(@RequestBody CustomerInfoQueryFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO); + return new Result().ok(openUpService.queryCustomerInfo(formDTO)); + } } diff --git a/epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/service/OpenUpService.java b/epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/service/OpenUpService.java index ceecebc6c5..5239b821b1 100644 --- a/epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/service/OpenUpService.java +++ b/epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/service/OpenUpService.java @@ -46,4 +46,12 @@ public interface OpenUpService { * @author sun **/ OrganizeTreeResultDTO organizeTree(OrganizeTreeFormDTO formDTO); + + /** + * @param formDTO + * @author yinzuomei + * @description 009、根据客户id查询根客户信息 + * @Date 2021/2/2 22:30 + **/ + CustomerInfoQueryResultDTO queryCustomerInfo(CustomerInfoQueryFormDTO formDTO); } diff --git a/epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/service/impl/OpenUpServiceImpl.java b/epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/service/impl/OpenUpServiceImpl.java index 170c3e32c4..86d58131f0 100644 --- a/epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/service/impl/OpenUpServiceImpl.java +++ b/epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/service/impl/OpenUpServiceImpl.java @@ -3,12 +3,14 @@ package com.epmet.service.impl; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.ModuleConstant; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; +import com.epmet.feign.OperCrmOpenFeignClient; import com.epmet.service.OpenUpService; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -29,6 +31,8 @@ public class OpenUpServiceImpl implements OpenUpService { private EpmetUserOpenFeignClient epmetUserOpenFeignClient; @Autowired private GovOrgOpenFeignClient govOrgOpenFeignClient; + @Autowired + private OperCrmOpenFeignClient operCrmOpenFeignClient; /** * @Description 网格工作人员 被禁用的、未激活的不显示 @@ -147,4 +151,20 @@ public class OpenUpServiceImpl implements OpenUpService { return result.getData(); } + /** + * @param formDTO + * @author yinzuomei + * @description 009、根据客户id查询根客户信息 + * @Date 2021/2/2 22:30 + **/ + @Override + public CustomerInfoQueryResultDTO queryCustomerInfo(CustomerInfoQueryFormDTO formDTO) { + //调用oper_crm查询根级客户,如果根级客户是外部客户,则需要调用commonservice获取名称 + Result crmResult = operCrmOpenFeignClient.queryCustomerInfoByCustomerId(formDTO.getCustomerId()); + if (!crmResult.success() && null == crmResult.getData()) { + throw new RenException("调用oper_crm查询客户信息异常"+crmResult.getInternalMsg()); + } + return ConvertUtils.sourceToTarget(crmResult.getData(), CustomerInfoQueryResultDTO.class); + } + } diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerRelationDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerRelationDTO.java new file mode 100644 index 0000000000..beef2169df --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/CustomerRelationDTO.java @@ -0,0 +1,110 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 客户关系表(01.14 add) + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-02-03 + */ +@Data +public class CustomerRelationDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户id + */ + private String customerId; + + /** + * 父级客户id;如果是顶级客户,此列=0 + */ + private String parentCustomerId; + + /** + * 当前客户类型取值: external:外部客户,internal:内部客户 + */ + private String customerType; + + /** + * 父级客户类型取值: external:外部客户,internal:内部客户;如果是顶级客户,此列=0 + */ + private String parentCustomerType; + + /** + * open,closed是否启用 + */ + private String status; + + /** + * 当前客户级别(社区级:community, +乡(镇、街道)级:street, +区县级: district, +市级: city +省级:province) + */ + private String level; + + /** + * 当前客户的地区编码,实际就是根组织的area_code + */ + private String areaCode; + + /** + * 删除标识0未删除1已删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerRelationInfoResultDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerRelationInfoResultDTO.java new file mode 100644 index 0000000000..99fb265f8a --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerRelationInfoResultDTO.java @@ -0,0 +1,23 @@ +package com.epmet.dto.result; + +import lombok.Data; + +/** + * 009、根据客户id查询根客户信息 返参DTO + * + * @author yinzuomei@elink-cn.com + * @date 2021/2/3 11:15 + */ +@Data +public class CustomerRelationInfoResultDTO { + /** + * 客户id + */ + private String customerId; + + /** + * 当前客户id的根级客户id,返回值0代表当前客户是根客户没有上级客户 + */ + private String rootCustomerId; + +} diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java index 496dcd636a..6725a257a1 100644 --- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java @@ -9,9 +9,12 @@ import com.epmet.dto.form.CustomerAppSecretFormDTO; import com.epmet.dto.form.CustomerManagerFormDTO; import com.epmet.dto.form.GridCountFormDTO; import com.epmet.dto.result.CrmParameterResultDTO; +import com.epmet.dto.result.CustomerRelationInfoResultDTO; import com.epmet.dto.result.GridCountResultDTO; import com.epmet.feign.fallback.OperCrmOpenFeignClientFallback; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -24,7 +27,7 @@ import java.util.List; * @date 2020/6/4 13:25 */ @FeignClient(name = ServiceConstant.OPER_CRM_SERVER, fallback = OperCrmOpenFeignClientFallback.class) -//@FeignClient(name = ServiceConstant.OPER_CRM_SERVER, fallback = OperCrmOpenFeignClientFallback.class, url = "localhost:8090") +// @FeignClient(name = ServiceConstant.OPER_CRM_SERVER, fallback = OperCrmOpenFeignClientFallback.class, url = "localhost:8090") public interface OperCrmOpenFeignClient { /** * 获取客户信息 @@ -94,4 +97,13 @@ public interface OperCrmOpenFeignClient { */ @PostMapping("/oper/crm/parameter/parameterupdate") Result updateParamInfo(@RequestBody List formDTOS); + + /** + * @param customerId + * @author yinzuomei + * @description 009、根据客户id查询根客户信息 + * @Date 2021/2/3 12:44 + **/ + @GetMapping("/oper/crm/customer/querycustomerinfobycustomerid/{customerId}") + Result queryCustomerInfoByCustomerId(@PathVariable("customerId") String customerId); } diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java index d18f98065a..fc0fd76fb8 100644 --- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java @@ -10,6 +10,7 @@ import com.epmet.dto.form.CustomerAppSecretFormDTO; import com.epmet.dto.form.CustomerManagerFormDTO; import com.epmet.dto.form.GridCountFormDTO; import com.epmet.dto.result.CrmParameterResultDTO; +import com.epmet.dto.result.CustomerRelationInfoResultDTO; import com.epmet.dto.result.GridCountResultDTO; import com.epmet.feign.OperCrmOpenFeignClient; import org.springframework.stereotype.Component; @@ -69,4 +70,15 @@ public class OperCrmOpenFeignClientFallback implements OperCrmOpenFeignClient { public Result updateParamInfo(List formDTOS) { return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "updateParamInfo", formDTOS); } + + /** + * @param customerId + * @author yinzuomei + * @description 009、根据客户id查询根客户信息 + * @Date 2021/2/3 12:44 + **/ + @Override + public Result queryCustomerInfoByCustomerId(String customerId) { + return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "queryCustomerInfoByCustomerId", customerId); + } } 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 e4ae80fc6e..0ae86f3ada 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 @@ -31,13 +31,11 @@ import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.CustomerDTO; import com.epmet.dto.form.*; -import com.epmet.dto.result.CustomerDetailResultDTO; -import com.epmet.dto.result.CustomerInfoResultDTO; -import com.epmet.dto.result.GridCountResultDTO; -import com.epmet.dto.result.ValidCustomerResultDTO; +import com.epmet.dto.result.*; import com.epmet.excel.CustomerExcel; import com.epmet.feign.GovOrgFeignClient; import com.epmet.service.CustomerService; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -330,4 +328,18 @@ public class CustomerController { return new Result(); } + /** + * @param customerId + * @author yinzuomei + * @description 009、根据客户id查询根客户信息 + * @Date 2021/2/3 12:52 + **/ + @GetMapping("querycustomerinfobycustomerid/{customerId}") + public Result queryCustomerInfoByCustomerId(@PathVariable("customerId") String customerId){ + if(StringUtils.isNotBlank(customerId)){ + CustomerRelationInfoResultDTO resultDTO=customerService.queryCustomerInfoByCustomerId(customerId); + return new Result().ok(resultDTO); + } + return new Result<>(); + } } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerRelationDao.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerRelationDao.java new file mode 100644 index 0000000000..3b30a4cbb3 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerRelationDao.java @@ -0,0 +1,35 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.CustomerRelationDTO; +import com.epmet.entity.CustomerRelationEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 客户关系表(01.14 add) + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-02-03 + */ +@Mapper +public interface CustomerRelationDao extends BaseDao { + + CustomerRelationDTO selectByCustomerId(String customerId); +} \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerRelationEntity.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerRelationEntity.java new file mode 100644 index 0000000000..4843ba4506 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerRelationEntity.java @@ -0,0 +1,77 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 客户关系表(01.14 add) + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-02-03 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("customer_relation") +public class CustomerRelationEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + private String customerId; + + /** + * 父级客户id;如果是顶级客户,此列=0 + */ + private String parentCustomerId; + + /** + * 当前客户类型取值: external:外部客户,internal:内部客户 + */ + private String customerType; + + /** + * 父级客户类型取值: external:外部客户,internal:内部客户;如果是顶级客户,此列=0 + */ + private String parentCustomerType; + + /** + * open,closed是否启用 + */ + private String status; + + /** + * 当前客户级别(社区级:community, +乡(镇、街道)级:street, +区县级: district, +市级: city +省级:province) + */ + private String level; + + /** + * 当前客户的地区编码,实际就是根组织的area_code + */ + private String areaCode; + +} diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerRelationService.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerRelationService.java new file mode 100644 index 0000000000..29f9118b51 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerRelationService.java @@ -0,0 +1,116 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.CustomerRelationDTO; +import com.epmet.entity.CustomerRelationEntity; + +import java.util.List; +import java.util.Map; + +/** + * 客户关系表(01.14 add) + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-02-03 + */ +public interface CustomerRelationService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2021-02-03 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2021-02-03 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return CustomerRelationDTO + * @author generator + * @date 2021-02-03 + */ + CustomerRelationDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2021-02-03 + */ + void save(CustomerRelationDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2021-02-03 + */ + void update(CustomerRelationDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2021-02-03 + */ + void delete(String[] ids); + + /** + * 根据客户id,查询客户关系表 + * + * @param customerId + * @return void + * @author generator + * @date 2021-02-03 + */ + CustomerRelationDTO getByCustomerId(String customerId); + + /** + * 获取某个客户的根客户id + * + * @param customerId + * @return void + * @author generator + * @date 2021-02-03 + */ + String getRootCustomerId(String customerId); + +} \ No newline at end of file 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 c9745552ed..82e872e511 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 @@ -22,10 +22,7 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerDTO; import com.epmet.dto.form.*; -import com.epmet.dto.result.CustomerDetailResultDTO; -import com.epmet.dto.result.CustomerInfoResultDTO; -import com.epmet.dto.result.GridCountResultDTO; -import com.epmet.dto.result.ValidCustomerResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.CustomerEntity; import java.text.ParseException; @@ -222,4 +219,11 @@ public interface CustomerService extends BaseService { */ void updateCustomerParameter(UpdateCustomerParameterFormDTO formDTO) throws ParseException; + /** + * @param customerId + * @author yinzuomei + * @description 009、根据客户id查询根客户信息 返参DTO + * @Date 2021/2/3 12:52 + **/ + CustomerRelationInfoResultDTO queryCustomerInfoByCustomerId(String customerId); } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerRelationServiceImpl.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerRelationServiceImpl.java new file mode 100644 index 0000000000..79bf41cff9 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerRelationServiceImpl.java @@ -0,0 +1,140 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +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.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.CustomerRelationDao; +import com.epmet.dto.CustomerRelationDTO; +import com.epmet.entity.CustomerRelationEntity; +import com.epmet.service.CustomerRelationService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 客户关系表(01.14 add) + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-02-03 + */ +@Slf4j +@Service +public class CustomerRelationServiceImpl extends BaseServiceImpl implements CustomerRelationService { + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, CustomerRelationDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, CustomerRelationDTO.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 CustomerRelationDTO get(String id) { + CustomerRelationEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, CustomerRelationDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(CustomerRelationDTO dto) { + CustomerRelationEntity entity = ConvertUtils.sourceToTarget(dto, CustomerRelationEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(CustomerRelationDTO dto) { + CustomerRelationEntity entity = ConvertUtils.sourceToTarget(dto, CustomerRelationEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + /** + * 根据客户id,查询客户关系表 + * + * @param customerId + * @return void + * @author generator + * @date 2021-02-03 + */ + @Override + public CustomerRelationDTO getByCustomerId(String customerId) { + return baseDao.selectByCustomerId(customerId); + } + + /** + * 获取某个客户的根客户id + * + * @param customerId + * @return void + * @author generator + * @date 2021-02-03 + */ + @Override + public String getRootCustomerId(String customerId) { + CustomerRelationDTO customerRelationDTO=this.getByCustomerId(customerId); + if (null == customerRelationDTO) { + log.info(String.format("根据客户id:%s查找customer_relation为空",customerId)); + return StrConstant.EPMETY_STR; + } + log.info(JSON.toJSONString(customerRelationDTO,true)); + if (!NumConstant.ZERO_STR.equals(customerRelationDTO.getParentCustomerId())) { + log.info("parentCustomerId is not equals 0 so continue"); + return getRootCustomerId(customerRelationDTO.getParentCustomerId()); + } + return customerRelationDTO.getCustomerId(); + } + +} \ No newline at end of file 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 9080d1573f..9d4bc93994 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 @@ -42,6 +42,7 @@ import com.epmet.dto.result.*; import com.epmet.entity.CustomerEntity; import com.epmet.feign.*; import com.epmet.redis.CustomerRedis; +import com.epmet.service.CustomerRelationService; import com.epmet.service.CustomerService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -84,6 +85,8 @@ public class CustomerServiceImpl extends BaseServiceImpl page(Map params) { @@ -738,4 +741,24 @@ public class CustomerServiceImpl extends BaseServiceImpl - + diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerRelationDao.xml b/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerRelationDao.xml new file mode 100644 index 0000000000..e3af5415b1 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerRelationDao.xml @@ -0,0 +1,16 @@ + + + + + + + + \ No newline at end of file