|
|
@ -1,13 +1,17 @@ |
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.rocketmq.messages.StaffPatrolMQMsg; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.ServiceConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.redis.RedisKeys; |
|
|
|
import com.epmet.commons.tools.redis.RedisUtils; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
@ -42,9 +46,7 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
@ -73,6 +75,8 @@ public class StaffPatrolRecordServiceImpl extends BaseServiceImpl<StaffPatrolRec |
|
|
|
private GovProjectOpenFeignClient govProjectOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private RedisUtils redisUtils; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
@ -469,19 +473,32 @@ public class StaffPatrolRecordServiceImpl extends BaseServiceImpl<StaffPatrolRec |
|
|
|
return resultDTO; |
|
|
|
} |
|
|
|
|
|
|
|
//2.查询网格信息
|
|
|
|
OrgInfoFormDTO org = new OrgInfoFormDTO(); |
|
|
|
List<String> orgIds = result.getList().stream().map(PcworkRecordListResultDTO.StaffPatrol::getGridId).collect(Collectors.toList()); |
|
|
|
orgIds = orgIds.stream().distinct().collect(Collectors.toList()); |
|
|
|
org.setOrgIds(orgIds); |
|
|
|
org.setOrgType("grid"); |
|
|
|
Result<List<OrgInfoResultDTO>> orgResult = govOrgOpenFeignClient.selectOrgInfo(org); |
|
|
|
if (!orgResult.success()) { |
|
|
|
throw new RenException("获取网格基础信息失败......"); |
|
|
|
//2.查询网格信息并赋值
|
|
|
|
Map<String, CustomerGridDTO> map = new HashMap<>(); |
|
|
|
for (PcworkRecordListResultDTO.StaffPatrol r : result.getList()) { |
|
|
|
if (map.containsKey(r.getGridId())) { |
|
|
|
r.setGridName(map.get(r.getGridId()).getGridName()); |
|
|
|
continue; |
|
|
|
} |
|
|
|
String redisKey = RedisKeys.getGridInfoKey(r.getGridId()); |
|
|
|
Map<String, Object> gridCache = redisUtils.hGetAll(redisKey); |
|
|
|
if (gridCache != null && gridCache.size() > 0) { |
|
|
|
// 直接取缓存中的
|
|
|
|
CustomerGridDTO dto = BeanUtil.mapToBean(gridCache, CustomerGridDTO.class, true); |
|
|
|
r.setGridName(dto.getGridName()); |
|
|
|
map.put(r.getGridId(), dto); |
|
|
|
} else { |
|
|
|
CustomerGridFormDTO form = new CustomerGridFormDTO(); |
|
|
|
form.setGridId(r.getGridId()); |
|
|
|
Result<CustomerGridDTO> resultGrid = govOrgOpenFeignClient.getGridBaseInfoByGridId(form); |
|
|
|
if (!resultGrid.success()) { |
|
|
|
throw new RenException("调用org服务获取网格基础信息失败......"); |
|
|
|
} |
|
|
|
r.setGridName(resultGrid.getData().getGridName()); |
|
|
|
map.put(r.getGridId(), resultGrid.getData()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//3.封装数据并返回
|
|
|
|
result.getList().forEach(r -> orgResult.getData().stream().filter(u -> r.getGridId().equals(u.getOrgId())).forEach(u -> r.setGridName(u.getOrgName()))); |
|
|
|
resultDTO.setTotal((int)result.getTotal()); |
|
|
|
resultDTO.setList(result.getList()); |
|
|
|
return resultDTO; |
|
|
|