Browse Source

# 接站接口优化

zhongwei
H.X 2 years ago
parent
commit
edd0086985
  1. 6
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmInfoEntity.java
  2. 2
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IQuestionClient.java
  3. 12
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/StationConstants.java
  4. 46
      hzims-service/equipment/pom.xml
  5. 11
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java
  6. 2
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/QuestionClient.java
  7. 17
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java
  8. 18
      hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/impl/EquipmentInstanceServiceImpl.java
  9. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java
  10. 24
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

6
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmInfoEntity.java

@ -209,4 +209,10 @@ public class EmInfoEntity extends TenantEntity {
@JsonSerialize(nullsUsing = NullSerializer.class) @JsonSerialize(nullsUsing = NullSerializer.class)
private Long deviceInstanceId; private Long deviceInstanceId;
@ApiModelProperty("设备类型")
private String emType;
@ApiModelProperty("机组类型")
private String setType;
} }

2
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IQuestionClient.java

@ -25,6 +25,6 @@ public interface IQuestionClient {
* @return * @return
*/ */
@GetMapping(SUBMIT_STATION_INFO) @GetMapping(SUBMIT_STATION_INFO)
R<Boolean> submitStationInfo(@RequestParam String stationCode, @RequestParam(required = false) String stationDesc); R<Boolean> submitStationInfo(@RequestParam("stationCode") String stationCode, @RequestParam(value = "stationDesc",required = false) String stationDesc);
} }

12
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/StationConstants.java

@ -3,6 +3,18 @@ package com.hnac.hzims.operational.station;
import lombok.Getter; import lombok.Getter;
public interface StationConstants { public interface StationConstants {
/*==============================================================================================*/
/**数据来源-hz3000-v3**/
String HZ3000_V3 = "3";
/**数据来源-hz3000-v4**/
String HZ3000_V4 = "4";
/**数据来源-hz3000-v4s**/
String HZ3000_V4S = "4S";
/**数据来源-hz3000-v5**/
String HZ3000_OTHER = "5";
/*==============================================================================================*/
String STATION_VIDEO_TYPE_CODE = "vedio_address_type"; String STATION_VIDEO_TYPE_CODE = "vedio_address_type";
//自动添加或修改机构数据 //自动添加或修改机构数据

46
hzims-service/equipment/pom.xml

@ -24,46 +24,6 @@
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-starter-oss-all</artifactId> <artifactId>blade-starter-oss-all</artifactId>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>org.springblade</groupId>-->
<!-- <artifactId>blade-auth</artifactId>-->
<!-- <version>2.7.5.RELEASE</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springblade</groupId>-->
<!-- <artifactId>blade-flow</artifactId>-->
<!-- <version>2.7.5.RELEASE</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springblade</groupId>-->
<!-- <artifactId>blade-flow-design</artifactId>-->
<!-- <version>2.7.5.RELEASE</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springblade</groupId>-->
<!-- <artifactId>blade-gateway</artifactId>-->
<!-- <version>2.7.5.RELEASE</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springblade</groupId>-->
<!-- <artifactId>blade-report</artifactId>-->
<!-- <version>2.7.5.RELEASE</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springblade</groupId>-->
<!-- <artifactId>blade-resource</artifactId>-->
<!-- <version>2.7.5.RELEASE</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springblade</groupId>-->
<!-- <artifactId>blade-system</artifactId>-->
<!-- <version>2.7.6.1.RELEASE</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springblade</groupId>-->
<!-- <artifactId>blade-xxljob-admin</artifactId>-->
<!-- <version>2.7.5.RELEASE</version>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>com.hnac.hzims</groupId> <groupId>com.hnac.hzims</groupId>
<artifactId>spare-api</artifactId> <artifactId>spare-api</artifactId>
@ -95,6 +55,12 @@
<groupId>com.hnac.hzinfo</groupId> <groupId>com.hnac.hzinfo</groupId>
<artifactId>read-data</artifactId> <artifactId>read-data</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>

11
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java

@ -19,7 +19,9 @@ import com.hnac.hzims.util.TableJsonUtils;
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO;
import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO;
import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
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.*;
@ -30,6 +32,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.*; import java.util.*;
@ -61,6 +64,9 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
@Autowired @Autowired
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
@Autowired
private DeviceClient deviceClient;
@Value("${hzims.equipment.emInfo.code}") @Value("${hzims.equipment.emInfo.code}")
public String deviceCodePath; public String deviceCodePath;
@ -97,6 +103,11 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
@Override @Override
@Transactional @Transactional
public R saveInfo(@Valid EmInfoAddVo em_info) { public R saveInfo(@Valid EmInfoAddVo em_info) {
// 查询设备编码设备实例是否已存在
R<Boolean> existResult = deviceClient.isDeviceCodeExist(em_info.getInfo().getNumber());
Assert.isTrue(existResult.isSuccess() && !existResult.getData(),() -> {
throw new ServiceException("该设备编码在设备实例中找到对应记录,保存失败!");
});
EmInfoEntity emInfoEntity = this.baseMapper.selectEmInfoByCode(em_info.getInfo().getNumber()); EmInfoEntity emInfoEntity = this.baseMapper.selectEmInfoByCode(em_info.getInfo().getNumber());
if (ObjectUtil.isNotEmpty(emInfoEntity)) { if (ObjectUtil.isNotEmpty(emInfoEntity)) {
return R.fail("设备编号已存在"); return R.fail("设备编号已存在");

2
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/QuestionClient.java

@ -20,7 +20,7 @@ public class QuestionClient implements IQuestionClient {
@GetMapping(SUBMIT_STATION_INFO) @GetMapping(SUBMIT_STATION_INFO)
@Override @Override
public R<Boolean> submitStationInfo(@RequestParam String stationCode,@RequestParam String stationDesc) { public R<Boolean> submitStationInfo(@RequestParam String stationCode,@RequestParam(required = false) String stationDesc) {
return R.status(fdpQuestionService.submitStationInfo(stationCode,stationDesc)); return R.status(fdpQuestionService.submitStationInfo(stationCode,stationDesc));
} }

17
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java

@ -24,11 +24,13 @@ import org.springblade.core.tool.api.R;
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 javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.Executors;
/** /**
* @author hx * @author hx
@ -141,17 +143,22 @@ public class FdpQuestionServiceImpl implements IFdpQuestionService {
@Override @Override
public boolean generateGraphInstance(Integer stationType, String stationId) { public boolean generateGraphInstance(Integer stationType, String stationId) {
Integer type = this.getStationType(stationType); Integer type = this.getStationType(stationType);
if(Func.isNotEmpty(type)) { Assert.isTrue(Func.isNotEmpty(type),() -> {
throw new ServiceException("设备所属站点类型只能为水电站或泵站");
});
Executors.newSingleThreadExecutor().submit(() -> {
HttpResponse httpResponse = HttpRequest.post(fdpUrlConfiguration.getGenerateGraphInstance()).body(JSON.toJSONString( HttpResponse httpResponse = HttpRequest.post(fdpUrlConfiguration.getGenerateGraphInstance()).body(JSON.toJSONString(
new HashMap<String,Object>(){{ new HashMap<String,Object>(){{
put("type",type); put("type",type);
put("stationId",stationId); put("stationId",stationId);
}} }}
)).execute(); )).execute();
return httpResponse.getStatus() == HttpServletResponse.SC_OK && if(httpResponse.getStatus() != HttpServletResponse.SC_OK ||
"1".equals(JSONObject.parseObject(httpResponse.body()).getString("success")); !"1".equals(JSONObject.parseObject(httpResponse.body()).getString("success"))) {
} logger.error("equipment:fdp:generateGraphInstance",httpResponse.body());
return false; }
});
return true;
} }
@Override @Override

18
hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/impl/EquipmentInstanceServiceImpl.java

@ -51,17 +51,17 @@ public class EquipmentInstanceServiceImpl implements IEquipmentInstanceService {
// 模型标识根据题目答案获取 // 模型标识根据题目答案获取
virtualDeviceDTO.setModelSignage(this.getModelSignageByAnswer(submitAnswerReq)); virtualDeviceDTO.setModelSignage(this.getModelSignageByAnswer(submitAnswerReq));
R saveResult = deviceClient.saveVirtualDevice(virtualDeviceDTO); R saveResult = deviceClient.saveVirtualDevice(virtualDeviceDTO);
Assert.isTrue(saveResult.isSuccess() && Func.isNotEmpty(saveResult.getData()),() -> { Assert.isTrue(saveResult.isSuccess(),() -> {
throw new ServiceException(saveResult.getMsg()); throw new ServiceException(saveResult.getMsg());
}); });
Long instanceId = Long.valueOf(String.valueOf(saveResult.getData())); // Long instanceId = Long.valueOf(String.valueOf(saveResult.getData()));
LambdaUpdateWrapper<EmInfoEntity> luw = Wrappers.<EmInfoEntity>lambdaUpdate() // LambdaUpdateWrapper<EmInfoEntity> luw = Wrappers.<EmInfoEntity>lambdaUpdate()
.set(EmInfoEntity::getDeviceInstanceId, instanceId) // .set(EmInfoEntity::getDeviceInstanceId, instanceId)
.eq(EmInfoEntity::getNumber, submitAnswerReq.getEmCode()); // .eq(EmInfoEntity::getNumber, submitAnswerReq.getEmCode());
Assert.isTrue(emInfoService.update(luw),() -> { // Assert.isTrue(emInfoService.update(luw),() -> {
throw new ServiceException("保存设备实例ID失败"); // throw new ServiceException("保存设备实例ID失败");
}); // });
submitAnswerReq.setInstanceId(instanceId.toString()); submitAnswerReq.setInstanceId(submitAnswerReq.getEmCode());
return fdpQuestionService.submitDeviceAnswer(submitAnswerReq); return fdpQuestionService.submitDeviceAnswer(submitAnswerReq);
} }

7
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java

@ -59,6 +59,13 @@ public class StationController extends BladeController {
return R.data(vos); return R.data(vos);
} }
@GetMapping("/detail/{id}")
@ApiOperationSupport(order = 60)
@ApiOperation(value = "查看详情", notes = "查看详情")
public R<StationEntity> detail(@PathVariable @ApiParam("主键ID") Long id) {
return R.data(stationService.getById(id));
}
/** /**
* 新增 * 新增
*/ */

24
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

@ -24,6 +24,9 @@ import com.hnac.hzims.operational.station.wrapper.StationWrapper;
import com.hnac.hzinfo.sdk.v5.project.ProjectClient; import com.hnac.hzinfo.sdk.v5.project.ProjectClient;
import com.hnac.hzinfo.sdk.v5.project.dto.ProjectDTO; import com.hnac.hzinfo.sdk.v5.project.dto.ProjectDTO;
import com.hnac.hzinfo.sdk.v5.project.vo.ProjectVO;*/ import com.hnac.hzinfo.sdk.v5.project.vo.ProjectVO;*/
import com.hnac.hzinfo.sdk.core.response.Result;
import com.hnac.hzinfo.sdk.v5.project.ProjectClient;
import com.hnac.hzinfo.sdk.v5.project.dto.ProjectDTO;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@ -62,7 +65,7 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
private final IDeptClient deptClient; private final IDeptClient deptClient;
private final UserAuthDataService userAuthDataService; private final UserAuthDataService userAuthDataService;
private final IUserClient userClient; private final IUserClient userClient;
//private final ProjectClient projectClient; private final ProjectClient projectClient;
private final BladeLogger logger; private final BladeLogger logger;
private final IQuestionClient questionClient; private final IQuestionClient questionClient;
@ -91,11 +94,14 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
Assert.isTrue(this.saveOrUpdate(req),() -> { Assert.isTrue(this.saveOrUpdate(req),() -> {
throw new ServiceException("创建/修改站点信息失败!"); throw new ServiceException("创建/修改站点信息失败!");
}); });
// 智能诊断站点推送 // 如果设备数据来源未选定其他 则进行站点初始化操作
ExecutorService executor = Executors.newSingleThreadExecutor(); if(!StationConstants.HZ3000_OTHER.equals(req.getDataSource())) {
executor.submit(() -> questionClient.submitStationInfo(req.getCode(), null)); // 智能诊断站点推送
// 新建项目 ExecutorService executor = Executors.newSingleThreadExecutor();
executor.submit(() -> this.instanceProject(req)); executor.submit(() -> questionClient.submitStationInfo(req.getCode(), ""));
// 新建项目
executor.submit(() -> this.instanceProject(req));
}
} }
@Override @Override
@ -103,7 +109,7 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
if(Func.isEmpty(req.getSecretKey()) || Func.isEmpty(req.getDataSource())) { if(Func.isEmpty(req.getSecretKey()) || Func.isEmpty(req.getDataSource())) {
return true; return true;
} }
/*if(super.updateById(req)) { if(super.updateById(req)) {
ProjectDTO projectDTO = new ProjectDTO(); ProjectDTO projectDTO = new ProjectDTO();
projectDTO.setName(req.getName()); projectDTO.setName(req.getName());
projectDTO.setSource(1); projectDTO.setSource(1);
@ -113,7 +119,7 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
Result result = projectClient.saveOrUpdate(projectDTO); Result result = projectClient.saveOrUpdate(projectDTO);
logger.info("operational:station:buildStation:"+req.getCode(), JSON.toJSONString(result)); logger.info("operational:station:buildStation:"+req.getCode(), JSON.toJSONString(result));
return result.getCode() == ResultCode.SUCCESS.getCode() && result.isSuccess(); return result.getCode() == ResultCode.SUCCESS.getCode() && result.isSuccess();
}*/ }
return false; return false;
} }
@ -161,7 +167,7 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
if (ObjectUtil.isNotEmpty(req.getEndDate())) { if (ObjectUtil.isNotEmpty(req.getEndDate())) {
le(StationEntity::getCreateTime, req.getEndDate()); le(StationEntity::getCreateTime, req.getEndDate());
} }
orderByAsc(StationEntity::getCreateTime); //orderByAsc(StationEntity::getCreateTime);
}}; }};
queryWrapper.orderByDesc(StationEntity::getSort); queryWrapper.orderByDesc(StationEntity::getSort);
queryWrapper.orderByDesc(StationEntity::getUpdateTime); queryWrapper.orderByDesc(StationEntity::getUpdateTime);

Loading…
Cancel
Save