From 1ab49c41786c4e1eb76d481c296066cd140a3e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E5=B1=95=E8=88=AA?= <2426745133@qq.com> Date: Tue, 30 Sep 2025 10:29:31 +0800 Subject: [PATCH] =?UTF-8?q?09-30-=E6=9B=B4=E6=96=B0=E6=97=B6=E5=85=81?= =?UTF-8?q?=E8=AE=B8=E4=B8=BA=E7=A9=BA=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/common-mybatis.yml | 4 +- .../impl/OpsInspectionTaskServiceImpl.java | 38 ++++++++++++++----- .../OpsInspectionTestTaskServiceImpl.java | 34 ++++++++++++++++- 3 files changed, 63 insertions(+), 13 deletions(-) diff --git a/ruoyi-common/ruoyi-common-mybatis/src/main/resources/common-mybatis.yml b/ruoyi-common/ruoyi-common-mybatis/src/main/resources/common-mybatis.yml index 9927d4f..c078ab2 100644 --- a/ruoyi-common/ruoyi-common-mybatis/src/main/resources/common-mybatis.yml +++ b/ruoyi-common/ruoyi-common-mybatis/src/main/resources/common-mybatis.yml @@ -29,6 +29,6 @@ mybatis-plus: # 逻辑未删除值 logicNotDeleteValue: 0 insertStrategy: NOT_NULL -# updateStrategy: NOT_NULL - updateStrategy: ALWAYS + updateStrategy: NOT_NULL +# updateStrategy: ALWAYS whereStrategy: NOT_NULL diff --git a/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/impl/OpsInspectionTaskServiceImpl.java b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/impl/OpsInspectionTaskServiceImpl.java index 1d8745e..21f8de8 100644 --- a/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/impl/OpsInspectionTaskServiceImpl.java +++ b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/impl/OpsInspectionTaskServiceImpl.java @@ -206,6 +206,28 @@ public class OpsInspectionTaskServiceImpl implements IOpsInspectionTaskService { if(isValid){ //TODO 做一些业务上的校验,判断是否需要校验 } + + //删除任务时删除节点和节点问题 + List problemIds = new ArrayList<>(); + LambdaQueryWrapper problemLambdaQueryWrapper = new LambdaQueryWrapper<>(); + + for (Long id : ids) { + //删除节点 + OpsInspectionTaskVo taskVo = baseMapper.selectVoById(id); + if (taskVo!= null){ + if (taskVo.getNodeIds()!=null){ + nodeMapper.deleteByIds(Arrays.stream(taskVo.getNodeIds().split(",")).toList()); + } + } + //删除问题 + problemLambdaQueryWrapper.clear(); + problemLambdaQueryWrapper.eq(OpsInspectionTaskProblem::getId, id); + List problemVos = problemMapper.selectVoList(problemLambdaQueryWrapper); + if (problemVos!= null && !problemVos.isEmpty()){ + problemMapper.deleteByIds(problemVos); + } + } + return baseMapper.deleteByIds(ids) > 0; } @@ -262,7 +284,7 @@ public class OpsInspectionTaskServiceImpl implements IOpsInspectionTaskService { Date finalStartDate = startDate; Date finalEndDate = endDate; - //仅统计在本月完成的巡检 + //仅统计在指定时间段内完成的巡检任务 List finishList = opsInspectionTaskVos.stream() .filter(taskVo -> taskVo.getFinishTime() != null && taskVo.getStartTime() != null && taskVo.getFinishTime().before(finalEndDate) && taskVo.getStartTime().after(finalStartDate)) .filter(vo -> vo.getCreateTime().after(finalStartDate) && vo.getCreateTime().before(finalEndDate)) @@ -271,15 +293,10 @@ public class OpsInspectionTaskServiceImpl implements IOpsInspectionTaskService { //发现问题数 通过createTime统计 int problemCount = 0; -// List problemList = opsInspectionTaskVos.stream() -// .filter(taskVo -> taskVo.getCreateTime().after(finalStartDate) && taskVo.getCreateTime().before(finalEndDate)) -// .toList(); -// if (!problemList.isEmpty()){ -// problemCount = problemList.size(); -// } LambdaQueryWrapper problemLqw = new LambdaQueryWrapper<>(); problemLqw.eq(OpsInspectionTaskProblem::getProjectId, projectId); - problemLqw.between(OpsInspectionTaskProblem::getCreateTime, finalStartDate, finalEndDate); + problemLqw.ge(OpsInspectionTaskProblem::getCreateTime, finalStartDate); + problemLqw.le(OpsInspectionTaskProblem::getCreateTime, finalEndDate); List problemVos = problemMapper.selectVoList(problemLqw); if (problemVos != null && !problemVos.isEmpty()){ @@ -339,8 +356,9 @@ public class OpsInspectionTaskServiceImpl implements IOpsInspectionTaskService { //巡检完成率 BigDecimal xjwcl; - //本月巡检数 - int byxjs = opsInspectionTaskVos.stream().filter(vo -> vo.getCreateTime().after(finalStartDate) && vo.getCreateTime().before(finalEndDate)) + //统计指定时间段内创建的巡检任务数 + int byxjs = opsInspectionTaskVos.stream() + .filter(vo -> !vo.getCreateTime().before(finalStartDate) && !vo.getCreateTime().after(finalEndDate)) .toList() .size(); //完成 / 巡检数 * 100 diff --git a/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/impl/OpsInspectionTestTaskServiceImpl.java b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/impl/OpsInspectionTestTaskServiceImpl.java index db9a80d..48b06e2 100644 --- a/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/impl/OpsInspectionTestTaskServiceImpl.java +++ b/ruoyi-modules/xny-ops/src/main/java/org/dromara/inspection/service/impl/OpsInspectionTestTaskServiceImpl.java @@ -1,5 +1,6 @@ package org.dromara.inspection.service.impl; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import lombok.Data; import org.apache.dubbo.config.annotation.DubboReference; import org.dromara.common.core.domain.R; @@ -150,6 +151,10 @@ public class OpsInspectionTestTaskServiceImpl implements IOpsInspectionTestTaskS OpsInspectionTestTask update = MapstructUtils.convert(bo, OpsInspectionTestTask.class); validEntityBeforeSave(update); + if(update == null){ + return R.fail(); + } + OpsInspectionTestTaskVo oldVo = baseMapper.selectVoById(bo.getId()); if (!oldVo.getStatus().equals("5") && bo.getStatus().equals("5")){ @@ -170,7 +175,34 @@ public class OpsInspectionTestTaskServiceImpl implements IOpsInspectionTestTaskS return R.fail("节点尚未全部完成"); } } - boolean b = baseMapper.updateById(update) > 0; + + // 使用 UpdateWrapper 更新包括 null 的字段 + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq("id", bo.getId()); + + // 手动设置需要更新的字段,包括可能为 null 的字段 + updateWrapper.set("task_name", update.getTaskName()) + .set("test_object", update.getTestObject()) + .set("begin_time", update.getBeginTime()) + .set("end_time", update.getEndTime()) + .set("time_info", update.getTimeInfo()) + .set("person", update.getPerson()) + .set("status", update.getStatus()) + .set("test_plan_id", update.getTestPlanId()) + .set("test_setting", update.getTestSetting()) + .set("plan_begin_time", update.getPlanBeginTime()) + .set("fail_reason", update.getFailReason()) + .set("fail_time", update.getFailTime()) + .set("fail_phase", update.getFailPhase()) + .set("faile_analyze", update.getFaileAnalyze()) + .set("faile_tips", update.getFaileTips()) + .set("test_long_time", update.getTestLongTime()) + .set("test_final", update.getTestFinal()) + .set("final_info", update.getFinalInfo()) + .set("pause_for", update.getPauseFor()) + .set("pause_time", update.getPauseTime()); + + boolean b = baseMapper.update(updateWrapper) > 0; if (b){ return R.ok(); }else {