Browse Source

Merge branch 'dev_routine_work' into develop

dev
sunyuchao 4 years ago
parent
commit
2bccd614a6
  1. 32
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java
  2. 45
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java
  3. 5
      epmet-user/epmet-user-server/src/main/resources/mapper/PatrolRoutineWorkDao.xml

32
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java

@ -36,6 +36,7 @@ import com.epmet.dto.form.CustomerGridFormDTO;
import com.epmet.dto.form.PatrolRoutineWorkFormDTO;
import com.epmet.dto.form.PcWorkListFormDTO;
import com.epmet.dto.form.patrol.PatrolQueryFormDTO;
import com.epmet.dto.result.AllGridsByUserIdResultDTO;
import com.epmet.dto.result.PatrolRoutineWorkResult;
import com.epmet.dto.result.PcWorkListResultDTO;
import com.epmet.entity.PatrolRoutineWorkEntity;
@ -60,6 +61,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 巡查例行工作
@ -171,10 +173,40 @@ public class PatrolRoutineWorkServiceImpl extends BaseServiceImpl<PatrolRoutineW
if (CollectionUtils.isEmpty(list)){
return result;
}
Result<List<DictTreeResultDTO>> workTypeResult = adminOpenFeignClient.dictTree(DictTypeEnum.PATROL_WORK_TYPE.getCode());
if (!workTypeResult.success()){
throw new EpmetException("查询例行工作分类失败...");
}
List<String> gridIds = list.stream().map(m -> m.getGridId()).distinct().collect(Collectors.toList());
Result<List<AllGridsByUserIdResultDTO>> gridNamesResult = govOrgOpenFeignClient.getGridListByGridIds(gridIds);
if (!gridNamesResult.success()){
throw new EpmetException("查询网格名字失败...");
}
list.forEach(l -> {
l.setWorkTypeName(disposeWorkTypeCode(workTypeResult.getData(),l.getWorkTypeCode()));
gridNamesResult.getData().stream().filter(g -> l.getGridId().equals(g.getGridId())).forEach(g -> l.setGridName(g.getGridName()));
});
result.setList(list);
return result;
}
public List<String> disposeWorkTypeCode(List<DictTreeResultDTO> workTypeList,List<String> code){
if (CollectionUtils.isEmpty(code)){
return new ArrayList<>();
}
List<String> result = new ArrayList<>();
code.forEach(c -> {
workTypeList.forEach(w1 -> {
w1.getChildren().forEach(w2 -> {
if (c.equals(w2.getId())){
result.add(w1.getName() + "-" + w2.getName());
}
});
});
});
return result;
}
/**
* desc:递归遍历树形结构 构建pids 根节点pids 为空字符串
*

45
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/StaffPatrolRecordServiceImpl.java

@ -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;

5
epmet-user/epmet-user-server/src/main/resources/mapper/PatrolRoutineWorkDao.xml

@ -47,6 +47,7 @@
<result property="gridId" column="gridId"/>
<result property="createdTime" column="createdTime"/>
<result property="workContent" column="workContent"/>
<result property="staffName" column="staffName"/>
<collection property="workTypeCode" ofType="java.lang.String" select="pcWorkTypeCodeList" column="wid">
<result column="workTypeCode"/>
</collection>
@ -61,8 +62,10 @@
w.USER_ID AS staffId,
w.GRID_ID AS gridId,
DATE_FORMAT(w.CREATED_TIME,'%Y-%m-%d %H:%i:%s') AS createdTime,
w.WORK_CONTENT AS workContent
w.WORK_CONTENT AS workContent,
s.REAL_NAME AS staffName
FROM patrol_routine_work w
INNER JOIN customer_staff s ON (s.USER_ID = w.USER_ID AND s.DEL_FLAG = 0)
WHERE w.DEL_FLAG = 0
<if test="staffId != null and staffId != '' ">
AND w.USER_ID = #{staffId}

Loading…
Cancel
Save