|
@ -18,10 +18,8 @@ |
|
|
package com.epmet.service.impl; |
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
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.NumConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
@ -29,29 +27,33 @@ import com.epmet.commons.tools.exception.EpmetException; |
|
|
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.EpmetRequestHolder; |
|
|
import com.epmet.commons.tools.utils.EpmetRequestHolder; |
|
|
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.dao.TagCustomerDao; |
|
|
import com.epmet.dao.TagCustomerDao; |
|
|
import com.epmet.dao.TagScopeDao; |
|
|
import com.epmet.dao.TagScopeDao; |
|
|
import com.epmet.dto.TagCustomerDTO; |
|
|
import com.epmet.dto.TagCustomerDTO; |
|
|
import com.epmet.dto.form.TagCustomerFormDTO; |
|
|
import com.epmet.dto.form.TagCustomerFormDTO; |
|
|
import com.epmet.dto.form.TagCustomerPageFormDTO; |
|
|
import com.epmet.dto.form.TagCustomerPageFormDTO; |
|
|
import com.epmet.dto.form.UpdateTagFormDTO; |
|
|
import com.epmet.dto.form.UpdateTagFormDTO; |
|
|
|
|
|
import com.epmet.dto.result.AgencyResultDTO; |
|
|
import com.epmet.dto.result.UpdateTagUseCountsResultDTO; |
|
|
import com.epmet.dto.result.UpdateTagUseCountsResultDTO; |
|
|
import com.epmet.entity.TagCustomerEntity; |
|
|
import com.epmet.entity.TagCustomerEntity; |
|
|
import com.epmet.entity.TagScopeEntity; |
|
|
import com.epmet.entity.TagScopeEntity; |
|
|
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
import com.epmet.service.TagCustomerService; |
|
|
import com.epmet.service.TagCustomerService; |
|
|
import com.epmet.utils.TagColorUtils; |
|
|
import com.epmet.utils.TagColorUtils; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.github.pagehelper.PageInfo; |
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
|
|
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.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
import java.util.Arrays; |
|
|
import java.util.Date; |
|
|
import java.util.Date; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 客户标签表 |
|
|
* 客户标签表 |
|
@ -59,10 +61,13 @@ import java.util.Map; |
|
|
* @author generator generator@elink-cn.com |
|
|
* @author generator generator@elink-cn.com |
|
|
* @since v1.0.0 2020-06-02 |
|
|
* @since v1.0.0 2020-06-02 |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
@Slf4j |
|
|
@Service |
|
|
@Service |
|
|
public class TagCustomerServiceImpl extends BaseServiceImpl<TagCustomerDao, TagCustomerEntity> implements TagCustomerService { |
|
|
public class TagCustomerServiceImpl extends BaseServiceImpl<TagCustomerDao, TagCustomerEntity> implements TagCustomerService { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private TagScopeDao tagScopeDao; |
|
|
private TagScopeDao tagScopeDao; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -78,22 +83,6 @@ public class TagCustomerServiceImpl extends BaseServiceImpl<TagCustomerDao, TagC |
|
|
return new PageData<>(list, pageInfo.getTotal()); |
|
|
return new PageData<>(list, pageInfo.getTotal()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<TagCustomerDTO> list(Map<String, Object> params) { |
|
|
|
|
|
List<TagCustomerEntity> entityList = baseDao.selectList(getWrapper(params)); |
|
|
|
|
|
|
|
|
|
|
|
return ConvertUtils.sourceToTarget(entityList, TagCustomerDTO.class); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private QueryWrapper<TagCustomerEntity> getWrapper(Map<String, Object> params){ |
|
|
|
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper<TagCustomerEntity> wrapper = new QueryWrapper<>(); |
|
|
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
|
|
|
|
|
|
|
|
|
return wrapper; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public TagCustomerDTO get(String id) { |
|
|
public TagCustomerDTO get(String id) { |
|
|
TagCustomerEntity entity = baseDao.selectById(id); |
|
|
TagCustomerEntity entity = baseDao.selectById(id); |
|
@ -119,13 +108,12 @@ public class TagCustomerServiceImpl extends BaseServiceImpl<TagCustomerDao, TagC |
|
|
entity.setUseCount(NumConstant.ZERO); |
|
|
entity.setUseCount(NumConstant.ZERO); |
|
|
entity.setShowFlag(NumConstant.ONE); |
|
|
entity.setShowFlag(NumConstant.ONE); |
|
|
insert(entity); |
|
|
insert(entity); |
|
|
if(CollectionUtils.isNotEmpty(dto.getAgencyIds())){ |
|
|
if(CollectionUtils.isNotEmpty(dto.getAgencyList())){ |
|
|
dto.getAgencyIds().forEach(tagScopeDTO->{ |
|
|
dto.getAgencyList().forEach(tagScopeDTO->{ |
|
|
TagScopeEntity tagScopeEntity=new TagScopeEntity(); |
|
|
TagScopeEntity tagScopeEntity=new TagScopeEntity(); |
|
|
tagScopeEntity.setCustomerId(entity.getCustomerId()); |
|
|
tagScopeEntity.setCustomerId(entity.getCustomerId()); |
|
|
tagScopeEntity.setTagId(entity.getId()); |
|
|
tagScopeEntity.setTagId(entity.getId()); |
|
|
tagScopeEntity.setAgencyId(tagScopeDTO.getAgencyId()); |
|
|
tagScopeEntity.setAgencyId(tagScopeDTO.getAgencyId()); |
|
|
tagScopeEntity.setAgencyName(tagScopeDTO.getAgencyName()); |
|
|
|
|
|
tagScopeEntity.setOrgIdPath(tagScopeDTO.getOrgIdPath()); |
|
|
tagScopeEntity.setOrgIdPath(tagScopeDTO.getOrgIdPath()); |
|
|
tagScopeDao.insert(tagScopeEntity); |
|
|
tagScopeDao.insert(tagScopeEntity); |
|
|
}); |
|
|
}); |
|
@ -151,13 +139,12 @@ public class TagCustomerServiceImpl extends BaseServiceImpl<TagCustomerDao, TagC |
|
|
updateById(entity); |
|
|
updateById(entity); |
|
|
//删除应用范围
|
|
|
//删除应用范围
|
|
|
tagScopeDao.deleteByTagId(entity.getId(),entity.getCustomerId()); |
|
|
tagScopeDao.deleteByTagId(entity.getId(),entity.getCustomerId()); |
|
|
if(CollectionUtils.isNotEmpty(dto.getAgencyIds())){ |
|
|
if(CollectionUtils.isNotEmpty(dto.getAgencyList())){ |
|
|
dto.getAgencyIds().forEach(tagScopeDTO->{ |
|
|
dto.getAgencyList().forEach(tagScopeDTO->{ |
|
|
TagScopeEntity tagScopeEntity=new TagScopeEntity(); |
|
|
TagScopeEntity tagScopeEntity=new TagScopeEntity(); |
|
|
tagScopeEntity.setCustomerId(entity.getCustomerId()); |
|
|
tagScopeEntity.setCustomerId(entity.getCustomerId()); |
|
|
tagScopeEntity.setTagId(entity.getId()); |
|
|
tagScopeEntity.setTagId(entity.getId()); |
|
|
tagScopeEntity.setAgencyId(tagScopeDTO.getAgencyId()); |
|
|
tagScopeEntity.setAgencyId(tagScopeDTO.getAgencyId()); |
|
|
tagScopeEntity.setAgencyName(tagScopeDTO.getAgencyName()); |
|
|
|
|
|
tagScopeEntity.setOrgIdPath(tagScopeDTO.getOrgIdPath()); |
|
|
tagScopeEntity.setOrgIdPath(tagScopeDTO.getOrgIdPath()); |
|
|
tagScopeDao.insert(tagScopeEntity); |
|
|
tagScopeDao.insert(tagScopeEntity); |
|
|
}); |
|
|
}); |
|
@ -213,4 +200,45 @@ public class TagCustomerServiceImpl extends BaseServiceImpl<TagCustomerDao, TagC |
|
|
.set(TagCustomerEntity::getShowFlag,showFlag); |
|
|
.set(TagCustomerEntity::getShowFlag,showFlag); |
|
|
baseDao.update(null,tagCustomerUpdateWrapper); |
|
|
baseDao.update(null,tagCustomerUpdateWrapper); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 初始化标签应用范围, |
|
|
|
|
|
* 每个标签,和当前客户下所有社区关联 |
|
|
|
|
|
* |
|
|
|
|
|
* @param customerId@return |
|
|
|
|
|
*/ |
|
|
|
|
|
@Async |
|
|
|
|
|
@Override |
|
|
|
|
|
public void initTagScope(String customerId) { |
|
|
|
|
|
if (StringUtils.isBlank(customerId)) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
LambdaQueryWrapper<TagCustomerEntity> queryWrapper = new LambdaQueryWrapper(); |
|
|
|
|
|
queryWrapper.eq(TagCustomerEntity::getCustomerId, customerId); |
|
|
|
|
|
List<TagCustomerEntity> tagList = baseDao.selectList(queryWrapper); |
|
|
|
|
|
if (CollectionUtils.isEmpty(tagList)) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
int tagTotal = tagList.size(); |
|
|
|
|
|
// 获取当前客户下所有的社区组织
|
|
|
|
|
|
Result<List<AgencyResultDTO>> communityRes = govOrgOpenFeignClient.getAllCommunity(customerId); |
|
|
|
|
|
if (communityRes.success() && CollectionUtils.isNotEmpty(communityRes.getData())) { |
|
|
|
|
|
int communityTotal = communityRes.getData().size(); |
|
|
|
|
|
int num = 1; |
|
|
|
|
|
for (TagCustomerEntity tag : tagList) { |
|
|
|
|
|
for (AgencyResultDTO agencyResultDTO : communityRes.getData()) { |
|
|
|
|
|
TagScopeEntity tagScopeEntity = new TagScopeEntity(); |
|
|
|
|
|
tagScopeEntity.setCustomerId(tag.getCustomerId()); |
|
|
|
|
|
tagScopeEntity.setTagId(tag.getId()); |
|
|
|
|
|
tagScopeEntity.setAgencyId(agencyResultDTO.getAgencyId()); |
|
|
|
|
|
tagScopeEntity.setOrgIdPath(agencyResultDTO.getOrgIdPath()); |
|
|
|
|
|
tagScopeDao.insert(tagScopeEntity); |
|
|
|
|
|
num++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
log.error(String.format("customerId:%s,已经将%s个标签应用给%s个社区,tag_scope产生%s条记录", customerId, tagTotal, communityTotal, num)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|