09-30-更新时允许为空字段
This commit is contained in:
@ -29,6 +29,6 @@ mybatis-plus:
|
|||||||
# 逻辑未删除值
|
# 逻辑未删除值
|
||||||
logicNotDeleteValue: 0
|
logicNotDeleteValue: 0
|
||||||
insertStrategy: NOT_NULL
|
insertStrategy: NOT_NULL
|
||||||
# updateStrategy: NOT_NULL
|
updateStrategy: NOT_NULL
|
||||||
updateStrategy: ALWAYS
|
# updateStrategy: ALWAYS
|
||||||
whereStrategy: NOT_NULL
|
whereStrategy: NOT_NULL
|
||||||
|
|||||||
@ -206,6 +206,28 @@ public class OpsInspectionTaskServiceImpl implements IOpsInspectionTaskService {
|
|||||||
if(isValid){
|
if(isValid){
|
||||||
//TODO 做一些业务上的校验,判断是否需要校验
|
//TODO 做一些业务上的校验,判断是否需要校验
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//删除任务时删除节点和节点问题
|
||||||
|
List<Long> problemIds = new ArrayList<>();
|
||||||
|
LambdaQueryWrapper<OpsInspectionTaskProblem> 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<OpsInspectionTaskProblemVo> problemVos = problemMapper.selectVoList(problemLambdaQueryWrapper);
|
||||||
|
if (problemVos!= null && !problemVos.isEmpty()){
|
||||||
|
problemMapper.deleteByIds(problemVos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return baseMapper.deleteByIds(ids) > 0;
|
return baseMapper.deleteByIds(ids) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +284,7 @@ public class OpsInspectionTaskServiceImpl implements IOpsInspectionTaskService {
|
|||||||
Date finalStartDate = startDate;
|
Date finalStartDate = startDate;
|
||||||
Date finalEndDate = endDate;
|
Date finalEndDate = endDate;
|
||||||
|
|
||||||
//仅统计在本月完成的巡检
|
//仅统计在指定时间段内完成的巡检任务
|
||||||
List<OpsInspectionTaskVo> finishList = opsInspectionTaskVos.stream()
|
List<OpsInspectionTaskVo> finishList = opsInspectionTaskVos.stream()
|
||||||
.filter(taskVo -> taskVo.getFinishTime() != null && taskVo.getStartTime() != null && taskVo.getFinishTime().before(finalEndDate) && taskVo.getStartTime().after(finalStartDate))
|
.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))
|
.filter(vo -> vo.getCreateTime().after(finalStartDate) && vo.getCreateTime().before(finalEndDate))
|
||||||
@ -271,15 +293,10 @@ public class OpsInspectionTaskServiceImpl implements IOpsInspectionTaskService {
|
|||||||
|
|
||||||
//发现问题数 通过createTime统计
|
//发现问题数 通过createTime统计
|
||||||
int problemCount = 0;
|
int problemCount = 0;
|
||||||
// List<OpsInspectionTaskVo> problemList = opsInspectionTaskVos.stream()
|
|
||||||
// .filter(taskVo -> taskVo.getCreateTime().after(finalStartDate) && taskVo.getCreateTime().before(finalEndDate))
|
|
||||||
// .toList();
|
|
||||||
// if (!problemList.isEmpty()){
|
|
||||||
// problemCount = problemList.size();
|
|
||||||
// }
|
|
||||||
LambdaQueryWrapper<OpsInspectionTaskProblem> problemLqw = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<OpsInspectionTaskProblem> problemLqw = new LambdaQueryWrapper<>();
|
||||||
problemLqw.eq(OpsInspectionTaskProblem::getProjectId, projectId);
|
problemLqw.eq(OpsInspectionTaskProblem::getProjectId, projectId);
|
||||||
problemLqw.between(OpsInspectionTaskProblem::getCreateTime, finalStartDate, finalEndDate);
|
problemLqw.ge(OpsInspectionTaskProblem::getCreateTime, finalStartDate);
|
||||||
|
problemLqw.le(OpsInspectionTaskProblem::getCreateTime, finalEndDate);
|
||||||
|
|
||||||
List<OpsInspectionTaskProblemVo> problemVos = problemMapper.selectVoList(problemLqw);
|
List<OpsInspectionTaskProblemVo> problemVos = problemMapper.selectVoList(problemLqw);
|
||||||
if (problemVos != null && !problemVos.isEmpty()){
|
if (problemVos != null && !problemVos.isEmpty()){
|
||||||
@ -339,8 +356,9 @@ public class OpsInspectionTaskServiceImpl implements IOpsInspectionTaskService {
|
|||||||
|
|
||||||
//巡检完成率
|
//巡检完成率
|
||||||
BigDecimal xjwcl;
|
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()
|
.toList()
|
||||||
.size();
|
.size();
|
||||||
//完成 / 巡检数 * 100
|
//完成 / 巡检数 * 100
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package org.dromara.inspection.service.impl;
|
package org.dromara.inspection.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.dromara.common.core.domain.R;
|
import org.dromara.common.core.domain.R;
|
||||||
@ -150,6 +151,10 @@ public class OpsInspectionTestTaskServiceImpl implements IOpsInspectionTestTaskS
|
|||||||
OpsInspectionTestTask update = MapstructUtils.convert(bo, OpsInspectionTestTask.class);
|
OpsInspectionTestTask update = MapstructUtils.convert(bo, OpsInspectionTestTask.class);
|
||||||
validEntityBeforeSave(update);
|
validEntityBeforeSave(update);
|
||||||
|
|
||||||
|
if(update == null){
|
||||||
|
return R.fail();
|
||||||
|
}
|
||||||
|
|
||||||
OpsInspectionTestTaskVo oldVo = baseMapper.selectVoById(bo.getId());
|
OpsInspectionTestTaskVo oldVo = baseMapper.selectVoById(bo.getId());
|
||||||
|
|
||||||
if (!oldVo.getStatus().equals("5") && bo.getStatus().equals("5")){
|
if (!oldVo.getStatus().equals("5") && bo.getStatus().equals("5")){
|
||||||
@ -170,7 +175,34 @@ public class OpsInspectionTestTaskServiceImpl implements IOpsInspectionTestTaskS
|
|||||||
return R.fail("节点尚未全部完成");
|
return R.fail("节点尚未全部完成");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean b = baseMapper.updateById(update) > 0;
|
|
||||||
|
// 使用 UpdateWrapper 更新包括 null 的字段
|
||||||
|
UpdateWrapper<OpsInspectionTestTask> 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){
|
if (b){
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
Reference in New Issue
Block a user