diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IQuestionClient.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IQuestionClient.java index da35544..4648e36 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IQuestionClient.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IQuestionClient.java @@ -19,6 +19,7 @@ public interface IQuestionClient { String API_PREFIX = "/feign/fdp/question"; String SUBMIT_STATION_INFO = API_PREFIX + "/submitStationInfo"; String DELETE_STATION_INFO = API_PREFIX + "/deleteStationInfo"; + String DELETE_STATION_ANSWER = API_PREFIX + "/deleteStationAnswer"; /** * 提交站点信息 @@ -31,4 +32,7 @@ public interface IQuestionClient { @DeleteMapping(DELETE_STATION_INFO) R deleteStationInfo(@RequestParam String stationId); + + @DeleteMapping(DELETE_STATION_INFO) + R deleteStationAnswer(@RequestParam String stationId); } diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/QuestionClientFallback.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/QuestionClientFallback.java index 2017105..1ade243 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/QuestionClientFallback.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/QuestionClientFallback.java @@ -22,4 +22,9 @@ public class QuestionClientFallback implements IQuestionClient { public R deleteStationInfo(String stationId) { return R.fail("智能诊断删除站点失败!"); } + + @Override + public R deleteStationAnswer(String stationId) { + return R.fail("智能诊断删除站点答案失败!"); + } } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java index cabb623..d0b7c17 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java @@ -159,18 +159,7 @@ public class EmInfoController extends BladeController { @ApiOperationSupport(order = 9) @ApiOperation(value = "逻辑删除", notes = "传入ids") public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { - String[] split = ids.split(","); - for (String id : split) { - List gpids = em_infoService.list(new QueryWrapper() {{ - eq("GPID", id); - }}); - if (CollectionUtil.isNotEmpty(gpids)) { - return R.fail("请先删除子设备信息"); - } - } - boolean b = em_infoService.deleteLogic(Func.toLongList(ids)); - em_infoService.getStationCodeStoreRedis(); - return R.status(b); + return R.status(em_infoService.remove(ids)); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java index fb2c548..3352f49 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java @@ -2,9 +2,11 @@ package com.hnac.hzims.equipment.service; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.vo.*; +import io.swagger.annotations.ApiParam; import org.springblade.core.mp.base.BaseService; import org.springblade.core.tool.api.R; import org.springblade.system.vo.CreateTableVO; +import org.springframework.web.bind.annotation.RequestParam; import javax.validation.Valid; import java.util.List; @@ -61,4 +63,6 @@ public interface IEmInfoService extends BaseService { List getEmCreateTable(List tableNames); List listByTenantId(String tenantId); + + Boolean remove(String ids); } 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 0b0c69a..bf4b190 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 @@ -14,6 +14,7 @@ import com.hnac.hzims.equipment.mapper.EmInfoMapper; import com.hnac.hzims.equipment.mapper.EmInfoNoScopeMapper; import com.hnac.hzims.equipment.service.*; import com.hnac.hzims.equipment.vo.*; +import com.hnac.hzims.fdp.service.IFdpQuestionService; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; @@ -28,6 +29,8 @@ import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.*; +import org.springblade.system.entity.Dept; +import org.springblade.system.feign.ISysClient; import org.springblade.system.vo.CreateTableVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -39,6 +42,7 @@ import org.springframework.util.Assert; import javax.validation.Valid; import java.util.*; +import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -72,6 +76,12 @@ public class EmInfoServiceImpl extends BaseServiceImpl idList = Func.toLongList(",",ids); + // 判断是否存在子设备 + List childEmList = this.list(Wrappers.lambdaQuery().in(EmInfoEntity::getGpid, idList)); + Assert.isTrue(CollectionUtil.isEmpty(childEmList),() -> { + throw new ServiceException("请先删除子设备信息"); + }); + // 删除FDP答题记录 + Consumer removeFdpEmInfo = id -> { + EmInfoEntity infoEntity = this.getById(id); + R deptResult = sysClient.getDept(infoEntity.getDepartment()); + if(ObjectUtil.isNotEmpty(infoEntity) && Func.isNotEmpty(infoEntity.getEmIndex()) && deptResult.isSuccess() + && Func.isNotEmpty(deptResult.getData()) && Func.isNotEmpty(deptResult.getData().getStationId())) { + questionService.deleteDevsetAnswer(deptResult.getData().getStationId(), infoEntity.getEmIndex()); + } + }; + idList.forEach(removeFdpEmInfo); + return this.deleteLogic(Func.toLongList(",", ids)); + } + /** * 设备信息缓存(ct、pt、installedCapacity、监测点位) diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/config/FdpUrlConfiguration.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/config/FdpUrlConfiguration.java index c71a221..66a9273 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/config/FdpUrlConfiguration.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/config/FdpUrlConfiguration.java @@ -48,5 +48,11 @@ public class FdpUrlConfiguration { /**按物模型实例编号删除问题答案**/ private String deleteInstanceAnswer; + /**删除站点问题的答案**/ + private String deleteStationAnswer; + + /**删除机组问题答案**/ + private String deleteDevsetAnswer; + } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/QuestionClient.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/QuestionClient.java index 3c18b89..f2ef758 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/QuestionClient.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/QuestionClient.java @@ -32,4 +32,10 @@ public class QuestionClient implements IQuestionClient { return R.status(fdpQuestionService.deleteStationInfo(stationId)); } + @DeleteMapping(DELETE_STATION_ANSWER) + @Override + public R deleteStationAnswer(String stationId) { + return R.status(fdpQuestionService.deleteStationAnswer(stationId)); + } + } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpQuestionService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpQuestionService.java index 5ff9c13..c860dce 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpQuestionService.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpQuestionService.java @@ -74,4 +74,18 @@ public interface IFdpQuestionService { */ List getInstanceAnswer(String instanceId); + /** + * 提交机组问题的答案。提交前会删除该物模型实例编号下的所有原答案 + * @param stationId 站点编码 + * @param index 设备序号 + * @return + */ + Boolean deleteDevsetAnswer(String stationId, int index); + + /** + * 删除站点问题的答案,也会删除站点的所有机组问题答案 + * @param stationId 站点ID + * @return + */ + Boolean deleteStationAnswer(String stationId); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java index 44b498a..e82b1c0 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java @@ -193,6 +193,48 @@ public class FdpQuestionServiceImpl implements IFdpQuestionService { return Lists.newArrayList(); } + @Override + public Boolean deleteDevsetAnswer(String stationId, int index) { + HttpResponse httpResponse = HttpRequest.post(fdpUrlConfiguration.getDeleteDevsetAnswer()).body( + JSON.toJSONString( + new HashMap(2){{ + put("stationId",stationId); + put("index",index); + }} + ) + ).execute(); + JSONObject responseObject = JSONObject.parseObject(httpResponse.body()); + if(httpResponse.getStatus() == HttpServletResponse.SC_OK && + "1".equals(responseObject.getString("success"))) { + logger.info("FdpQuestion:deleteDevsetAnswer","FDP设备删除成功!站点ID为:"+stationId+",设备编号为:"+index); + return JSONObject.parseObject(responseObject.getString("data"),Boolean.class); + } + else { + logger.error("FdpQuestion:deleteDevsetAnswer","FDP设备删除失败!站点ID为:"+stationId+",设备编号为:"+index); + } + return false; + } + + @Override + public Boolean deleteStationAnswer(String stationId) { + HttpResponse httpResponse = HttpRequest.post(fdpUrlConfiguration.getDeleteStationAnswer()).body( + JSON.toJSONString( + new HashMap(1){{ + put("stationId",stationId); + }} + ) + ).execute(); + JSONObject responseObject = JSONObject.parseObject(httpResponse.body()); + if(httpResponse.getStatus() == HttpServletResponse.SC_OK && + "1".equals(responseObject.getString("success"))) { + return JSONObject.parseObject(responseObject.getString("data"),Boolean.class); + } + else { + logger.error("FdpQuestion:deleteDevsetAnswer","FDP设备站点问题的答案失败!站点ID为:"+stationId); + } + return false; + } + /** * 根据站点类型获取Fdp的站点类型 * @param stationType 站点管理站点类型 diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationAttributeController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationAttributeController.java index 0ba2954..eede11e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationAttributeController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationAttributeController.java @@ -91,10 +91,12 @@ public class StationAttributeController extends BladeController { return R.status(stationAttributeService.deleteLogic(Func.toLongList(ids))); } - @PutMapping("/bandingMonitor/{emCode}") + @PutMapping("/bandingMonitor") @ApiOperation("根据设备编码更新集中监控监测点绑定") @ApiOperationSupport(order = 4) - public R> bandingMonitor(@PathVariable @ApiParam(value = "设备编码",required = true) String emCode) { - return R.data(stationAttributeService.bandingMonitor(emCode)); + public R> bandingMonitor(@ApiParam(value = "设备编码",required = true) String emCode, + @ApiParam(value = "站点类型",required = true) String stationType, + @ApiParam(value = "设备类型",required = true) String emType) { + return R.data(stationAttributeService.bandingMonitor(emCode,stationType,emType)); } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationAttributeService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationAttributeService.java index 9a0f891..d3ecdb8 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationAttributeService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationAttributeService.java @@ -45,5 +45,5 @@ public interface IStationAttributeService extends BaseService bandingMonitor(String emCode); + List bandingMonitor(String emCode,String stationType,String emType); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationAttributeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationAttributeServiceImpl.java index efaf4d1..e9dd316 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationAttributeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationAttributeServiceImpl.java @@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; import com.hnac.hzims.common.service.UserAuthDataService; import com.hnac.hzims.fdp.vo.FdpFaultStatusVo; +import com.hnac.hzims.operational.config.entity.FocusAttributeEntity; +import com.hnac.hzims.operational.config.service.IFocusAttributeService; import com.hnac.hzims.operational.station.entity.StationAttrConfigEntity; import com.hnac.hzims.operational.station.entity.StationAttributeEntity; import com.hnac.hzims.operational.station.entity.StationEntity; @@ -14,7 +16,10 @@ import com.hnac.hzims.operational.station.service.IStationAttrConfigService; import com.hnac.hzims.operational.station.service.IStationAttributeService; import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.vo.StationAttributeVo; +import com.hnac.hzinfo.sdk.core.response.Result; import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; +import com.hnac.hzinfo.sdk.v5.device.dto.DeviceChildrenDTO; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceChildrenVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; import lombok.AllArgsConstructor; import lombok.RequiredArgsConstructor; @@ -25,19 +30,14 @@ import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.BeanUtil; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springblade.core.tool.utils.StringUtil; +import org.springblade.core.tool.utils.*; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.util.Assert; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -50,6 +50,7 @@ public class StationAttributeServiceImpl extends BaseServiceImpl bandingMonitor(String emCode) { - List result = new ArrayList<>(); - LambdaQueryWrapper wq = Wrappers.lambdaQuery().eq(StationAttributeEntity::getEmCode, emCode); - List attributeEntities = this.list(wq); - if(CollectionUtil.isEmpty(attributeEntities)) { - return Lists.newArrayList(); - } - // 获取设备实例物模型绑定数据 - R> onlineAttrR= deviceClient.getOnlineAttr(emCode); - Assert.isTrue(onlineAttrR.isSuccess(),() -> { - throw new ServiceException(onlineAttrR.getMsg()); - }); - if(CollectionUtil.isNotEmpty(onlineAttrR.getData())) { - Map> stringListMap = onlineAttrR.getData().stream().collect(Collectors.groupingBy(DeviceInstanceAttrVO::getSignage)); - result = attributeEntities.stream().map(attributeEntity -> { - StationAttributeVo attributeVo = BeanUtil.copy(attributeEntity, StationAttributeVo.class); - List deviceInstanceAttrVOS = stringListMap.get(attributeEntity.getSignage()); - if(CollectionUtil.isNotEmpty(deviceInstanceAttrVOS)) { - attributeVo.setMonitorId(deviceInstanceAttrVOS.get(0).getFacDeviceAttrId()); - attributeVo.setMonitorName(deviceInstanceAttrVOS.get(0).getFacDeviceAttrName()); - } - return attributeVo; - }).collect(Collectors.toList()); - } + public List bandingMonitor(String emCode,String stationType,String emType) { + List result; + // 获取集中监控属性配置 + List attributes = attributeService.list(Wrappers.lambdaQuery() + .eq(FocusAttributeEntity::getDomainId, stationType) + .eq(FocusAttributeEntity::getGroupId, emType) + .eq(FocusAttributeEntity::getStatus, 0) + ); + // 标识 + List signages = attributes.stream().map(FocusAttributeEntity::getSignage).filter(Func::isNotEmpty).collect(Collectors.toList()); + // 根据设备实例查询采集点 + DeviceChildrenDTO deviceChildrenDTO = new DeviceChildrenDTO(); + deviceChildrenDTO.setSignages(signages); + deviceChildrenDTO.setDeviceCode(emCode); + deviceChildrenDTO.setType("attr"); + Result> deviceChildrenListResult = deviceClient.getRealId(deviceChildrenDTO); + boolean facAttrFlag = deviceChildrenListResult.isSuccess() && CollectionUtil.isNotEmpty(deviceChildrenListResult.getData()); + // 根据集中监控属性配置获取站点集中监控属性配置 + Function convert = focusAttr -> { + StationAttributeVo vo = BeanUtil.copy(focusAttr,StationAttributeVo.class); + if(facAttrFlag) { + List data = deviceChildrenListResult.getData(); + Optional facAttrOptional = data.stream().filter(attr -> focusAttr.getSignage().equals(attr.getSignage())).findAny(); + vo.setMonitorId(facAttrOptional.map(DeviceChildrenVO::getRealId).orElse(null)); + vo.setMonitorName(facAttrOptional.map(DeviceChildrenVO::getName).orElse(null)); + } + return vo; + }; + result = attributes.stream().map(convert).collect(Collectors.toList()); return result; } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java index 1a06dad..17d0b92 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.station.service.impl; + package com.hnac.hzims.operational.station.service.impl; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -142,11 +142,16 @@ public class StationServiceImpl extends BaseServiceImpl { + // 删除站点下集中监控属性配置 stationAttributeService.removeByStationCode(stationEntity.getCode()); + // 删除智能诊断站点 + questionClient.deleteStationInfo(stationEntity.getCode()); + // 删除智能诊断实例图信息 + questionClient.deleteStationAnswer(stationEntity.getCode()); },"删除站点集中监控属性").start(); return saveFlag; } diff --git a/pom.xml b/pom.xml index 722d126..255422d 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ 3.8.1 UTF-8 - 4.6.1-SNAPSHOT + 5.0.1-SNAPSHOT