diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java index 7d22c2e..4d5d095 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java @@ -79,7 +79,7 @@ public interface IEmInfoClient { String GET_EM_INFO_TREE_BY_EM_CODE = API_PREFIX + "/getEmInfoTreeByEmCode"; String UPDATE_BY_EM_CODE = API_PREFIX + "/updateByEmCode"; String UPDATE_BATCH_EM_STATE = API_PREFIX + "/updateBachEmState"; - + String GET_CHILDREN_BY_EM_CODE = API_PREFIX + "/getChildrenByEmCode"; String GET_EM_CREATE_TABLE = API_PREFIX + "/getEmCreateTable"; @PostMapping(DETAIL) @@ -153,4 +153,12 @@ public interface IEmInfoClient { @PostMapping(GET_EM_CREATE_TABLE) List getEmCreateTable(@RequestParam("list") List tableNames); + + /** + * 获取设备下的子设备编号列表 + * @param emCode 设备编号 + * @return 子设备编号列表 + */ + @GetMapping(GET_CHILDREN_BY_EM_CODE) + R> getChildrenByEmCode(@RequestParam("emCode") String emCode); } diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java index f79cbfd..e8b0b95 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java @@ -98,4 +98,9 @@ public class IEmInfoClientBack implements IEmInfoClient { public List getEmCreateTable(List tableNames) { return new ArrayList<>(); } + + @Override + public R> getChildrenByEmCode(String emCode) { + return R.fail("远程调用失败"); + } } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java index 5d999c3..dd24111 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java @@ -3,19 +3,20 @@ package com.hnac.hzims.equipment.feign; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Lists; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.service.IEmInfoService; import com.hnac.hzims.equipment.vo.DeviceVO; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.system.vo.CreateTableVO; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; +import java.util.stream.Collectors; @RestController @@ -133,6 +134,16 @@ public class EmInfoClient implements IEmInfoClient { return service.getEmCreateTable(tableNames); } + @Override + public R> getChildrenByEmCode(@RequestParam String emCode) { + EmInfoEntity emInfo = service.getOne(Wrappers.lambdaQuery().eq(EmInfoEntity::getNumber, emCode)); + if(ObjectUtil.isEmpty(emInfo)) { + return R.data(Lists.newArrayList()); + } + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery().like(EmInfoEntity::getPath, emInfo.getPath()); + return R.data(service.list(wrapper).stream().map(EmInfoEntity::getNumber).distinct().collect(Collectors.toList())); + } + /** * * @param emCode diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java index 0d468b4..12726bd 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java @@ -599,14 +599,15 @@ public class EmInfoServiceImpl extends BaseServiceImpl Arrays.stream(path.split("/"))).distinct().collect(Collectors.toList()); emCodes.addAll(childrenEmCode); } + EmInfoEntity emInfo = this.getOne(Wrappers.lambdaQuery().eq(EmInfoEntity::getNumber, parentCode)); // 获取parentCode下的子设备集合 LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery() - .eq(EmInfoEntity::getGpid, parentCode) + .eq(EmInfoEntity::getGpid, Optional.ofNullable(emInfo).map(EmInfoEntity::getId).orElse(0L)) .eq(EmInfoEntity::getDepartment,deptId); List emInfoList = this.list(queryWrapper); List result = emInfoList.stream().map(emInfoEntity -> { JSONObject object = JSONObject.parseObject(JSON.toJSONString(emInfoEntity)); - object.put("disabled", emCodes.contains(emInfoEntity.getNumber()) ? true : false); + object.put("disabled", emCodes.contains(emInfoEntity.getNumber()) ? false : true); return object; }).collect(Collectors.toList()); return result; diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ObjectServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ObjectServiceImpl.java index 2e97031..0614870 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ObjectServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ObjectServiceImpl.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; import com.google.zxing.BarcodeFormat; +import com.hnac.hzims.equipment.feign.IEmInfoClient; import com.hnac.hzinfo.inspect.Constants; import com.hnac.hzinfo.inspect.obj.ObjectConstants; import com.hnac.hzinfo.inspect.obj.entity.*; @@ -58,6 +59,8 @@ public class ObjectServiceImpl extends BaseServiceImpl emCodeList = Func.toStrList(",", object.getEmCodes()); - Function getTemplateProjectByEmCode = index -> { + Function getTemplateProjectByEmCode = emCode -> { ProjectEntity project = new ProjectEntity(); - project.setEmCode(emCodeList.get(index)); + project.setEmCode(emCode); project.setStatus(ObjectConstants.ProjectEnableEnum.YES.getEnableType()); ProjectEntity one = projectService.getOne(project); - return TemplateProjectEntity.builder().templateId(template.getId()).projectId(one.getId()).sort(index).build(); + return TemplateProjectEntity.builder().templateId(template.getId()).projectId(one.getId()).build(); }; List templateProjectList = Stream.iterate(0,n -> n + 1).limit(emCodeList.size()) - .map(getTemplateProjectByEmCode).collect(Collectors.toList()); + .flatMap(index -> emInfoClient.getChildrenByEmCode(emCodeList.get(index)).getData().stream()).map(getTemplateProjectByEmCode).collect(Collectors.toList()); templateProjectService.saveBatch(templateProjectList); } } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/config/ThreadPoolConfig.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/config/ThreadPoolConfig.java index b3e8b1a..3d2a9a3 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/config/ThreadPoolConfig.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/config/ThreadPoolConfig.java @@ -25,6 +25,6 @@ public class ThreadPoolConfig { @Bean public ExecutorService appMessagePushExecutor() { - return new ThreadPoolExecutor(2, 5, 5L, TimeUnit.SECONDS,new LinkedBlockingQueue()); + return new ThreadPoolExecutor(1, 1, 0L, TimeUnit.SECONDS,new LinkedBlockingQueue()); } } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java index c5c3958..560bbcc 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java @@ -51,7 +51,7 @@ public class MessagePushRecordController extends BladeController { @ApiOperation("查询消息推送记录列表") @ApiOperationSupport(order = 3) public R> list(MessagePushRecordEntity request) { - return R.data(messagePushRecordService.list(request)); + return R.data(messagePushRecordService.listNoUserScope(request)); } @GetMapping("/listPage") @@ -62,7 +62,7 @@ public class MessagePushRecordController extends BladeController { title = "消息管理", operatorType = OperatorType.MOBILE, businessType = BusinessType.GENCODE, action = "分页查询消息推送记录列表") public R> listPage(MessagePushRecordEntity request, Query query) { - return R.data(messagePushRecordService.listPage(request, query)); + return R.data(messagePushRecordService.listPageNoUserScope(request, query)); } @GetMapping("/send/{id}") diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java index 56a2974..94a1d31 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java @@ -22,6 +22,13 @@ public interface IMessagePushRecordService extends BaseService list(MessagePushRecordEntity request); /** + * 查询消息推送记录列表 - 无数据权限 + * @param request + * @return + */ + List listNoUserScope(MessagePushRecordEntity request); + + /** * 分页查询消息推送记录列表 * @param request 查询条件 * @param query 分页 @@ -29,6 +36,14 @@ public interface IMessagePushRecordService extends BaseService listPage(MessagePushRecordEntity request, Query query); + /** + * 分页查询消息推送记录列表 - 无数据权限 + * @param request 查询条件 + * @param query 分页 + * @return 消息记录列表 + */ + IPage listPageNoUserScope(MessagePushRecordEntity request, Query query); + /** @Author hx * @Description 根据ID发送短信 * @Date 2023/4/4 17:37 diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java index 909b955..cbc3f0c 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java @@ -57,10 +57,20 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl listNoUserScope(MessagePushRecordEntity request) { + return noAurhScopeMapper.selectList(this.getQueryWrapper(request)); + } + + @Override public IPage listPage(MessagePushRecordEntity request, Query query) { return this.page(Condition.getPage(query), this.getQueryWrapper(request)); } + @Override + public IPage listPageNoUserScope(MessagePushRecordEntity request, Query query) { + return noAurhScopeMapper.selectPage(Condition.getPage(query), this.getQueryWrapper(request)); + } + /** * @return java.lang.Boolean 推送结果 * @Author hx