微调
This commit is contained in:
@@ -148,9 +148,9 @@ public class AdPlanController extends BaseController {
|
||||
@ApiImplicitParam(name = "file", value = "检测计划数据文件", required = true),
|
||||
@ApiImplicitParam(name = "pattern", value = "模式Id", required = true)
|
||||
})
|
||||
public HttpResult<Object> importData(@RequestParam("file") MultipartFile file, @RequestParam("pattern") String pattern, HttpServletResponse response) {
|
||||
public HttpResult<Object> importData(@RequestParam("file") MultipartFile file, @RequestParam("patternId") String patternId, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importData");
|
||||
LogUtil.njcnDebug(log, "{},上传文件为:{}, 模式Id为:{}", methodDescribe, file.getOriginalFilename(), pattern);
|
||||
LogUtil.njcnDebug(log, "{},上传文件为:{}, 模式Id为:{}", methodDescribe, file.getOriginalFilename(), patternId);
|
||||
|
||||
ImportParams params = new ImportParams();
|
||||
params.setHeadRows(2);
|
||||
@@ -166,25 +166,25 @@ public class AdPlanController extends BaseController {
|
||||
} else {
|
||||
List<AdPlanExcel.ImportData> adPlanExcelList = adPlanExcelResult.getList();
|
||||
if (ObjectUtil.isNotEmpty(adPlanExcelList)) {
|
||||
adPlanService.importData(pattern,adPlanExcelList);
|
||||
adPlanService.importData(patternId,adPlanExcelList);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL, e.getMessage());
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/getPieData")
|
||||
@ApiOperation("获取饼状图数据")
|
||||
@ApiImplicitParam(name = "id", value = "检测计划id", required = true)
|
||||
public HttpResult<List<List<Map<String, Object>>>> getPieData(@RequestParam("planId") String planId) {
|
||||
String methodDescribe = getMethodDescribe("getPieData");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, planId);
|
||||
List<List<Map<String, Object>>> result = pqDevService.getPieData(planId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
// @OperateInfo
|
||||
// @GetMapping("/getPieData")
|
||||
// @ApiOperation("获取饼状图数据")
|
||||
// @ApiImplicitParam(name = "id", value = "检测计划id", required = true)
|
||||
// public HttpResult<List<List<Map<String, Object>>>> getPieData(@RequestParam("planId") String planId) {
|
||||
// String methodDescribe = getMethodDescribe("getPieData");
|
||||
// LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, planId);
|
||||
// List<List<Map<String, Object>>> result = pqDevService.getPieData(planId);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -25,19 +25,19 @@ public class AdPlanExcel {
|
||||
@NotBlank(message = DevValidMessage.NAME_NOT_BLANK)
|
||||
private String name;
|
||||
|
||||
@Excel(name = "检测源", width = 40, needMerge = true, orderNum = "2")
|
||||
@Excel(name = "检测源", width = 40, needMerge = true, orderNum = "1")
|
||||
@NotBlank(message = DevValidMessage.SOURC_NOT_BLANK)
|
||||
private String source;
|
||||
|
||||
@Excel(name = "数据源", width = 20, needMerge = true, orderNum = "4")
|
||||
@Excel(name = "数据源", width = 20, needMerge = true, orderNum = "2")
|
||||
@NotBlank(message = DevValidMessage.DATASOURCE_NOT_BLANK)
|
||||
private String datasourceId;
|
||||
|
||||
@Excel(name = "脚本", width = 50, needMerge = true, orderNum = "5")
|
||||
@Excel(name = "脚本", width = 50, needMerge = true, orderNum = "3")
|
||||
@NotBlank(message = DevValidMessage.SCRIPT_NOT_BLANK)
|
||||
private String scriptId;
|
||||
|
||||
@Excel(name = "误差体系", width = 30, needMerge = true, orderNum = "6")
|
||||
@Excel(name = "误差体系", width = 30, needMerge = true, orderNum = "4")
|
||||
@NotBlank(message = DevValidMessage.ERRORSYS_NOT_BLANK)
|
||||
private String errorSysId;
|
||||
|
||||
@@ -45,40 +45,52 @@ public class AdPlanExcel {
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ExportData extends AdPlanExcel {
|
||||
@Excel(name = "模式", width = 20, needMerge = true, orderNum = "1")
|
||||
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
|
||||
private String pattern;
|
||||
// @Excel(name = "模式", width = 20, needMerge = true, orderNum = "1")
|
||||
// @NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
|
||||
// private String pattern;
|
||||
|
||||
@Excel(name = "父计划id", width = 25, needMerge = true, orderNum = "3")
|
||||
private String fatherPlanId;
|
||||
// @Excel(name = "父计划id", width = 25, needMerge = true, orderNum = "3")
|
||||
// private String fatherPlanId;
|
||||
|
||||
@Excel(name = "是否做守时检测(否\\是)", width = 15, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "7")
|
||||
@Excel(name = "是否做守时检测(否\\是)", width = 15, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "5")
|
||||
private Integer timeCheck;
|
||||
|
||||
@Excel(name = "检测状态(未检\\检测中\\检测完成)", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true, orderNum = "8")
|
||||
@Excel(name = "检测状态(未检\\检测中\\检测完成)", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true, orderNum = "6")
|
||||
private Integer testState;
|
||||
|
||||
@Excel(name = "报告生成状态(未生成\\部分生成\\全部生成)", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true, orderNum = "9")
|
||||
@Excel(name = "报告生成状态(未生成\\部分生成\\全部生成)", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true, orderNum = "7")
|
||||
private Integer reportState;
|
||||
|
||||
@Excel(name = "检测结果(不符合\\符合\\未检)", width = 10, replace = {"不符合_0", "符合_1", "未检_2"}, needMerge = true, orderNum = "10")
|
||||
@Excel(name = "检测结果(不符合\\符合\\未检)", width = 10, replace = {"不符合_0", "符合_1", "未检_2"}, needMerge = true, orderNum = "8")
|
||||
private Integer result;
|
||||
|
||||
@Excel(name = "数据表后缀", width = 20, needMerge = true, orderNum = "11")
|
||||
private Integer code;
|
||||
// @Excel(name = "数据表后缀", width = 20, needMerge = true, orderNum = "11")
|
||||
// private Integer code;
|
||||
|
||||
@ExcelCollection(name = "绑定的设备", orderNum = "12")
|
||||
@ExcelCollection(name = "绑定的设备", orderNum = "9")
|
||||
private List<AdPlanExcel.BoundExportData> devices;
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ImportData extends AdPlanExcel {
|
||||
@Excel(name = "是否做守时检测(否\\是)", width = 15, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "7")
|
||||
@NotNull(message = DevValidMessage.TIMECHECK_NOT_BLANK)
|
||||
@Excel(name = "是否做守时检测(否\\是)", width = 15, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "5")
|
||||
@NotBlank(message = DevValidMessage.TIMECHECK_NOT_BLANK)
|
||||
private String timeCheck;
|
||||
|
||||
@ExcelCollection(name = "绑定的设备", orderNum = "13")
|
||||
@Excel(name = "检测状态(未检\\检测中\\检测完成)", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true, orderNum = "6")
|
||||
@NotBlank(message = DevValidMessage.TEST_STATE_NOT_NULL)
|
||||
private String testState;
|
||||
|
||||
@Excel(name = "报告生成状态(未生成\\部分生成\\全部生成)", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true, orderNum = "7")
|
||||
@NotBlank(message = DevValidMessage.REPORT_STATE_NOT_NULL)
|
||||
private String reportState;
|
||||
|
||||
@Excel(name = "检测结果(不符合\\符合\\未检)", width = 10, replace = {"不符合_0", "符合_1", "未检_2"}, needMerge = true, orderNum = "8")
|
||||
@NotBlank(message = DevValidMessage.CHECK_RESULT_STATE_NOT_NULL)
|
||||
private String result;
|
||||
|
||||
@ExcelCollection(name = "绑定的设备", orderNum = "9")
|
||||
private List<AdPlanExcel.BoundImportData> devices;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean addAdPlan(AdPlanParam param) {
|
||||
AdPlan adPlan = new AdPlan();
|
||||
BeanUtil.copyProperties(param, adPlan);
|
||||
@@ -115,6 +116,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean updateAdPlan(AdPlanParam.UpdateParam param) {
|
||||
AdPlan adPlan = new AdPlan();
|
||||
BeanUtil.copyProperties(param, adPlan);
|
||||
@@ -123,18 +125,14 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
|
||||
// 修改检测计划、检测源关联
|
||||
adPlanSourceService.updateAdPlanSource(param.getId(), param.getSourceIds());
|
||||
// 修改时,只有未检测过的设备才可以修改绑定设备
|
||||
List<String> unCheckedIds = pqDevService.listUnchecked().stream().map(PqDev::getId).collect(Collectors.toList());
|
||||
if (unCheckedIds.containsAll(param.getDevIds())) {
|
||||
pqDevService.bind(param.getId(), param.getDevIds());
|
||||
} else {
|
||||
throw new BusinessException(DevResponseEnum.HAS_NOT_UNCHECKED_DEVICE);
|
||||
}
|
||||
|
||||
pqDevService.bind(param.getId(), param.getDevIds());
|
||||
|
||||
return this.updateById(adPlan);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean deleteAdPlan(List<String> ids) {
|
||||
for (String id : ids) {
|
||||
PqDevParam.QueryParam queryParam = new PqDevParam.QueryParam();
|
||||
@@ -274,14 +272,14 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
*/
|
||||
private void visualize(List<AdPlan> planList) {
|
||||
planList.forEach(adPlan -> {
|
||||
if (StrUtil.isNotBlank(adPlan.getPattern())) {
|
||||
adPlan.setPattern(dictDataService.getDictDataById(adPlan.getPattern()).getName());
|
||||
}
|
||||
if (CommonEnum.FATHER_ID.getValue().equals(adPlan.getFatherPlanId())) {
|
||||
adPlan.setFatherPlanId(CommonEnum.FATHER_ID.getMsg());
|
||||
} else {
|
||||
adPlan.setFatherPlanId(this.getById(adPlan.getFatherPlanId()).getName());
|
||||
}
|
||||
// if (StrUtil.isNotBlank(adPlan.getPattern())) {
|
||||
// adPlan.setPattern(dictDataService.getDictDataById(adPlan.getPattern()).getName());
|
||||
// }
|
||||
// if (CommonEnum.FATHER_ID.getValue().equals(adPlan.getFatherPlanId())) {
|
||||
// adPlan.setFatherPlanId(CommonEnum.FATHER_ID.getMsg());
|
||||
// } else {
|
||||
// adPlan.setFatherPlanId(this.getById(adPlan.getFatherPlanId()).getName());
|
||||
// }
|
||||
if (StrUtil.isNotBlank(adPlan.getDatasourceId())) {
|
||||
String[] datasourceIds = adPlan.getDatasourceId().split(StrUtil.COMMA);
|
||||
adPlan.setDatasourceId(Arrays.stream(datasourceIds).map(id -> DataSourceEnum.getMsgByValue(id)).collect(Collectors.joining(StrUtil.COMMA)));
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.njcn.gather.device.source.pojo.po.PqSource;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -31,6 +32,7 @@ public class AdPlanSourceServiceImpl extends ServiceImpl<AdPlanSourceMapper, AdP
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean addAdPlanSource(String planId, List<String> sourceIds) {
|
||||
List<AdPlanSource> adPlanSourceList = new ArrayList<>();
|
||||
for (String sourceId : sourceIds) {
|
||||
@@ -40,6 +42,7 @@ public class AdPlanSourceServiceImpl extends ServiceImpl<AdPlanSourceMapper, AdP
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean deleteAdPlanSourceByPlanIds(List<String> planIds) {
|
||||
QueryWrapper<AdPlanSource> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("ad_plan_source.Plan_Id", planIds);
|
||||
@@ -47,6 +50,7 @@ public class AdPlanSourceServiceImpl extends ServiceImpl<AdPlanSourceMapper, AdP
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean updateAdPlanSource(String planId, List<String> sourceIds) {
|
||||
this.deleteAdPlanSourceByPlanIds(Collections.singletonList(planId));
|
||||
this.addAdPlanSource(planId, sourceIds);
|
||||
|
||||
Reference in New Issue
Block a user