Browse Source

fix:对象取消和停用判断条件修改

master
luyie 2 weeks ago
parent
commit
801cf4d23f
  1. 43
      HZInfo-RIS-PXHD/hzinfo-ris-pxhd-service/hzinfo-inspect-service/src/main/java/org/springblade/hzinfo_inspect/obj/web/ObjectController.java
  2. 4
      HZInfo-RIS-PXHD/hzinfo-ris-pxhd-service/hzinfo-inspect-service/src/main/java/org/springblade/hzinfo_inspect/plan/mapper/PlanObjectTemplateMapper.java
  3. 22
      HZInfo-RIS-PXHD/hzinfo-ris-pxhd-service/hzinfo-inspect-service/src/main/java/org/springblade/hzinfo_inspect/plan/mapper/PlanObjectTemplateMapper.xml
  4. 5
      HZInfo-RIS-PXHD/hzinfo-ris-pxhd-service/hzinfo-inspect-service/src/main/java/org/springblade/hzinfo_inspect/plan/service/IPlanObjectTemplateService.java
  5. 10
      HZInfo-RIS-PXHD/hzinfo-ris-pxhd-service/hzinfo-inspect-service/src/main/java/org/springblade/hzinfo_inspect/plan/service/impl/PlanObjectTemplateServiceImpl.java
  6. 3
      HZInfo-RIS-PXHD/hzinfo-ris-pxhd-service/hzinfo-inspect-service/src/main/java/org/springblade/hzinfo_inspect/task/job/TaskJob.java

43
HZInfo-RIS-PXHD/hzinfo-ris-pxhd-service/hzinfo-inspect-service/src/main/java/org/springblade/hzinfo_inspect/obj/web/ObjectController.java

@ -7,18 +7,6 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import org.springblade.core.mp.support.Condition;
import org.springblade.hzinfo_inspect.obj.entity.ObjectDangerEntity;
import org.springblade.hzinfo_inspect.obj.entity.ObjectEntity;
import org.springblade.hzinfo_inspect.obj.entity.ObjectTemplateEntity;
import org.springblade.hzinfo_inspect.obj.entity.OtherObjectEntity;
import org.springblade.hzinfo_inspect.obj.services.*;
import org.springblade.hzinfo_inspect.obj.utils.CodeUtils;
import org.springblade.hzinfo_inspect.obj.vo.*;
import org.springblade.hzinfo_inspect.plan.PlanContants;
import org.springblade.hzinfo_inspect.plan.entity.PlanObjectTemplateEntity;
import org.springblade.hzinfo_inspect.plan.service.IPlanObjectTemplateService;
import org.springblade.hzinfo_inspect.task.TaskContants;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
@ -26,12 +14,24 @@ import lombok.AllArgsConstructor;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.BladeUser; import org.springblade.core.secure.BladeUser;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.hzinfo_inspect.obj.entity.ObjectDangerEntity;
import org.springblade.hzinfo_inspect.obj.entity.ObjectEntity;
import org.springblade.hzinfo_inspect.obj.entity.ObjectTemplateEntity;
import org.springblade.hzinfo_inspect.obj.entity.OtherObjectEntity;
import org.springblade.hzinfo_inspect.obj.services.*;
import org.springblade.hzinfo_inspect.obj.utils.CodeUtils;
import org.springblade.hzinfo_inspect.obj.vo.ObjectBatchVo;
import org.springblade.hzinfo_inspect.obj.vo.ObjectExcelInputData;
import org.springblade.hzinfo_inspect.obj.vo.ObjectListQueryVO;
import org.springblade.hzinfo_inspect.obj.vo.OtherObjectListQueryVO;
import org.springblade.hzinfo_inspect.plan.PlanContants;
import org.springblade.hzinfo_inspect.plan.service.IPlanObjectTemplateService;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -40,10 +40,9 @@ import javax.validation.Valid;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
@ -164,11 +163,8 @@ public class ObjectController extends BladeController {
@ApiOperation(value = "逻辑删除", notes = "传入ids") @ApiOperation(value = "逻辑删除", notes = "传入ids")
public R<Boolean> remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { public R<Boolean> remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
List<Long> delIdList = Func.toLongList(ids); List<Long> delIdList = Func.toLongList(ids);
QueryWrapper<PlanObjectTemplateEntity> qw = new QueryWrapper<>(); if (planObjectTemplateService.hasRelatedPlan(delIdList)) {
qw.lambda().in(PlanObjectTemplateEntity::getObjectId, delIdList).eq(PlanObjectTemplateEntity::getIsDeleted, 0); return R.fail("该巡检对象存在使用中任务,请删除任务,或等待任务完成");
int count = planObjectTemplateService.count(qw);
if (count > 0) {
return R.fail("该巡检对象已关联模板,请先取消关联");
} }
for (Long aLong : delIdList) { for (Long aLong : delIdList) {
objectTemplateService.remove(new QueryWrapper<ObjectTemplateEntity>() {{ objectTemplateService.remove(new QueryWrapper<ObjectTemplateEntity>() {{
@ -183,11 +179,8 @@ public class ObjectController extends BladeController {
@ApiOperation(value = "启用/停用", notes = "传入id,以及目标状态0-启用,1-停用") @ApiOperation(value = "启用/停用", notes = "传入id,以及目标状态0-启用,1-停用")
public R<Boolean> disableOrEnable(@RequestParam Long id, @RequestParam Integer status) { public R<Boolean> disableOrEnable(@RequestParam Long id, @RequestParam Integer status) {
if (status == 1) { if (status == 1) {
QueryWrapper<PlanObjectTemplateEntity> qw = new QueryWrapper<>(); if (planObjectTemplateService.hasRelatedPlan(Collections.singletonList(id))) {
qw.lambda().eq(PlanObjectTemplateEntity::getObjectId, id).eq(PlanObjectTemplateEntity::getIsDeleted, 0); return R.fail("该巡检对象存在使用中任务,请删除任务,或等待任务完成");
int count = planObjectTemplateService.count(qw);
if (count > 0) {
return R.fail("该巡检对象已关联模板,请先取消关联");
} }
} }
UpdateWrapper<ObjectEntity> ew = new UpdateWrapper<>(); UpdateWrapper<ObjectEntity> ew = new UpdateWrapper<>();

4
HZInfo-RIS-PXHD/hzinfo-ris-pxhd-service/hzinfo-inspect-service/src/main/java/org/springblade/hzinfo_inspect/plan/mapper/PlanObjectTemplateMapper.java

@ -2,8 +2,11 @@ package org.springblade.hzinfo_inspect.plan.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springblade.hzinfo_inspect.plan.entity.PlanObjectTemplateEntity; import org.springblade.hzinfo_inspect.plan.entity.PlanObjectTemplateEntity;
import java.util.List;
/** /**
* Mapper 接口 * Mapper 接口
* *
@ -12,4 +15,5 @@ import org.springblade.hzinfo_inspect.plan.entity.PlanObjectTemplateEntity;
@Mapper @Mapper
public interface PlanObjectTemplateMapper extends BaseMapper<PlanObjectTemplateEntity> { public interface PlanObjectTemplateMapper extends BaseMapper<PlanObjectTemplateEntity> {
long hasRelatedPlan(@Param("objectId") List<Long> objectId, @Param("dateStr") String dateStr);
} }

22
HZInfo-RIS-PXHD/hzinfo-ris-pxhd-service/hzinfo-inspect-service/src/main/java/org/springblade/hzinfo_inspect/plan/mapper/PlanObjectTemplateMapper.xml

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.springblade.hzinfo_inspect.plan.mapper.PlanObjectTemplateMapper">
<select id="hasRelatedPlan" resultType="java.lang.Long">
SELECT
COUNT(1) AS `count`
FROM
hz_st_re_plan_object_template AS `relation`,
hz_st_re_plan AS `plan`
WHERE
`relation`.`PLAN_ID` = `plan`.ID
AND `relation`.is_deleted = 0
AND `relation`.object_id in
<foreach collection="objectId" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
AND `plan`.IS_DELETED = 0
AND `plan`.`STATUS` != '4'
AND `plan`.END_TIME <![CDATA[ >= ]]> #{dateStr}
</select>
</mapper>

5
HZInfo-RIS-PXHD/hzinfo-ris-pxhd-service/hzinfo-inspect-service/src/main/java/org/springblade/hzinfo_inspect/plan/service/IPlanObjectTemplateService.java

@ -1,14 +1,15 @@
package org.springblade.hzinfo_inspect.plan.service; package org.springblade.hzinfo_inspect.plan.service;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import org.springblade.hzinfo_inspect.plan.entity.PlanObjectTemplateEntity; import org.springblade.hzinfo_inspect.plan.entity.PlanObjectTemplateEntity;
import java.util.List;
/** /**
* 巡检计划对象模板服务类 * 巡检计划对象模板服务类
* *
* @author Chill * @author Chill
*/ */
public interface IPlanObjectTemplateService extends BaseService<PlanObjectTemplateEntity> { public interface IPlanObjectTemplateService extends BaseService<PlanObjectTemplateEntity> {
boolean hasRelatedPlan(List<Long> objectId);
} }

10
HZInfo-RIS-PXHD/hzinfo-ris-pxhd-service/hzinfo-inspect-service/src/main/java/org/springblade/hzinfo_inspect/plan/service/impl/PlanObjectTemplateServiceImpl.java

@ -6,6 +6,10 @@ import org.springblade.hzinfo_inspect.plan.mapper.PlanObjectTemplateMapper;
import org.springblade.hzinfo_inspect.plan.service.IPlanObjectTemplateService; import org.springblade.hzinfo_inspect.plan.service.IPlanObjectTemplateService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
/** /**
* 巡检计划对象模板服务实现类 * 巡检计划对象模板服务实现类
@ -15,4 +19,10 @@ import org.springframework.stereotype.Service;
@Service @Service
public class PlanObjectTemplateServiceImpl extends BaseServiceImpl<PlanObjectTemplateMapper, PlanObjectTemplateEntity> implements IPlanObjectTemplateService { public class PlanObjectTemplateServiceImpl extends BaseServiceImpl<PlanObjectTemplateMapper, PlanObjectTemplateEntity> implements IPlanObjectTemplateService {
@Override
public boolean hasRelatedPlan(List<Long> objectId) {
LocalDateTime now = LocalDateTime.now();
String dateStr = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
return this.baseMapper.hasRelatedPlan(objectId, dateStr) > 0;
}
} }

3
HZInfo-RIS-PXHD/hzinfo-ris-pxhd-service/hzinfo-inspect-service/src/main/java/org/springblade/hzinfo_inspect/task/job/TaskJob.java

@ -48,14 +48,11 @@ public class TaskJob {
private ITaskService taskService; private ITaskService taskService;
@Autowired @Autowired
private TaskRemindManager remindManager; private TaskRemindManager remindManager;
// @Autowired
// private IRobotTaskService robotTaskService;
/** /**
* 派发任务 * 派发任务
*/ */
@Scheduled(cron = "30 0 0 * * ?") @Scheduled(cron = "30 0 0 * * ?")
// @XxlJob("taskJobDistribute")
@Transactional @Transactional
public ReturnT<String> taskDistribute() throws Exception { public ReturnT<String> taskDistribute() throws Exception {
// log.info("=====================派发任务==================="); // log.info("=====================派发任务===================");

Loading…
Cancel
Save