Browse Source

返回数据模型新增字段:路段范围sectionRange 和 用户名username

tags/V1.3.3^2
suqin 11 months ago
parent
commit
7773147229
2 changed files with 75 additions and 5 deletions
  1. +63
    -5
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/iotequipment/query/QueryEditIotEquipmentPageListService.java
  2. +12
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/IotEquipmentVo.java

+ 63
- 5
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/iotequipment/query/QueryEditIotEquipmentPageListService.java View File

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

+ 12
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/IotEquipmentVo.java View File

@@ -55,6 +55,12 @@ public class IotEquipmentVo extends BaseEntity {
*/
private String sectionId;

/**
* 路段范围
*/
private String sectionRange;


/**
* 位置
*/
@@ -85,6 +91,12 @@ public class IotEquipmentVo extends BaseEntity {
*/
private String createUser;

/**
* 添加人的realName
*/
private String username;


/**
* 创建时间
*/

Loading…
Cancel
Save