树形列表查询企业-智能安全帽-设备信息
This commit is contained in:
parent
ff67dbdfdd
commit
234b9ddb55
@ -1,11 +1,18 @@
|
||||
package com.zhgd.xmgl.modules.safetyhat.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.zhgd.annotation.OperLog;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatDev;
|
||||
import com.zhgd.xmgl.modules.safetyhat.entity.vo.QueryEnterpriseTreeVo;
|
||||
import com.zhgd.xmgl.modules.safetyhat.service.ISafetyHatDevService;
|
||||
import com.zhgd.xmgl.modules.vehicleposition.entity.vo.CountVehiclePositionDevVo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
|
||||
import com.zhgd.xmgl.modules.worker.service.IEnterpriseInfoService;
|
||||
import com.zhgd.xmgl.modules.worker.service.impl.WorkerInfoServiceImpl;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
@ -15,6 +22,7 @@ import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.simpleframework.xml.core.Validate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -25,8 +33,11 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@ -41,6 +52,12 @@ import java.util.List;
|
||||
@Slf4j
|
||||
@Api(tags = "智能安全帽-设备相关Api")
|
||||
public class SafetyHatDevController {
|
||||
@Lazy
|
||||
@Autowired
|
||||
WorkerInfoServiceImpl workerInfoService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
IEnterpriseInfoService enterpriseInfoService;
|
||||
@Autowired
|
||||
private ISafetyHatDevService safetyHatDevService;
|
||||
|
||||
@ -165,7 +182,6 @@ public class SafetyHatDevController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@OperLog(operModul = "智能安全帽设备管理", operType = "查询", operDesc = "模板增量导入")
|
||||
@ApiOperation(value = "模板增量导入", notes = "模板增量导入")
|
||||
@ApiImplicitParams({
|
||||
@ -177,4 +193,39 @@ public class SafetyHatDevController {
|
||||
safetyHatDevService.importExcelTemplate(file, projectSn);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@OperLog(operModul = "智能安全帽设备管理", operType = "查询", operDesc = "树形列表查询企业-智能安全帽-设备信息")
|
||||
@ApiOperation(value = "树形列表查询企业-智能安全帽-设备信息", notes = "树形列表查询企业-智能安全帽-设备信息", httpMethod = "GET")
|
||||
@GetMapping(value = "/enterprise/tree/list")
|
||||
public Result<List<QueryEnterpriseTreeVo>> queryEnterpriseTreeList(@ApiIgnore @RequestParam HashMap<String, Object> paramMap) {
|
||||
List<SafetyHatDev> safetyHatDevs = safetyHatDevService.queryList(paramMap);
|
||||
List<Long> workerIds = safetyHatDevs.stream().map(safetyHatDev -> safetyHatDev.getWorkerInfoId()).collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(workerIds)) {
|
||||
workerIds.add(-1L);
|
||||
}
|
||||
List<WorkerInfo> workerInfos = workerInfoService.list(new LambdaQueryWrapper<WorkerInfo>().in(WorkerInfo::getId, workerIds));
|
||||
List<Long> enterpriseIds = workerInfos.stream().map(WorkerInfo::getEnterpriseId).collect(Collectors.toList());
|
||||
Map<Long, List<WorkerInfo>> enterpriseMap = workerInfos.stream().collect(Collectors.groupingBy(WorkerInfo::getEnterpriseId));
|
||||
if (CollUtil.isEmpty(enterpriseIds)) {
|
||||
enterpriseIds.add(-1L);
|
||||
}
|
||||
List<EnterpriseInfo> enterpriseInfos = enterpriseInfoService.list(new LambdaQueryWrapper<EnterpriseInfo>().in(EnterpriseInfo::getId, enterpriseIds));
|
||||
List<QueryEnterpriseTreeVo> rt = new ArrayList<>();
|
||||
for (EnterpriseInfo enterpriseInfo : enterpriseInfos) {
|
||||
QueryEnterpriseTreeVo vo = new QueryEnterpriseTreeVo();
|
||||
vo.setName(enterpriseInfo.getEnterpriseName());
|
||||
vo.setEnterpriseId(enterpriseInfo.getId());
|
||||
List<SafetyHatDev> hatDevs = safetyHatDevs.stream().filter(safetyHatDev -> {
|
||||
safetyHatDev.setName(safetyHatDev.getWorkerName());
|
||||
List<WorkerInfo> l = enterpriseMap.get(enterpriseInfo.getId());
|
||||
if (CollUtil.isNotEmpty(l)) {
|
||||
return l.stream().anyMatch(workerInfo -> safetyHatDev.getWorkerInfoId().equals(workerInfo.getId()));
|
||||
}
|
||||
return false;
|
||||
}).collect(Collectors.toList());
|
||||
vo.setSafetyHatDevs(hatDevs);
|
||||
rt.add(vo);
|
||||
}
|
||||
return Result.success(rt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
package com.zhgd.xmgl.modules.safetyhat.entity.vo;
|
||||
|
||||
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatDev;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public
|
||||
class QueryEnterpriseTreeVo {
|
||||
@ApiModelProperty(value = "合作单位名称")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "合作单位id")
|
||||
private Long enterpriseId;
|
||||
private List<SafetyHatDev> safetyHatDevs;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user