Browse Source

# 巡检内容定义删除时做设备定义绑定内容定义时无法删除的限制

# 设备定义列表bug解决
zhongwei
haungxing 1 year ago
parent
commit
2538c0df15
  1. 23
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmTreeInspectClient.java
  2. 4
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmDefinitionController.java
  3. 31
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmTreeInspectClient.java
  4. 6
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeInspectMapper.java
  5. 12
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeInspectMapper.xml
  6. 9
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmTreeInspectService.java
  7. 8
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmTreeInspectServiceImpl.java
  8. 4
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/IContentDefinitionService.java
  9. 21
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ContentDefinitionServiceImpl.java
  10. 2
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ContentDefinitionController.java

23
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmTreeInspectClient.java

@ -0,0 +1,23 @@
package com.hnac.hzims.equipment.feign;
import com.hnac.hzims.EquipmentConstants;
import org.springblade.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;
@FeignClient(value = EquipmentConstants.APP_NAME)
public interface IEmTreeInspectClient {
String API_PREFIX = "/feign/em/tree/inspect";
String GET_EM_TREE_CONTENT_ID = API_PREFIX + "/getEmTreeContentId";
/**
* 获取设备信息中已绑定的巡检内容定义ID
* @return 巡检内容定义ID
*/
@GetMapping(GET_EM_TREE_CONTENT_ID)
R<List<Long>> getEmTreeContentId();
}

4
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmDefinitionController.java

@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List; import java.util.List;
import java.util.Optional;
/** /**
* 设备定义控制层 * 设备定义控制层
@ -75,8 +76,7 @@ public class EmDefinitionController extends BladeController {
wrapper.orderByDesc(EmDefinitionEntity::getCreateTime); wrapper.orderByDesc(EmDefinitionEntity::getCreateTime);
IPage<EmDefinitionEntity> pages = emDefinitionService.page(Condition.getPage(query), wrapper); IPage<EmDefinitionEntity> pages = emDefinitionService.page(Condition.getPage(query), wrapper);
for (EmDefinitionEntity definition : pages.getRecords()) { for (EmDefinitionEntity definition : pages.getRecords()) {
User createUser = UserCache.getUser(definition.getCreateUser()); definition.setCreateUserName(Optional.ofNullable(UserCache.getUser(definition.getCreateUser())).map(User::getName).orElse(String.valueOf(definition.getCreateUser())));
definition.setCreateUserName(createUser.getName());
} }
return R.data(pages); return R.data(pages);

31
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmTreeInspectClient.java

@ -0,0 +1,31 @@
package com.hnac.hzims.equipment.feign;
import com.hnac.hzims.equipment.service.IEmTreeInspectService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @ClassName EmTreeInspectClient
* @description: 设备树与巡检内容定义关联关系client
* @author: hx
* @create: 2023-08-11 17:31
* @Version 4.0
**/
@RestController
@AllArgsConstructor
@Slf4j
public class EmTreeInspectClient implements IEmTreeInspectClient {
private final IEmTreeInspectService emTreeInspectService;
@Override
@GetMapping(GET_EM_TREE_CONTENT_ID)
public R<List<Long>> getEmTreeContentId() {
return R.data(emTreeInspectService.selectEmTreeContentId());
}
}

6
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeInspectMapper.java

@ -4,5 +4,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.equipment.entity.EmTreeInspectEntity; import com.hnac.hzims.equipment.entity.EmTreeInspectEntity;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
import java.util.List;
import java.util.Map;
public interface EmTreeInspectMapper extends BaseMapper<EmTreeInspectEntity> { public interface EmTreeInspectMapper extends BaseMapper<EmTreeInspectEntity> {
List<Long> selectEmTreeContentId();
} }

12
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmTreeInspectMapper.xml

@ -1,5 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.equipment.mapper.EmTreeInspectMapper"> <mapper namespace="com.hnac.hzims.equipment.mapper.EmTreeInspectMapper">
<select id="selectEmTreeContentId" resultType="java.lang.Long">
select distinct content_id
from hzims_em_definition ed,
hzims_em_tree et,
hzims_em_tree_inspect ti
where ed.id = et.definition_id
and et.id = ti.tree_id
and ed.IS_DELETED = 0
and ti.IS_DELETED = 0
and et.IS_DELETED = 0
</select>
</mapper> </mapper>

9
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmTreeInspectService.java

@ -3,5 +3,14 @@ package com.hnac.hzims.equipment.service;
import com.hnac.hzims.equipment.entity.EmTreeInspectEntity; import com.hnac.hzims.equipment.entity.EmTreeInspectEntity;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import java.util.List;
public interface IEmTreeInspectService extends BaseService<EmTreeInspectEntity> { public interface IEmTreeInspectService extends BaseService<EmTreeInspectEntity> {
/**
* 获取
* @return 巡检内容定义ID列表
*/
List<Long> selectEmTreeContentId();
} }

8
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmTreeInspectServiceImpl.java

@ -7,6 +7,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* @author tanghaihao * @author tanghaihao
* @date 2023年06月15日 9:08 * @date 2023年06月15日 9:08
@ -14,4 +16,10 @@ import org.springframework.stereotype.Service;
@Service @Service
@Slf4j @Slf4j
public class EmTreeInspectServiceImpl extends BaseServiceImpl<EmTreeInspectMapper, EmTreeInspectEntity> implements IEmTreeInspectService { public class EmTreeInspectServiceImpl extends BaseServiceImpl<EmTreeInspectMapper, EmTreeInspectEntity> implements IEmTreeInspectService {
@Override
public List<Long> selectEmTreeContentId() {
return this.baseMapper.selectEmTreeContentId();
}
} }

4
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/IContentDefinitionService.java

@ -6,14 +6,18 @@ import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzinfo.inspect.obj.dto.ContentDefinitionDTO; import com.hnac.hzinfo.inspect.obj.dto.ContentDefinitionDTO;
import com.hnac.hzinfo.inspect.obj.entity.ContentDefinitionEntity; import com.hnac.hzinfo.inspect.obj.entity.ContentDefinitionEntity;
import com.hnac.hzinfo.inspect.obj.vo.ContentDefinitionVO; import com.hnac.hzinfo.inspect.obj.vo.ContentDefinitionVO;
import net.bytebuddy.matcher.BooleanMatcher;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; import java.util.List;
public interface IContentDefinitionService extends BaseService<ContentDefinitionEntity> { public interface IContentDefinitionService extends BaseService<ContentDefinitionEntity> {
Boolean removeByIds(String ids);
/** /**
* 根据筛选条件获取列表 * 根据筛选条件获取列表
* @param request 筛选条件 * @param request 筛选条件

21
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ContentDefinitionServiceImpl.java

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hnac.hzims.equipment.feign.IEmTreeInspectClient;
import com.hnac.hzinfo.inspect.obj.dto.ContentDefinitionDTO; import com.hnac.hzinfo.inspect.obj.dto.ContentDefinitionDTO;
import com.hnac.hzinfo.inspect.obj.entity.ContentDefinitionEntity; import com.hnac.hzinfo.inspect.obj.entity.ContentDefinitionEntity;
import com.hnac.hzinfo.inspect.obj.mapper.ContentDefinitionMapper; import com.hnac.hzinfo.inspect.obj.mapper.ContentDefinitionMapper;
@ -12,16 +13,21 @@ import com.hnac.hzinfo.inspect.obj.vo.ContentDefinitionVO;
import com.hnac.hzinfo.inspect.obj.wrapper.ContentDefinitionWrapper; import com.hnac.hzinfo.inspect.obj.wrapper.ContentDefinitionWrapper;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.BeanUtil;
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.core.tool.utils.StringUtil; import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Optional;
/** /**
* @ClassName ContentDefinitionServiceImpl * @ClassName ContentDefinitionServiceImpl
@ -37,6 +43,21 @@ import java.util.List;
public class ContentDefinitionServiceImpl extends BaseServiceImpl<ContentDefinitionMapper, ContentDefinitionEntity> public class ContentDefinitionServiceImpl extends BaseServiceImpl<ContentDefinitionMapper, ContentDefinitionEntity>
implements IContentDefinitionService { implements IContentDefinitionService {
private final IEmTreeInspectClient emTreeInspectClient;
@Override
public Boolean removeByIds(String ids) {
R<List<Long>> contentIdR = emTreeInspectClient.getEmTreeContentId();
Assert.isTrue(contentIdR.isSuccess(),() -> {
throw new ServiceException("查询设备定义绑定内容失败");
});
Optional<Long> optional = Func.toLongList(",",ids).stream().filter(id -> contentIdR.getData().contains(id)).findFirst();
if(optional.isPresent()) {
throw new ServiceException("删除失败,【"+this.getById(optional.get()).getName()+"】内容定义已与设备定义绑定");
}
return this.removeByIds(Func.toLongList(",",ids));
}
@Override @Override
public List<ContentDefinitionVO> list(ContentDefinitionDTO request) { public List<ContentDefinitionVO> list(ContentDefinitionDTO request) {
QueryWrapper<ContentDefinitionEntity> queryWrapper = Condition.getQueryWrapper(BeanUtil.copy(request, ContentDefinitionEntity.class)); QueryWrapper<ContentDefinitionEntity> queryWrapper = Condition.getQueryWrapper(BeanUtil.copy(request, ContentDefinitionEntity.class));

2
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ContentDefinitionController.java

@ -78,7 +78,7 @@ public class ContentDefinitionController extends BladeController {
@ApiOperation("根据ID删除") @ApiOperation("根据ID删除")
@ApiOperationSupport(order = 5) @ApiOperationSupport(order = 5)
public R removeByIds(@RequestParam String ids) { public R removeByIds(@RequestParam String ids) {
return R.status(contentDefinitionService.removeByIds(Func.toLongList(",",ids))); return R.status(contentDefinitionService.removeByIds(ids));
} }
@GetMapping("/detail") @GetMapping("/detail")

Loading…
Cancel
Save