|
|
@ -21,12 +21,16 @@ import com.alibaba.fastjson.JSON; |
|
|
|
import com.epmet.commons.rocketmq.messages.OrgOrStaffMQMsg; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.security.user.LoginUserUtil; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.CustomerAgencyConstant; |
|
|
|
import com.epmet.constant.OrgInfoConstant; |
|
|
|
import com.epmet.constant.RoleKeyConstants; |
|
|
|
import com.epmet.dao.CustomerAgencyDao; |
|
|
|
import com.epmet.dao.CustomerGridDao; |
|
|
@ -35,6 +39,7 @@ import com.epmet.dto.GovStaffRoleDTO; |
|
|
|
import com.epmet.dto.form.*; |
|
|
|
import com.epmet.dto.result.*; |
|
|
|
import com.epmet.entity.CustomerAgencyEntity; |
|
|
|
import com.epmet.entity.CustomerGridEntity; |
|
|
|
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; |
|
|
|
import com.epmet.feign.EpmetMessageOpenFeignClient; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
@ -52,6 +57,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
@ -530,6 +536,97 @@ public class AgencyServiceImpl implements AgencyService { |
|
|
|
return resultDTO; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 【地图配置】删除 |
|
|
|
* @param formDTO |
|
|
|
* @author zxc |
|
|
|
* @date 2021/10/25 9:30 上午 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void mapDelArea(MapDelAreaFormDTO formDTO) { |
|
|
|
customerAgencyDao.delMapArea(formDTO.getOrgId(),formDTO.getLevel()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 【地图配置】新增 |
|
|
|
* @param formDTO |
|
|
|
* @author zxc |
|
|
|
* @date 2021/10/25 9:58 上午 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void mapAddArea(MapAddAreaFormDTO formDTO) { |
|
|
|
customerAgencyDao.addMapArea(formDTO.getOrgId(), formDTO.getLevel(), formDTO.getCoordinates()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 【地图配置】组织查询 |
|
|
|
* @param formDTO |
|
|
|
* @param tokenDto |
|
|
|
* @author zxc |
|
|
|
* @date 2021/10/25 10:50 上午 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public MapOrgResultDTO mapOrg(MapOrgFormDTO formDTO, TokenDto tokenDto) { |
|
|
|
MapOrgResultDTO result = new MapOrgResultDTO(); |
|
|
|
if (StringUtils.isBlank(formDTO.getOrgId())){ |
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); |
|
|
|
formDTO.setOrgId(staffInfo.getFromOrgId()); |
|
|
|
formDTO.setLevel(staffInfo.getFromOrgType()); |
|
|
|
} |
|
|
|
if (formDTO.getLevel().equals(OrgInfoConstant.AGENCY)){ |
|
|
|
CustomerAgencyEntity entity = customerAgencyDao.selectById(formDTO.getOrgId()); |
|
|
|
result = ConvertUtils.sourceToTarget(entity,MapOrgResultDTO.class); |
|
|
|
result.setName(entity.getOrganizationName()); |
|
|
|
result.setLevel(formDTO.getLevel()); |
|
|
|
result.setLatitude(StringUtils.isBlank(entity.getLatitude()) ? null : new BigDecimal(entity.getLatitude())); |
|
|
|
result.setLongitude(StringUtils.isBlank(entity.getLongitude()) ? null : new BigDecimal(entity.getLongitude())); |
|
|
|
if (entity.getLevel().equals(OrgInfoConstant.COMMUNITY)){ |
|
|
|
List<MapSonOrgResultDTO> son = customerAgencyDao.selectSonOrg(formDTO.getOrgId(), OrgInfoConstant.GRID); |
|
|
|
if (CollectionUtils.isNotEmpty(son)){ |
|
|
|
son.forEach(s -> { |
|
|
|
s.setLatitude(StringUtils.isBlank(s.getLatitudeOrigin()) ? null : new BigDecimal(s.getLatitudeOrigin())); |
|
|
|
s.setLongitude(StringUtils.isBlank(s.getLongitudeOrigin()) ? null : new BigDecimal(s.getLongitudeOrigin())); |
|
|
|
}); |
|
|
|
} |
|
|
|
result.setChildren(CollectionUtils.isEmpty(son) ? new ArrayList<>() : son); |
|
|
|
}else { |
|
|
|
List<MapSonOrgResultDTO> dtoList = new ArrayList<>(); |
|
|
|
List<MapSonOrgResultDTO> son = customerAgencyDao.selectSonOrg(formDTO.getOrgId(), OrgInfoConstant.AGENCY); |
|
|
|
if (CollectionUtils.isNotEmpty(son)){ |
|
|
|
dtoList.addAll(son); |
|
|
|
} |
|
|
|
// 直属网格
|
|
|
|
List<MapSonOrgResultDTO> directlySub = customerAgencyDao.selectSonOrg(formDTO.getOrgId(), OrgInfoConstant.GRID); |
|
|
|
if (CollectionUtils.isNotEmpty(directlySub)){ |
|
|
|
dtoList.addAll(directlySub); |
|
|
|
} |
|
|
|
if (CollectionUtils.isNotEmpty(dtoList)){ |
|
|
|
dtoList.forEach(d -> { |
|
|
|
d.setLatitude(StringUtils.isBlank(d.getLatitudeOrigin()) ? null : new BigDecimal(d.getLatitudeOrigin())); |
|
|
|
d.setLongitude(StringUtils.isBlank(d.getLongitudeOrigin()) ? null : new BigDecimal(d.getLongitudeOrigin())); |
|
|
|
}); |
|
|
|
} |
|
|
|
result.setChildren(dtoList); |
|
|
|
} |
|
|
|
}else if (formDTO.getLevel().equals(OrgInfoConstant.GRID)){ |
|
|
|
CustomerGridEntity entity = customerGridDao.selectById(formDTO.getOrgId()); |
|
|
|
result = ConvertUtils.sourceToTarget(entity,MapOrgResultDTO.class); |
|
|
|
result.setName(entity.getGridName()); |
|
|
|
result.setLevel(formDTO.getLevel()); |
|
|
|
result.setLatitude(StringUtils.isBlank(entity.getLatitude()) ? null : new BigDecimal(entity.getLatitude())); |
|
|
|
result.setLongitude(StringUtils.isBlank(entity.getLongitude()) ? null : new BigDecimal(entity.getLongitude())); |
|
|
|
List<MapSonOrgResultDTO> son = customerAgencyDao.selectSonOrg(formDTO.getOrgId(), OrgInfoConstant.NEIGHBOR_HOOD); |
|
|
|
if (CollectionUtils.isNotEmpty(son)){ |
|
|
|
son.forEach(s -> { |
|
|
|
s.setLatitude(StringUtils.isBlank(s.getLatitudeOrigin()) ? null : new BigDecimal(s.getLatitudeOrigin())); |
|
|
|
s.setLongitude(StringUtils.isBlank(s.getLongitudeOrigin()) ? null : new BigDecimal(s.getLongitudeOrigin())); |
|
|
|
}); |
|
|
|
} |
|
|
|
result.setChildren(CollectionUtils.isEmpty(son) ? new ArrayList<>() : son); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
private CustomerAgencyEntity constructInsertEntity(AddAgencyV2FormDTO formDTO, CustomerAgencyDTO parent) { |
|
|
|
CustomerAgencyEntity insertEntity = ConvertUtils.sourceToTarget(formDTO, CustomerAgencyEntity.class); |
|
|
|
insertEntity.setOrganizationName(formDTO.getAgencyName()); |
|
|
|