From 323b16b5802797b1870c3fe052b0736265a23170 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 24 May 2024 15:47:17 +0800 Subject: [PATCH 01/15] =?UTF-8?q?#=E7=AB=99=E7=82=B9=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../station/entity/StationRelation.java | 130 ++++++++++++++++++++ .../operational/station/vo/HomeMapStationVo.java | 44 +++++++ .../operational/station/RunReportConstant.java | 5 + .../station/controller/StationController.java | 7 +- .../controller/StationRelationController.java | 134 +++++++++++++++++++++ .../station/mapper/StationRelationMapper.java | 8 ++ .../station/mapper/StationRelationMapper.xml | 5 + .../station/service/IStationRelationService.java | 19 +++ .../station/service/IStationService.java | 3 + .../service/impl/StationRelationServiceImpl.java | 47 ++++++++ .../station/service/impl/StationServiceImpl.java | 28 +++++ .../operational/src/main/resources/db/2.0.5.sql | 19 +++ 12 files changed, 446 insertions(+), 3 deletions(-) create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationRelation.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/HomeMapStationVo.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationRelationController.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.xml create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationRelationService.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationRelationServiceImpl.java create mode 100644 hzims-service/operational/src/main/resources/db/2.0.5.sql 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 From 4c1eb9c1d2af572fa5a37b60428f6f439679f66b Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Sat, 25 May 2024 10:53:32 +0800 Subject: [PATCH 02/15] =?UTF-8?q?#=E5=A4=A7=E6=A8=A1=E5=9E=8B=E5=8F=91?= =?UTF-8?q?=E7=94=B5=E9=87=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/fill/feign/IGenerateClient.java | 26 +++++++++++++++ .../fill/feign/IGenerateClientFallback.java | 15 +++++++++ .../controller/InteractiveController.java | 9 +++++ .../interactive/service/IInteractiveService.java | 2 ++ .../service/impl/InteractiveServiceImpl.java | 31 ++++++++++++++++++ .../operational/fill/feign/GenerateClient.java | 38 ++++++++++++++++++++++ 6 files changed, 121 insertions(+) create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClient.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClientFallback.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClient.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClient.java new file mode 100644 index 0000000..d73fa37 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClient.java @@ -0,0 +1,26 @@ +package com.hnac.hzims.operational.fill.feign; + +import com.hnac.hzims.operational.OperationalConstants; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * @author ysj + */ +@FeignClient( + value = OperationalConstants.APP_NAME, + fallback = IGenerateClientFallback.class +) +public interface IGenerateClient { + + String API_PREFIX = "/feign/generate/"; + + String STATION_GENERATE_BY_TIME = API_PREFIX + "/stationGenerateByTime"; + + + @GetMapping(STATION_GENERATE_BY_TIME) + Double stationGenerateByTime(@RequestParam("stationId") String stationId, + @RequestParam("startTime") String startTime, + @RequestParam("endTime") String endTime); +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClientFallback.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClientFallback.java new file mode 100644 index 0000000..da7c067 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClientFallback.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.operational.fill.feign; + +import org.springframework.stereotype.Component; + +/** + * @author hx + */ +@Component +public class IGenerateClientFallback implements IGenerateClient { + + @Override + public Double stationGenerateByTime(String stationId, String startTime, String endTime) { + return 0.0; + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java index 40e79b3..472d092 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java @@ -77,4 +77,13 @@ public class InteractiveController { public R sendRemoteControl(@RequestBody ControlDTO operate) { return interactiveService.sendRemoteControl(operate); } + + @ApiOperation("站点发电量") + @ApiOperationSupport(order = 7) + @RequestMapping(value = "/generation",method = {RequestMethod.GET,RequestMethod.POST}) + public R generation(@RequestParam @ApiParam("站点编号") String stationId, + @RequestParam @ApiParam("开始时间") String startTime, + @RequestParam @ApiParam("结束时间")String endTime) { + return R.data(interactiveService.generation(stationId,startTime,endTime) + "kwh"); + } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java index 2f6588a..acdcb37 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java @@ -43,4 +43,6 @@ public interface IInteractiveService { R knowledgeAsk(String question, String sessionId, String userId, String knowledge); R sendRemoteControl(ControlDTO operate); + + Double generation(String stationId, String startTime, String endTime); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java index f5571dd..7ba145b 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java @@ -14,6 +14,9 @@ import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService; import com.hnac.hzims.bigmodel.interactive.service.IParamsService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import com.hnac.hzims.operational.fill.feign.IGenerateClient; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.feign.IStationClient; import com.xxl.job.core.log.XxlJobLogger; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -54,6 +57,10 @@ public class InteractiveServiceImpl implements IInteractiveService { private final IRemoteClient remoteClient; + private final IStationClient stationClient; + + private final IGenerateClient generateClient; + private final IJumpPageService jumpPageService; private final IParamsService paramsService; @@ -277,4 +284,28 @@ public class InteractiveServiceImpl implements IInteractiveService { public R sendRemoteControl(ControlDTO operate) { return remoteClient.sendCtrl(operate); } + + /** + * 站点发电量 + * @param stationId + * @param startTime + * @param endTime + * @return + */ + @Override + public Double generation(String stationId, String startTime, String endTime) { + // 步骤1.查询站点 + R station = stationClient.getStationByCode(stationId); + if(!station.isSuccess() || ObjectUtil.isEmpty(station.getData())){ + return 0.0; + } + // 步骤2.查询填报发电量 + double fill = generateClient.stationGenerateByTime(stationId,startTime,endTime); + + // 步骤3.查询设备 + + // 步骤4.遍历设备查询发电量 + + return fill; + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java new file mode 100644 index 0000000..54e86ac --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java @@ -0,0 +1,38 @@ +package com.hnac.hzims.operational.fill.feign; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.operational.fill.entity.GenerateEntity; +import com.hnac.hzims.operational.fill.service.GenerateService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + + +/** + * @author ysj + */ +@RestController +@Slf4j +@AllArgsConstructor +public class GenerateClient implements IGenerateClient { + + private final GenerateService generateService; + + @Override + @GetMapping(STATION_GENERATE_BY_TIME) + public Double stationGenerateByTime(String stationId, String startTime, String endTime) { + List generates = generateService.list(Wrappers.lambdaQuery() + .eq(GenerateEntity::getStationCode,stationId) + .ge(GenerateEntity::getFillDate,startTime) + .le(GenerateEntity::getGenerate,endTime) + ); + if(CollectionUtil.isEmpty(generates)){ + return 0.0; + } + return generates.stream().mapToDouble(GenerateEntity::getGenerate).sum(); + } +} From 3b2f2da88c20a4c1e0e973775a48445ac3a6dc9d Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Sat, 25 May 2024 11:35:59 +0800 Subject: [PATCH 03/15] =?UTF-8?q?#=E5=A4=A7=E6=A8=A1=E5=9E=8B=E5=8F=91?= =?UTF-8?q?=E7=94=B5=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/equipment/feign/IEmInfoClient.java | 7 ++ .../hzims/equipment/feign/IEmInfoClientBack.java | 6 ++ .../hnac/hzims/equipment/feign/EmInfoClient.java | 6 ++ .../hnac/hzims/equipment/mapper/EmParamMapper.java | 1 + .../hnac/hzims/equipment/mapper/EmParamMapper.xml | 9 ++ .../hzims/equipment/service/IEmInfoService.java | 2 + .../hzims/equipment/service/IEmParamService.java | 1 + .../equipment/service/impl/EmInfoServiceImpl.java | 47 +++++++++++ .../equipment/service/impl/EmParamServiceImpl.java | 5 ++ .../controller/InteractiveController.java | 10 +-- .../service/impl/InteractiveServiceImpl.java | 96 ++++++++++++++++++++-- .../main/service/IAnalyseDataService.java | 5 +- .../main/service/impl/AnalyseDataServiceImpl.java | 61 +++++++++++++- 13 files changed, 241 insertions(+), 15 deletions(-) diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java index 6e6dec3..df356ed 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java @@ -19,6 +19,7 @@ package com.hnac.hzims.equipment.feign; import com.hnac.hzims.EquipmentConstants; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.vo.DeviceVO; +import com.hnac.hzims.equipment.vo.RideDeviceVo; import org.springblade.core.tool.api.R; import org.springblade.system.vo.CreateTableVO; import org.springframework.cloud.openfeign.FeignClient; @@ -84,6 +85,9 @@ public interface IEmInfoClient { String DEVICE_BY_PATH = API_PREFIX + "/deviceByPath"; String EM_INFO_LIST = API_PREFIX + "/emInfoList"; + String RIDE_DEVICES = API_PREFIX + "/rideDevices"; + + @PostMapping(DETAIL) EmInfoEntity getByCode(@RequestParam("code") String id); @@ -169,4 +173,7 @@ public interface IEmInfoClient { @GetMapping(EM_INFO_LIST) R> emInfoList(EmInfoEntity req); + + @GetMapping(RIDE_DEVICES) + List rideDevices(List longs); } diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java index c411e7e..104d494 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java @@ -2,6 +2,7 @@ package com.hnac.hzims.equipment.feign; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.vo.DeviceVO; +import com.hnac.hzims.equipment.vo.RideDeviceVo; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.api.R; import org.springblade.system.vo.CreateTableVO; @@ -114,4 +115,9 @@ public class IEmInfoClientBack implements IEmInfoClient { public R> emInfoList(EmInfoEntity req) { return R.fail("远程调用失败"); } + + @Override + public List rideDevices(List longs) { + return new ArrayList<>(); + } } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java index 637da20..444b59c 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java @@ -9,6 +9,7 @@ import com.hnac.hzims.common.utils.Condition; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.service.IEmInfoService; import com.hnac.hzims.equipment.vo.DeviceVO; +import com.hnac.hzims.equipment.vo.RideDeviceVo; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.ObjectUtil; @@ -155,6 +156,11 @@ public class EmInfoClient implements IEmInfoClient { return R.data(service.list(queryWrapper)); } + @Override + public List rideDevices(List deptIds) { + return service.rideDevices(deptIds); + } + @PostMapping(GET_EM_CREATE_TABLE) @Override public List getEmCreateTable(List tableNames) { diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.java index a2cb335..0e83b71 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.java @@ -19,4 +19,5 @@ public interface EmParamMapper extends UserDataScopeBaseMapper { List selectRideCountGroupEmIdByDepts(@Param("list") List list); + List rides(List deviceIds); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.xml b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.xml index bf699b0..09861ea 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.xml +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.xml @@ -53,4 +53,13 @@ 'installedCapacity') + 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 ead9dee..5632b61 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 @@ -98,4 +98,6 @@ public interface IEmInfoService extends BaseService { List select(Long deptId); List getEmInfoTree(EmInfoEntity req); + + List rideDevices(List deptIds); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmParamService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmParamService.java index 9284338..ca087ff 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmParamService.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmParamService.java @@ -19,4 +19,5 @@ public interface IEmParamService extends BaseService { Map> getRideCountGroupEmIdByDepts(List emIds); + List rides(List deviceIds); } 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 fb6fb04..75d0db5 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 @@ -949,4 +949,51 @@ public class EmInfoServiceImpl extends BaseServiceImpl rideDevices(List deptIds) { + // 查询设备 + List devices = this.list(Wrappers.lambdaQuery() + .in(EmInfoEntity::getDepartment,deptIds) + .eq(EmInfoEntity::getHomePageDisplay,"1") + .eq(EmInfoEntity::getEmType,"2") + ); + if(CollectionUtil.isEmpty(devices)){ + return new ArrayList<>(); + } + List paramList = paramService.rides(devices.stream().map(EmInfoEntity::getId).collect(Collectors.toList())); + return devices.stream().map(device->{ + RideDeviceVo rideDevice = new RideDeviceVo(); + BeanUtil.copyProperties(device,rideDevice); + // 寻找设备配置参数 + List itemParamList = paramList.stream().filter(o->device.getId().equals(o.getInfoId())).collect(Collectors.toList()); + if(CollectionUtil.isNotEmpty(itemParamList)) { + // 遍历设备配置参数 + for (EmParamEntity paramEntity : itemParamList) { + String paramName = paramEntity.getParamName(); + switch (paramName) { + case "ct": + case "CT": + rideDevice.setCt(Double.parseDouble(paramEntity.getParamValue())); + break; + case "pt": + case "PT": + rideDevice.setPt(Double.parseDouble(paramEntity.getParamValue())); + break; + default: + break; + } + } + // 设置ct * pt + if (null != rideDevice.getCt() && null != rideDevice.getPt()) { + rideDevice.setRide(rideDevice.getCt() * rideDevice.getPt()); + }else{ + rideDevice.setRide(1.0); + } + }else{ + rideDevice.setRide(1.0); + } + return rideDevice; + }).collect(Collectors.toList()); + } + } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmParamServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmParamServiceImpl.java index 394189f..cd4f0c6 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmParamServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmParamServiceImpl.java @@ -69,4 +69,9 @@ public class EmParamServiceImpl extends BaseServiceImpl rides(List deviceIds) { + return this.baseMapper.rides(deviceIds); + } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java index 472d092..bf68a91 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java @@ -1,6 +1,5 @@ package com.hnac.hzims.bigmodel.interactive.controller; -import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.bigmodel.BigModelConstants; @@ -8,7 +7,6 @@ import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzinfo.log.annotation.Business; import io.swagger.annotations.Api; -import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; @@ -16,9 +14,7 @@ import org.springblade.core.tool.api.R; import org.springblade.system.dto.ControlDTO; import org.springframework.web.bind.annotation.*; -import javax.servlet.http.HttpServletRequest; -import java.util.HashMap; -import java.util.Map; +import java.text.DecimalFormat; /** * @Author: huangxing @@ -84,6 +80,8 @@ public class InteractiveController { public R generation(@RequestParam @ApiParam("站点编号") String stationId, @RequestParam @ApiParam("开始时间") String startTime, @RequestParam @ApiParam("结束时间")String endTime) { - return R.data(interactiveService.generation(stationId,startTime,endTime) + "kwh"); + double generate = interactiveService.generation(stationId,startTime,endTime); + DecimalFormat format = new DecimalFormat("0.00"); + return R.data(format.format(generate) + "kwh"); } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java index 7ba145b..93730b0 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.hnac.hzims.bigmodel.configuration.BigModelInvokeUrl; import com.hnac.hzims.bigmodel.entity.FunctionEntity; import com.hnac.hzims.bigmodel.function.service.IFunctionService; @@ -14,19 +15,26 @@ import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService; import com.hnac.hzims.bigmodel.interactive.service.IParamsService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import com.hnac.hzims.equipment.feign.IEmInfoClient; +import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; +import com.hnac.hzims.equipment.vo.RideDeviceVo; import com.hnac.hzims.operational.fill.feign.IGenerateClient; +import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; +import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; +import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; +import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; import com.xxl.job.core.log.XxlJobLogger; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.MapUtils; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springblade.core.tool.utils.StringUtil; +import org.springblade.core.tool.utils.*; import org.springblade.system.dto.ControlDTO; import org.springblade.system.dto.DeptStationDTO; import org.springblade.system.feign.IDeptClient; @@ -38,7 +46,10 @@ import org.springframework.stereotype.Service; import org.springframework.util.Assert; import javax.servlet.http.HttpServletResponse; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.concurrent.*; import java.util.stream.Collectors; import static com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants.TypeEnum; @@ -55,6 +66,8 @@ public class InteractiveServiceImpl implements IInteractiveService { private final BladeLogger logger; + private final IEmInfoClient deviceClient; + private final IRemoteClient remoteClient; private final IStationClient stationClient; @@ -73,8 +86,12 @@ public class InteractiveServiceImpl implements IInteractiveService { private final RedisTemplate redisTemplate; + private final IAnalyseDataSearchClient analyseDataSearchClient; + private final ExtraResolveStrategyService extraResolveStrategyService; + private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("station-device-generate-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy()); + @Value("${fdp.host}") private String fdpHost; @@ -303,9 +320,78 @@ public class InteractiveServiceImpl implements IInteractiveService { double fill = generateClient.stationGenerateByTime(stationId,startTime,endTime); // 步骤3.查询设备 + List devices = deviceClient.rideDevices(Collections.singletonList(station.getData().getRefDept())); + if(CollectionUtil.isEmpty(devices)){ + return fill; + } // 步骤4.遍历设备查询发电量 + // 监控线程执行完后返回结果 + CountDownLatch countDownLatch = new CountDownLatch(devices.size()); + List deviceGenerate = new CopyOnWriteArrayList(); + for(RideDeviceVo device : devices){ + pool.submit(()->{ + deviceGenerate.add(this.periodTargetFloat(startTime,endTime,5,6,device.getNumber(),device.getRide(), HomePageConstant.HYDROPOWER_GENERATE_POWER)); + }); + countDownLatch.countDown(); + } + //所有模板数据获取完成后释放锁 + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + return fill + deviceGenerate.stream().mapToDouble(Double::doubleValue).sum(); + } - return fill; + /*** + * 指标数据列表查询 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值 + * @param cycleType 间隔周期 : 0-> 秒 1-> 分 2-> 小时 3->天 4-> 周 5-> 月 6-> 年 + * @param deviceCode 设备编号 + * @param ride 配电比 + * @param signages 指标 + * @return + */ + private Double periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode,Double ride,String signages) { + AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); + List signboardConditions = new ArrayList<>(); + AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); + analyzeDataConditionPO.setFull(1); + po.setDeviceCode(deviceCode); + analyzeDataConditionPO.setSignages(signages); + analyzeDataConditionPO.setKeepFigures(2); + analyzeDataConditionPO.setAccessRules(accessRules); + analyzeDataConditionPO.setSaveTimeType(cycleType); + // 间隔 + analyzeDataConditionPO.setTimeInterval(1); + analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + signboardConditions.add(analyzeDataConditionPO); + po.setSignboardConditions(signboardConditions); + R> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po); + if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { + return 0.0; + } + List records = result.getData(); + if(CollectionUtil.isEmpty(records)){ + return 0.0; + } + AnalyzeDataConditionVO analyzeDataConditionVO = records.get(0); + if (ObjectUtil.isEmpty(analyzeDataConditionVO)) { + return 0.0; + } + List analyseDataTaosVOList = analyzeDataConditionVO.getList(); + if (CollectionUtil.isEmpty(analyseDataTaosVOList)) { + return 0.0; + } + AnalyseDataTaosVO analyseDataTaosVO = analyzeDataConditionVO.getList().get(0); + if (ObjectUtil.isEmpty(analyseDataTaosVO) || StringUtil.isBlank(analyseDataTaosVO.getVal())) { + return 0.0; + } + return Double.parseDouble(analyseDataTaosVO.getVal()) * ride; } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAnalyseDataService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAnalyseDataService.java index 14d1292..fe2130f 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAnalyseDataService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAnalyseDataService.java @@ -15,10 +15,13 @@ public interface IAnalyseDataService { List getAnalyzeCodeBySignages(Function convert, T resource); + List analyzeCodeBySignages(List list); + + List periodTargetSignages(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, List signages); List periodTargetData(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signages); List periodTargetDatas(String startTime, String endTime, Integer accessRules, Integer cycleType, List deviceCodes, String signages); - Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, Integer ride ,String signages); + Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, Double ride ,String signages); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java index 927d6d2..865f0e8 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java @@ -22,7 +22,10 @@ import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; @@ -47,6 +50,58 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService { return result; } + /** + * 查询设备实例属性标识 + * @param list + * @return + */ + @Override + public List analyzeCodeBySignages(List list) { + R> result = analyseDataSearchClient.getAnalyzeCodeBySignages(list); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + return new ArrayList<>(); + } + return result.getData(); + } + + /*** + * 指标数据列表查询 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值 + * @param cycleType 间隔周期 : 0-> 秒 1-> 分 2-> 小时 3->天 4-> 周 5-> 月 6-> 年 + * @param deviceCode 设备编号 + * @param signages 指标集合 + * @return + */ + @Override + public List periodTargetSignages(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, List signages) { + AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); + List signboardConditions = new ArrayList<>(); + signages.forEach(signage->{ + AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); + analyzeDataConditionPO.setFull(1); + po.setDeviceCode(deviceCode); + analyzeDataConditionPO.setKeepFigures(2); + analyzeDataConditionPO.setAccessRules(accessRules); + analyzeDataConditionPO.setSaveTimeType(cycleType); + analyzeDataConditionPO.setSignages(signage); + // 间隔 + analyzeDataConditionPO.setTimeInterval(1); + analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME))); + signboardConditions.add(analyzeDataConditionPO); + }); + po.setSignboardConditions(signboardConditions); + log.error("period_targets_data_request {}",po); + R> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po); + if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) { + return new ArrayList<>(); + } + log.error("period_targets_data_resp {}",result); + return result.getData(); + } + /*** * 指标数据列表查询 * @param startTime 开始时间 @@ -134,7 +189,7 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService { * @return */ @Override - public Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode,Integer ride,String signages) { + public Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode,Double ride,String signages) { AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); List signboardConditions = new ArrayList<>(); AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); @@ -170,7 +225,7 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService { if (ObjectUtil.isEmpty(analyseDataTaosVO) || StringUtil.isBlank(analyseDataTaosVO.getVal())) { return 0f; } - return Float.parseFloat(Optional.ofNullable(analyseDataTaosVO.getVal()).orElse("0")) * ride; + return Float.parseFloat(String.valueOf(Double.parseDouble(analyseDataTaosVO.getVal()) * ride)) ; } From 1c0aec87e2365ed27364621f3b1e736896852c15 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Sat, 25 May 2024 11:37:51 +0800 Subject: [PATCH 04/15] =?UTF-8?q?add:=E7=AB=99=E7=82=B9=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/interactive/vo/AttrSelectionVO.java | 14 ++++++ .../hzims/bigmodel/interactive/vo/DataItemVO.java | 39 ++++++++++++++++ .../hnac/hzims/bigmodel/interactive/vo/DataVO.java | 32 +++++++++++++ .../hzims/bigmodel/interactive/vo/RealDataVO.java | 20 ++++++++ .../operational/station/feign/IStationClient.java | 5 +- .../station/feign/IStationClientFallBack.java | 5 ++ .../interactive/constants/FuncRouteEnum.java | 1 + .../constants/SearchStationTypeEnum.java | 39 ++++++++++++++++ .../interactive/constants/SearchTypeEnum.java | 28 ++++++++++++ .../controller/InteractiveController.java | 7 +++ .../interactive/service/IInteractiveService.java | 3 ++ .../service/impl/ExtraResolveStrategyService.java | 49 ++++++++++++++++---- .../service/impl/InteractiveServiceImpl.java | 53 ++++++++++++++++++++++ .../hzims/bigmodel/interactive/vo/DataItemVO.java | 39 ---------------- .../hnac/hzims/bigmodel/interactive/vo/DataVO.java | 32 ------------- .../hzims/bigmodel/interactive/vo/RealDataVO.java | 20 -------- .../operational/station/feign/StationClient.java | 13 ++++++ 17 files changed, 299 insertions(+), 100 deletions(-) create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AttrSelectionVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java create mode 100644 hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchTypeEnum.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java delete mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AttrSelectionVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AttrSelectionVO.java new file mode 100644 index 0000000..67f0011 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AttrSelectionVO.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/24 15:55 + */ +@Data +public class AttrSelectionVO extends SelectionVO implements Serializable { + private DataItemVO item; +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java new file mode 100644 index 0000000..914f25b --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java @@ -0,0 +1,39 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/22 10:20 + */ +@Data +public class DataItemVO implements Serializable { + + private String name; + + @JSONField(name = "id") + private String attrId; + + @JSONField(name = "param_name") + private String attrName; + + @JSONField(name = "device_name") + private String deviceName; + + @JSONField(name = "device_id") + private String deviceId; + + @JSONField(name = "station_id") + private String projectId; + + @JSONField(name = "station_name") + private String projectName; + + private String signage; + + private String units; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java new file mode 100644 index 0000000..1f2fcfd --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java @@ -0,0 +1,32 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import com.alibaba.fastjson.annotation.JSONField; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/22 10:28 + */ +@Data +public class DataVO implements Serializable { + + /**数据查询类型:实时、历史**/ + private String type; + + @JSONField(name = "time_begin") + private String startTime; + + @JSONField(name = "time_end") + private String endTime; + + /**包括:"其它"、"最大值"、"最小值"、"总和值"、"平均值"**/ + private String method; + + /**实时数据结果集**/ + private RealDataVO real; + + private DataItemVO item; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java new file mode 100644 index 0000000..16a5a46 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springblade.core.tool.utils.DateUtil; + +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/24 10:26 + */ +@Data +public class RealDataVO implements Serializable { + + private String time; + + private String value; + +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java index cc8856a..8574363 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java @@ -30,7 +30,7 @@ public interface IStationClient { String LIST = API_PREFIX + "/list"; String QUERY_EXIST_LGTD_LTTD = API_PREFIX + "/queryExistLgtdAndLttd"; String GET_ONE = API_PREFIX + "/getOne"; - + String GET_STATIONS_BY_TYPE_AND_DURATION = "/getStationByTypeAndDuration"; String QUERY_STATION_BY_CODES = API_PREFIX + "/querySatationByCodes"; @GetMapping(GET_LIST_ALL) @@ -81,4 +81,7 @@ public interface IStationClient { */ @PostMapping(QUERY_STATION_BY_CODES) R> querySatationByCodes(@RequestParam("codes") List codes); + + @GetMapping(GET_STATIONS_BY_TYPE_AND_DURATION) + R> getStationByTypeAndDuration(@RequestParam(required = false) String startTime,@RequestParam(required = false) String endTime,@RequestParam String type); } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java index 5c0aca1..eeb90e5 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java @@ -76,4 +76,9 @@ public class IStationClientFallBack implements IStationClient { public R> querySatationByCodes(List codes) { return R.data(new ArrayList<>()); } + + @Override + public R> getStationByTypeAndDuration(String startTime, String endTime, String type) { + return R.fail("远程调用失败!"); + } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java index 4b1d359..8ce75d0 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java @@ -21,6 +21,7 @@ public enum FuncRouteEnum { CHOOSE_FAULT("choose_fault","选择故障",null), CONFIRM_YK("confirm_yk","遥控确认", FunctionConstants.TypeEnum.PARAMS), SHOW_PARAM("show_param","设备参数查询", FunctionConstants.TypeEnum.PARAMS), + CHOOSE_YC("choose_yc","选择遥测数据",FunctionConstants.TypeEnum.CHOOSE) ; @Getter private String funcCode; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java new file mode 100644 index 0000000..15be73a --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java @@ -0,0 +1,39 @@ +package com.hnac.hzims.bigmodel.interactive.constants; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * @Author: huangxing + * @Date: 2024/05/24 17:14 + */ +@AllArgsConstructor +public enum SearchStationTypeEnum { + TOTAL("站点总数量",null), + HYDROPOWER_TOTAL("水电站总数量","0"), + WIND_POWER_TOTAL("风电场总数量","1"), + ENERGY_STORAGE_TOTAL("储能站总数量","3"), + PHOTOVOLTAIC_TOTAL("光伏站总数量","5"), + CHARGE_TOTAL("充电站总数量","7"), + HYDROPOWER_NUM("水电站接入量","0"), + WIND_POWER_NUM("风电场接入量","1"), + ENERGY_STORAGE_NUM("储能站接入量","3"), + PHOTOVOLTAIC_NUM("光伏站接入量","5"), + CHARGE_NUM("充电站接入量","7"), + ; + + @Getter + private String searchStationType; + @Getter + private String stationType; + + public static SearchStationTypeEnum getTypeEnum(String searchStationType) { + return Arrays.stream(SearchStationTypeEnum.class.getEnumConstants()) + .filter(e -> e.getSearchStationType().equals(searchStationType)) + .findFirst() + .orElse(null); + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchTypeEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchTypeEnum.java new file mode 100644 index 0000000..0692d62 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchTypeEnum.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.bigmodel.interactive.constants; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.Getter; + +import java.util.Arrays; + +/** + * @Author: huangxing + * @Date: 2024/05/24 17:13 + */ +@AllArgsConstructor +public enum SearchTypeEnum { + REAL("实时"), + HISTORY("历史") + ; + @Getter + private String searchType; + + public static SearchTypeEnum getSearchType(String searchType) { + return Arrays.stream(SearchTypeEnum.class.getEnumConstants()) + .filter(e -> e.getSearchType().equals(searchType)) + .findFirst() + .orElse(null); + } + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java index 40e79b3..9fbb0b2 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java @@ -77,4 +77,11 @@ public class InteractiveController { public R sendRemoteControl(@RequestBody ControlDTO operate) { return interactiveService.sendRemoteControl(operate); } + + @ApiOperation("解析接入站点数量") + @ApiOperationSupport(order = 7) + @PostMapping("/resolveStations") + public R resolveStations(String startTime,String endTime,String type,String enumType) { + return R.data(interactiveService.resolveStations(startTime,endTime,type,enumType)); + } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java index 2f6588a..d37d0cf 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java @@ -2,6 +2,7 @@ package com.hnac.hzims.bigmodel.interactive.service; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; import org.springblade.core.tool.api.R; import org.springblade.system.dto.ControlDTO; @@ -14,6 +15,8 @@ import java.util.Map; */ public interface IInteractiveService { + ExtraVO resolveStations(String startTime, String endTime, String type, String enumType); + R resolve(ModelFunctionReq req); R ask(String question,String sessionId,String userId); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index 9502fec..4143a10 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -12,15 +12,14 @@ import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; +import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceFuncVO; import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.log.XxlJobLogger; import lombok.AllArgsConstructor; +import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.BeanUtil; -import org.springblade.core.tool.utils.DateUtil; -import org.springblade.core.tool.utils.Func; -import org.springblade.core.tool.utils.StringUtil; +import org.springblade.core.tool.utils.*; import org.springblade.system.dto.ControlDTO; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @@ -45,6 +44,7 @@ public class ExtraResolveStrategyService { private final IStationVideoTypeClient videoTypeClient; private final JumpRouteJoinStrategy jumpRouteJoinStrategy; private final DeviceClient deviceClient; + private final BladeLogger logger; private final RedisTemplate redisTemplate; /** @@ -74,6 +74,8 @@ public class ExtraResolveStrategyService { return this.resolveConfirmRemote(extra); case SHOW_PARAM: return this.resolveShowParam(extra); + case CHOOSE_YC: + return this.resolveChooseYc(extra); default: break; } @@ -82,16 +84,47 @@ public class ExtraResolveStrategyService { return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class); } + private ExtraVO resolveChooseYc(JSONObject extra) { + ExtraVO result = new ExtraVO(); + JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data"))); + if(data.containsKey("ycs")) { + List attrs = JSONArray.parseArray(JSON.toJSONString(data.get("ycs")), AttrSelectionVO.class); + result.setSelection(attrs); + } + result.setFuncCode(FuncRouteEnum.CHOOSE_YC.getFuncCode()); + result.setSpecial(true); + result.setType(FuncRouteEnum.CHOOSE_YC.getType().getType()); + return result; + } + private ExtraVO resolveShowParam(Map extra) { ExtraVO result = new ExtraVO(); result.setFuncCode(FuncRouteEnum.SHOW_PARAM.getFuncCode()); result.setType(FuncRouteEnum.SHOW_PARAM.getType().getType()); Map param = new HashMap(1); DataVO data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")),DataVO.class); - if(Func.isNotEmpty(data) && Func.isNotEmpty(data.getReal()) && Func.isNotEmpty(data.getReal().getTime()) && StringUtil.isNotBlank(data.getReal().getTime())) { - RealDataVO real = data.getReal(); - Date date = DateUtil.parse(real.getTime(), PATTERN_DATETIME); - real.setTime(DateUtil.format(date,DateUtil.PATTERN_DATETIME)); + if(Func.isNotEmpty(data)) { + if(Func.isNotEmpty(data.getReal())) { + if(Func.isNotEmpty(data.getReal().getTime()) && StringUtil.isNotBlank(data.getReal().getTime())) { + RealDataVO real = data.getReal(); + Date date = DateUtil.parse(real.getTime(), PATTERN_DATETIME); + real.setTime(DateUtil.format(date,DateUtil.PATTERN_DATETIME)); + } + } + if(Func.isNotEmpty(data.getItem())) { + if("历史".equals(data.getType())) { + // 历史数据需要手动查询功能ID供前端使用 + DataItemVO item = data.getItem(); + R> attrR = deviceClient.getOnlineAttr(item.getDeviceId()); + if(attrR.isSuccess() && CollectionUtil.isNotEmpty(attrR.getData())) { + List attrList = attrR.getData(); + Optional facDeviceIdOptional = attrList.stream().parallel().filter(f -> item.getSignage().equals(f.getSignage())) + .map(DeviceInstanceAttrVO::getFacDeviceAttrId).findFirst(); + logger.info("hzims-big-model:resolveShowParam:facDeviceId",facDeviceIdOptional.orElse("")); + item.setAttrId(facDeviceIdOptional.orElse(null)); + } + } + } } param.put("data", data); result.setParams(param); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java index f5571dd..ba34e33 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java @@ -9,11 +9,17 @@ import com.hnac.hzims.bigmodel.configuration.BigModelInvokeUrl; import com.hnac.hzims.bigmodel.entity.FunctionEntity; import com.hnac.hzims.bigmodel.function.service.IFunctionService; import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; +import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants; +import com.hnac.hzims.bigmodel.interactive.constants.SearchStationTypeEnum; +import com.hnac.hzims.bigmodel.interactive.constants.SearchTypeEnum; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService; import com.hnac.hzims.bigmodel.interactive.service.IParamsService; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; +import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.feign.IStationClient; import com.xxl.job.core.log.XxlJobLogger; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -66,12 +72,59 @@ public class InteractiveServiceImpl implements IInteractiveService { private final RedisTemplate redisTemplate; + private final IStationClient stationClient; + private final ExtraResolveStrategyService extraResolveStrategyService; @Value("${fdp.host}") private String fdpHost; @Override + public ExtraVO resolveStations(String startTime, String endTime, String type, String enumType) { + ExtraVO extraVO = new ExtraVO(); + extraVO.setType(TypeEnum.PARAMS.getType()); + extraVO.setFuncCode("stations_num"); + String stationType = ""; + SearchStationTypeEnum stationTypeEnum = SearchStationTypeEnum.getTypeEnum(enumType); + if(SearchTypeEnum.REAL.getSearchType().equals(type)) { + startTime = null; + endTime = null; + } + else { + switch(stationTypeEnum) { + case HYDROPOWER_TOTAL: + case WIND_POWER_TOTAL: + case ENERGY_STORAGE_TOTAL: + case PHOTOVOLTAIC_TOTAL: + case CHARGE_TOTAL: + stationType = stationTypeEnum.getStationType(); + startTime = null; + break; + case HYDROPOWER_NUM: + case WIND_POWER_NUM: + case ENERGY_STORAGE_NUM: + case PHOTOVOLTAIC_NUM: + case CHARGE_NUM: + stationType = stationTypeEnum.getStationType(); + break; + default: + throw new ServiceException("未查询到相关"); + } + } + R> stationListR = stationClient.getStationByTypeAndDuration(startTime, endTime, stationType); + Assert.isTrue(stationListR.isSuccess(),() -> { + throw new ServiceException("获取接入站点数量失败!"); + }); + Map params = new HashMap<>(); + params.put("searchStationType",stationTypeEnum.getSearchStationType()); + params.put("num",stationTypeEnum.getSearchStationType()); + params.put("startTime",startTime); + params.put("endTime",endTime); + extraVO.setParams(params); + return extraVO; + } + + @Override public R resolve(ModelFunctionReq req) { logger.info("interactive:resolve","开始解析大模型函数,函数内容为:" + JSON.toJSONString(req)); FunctionEntity function = functionService.getFunctionByCode(req.getFunctionName()); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java deleted file mode 100644 index 914f25b..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import com.alibaba.fastjson.annotation.JSONField; -import lombok.Data; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/22 10:20 - */ -@Data -public class DataItemVO implements Serializable { - - private String name; - - @JSONField(name = "id") - private String attrId; - - @JSONField(name = "param_name") - private String attrName; - - @JSONField(name = "device_name") - private String deviceName; - - @JSONField(name = "device_id") - private String deviceId; - - @JSONField(name = "station_id") - private String projectId; - - @JSONField(name = "station_name") - private String projectName; - - private String signage; - - private String units; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java deleted file mode 100644 index 1f2fcfd..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import com.alibaba.fastjson.annotation.JSONField; -import lombok.Data; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/22 10:28 - */ -@Data -public class DataVO implements Serializable { - - /**数据查询类型:实时、历史**/ - private String type; - - @JSONField(name = "time_begin") - private String startTime; - - @JSONField(name = "time_end") - private String endTime; - - /**包括:"其它"、"最大值"、"最小值"、"总和值"、"平均值"**/ - private String method; - - /**实时数据结果集**/ - private RealDataVO real; - - private DataItemVO item; - -} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java deleted file mode 100644 index 16a5a46..0000000 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzims.bigmodel.interactive.vo; - -import com.fasterxml.jackson.annotation.JsonFormat; -import lombok.Data; -import org.springblade.core.tool.utils.DateUtil; - -import java.io.Serializable; - -/** - * @Author: huangxing - * @Date: 2024/05/24 10:26 - */ -@Data -public class RealDataVO implements Serializable { - - private String time; - - private String value; - -} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java index e9cf868..fbefca8 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java @@ -14,6 +14,7 @@ import org.springblade.core.mp.support.Condition; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.core.tool.utils.StringUtil; import org.springblade.system.user.entity.User; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; @@ -137,6 +138,18 @@ public class StationClient implements IStationClient { .in(StationEntity::getCode,codes))); } + @Override + @GetMapping("/getStationByTypeAndDuration") + public R> getStationByTypeAndDuration(@RequestParam(required = false) String startTime, + @RequestParam(required = false) String endTime, + @RequestParam(required = false) String type) { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery() + .eq(StationEntity::getType, type) + .le(StringUtil.isNotBlank(endTime) && Func.isNotEmpty(endTime),StationEntity::getCreateTime, endTime) + .ge(StringUtil.isNotBlank(startTime) && Func.isNotEmpty(startTime),StationEntity::getCreateTime, startTime); + return R.data(stationService.list(wrapper)); + } + @Override @PostMapping("/getStationByCodeOrRedDept") From 90b431a7b31bd50c30085d0ac9f7c3f32de78787 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Sat, 25 May 2024 12:08:03 +0800 Subject: [PATCH 05/15] =?UTF-8?q?#=E5=A4=A7=E6=A8=A1=E5=9E=8B=E5=8F=91?= =?UTF-8?q?=E7=94=B5=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hzims-service/hzims-big-model/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hzims-service/hzims-big-model/pom.xml b/hzims-service/hzims-big-model/pom.xml index cedb16a..91ae6d1 100644 --- a/hzims-service/hzims-big-model/pom.xml +++ b/hzims-service/hzims-big-model/pom.xml @@ -75,6 +75,10 @@ com.hnac.hzinfo.data hzinfo-data-sdk + + com.hnac.hzims + equipment-api + From b74c3296c3f2d4ec5414e40b5310490637420aad Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Sat, 25 May 2024 18:46:28 +0800 Subject: [PATCH 06/15] =?UTF-8?q?add:=E7=AB=99=E7=82=B9=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/station/feign/IStationClient.java | 4 +- .../constants/SearchStationTypeEnum.java | 24 ++++++----- .../controller/InteractiveController.java | 5 ++- .../service/impl/ExtraResolveStrategyService.java | 3 ++ .../service/impl/InteractiveServiceImpl.java | 50 +++++----------------- .../bigmodel/interactive/vo/StationSearchVO.java | 24 +++++++++++ .../bigmodel/schedule/InteractiveSchedule.java | 18 +++----- .../bigmodel/schedule/XxlJobHandlerConstant.java | 4 +- 8 files changed, 65 insertions(+), 67 deletions(-) create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSearchVO.java diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java index 8574363..28019bd 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java @@ -30,7 +30,7 @@ public interface IStationClient { String LIST = API_PREFIX + "/list"; String QUERY_EXIST_LGTD_LTTD = API_PREFIX + "/queryExistLgtdAndLttd"; String GET_ONE = API_PREFIX + "/getOne"; - String GET_STATIONS_BY_TYPE_AND_DURATION = "/getStationByTypeAndDuration"; + String GET_STATIONS_BY_TYPE_AND_DURATION = API_PREFIX + "/getStationByTypeAndDuration"; String QUERY_STATION_BY_CODES = API_PREFIX + "/querySatationByCodes"; @GetMapping(GET_LIST_ALL) @@ -83,5 +83,5 @@ public interface IStationClient { R> querySatationByCodes(@RequestParam("codes") List codes); @GetMapping(GET_STATIONS_BY_TYPE_AND_DURATION) - R> getStationByTypeAndDuration(@RequestParam(required = false) String startTime,@RequestParam(required = false) String endTime,@RequestParam String type); + R> getStationByTypeAndDuration(@RequestParam(required = false) String startTime,@RequestParam(required = false) String endTime,@RequestParam(required = false) String type); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java index 15be73a..51ce3a1 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java @@ -11,23 +11,25 @@ import java.util.Arrays; */ @AllArgsConstructor public enum SearchStationTypeEnum { - TOTAL("站点总数量",null), - HYDROPOWER_TOTAL("水电站总数量","0"), - WIND_POWER_TOTAL("风电场总数量","1"), - ENERGY_STORAGE_TOTAL("储能站总数量","3"), - PHOTOVOLTAIC_TOTAL("光伏站总数量","5"), - CHARGE_TOTAL("充电站总数量","7"), - HYDROPOWER_NUM("水电站接入量","0"), - WIND_POWER_NUM("风电场接入量","1"), - ENERGY_STORAGE_NUM("储能站接入量","3"), - PHOTOVOLTAIC_NUM("光伏站接入量","5"), - CHARGE_NUM("充电站接入量","7"), + TOTAL("站点总数量",null,"运维平台目前接入站点总数为:%s"), + HYDROPOWER_TOTAL("水电站总数量","0","运维平台目前接入水电站总数为:%s"), + WIND_POWER_TOTAL("风电场总数量","1","运维平台目前接入风电场总数为:%s"), + ENERGY_STORAGE_TOTAL("储能站总数量","3","运维平台目前接入储能站总数为:%s"), + PHOTOVOLTAIC_TOTAL("光伏站总数量","5","运维平台目前接入光伏站总数为:%s"), + CHARGE_TOTAL("充电站总数量","7","运维平台目前接入充电站总数为:%s"), + HYDROPOWER_NUM("水电站接入量","0","运维平台目前接入水电站接入量为:%s"), + WIND_POWER_NUM("风电场接入量","1","运维平台目前接入风电场接入量为:%s"), + ENERGY_STORAGE_NUM("储能站接入量","3","运维平台目前接入储能站接入量为:%s"), + PHOTOVOLTAIC_NUM("光伏站接入量","5","运维平台目前接入光伏站接入量为:%s"), + CHARGE_NUM("充电站接入量","7","运维平台目前接入充电站接入量为:%s"), ; @Getter private String searchStationType; @Getter private String stationType; + @Getter + private String label; public static SearchStationTypeEnum getTypeEnum(String searchStationType) { return Arrays.stream(SearchStationTypeEnum.class.getEnumConstants()) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java index 03dd26e..0771fba 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java @@ -5,6 +5,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.bigmodel.BigModelConstants; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; +import com.hnac.hzims.bigmodel.interactive.vo.StationSearchVO; import com.hnac.hzinfo.log.annotation.Business; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -77,8 +78,8 @@ public class InteractiveController { @ApiOperation("解析接入站点数量") @ApiOperationSupport(order = 7) @PostMapping("/resolveStations") - public R resolveStations(String startTime,String endTime,String type,String enumType) { - return R.data(interactiveService.resolveStations(startTime,endTime,type,enumType)); + public R resolveStations(@RequestBody StationSearchVO req) { + return R.data(interactiveService.resolveStations(req.getStartTime(),req.getEndTime(),req.getType(),req.getEnumType())); } @ApiOperation("站点发电量") diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index 4143a10..ed8ffff 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -81,6 +81,9 @@ public class ExtraResolveStrategyService { } } } + else if(extra.containsKey("extra")){ + return extra.getObject("extra",ExtraVO.class); + } return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java index 516c5ea..bfe3f2d 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java @@ -22,7 +22,7 @@ import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzims.equipment.feign.IEmInfoClient; -import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; + import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.equipment.vo.RideDeviceVo; import com.hnac.hzims.operational.fill.feign.IGenerateClient; import com.hnac.hzims.operational.main.constant.HomePageConstant; @@ -92,8 +92,6 @@ public class InteractiveServiceImpl implements IInteractiveService { private final RedisTemplate redisTemplate; - private final IStationClient stationClient; - private final IAnalyseDataSearchClient analyseDataSearchClient; private final ExtraResolveStrategyService extraResolveStrategyService; @@ -108,40 +106,23 @@ public class InteractiveServiceImpl implements IInteractiveService { ExtraVO extraVO = new ExtraVO(); extraVO.setType(TypeEnum.PARAMS.getType()); extraVO.setFuncCode("stations_num"); - String stationType = ""; + String label; SearchStationTypeEnum stationTypeEnum = SearchStationTypeEnum.getTypeEnum(enumType); - if(SearchTypeEnum.REAL.getSearchType().equals(type)) { - startTime = null; - endTime = null; + if(!startTime.equals(endTime)) { + label = String.format("自%s到%s时间为止,",startTime,endTime); } else { - switch(stationTypeEnum) { - case HYDROPOWER_TOTAL: - case WIND_POWER_TOTAL: - case ENERGY_STORAGE_TOTAL: - case PHOTOVOLTAIC_TOTAL: - case CHARGE_TOTAL: - stationType = stationTypeEnum.getStationType(); - startTime = null; - break; - case HYDROPOWER_NUM: - case WIND_POWER_NUM: - case ENERGY_STORAGE_NUM: - case PHOTOVOLTAIC_NUM: - case CHARGE_NUM: - stationType = stationTypeEnum.getStationType(); - break; - default: - throw new ServiceException("未查询到相关"); - } + startTime = null; + endTime = null; + label = "目前"; } - R> stationListR = stationClient.getStationByTypeAndDuration(startTime, endTime, stationType); + R> stationListR = stationClient.getStationByTypeAndDuration(startTime, endTime, stationTypeEnum.getStationType()); Assert.isTrue(stationListR.isSuccess(),() -> { throw new ServiceException("获取接入站点数量失败!"); }); Map params = new HashMap<>(); params.put("searchStationType",stationTypeEnum.getSearchStationType()); - params.put("num",stationTypeEnum.getSearchStationType()); + params.put("label",label + String.format(stationTypeEnum.getLabel(),stationListR.getData().size())); params.put("startTime",startTime); params.put("endTime",endTime); extraVO.setParams(params); @@ -192,18 +173,7 @@ public class InteractiveServiceImpl implements IInteractiveService { } private void addQuestionSessionId(String sessionId) { - // 添加redis问题会话 - Object json = redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); - if(ObjectUtil.isEmpty(json)){ - List asks = Collections.singletonList(sessionId); - redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,JSONObject.toJSONString(asks)); - }else{ - List asks = JSONObject.parseArray(json.toString(),String.class); - if(!asks.contains(sessionId)){ - asks.add(sessionId); - } - redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,JSONObject.toJSONString(asks)); - } + redisTemplate.opsForList().leftPush(HZIMS_BIGMODEL_ASK_KEY,sessionId); } @Override diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSearchVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSearchVO.java new file mode 100644 index 0000000..d111b70 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSearchVO.java @@ -0,0 +1,24 @@ +package com.hnac.hzims.bigmodel.interactive.vo; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author: huangxing + * @Date: 2024/05/25 14:03 + */ +@Data +public class StationSearchVO implements Serializable { + + private String startTime; + + private String endTime; + + @NotBlank(message = "查询类型不能为空") + private String type; + + private String enumType; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java index 85affae..e145733 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java @@ -23,6 +23,7 @@ import com.xxl.job.core.log.XxlJobLogger; import lombok.AllArgsConstructor; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springframework.data.redis.core.RedisTemplate; @@ -90,12 +91,7 @@ public class InteractiveSchedule { @XxlJob(GET_INTERACTIVE_RESULT) public ReturnT getInteractiveResult(String params) { - Object json = redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); - if(ObjectUtil.isEmpty(json)){ - XxlJobLogger.log("未获取到问题标识,或者用户未进行提问!"); - return ReturnT.SUCCESS; - } - List sessionIds = JSONObject.parseArray(json.toString(),String.class); + List sessionIds = redisTemplate.opsForList().range(HZIMS_BIGMODEL_ASK_KEY, 0, -1); if(CollectionUtil.isEmpty(sessionIds)){ XxlJobLogger.log("问题都已经回答完毕!"); return ReturnT.SUCCESS; @@ -106,13 +102,13 @@ public class InteractiveSchedule { if(sessionIds.contains(answerVO.getSessionId())){ WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); - wsService.sendMessage(session,message); + if(Func.isNotEmpty(session)) { + wsService.sendMessage(session,message); + } } - // 问题回答完成,去除redis问题标记 - if(answerVO.getRunning() == 0){ - sessionIds.remove(answerVO.getSessionId()); + if(answerVO.getRunning() == 0) { + redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,answerVO.getSessionId()); } - redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY, JSONObject.toJSONString(sessionIds)); }, getAnswerPoolExecutor)); return ReturnT.SUCCESS; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java index 7317f54..0f210b7 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java @@ -1,5 +1,7 @@ package com.hnac.hzims.bigmodel.schedule; +import com.hnac.hzims.common.constant.CommonConstant; + /** * @Author: huangxing * @Date: 2024/04/28 16:19 @@ -18,6 +20,6 @@ public interface XxlJobHandlerConstant { String INTERACTIVE_RESULT_KEY = "hzllm:interactive:result"; - String HZIMS_BIGMODEL_ASK_KEY = "hzims:bigmodel:ask:key"; + String HZIMS_BIGMODEL_ASK_KEY = CommonConstant.TENANT_ID + ":hzims:bigmodel:ask:key"; } From 4eb705f531fc2b26c808b9f077968cec30d1cd34 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Sun, 26 May 2024 11:25:38 +0800 Subject: [PATCH 07/15] =?UTF-8?q?add:=E7=AB=99=E7=82=B9=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ExtraResolveStrategyService.java | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java index ed8ffff..60d910d 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java @@ -114,20 +114,20 @@ public class ExtraResolveStrategyService { real.setTime(DateUtil.format(date,DateUtil.PATTERN_DATETIME)); } } - if(Func.isNotEmpty(data.getItem())) { - if("历史".equals(data.getType())) { - // 历史数据需要手动查询功能ID供前端使用 - DataItemVO item = data.getItem(); - R> attrR = deviceClient.getOnlineAttr(item.getDeviceId()); - if(attrR.isSuccess() && CollectionUtil.isNotEmpty(attrR.getData())) { - List attrList = attrR.getData(); - Optional facDeviceIdOptional = attrList.stream().parallel().filter(f -> item.getSignage().equals(f.getSignage())) - .map(DeviceInstanceAttrVO::getFacDeviceAttrId).findFirst(); - logger.info("hzims-big-model:resolveShowParam:facDeviceId",facDeviceIdOptional.orElse("")); - item.setAttrId(facDeviceIdOptional.orElse(null)); - } - } - } +// if(Func.isNotEmpty(data.getItem())) { +// if("历史".equals(data.getType())) { +// // 历史数据需要手动查询功能ID供前端使用 +// DataItemVO item = data.getItem(); +// R> attrR = deviceClient.getOnlineAttr(item.getDeviceId()); +// if(attrR.isSuccess() && CollectionUtil.isNotEmpty(attrR.getData())) { +// List attrList = attrR.getData(); +// Optional facDeviceIdOptional = attrList.stream().parallel().filter(f -> item.getSignage().equals(f.getSignage())) +// .map(DeviceInstanceAttrVO::getFacDeviceAttrId).findFirst(); +// logger.info("hzims-big-model:resolveShowParam:facDeviceId",facDeviceIdOptional.orElse("")); +// item.setAttrId(facDeviceIdOptional.orElse(null)); +// } +// } +// } } param.put("data", data); result.setParams(param); From b8ad77fa361d26fd2d53297116094df0f2449b98 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 27 May 2024 08:13:30 +0800 Subject: [PATCH 08/15] =?UTF-8?q?#=E5=A4=A7=E6=A8=A1=E5=9E=8B=E5=8F=91?= =?UTF-8?q?=E7=94=B5=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/equipment/feign/IEmInfoClient.java | 2 +- .../hnac/hzims/equipment/feign/EmInfoClient.java | 3 ++- .../hnac/hzims/equipment/mapper/EmParamMapper.java | 2 +- .../service/impl/InteractiveServiceImpl.java | 1 - .../fill/controller/GenerateController.java | 9 +++++++ .../operational/fill/feign/GenerateClient.java | 7 ++++-- .../operational/fill/service/GenerateService.java | 2 ++ .../fill/service/impl/GenerateServiceImpl.java | 28 ++++++++++++++++++---- 8 files changed, 44 insertions(+), 10 deletions(-) diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java index df356ed..45145c9 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java @@ -175,5 +175,5 @@ public interface IEmInfoClient { R> emInfoList(EmInfoEntity req); @GetMapping(RIDE_DEVICES) - List rideDevices(List longs); + List rideDevices(@RequestParam("deptIds") List deptIds); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java index 444b59c..de29497 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java @@ -157,7 +157,8 @@ public class EmInfoClient implements IEmInfoClient { } @Override - public List rideDevices(List deptIds) { + @GetMapping(RIDE_DEVICES) + public List rideDevices(@RequestParam("deptIds") List deptIds) { return service.rideDevices(deptIds); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.java index 0e83b71..7244763 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.java @@ -19,5 +19,5 @@ public interface EmParamMapper extends UserDataScopeBaseMapper { List selectRideCountGroupEmIdByDepts(@Param("list") List list); - List rides(List deviceIds); + List rides(@Param("deviceIds") List deviceIds); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java index bfe3f2d..8041056 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java @@ -347,7 +347,6 @@ public class InteractiveServiceImpl implements IInteractiveService { if(CollectionUtil.isEmpty(devices)){ return fill; } - // 步骤4.遍历设备查询发电量 // 监控线程执行完后返回结果 CountDownLatch countDownLatch = new CountDownLatch(devices.size()); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/controller/GenerateController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/controller/GenerateController.java index abe2ff8..54b5591 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/controller/GenerateController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/controller/GenerateController.java @@ -80,4 +80,13 @@ public class GenerateController extends BladeController { return service.pageCondition(filter, query); } + /** + * 新增 + */ + @PostMapping("/test") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "测试发电量保存", notes = "传入InsertPowerEntity对象") + public R test(@RequestBody GenerateEntity entity) { + return R.status(service.test(entity)); + } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java index 54e86ac..a017445 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java @@ -7,6 +7,7 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.utils.CollectionUtil; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.List; @@ -24,11 +25,13 @@ public class GenerateClient implements IGenerateClient { @Override @GetMapping(STATION_GENERATE_BY_TIME) - public Double stationGenerateByTime(String stationId, String startTime, String endTime) { + public Double stationGenerateByTime(@RequestParam("stationId") String stationId, + @RequestParam("startTime") String startTime, + @RequestParam("endTime") String endTime) { List generates = generateService.list(Wrappers.lambdaQuery() .eq(GenerateEntity::getStationCode,stationId) .ge(GenerateEntity::getFillDate,startTime) - .le(GenerateEntity::getGenerate,endTime) + .le(GenerateEntity::getFillDate,endTime) ); if(CollectionUtil.isEmpty(generates)){ return 0.0; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java index 699bd03..fa68b8a 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java @@ -37,4 +37,6 @@ public interface GenerateService extends BaseService { List generateThreeYear(String start, String end, String station); List fillPowerMon(String code); + + boolean test(GenerateEntity entity); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java index bc33c70..88fc4f4 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java @@ -26,10 +26,7 @@ import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; /** @@ -246,6 +243,29 @@ public class GenerateServiceImpl extends BaseServiceImpl 0){ + entity.setId(null); + entity.setFillDate(DateUtil.format(start,DateUtil.PATTERN_DATE)); + entity.setGenerate((random.nextDouble() * 10000) + 50000); + this.save(entity); + calendar.add(Calendar.DAY_OF_MONTH,1); + start = calendar.getTime(); + } + return true; + } + /** * 获取近年月份集合 From eb8d326b6ca9f81f814cd053672b6d3678f05e32 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 27 May 2024 08:49:22 +0800 Subject: [PATCH 09/15] =?UTF-8?q?#=E5=A4=A7=E6=A8=A1=E5=9E=8B=E5=8F=91?= =?UTF-8?q?=E7=94=B5=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/bigmodel/interactive/controller/InteractiveController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java index 0771fba..c109e57 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java @@ -90,6 +90,6 @@ public class InteractiveController { @RequestParam @ApiParam("结束时间")String endTime) { double generate = interactiveService.generation(stationId,startTime,endTime); DecimalFormat format = new DecimalFormat("0.00"); - return R.data(format.format(generate) + "kwh"); + return R.data(format.format(generate) + "kWh"); } } From ce28eac1b62e611a3558e55f16bb5e3bb3a206a0 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Mon, 27 May 2024 09:15:58 +0800 Subject: [PATCH 10/15] =?UTF-8?q?add:=E7=AB=99=E7=82=B9=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../constants/SearchStationTypeEnum.java | 25 ++++++++++++---------- .../websocket/handler/InteractiveHandler.java | 14 ++++++++++++ .../operational/station/feign/StationClient.java | 2 +- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java index 51ce3a1..ea935c1 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java @@ -11,17 +11,20 @@ import java.util.Arrays; */ @AllArgsConstructor public enum SearchStationTypeEnum { - TOTAL("站点总数量",null,"运维平台目前接入站点总数为:%s"), - HYDROPOWER_TOTAL("水电站总数量","0","运维平台目前接入水电站总数为:%s"), - WIND_POWER_TOTAL("风电场总数量","1","运维平台目前接入风电场总数为:%s"), - ENERGY_STORAGE_TOTAL("储能站总数量","3","运维平台目前接入储能站总数为:%s"), - PHOTOVOLTAIC_TOTAL("光伏站总数量","5","运维平台目前接入光伏站总数为:%s"), - CHARGE_TOTAL("充电站总数量","7","运维平台目前接入充电站总数为:%s"), - HYDROPOWER_NUM("水电站接入量","0","运维平台目前接入水电站接入量为:%s"), - WIND_POWER_NUM("风电场接入量","1","运维平台目前接入风电场接入量为:%s"), - ENERGY_STORAGE_NUM("储能站接入量","3","运维平台目前接入储能站接入量为:%s"), - PHOTOVOLTAIC_NUM("光伏站接入量","5","运维平台目前接入光伏站接入量为:%s"), - CHARGE_NUM("充电站接入量","7","运维平台目前接入充电站接入量为:%s"), + STATION_TOTAL("电站总数量",null,"智能运维平台接入电站总数为:%s"), + SET_TOTAL("站点总数量",null,"智能运维平台接入站点总数为:%s"), + HYDROPOWER_TOTAL("水电站总数量","0","智能运维平台接入水电站总数为:%s"), + WIND_POWER_TOTAL("风电场总数量","1","智能运维平台接入风电场总数为:%s"), + ENERGY_STORAGE_TOTAL("储能站总数量","3","智能运维平台接入储能站总数为:%s"), + PHOTOVOLTAIC_TOTAL("光伏站总数量","5","智能运维平台接入光伏站总数为:%s"), + CHARGE_TOTAL("充电站总数量","7","智能运维平台接入充电站总数为:%s"), + STATION_NUM("电站接入量",null,"智能运维平台接入电站总数为:%s"), + SET_NUM("站点接入量",null,"智能运维平台接入站点总数为:%s"), + HYDROPOWER_NUM("水电站接入量","0","智能运维平台接入水电站接入量为:%s"), + WIND_POWER_NUM("风电场接入量","1","智能运维平台接入风电场接入量为:%s"), + ENERGY_STORAGE_NUM("储能站接入量","3","智能运维平台接入储能站接入量为:%s"), + PHOTOVOLTAIC_NUM("光伏站接入量","5","智能运维平台接入光伏站接入量为:%s"), + CHARGE_NUM("充电站接入量","7","智能运维平台接入充电站接入量为:%s"), ; @Getter diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java index 23b8d2e..c8a5ce8 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java @@ -117,6 +117,8 @@ public class InteractiveHandler extends TextWebSocketHandler { case CHOOSE_FAULT: this.handleFaultChoose(messageContext,sessionId); break; + case CHOOSE_YC: + this.handleDataChoose(messageContext,sessionId); default: break; } @@ -209,4 +211,16 @@ public class InteractiveHandler extends TextWebSocketHandler { extra.put("data",data); interactiveService.specialAsk(sessionId,userId,extra); } + + private void handleDataChoose(JSONObject messageContext,String sessionId) { + IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); + String userId = messageContext.getString("userId"); + String funcCode = messageContext.getString("funcCode"); + FaultSelectionVO selectionVO = messageContext.getObject("selection",FaultSelectionVO.class); + Map extra = new HashMap<>(2); + extra.put("func",funcCode); + extra.put("data",selectionVO); + interactiveService.specialAsk(sessionId,userId,extra); + } + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java index fbefca8..b2ca924 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java @@ -144,7 +144,7 @@ public class StationClient implements IStationClient { @RequestParam(required = false) String endTime, @RequestParam(required = false) String type) { LambdaQueryWrapper wrapper = Wrappers.lambdaQuery() - .eq(StationEntity::getType, type) + .eq(StringUtil.isNotBlank(type) && Func.isNotEmpty(type),StationEntity::getType, type) .le(StringUtil.isNotBlank(endTime) && Func.isNotEmpty(endTime),StationEntity::getCreateTime, endTime) .ge(StringUtil.isNotBlank(startTime) && Func.isNotEmpty(startTime),StationEntity::getCreateTime, startTime); return R.data(stationService.list(wrapper)); From 3f0e049e33e948c6b4cf7b040e6ad24a09b95372 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 27 May 2024 09:23:50 +0800 Subject: [PATCH 11/15] =?UTF-8?q?#=E5=A4=A7=E6=A8=A1=E5=9E=8B=E5=8F=91?= =?UTF-8?q?=E7=94=B5=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java index 88fc4f4..9cf07ec 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java @@ -258,7 +258,7 @@ public class GenerateServiceImpl extends BaseServiceImpl 0){ entity.setId(null); entity.setFillDate(DateUtil.format(start,DateUtil.PATTERN_DATE)); - entity.setGenerate((random.nextDouble() * 10000) + 50000); + entity.setGenerate((random.nextDouble() * 2800) + 12000); this.save(entity); calendar.add(Calendar.DAY_OF_MONTH,1); start = calendar.getTime(); From afbab4cc47234542f80f6a0e24717f946e377a20 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 27 May 2024 14:45:51 +0800 Subject: [PATCH 12/15] =?UTF-8?q?#=E5=A1=AB=E6=8A=A5=E5=8F=91=E7=94=B5?= =?UTF-8?q?=E9=87=8F=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/hnac/hzims/operational/fill/feign/GenerateClient.java | 5 ++++- .../hzims/operational/fill/service/impl/GenerateServiceImpl.java | 2 +- .../hzims/operational/main/service/impl/HydropowerServiceImpl.java | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java index a017445..22030a1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java @@ -6,10 +6,12 @@ import com.hnac.hzims.operational.fill.service.GenerateService; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.Date; import java.util.List; @@ -28,9 +30,10 @@ public class GenerateClient implements IGenerateClient { public Double stationGenerateByTime(@RequestParam("stationId") String stationId, @RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime) { + Date start = DateUtil.parse(startTime,DateUtil.PATTERN_DATETIME); List generates = generateService.list(Wrappers.lambdaQuery() .eq(GenerateEntity::getStationCode,stationId) - .ge(GenerateEntity::getFillDate,startTime) + .ge(GenerateEntity::getFillDate,DateUtil.format(start,DateUtil.PATTERN_DATE)) .le(GenerateEntity::getFillDate,endTime) ); if(CollectionUtil.isEmpty(generates)){ diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java index 9cf07ec..b3141e0 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java @@ -258,7 +258,7 @@ public class GenerateServiceImpl extends BaseServiceImpl 0){ entity.setId(null); entity.setFillDate(DateUtil.format(start,DateUtil.PATTERN_DATE)); - entity.setGenerate((random.nextDouble() * 2800) + 12000); + entity.setGenerate((random.nextDouble() * 1360) + 19000); this.save(entity); calendar.add(Calendar.DAY_OF_MONTH,1); start = calendar.getTime(); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java index cba31a3..98d399a 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java @@ -631,6 +631,8 @@ public class HydropowerServiceImpl implements HydropowerService { // 年发电量 kpi.setGenerateYear(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum()); // 月发电量 + + kpi.setGenerateMon(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum()); // 日发电量 kpi.setGenerateDay(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerDay).sum()); From c8dcd995023c2c8448a92835e098faec36f66f8c Mon Sep 17 00:00:00 2001 From: liwen Date: Mon, 27 May 2024 16:36:34 +0800 Subject: [PATCH 13/15] =?UTF-8?q?update:=20=E5=8D=AB=E7=94=9F=E8=87=AA?= =?UTF-8?q?=E6=9F=A5=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/HygieneTemplateDetailEntity.java | 8 ++++ .../safeproduct/controller/HygieneController.java | 4 +- .../service/IHygieneTemplateDetailService.java | 7 ++++ .../service/IHygieneTemplateService.java | 7 ++++ .../service/impl/HygienePlanServiceImpl.java | 43 +++++++++------------- .../impl/HygieneTemplateDetailServiceImpl.java | 13 +++++++ .../service/impl/HygieneTemplateServiceImpl.java | 33 ++++++++++++++++- .../com/hnac/hzims/safeproduct/utils/BaseUtil.java | 18 +++++++++ .../safeproduct/src/main/resources/db/2.0.1.sql | 4 +- 9 files changed, 107 insertions(+), 30 deletions(-) diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateDetailEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateDetailEntity.java index 9fe501f..3f3ff43 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateDetailEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateDetailEntity.java @@ -25,6 +25,14 @@ public class HygieneTemplateDetailEntity extends BaseEntity { @ApiModelProperty("责任区") private String zone; + @Size(max = 20, message = "责任人字段长度不能超过20") + @ApiModelProperty("责任人") + private String principal; + @ApiModelProperty("检查项") private String checkItem; + + @Size(max = 255, message = "检查项分值字段长度不能超过255") + @ApiModelProperty("检查项分值") + private String checkItemScore; } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java index e6c0c3e..fe2739c 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java @@ -218,7 +218,7 @@ public class HygieneController extends BladeController { @ApiOperation(value = "卫生自查模板详情") @ApiOperationSupport(order = 18) @Operate(label = "卫生自查模板详情", type = BusinessType.QUERY, ignore = false) - public R hygieneTemplateDetail(@RequestParam Long id) { + public R hygieneTemplateDetail(@RequestParam Long id) { HygieneTemplateDetailVO detail = hygieneTemplateService.getHygieneTemplateDetail(id); return R.data(detail); } @@ -227,7 +227,7 @@ public class HygieneController extends BladeController { @ApiOperation(value = "卫生自查模板分页") @ApiOperationSupport(order = 19) @Operate(label = "卫生自查模板分页", type = BusinessType.QUERY, ignore = false) - public R hygieneTemplatePage(@ApiIgnore @RequestParam Map param, Query query) { + public R> hygieneTemplatePage(@ApiIgnore @RequestParam Map param, Query query) { IPage page = hygieneTemplateService.page(Condition.getPage(query), Condition.getQueryWrapper( param, HygieneTemplateEntity.class)); return R.data(page); diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateDetailService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateDetailService.java index de71dad..463b0b5 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateDetailService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateDetailService.java @@ -18,4 +18,11 @@ public interface IHygieneTemplateDetailService extends IService getListByTemplateId(Long templateId); + + /** + * 删除关联模板详情数据 + * @param templateId 模板id + * @return true-成功,false-失败 + */ + boolean removeReferenceDetail(Long templateId); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java index 71493f9..5f45e16 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java @@ -39,4 +39,11 @@ public interface IHygieneTemplateService extends IService * @return 详情 */ HygieneTemplateDetailVO getHygieneTemplateDetail(Long id); + + /** + * 根据模板名获取模板 + * @param name 模板名 + * @return 模板实体类 + */ + HygieneTemplateEntity getHygieneTemplateByName(String name); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java index 2c3b176..fb4a3d3 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java @@ -18,6 +18,7 @@ import com.hnac.hzims.safeproduct.mapper.HygienePlanMapper; import com.hnac.hzims.safeproduct.service.IHygienePlanService; import com.hnac.hzims.safeproduct.service.IHygieneRecordService; import com.hnac.hzims.safeproduct.service.IHygieneZoneService; +import com.hnac.hzims.safeproduct.utils.BaseUtil; import com.hnac.hzims.safeproduct.vo.HygienePlanDetailVO; import com.hnac.hzims.safeproduct.vo.HygieneMonthVO; import org.springblade.core.log.exception.ServiceException; @@ -126,7 +127,7 @@ public class HygienePlanServiceImpl extends ServiceImpl zoneList = hygienePlanDTO.getZoneList(); // 若计划修改成功,修改关联责任区数据 if (updatePlan) { - for (HygieneZoneEntity zone : zoneList) { - String[] scores = zone.getCheckItemScore().split(",|,"); - // 校验检查项总成绩是否为标准总成绩 - getSumScore(scores, hygienePlanDTO.getStandardScore()); + // 删除旧数据 + boolean removeZone = hygieneZoneService.removeReferenceZone(hygienePlanDTO.getId()); + if (removeZone) { + hygienePlan = getPlanByName(hygienePlanDTO.getName()); + // 增加新数据 + for (HygieneZoneEntity zone : zoneList) { + // 传计划id + if (hygienePlan != null) { + zone.setHygienePlanId(hygienePlan.getId()); + } + String[] scores = zone.getCheckItemScore().split(",|,"); + // 校验检查项总成绩是否为标准总成绩 + BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore()); + } + // 校验通过则批量修改责任区数据 + return R.status(hygieneZoneService.saveBatch(zoneList)); } - // 校验通过则批量修改责任区数据 - return R.status(hygieneZoneService.updateBatchById(zoneList)); } return R.status(Boolean.FALSE); } @@ -210,24 +221,6 @@ public class HygienePlanServiceImpl extends ServiceImpl standardScore) { - throw new ServiceException("累计分值超过标准总分值"); - } - } - if (sum < standardScore) { - throw new ServiceException("标准总分值未全部分配"); - } - } - - /** * 根据编码查询卫生自查计划 */ @Override diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateDetailServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateDetailServiceImpl.java index 3ea4851..8df4088 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateDetailServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateDetailServiceImpl.java @@ -8,6 +8,7 @@ import com.hnac.hzims.safeproduct.service.IHygieneTemplateDetailService; import org.springframework.stereotype.Service; import java.util.List; +import java.util.stream.Collectors; /** * 卫生自查模板详情服务实现类 @@ -27,4 +28,16 @@ public class HygieneTemplateDetailServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(HygieneTemplateDetailEntity::getTemplateId, templateId); + List list = this.list(queryWrapper); + List ids = list.stream().map(HygieneTemplateDetailEntity::getId).collect(Collectors.toList()); + return this.removeByIds(ids); + } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java index efceb94..55f66bb 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java @@ -8,6 +8,7 @@ import com.hnac.hzims.safeproduct.entity.HygieneTemplateEntity; import com.hnac.hzims.safeproduct.mapper.HygieneTemplateMapper; import com.hnac.hzims.safeproduct.service.IHygieneTemplateDetailService; import com.hnac.hzims.safeproduct.service.IHygieneTemplateService; +import com.hnac.hzims.safeproduct.utils.BaseUtil; import com.hnac.hzims.safeproduct.vo.HygieneTemplateDetailVO; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.utils.CollectionUtil; @@ -49,6 +50,15 @@ public class HygieneTemplateServiceImpl extends ServiceImpl detailList = hygieneTemplateDTO.getTemplateDetailList(); + detailList.forEach(detail -> { + detail.setTemplateId(hygieneTemplateEntity.getId()); + String[] scores = detail.getCheckItemScore().split(",|,"); + // 校验检查项总成绩是否为标准总成绩 + BaseUtil.getSumScore(scores, 100); + }); return hygieneTemplateDetailService.saveBatch(hygieneTemplateDTO.getTemplateDetailList()); } @@ -72,9 +82,18 @@ public class HygieneTemplateServiceImpl extends ServiceImpl detailList = hygieneTemplateDTO.getTemplateDetailList(); + for (HygieneTemplateDetailEntity detail : detailList) { + String[] scores = detail.getCheckItemScore().split(",|,"); + BaseUtil.getSumScore(scores, 100); + } + return hygieneTemplateDetailService.saveBatch(detailList); } /** @@ -104,4 +123,14 @@ public class HygieneTemplateServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, name); + return this.getOne(queryWrapper); + } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java index da74c7f..76aada7 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java @@ -395,4 +395,22 @@ public class BaseUtil { } return fileName; } + + /** + * 计算累计分值 + * @param scores 各项分值 + * @param standardScore 标准总分值 + */ + public static void getSumScore(String[] scores, Integer standardScore) { + int sum = 0; + for (String score : scores) { + sum += Integer.parseInt(score); + if (sum > standardScore) { + throw new ServiceException("累计分值超过标准总分值"); + } + } + if (sum < standardScore) { + throw new ServiceException("标准总分值未全部分配"); + } + } } diff --git a/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql b/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql index 3730612..9434144 100644 --- a/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql +++ b/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql @@ -31,7 +31,9 @@ CREATE TABLE IF NOT EXISTS `hzims_hygiene_template_detail` ( `id` bigint(20) NOT NULL COMMENT '主键ID', `template_id` bigint(20) NOT NULL COMMENT '模板id', `zone` varchar(50) NOT NULL COMMENT '责任区', - `check_item` mediumtext NOT NULL COMMENT '检查项', + `PRINCIPAL` VARCHAR(20) NOT NULL COMMENT '责任人', + `CHECK_ITEM` MEDIUMTEXT NOT NULL COMMENT '检查项', + `CHECK_ITEM_SCORE` VARCHAR(255) NOT NULL COMMENT '检查项分值', `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', `create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', From 2718da82c99eaf93a605895629bd4aeb82a9ad75 Mon Sep 17 00:00:00 2001 From: liwen Date: Mon, 27 May 2024 16:37:00 +0800 Subject: [PATCH 14/15] =?UTF-8?q?update:=20message=E6=9C=8D=E5=8A=A1pom?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hzims-service/message/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/hzims-service/message/pom.xml b/hzims-service/message/pom.xml index 2dcf390..7f5519f 100644 --- a/hzims-service/message/pom.xml +++ b/hzims-service/message/pom.xml @@ -88,7 +88,6 @@ org.springblade blade-system-api - 5.0.2-SNAPSHOT From bcc6592d3505b1f03d5911b63b48fb4b75007016 Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 28 May 2024 11:24:00 +0800 Subject: [PATCH 15/15] =?UTF-8?q?update:=20=E5=8D=AB=E7=94=9F=E8=87=AA?= =?UTF-8?q?=E6=9F=A5=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../safeproduct/mapper/HygienePlanMapper.java | 1 - .../service/impl/HygienePlanServiceImpl.java | 82 ++++++++++------------ .../service/impl/HygieneRecordServiceImpl.java | 14 ++-- .../service/impl/HygieneTemplateServiceImpl.java | 46 ++++++------ .../safeproduct/src/main/resources/db/2.0.1.sql | 6 +- 5 files changed, 75 insertions(+), 74 deletions(-) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java index 946d92b..8170e95 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java @@ -7,7 +7,6 @@ import org.apache.ibatis.annotations.Mapper; import org.springblade.core.datascope.annotation.UserDataAuth; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; - /** * 卫生自查计划Mapper类 * diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java index fb4a3d3..4ad0ca5 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java @@ -63,15 +63,16 @@ public class HygienePlanServiceImpl extends ServiceImpl zoneList = hygienePlanDTO.getZoneList(); - // 若计划新增成功,新增关联责任区数据 - if (savePlan) { - hygienePlan = getPlanByName(hygienePlanDTO.getName()); - for (HygieneZoneEntity zone : zoneList) { - // 传计划id - if (hygienePlan != null) { - zone.setHygienePlanId(hygienePlan.getId()); - } - String[] scores = zone.getCheckItemScore().split(",|,"); - // 校验检查项总成绩是否为标准总成绩 - BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore()); - } - // 校验通过则批量新增责任区数据 - return R.status(hygieneZoneService.saveBatch(zoneList)); + hygienePlan = getPlanByName(hygienePlanDTO.getName()); + for (HygieneZoneEntity zone : zoneList) { + zone.setHygienePlanId(hygienePlan.getId()); + String[] scores = zone.getCheckItemScore().split(",|,"); + // 校验检查项总成绩是否为标准总成绩 + BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore()); } - return R.status(Boolean.FALSE); + // 校验通过则批量新增责任区数据 + return R.status(hygieneZoneService.saveBatch(zoneList)); } /** @@ -153,28 +151,26 @@ public class HygienePlanServiceImpl extends ServiceImpl zoneList = hygienePlanDTO.getZoneList(); - // 若计划修改成功,修改关联责任区数据 - if (updatePlan) { - // 删除旧数据 - boolean removeZone = hygieneZoneService.removeReferenceZone(hygienePlanDTO.getId()); - if (removeZone) { - hygienePlan = getPlanByName(hygienePlanDTO.getName()); - // 增加新数据 - for (HygieneZoneEntity zone : zoneList) { - // 传计划id - if (hygienePlan != null) { - zone.setHygienePlanId(hygienePlan.getId()); - } - String[] scores = zone.getCheckItemScore().split(",|,"); - // 校验检查项总成绩是否为标准总成绩 - BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore()); - } - // 校验通过则批量修改责任区数据 - return R.status(hygieneZoneService.saveBatch(zoneList)); - } + // 删除旧的责任区数据 + boolean removeZone = hygieneZoneService.removeReferenceZone(hygienePlanDTO.getId()); + if (!removeZone) { + throw new ServiceException("删除旧的责任区数据失败"); + } + // 新增新的责任区数据 + hygienePlan = getPlanByName(hygienePlanDTO.getName()); + for (HygieneZoneEntity zone : zoneList) { + zone.setHygienePlanId(hygienePlan.getId()); + String[] scores = zone.getCheckItemScore().split(",|,"); + // 校验检查项总成绩是否为标准总成绩 + BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore()); } - return R.status(Boolean.FALSE); + // 校验通过则批量修改责任区数据 + return R.status(hygieneZoneService.saveBatch(zoneList)); } /** diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java index 24d3a9f..b38db24 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java @@ -84,9 +84,9 @@ public class HygieneRecordServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, templateName); - List list = this.list(queryWrapper); - if (CollectionUtil.isNotEmpty(list)) { + // 重名校验 + HygieneTemplateEntity hygieneTemplate = getHygieneTemplateByName(templateName); + if (hygieneTemplate != null) { throw new ServiceException("模板名不可重复"); } - HygieneTemplateEntity hygieneTemplate = new HygieneTemplateEntity(); - hygieneTemplate.setTemplateName(templateName); - boolean saveTemplate = this.save(hygieneTemplate); + // 新增模板 + HygieneTemplateEntity hygieneTemplateEntity = new HygieneTemplateEntity(); + hygieneTemplateEntity.setTemplateName(templateName); + boolean saveTemplate = this.save(hygieneTemplateEntity); if (!saveTemplate) { throw new ServiceException("卫生自查模板新增失败"); } - // 传模板id - HygieneTemplateEntity hygieneTemplateEntity = getHygieneTemplateByName(templateName); + // 新增模板详情 + hygieneTemplate = getHygieneTemplateByName(templateName); List detailList = hygieneTemplateDTO.getTemplateDetailList(); - detailList.forEach(detail -> { - detail.setTemplateId(hygieneTemplateEntity.getId()); + for (HygieneTemplateDetailEntity detail : detailList) { + detail.setTemplateId(hygieneTemplate.getId()); String[] scores = detail.getCheckItemScore().split(",|,"); // 校验检查项总成绩是否为标准总成绩 BaseUtil.getSumScore(scores, 100); - }); - return hygieneTemplateDetailService.saveBatch(hygieneTemplateDTO.getTemplateDetailList()); + } + return hygieneTemplateDetailService.saveBatch(detailList); } /** @@ -70,26 +69,33 @@ public class HygieneTemplateServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, templateName); queryWrapper.lambda().ne(HygieneTemplateEntity::getId, templateId); - List list = this.list(queryWrapper); - if (CollectionUtil.isNotEmpty(list)) { + HygieneTemplateEntity hygieneTemplate = this.getOne(queryWrapper); + if (hygieneTemplate != null) { throw new ServiceException("模板名不可重复"); } - HygieneTemplateEntity hygieneTemplate = new HygieneTemplateEntity(); - hygieneTemplate.setId(templateId); - hygieneTemplate.setTemplateName(templateName); - boolean updateTemplate = this.updateById(hygieneTemplate); + // 更新模板 + HygieneTemplateEntity hygieneTemplateEntity = new HygieneTemplateEntity(); + hygieneTemplateEntity.setId(templateId); + hygieneTemplateEntity.setTemplateName(templateName); + boolean updateTemplate = this.updateById(hygieneTemplateEntity); if (!updateTemplate) { throw new ServiceException("卫生自查模板更新失败"); } + // 更新模板详情 + // 删除旧的模板详情数据 boolean removeDetail = hygieneTemplateDetailService.removeReferenceDetail(templateId); if (!removeDetail) { throw new ServiceException("卫生自查模板详情数据删除失败"); } + // 新增新的模板详情数据 + hygieneTemplate = getHygieneTemplateByName(templateName); List detailList = hygieneTemplateDTO.getTemplateDetailList(); for (HygieneTemplateDetailEntity detail : detailList) { + detail.setTemplateId(hygieneTemplate.getId()); String[] scores = detail.getCheckItemScore().split(",|,"); BaseUtil.getSumScore(scores, 100); } diff --git a/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql b/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql index 9434144..26bf967 100644 --- a/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql +++ b/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql @@ -31,9 +31,9 @@ CREATE TABLE IF NOT EXISTS `hzims_hygiene_template_detail` ( `id` bigint(20) NOT NULL COMMENT '主键ID', `template_id` bigint(20) NOT NULL COMMENT '模板id', `zone` varchar(50) NOT NULL COMMENT '责任区', - `PRINCIPAL` VARCHAR(20) NOT NULL COMMENT '责任人', - `CHECK_ITEM` MEDIUMTEXT NOT NULL COMMENT '检查项', - `CHECK_ITEM_SCORE` VARCHAR(255) NOT NULL COMMENT '检查项分值', + `prinicipal` varchar(20) NOT NULL COMMENT '责任人', + `check_item` mediumtext NOT NULL COMMENT '检查项', + `check_item_score` varchar(255) NOT NULL COMMENT '检查项分值', `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', `create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',