diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationRelation.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationRelation.java new file mode 100644 index 0000000..509ca22 --- /dev/null +++ b/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; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/HomeMapStationVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/HomeMapStationVo.java new file mode 100644 index 0000000..3aa7c25 --- /dev/null +++ b/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; +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/RunReportConstant.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/RunReportConstant.java index 90d534b..2fae440 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/RunReportConstant.java +++ b/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 HS_MODEL_SIGNAGE = "hs_ecological_flow_model"; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java index 7351f30..ce3a5c3 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java +++ b/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.station.entity.StationEntity; 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 io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -177,9 +178,9 @@ public class StationController extends BladeController { @ApiLog @GetMapping("/getHomeStationList") @ApiOperationSupport(order = 91) - @ApiOperation(value = "获取首页站点列表", notes = "") - public R> getHomeStationList(@RequestParam(value = "deptId", required = false) Long deptId, @RequestParam(value = "types", required = false) List types, @RequestParam(value = "serveType", required = false) Integer serveType) { - return R.data(stationService.getHomeStationList(deptId, types, serveType,true)); + @ApiOperation(value = "获取首页地图站点列表", notes = "") + public R> getHomeStationList() { + return R.data(stationService.homeMapStationVo()); } @ApiLog diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationRelationController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationRelationController.java new file mode 100644 index 0000000..0241dbd --- /dev/null +++ b/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 stationRelation) { + + return R.data(stationRelationService.getStationRelationList(stationRelation)); + } + + @GetMapping("/page") + @ApiOperation("分页查询列表") + @ApiOperationSupport(order = 2) + public R> 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 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 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 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> getDevice() { + R> rData = deviceClient.getDeviceByModelSignage(RunReportConstant.HS_MODEL_SIGNAGE); + if (rData.getCode() == 200) { + List data = rData.getData(); + return R.data(data); + } else { + return R.fail("获取设备信息失败"); + } + } + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.java new file mode 100644 index 0000000..e08e69e --- /dev/null +++ b/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 { + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.xml new file mode 100644 index 0000000..e1cfa29 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationRelationService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationRelationService.java new file mode 100644 index 0000000..e8e9964 --- /dev/null +++ b/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 { + + List getStationRelationList(StationRelation stationRelation); + + IPage getStationRelationPageList(StationRelation stationRelation, Query query); +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java index 4e3faac..b54f579 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java +++ b/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.hnac.hzims.operational.main.vo.StationCountVo; 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.StationVO; import org.springblade.core.mp.base.BaseService; @@ -136,4 +137,6 @@ public interface IStationService extends BaseService { * @return 更新是否成功 */ boolean updateBatchSort(List req); + + List homeMapStationVo(); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationRelationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationRelationServiceImpl.java new file mode 100644 index 0000000..6e02935 --- /dev/null +++ b/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 implements IStationRelationService { + @Override + public List getStationRelationList(StationRelation stationRelation) { + LambdaQueryWrapper 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 getStationRelationPageList(StationRelation stationRelation, Query query) { + LambdaQueryWrapper 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); + } +} 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 aa58a0f..6b85aa8 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 @@ -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.IStationPushConfigService; 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.StationPushConfigVO; import com.hnac.hzims.operational.station.vo.StationVO; @@ -776,4 +777,31 @@ public class StationServiceImpl extends BaseServiceImpl homeMapStationVo() { + List stations = this.list(Wrappers.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()); + } } diff --git a/hzims-service/operational/src/main/resources/db/2.0.5.sql b/hzims-service/operational/src/main/resources/db/2.0.5.sql new file mode 100644 index 0000000..01b2814 --- /dev/null +++ b/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='站点和霍山生态流量电站的关联关系表'; \ No newline at end of file