|
|
@@ -10,14 +10,10 @@ import com.tuoheng.admin.entity.*; |
|
|
|
import com.tuoheng.admin.enums.DataPermissionEnum; |
|
|
|
import com.tuoheng.admin.enums.MarkEnum; |
|
|
|
import com.tuoheng.admin.enums.code.inspection.QueryInspectionPageListCodeEnum; |
|
|
|
import com.tuoheng.admin.mapper.DeptMapper; |
|
|
|
import com.tuoheng.admin.mapper.IotEquipmentMapper; |
|
|
|
import com.tuoheng.admin.mapper.RoadInformationMapper; |
|
|
|
import com.tuoheng.admin.mapper.SectionMapper; |
|
|
|
import com.tuoheng.admin.mapper.*; |
|
|
|
import com.tuoheng.admin.request.iotequipment.QueryIotEquipmentPageListRequest; |
|
|
|
import com.tuoheng.admin.utils.CurrentUserUtil; |
|
|
|
import com.tuoheng.admin.vo.IotEquipmentVo; |
|
|
|
import com.tuoheng.admin.vo.accident.AccidentVo; |
|
|
|
import com.tuoheng.common.core.utils.JsonResult; |
|
|
|
import com.tuoheng.common.core.utils.StringUtils; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
@@ -50,6 +46,8 @@ public class QueryEditIotEquipmentPageListService { |
|
|
|
|
|
|
|
private final SectionMapper sectionMapper; |
|
|
|
|
|
|
|
private final UserMapper userMapper; |
|
|
|
|
|
|
|
public JsonResult getPageList(QueryIotEquipmentPageListRequest request) { |
|
|
|
User user = CurrentUserUtil.getUserInfo(); |
|
|
|
JsonResult result = this.check(request); |
|
|
@@ -121,8 +119,14 @@ public class QueryEditIotEquipmentPageListService { |
|
|
|
|
|
|
|
Map<String, Dept> deptMap = this.getDeptMap(iotEquipmentList); |
|
|
|
Map<String, RoadInformation> roadInformationMap = this.getRoadInformationMap(iotEquipmentList); |
|
|
|
Map<String, Section> sectionMap = this.getSectionMap(iotEquipmentList); |
|
|
|
Map<String, User> userMap = this.getUserMap(iotEquipmentList); |
|
|
|
|
|
|
|
Dept dept; |
|
|
|
RoadInformation roadInformation; |
|
|
|
Section section; |
|
|
|
User user; |
|
|
|
|
|
|
|
for (IotEquipmentVo iotEquipmentVo : iotEquipmentVoList) { |
|
|
|
if (ObjectUtil.isNotEmpty(deptMap)) { |
|
|
|
dept = deptMap.get(iotEquipmentVo.getDeptId()); |
|
|
@@ -136,11 +140,65 @@ public class QueryEditIotEquipmentPageListService { |
|
|
|
iotEquipmentVo.setRoadName(roadInformation.getName()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//返回数据模型新增字段:路段范围sectionRange 和 用户名username |
|
|
|
if (ObjectUtil.isNotEmpty(sectionMap)) { |
|
|
|
section = sectionMap.get(iotEquipmentVo.getSectionId()); |
|
|
|
if (ObjectUtil.isNotEmpty(section)) { |
|
|
|
iotEquipmentVo.setSectionRange(section.getSectionRange()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(userMap)) { |
|
|
|
user = userMap.get(iotEquipmentVo.getCreateUser()); |
|
|
|
if (ObjectUtil.isNotEmpty(user)) { |
|
|
|
iotEquipmentVo.setUsername(user.getRealname()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return iotEquipmentVoList; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 获取用户列表,放到map,减少循环次数 |
|
|
|
* @param iotEquipmentList |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private Map<String, User> getUserMap(List<IotEquipment> iotEquipmentList) { |
|
|
|
List<String> userIdList = iotEquipmentList.stream().map(o -> o.getCreateUser()).collect(Collectors.toList()); |
|
|
|
List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>() |
|
|
|
.in(User::getId, userIdList) |
|
|
|
.eq(User::getMark, MarkEnum.VALID.getCode())); |
|
|
|
Map<String, User> userMap = userList.stream().collect(Collectors.toMap(User::getId, Function.identity())); |
|
|
|
return userMap; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 获取路段列表,放到map,减少循环次数 |
|
|
|
* @param iotEquipmentList |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private Map<String, Section> getSectionMap(List<IotEquipment> iotEquipmentList) { |
|
|
|
List<String> sectionIdList = iotEquipmentList.stream().map(o -> o.getSectionId()).collect(Collectors.toList()); |
|
|
|
List<Section> sectionList = sectionMapper.selectList(new LambdaQueryWrapper<Section>() |
|
|
|
.in(Section::getId, sectionIdList) |
|
|
|
.eq(Section::getMark, MarkEnum.VALID.getCode())); |
|
|
|
Map<String, Section> sectionMap = sectionList.stream().collect(Collectors.toMap(Section::getId, Function.identity())); |
|
|
|
return sectionMap; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 设置列表中每一个的部门名称 |
|
|
|
* 查询到的列表中的部门Id,作为部门id列表,查询所有的部门,该结果数据量不会太大,放到map中 |