正式检测-左侧检测项、检测详情弹窗-表单内容

This commit is contained in:
caozehui
2024-12-31 14:42:19 +08:00
parent 3bc797f23e
commit 14f3ab52bb
22 changed files with 652 additions and 23 deletions

View File

@@ -52,8 +52,6 @@ import java.util.Map;
public class AdPlanController extends BaseController {
private final IAdPlanService adPlanService;
private final IPqDevService pqDevService;
private final IDictDataService dictDataService;
@OperateInfo
@PostMapping("/list")
@@ -166,7 +164,7 @@ public class AdPlanController extends BaseController {
} else {
List<AdPlanExcel.ImportData> adPlanExcelList = adPlanExcelResult.getList();
if (ObjectUtil.isNotEmpty(adPlanExcelList)) {
adPlanService.importData(patternId,adPlanExcelList);
adPlanService.importData(patternId, adPlanExcelList);
}
}
} catch (Exception e) {
@@ -186,5 +184,16 @@ public class AdPlanController extends BaseController {
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
// }
@OperateInfo
@GetMapping("/getBigTestItem")
@ApiOperation("获取检测大项数据")
@ApiImplicitParam(name = "id", value = "检测计划id", required = true)
public HttpResult<List<Map<String, String>>> getBigTestItem(@RequestParam("planId") String planId) {
String methodDescribe = getMethodDescribe("getBigTestItem");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, planId);
List<Map<String, String>> result = adPlanService.getBigTestItem(planId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -77,4 +77,19 @@ public interface IAdPlanService extends IService<AdPlan> {
*/
void importData(String patternId, List<AdPlanExcel.ImportData> adPlanExcelList);
/**
* 可视化
*
* @param planList 检测计划列表
*/
void visualize(List<AdPlan> planList);
/**
* 获取检测大项
*
* @param planId 检测计划Id
* @return
*/
List<Map<String, String>> getBigTestItem(String planId);
}

View File

@@ -15,6 +15,8 @@ import com.njcn.gather.device.device.pojo.po.PqDev;
import com.njcn.gather.device.device.service.IPqDevService;
import com.njcn.gather.device.err.service.IPqErrSysService;
import com.njcn.gather.device.pojo.enums.*;
import com.njcn.gather.device.script.pojo.po.PqScriptDtls;
import com.njcn.gather.device.script.service.IPqScriptDtlsService;
import com.njcn.gather.device.script.service.IPqScriptService;
import com.njcn.gather.device.source.pojo.po.PqSource;
import com.njcn.gather.device.source.service.IPqSourceService;
@@ -26,7 +28,9 @@ import com.njcn.gather.plan.pojo.vo.AdPlanExcel;
import com.njcn.gather.plan.pojo.vo.AdPlanVO;
import com.njcn.gather.plan.service.IAdPlanService;
import com.njcn.gather.plan.service.IAdPlanSourceService;
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
import com.njcn.gather.system.dictionary.service.IDictDataService;
import com.njcn.gather.system.dictionary.service.IDictTreeService;
import com.njcn.web.factory.PageFactory;
import com.njcn.web.utils.ExcelUtil;
import lombok.RequiredArgsConstructor;
@@ -53,6 +57,8 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
private final IPqDevService pqDevService;
private final IDictDataService dictDataService;
private final IPqSourceService pqSourceService;
private final IPqScriptDtlsService pqScriptDtlsService;
private final IDictTreeService dictTreeService;
@Override
public Page<AdPlanVO> listAdPlan(AdPlanParam.QueryParam queryParam) {
@@ -168,7 +174,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
child.put("id", adPlan.getId());
child.put("pid", adPlan.getFatherPlanId());
child.put("name", adPlan.getName());
child.put("timeCheck",adPlan.getTimeCheck());
child.put("timeCheck", adPlan.getTimeCheck());
children.add(child);
});
}
@@ -266,12 +272,8 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
return queryWrapper;
}
/**
* 可视化
*
* @param planList 检测计划列表
*/
private void visualize(List<AdPlan> planList) {
@Override
public void visualize(List<AdPlan> planList) {
planList.forEach(adPlan -> {
// if (StrUtil.isNotBlank(adPlan.getPattern())) {
// adPlan.setPattern(dictDataService.getDictDataById(adPlan.getPattern()).getName());
@@ -295,6 +297,30 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
});
}
@Override
public List<Map<String, String>> getBigTestItem(String planId) {
List<Map<String, String>> result = new ArrayList<>();
AdPlan adPlan = this.getById(planId);
String scriptId = adPlan.getScriptId();
List<PqScriptDtls> scriptDtlsList = pqScriptDtlsService.listPqScriptDtlByScriptId(scriptId);
Map<String, List<PqScriptDtls>> collect = scriptDtlsList.stream()
.sorted(Comparator.comparing(PqScriptDtls::getIndex))
.collect(Collectors.groupingBy(PqScriptDtls::getScriptType, LinkedHashMap::new, Collectors.toList()));
collect.forEach((key, value) -> {
Map<String, String> map = new HashMap<>();
map.put("id", key);
DictTree dictTree = dictTreeService.getById(key);
map.put("code", dictTree.getCode());
map.put("scriptName", dictTree.getName());
result.add(map);
});
return result;
}
/**
* 逆向可视化
*
@@ -327,5 +353,4 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
private Integer generateCode() {
return this.count() + 1;
}
}

View File

@@ -0,0 +1,61 @@
package com.njcn.gather.result.controller;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.LogUtil;
import com.njcn.gather.result.pojo.param.ResultParam;
import com.njcn.gather.result.pojo.vo.FormContentVO;
import com.njcn.gather.result.pojo.vo.TreeDataVO;
import com.njcn.gather.result.service.IResultService;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.HttpResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author caozehui
* @data 2024-12-30
*/
@Slf4j
@Api(tags = "检测结果")
@RestController
@RequestMapping("/result")
@RequiredArgsConstructor
public class ResultController extends BaseController {
private final IResultService resultService;
@OperateInfo
@PostMapping("/formContent")
@ApiOperation("查询检测结果-表单内容")
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
public HttpResult<FormContentVO> formContent(@RequestBody @Validated ResultParam.QueryParam queryParam) {
String methodDescribe = getMethodDescribe("formContent");
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
FormContentVO result = resultService.getFormContent(queryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo
@PostMapping("/treeData")
@ApiOperation("查询检测结果-树形结构的具体检测项")
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
public HttpResult<List<TreeDataVO>> treeData(@RequestBody @Validated ResultParam.QueryParam queryParam) {
String methodDescribe = getMethodDescribe("treeData");
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
}

View File

@@ -0,0 +1,37 @@
package com.njcn.gather.result.pojo.param;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.device.pojo.constant.DevValidMessage;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
/**
* @author caozehui
* @data 2024-12-30
*/
@Data
public class ResultParam {
@Data
public static class QueryParam {
@ApiModelProperty(value = "检测计划Id", required = true)
@NotBlank(message = DevValidMessage.PLAN_ID_NOT_NULL)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PLAN_ID_FORMAT_ERROR)
private String planId;
// 脚本类型当为null时表示查询所有脚本类型否则只查询指定脚本类型
private String scriptType;
@ApiModelProperty(value = "设备Id", required = true)
@NotBlank(message = DevValidMessage.DEV_ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.DEV_ID_FORMAT_ERROR)
private String deviceId;
// 通道号,当为-1时表示查询所有通道号否则只查询指定通道号
private String chnNum;
}
}

View File

@@ -0,0 +1,24 @@
package com.njcn.gather.result.pojo.vo;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* @author caozehui
* @data 2024-12-30
*/
@Data
public class FormContentVO {
private String scriptName;
private String errorSysName;
private String dataRule;
private String deviceName;
private List<Map<String, String>> chnList;
}

View File

@@ -0,0 +1,16 @@
package com.njcn.gather.result.pojo.vo;
import lombok.Data;
/**
* @author caozehui
* @data 2024-12-31
*/
@Data
public class TreeDataVO {
private String id;
private String scriptName;
private TreeDataVO[] children;
}

View File

@@ -0,0 +1,12 @@
package com.njcn.gather.result.service;
import com.njcn.gather.result.pojo.param.ResultParam;
import com.njcn.gather.result.pojo.vo.FormContentVO;
/**
* @author caozehui
* @data 2024-12-30
*/
public interface IResultService {
FormContentVO getFormContent(ResultParam.QueryParam queryParam);
}

View File

@@ -0,0 +1,109 @@
package com.njcn.gather.result.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
import com.njcn.gather.device.device.service.IPqDevService;
import com.njcn.gather.device.script.service.IPqScriptDtlsService;
import com.njcn.gather.plan.pojo.po.AdPlan;
import com.njcn.gather.plan.service.IAdPlanService;
import com.njcn.gather.result.pojo.param.ResultParam;
import com.njcn.gather.result.pojo.vo.FormContentVO;
import com.njcn.gather.result.service.IResultService;
import com.njcn.gather.storage.pojo.po.AdBaseResult;
import com.njcn.gather.storage.service.AdHarmonicService;
import com.njcn.gather.storage.service.AdNonHarmonicService;
import com.njcn.gather.system.config.service.ISysTestConfigService;
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
import com.njcn.gather.system.dictionary.service.IDictTreeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author caozehui
* @data 2024-12-30
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class ResultServiceImpl implements IResultService {
private final IAdPlanService adPlanService;
private final ISysTestConfigService sysTestConfigService;
private final IPqDevService pqDevService;
private final AdNonHarmonicService adNonHarmonicService;
private final AdHarmonicService adHarmonicService;
private final IPqScriptDtlsService pqScriptDtlsService;
private final IDictTreeService dictTreeService;
// 谐波类code取树形字典表中的code
private final List<String> HARMONIC_TYPE_CODE = Arrays.asList("HV", "HI", "HP", "HSV", "HSI");
@Override
public FormContentVO getFormContent(ResultParam.QueryParam queryParam) {
FormContentVO formContentVO = new FormContentVO();
AdPlan plan = adPlanService.getById(queryParam.getPlanId());
String scriptId = null;
if (ObjectUtil.isNotNull(plan)) {
scriptId = plan.getScriptId();
adPlanService.visualize(Collections.singletonList(plan));
}
formContentVO.setScriptName(plan.getScriptId());
formContentVO.setErrorSysName(plan.getErrorSysId());
formContentVO.setDataRule(sysTestConfigService.getConfig().getDataRule());
formContentVO.setDeviceName(pqDevService.getById(queryParam.getDeviceId()).getName());
List<Map<String, String>> chnList = new ArrayList<>();
List<AdBaseResult> allResultList = new ArrayList<>();
if (ObjectUtil.isNotNull(queryParam.getScriptType())) { //只查询指定的脚本类型
List<Integer> indexList = pqScriptDtlsService.getIndexList(queryParam.getScriptType(), scriptId);
DictTree dictTree = dictTreeService.getById(queryParam.getScriptType());
if (HARMONIC_TYPE_CODE.contains(dictTree.getCode())) {
String prefix = "ad_harmonic_result_";
DynamicTableNameHandler.setTableName(prefix + plan.getCode());
allResultList.addAll(adHarmonicService.get(scriptId, indexList, queryParam.getDeviceId(), queryParam.getChnNum()));
DynamicTableNameHandler.remove();
} else {
String prefix = "ad_non_harmonic_result_";
DynamicTableNameHandler.setTableName(prefix + plan.getCode());
allResultList.addAll(adNonHarmonicService.get(scriptId, indexList, queryParam.getDeviceId(), queryParam.getChnNum()));
DynamicTableNameHandler.remove();
}
} else { //查询所有的脚本类型
String prefix = "ad_harmonic_result_";
DynamicTableNameHandler.setTableName(prefix + plan.getCode());
allResultList.addAll(adHarmonicService.get(scriptId, null, queryParam.getDeviceId(), queryParam.getChnNum()));
DynamicTableNameHandler.remove();
prefix = "ad_non_harmonic_result_";
DynamicTableNameHandler.setTableName(prefix + plan.getCode());
allResultList.addAll(adNonHarmonicService.get(scriptId, null, queryParam.getDeviceId(), queryParam.getChnNum()));
DynamicTableNameHandler.remove();
}
if(ObjectUtil.isNotEmpty(allResultList)){
Map<String, List<AdBaseResult>> chnMap = allResultList.stream().collect(
Collectors.groupingBy(obj -> obj.getMonitorId().substring(obj.getMonitorId().lastIndexOf("_") + 1))
);
chnMap.forEach((chn, list) -> {
Map<String, String> map = new HashMap<>();
map.put("value", chn);
long count = list.stream().filter(obj -> obj.getResultFlag() == 0).count();
map.put("label", count > 0 ? "0" : "1");
chnList.add(map);
});
}
chnList.sort(Comparator.comparingInt(o -> Integer.parseInt(o.get("value"))));
formContentVO.setChnList(chnList);
return formContentVO;
}
}