|
|
|
@@ -14,6 +14,7 @@ import cn.hutool.core.util.ZipUtil;
|
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
@@ -21,6 +22,8 @@ import com.njcn.common.pojo.enums.common.DataStateEnum;
|
|
|
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
|
|
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
|
|
|
import com.njcn.common.pojo.exception.BusinessException;
|
|
|
|
import com.njcn.common.pojo.exception.BusinessException;
|
|
|
|
import com.njcn.common.pojo.poi.PullDown;
|
|
|
|
import com.njcn.common.pojo.poi.PullDown;
|
|
|
|
|
|
|
|
import com.njcn.gather.detection.pojo.po.AdPair;
|
|
|
|
|
|
|
|
import com.njcn.gather.detection.service.IAdPariService;
|
|
|
|
import com.njcn.gather.device.mapper.PqDevMapper;
|
|
|
|
import com.njcn.gather.device.mapper.PqDevMapper;
|
|
|
|
import com.njcn.gather.device.pojo.enums.*;
|
|
|
|
import com.njcn.gather.device.pojo.enums.*;
|
|
|
|
import com.njcn.gather.device.pojo.param.PqDevParam;
|
|
|
|
import com.njcn.gather.device.pojo.param.PqDevParam;
|
|
|
|
@@ -88,6 +91,7 @@ import org.apache.poi.xddf.usermodel.chart.*;
|
|
|
|
import org.apache.poi.xssf.usermodel.*;
|
|
|
|
import org.apache.poi.xssf.usermodel.*;
|
|
|
|
import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarSer;
|
|
|
|
import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarSer;
|
|
|
|
import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
|
|
|
|
import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
|
|
|
|
|
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
@@ -131,6 +135,9 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
|
|
|
private final IPqErrSysDtlsService pqErrSysDtlsService;
|
|
|
|
private final IPqErrSysDtlsService pqErrSysDtlsService;
|
|
|
|
private final IPqStandardDevService pqStandardDevService;
|
|
|
|
private final IPqStandardDevService pqStandardDevService;
|
|
|
|
private final IPqIcdPathService pqIcdPathService;
|
|
|
|
private final IPqIcdPathService pqIcdPathService;
|
|
|
|
|
|
|
|
private final IAdPariService adPairService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<AdPlanVO> listAdPlan(AdPlanParam.QueryParam queryParam) {
|
|
|
|
public List<AdPlanVO> listAdPlan(AdPlanParam.QueryParam queryParam) {
|
|
|
|
@@ -225,10 +232,6 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
|
|
|
|
|
|
|
|
|
|
|
adPlan.setState(DataStateEnum.ENABLE.getCode());
|
|
|
|
adPlan.setState(DataStateEnum.ENABLE.getCode());
|
|
|
|
|
|
|
|
|
|
|
|
// 默认为顶级检测计划
|
|
|
|
|
|
|
|
adPlan.setFatherPlanId(CommonEnum.FATHER_ID.getValue());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isBlank(param.getFatherPlanId())) {
|
|
|
|
if (StrUtil.isBlank(param.getFatherPlanId())) {
|
|
|
|
// 默认为顶级检测计划
|
|
|
|
// 默认为顶级检测计划
|
|
|
|
adPlan.setFatherPlanId(CommonEnum.FATHER_ID.getValue());
|
|
|
|
adPlan.setFatherPlanId(CommonEnum.FATHER_ID.getValue());
|
|
|
|
@@ -1558,7 +1561,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
|
|
|
subPlanMetaData.setIcdPathList(pqIcdPathList);
|
|
|
|
subPlanMetaData.setIcdPathList(pqIcdPathList);
|
|
|
|
|
|
|
|
|
|
|
|
// 获取检测计划绑定的被检设备数据
|
|
|
|
// 获取检测计划绑定的被检设备数据
|
|
|
|
List<PqDev> devList = pqDevService.list(new QueryWrapper<PqDev>().eq("Plan_Id", planId));
|
|
|
|
List<PqDev> devList = pqDevService.list(new LambdaQueryWrapper<PqDev>().eq(PqDev::getPlanId, planId));
|
|
|
|
if (CollUtil.isNotEmpty(devList)) {
|
|
|
|
if (CollUtil.isNotEmpty(devList)) {
|
|
|
|
List<String> devIds = devList.stream().map(PqDev::getId).collect(Collectors.toList());
|
|
|
|
List<String> devIds = devList.stream().map(PqDev::getId).collect(Collectors.toList());
|
|
|
|
// 被检设备监测点
|
|
|
|
// 被检设备监测点
|
|
|
|
@@ -1796,4 +1799,67 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void exportPlanCheckDataZip(String planId, HttpServletResponse response) {
|
|
|
|
|
|
|
|
AdPlanCheckDataVO planCheckDataVO = new AdPlanCheckDataVO();
|
|
|
|
|
|
|
|
// 获取检测计划基本数据
|
|
|
|
|
|
|
|
AdPlan plan = this.getById(planId);
|
|
|
|
|
|
|
|
planCheckDataVO.setPlan(plan);
|
|
|
|
|
|
|
|
// 获取检测计划绑定的被检设备数据
|
|
|
|
|
|
|
|
List<PqDev> devList = pqDevService.list(new LambdaQueryWrapper<PqDev>().eq(PqDev::getPlanId, planId));
|
|
|
|
|
|
|
|
planCheckDataVO.setDevList(devList);
|
|
|
|
|
|
|
|
List<String> devIds = devList.stream().map(PqDev::getId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
// 被检设备状态统计
|
|
|
|
|
|
|
|
List<PqDevSub> devSubList = pqDevSubService.list(new LambdaQueryWrapper<PqDevSub>().in(PqDevSub::getDevId, devIds));
|
|
|
|
|
|
|
|
planCheckDataVO.setDevSubList(devSubList);
|
|
|
|
|
|
|
|
// 设备通道匹对关系
|
|
|
|
|
|
|
|
List<AdPair> pairList = adPairService.list(new LambdaQueryWrapper<AdPair>().eq(AdPair::getPlanId, planId));
|
|
|
|
|
|
|
|
planCheckDataVO.setPairList(pairList);
|
|
|
|
|
|
|
|
// 获取计划检测结果数据表以及数据
|
|
|
|
|
|
|
|
Integer code = plan.getCode();
|
|
|
|
|
|
|
|
Map<String, List<Map<String, Object>>> checkData = new HashMap<>();
|
|
|
|
|
|
|
|
List<String> dataTableNames = CollUtil.newArrayList("ad_harmonic_" + code, "ad_non_harmonic_" + code, "ad_harmonic_result_" + code, "ad_non_harmonic_result_" + code);
|
|
|
|
|
|
|
|
for (String dataTableName : dataTableNames) {
|
|
|
|
|
|
|
|
List<Map<String, Object>> dataList = jdbcTemplate.queryForList("select * from " + dataTableName);
|
|
|
|
|
|
|
|
checkData.put(dataTableName, dataList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
planCheckDataVO.setCheckData(checkData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 导出数据.zip文件
|
|
|
|
|
|
|
|
String jsonStr = JSONUtil.toJsonStr(planCheckDataVO);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
// 创建临时目录
|
|
|
|
|
|
|
|
File tempDir = FileUtil.mkdir(FileUtil.getTmpDirPath() + "export_" + System.currentTimeMillis() + "/");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建 JSON 文件
|
|
|
|
|
|
|
|
String jsonFileName = plan.getName() + ".json";
|
|
|
|
|
|
|
|
File jsonFile = FileUtil.file(tempDir, jsonFileName);
|
|
|
|
|
|
|
|
FileUtil.writeUtf8String(jsonStr, jsonFile);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建 ZIP 文件
|
|
|
|
|
|
|
|
String zipFileName = URLEncoder.encode(plan.getName() + "_检测数据.zip", "UTF-8");
|
|
|
|
|
|
|
|
File zipFile = FileUtil.file(tempDir, zipFileName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 先将json文件添加到zip中
|
|
|
|
|
|
|
|
ZipUtil.zip(jsonFile.getAbsolutePath(), zipFile.getAbsolutePath());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置响应头
|
|
|
|
|
|
|
|
response.reset();
|
|
|
|
|
|
|
|
response.setContentType("application/octet-stream;charset=UTF-8");
|
|
|
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=\"" + zipFileName + "\"");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 将 ZIP 文件写入响应
|
|
|
|
|
|
|
|
ServletOutputStream os = response.getOutputStream();
|
|
|
|
|
|
|
|
FileUtil.writeToStream(zipFile, os);
|
|
|
|
|
|
|
|
os.flush();
|
|
|
|
|
|
|
|
os.close();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 删除临时文件
|
|
|
|
|
|
|
|
FileUtil.del(tempDir);
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
log.error("导出计划检测数据.zip文件失败: ", e);
|
|
|
|
|
|
|
|
throw new BusinessException(CommonResponseEnum.FAIL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|