09-25-试验任务完善试验记录
This commit is contained in:
		| @ -110,11 +110,11 @@ public class OpsInspectionTestTaskController extends BaseController { | ||||
|      * | ||||
|      * @param projectId 项目ID | ||||
|      */ | ||||
| //    @SaCheckPermission("inspection:testTask:record") | ||||
| //    @GetMapping("/record") | ||||
| //    public R<Object> record(@RequestParam Long projectId){ | ||||
| //        return opsInspectionTestTaskService.record(projectId); | ||||
| //    } | ||||
|     @SaCheckPermission("inspection:testTask:record") | ||||
|     @GetMapping("/record") | ||||
|     public R<Object> record(@RequestParam Long projectId){ | ||||
|         return opsInspectionTestTaskService.record(projectId); | ||||
|     } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -10,36 +10,36 @@ public class OpsInspectionTestTaskRecord { | ||||
|     /** | ||||
|      * 本月完成数 | ||||
|      */ | ||||
|     private Long finishCount; | ||||
|     private String finishCount; | ||||
|  | ||||
|     /** | ||||
|      * 上月增加数 | ||||
|      */ | ||||
|     private BigDecimal finishCountAdd; | ||||
|     private String finishCountAdd; | ||||
|  | ||||
|     /** | ||||
|      * 本月通过率 | ||||
|      */ | ||||
|     private BigDecimal passValue; | ||||
|     private String passValue; | ||||
|  | ||||
|     /** | ||||
|      * 通过增长率 | ||||
|      */ | ||||
|     private BigDecimal passValueAdd; | ||||
|     private String passValueAdd; | ||||
|  | ||||
|     /** | ||||
|      * 待分析数 | ||||
|      */ | ||||
|     private Long failCount; | ||||
|     private String failCount; | ||||
|  | ||||
|     /** | ||||
|      * 平均测试时间 | ||||
|      */ | ||||
|     private Long averageTestTime; | ||||
|     private String averageTestTime; | ||||
|  | ||||
|     /** | ||||
|      * 平均测试时间数增长率 | ||||
|      */ | ||||
|     private BigDecimal averageTestTimeAdd; | ||||
|     private String averageTestTimeAdd; | ||||
|  | ||||
| } | ||||
|  | ||||
| @ -175,12 +175,17 @@ public class OpsInspectionOrderServiceImpl implements IOpsInspectionOrderService | ||||
|         } | ||||
|  | ||||
|         List<String> urls = new ArrayList<>(); | ||||
|         List<Long> nodeIds = new ArrayList<>(); | ||||
|  | ||||
|         for (Long id : ids) { | ||||
|             OpsInspectionOrderVo vo = queryById(id); | ||||
|             if (vo != null){ | ||||
|                 if (vo.getFileUrl()!=null) { | ||||
|                     urls.add(vo.getFileUrl()); | ||||
|                 } | ||||
|                 for (String nodeId : List.of(vo.getNodeIds().split(","))) { | ||||
|                     nodeIds.add(Long.valueOf(nodeId)); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @ -191,6 +196,11 @@ public class OpsInspectionOrderServiceImpl implements IOpsInspectionOrderService | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         //同时删除节点 | ||||
|         if (!nodeIds.isEmpty()) { | ||||
|             nodeMapper.deleteByIds(nodeIds); | ||||
|         } | ||||
|  | ||||
|         return baseMapper.deleteByIds(ids) > 0; | ||||
|     } | ||||
|  | ||||
|  | ||||
| @ -34,6 +34,7 @@ import java.math.RoundingMode; | ||||
| import java.time.LocalDate; | ||||
| import java.time.ZoneId; | ||||
| import java.util.*; | ||||
| import java.util.concurrent.TimeUnit; | ||||
|  | ||||
| /** | ||||
|  * 运维-巡检-试验任务Service业务层处理 | ||||
| @ -269,7 +270,7 @@ public class OpsInspectionTestTaskServiceImpl implements IOpsInspectionTestTaskS | ||||
|         Long totalTestTime = 0L; | ||||
|  | ||||
|         for (OpsInspectionTestTaskVo opsInspectionTestTaskVo : list) { | ||||
|             if (opsInspectionTestTaskVo.getPlanFinishTime().after(startDate) && opsInspectionTestTaskVo.getPlanFinishTime().before(endDate) && opsInspectionTestTaskVo.getStatus().equals("5")){ | ||||
|             if (opsInspectionTestTaskVo.getPlanBeginTime().after(startDate) && opsInspectionTestTaskVo.getPlanFinishTime().before(endDate) && opsInspectionTestTaskVo.getStatus().equals("5")){ | ||||
|                 finishCount++; | ||||
|                 totalTestTime += opsInspectionTestTaskVo.getPlanFinishTime().getTime() - opsInspectionTestTaskVo.getPlanBeginTime().getTime(); | ||||
|             } | ||||
| @ -277,22 +278,51 @@ public class OpsInspectionTestTaskServiceImpl implements IOpsInspectionTestTaskS | ||||
|                 failCount++; | ||||
|             } | ||||
|         } | ||||
|         record.setFinishCount(finishCount); | ||||
|         record.setFailCount(failCount); | ||||
|         record.setPassValue(BigDecimal.valueOf(finishCount).divide(BigDecimal.valueOf(list.size()), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))); | ||||
|         record.setAverageTestTime(totalTestTime/finishCount); | ||||
|  | ||||
|         record.setFinishCount(String.valueOf(finishCount)); | ||||
|         record.setFailCount(String.valueOf(failCount)); | ||||
|         record.setPassValue(String.valueOf(BigDecimal.valueOf(finishCount).divide(BigDecimal.valueOf(list.size()), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100")))); | ||||
|         record.setAverageTestTime(BigDecimal.valueOf((double) TimeUnit.MILLISECONDS.toMinutes(totalTestTime) / finishCount).toString()); | ||||
|  | ||||
|         //统计上一月的数据 | ||||
|         firstDay = LocalDate.now().minusMonths(1).withDayOfMonth(1); | ||||
|         lastDay = firstDay.plusMonths(1).minusDays(1); | ||||
|         Date finalEndDate = Date.from(firstDay.atStartOfDay(ZoneId.systemDefault()).toInstant()); | ||||
|         Date finalStartDate  = Date.from(lastDay.atTime(23, 59, 59).atZone(ZoneId.systemDefault()).toInstant()); | ||||
|         Date finalEndDate = Date.from(LocalDate.now().minusMonths(1).withDayOfMonth(1).atStartOfDay(ZoneId.systemDefault()).toInstant()); | ||||
|         Date finalStartDate  = Date.from(LocalDate.now().minusMonths(1).withDayOfMonth(1).plusMonths(1).minusDays(1).atTime(23, 59, 59).atZone(ZoneId.systemDefault()).toInstant()); | ||||
|  | ||||
|         //上月数据列表 | ||||
|         List<OpsInspectionTestTaskVo> lastMonth = list.stream().filter(testTaskVo -> testTaskVo.getPlanBeginTime().before(finalEndDate) && testTaskVo.getPlanFinishTime().after(finalStartDate)) | ||||
|         List<OpsInspectionTestTaskVo> lastMonth = list.stream().filter(testTaskVo -> testTaskVo.getPlanFinishTime().before(finalEndDate) && testTaskVo.getPlanBeginTime().after(finalStartDate)) | ||||
|             .toList(); | ||||
|  | ||||
|         //上月完成数 | ||||
|         finishCount = 0L; | ||||
|         //上月实验通过率 | ||||
|         BigDecimal passValue = BigDecimal.ZERO; | ||||
|         //上月平均实验时长 | ||||
|         totalTestTime = 0L; | ||||
|  | ||||
|         for (OpsInspectionTestTaskVo vo : lastMonth) { | ||||
|             if (vo.getStatus().equals("5")){ | ||||
|                 finishCount++; | ||||
|                 totalTestTime += vo.getPlanFinishTime().getTime() - vo.getPlanBeginTime().getTime(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         //完成数增长率 | ||||
|         BigDecimal wcszzl = BigDecimal.valueOf(Double.parseDouble(record.getFinishCount())).divide(BigDecimal.valueOf(finishCount), 2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100.00)); | ||||
|         record.setFinishCountAdd(wcszzl.toString()); | ||||
|  | ||||
|         //上月通过率 | ||||
|         if(BigDecimal.valueOf(lastMonth.size()).compareTo(BigDecimal.ZERO) > 0) { | ||||
|             passValue = BigDecimal.valueOf(Double.valueOf(finishCount)).divide(BigDecimal.valueOf(lastMonth.size()), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100")); | ||||
|         } | ||||
|         //进行比较 得出通过增长率 | ||||
|         BigDecimal tgzzl = BigDecimal.valueOf(Double.parseDouble(record.getPassValue())).divide(passValue, 2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100.00)); | ||||
|         record.setPassValueAdd(tgzzl.toString()); | ||||
|  | ||||
|         //上月平均实验时间 | ||||
|         BigDecimal sypjsj = BigDecimal.valueOf((double) TimeUnit.MILLISECONDS.toMinutes(totalTestTime) / finishCount); | ||||
|         //平均时间增长率 | ||||
|         BigDecimal sysjzzl = sypjsj.divide(BigDecimal.valueOf(Double.parseDouble(record.getAverageTestTime())), 2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100.00)); | ||||
|         record.setAverageTestTimeAdd(sysjzzl.toString()); | ||||
|  | ||||
|         return R.ok(record); | ||||
|     } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user