Browse Source

运营端-修改客户信息1

dev
yinzuomei 4 years ago
parent
commit
26502e0b51
  1. 1
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/ScreenProjectServiceImpl.java
  2. 7
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerAgencyDTO.java
  3. 47
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CustomerAreaCodeFormDTO.java
  4. 13
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java
  5. 11
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java
  6. 15
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java
  7. 7
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java
  8. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java
  9. 149
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java
  10. 2
      epmet-module/gov-org/gov-org-server/src/main/resources/logback-spring.xml
  11. 31
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/UpdateCustomerFormDTO.java
  12. 13
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerListResultDTO.java
  13. 8
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java
  14. 7
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java
  15. 37
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java

1
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/ScreenProjectServiceImpl.java

@ -42,7 +42,6 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import sun.jvm.hotspot.memory.ContiguousSpace;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;

7
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/CustomerAgencyDTO.java

@ -172,4 +172,11 @@ public class CustomerAgencyDTO implements Serializable {
* 联系电话 * 联系电话
*/ */
private String mobile; private String mobile;
//内部接口使用
/**
* open:当前客户新增组织需要选择areaCodeclosed: 无需选择区域编码
*/
private String areaCodeSwitch;
} }

47
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CustomerAreaCodeFormDTO.java

@ -0,0 +1,47 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 运营端-客户管理修改客户信息调用gov-org服务修改组织区划开关修改根组织areaCode入参
*/
@Data
public class CustomerAreaCodeFormDTO implements Serializable {
public interface ShowGroup extends CustomerClientShowGroup {}
public interface AddUserInternalGroup {
}
public interface OpenAreaCodeSwitchGroup extends CustomerClientShowGroup {}
/**
* 客户ID
*/
@NotBlank(message = "customerId不能为空",groups = AddUserInternalGroup.class)
private String customerId;
/**
* open:当前客户新增组织需要选择areaCodeclosed: 无需选择区域编码
*/
@NotBlank(message = "组织区划开关不能为空,开启:open;关闭:closed",groups = ShowGroup.class)
private String areaCodeSwitch;
@NotBlank(message = "根组织不能为空",groups = AddUserInternalGroup.class)
private String rootAgencyId;
@NotBlank(message = "rootAgencyAreaCode不能为空",groups = OpenAreaCodeSwitchGroup.class)
private String rootAgencyAreaCode;
@NotBlank(message = "rootAgencyParentCode不能为空",groups = OpenAreaCodeSwitchGroup.class)
private String rootAgencyParentCode;
/**
* token获取userId
*/
@NotBlank(message = "当前操作用户id不能为空",groups = AddUserInternalGroup.class)
private String userId;
}

13
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java

@ -20,8 +20,8 @@ import java.util.Set;
* @author yinzuomei@elink-cn.com * @author yinzuomei@elink-cn.com
* @date 2020/6/4 13:37 * @date 2020/6/4 13:37
*/ */
// @FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallbackFactory = GovOrgOpenFeignClientFallbackFactory.class, url = "localhost:8092") @FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallbackFactory = GovOrgOpenFeignClientFallbackFactory.class, url = "localhost:8092")
@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallbackFactory = GovOrgOpenFeignClientFallbackFactory.class) // @FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallbackFactory = GovOrgOpenFeignClientFallbackFactory.class)
public interface GovOrgOpenFeignClient { public interface GovOrgOpenFeignClient {
/** /**
@ -558,4 +558,13 @@ public interface GovOrgOpenFeignClient {
*/ */
@GetMapping("/gov/org/icneighborhood/{id}") @GetMapping("/gov/org/icneighborhood/{id}")
Result<IcNeighborHoodDTO> getIcNeighbordhoodById(@PathVariable("id") String id); Result<IcNeighborHoodDTO> getIcNeighbordhoodById(@PathVariable("id") String id);
/**
* 运营端-客户管理修改客户信息调用gov-org服务修改组织区划开关修改根组织areaCode入参
* @param formDTO
* @return
*/
@PostMapping("/gov/org/customeragency/configcustomerareacode")
Result configCustomerAreaCode(@RequestBody CustomerAreaCodeFormDTO formDTO);
} }

11
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java

@ -353,4 +353,15 @@ public class GovOrgOpenFeignClientFallback implements GovOrgOpenFeignClient {
public Result<IcNeighborHoodDTO> getIcNeighbordhoodById(String id) { public Result<IcNeighborHoodDTO> getIcNeighbordhoodById(String id) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getIcNeighbordhoodById", id); return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getIcNeighbordhoodById", id);
} }
/**
* 运营端-客户管理修改客户信息调用gov-org服务修改组织区划开关修改根组织areaCode入参
*
* @param areaCodeFormDTO
* @return
*/
@Override
public Result configCustomerAreaCode(CustomerAreaCodeFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "configCustomerAreaCode", formDTO);
}
} }

15
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java

@ -28,6 +28,7 @@ import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.constant.CustomerAgencyConstant;
import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.form.*; import com.epmet.dto.form.*;
import com.epmet.dto.result.*; import com.epmet.dto.result.*;
@ -380,4 +381,18 @@ public class CustomerAgencyController {
return new Result<OrgMobileResultDTO>().ok(customerAgencyService.orgMobile(formDTO.getGridId())); return new Result<OrgMobileResultDTO>().ok(customerAgencyService.orgMobile(formDTO.getGridId()));
} }
/**
* 运营端-客户管理修改客户信息调用gov-org服务修改组织区划开关修改根组织areaCode入参
* @param formDTO
* @return
*/
@PostMapping("configcustomerareacode")
Result configCustomerAreaCode(@RequestBody CustomerAreaCodeFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, CustomerAreaCodeFormDTO.AddUserInternalGroup.class, CustomerAreaCodeFormDTO.ShowGroup.class);
if (CustomerAgencyConstant.AREA_CODE_SWITCH_OPEN.equals(formDTO.getAreaCodeSwitch())) {
ValidatorUtils.validateEntity(formDTO, CustomerAreaCodeFormDTO.OpenAreaCodeSwitchGroup.class);
}
customerAgencyService.configCustomerAreaCode(formDTO);
return new Result();
}
} }

7
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java

@ -269,4 +269,11 @@ public interface CustomerAgencyService extends BaseService<CustomerAgencyEntity>
* @author sun * @author sun
**/ **/
OrgMobileResultDTO orgMobile(String gridId); OrgMobileResultDTO orgMobile(String gridId);
/**
* 运营端-客户管理修改客户信息调用gov-org服务修改组织区划开关修改根组织areaCode入参
* @param formDTO
* @return
*/
void configCustomerAreaCode(CustomerAreaCodeFormDTO formDTO);
} }

6
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java

@ -498,7 +498,11 @@ public class AgencyServiceImpl implements AgencyService {
@Override @Override
public CustomerAgencyDTO getCustomerRootAgency(String customerId) { public CustomerAgencyDTO getCustomerRootAgency(String customerId) {
return customerAgencyDao.getCustomerRootAgency(customerId); CustomerAgencyDTO root=customerAgencyDao.getCustomerRootAgency(customerId);
if (null != root) {
root.setAreaCodeSwitch(customerOrgParameterService.getAreaCodeSwitch(customerId));
}
return root;
} }
@Override @Override

149
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java

@ -18,11 +18,14 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant; 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.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisKeys;
@ -36,13 +39,17 @@ import com.epmet.dto.*;
import com.epmet.dto.form.*; import com.epmet.dto.form.*;
import com.epmet.dto.result.*; import com.epmet.dto.result.*;
import com.epmet.entity.CustomerAgencyEntity; import com.epmet.entity.CustomerAgencyEntity;
import com.epmet.entity.CustomerDepartmentEntity;
import com.epmet.entity.CustomerGridEntity; import com.epmet.entity.CustomerGridEntity;
import com.epmet.entity.CustomerOrgParameterEntity;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.feign.EpmetUserFeignClient; import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.OperCrmFeignClient; import com.epmet.feign.OperCrmFeignClient;
import com.epmet.redis.CustomerAgencyRedis; import com.epmet.redis.CustomerAgencyRedis;
import com.epmet.service.CustomerAgencyService; import com.epmet.service.CustomerAgencyService;
import com.epmet.util.ModuleConstant; import com.epmet.util.ModuleConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -62,6 +69,7 @@ import java.util.stream.Collectors;
* @author generator generator@elink-cn.com * @author generator generator@elink-cn.com
* @since v1.0.0 2020-04-20 * @since v1.0.0 2020-04-20
*/ */
@Slf4j
@Service @Service
public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao, CustomerAgencyEntity> implements CustomerAgencyService { public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao, CustomerAgencyEntity> implements CustomerAgencyService {
@ -86,6 +94,11 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
@Autowired
private CustomerOrgParameterDao customerOrgParameterDao;
@Autowired
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
@Override @Override
public PageData<CustomerAgencyDTO> page(Map<String, Object> params) { public PageData<CustomerAgencyDTO> page(Map<String, Object> params) {
@ -1220,4 +1233,140 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao
return baseDao.getAgencyMobile(gridId); return baseDao.getAgencyMobile(gridId);
} }
/**
* 运营端-客户管理修改客户信息调用gov-org服务修改组织区划开关修改根组织areaCode入参
*
* @param formDTO
* @return
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void configCustomerAreaCode(CustomerAreaCodeFormDTO formDTO) {
//1、设置开关
CustomerOrgParameterEntity switchEntity = customerOrgParameterDao.selectByCustomerId(formDTO.getCustomerId(), CustomerAgencyConstant.AREA_CODE_SWITCH);
if (null != switchEntity) {
switchEntity.setParameterValue(formDTO.getAreaCodeSwitch());
customerOrgParameterDao.updateById(switchEntity);
} else {
CustomerOrgParameterEntity insert=new CustomerOrgParameterEntity();
insert.setCustomerId(formDTO.getCustomerId());
insert.setParameterKey(CustomerAgencyConstant.AREA_CODE_SWITCH);
insert.setParameterValue(formDTO.getAreaCodeSwitch());
insert.setParameterName("是否开启区域编码");
insert.setDescription("open:当前客户新增组织需要选择areaCode;closed: 无需选择区域编码");
customerOrgParameterDao.insert(insert);
}
if(CustomerAgencyConstant.AREA_CODE_SWITCH_OPEN.equals(formDTO.getAreaCodeSwitch())){
//开关开启,并且修改了组织区划才会调用
CustomerAgencyEntity root=baseDao.selectById(formDTO.getRootAgencyId());
String originalAreaCode=root.getAreaCode();
//areaCode做了修改
if(!formDTO.getRootAgencyAreaCode().equals(originalAreaCode)){
log.warn("组织区划开关打开, 并且当前传入的areaCode与之前的不一致,所以要进行update操作");
String newAreaCode=getAgencyNewAreaCode(root.getId(),root.getOrganizationName(),root.getLevel(),formDTO.getRootAgencyAreaCode(),formDTO.getRootAgencyParentCode());
//1、更新根组织的area_code、
root.setAreaCode(newAreaCode);
root.setParentAreaCode(formDTO.getRootAgencyParentCode());
baseDao.updateById(root);
//2、直属下级的parent_areaCode赋值、areaCode(置空)
LambdaUpdateWrapper<CustomerAgencyEntity> updateAgencyWrapper = new LambdaUpdateWrapper<>();
updateAgencyWrapper.eq(CustomerAgencyEntity::getPid,root.getId())
.set(CustomerAgencyEntity::getParentAreaCode,newAreaCode)
.set(CustomerAgencyEntity::getAreaCode, StrConstant.EPMETY_STR)
.set(CustomerAgencyEntity::getUpdatedBy,formDTO.getUserId())
.set(CustomerAgencyEntity::getUpdatedTime,new Date());
Integer rows = baseDao.update(null, updateAgencyWrapper);
log.info(String.format("更新了%s个下级组织的parent_area_code",rows));
// 3、直属网格
LambdaUpdateWrapper<CustomerGridEntity> updateGridWrapper = new LambdaUpdateWrapper<>();
updateGridWrapper.eq(CustomerGridEntity::getPid,root.getId())
.set(CustomerGridEntity::getAreaCode, newAreaCode)
.set(CustomerGridEntity::getUpdatedBy,formDTO.getUserId())
.set(CustomerGridEntity::getUpdatedTime,new Date());
int subGridRows=customerGridDao.update(null,updateGridWrapper);
log.info(String.format("更新了%s个直属网格的area_code",subGridRows));
// 4、直属部门
LambdaUpdateWrapper<CustomerDepartmentEntity> updateDeptWrapper = new LambdaUpdateWrapper<>();
updateDeptWrapper.eq(CustomerDepartmentEntity::getAgencyId,root.getId())
.set(CustomerDepartmentEntity::getAreaCode, newAreaCode)
.set(CustomerDepartmentEntity::getUpdatedBy,formDTO.getUserId())
.set(CustomerDepartmentEntity::getUpdatedTime,new Date());
int gridRows=customerDepartmentDao.update(null,updateDeptWrapper);
log.info(String.format("更新了%s个直属部门的area_code",gridRows));
//5、非直属下级组织,统一置为空
LambdaUpdateWrapper<CustomerAgencyEntity> agencyWrapper = new LambdaUpdateWrapper<>();
agencyWrapper.ne(CustomerAgencyEntity::getPid,root.getId())
.like(CustomerAgencyEntity::getPids,root.getId())
.set(CustomerAgencyEntity::getParentAreaCode,StrConstant.EPMETY_STR)
.set(CustomerAgencyEntity::getAreaCode, StrConstant.EPMETY_STR)
.set(CustomerAgencyEntity::getUpdatedBy,formDTO.getUserId())
.set(CustomerAgencyEntity::getUpdatedTime,new Date());
baseDao.update(null, agencyWrapper);
//6、非直属网格
LambdaUpdateWrapper<CustomerGridEntity> gridWrapper = new LambdaUpdateWrapper<>();
gridWrapper.ne(CustomerGridEntity::getPid,root.getId())
.like(CustomerGridEntity::getPids,root.getId())
.set(CustomerGridEntity::getAreaCode, StrConstant.EPMETY_STR)
.set(CustomerGridEntity::getUpdatedBy,formDTO.getUserId())
.set(CustomerGridEntity::getUpdatedTime,new Date());
customerGridDao.update(null,gridWrapper);
//7、非直属部门的
LambdaUpdateWrapper<CustomerDepartmentEntity> deptWrapper = new LambdaUpdateWrapper<>();
deptWrapper.ne(CustomerDepartmentEntity::getAgencyId,root.getId())
.like(CustomerDepartmentEntity::getAreaCode,originalAreaCode)
.set(CustomerDepartmentEntity::getAreaCode, StrConstant.EPMETY_STR)
.set(CustomerDepartmentEntity::getUpdatedBy,formDTO.getUserId())
.set(CustomerDepartmentEntity::getUpdatedTime,new Date());
customerDepartmentDao.update(null,deptWrapper);
}
}
}
/**
*
* @param agencyId
* @param agencyName
* @param level 社区级community街道:street,区县级: district,市级: city省级:province
* @param areaCode
* @param parentArenCode
* @return 返回组织区划编码
*/
private String getAgencyNewAreaCode(String agencyId, String agencyName, String level,String areaCode, String parentArenCode) {
String newAreaCode="";
if (!"other".equals(areaCode)) {
//校验除了当前组织外,areaCode是否被使用过
List<String> agencyIds = baseDao.selectAgencyIdsByAreaCode(areaCode, agencyId);
if (CollectionUtils.isNotEmpty(agencyIds)) {
//已经被占用,提示
throw new RenException(EpmetErrorCode.AREA_CODE_ALREADY_EXISTS.getCode(), EpmetErrorCode.AREA_CODE_ALREADY_EXISTS.getMsg());
}
newAreaCode=areaCode;
} else {
//如果选择的是other,需要自定义一个编码
AddAreaCodeFormDTO addAreaCodeFormDTO = new AddAreaCodeFormDTO();
addAreaCodeFormDTO.setCurrentAreaLevel(level);
addAreaCodeFormDTO.setParentAreaCode(parentArenCode);
addAreaCodeFormDTO.setName(agencyName);
Result<String> addAreaCodeResult = epmetCommonServiceOpenFeignClient.addAreaCode(addAreaCodeFormDTO);
if (!addAreaCodeResult.success() || StringUtils.isBlank(addAreaCodeResult.getData())) {
if (addAreaCodeResult.getCode() > 8000) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "自定义area_code异常" + addAreaCodeResult.getInternalMsg(), addAreaCodeResult.getMsg());
} else {
throw new RenException("自定义area_code异常" + addAreaCodeResult.getInternalMsg());
}
}
newAreaCode=addAreaCodeResult.getData();
}
return newAreaCode;
}
} }

2
epmet-module/gov-org/gov-org-server/src/main/resources/logback-spring.xml

@ -139,7 +139,7 @@
</appender> </appender>
<!-- 开发、测试环境 --> <!-- 开发、测试环境 -->
<springProfile name="dev,test"> <springProfile name="dev,test,local">
<logger name="org.springframework.web" level="INFO"/> <logger name="org.springframework.web" level="INFO"/>
<logger name="org.springboot.sample" level="INFO"/> <logger name="org.springboot.sample" level="INFO"/>
<logger name="com.epmet.dao" level="INFO"/> <logger name="com.epmet.dao" level="INFO"/>

31
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/UpdateCustomerFormDTO.java

@ -1,8 +1,11 @@
package com.epmet.dto.form; package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable; import java.io.Serializable;
/** /**
@ -15,17 +18,26 @@ import java.io.Serializable;
public class UpdateCustomerFormDTO implements Serializable { public class UpdateCustomerFormDTO implements Serializable {
private static final long serialVersionUID = 1296290251616658023L; private static final long serialVersionUID = 1296290251616658023L;
public interface ShowGroup extends CustomerClientShowGroup {}
public interface AddUserInternalGroup {
}
public interface OpenAreaCodeSwitchGroup extends CustomerClientShowGroup {}
/** /**
* 客户ID * 客户ID
*/ */
@NotBlank(message = "customerId不能为空",groups = AddUserInternalGroup.class)
private String customerId; private String customerId;
/** /**
* 客户名 * 客户名
*/ */
@NotBlank(message = "客户名称不能为空",groups = ShowGroup.class)
@Length(max = 20, message = "客户名称最多输入20个字", groups = ShowGroup.class)
private String customerName; private String customerName;
/** /**
* logo * logo
*/ */
@NotBlank(message = "logo不能为空",groups = ShowGroup.class)
private String logo; private String logo;
// /** // /**
// * 根管理员姓名 // * 根管理员姓名
@ -35,4 +47,23 @@ public class UpdateCustomerFormDTO implements Serializable {
// * 根管理员电话 // * 根管理员电话
// */ // */
// private String rootManagePhone; // private String rootManagePhone;
//修改客户信息,可设置组织区划开关,修改根组织组织区划,故新增以下参数
@NotBlank(message = "tokenDto获取userId不能为空",groups = AddUserInternalGroup.class)
private String userId;
@NotBlank(message = "根组织不能为空",groups = AddUserInternalGroup.class)
private String rootAgencyId;
/**
* open:当前客户新增组织需要选择areaCodeclosed: 无需选择区域编码
*/
@NotBlank(message = "组织区划开关不能为空,开启:open;关闭:closed",groups = ShowGroup.class)
private String areaCodeSwitch;
@NotBlank(message = "rootAgencyAreaCode不能为空",groups = OpenAreaCodeSwitchGroup.class)
private String rootAgencyAreaCode;
@NotBlank(message = "rootAgencyParentCode不能为空",groups = OpenAreaCodeSwitchGroup.class)
private String rootAgencyParentCode;
} }

13
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/CustomerListResultDTO.java

@ -63,4 +63,17 @@ public class CustomerListResultDTO implements Serializable {
* 区县 * 区县
*/ */
private String county; private String county;
/**
* 需求修改客户信息时可以社区组织区划开关可修改根组织的areaCode
* 故新增以下参数
*/
private String rootAgencyId;
private String rootAgencyAreaCode;
private String rootAgencyParentCode;
private String rootAgencyLevel;
/**
* open:当前客户新增组织需要选择areaCodeclosed: 无需选择区域编码
*/
private String areaCodeSwitch;
} }

8
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java

@ -314,7 +314,13 @@ public class CustomerController {
* @return com.epmet.commons.tools.utils.Result * @return com.epmet.commons.tools.utils.Result
*/ */
@PostMapping("updatecustomer") @PostMapping("updatecustomer")
public Result updateCustomer(@RequestBody UpdateCustomerFormDTO formDTO) { public Result updateCustomer(@LoginUser TokenDto tokenDto,@RequestBody UpdateCustomerFormDTO formDTO) {
formDTO.setUserId(tokenDto.getUserId());
ValidatorUtils.validateEntity(formDTO,UpdateCustomerFormDTO.ShowGroup.class,UpdateCustomerFormDTO.AddUserInternalGroup.class);
//如果开启了组织区划开关,根组织的组织区划变态男
if("open".equals(formDTO.getAreaCodeSwitch())){
ValidatorUtils.validateEntity(formDTO,UpdateCustomerFormDTO.OpenAreaCodeSwitchGroup.class);
}
customerService.updateCustomer(formDTO); customerService.updateCustomer(formDTO);
return new Result(); return new Result();
} }

7
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java

@ -1,10 +1,6 @@
package com.epmet.feign; package com.epmet.feign;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.annotation.RequirePermission;
import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.enums.RequirePermissionEnum;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.form.AddAgencyFormDTO; import com.epmet.dto.form.AddAgencyFormDTO;
@ -12,7 +8,6 @@ import com.epmet.dto.form.AddRootAgencyFormDTO;
import com.epmet.dto.form.StaffSubmitFromDTO; import com.epmet.dto.form.StaffSubmitFromDTO;
import com.epmet.dto.result.AddAgencyResultDTO; import com.epmet.dto.result.AddAgencyResultDTO;
import com.epmet.feign.fallback.GovOrgFeignClientFallBack; import com.epmet.feign.fallback.GovOrgFeignClientFallBack;
import oracle.jdbc.proxy.annotation.Post;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -22,7 +17,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
//, url = "localhost:8092" //, url = "localhost:8092"
@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeignClientFallBack.class) @FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeignClientFallBack.class, url = "localhost:8092")
public interface GovOrgFeignClient { public interface GovOrgFeignClient {
/** /**

37
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java

@ -19,6 +19,7 @@ package com.epmet.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; 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.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
@ -26,16 +27,13 @@ import com.epmet.commons.rocketmq.messages.InitCustomerMQMsg;
import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.ModuleConstant; import com.epmet.constant.*;
import com.epmet.constant.RoleKeyConstants;
import com.epmet.constant.ThirdConstant;
import com.epmet.constant.SystemMessageType;
import com.epmet.constant.UserWorkType;
import com.epmet.dao.CustomerDao; import com.epmet.dao.CustomerDao;
import com.epmet.dto.*; import com.epmet.dto.*;
import com.epmet.dto.form.*; import com.epmet.dto.form.*;
@ -84,8 +82,6 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerDao, CustomerEn
@Autowired @Autowired
private CustomerDao customerDao; private CustomerDao customerDao;
@Autowired @Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Autowired
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient;
@Autowired @Autowired
private EpmetPointOpenFeignClient epmetPointOpenFeignClient; private EpmetPointOpenFeignClient epmetPointOpenFeignClient;
@ -661,6 +657,12 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerDao, CustomerEn
// 管理员 // 管理员
if (agency != null) { if (agency != null) {
dto.setRootAgencyId(agency.getId());
dto.setRootAgencyAreaCode(agency.getAreaCode());
dto.setRootAgencyParentCode(agency.getParentAreaCode());
dto.setRootAgencyLevel(agency.getLevel());
dto.setAreaCodeSwitch(agency.getAreaCodeSwitch());
StaffRoleFormDTO staffsInRoleForm = new StaffRoleFormDTO(); StaffRoleFormDTO staffsInRoleForm = new StaffRoleFormDTO();
staffsInRoleForm.setOrgId(agency.getId()); staffsInRoleForm.setOrgId(agency.getId());
staffsInRoleForm.setRoleKey(RoleKeyConstants.ROLE_KEY_ROOT_MANAGER); staffsInRoleForm.setRoleKey(RoleKeyConstants.ROLE_KEY_ROOT_MANAGER);
@ -688,12 +690,29 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerDao, CustomerEn
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void updateCustomer(UpdateCustomerFormDTO formDTO) { public void updateCustomer(UpdateCustomerFormDTO formDTO) {
//客户名称校验是否唯一
LambdaQueryWrapper<CustomerEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CustomerEntity::getCustomerName, formDTO.getCustomerName());
queryWrapper.ne(CustomerEntity::getId, formDTO.getCustomerId());
Integer roleOperationCount = baseDao.selectCount(queryWrapper);
if (null != roleOperationCount && roleOperationCount > NumConstant.ZERO) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "客户名称已存在:" + formDTO.getCustomerName(), "客户名称已存在");
}
//2、设置组织区划开关、根组织的组织区划 调用gov-org服务
CustomerAreaCodeFormDTO areaCodeFormDTO = ConvertUtils.sourceToTarget(formDTO, CustomerAreaCodeFormDTO.class);
Result govOrgresult = govOrgOpenFeignClient.configCustomerAreaCode(areaCodeFormDTO);
if (!govOrgresult.success()) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "gov-org服务异常:" + govOrgresult.getInternalMsg(), "设置组织区划接口返回异常:" + govOrgresult.getMsg());
}
//3、修改客户名称
CustomerEntity entity = new CustomerEntity(); CustomerEntity entity = new CustomerEntity();
entity.setId(formDTO.getCustomerId()); entity.setId(formDTO.getCustomerId());
if (StringUtils.isNotBlank(formDTO.getCustomerName())){ if (StringUtils.isNotBlank(formDTO.getCustomerName())) {
entity.setCustomerName(formDTO.getCustomerName()); entity.setCustomerName(formDTO.getCustomerName());
} }
if (StringUtils.isNotBlank(formDTO.getLogo())){ if (StringUtils.isNotBlank(formDTO.getLogo())) {
entity.setLogo(formDTO.getLogo()); entity.setLogo(formDTO.getLogo());
} }
entity.setLogo(formDTO.getLogo()); entity.setLogo(formDTO.getLogo());

Loading…
Cancel
Save