Browse Source

# FDP站点推送接口添加tenantId字段,运维平台删除站点、设备同步删除FDP站点及设备

zhongwei
haungxing 1 year ago
parent
commit
a550f32ad5
  1. 4
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IQuestionClient.java
  2. 5
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/QuestionClientFallback.java
  3. 13
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java
  4. 4
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java
  5. 31
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java
  6. 6
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/config/FdpUrlConfiguration.java
  7. 6
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/QuestionClient.java
  8. 14
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpQuestionService.java
  9. 42
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java
  10. 2
      pom.xml

4
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 API_PREFIX = "/feign/fdp/question";
String SUBMIT_STATION_INFO = API_PREFIX + "/submitStationInfo"; String SUBMIT_STATION_INFO = API_PREFIX + "/submitStationInfo";
String DELETE_STATION_INFO = API_PREFIX + "/deleteStationInfo"; 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) @DeleteMapping(DELETE_STATION_INFO)
R<Boolean> deleteStationInfo(@RequestParam String stationId); R<Boolean> deleteStationInfo(@RequestParam String stationId);
@DeleteMapping(DELETE_STATION_INFO)
R<Boolean> deleteStationAnswer(@RequestParam String stationId);
} }

5
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<Boolean> deleteStationInfo(String stationId) { public R<Boolean> deleteStationInfo(String stationId) {
return R.fail("智能诊断删除站点失败!"); return R.fail("智能诊断删除站点失败!");
} }
@Override
public R<Boolean> deleteStationAnswer(String stationId) {
return R.fail("智能诊断删除站点答案失败!");
}
} }

13
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) @ApiOperationSupport(order = 9)
@ApiOperation(value = "逻辑删除", notes = "传入ids") @ApiOperation(value = "逻辑删除", notes = "传入ids")
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
String[] split = ids.split(","); return R.status(em_infoService.remove(ids));
for (String id : split) {
List<EmInfoEntity> gpids = em_infoService.list(new QueryWrapper<EmInfoEntity>() {{
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);
} }

4
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.entity.EmInfoEntity;
import com.hnac.hzims.equipment.vo.*; import com.hnac.hzims.equipment.vo.*;
import io.swagger.annotations.ApiParam;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.system.vo.CreateTableVO; import org.springblade.system.vo.CreateTableVO;
import org.springframework.web.bind.annotation.RequestParam;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List; import java.util.List;
@ -61,4 +63,6 @@ public interface IEmInfoService extends BaseService<EmInfoEntity> {
List<CreateTableVO> getEmCreateTable(List<String> tableNames); List<CreateTableVO> getEmCreateTable(List<String> tableNames);
List<DeviceVO> listByTenantId(String tenantId); List<DeviceVO> listByTenantId(String tenantId);
Boolean remove(String ids);
} }

31
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.mapper.EmInfoNoScopeMapper;
import com.hnac.hzims.equipment.service.*; import com.hnac.hzims.equipment.service.*;
import com.hnac.hzims.equipment.vo.*; 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.main.constant.HomePageConstant;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient; 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.mp.base.BaseServiceImpl;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*; 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.springblade.system.vo.CreateTableVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@ -39,6 +42,7 @@ import org.springframework.util.Assert;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.*; import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -72,6 +76,12 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
@Autowired @Autowired
private DeviceClient deviceClient; private DeviceClient deviceClient;
@Autowired
private ISysClient sysClient;
@Autowired
private IFdpQuestionService questionService;
@Value("${hzims.equipment.emInfo.code}") @Value("${hzims.equipment.emInfo.code}")
public String deviceCodePath; public String deviceCodePath;
@ -420,6 +430,27 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
return this.baseMapper.listByTenantId(tenantId); return this.baseMapper.listByTenantId(tenantId);
} }
@Override
public Boolean remove(String ids) {
List<Long> idList = Func.toLongList(",",ids);
// 判断是否存在子设备
List<EmInfoEntity> childEmList = this.list(Wrappers.<EmInfoEntity>lambdaQuery().in(EmInfoEntity::getGpid, idList));
Assert.isTrue(CollectionUtil.isEmpty(childEmList),() -> {
throw new ServiceException("请先删除子设备信息");
});
// 删除FDP答题记录
Consumer<Long> removeFdpEmInfo = id -> {
EmInfoEntity infoEntity = this.getById(id);
R<Dept> 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));
}
/** /**
* 设备信息缓存(ctptinstalledCapacity监测点位) * 设备信息缓存(ctptinstalledCapacity监测点位)

6
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 deleteInstanceAnswer;
/**删除站点问题的答案**/
private String deleteStationAnswer;
/**删除机组问题答案**/
private String deleteDevsetAnswer;
} }

6
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)); return R.status(fdpQuestionService.deleteStationInfo(stationId));
} }
@DeleteMapping(DELETE_STATION_ANSWER)
@Override
public R<Boolean> deleteStationAnswer(String stationId) {
return R.status(fdpQuestionService.deleteStationAnswer(stationId));
}
} }

14
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpQuestionService.java

@ -74,4 +74,18 @@ public interface IFdpQuestionService {
*/ */
List<JSONObject> getInstanceAnswer(String instanceId); List<JSONObject> getInstanceAnswer(String instanceId);
/**
* 提交机组问题的答案提交前会删除该物模型实例编号下的所有原答案
* @param stationId 站点编码
* @param index 设备序号
* @return
*/
Boolean deleteDevsetAnswer(String stationId, int index);
/**
* 删除站点问题的答案也会删除站点的所有机组问题答案
* @param stationId 站点ID
* @return
*/
Boolean deleteStationAnswer(String stationId);
} }

42
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(); return Lists.newArrayList();
} }
@Override
public Boolean deleteDevsetAnswer(String stationId, int index) {
HttpResponse httpResponse = HttpRequest.post(fdpUrlConfiguration.getDeleteDevsetAnswer()).body(
JSON.toJSONString(
new HashMap<String,Object>(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<String,Object>(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的站点类型 * 根据站点类型获取Fdp的站点类型
* @param stationType 站点管理站点类型 * @param stationType 站点管理站点类型

2
pom.xml

@ -18,7 +18,7 @@
<maven.plugin.version>3.8.1</maven.plugin.version> <maven.plugin.version>3.8.1</maven.plugin.version>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<hzinfo.data.version>4.6.1-SNAPSHOT</hzinfo.data.version> <hzinfo.data.version>5.0.1-SNAPSHOT</hzinfo.data.version>
<!-- <hzinfo.data.api.version>4.5.3-SNAPSHOT</hzinfo.data.api.version>--> <!-- <hzinfo.data.api.version>4.5.3-SNAPSHOT</hzinfo.data.api.version>-->
<!-- <hzinfo.data.sdk.version>4.5.4-RELEASE</hzinfo.data.sdk.version>--> <!-- <hzinfo.data.sdk.version>4.5.4-RELEASE</hzinfo.data.sdk.version>-->

Loading…
Cancel
Save