1.污区图
2.过程监督-终端 代码提交
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
package com.njcn.process.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.process.pojo.param.TerminalParam;
|
||||
import com.njcn.process.pojo.vo.TerminalVO;
|
||||
import com.njcn.process.service.PmsTerminalDetectionService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 终端检测监督
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2023-02-27
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/process/pmsTerminalDetection")
|
||||
@Api(tags = "终端检测监督管理")
|
||||
@RequiredArgsConstructor
|
||||
public class PmsTerminalDetectionController extends BaseController {
|
||||
private final PmsTerminalDetectionService pmsTerminalDetectionService;
|
||||
|
||||
|
||||
@PostMapping("/getTerminalPage")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("终端检测监督管理分页查询")
|
||||
public HttpResult<Page<TerminalVO>> getPage(@RequestBody TerminalParam.TerminalPageParam param) {
|
||||
String methodDescribe = getMethodDescribe("getTerminalPage");
|
||||
Page<TerminalVO> page = pmsTerminalDetectionService.terminalPage(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "导出终端入网检测录入模板")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/export")
|
||||
public void export(HttpServletResponse response) {
|
||||
pmsTerminalDetectionService.exportTemplate(response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping(value = "/importTerminal")
|
||||
@ApiOperation("excel批量导入终端入网检测录入")
|
||||
@ResponseBody
|
||||
public HttpResult<String> importTerminalBase(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importTerminal");
|
||||
pmsTerminalDetectionService.batchTerminal(file, response);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ApiOperation("批量导入检测报告")
|
||||
@PostMapping(value = "/importReport")
|
||||
public HttpResult<String> importReport(@ApiParam(value = "文件", required = true) @RequestPart("files") MultipartFile[] files, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importReport");
|
||||
pmsTerminalDetectionService.importReport(files, response);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@PostMapping("/getStatistics")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("终端入网检测台账统计")
|
||||
public HttpResult<List<TerminalVO.TerminalStatistics>> getStatistics(@RequestBody TerminalParam param) {
|
||||
String methodDescribe = getMethodDescribe("getStatistics");
|
||||
List<TerminalVO.TerminalStatistics> list = pmsTerminalDetectionService.getStatistics(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@PostMapping("/getCycleStatistics")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("周期检测统计")
|
||||
public HttpResult<List<TerminalVO.TerminalStatistics>> getCycleStatistics(@RequestBody TerminalParam.TerminalCycleParam param) {
|
||||
String methodDescribe = getMethodDescribe("getCycleStatistics");
|
||||
List<TerminalVO.TerminalStatistics> list = pmsTerminalDetectionService.getCycleStatistics(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.njcn.process.mapper;
|
||||
|
||||
import com.njcn.process.pojo.param.TerminalParam;
|
||||
import com.njcn.process.pojo.po.PmsTerminalDetection;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.process.pojo.vo.TerminalVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2023-02-27
|
||||
*/
|
||||
public interface PmsTerminalDetectionMapper extends BaseMapper<PmsTerminalDetection> {
|
||||
|
||||
/***
|
||||
* 终端入网检测台账统计
|
||||
* @author wr
|
||||
* @date 2023-02-28 11:14
|
||||
* @param param
|
||||
* @param ids
|
||||
* @return List<TerminalStatistics>
|
||||
*/
|
||||
List<TerminalVO.TerminalStatistics> selectStatistics(@Param("param") TerminalParam param,
|
||||
@Param("ids") List<String> ids);
|
||||
|
||||
/***
|
||||
* 周期检测统计
|
||||
* @author wr
|
||||
* @date 2023-02-28 11:14
|
||||
* @param param
|
||||
* @param ids
|
||||
* @return List<TerminalStatistics>
|
||||
*/
|
||||
List<TerminalVO.TerminalStatistics> selectCycleStatistics(@Param("param") TerminalParam.TerminalCycleParam param,
|
||||
@Param("ids") List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.process.mapper.PmsTerminalDetectionMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.njcn.process.pojo.po.PmsTerminalDetection">
|
||||
<id column="Id" property="id" />
|
||||
<result column="Create_Time" property="createTime" />
|
||||
<result column="Update_Time" property="updateTime" />
|
||||
<result column="Name" property="name" />
|
||||
<result column="Org_Name" property="orgName" />
|
||||
<result column="Org_No" property="orgNo" />
|
||||
<result column="Manufacture" property="manufacture" />
|
||||
<result column="Install_place" property="installPlace" />
|
||||
<result column="Inspection_Name" property="inspectionName" />
|
||||
<result column="Test_results" property="testResults" />
|
||||
<result column="Inspection_Time" property="inspectionTime" />
|
||||
<result column="Next_inspection_Time" property="nextInspectionTime" />
|
||||
<result column="Inspection_Report" property="inspectionReport" />
|
||||
<result column="Original_Report" property="originalReport" />
|
||||
<result column="Status" property="status" />
|
||||
<result column="Create_By" property="createBy" />
|
||||
<result column="Update_By" property="updateBy" />
|
||||
</resultMap>
|
||||
<select id="selectStatistics" resultType="com.njcn.process.pojo.vo.TerminalVO$TerminalStatistics">
|
||||
SELECT
|
||||
Org_No,
|
||||
count( id ) AS count
|
||||
FROM
|
||||
pms_terminal_detection
|
||||
<where>
|
||||
<if test="ids != null and ids.size > 0">
|
||||
AND org_no IN
|
||||
<foreach collection='ids' item='item' index="index" open='(' separator=',' close=')'>
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="param!=null and param.startTime != null and param.startTime !=''">
|
||||
AND data_date >= #{param.startTime}
|
||||
</if>
|
||||
<if test="param!=null and param.endTime != null and param.endTime != ''">
|
||||
AND data_date <= #{param.endTime}
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY
|
||||
Org_No
|
||||
</select>
|
||||
<select id="selectCycleStatistics" resultType="com.njcn.process.pojo.vo.TerminalVO$TerminalStatistics">
|
||||
SELECT
|
||||
Org_No,
|
||||
count( id ) AS count
|
||||
FROM
|
||||
pms_terminal_detection
|
||||
<where>
|
||||
Next_inspection_Time <= DATE_FORMAT( now(), '%Y-%m-%d' )
|
||||
<if test="ids != null and ids.size > 0">
|
||||
AND org_no IN
|
||||
<foreach collection='ids' item='item' index="index" open='(' separator=',' close=')'>
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="param!=null and param.testResults != null and param.testResults !=''">
|
||||
AND Test_results = #{param.testResults}
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY
|
||||
Org_No
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.njcn.process.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.process.pojo.param.TerminalParam;
|
||||
import com.njcn.process.pojo.po.PmsTerminalDetection;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.process.pojo.vo.TerminalVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 终端检测监督
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2023-02-27
|
||||
*/
|
||||
public interface PmsTerminalDetectionService extends IService<PmsTerminalDetection> {
|
||||
|
||||
/***
|
||||
* 终端检测监督列表
|
||||
* @author wr
|
||||
* @date 2023-02-27 13:58
|
||||
* @param param
|
||||
* @return Page<?>
|
||||
*/
|
||||
Page<TerminalVO> terminalPage(TerminalParam.TerminalPageParam param);
|
||||
|
||||
/***
|
||||
* 导出模板
|
||||
* @author wr
|
||||
* @date 2023-02-27 16:14
|
||||
* @param response
|
||||
*/
|
||||
void exportTemplate(HttpServletResponse response);
|
||||
|
||||
/***
|
||||
* 终端检测监督单条新增
|
||||
* @author wr
|
||||
* @date 2023-02-27 14:02
|
||||
* @param param
|
||||
* @return Boolean
|
||||
*/
|
||||
Boolean insertTerminal(TerminalParam param);
|
||||
/***
|
||||
* 终端检测监督批量新增
|
||||
* @author wr
|
||||
* @date 2023-02-27 14:02
|
||||
* @param file
|
||||
* @param response
|
||||
* @return Boolean
|
||||
*/
|
||||
void batchTerminal(MultipartFile file, HttpServletResponse response);
|
||||
|
||||
/***
|
||||
* 终端检测监督修改
|
||||
* @author wr
|
||||
* @date 2023-02-27 14:02
|
||||
* @param param
|
||||
* @return Boolean
|
||||
*/
|
||||
Boolean updateTerminal(TerminalParam.TerminalUpdateParam param);
|
||||
|
||||
/***
|
||||
* 终端检测监督删除
|
||||
* @author wr
|
||||
* @date 2023-02-27 14:02
|
||||
* @param ids
|
||||
* @return Boolean
|
||||
*/
|
||||
Boolean dekTerminal(List<String> ids);
|
||||
|
||||
/***
|
||||
* 批量导入检测报告
|
||||
* @author wr
|
||||
* @date 2023-02-28 9:55
|
||||
* @param files
|
||||
* @param response
|
||||
*/
|
||||
void importReport(MultipartFile[] files, HttpServletResponse response);
|
||||
|
||||
/***
|
||||
* 终端入网检测台账统计
|
||||
* @author wr
|
||||
* @date 2023-02-28 11:03
|
||||
* @param param
|
||||
* @return List<TerminalStatistics>
|
||||
*/
|
||||
List<TerminalVO.TerminalStatistics> getStatistics(TerminalParam param);
|
||||
|
||||
/***
|
||||
* 周期检测统计
|
||||
* @author wr
|
||||
* @date 2023-02-28 13:48
|
||||
* @param param
|
||||
* @return List<TerminalStatistics>
|
||||
*/
|
||||
List<TerminalVO.TerminalStatistics> getCycleStatistics(TerminalParam.TerminalCycleParam param);
|
||||
}
|
||||
@@ -0,0 +1,289 @@
|
||||
package com.njcn.process.service.impl;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.device.pms.enums.PmsDeviceResponseEnum;
|
||||
import com.njcn.poi.excel.ExcelUtil;
|
||||
import com.njcn.poi.util.PoiUtil;
|
||||
import com.njcn.process.pojo.dto.excel.TerminalExcel;
|
||||
import com.njcn.process.pojo.param.TerminalParam;
|
||||
import com.njcn.process.pojo.po.PmsTerminalDetection;
|
||||
import com.njcn.process.mapper.PmsTerminalDetectionMapper;
|
||||
import com.njcn.process.pojo.vo.TerminalVO;
|
||||
import com.njcn.process.service.PmsTerminalDetectionService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.process.utils.ExcelStyleUtil;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.pojo.dto.DeptDTO;
|
||||
import com.njcn.user.pojo.vo.PvTerminalTreeVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 终端检测监督
|
||||
* </p>
|
||||
*
|
||||
* @author wr
|
||||
* @since 2023-02-27
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PmsTerminalDetectionServiceImpl extends ServiceImpl<PmsTerminalDetectionMapper, PmsTerminalDetection> implements PmsTerminalDetectionService {
|
||||
|
||||
private final DeptFeignClient deptFeignClient;
|
||||
|
||||
@Override
|
||||
public Page<TerminalVO> terminalPage(TerminalParam.TerminalPageParam param) {
|
||||
Page<PmsTerminalDetection> pageList = this.page(new Page<>(param.getPageNum(), param.getPageSize())
|
||||
, new LambdaQueryWrapper<PmsTerminalDetection>()
|
||||
.eq(PmsTerminalDetection::getStatus, DataStateEnum.ENABLE.getCode())
|
||||
// .in(RMpWpPowerDetailQ::getMeasurementPointId, monitorIds)
|
||||
.le(param.getType() != 0, PmsTerminalDetection::getNextInspectionTime, LocalDate.now())
|
||||
// .le(StrUtil.isNotBlank(param.getEndTime()), PmsTerminalDetection::getDataDate, param.getEndTime())
|
||||
);
|
||||
List<TerminalVO> rMpWpPowerDetailVOS2 = BeanUtil.copyToList(pageList.getRecords(), TerminalVO.class);
|
||||
|
||||
Page<TerminalVO> page = BeanUtil.copyProperties(pageList, Page.class);
|
||||
page.setRecords(rMpWpPowerDetailVOS2);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportTemplate(HttpServletResponse response) {
|
||||
ExportParams exportParams = new ExportParams("批量导入模板(请严格按照模板标准填入数据)", "终端入网检测录入信息");
|
||||
exportParams.setStyle(ExcelStyleUtil.class);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, TerminalExcel.class, new ArrayList<TerminalExcel>());
|
||||
PoiUtil.exportFileByWorkbook(workbook, "终端入网检测录入模板.xlsx", response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean insertTerminal(TerminalParam param) {
|
||||
PmsTerminalDetection detection = BeanUtil.copyProperties(param, PmsTerminalDetection.class);
|
||||
|
||||
return this.save(detection);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchTerminal(MultipartFile file, HttpServletResponse response) {
|
||||
ImportParams params = new ImportParams();
|
||||
params.setHeadRows(1);
|
||||
params.setTitleRows(1);
|
||||
params.setNeedVerify(true);
|
||||
//第一个sheet为台账信息
|
||||
params.setStartSheetIndex(0);
|
||||
params.setSheetNum(1);
|
||||
try {
|
||||
ExcelImportResult<TerminalExcel> terminalList = ExcelImportUtil.importExcelMore(file.getInputStream(), TerminalExcel.class, params);
|
||||
//如果存在非法数据,将不合格的数据导出
|
||||
if (terminalList.isVerifyFail()) {
|
||||
PoiUtil.exportFileByWorkbook(terminalList.getFailWorkbook(), "非法终端入网检测录入信息.xlsx", response);
|
||||
} else {
|
||||
saveTerminalBase(terminalList.getList());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateTerminal(TerminalParam.TerminalUpdateParam param) {
|
||||
long count = this.count(new LambdaQueryWrapper<PmsTerminalDetection>()
|
||||
.ne(PmsTerminalDetection::getId, param.getId())
|
||||
.and(wrapper ->
|
||||
wrapper.eq(PmsTerminalDetection::getName, param.getName())
|
||||
)
|
||||
|
||||
);
|
||||
if (count > 0) {
|
||||
throw new BusinessException(PmsDeviceResponseEnum.MODEL_NAME_REPEAT);
|
||||
}
|
||||
PmsTerminalDetection detection = BeanUtil.copyProperties(param, PmsTerminalDetection.class);
|
||||
return this.updateById(detection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean dekTerminal(List<String> ids) {
|
||||
return this.removeByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importReport(MultipartFile[] files, HttpServletResponse response) {
|
||||
PmsTerminalDetection detection;
|
||||
List<PmsTerminalDetection> data = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
detection = new PmsTerminalDetection();
|
||||
//上传的文件名称
|
||||
String originalFilename = files[i].getOriginalFilename();
|
||||
String[] split = originalFilename.split("-");
|
||||
if (split.length > 0) {
|
||||
if (split[1].substring(0, split[1].indexOf(".")).equals("检测报告")) {
|
||||
//todo 文件名称
|
||||
detection.setInspectionReport(originalFilename);
|
||||
detection.setId(split[0]);
|
||||
data.add(detection);
|
||||
}
|
||||
if (split[1].substring(0, split[1].indexOf(".")).equals("原始数据报告")) {
|
||||
//todo 文件名称
|
||||
detection.setOriginalReport(originalFilename);
|
||||
detection.setId(split[0]);
|
||||
data.add(detection);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(data)) {
|
||||
Map<String, PmsTerminalDetection> terminalMap = data.stream().collect(Collectors.toMap(PmsTerminalDetection::getId, Function.identity(), (key1, key2) -> {
|
||||
//检测报告告为空
|
||||
if (key1.getInspectionReport() == null) {
|
||||
key1.setInspectionReport(key2.getInspectionReport());
|
||||
}
|
||||
//原始数据报告为空
|
||||
if (key1.getOriginalReport() == null) {
|
||||
key1.setOriginalReport(key2.getOriginalReport());
|
||||
}
|
||||
return key1;
|
||||
}));
|
||||
List<PmsTerminalDetection> updateTerminal = new ArrayList<>(terminalMap.values());
|
||||
this.updateBatchById(updateTerminal);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TerminalVO.TerminalStatistics> getStatistics(TerminalParam param) {
|
||||
List<DeptDTO> deptDTOS = deptFeignClient.getDepSonDetailByDeptId(param.getId()).getData();
|
||||
List<String> ids = deptDTOS.stream().map(DeptDTO::getCode).collect(Collectors.toList());
|
||||
List<TerminalVO.TerminalStatistics> list = this.baseMapper.selectStatistics(param, ids);
|
||||
return getStatisticsList(deptDTOS, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TerminalVO.TerminalStatistics> getCycleStatistics(TerminalParam.TerminalCycleParam param) {
|
||||
List<DeptDTO> deptDTOS = deptFeignClient.getDepSonDetailByDeptId(param.getId()).getData();
|
||||
List<String> ids = deptDTOS.stream().map(DeptDTO::getCode).collect(Collectors.toList());
|
||||
List<TerminalVO.TerminalStatistics> list = this.baseMapper.selectCycleStatistics(param, ids);
|
||||
return getStatisticsList(deptDTOS, list);
|
||||
}
|
||||
|
||||
/***
|
||||
* 统计数据,单位名称赋值
|
||||
* @author wr
|
||||
* @date 2023-02-28 14:04
|
||||
* @param deptDTOS
|
||||
* @param list
|
||||
* @return List<TerminalStatistics>
|
||||
*/
|
||||
private List<TerminalVO.TerminalStatistics> getStatisticsList(List<DeptDTO> deptDTOS, List<TerminalVO.TerminalStatistics> list) {
|
||||
Map<String, String> deptMap = deptDTOS.stream().collect(Collectors.toMap(DeptDTO::getCode, DeptDTO::getName));
|
||||
for (TerminalVO.TerminalStatistics t : list) {
|
||||
if (deptMap.containsKey(t.getOrgNo())) {
|
||||
t.setOrgName(deptMap.get(t.getOrgNo()));
|
||||
}
|
||||
}
|
||||
Map<String, TerminalVO.TerminalStatistics> listMap = list.stream().collect(
|
||||
Collectors.toMap(TerminalVO.TerminalStatistics::getOrgNo, Function.identity()));
|
||||
|
||||
List<DeptDTO> notDeptDTOS = deptDTOS.stream().filter(r -> !listMap.containsKey(r.getCode()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(notDeptDTOS)) {
|
||||
TerminalVO.TerminalStatistics notTerminal;
|
||||
for (DeptDTO notDeptDTO : notDeptDTOS) {
|
||||
notTerminal = new TerminalVO.TerminalStatistics();
|
||||
notTerminal.setOrgNo(notDeptDTO.getCode());
|
||||
notTerminal.setOrgName(notDeptDTO.getName());
|
||||
notTerminal.setCount(0);
|
||||
list.add(notTerminal);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/***
|
||||
* 批量导入t终端入网检测信息
|
||||
* @author wr
|
||||
* @date 2023-02-28 14:05
|
||||
* @param terminalList
|
||||
*/
|
||||
private void saveTerminalBase(List<TerminalExcel> terminalList) {
|
||||
List<PvTerminalTreeVO> data = deptFeignClient.allDeptList().getData();
|
||||
List<PmsTerminalDetection> list = this.list(new LambdaQueryWrapper<PmsTerminalDetection>()
|
||||
.eq(PmsTerminalDetection::getStatus, DataStateEnum.ENABLE.getCode()));
|
||||
Map<String, PmsTerminalDetection> terminalMap = list.stream().collect(Collectors.toMap(p -> p.getId(), Function.identity()));
|
||||
List<TerminalExcel.TerminalExcelMsg> terminalExcelMsg = new ArrayList<>();
|
||||
//错误数据初始化
|
||||
TerminalExcel.TerminalExcelMsg msg = null;
|
||||
List<PmsTerminalDetection> pmsTerminalDetections = new ArrayList<>();
|
||||
//正常数据
|
||||
PmsTerminalDetection detection;
|
||||
for (TerminalExcel terminalExcel : terminalList) {
|
||||
//根据终端编号和终端名称判断数据是否又重复终端
|
||||
if (terminalMap.containsKey(terminalExcel.getId())) {
|
||||
addMsg(terminalExcelMsg, terminalExcel, msg, "当前终端编号重复");
|
||||
continue;
|
||||
}
|
||||
String orgName = terminalExcel.getOrgName();
|
||||
//判断
|
||||
List<PvTerminalTreeVO> deptList = data.stream().filter(d ->
|
||||
d.getName().indexOf(orgName) > -1
|
||||
).collect(Collectors.toList());
|
||||
if (CollectionUtil.isEmpty(deptList)) {
|
||||
addMsg(terminalExcelMsg, terminalExcel, msg, "当前部门机构不存在");
|
||||
continue;
|
||||
}
|
||||
if (deptList.size() > 1) {
|
||||
addMsg(terminalExcelMsg, terminalExcel, msg, "当前部门机构模糊匹配出现多个部门,请详细编写部门机构");
|
||||
continue;
|
||||
}
|
||||
detection = BeanUtil.copyProperties(terminalExcel, PmsTerminalDetection.class);
|
||||
detection.setOrgNo(deptList.get(0).getCode());
|
||||
detection.setOrgName(deptList.get(0).getName());
|
||||
detection.setTestResults(0);
|
||||
detection.setStatus(1);
|
||||
pmsTerminalDetections.add(detection);
|
||||
}
|
||||
|
||||
this.saveBatch(pmsTerminalDetections);
|
||||
|
||||
//错误信息不为空,则以excel的形式输出到前台
|
||||
if (CollectionUtil.isNotEmpty(terminalExcelMsg)) {
|
||||
ExcelUtil.exportExcel("失败列表.xlsx", TerminalExcel.TerminalExcelMsg.class, terminalExcelMsg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
* 错误信息,赋值
|
||||
* @author wr
|
||||
* @date 2023-02-28 14:05
|
||||
* @param terminalExcelMsg
|
||||
* @param terminalExcel
|
||||
* @param msg
|
||||
* @param content
|
||||
*/
|
||||
private void addMsg(List<TerminalExcel.TerminalExcelMsg> terminalExcelMsg, TerminalExcel terminalExcel, TerminalExcel.TerminalExcelMsg msg, String content) {
|
||||
msg = BeanUtil.copyProperties(terminalExcel, TerminalExcel.TerminalExcelMsg.class);
|
||||
msg.setMsg(content);
|
||||
terminalExcelMsg.add(msg);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user