Browse Source

#站点接口优化

zhongwei
yang_shj 6 months ago
parent
commit
323b16b580
  1. 130
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationRelation.java
  2. 44
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/HomeMapStationVo.java
  3. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/RunReportConstant.java
  4. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java
  5. 134
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationRelationController.java
  6. 8
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.java
  7. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.xml
  8. 19
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationRelationService.java
  9. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java
  10. 47
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationRelationServiceImpl.java
  11. 28
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java
  12. 19
      hzims-service/operational/src/main/resources/db/2.0.5.sql

130
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationRelation.java

@ -0,0 +1,130 @@
package com.hnac.hzims.operational.station.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import okhttp3.internal.annotations.EverythingIsNonNull;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 站点和霍山生态流量电站的关联关系表
* @author tanghaihao
* @date 2023年10月08日 13:58
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("station_relation")
public class StationRelation implements Serializable {
private static final long serialVersionUID=1L;
/**
* ID
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 站点编码
*/
@TableField("station_code")
private String stationCode;
/**
* 站点名称
*/
@TableField(exist = false)
private String stationName;
/**
* 设备编码
*/
@TableField("device_code")
private String deviceCode;
/**
* 设备名称
*/
@TableField(exist = false)
private String deviceName;
/**
* 核定流量
*/
@TableField("flow_value")
private String flowValue;
/**
* 低级告警负责人id
*/
@TableField("low_soe_user_id")
private String lowSoeUserId;
/**
* 低级告警电话号码
*/
@TableField("low_soe_phone")
private String lowSoePhone;
/**
* 中级告警负责人id
*/
@TableField("middle_soe_user_id")
private String middleSoeUserId;
/**
* 中级告警电话号码
*/
@TableField("middle_soe_phone")
private String middleSoePhone;
/**
* 高级告警负责人id
*/
@TableField("high_soe_user_id")
private String highSoeUserId;
/**
* 高级告警电话号码
*/
@TableField("high_soe_phone")
private String highSoePhone;
/**
* 当日是否发送预警
*/
@TableField("send_warning")
private Integer sendWarning;
/**
* 当日是否发送告警
*/
@TableField("send_soe")
private Integer sendSoe;
/**
* 创建时间
*/
@TableField("create_time")
private LocalDateTime createTime;
/**
* 更新时间
*/
@TableField("update_time")
private LocalDateTime updateTime;
/**
* 逻辑删除
*/
@TableField("is_deleted")
private Integer isDeleted;
}

44
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/HomeMapStationVo.java

@ -0,0 +1,44 @@
package com.hnac.hzims.operational.station.vo;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.SqlCondition;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.mp.support.QueryField;
/**
* @author ysj
*/
@Data
public class HomeMapStationVo {
@ApiModelProperty("行政区划")
private String areaCode;
@ApiModelProperty("编号")
private String code;
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("经度(东经)")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Float lgtd;
@ApiModelProperty("纬度(北纬)")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Float lttd;
@ApiModelProperty("所属机构")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Long refDept;
@ApiModelProperty("站点是否为国外 1:是;0:否")
private Boolean isAbroad;
@ApiModelProperty("所属国家")
private String refCountry;
}

5
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/RunReportConstant.java

@ -5,4 +5,9 @@ public interface RunReportConstant {
* 运行月报定时任务 * 运行月报定时任务
*/ */
String TASK_VALUE_RUN_REPORT_CREATE = "runReportCreateHandler"; String TASK_VALUE_RUN_REPORT_CREATE = "runReportCreateHandler";
/**
* 数据平台霍山生态流量监测模型标识
*/
String HS_MODEL_SIGNAGE = "hs_ecological_flow_model";
} }

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

@ -10,6 +10,7 @@ import com.hnac.hzims.operational.data.service.HzimsDataService;
import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.operational.station.vo.HomeMapStationVo;
import com.hnac.hzims.operational.station.vo.StationVO; import com.hnac.hzims.operational.station.vo.StationVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -177,9 +178,9 @@ public class StationController extends BladeController {
@ApiLog @ApiLog
@GetMapping("/getHomeStationList") @GetMapping("/getHomeStationList")
@ApiOperationSupport(order = 91) @ApiOperationSupport(order = 91)
@ApiOperation(value = "获取首页站点列表", notes = "") @ApiOperation(value = "获取首页地图站点列表", notes = "")
public R<List<StationEntity>> getHomeStationList(@RequestParam(value = "deptId", required = false) Long deptId, @RequestParam(value = "types", required = false) List<Integer> types, @RequestParam(value = "serveType", required = false) Integer serveType) { public R<List<HomeMapStationVo>> getHomeStationList() {
return R.data(stationService.getHomeStationList(deptId, types, serveType,true)); return R.data(stationService.homeMapStationVo());
} }
@ApiLog @ApiLog

134
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationRelationController.java

@ -0,0 +1,134 @@
package com.hnac.hzims.operational.station.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.operational.station.RunReportConstant;
import com.hnac.hzims.operational.station.entity.StationRelation;
import com.hnac.hzims.operational.station.service.IStationRelationService;
import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSupport;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* @author tanghaihao
* @date 2023年10月08日 15:04
*/
@RestController
@RequestMapping("/station/station-relation")
@AllArgsConstructor
@Api(value = "站点和霍山生态流量电站的关联关系管理",tags = "站点和霍山生态流量电站的关联关系管理")
public class StationRelationController {
private final IStationRelationService stationRelationService;
private final DeviceClient deviceClient;
@GetMapping("/list")
@ApiOperation("查询列表")
@ApiOperationSupport(order = 1)
public R<List<StationRelation>> list(StationRelation stationRelation) {
return R.data(stationRelationService.getStationRelationList(stationRelation));
}
@GetMapping("/page")
@ApiOperation("分页查询列表")
@ApiOperationSupport(order = 2)
public R<IPage<StationRelation>> page(StationRelation stationRelation, Query query) {
return R.data(stationRelationService.getStationRelationPageList(stationRelation, query));
}
@PostMapping("/save")
@ApiOperation("保存")
@ApiOperationSupport(order = 3)
public R save(@RequestBody @Valid StationRelation stationRelation) {
if (Func.isEmpty(stationRelation.getStationCode())) {
return R.fail("站点编码不能为空");
}
if (Func.isEmpty(stationRelation.getDeviceCode())) {
return R.fail("设备编码不能为空");
}
if (Func.isEmpty(stationRelation.getLowSoeUserId())) {
return R.fail("低级告警负责人不能为空");
}
if (Func.isEmpty(stationRelation.getLowSoePhone())) {
return R.fail("低级告警电话号码不能为空");
}
if (Func.isEmpty(stationRelation.getMiddleSoeUserId())) {
return R.fail("中级告警负责人不能为空");
}
if (Func.isEmpty(stationRelation.getMiddleSoePhone())) {
return R.fail("中级告警电话号码不能为空");
}
if (Func.isEmpty(stationRelation.getHighSoeUserId())) {
return R.fail("高级告警负责人不能为空");
}
if (Func.isEmpty(stationRelation.getHighSoePhone())) {
return R.fail("高级告警电话号码不能为空");
}
if (Func.isEmpty(stationRelation.getFlowValue())) {
return R.fail("核定流量不能为空");
}
LambdaQueryWrapper<StationRelation> wrapper = new LambdaQueryWrapper();
wrapper.and(item -> item.eq(StationRelation::getStationCode, stationRelation.getStationCode())
.or().eq(StationRelation::getDeviceCode, stationRelation.getDeviceCode()));
wrapper.eq(StationRelation::getIsDeleted, 0);
int count = stationRelationService.count(wrapper);
if (count > 0) {
return R.fail("站点关联关系已存在");
}
return R.status(stationRelationService.save(stationRelation));
}
@PostMapping("/update")
@ApiOperation("编辑")
@ApiOperationSupport(order = 4)
public R update(@RequestBody @Valid StationRelation stationRelation) {
LambdaQueryWrapper<StationRelation> wrapper = new LambdaQueryWrapper();
wrapper.and(item -> item.eq(StationRelation::getStationCode, stationRelation.getStationCode())
.or().eq(StationRelation::getDeviceCode, stationRelation.getDeviceCode()));
wrapper.eq(StationRelation::getIsDeleted, 0);
wrapper.ne(StationRelation::getId, stationRelation.getId());
int count = stationRelationService.count(wrapper);
if (count > 0) {
return R.fail("站点关联关系已存在");
}
return R.status(stationRelationService.updateById(stationRelation));
}
@GetMapping("/remove")
@ApiOperation("删除")
@ApiOperationSupport(order = 5)
public R remove(Long id) {
LambdaUpdateWrapper<StationRelation> wrapper = new LambdaUpdateWrapper<>();
wrapper.set(StationRelation::getIsDeleted, 1);
wrapper.eq(StationRelation::getId, id);
stationRelationService.update(wrapper);
return R.success("操作成功");
}
@GetMapping("/getDevice")
@ApiOperation("获取生态流量模型的设备信息")
@ApiOperationSupport(order = 6)
public R<List<DeviceInstanceVO>> getDevice() {
R<List<DeviceInstanceVO>> rData = deviceClient.getDeviceByModelSignage(RunReportConstant.HS_MODEL_SIGNAGE);
if (rData.getCode() == 200) {
List<DeviceInstanceVO> data = rData.getData();
return R.data(data);
} else {
return R.fail("获取设备信息失败");
}
}
}

8
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.java

@ -0,0 +1,8 @@
package com.hnac.hzims.operational.station.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.operational.station.entity.StationRelation;
public interface StationRelationMapper extends BaseMapper<StationRelation> {
}

5
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.xml

@ -0,0 +1,5 @@
<?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">
<mapper namespace="com.hnac.hzims.operational.station.mapper.StationRelationMapper">
</mapper>

19
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationRelationService.java

@ -0,0 +1,19 @@
package com.hnac.hzims.operational.station.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.operational.station.entity.StationRelation;
import org.springblade.core.mp.support.Query;
import java.util.List;
/**
* @author tanghaihao
* @date 2023年10月08日 15:04
*/
public interface IStationRelationService extends IService<StationRelation> {
List<StationRelation> getStationRelationList(StationRelation stationRelation);
IPage<StationRelation> getStationRelationPageList(StationRelation stationRelation, Query query);
}

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java

@ -3,6 +3,7 @@ package com.hnac.hzims.operational.station.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.operational.main.vo.StationCountVo; import com.hnac.hzims.operational.main.vo.StationCountVo;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.vo.HomeMapStationVo;
import com.hnac.hzims.operational.station.vo.StationAndDeptVo; import com.hnac.hzims.operational.station.vo.StationAndDeptVo;
import com.hnac.hzims.operational.station.vo.StationVO; import com.hnac.hzims.operational.station.vo.StationVO;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
@ -136,4 +137,6 @@ public interface IStationService extends BaseService<StationEntity> {
* @return 更新是否成功 * @return 更新是否成功
*/ */
boolean updateBatchSort(List<StationEntity> req); boolean updateBatchSort(List<StationEntity> req);
List<HomeMapStationVo> homeMapStationVo();
} }

47
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationRelationServiceImpl.java

@ -0,0 +1,47 @@
package com.hnac.hzims.operational.station.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.operational.station.entity.StationRelation;
import com.hnac.hzims.operational.station.mapper.StationRelationMapper;
import com.hnac.hzims.operational.station.service.IStationRelationService;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.utils.Func;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author tanghaihao
* @date 2023年10月08日 14:37
*/
@Service
public class StationRelationServiceImpl extends ServiceImpl<StationRelationMapper, StationRelation> implements IStationRelationService {
@Override
public List<StationRelation> getStationRelationList(StationRelation stationRelation) {
LambdaQueryWrapper<StationRelation> wrapper = new LambdaQueryWrapper();
if (Func.isNotEmpty(stationRelation.getStationCode())) {
wrapper.eq(StationRelation::getStationCode, stationRelation.getStationCode());
}
if (Func.isNotEmpty(stationRelation.getDeviceCode())) {
wrapper.eq(StationRelation::getDeviceCode, stationRelation.getDeviceCode());
}
wrapper.eq(StationRelation::getIsDeleted, 0);
return this.list(wrapper);
}
@Override
public IPage<StationRelation> getStationRelationPageList(StationRelation stationRelation, Query query) {
LambdaQueryWrapper<StationRelation> wrapper = new LambdaQueryWrapper();
if (Func.isNotEmpty(stationRelation.getStationCode())) {
wrapper.eq(StationRelation::getStationCode, stationRelation.getStationCode());
}
if (Func.isNotEmpty(stationRelation.getDeviceCode())) {
wrapper.eq(StationRelation::getDeviceCode, stationRelation.getDeviceCode());
}
wrapper.eq(StationRelation::getIsDeleted, 0);
return this.page(Condition.getPage(query), wrapper);
}
}

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

@ -25,6 +25,7 @@ import com.hnac.hzims.operational.station.mapper.StationMapper;
import com.hnac.hzims.operational.station.service.IStationAttributeService; import com.hnac.hzims.operational.station.service.IStationAttributeService;
import com.hnac.hzims.operational.station.service.IStationPushConfigService; import com.hnac.hzims.operational.station.service.IStationPushConfigService;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.operational.station.vo.HomeMapStationVo;
import com.hnac.hzims.operational.station.vo.StationAndDeptVo; import com.hnac.hzims.operational.station.vo.StationAndDeptVo;
import com.hnac.hzims.operational.station.vo.StationPushConfigVO; import com.hnac.hzims.operational.station.vo.StationPushConfigVO;
import com.hnac.hzims.operational.station.vo.StationVO; import com.hnac.hzims.operational.station.vo.StationVO;
@ -776,4 +777,31 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
} }
return this.updateBatchById(stations); return this.updateBatchById(stations);
} }
/**
* 获取首页地图站点列表
* @return
*/
@Override
public List<HomeMapStationVo> homeMapStationVo() {
List<StationEntity> stations = this.list(Wrappers.<StationEntity>lambdaQuery()
.isNotNull(StationEntity::getRefDept)
.isNotNull(StationEntity::getAreaCode)
);
if(CollectionUtil.isEmpty(stations)){
return new ArrayList<>();
}
return stations.stream().map(o->{
HomeMapStationVo mapStation = new HomeMapStationVo();
mapStation.setAreaCode(o.getAreaCode());
mapStation.setName(o.getName());
mapStation.setCode(o.getCode());
mapStation.setLttd(o.getLttd());
mapStation.setLgtd(o.getLgtd());
mapStation.setRefDept(o.getRefDept());
mapStation.setIsAbroad(o.getIsAbroad());
mapStation.setRefCountry(o.getRefCountry());
return mapStation;
}).collect(Collectors.toList());
}
} }

19
hzims-service/operational/src/main/resources/db/2.0.5.sql

@ -0,0 +1,19 @@
DROP TABLE IF EXISTS `station_relation`;
CREATE TABLE `station_relation` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`station_code` varchar(200) DEFAULT NULL COMMENT '站点编码',
`device_code` varchar(128) DEFAULT NULL COMMENT '设备编码',
`send_warning` int(11) DEFAULT '0' COMMENT '当日是否发送预警',
`send_soe` int(11) DEFAULT '0' COMMENT '当日是否发送告警',
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
`is_deleted` tinyint(1) DEFAULT '0' COMMENT '逻辑删除',
`low_soe_user_id` varchar(20) DEFAULT NULL COMMENT '低级告警负责人id',
`low_soe_phone` varchar(20) DEFAULT NULL COMMENT '低级告警电话号码',
`middle_soe_user_id` varchar(20) DEFAULT NULL COMMENT '中级告警负责人id',
`middle_soe_phone` varchar(20) DEFAULT NULL COMMENT '中级告警电话号码',
`high_soe_user_id` varchar(20) DEFAULT NULL COMMENT '高级告警负责人id',
`high_soe_phone` varchar(20) DEFAULT NULL COMMENT '高级告警电话号码',
`flow_value` double(12,3) DEFAULT NULL COMMENT '核定流量',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='站点和霍山生态流量电站的关联关系表';
Loading…
Cancel
Save