From 1b78157c7dc359a5f109206fab07e1b5dda4a985 Mon Sep 17 00:00:00 2001 From: luyie Date: Wed, 11 Sep 2024 16:38:07 +0800 Subject: [PATCH 1/3] =?UTF-8?q?add:=E5=A4=A7=E6=A8=A1=E5=9E=8B=EF=BC=8C?= =?UTF-8?q?=E7=9F=A5=E8=AF=86=E5=BA=93=E6=96=87=E4=BB=B6=E7=AE=A1=E7=90=86?= =?UTF-8?q?=EF=BC=8C=E6=96=87=E4=BB=B6=E5=88=86=E6=AE=B5=EF=BC=8C=E5=85=A5?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../maintenance/constants/StoreStatus.java | 32 ++++++++++ .../KnowledgeFileFragmentController.java | 72 ++++++++++++++++++++++ .../controller/KnowledgeFileInfoController.java | 10 ++- .../maintenance/entity/AgentLogEntity.java | 2 +- .../maintenance/entity/KnowledgeFileFragment.java | 46 ++++++++++++++ .../maintenance/entity/KnowledgeFileInfo.java | 16 ++++- .../maintenance/entity/VectorParamEntity.java | 2 +- .../mapper/KnowledgeFileFragmentMapper.java | 11 ++++ .../service/KnowledgeFileFragmentService.java | 14 +++++ .../service/KnowledgeFileInfoService.java | 2 + .../impl/KnowledgeFileFragmentServiceImpl.java | 34 ++++++++++ .../service/impl/KnowledgeFileInfoServiceImpl.java | 17 +++++ .../service/impl/VectorParamServiceImpl.java | 2 + .../hzims/bigmodel/maintenance/vo/IdRequest.java | 16 +++++ 14 files changed, 271 insertions(+), 5 deletions(-) create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/constants/StoreStatus.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/KnowledgeFileFragmentController.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/KnowledgeFileFragment.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/KnowledgeFileFragmentMapper.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/KnowledgeFileFragmentService.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/KnowledgeFileFragmentServiceImpl.java create mode 100644 hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/IdRequest.java diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/constants/StoreStatus.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/constants/StoreStatus.java new file mode 100644 index 0000000..b100870 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/constants/StoreStatus.java @@ -0,0 +1,32 @@ +package com.hnac.hzims.bigmodel.maintenance.constants; + +import lombok.Getter; + +/** + * @Author: ypj + * @Date: 2024/9/11 16:16 + */ +@Getter +public enum StoreStatus { + + NOT_STORE(0, "未入库"), + STORED(1, "已入库"), + STORING(2, "入库中"); + + private final int code; + private final String msg; + + StoreStatus(int code, String msg) { + this.code = code; + this.msg = msg; + } + + public static StoreStatus getInstance(int code) { + for (StoreStatus status : StoreStatus.values()) { + if (status.getCode() == code) { + return status; + } + } + return null; + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/KnowledgeFileFragmentController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/KnowledgeFileFragmentController.java new file mode 100644 index 0000000..bf97c49 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/KnowledgeFileFragmentController.java @@ -0,0 +1,72 @@ +package com.hnac.hzims.bigmodel.maintenance.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.bigmodel.maintenance.entity.KnowledgeFileFragment; +import com.hnac.hzims.bigmodel.maintenance.service.KnowledgeFileFragmentService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.support.Condition; +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 java.util.List; + +/** + * @Author: ypj + * @Date: 2024/9/11 11:56 + */ +@RestController +@Slf4j +@RequestMapping("/knowledge/fragment") +@AllArgsConstructor +@Api(value = "知识库文件分片管理", tags = "知识库文件分片管理") +public class KnowledgeFileFragmentController { + private final KnowledgeFileFragmentService knowledgeFileFragmentService; + + @GetMapping("/listPage") + @ApiOperation(value = "分页查询") + @ApiOperationSupport(order = 1) + public R> listPage(Query query, KnowledgeFileFragment req) { + return R.data(knowledgeFileFragmentService.page(Condition.getPage(query), Condition.getQueryWrapper(new KnowledgeFileFragment(), req))); + } + + @GetMapping("/detail") + @ApiOperation(value = "查看详情") + @ApiOperationSupport(order = 2) + public R detail(@RequestParam @ApiParam("主键ID") Long id) { + return R.data(knowledgeFileFragmentService.getById(id)); + } + + @PostMapping("/save") + @ApiOperation(value = "保存") + @ApiOperationSupport(order = 3) + public R save(@RequestBody KnowledgeFileFragment req) { + return R.status(knowledgeFileFragmentService.save(req)); + } + + @PutMapping("/update") + @ApiOperation(value = "编辑") + @ApiOperationSupport(order = 4) + public R update(@RequestBody KnowledgeFileFragment req) { + return R.status(knowledgeFileFragmentService.updateById(req)); + } + + @DeleteMapping("/remove") + @ApiOperation(value = "删除") + @ApiOperationSupport(order = 5) + public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { + return R.status(knowledgeFileFragmentService.removeByIds(Func.toLongList(",", ids))); + } + + @GetMapping("/getByDocId") + @ApiOperation(value = "根据文档ID获取分片,不分页") + public R> getByDocId(@RequestParam @ApiParam("主键ID") Long docId) { + return R.data(knowledgeFileFragmentService.getByDocId(docId)); + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/KnowledgeFileInfoController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/KnowledgeFileInfoController.java index e6a7008..5ea94d6 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/KnowledgeFileInfoController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/KnowledgeFileInfoController.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.bigmodel.maintenance.entity.KnowledgeFileInfo; import com.hnac.hzims.bigmodel.maintenance.service.KnowledgeFileInfoService; +import com.hnac.hzims.bigmodel.maintenance.vo.IdRequest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -37,7 +38,7 @@ public class KnowledgeFileInfoController { @ApiOperationSupport(order = 1) public R> listPage(Query query, KnowledgeFileInfo req) { return R.data(knowledgeFileInfoService.page(Condition.getPage(query), - Condition.getQueryWrapper(new KnowledgeFileInfo(), req).orderByDesc(KnowledgeFileInfo::getCreateTime))); + Condition.getQueryWrapper(new KnowledgeFileInfo(), req).orderByDesc(KnowledgeFileInfo::getCreateTime))); } @GetMapping("/detail") @@ -74,4 +75,11 @@ public class KnowledgeFileInfoController { public R upload(@ApiParam(value = "上传文件", required = true) @RequestPart("file") MultipartFile file) { return ossClient.putFile(file); } + + @PostMapping("/store") + @ApiOperation(value = "入库") + @ApiOperationSupport(order = 7) + public R store(@RequestBody IdRequest req) { + return R.status(knowledgeFileInfoService.store(req)); + } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/AgentLogEntity.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/AgentLogEntity.java index fd1d6dc..2931615 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/AgentLogEntity.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/AgentLogEntity.java @@ -18,7 +18,7 @@ import java.util.Date; * @Date: 2024/9/9 10:38 */ @ApiModel("问题标注") -@TableName("agent_log") +@TableName("gglm_agent_log") @Data public class AgentLogEntity extends TenantEntity implements Serializable { private static final long serialVersionUID = 1L; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/KnowledgeFileFragment.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/KnowledgeFileFragment.java new file mode 100644 index 0000000..2982ae1 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/KnowledgeFileFragment.java @@ -0,0 +1,46 @@ +package com.hnac.hzims.bigmodel.maintenance.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.mp.support.SqlCondition; +import org.springblade.core.tenant.mp.TenantEntity; + +import java.io.Serializable; + +/** + * @Author: ypj + * @Date: 2024/9/11 9:58 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("knowledge_file_fragment") +@ApiModel(value = "知识库文件分片信息",description = "知识库文件分片信息") +public class KnowledgeFileFragment extends TenantEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("文档ID") + @TableField("DOC_ID") + @QueryField(condition = SqlCondition.EQUAL) + private Long docId; + + @ApiModelProperty("文档问题") + @TableField("DOC_QS") + @QueryField(condition = SqlCondition.LIKE) + private String docQs; + + @ApiModelProperty("文档内容") + @TableField("DOC_CONTENT") + @QueryField(condition = SqlCondition.LIKE) + private String docContent; + + @ApiModelProperty("文档页码") + @TableField("DOC_PAGE_INDEX") + @QueryField(condition = SqlCondition.EQUAL) + private Integer docPageIndex; + +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/KnowledgeFileInfo.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/KnowledgeFileInfo.java index d3ff16d..a1f6ab2 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/KnowledgeFileInfo.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/KnowledgeFileInfo.java @@ -6,6 +6,8 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.mp.support.SqlCondition; import org.springblade.core.tenant.mp.TenantEntity; import java.io.Serializable; @@ -16,41 +18,51 @@ import java.io.Serializable; */ @Data @EqualsAndHashCode(callSuper=false) -@TableName("HZIMS_KNOWLEDGE_FILE_INFO") +@TableName("knowledge_file_info") @ApiModel(value = "知识库文件信息",description = "知识库文件信息") public class KnowledgeFileInfo extends TenantEntity implements Serializable { private static final long serialVersionUID = 1L; @ApiModelProperty("文件名称") + @QueryField(condition = SqlCondition.LIKE) private String name; @ApiModelProperty("文件url") + @QueryField(condition = SqlCondition.LIKE) private String url; @ApiModelProperty("文件大小") + @QueryField(condition = SqlCondition.EQUAL) private Long size; @ApiModelProperty("简介") + @QueryField(condition = SqlCondition.LIKE) private String briefs; @ApiModelProperty("标签") + @QueryField(condition = SqlCondition.LIKE) private String tags; @ApiModelProperty("业务领域") + @QueryField(condition = SqlCondition.EQUAL) private String domain; @ApiModelProperty("权限等级,5个等级") @TableField("AUTHORITY_CLASS") + @QueryField(condition = SqlCondition.EQUAL) private Integer authorityClass; @ApiModelProperty("是否可见,0为不可见,1为可见") + @QueryField(condition = SqlCondition.EQUAL) private Integer visible; - @ApiModelProperty("文件状态,0为未入库,1为已入库") + @ApiModelProperty("文件状态,0为未入库,1为已入库,2为入库中") @TableField("FILE_STATUS") + @QueryField(condition = SqlCondition.EQUAL) private Integer fileStatus; @ApiModelProperty("备注") + @QueryField(condition = SqlCondition.LIKE) private String remark; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/VectorParamEntity.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/VectorParamEntity.java index 6553578..72ed2d8 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/VectorParamEntity.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/VectorParamEntity.java @@ -16,7 +16,7 @@ import java.io.Serializable; * @Date: 2024/9/2 14:54 */ @ApiModel("向量参数配置") -@TableName("HZIMS_VECTOR_PARAM") +@TableName("gglm_vector_param") @Data public class VectorParamEntity extends TenantEntity implements Serializable { private static final long serialVersionUID = 1L; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/KnowledgeFileFragmentMapper.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/KnowledgeFileFragmentMapper.java new file mode 100644 index 0000000..0bfe6fd --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/mapper/KnowledgeFileFragmentMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.bigmodel.maintenance.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.bigmodel.maintenance.entity.KnowledgeFileFragment; + +/** + * @Author: ypj + * @Date: 2024/9/11 10:49 + */ +public interface KnowledgeFileFragmentMapper extends BaseMapper { +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/KnowledgeFileFragmentService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/KnowledgeFileFragmentService.java new file mode 100644 index 0000000..5851b8e --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/KnowledgeFileFragmentService.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.bigmodel.maintenance.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.bigmodel.maintenance.entity.KnowledgeFileFragment; + +import java.util.List; + +/** + * @Author: ypj + * @Date: 2024/9/11 10:50 + */ +public interface KnowledgeFileFragmentService extends IService { + List getByDocId(Long docId); +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/KnowledgeFileInfoService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/KnowledgeFileInfoService.java index 81f58c9..aa8482f 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/KnowledgeFileInfoService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/KnowledgeFileInfoService.java @@ -2,10 +2,12 @@ package com.hnac.hzims.bigmodel.maintenance.service; import com.baomidou.mybatisplus.extension.service.IService; import com.hnac.hzims.bigmodel.maintenance.entity.KnowledgeFileInfo; +import com.hnac.hzims.bigmodel.maintenance.vo.IdRequest; /** * @Author: ypj * @Date: 2024/9/10 16:42 */ public interface KnowledgeFileInfoService extends IService { + Boolean store(IdRequest req); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/KnowledgeFileFragmentServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/KnowledgeFileFragmentServiceImpl.java new file mode 100644 index 0000000..c1ebffa --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/KnowledgeFileFragmentServiceImpl.java @@ -0,0 +1,34 @@ +package com.hnac.hzims.bigmodel.maintenance.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.bigmodel.maintenance.entity.KnowledgeFileFragment; +import com.hnac.hzims.bigmodel.maintenance.mapper.KnowledgeFileFragmentMapper; +import com.hnac.hzims.bigmodel.maintenance.service.KnowledgeFileFragmentService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @Author: ypj + * @Date: 2024/9/11 10:51 + */ +@Service +@Slf4j +@AllArgsConstructor +@DS("hznlm") +public class KnowledgeFileFragmentServiceImpl extends ServiceImpl implements KnowledgeFileFragmentService { + private KnowledgeFileFragmentMapper knowledgeFileFragmentMapper; + + @Override + public List getByDocId(Long docId) { + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery() + .eq(KnowledgeFileFragment::getDocId, docId) + .orderByAsc(KnowledgeFileFragment::getDocPageIndex); + return knowledgeFileFragmentMapper.selectList(queryWrapper); + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java index 9fc1ad7..c367af7 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/KnowledgeFileInfoServiceImpl.java @@ -1,9 +1,14 @@ package com.hnac.hzims.bigmodel.maintenance.service.impl; +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.bigmodel.maintenance.constants.StoreStatus; import com.hnac.hzims.bigmodel.maintenance.entity.KnowledgeFileInfo; import com.hnac.hzims.bigmodel.maintenance.mapper.KnowledgeFileInfoMapper; import com.hnac.hzims.bigmodel.maintenance.service.KnowledgeFileInfoService; +import com.hnac.hzims.bigmodel.maintenance.vo.IdRequest; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -15,5 +20,17 @@ import org.springframework.stereotype.Service; @Service @Slf4j @AllArgsConstructor +@DS("hznlm") public class KnowledgeFileInfoServiceImpl extends ServiceImpl implements KnowledgeFileInfoService { + private final KnowledgeFileInfoMapper knowledgeFileInfoMapper; + + @Override + public Boolean store(IdRequest req) { + KnowledgeFileInfo knowledgeFileInfo = knowledgeFileInfoMapper.selectById(req.getId()); + + LambdaUpdateWrapper queryWrapper = Wrappers.lambdaUpdate() + .set(KnowledgeFileInfo::getFileStatus, StoreStatus.STORING.getCode()) + .eq(KnowledgeFileInfo::getId, req.getId()); + return this.update(queryWrapper); + } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java index 9a9af62..fcb265f 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/VectorParamServiceImpl.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.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.fasterxml.jackson.core.JsonProcessingException; @@ -30,6 +31,7 @@ import java.util.*; @Service @Slf4j @AllArgsConstructor +@DS("hznlm") public class VectorParamServiceImpl extends ServiceImpl implements VectorParamService { private static final String CLIENT_SIGN = "vector_param"; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/IdRequest.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/IdRequest.java new file mode 100644 index 0000000..113c03b --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/vo/IdRequest.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.bigmodel.maintenance.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Author: ypj + * @Date: 2024/9/11 14:16 + */ +@Data +@ApiModel("单id操作请求") +public class IdRequest { + @ApiModelProperty("主键ID") + private Long id; +} From 4b2cf6eee1e5f3ce4e5fff74a66c808ecafee72c Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Wed, 11 Sep 2024 17:20:52 +0800 Subject: [PATCH 2/3] =?UTF-8?q?#=E6=96=B0=E7=89=88=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=B0=B4=E4=BD=8D=E7=BB=9F=E8=AE=A1=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/business/ws/alart/vo/AlartParamVo.java | 7 +- .../hnac/hzims/equipment/feign/IEmInfoClient.java | 4 +- .../hzims/equipment/feign/IEmInfoClientBack.java | 3 +- .../hydroelectric/vo/HydroelectricLoadVo.java | 19 ++++ .../hydroelectric/vo/HydroelectricLoadWaterVo.java | 25 +++++ .../hydroelectric/vo/HydroelectricStationVo.java | 11 ++- .../hydroelectric/vo/HydroelectricWaterVo.java | 19 ++++ .../main/constant/HomePageConstant.java | 3 +- .../hzims/operational/main/vo/WaterLevelVo.java | 4 +- .../hnac/hzims/equipment/feign/EmInfoClient.java | 5 +- .../service/impl/HistoryDeviceServiceImpl.java | 6 ++ .../hzims/alarm/show/service/AlarmService.java | 3 +- .../alarm/show/service/impl/AlarmServiceImpl.java | 83 +++++++--------- .../hnac/hzims/alarm/ws/alart/AlarmHandler.java | 14 +-- .../hzims/alarm/ws/alart/AlarmSessionManager.java | 1 - .../hzims/alarm/ws/alart/AlarmSocketConfig.java | 4 +- .../scheduled/GenerationScheduledTask.java | 14 +-- .../scheduled/scheduled/MonitorScheduledTask.java | 21 +++-- .../scheduled/RealTargetScheduledTask.java | 28 +++--- .../operation/home/impl/RealTargetServiceImpl.java | 77 ++++++++++----- .../data/service/impl/HzimsDataServiceImpl.java | 9 +- .../controller/HydroelectricController.java | 1 + .../service/impl/HydroelectricServiceImpl.java | 105 ++++++++++++++++++++- .../main/service/impl/HydropowerServiceImpl.java | 4 +- .../main/service/impl/WaterServiceImpl.java | 8 +- 25 files changed, 340 insertions(+), 138 deletions(-) create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricLoadVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricLoadWaterVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricWaterVo.java diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java index 462bccc..4c5a13b 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java @@ -13,9 +13,6 @@ import java.util.List; @ApiModel(value = "告警websocket参数", description = "") public class AlartParamVo { - @ApiModelProperty("站点类型: 2-云服务 1-代运维") - private Integer serveType; - - @ApiModelProperty("用户权限机构集合") - private List depts; + @ApiModelProperty("站点集合") + private List codes; } \ No newline at end of file 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 b60f2ae..3368a5a 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 @@ -173,8 +173,8 @@ public interface IEmInfoClient { @GetMapping(DEVICE_BY_PATH) List deviceByPath(@RequestParam("emCode") String emCode); - @GetMapping(EM_INFO_LIST) - R> emInfoList(@RequestParam("req")EmInfoEntity req); + @GetMapping (EM_INFO_LIST) + R> emInfoList(@RequestParam("deptId") Long deptId); @GetMapping(RIDE_DEVICES) List rideDevices(@RequestParam("deptIds") List deptIds); 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 c84c6eb..8ce13dd 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 @@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.api.R; import org.springblade.system.vo.CreateTableVO; import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestParam; import java.util.ArrayList; import java.util.List; @@ -112,7 +113,7 @@ public class IEmInfoClientBack implements IEmInfoClient { } @Override - public R> emInfoList(EmInfoEntity req) { + public R> emInfoList(Long deptId) { return R.fail("远程调用失败"); } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricLoadVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricLoadVo.java new file mode 100644 index 0000000..e1e7257 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricLoadVo.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.operational.homePage.hydroelectric.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "站点首页-最近24小时总有功") +public class HydroelectricLoadVo { + + @ApiModelProperty(value = "字符串时间") + private String time; + + @ApiModelProperty(value = "有功功率") + private String load; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricLoadWaterVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricLoadWaterVo.java new file mode 100644 index 0000000..dfab183 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricLoadWaterVo.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.operational.homePage.hydroelectric.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "站点首页-最近24小时总有功/水位") +public class HydroelectricLoadWaterVo { + + @ApiModelProperty(value = "日期") + private String time; + + @ApiModelProperty(value = "小时") + private Integer hour; + + @ApiModelProperty(value = "功率") + private Double load; + + @ApiModelProperty(value = "水位") + private Double water; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricStationVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricStationVo.java index 6bbfc09..042ac45 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricStationVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricStationVo.java @@ -6,7 +6,6 @@ import com.hnac.hzims.hzimsweather.response.weather.Daily; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import lombok.experimental.Tolerate; import java.util.List; @@ -68,14 +67,20 @@ public class HydroelectricStationVo { @JsonSerialize(nullsUsing = NullSerializer.class) private Double powerYesterDay; + @ApiModelProperty(value = "站点水位") + private Double water; + @ApiModelProperty(value = "七日内天气") private List weather; @ApiModelProperty(value = "设备集合") private List devices; - @ApiModelProperty(value = "降雨曲线") - private List powerRains; + /*@ApiModelProperty(value = "降雨曲线") + private List powerRains;*/ + + @ApiModelProperty(value = "总有功/水位曲线") + private List loadWaters; @ApiModelProperty(value = "发电量曲线") private List generateMons; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricWaterVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricWaterVo.java new file mode 100644 index 0000000..08ad9d0 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricWaterVo.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.operational.homePage.hydroelectric.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "站点首页-最近24小时水位") +public class HydroelectricWaterVo { + + @ApiModelProperty(value = "字符串时间") + private String time; + + @ApiModelProperty(value = "水位") + private String water; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java index 60485a6..89db1fa 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java @@ -186,7 +186,8 @@ public interface HomePageConstant { // 单位设置 String CONCAT_P = "-P"; // 有功功率单位拼接值 - String CONCAT_Q = "-Q"; // 有功功率单位拼接值 + String CONCAT_Q = "-Q"; + // 有功功率单位拼接值 String CONCAT_UAB = "-UAB"; // 有功功率单位拼接值 String CONCAT_IA = "-IA"; // 有功功率单位拼接值 diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WaterLevelVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WaterLevelVo.java index f4d0875..8e38c7f 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WaterLevelVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WaterLevelVo.java @@ -23,8 +23,8 @@ public class WaterLevelVo { private Double dischargeFlow; @ApiModelProperty(value = "前水位曲线数据") - private Map frontCurveMap; + private Map frontCurveMap; @ApiModelProperty(value = "后水位曲线数据") - private Map rearCurveMap; + private Map rearCurveMap; } 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 fd998c1..4ad7007 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 @@ -151,8 +151,9 @@ public class EmInfoClient implements IEmInfoClient { @Override @GetMapping(EM_INFO_LIST) - public R> emInfoList(@RequestParam("req") EmInfoEntity req) { - LambdaQueryWrapper queryWrapper = Condition.getQueryWrapper(EmInfoEntity.class, req); + public R> emInfoList(@RequestParam("deptId") Long deptId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(EmInfoEntity::getCreateDept,deptId); return R.data(service.list(queryWrapper)); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryDeviceServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryDeviceServiceImpl.java index 2200c88..404e5ef 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryDeviceServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryDeviceServiceImpl.java @@ -182,6 +182,12 @@ public class HistoryDeviceServiceImpl implements IHistoryDeviceService { */ @Override public List historyCurve(HistoryDataParamVo param) { + if(StringUtil.isEmpty(param.getFirstAttrId()) && StringUtil.isEmpty(param.getSecondAttrId()) + && StringUtil.isEmpty(param.getThirdlyAttrId()) && StringUtil.isEmpty(param.getFourthAttrId()) + && StringUtil.isEmpty(param.getFifthAttrName())){ + return new ArrayList<>(); + } + // 计算查询数据维度 : 0-10秒 、 1-1分钟 、2-5分钟 ..... Integer intervalType = this.computeInterval(param.getStartTime(),param.getEndTime()); // 查询数据 diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java index 020b84a..46abe4b 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java @@ -8,7 +8,6 @@ import com.hnac.hzims.alarm.config.vo.AlarmHistoryVo; import com.hnac.hzims.alarm.show.vo.AlarmHistoryParamVo; import com.hnac.hzims.alarm.show.vo.AlarmVideoVo; import com.hnac.hzims.alarm.show.vo.ShowQueryVo; -import com.hnac.hzims.business.ws.alart.vo.AlartParamVo; import org.springframework.web.socket.TextMessage; import java.util.List; @@ -24,7 +23,7 @@ public interface AlarmService extends IService { List broadcast(String startTime, String endTime,Integer serveType); - TextMessage majorAlarm(AlartParamVo param); + TextMessage majorAlarm(List stations); List alarmVideos(String stationCode, String deviceCode, String realId,Integer alarmType); diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java index 25e2f6d..11ac69c 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java @@ -18,7 +18,6 @@ import com.hnac.hzims.alarm.show.vo.AlarmHistoryParamVo; import com.hnac.hzims.alarm.show.vo.AlarmVideoVo; import com.hnac.hzims.alarm.show.vo.ShowQueryVo; import com.hnac.hzims.alarm.source.service.MessageService; -import com.hnac.hzims.business.ws.alart.vo.AlartParamVo; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; import com.hnac.hzims.equipment.feign.IEmInfoClient; @@ -36,14 +35,12 @@ 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.mp.base.BaseServiceImpl; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; -import org.springblade.message.dto.MailMessageDTO; import org.springblade.message.fegin.IMessageClient; -import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -111,6 +108,9 @@ public class AlarmServiceImpl extends ServiceImpl impl if(!StringUtil.isEmpty(showQuery.getAlarmType())){ wrapper.eq("ALARM_TYPE",showQuery.getAlarmType()); } + if(!StringUtil.isEmpty(showQuery.getContent())){ + wrapper.like("alarmContext",showQuery.getContent()); + } // 处理告警过滤 :当天处理告警 List handles = alarmHandleService.handles(); @@ -140,6 +140,18 @@ public class AlarmServiceImpl extends ServiceImpl impl } /** + * 获取权限站点 + * @return + */ + private List stationsByCodes(List stations) { + R> result = stationClient.querySatationByCodes(stations); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + return new ArrayList<>(); + } + return result.getData(); + } + + /** * 查询告警数量 * @return */ @@ -191,6 +203,9 @@ public class AlarmServiceImpl extends ServiceImpl impl }).collect(Collectors.toList()); } + + + /** * 播报告警 * @param startTime @@ -218,26 +233,25 @@ public class AlarmServiceImpl extends ServiceImpl impl /** * 弹框告警 - * @param param + * @param codes * @return */ @Override - public TextMessage majorAlarm(AlartParamVo param) { + public TextMessage majorAlarm(List codes) { // 站点查询 - List stations = this.stations(param.getServeType()); - if(CollectionUtil.isEmpty(stations) || CollectionUtil.isEmpty(param.getDepts())){ - return new TextMessage(new ArrayList().toString()); - } - List effectives = stations.stream().filter(station->param.getDepts().contains(station.getRefDept())).map(StationEntity::getCode).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(effectives)){ + List stations = this.stationsByCodes(codes); + if(CollectionUtil.isEmpty(stations)){ return new TextMessage(new ArrayList().toString()); } // 条件过滤 QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().in(AlarmEntity::getStationId,effectives); - queryWrapper.lambda().in(AlarmEntity::getAlarmType, Arrays.asList(AlarmConstants.FAULT,AlarmConstants.EARLY)); - queryWrapper.lambda().eq(AlarmEntity::getIsShowAlert,0); - queryWrapper.lambda().eq(AlarmEntity::getStatus,0); + queryWrapper.lambda().in(AlarmEntity::getStationId,stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); + queryWrapper.lambda().in(AlarmEntity::getAlarmType, AlarmConstants.WHOLE_ALARM_TYPE); + queryWrapper.lambda().eq(AlarmEntity::getIsRightTabulation,0); + queryWrapper.lambda().ge(AlarmEntity::getAlarmTime, DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00"); + queryWrapper.lambda().le(AlarmEntity::getAlarmTime,DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME)); + queryWrapper.lambda().orderByDesc(AlarmEntity::getAlarmTime); + //queryWrapper.lambda().eq(AlarmEntity::getStatus,0); // 处理告警过滤 :当天处理告警 List handles = alarmHandleService.handles(); if(!CollectionUtil.isEmpty(handles)){ @@ -247,10 +261,9 @@ public class AlarmServiceImpl extends ServiceImpl impl if(CollectionUtil.isEmpty(alarms)){ return new TextMessage(new ArrayList().toString()); } - return new TextMessage(JSONObject.toJSONString(alarms.stream().sorted(Comparator.comparing(AlarmEntity::getAlarmTime).reversed()).collect(Collectors.toList()))); + return new TextMessage(JSONObject.toJSONString(alarms.stream().skip(0).limit(1000).collect(Collectors.toList()))); } - /** * 验证设备编号是否绑定视频 * @param emInfo 设备信息 @@ -374,35 +387,6 @@ public class AlarmServiceImpl extends ServiceImpl impl } /** - * websocket断联发送邮件 - * @return - */ - - public void sendMailByNum(Integer num,Integer maxConnent,String name) { - if (num>=maxConnent){ - MailMessageDTO mailMessageDTO = new MailMessageDTO(); - mailMessageDTO.setDeptId(200000L); - mailMessageDTO.setDeptName("华自科技"); - mailMessageDTO.setBusinessClassify("system"); - mailMessageDTO.setBusinessKey("Mail"); - mailMessageDTO.setSubject("邮件发送"); - - mailMessageDTO.setContent(name+"websocket链接失败;"+"链接失败次数:"+num); - R> res = userClient.userListByRoleAlias("200000", "sendMail"); - if (!res.isSuccess()||CollectionUtil.isEmpty(res.getData())){ - log.error("消息发送失败:无对应用户"); - } - String userIds = res.getData().stream().map(s -> s.getId().toString()).collect(Collectors.joining(",")); - mailMessageDTO.setUserIds(userIds); - mailMessageDTO.setIsHtml(false); - R booleanR = messageClient.sendMailMsgByUsers(mailMessageDTO); - if (!booleanR.isSuccess()){ - log.error("消息发送失败:"+mailMessageDTO.getUserIds()+"--->"+booleanR.getMsg()); - } - } - } - - /** * 获取告警视频信息 * @param stationCode * @param deviceCode @@ -435,6 +419,7 @@ public class AlarmServiceImpl extends ServiceImpl impl throw new ServiceException("未查询到告警视频信息!"); } + /** *查询站点绑定视频信息 * @param stationCode @@ -530,10 +515,8 @@ public class AlarmServiceImpl extends ServiceImpl impl if(!station.isSuccess() || ObjectUtil.isEmpty(station)){ throw new ServiceException("未查询到告警采集点绑定视频信息!"); } - EmInfoEntity param = new EmInfoEntity(); - param.setDepartment(station.getData().getRefDept()); // 查询设备 - R> devices = emInfoClient.emInfoList(param); + R> devices = emInfoClient.emInfoList(station.getData().getRefDept()); if(!devices.isSuccess() || CollectionUtil.isEmpty(devices.getData())){ throw new ServiceException("未查询到告警采集点绑定视频信息!"); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java index f6052a0..5053e34 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.business.ws.alart.vo.AlartParamVo; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -31,13 +32,11 @@ public class AlarmHandler extends TextWebSocketHandler { session.getAttributes().put("userId", uid); log.info("sessionId: " + session.getId()); log.info("session connection successful!"); - AlarmSocketPool.pool.put(session.getId(), this); } @Override public void afterConnectionClosed(WebSocketSession session, CloseStatus status) { AlarmSessionManager.removeAndClose(session.getId()); - AlarmSocketPool.pool.remove(session.getId()); log.info("sessionId: " + session.getId()); log.info("uri: " + session.getUri()); log.info("session closed successful!"); @@ -46,7 +45,6 @@ public class AlarmHandler extends TextWebSocketHandler { @Override public void handleTransportError(WebSocketSession session, Throwable exception) { AlarmSessionManager.removeAndClose(session.getId()); - AlarmSocketPool.pool.remove(session.getId()); } @Override @@ -56,11 +54,13 @@ public class AlarmHandler extends TextWebSocketHandler { if(StringUtil.isBlank(message)){ return; } - AlartParamVo param = JSONObject.parseObject(message,AlartParamVo.class); - if(ObjectUtil.isEmpty(param)){ + AlartParamVo param = JSONObject.parseObject(textMessage.getPayload(), AlartParamVo.class); + if(ObjectUtil.isEmpty(param) || CollectionUtil.isEmpty(param.getCodes())){ return; } - TextMessage sendMessage = alarmService.majorAlarm(param); + session.getAttributes().put("codes", param.getCodes()); + AlarmSessionManager.SESSION_POOL.put(userId,session); + TextMessage sendMessage = alarmService.majorAlarm(param.getCodes()); session.sendMessage(sendMessage); } -} +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSessionManager.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSessionManager.java index b54e6b2..d2227b9 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSessionManager.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSessionManager.java @@ -55,7 +55,6 @@ public class AlarmSessionManager { throw new RuntimeException("关闭ws会话失败!", ex); } } - SESSION_POOL.remove(uid); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketConfig.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketConfig.java index bbceab3..051da5a 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketConfig.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketConfig.java @@ -18,11 +18,11 @@ public class AlarmSocketConfig implements WebSocketConfigurer{ @Override public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { // 集中监控弹框处理器 - registry.addHandler(monitorHandler(), "/alarm/alart/{uid}").setAllowedOrigins("*"); + registry.addHandler(alarmHandler(), "/alarm/alart/{uid}").setAllowedOrigins("*"); } @Bean - public WebSocketHandler monitorHandler() { + public WebSocketHandler alarmHandler() { return new AlarmHandler(); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java index 55963c4..1fb0ed2 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java @@ -63,9 +63,10 @@ public class GenerationScheduledTask { * @param param * @return */ - @XxlJob(THIS_DAY_POWER_GENERATION) - //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT thisDayPowerGeneration(String param) { + //@XxlJob(THIS_DAY_POWER_GENERATION) + @Scheduled(cron = "0/40 * * * * ? ") + public ReturnT thisDayPowerGeneration() { + String param = ""; if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } @@ -78,9 +79,10 @@ public class GenerationScheduledTask { * @param param * @return */ - @XxlJob(LOAD_THREE_YEAR_POWER_GENERATION) - //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT loadThreeYearPowerGeneration(String param) { + //@XxlJob(LOAD_THREE_YEAR_POWER_GENERATION) + @Scheduled(cron = "0 0 1 * * ? ") + public ReturnT loadThreeYearPowerGeneration() { + String param = ""; if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java index 15e3cf7..6e962f2 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/MonitorScheduledTask.java @@ -29,9 +29,10 @@ public class MonitorScheduledTask { /** * realId刷新 */ - @XxlJob(REAL_ID_DATA) - //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT loadRealId(String param) { + //@XxlJob(REAL_ID_DATA) + @Scheduled(cron = "0/40 * * * * ? ") + public ReturnT loadRealId() { + String param = ""; if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } @@ -43,9 +44,10 @@ public class MonitorScheduledTask { * 实时数据刷新 * @return ReturnT */ - @XxlJob(REAL_TIME_DATA) - //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT loadRealData(String param) { + //@XxlJob(REAL_TIME_DATA) + @Scheduled(cron = "0/40 * * * * ? ") + public ReturnT loadRealData() { + String param = ""; if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } @@ -57,9 +59,10 @@ public class MonitorScheduledTask { * 集中监控数据处理 * @return ReturnT */ - @XxlJob(CENTRALIZED_MONITORING) - //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT loadMonitoring(String param) { + //@XxlJob(CENTRALIZED_MONITORING) + @Scheduled(cron = "0/4 * * * * ? ") + public ReturnT loadMonitoring() { + String param = ""; if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java index 9591c87..0a1b3ff 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java @@ -33,9 +33,10 @@ public class RealTargetScheduledTask { * @return * @throws Exception */ - @XxlJob(LOAD_EM_INFO) - //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT loadEmInfo(String param) { + //@XxlJob(LOAD_EM_INFO) + @Scheduled(cron = "0/40 * * * * ? ") + public ReturnT loadEmInfo() { + String param = ""; if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } @@ -46,9 +47,10 @@ public class RealTargetScheduledTask { /** * 水电站-机组实时加载 */ - @XxlJob(LOAD_HYDROPOWER_UNIT_REAL) - //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT loadHydropowerReal(String param) { + //@XxlJob(LOAD_HYDROPOWER_UNIT_REAL) + @Scheduled(cron = "0/5 * * * * ? ") + public ReturnT loadHydropowerReal() { + String param = ""; if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } @@ -59,9 +61,10 @@ public class RealTargetScheduledTask { /** * 水电站-机组指标加载 */ - @XxlJob(LOAD_HYDROPOWER_UNIT_TARGET) - //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT loadHydropowerTarget(String param) { + //@XxlJob(LOAD_HYDROPOWER_UNIT_TARGET) + @Scheduled(cron = "0 0/2 * * * ? ") + public ReturnT loadHydropowerTarget() { + String param = ""; if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } @@ -110,9 +113,10 @@ public class RealTargetScheduledTask { /** * 水利-站点水位数据 */ - @XxlJob(LOAD_WATER_LEVEL) - //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT loadWaterLevel(String param) { + //@XxlJob(LOAD_WATER_LEVEL) + @Scheduled(cron = "0/40 * * * * ? ") + public ReturnT loadWaterLevel() { + String param = ""; if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java index 98aaa2b..c5dfd55 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.hnac.hzims.EquipmentConstants; import com.hnac.hzims.equipment.entity.EmParamEntity; +import com.hnac.hzims.equipment.entity.StartStopDurationEntity; import com.hnac.hzims.equipment.entity.ThirtyGenerationEntity; import com.hnac.hzims.equipment.entity.ThreeGenerationEntity; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; @@ -19,10 +20,7 @@ import com.hnac.hzims.operational.main.vo.*; import com.hnac.hzims.operational.station.StationConstants; import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity; import com.hnac.hzims.operational.station.entity.StationEntity; -import com.hnac.hzims.scheduled.service.equipment.DeviceParamService; -import com.hnac.hzims.scheduled.service.equipment.DeviceService; -import com.hnac.hzims.scheduled.service.equipment.ThirtyGenerateService; -import com.hnac.hzims.scheduled.service.equipment.ThreeGenerateService; +import com.hnac.hzims.scheduled.service.equipment.*; import com.hnac.hzims.scheduled.service.operation.fill.*; import com.hnac.hzims.scheduled.service.operation.home.ModelStationService; import com.hnac.hzims.scheduled.service.operation.home.RealTargetService; @@ -42,7 +40,6 @@ import com.hnac.hzinfo.sdk.core.response.HzPage; import com.hnac.hzinfo.sdk.core.response.Result; import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; import com.xxl.job.core.log.XxlJobLogger; -import io.undertow.util.CopyOnWriteMap; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; @@ -58,7 +55,9 @@ import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.math.RoundingMode; +import java.time.Duration; import java.time.LocalDate; +import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.*; @@ -102,6 +101,8 @@ public class RealTargetServiceImpl implements RealTargetService { private final ThirtyGenerateService thirtyGenerateService; + private final StartStopDurationService startStopDurationService; + private final RedisTemplate redisTemplate; private final IHeWeatherWeatherClient heWeatherWeatherClient; @@ -293,6 +294,9 @@ public class RealTargetServiceImpl implements RealTargetService { List targets = this.generteFill(stations); // 水电站设备 List devices = this.pumpDevices(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())); + // 今年已经过去多少个小时了 + double hoursPassed = this.hoursPassed(); + Random random = new Random(); if(CollectionUtil.isNotEmpty(devices)){ CountDownLatch countDownLatch = new CountDownLatch(devices.size()); @@ -319,16 +323,29 @@ public class RealTargetServiceImpl implements RealTargetService { target.setActivePowerVoList(this.getLoadsByDay(device)); // 30天发电量 target.setGenerationPowerVoList(this.getGenerationPowerList(generations,device)); + if(station.isPresent()){ + // 查询设备当年开停机数据 + List durations = startStopDurationService.list(Wrappers.lambdaQuery() + .eq(StartStopDurationEntity::getStationId,station.get().getCode()) + .eq(StartStopDurationEntity::getDeviceCode,device.getEmCode()) + ); + if(CollectionUtil.isEmpty(durations)){ + target.setStartupDurationYear(0.0); + target.setShutDownDurationYear(hoursPassed); + }else{ + target.setStartupDurationYear(durations.stream().mapToDouble(StartStopDurationEntity::getStartDuration).sum()); + target.setShutDownDurationYear(durations.stream().mapToDouble(StartStopDurationEntity::getStopDuration).sum()); + } + }else{ + target.setStartupDurationYear(0.0); + target.setShutDownDurationYear(hoursPassed); + } // FIXME 本次开机/停机时间 Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.MINUTE,random.nextInt(1440)); target.setStartDownTime(DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME)); // FIXME 本次开/停机时长 target.setStartupDownDuration(random.nextDouble() * 24); - // FIXME 今年开机时长 - target.setStartupDurationYear(random.nextDouble() * 5024); - // FIXME 今年停机时长 - target.setShutDownDurationYear(5024 - target.getStartupDurationYear()); targets.add(target); countDownLatch.countDown(); }catch (Exception exception){ @@ -347,7 +364,6 @@ public class RealTargetServiceImpl implements RealTargetService { if(CollectionUtil.isEmpty(targets)){ return; } - redisTemplate.opsForValue().set(load_hydropower_unit_target_key,targets); } @@ -421,6 +437,20 @@ public class RealTargetServiceImpl implements RealTargetService { } /** + * 今年过去多少个小时 + * @return + */ + private double hoursPassed() { + LocalDateTime now = LocalDateTime.now(); + // 获取当前年份的第一个小时 + LocalDateTime startOfYear = LocalDateTime.of(now.getYear(), 1, 1, 0, 0); + // 计算持续时间 + Duration duration = Duration.between(startOfYear, now); + // 输出过了多少个小时 + return Double.parseDouble(String.valueOf(duration.toHours())); + } + + /** * 水利-泵组实时加载 * @param param */ @@ -667,10 +697,10 @@ public class RealTargetServiceImpl implements RealTargetService { double dischargeFlow=this.getWaterLevel(item.getInstanceCode(),HomePageConstant.DISCHARGE_FLOW); waterLevelVo.setDischargeFlow(dischargeFlow); // 前水位当日曲线 - Map frontCurveMap=this.getWaterLevelMap(item.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL); + Map frontCurveMap=this.getWaterLevelMap(item.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL); waterLevelVo.setFrontCurveMap(frontCurveMap); // 后水位当日曲线 - Map rearCurveMap=this.getWaterLevelMap(item.getInstanceCode(),HomePageConstant.REAR_WATER_LEVEL); + Map rearCurveMap=this.getWaterLevelMap(item.getInstanceCode(),HomePageConstant.REAR_WATER_LEVEL); waterLevelVo.setRearCurveMap(rearCurveMap); list.add(waterLevelVo); } @@ -1262,11 +1292,14 @@ public class RealTargetServiceImpl implements RealTargetService { * @param signage * @return */ - private Map getWaterLevelMap(String instanceCode, String signage) { - // 开始日期 - String start = DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00"; - // 结束日期 - String end = DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 23:59:59"; + private Map getWaterLevelMap(String instanceCode, String signage) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + // 结束时间 + String end = DateUtil.format(calendar.getTime(),"yyyy-MM-dd HH:") + "59:59"; + calendar.add(Calendar.HOUR_OF_DAY,-23); + // 开始时间 + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); List datas = dataService.periodTargetData(start, end,6, 2,instanceCode,signage); if(CollectionUtil.isEmpty(datas)){ return new HashMap<>(); @@ -1275,14 +1308,14 @@ public class RealTargetServiceImpl implements RealTargetService { key-> { if(key.getTs().contains(".0")){ Date dateTime = DateUtil.parse(key.getTs(), "yyyy-MM-dd HH:mm:ss.s"); - return dateTime.getHours(); + return DateUtil.format(dateTime,DateUtil.PATTERN_DATETIME); } Date dateTime = DateUtil.parse(key.getTs() + ".0", "yyyy-MM-dd HH:mm:ss.s"); - return dateTime.getHours(); + return DateUtil.format(dateTime,DateUtil.PATTERN_DATETIME); }, value -> { if(StringUtil.isEmpty(value.getVal())){ - return ""; + return "0.0"; } return value.getVal(); }) @@ -1626,13 +1659,13 @@ public class RealTargetServiceImpl implements RealTargetService { target.setDeptName(station.getName()); // 当年发电量 target.setPowerYear(generateService.generate(year,station.getCode())); - // FIXME 去年发电量 + // 去年发电量 target.setPowerYesterYear(0f); // 当月发电量 target.setPowerMon(generateService.generate(mon,station.getCode())); // 当日发电量 target.setPowerDay(generateService.generate(day,station.getCode())); - // FIXME 昨日发电量 + // 昨日发电量 target.setPowerYesterDay(0f); // 30天发电量 target.setGenerationPowerVoList(generateService.generate30Day(day,station.getCode())); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java index 723778b..fe5016a 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java @@ -1,6 +1,5 @@ package com.hnac.hzims.operational.data.service.impl; -import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.equipment.entity.PlanGenerationEntity; import com.hnac.hzims.equipment.feign.IEmInfoClient; @@ -10,7 +9,6 @@ import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.hzimsweather.feign.IRainfallClient; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse; import com.hnac.hzims.operational.data.service.HzimsDataService; -import com.hnac.hzims.operational.data.vo.AreaVo; import com.hnac.hzims.operational.data.vo.*; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.service.AreaService; @@ -26,15 +24,12 @@ import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; 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.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; -import org.springblade.system.entity.Dept; import org.springblade.system.feign.ISysClient; -import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @@ -695,7 +690,9 @@ public class HzimsDataServiceImpl implements HzimsDataService { WaterLevelVo level = validList.get(0); // 前池水位、当日水位曲线 response.setFrontWaterLevel(level.getFrontWaterLevel()); - response.setFrontCurveMap(level.getFrontCurveMap()); + response.setFrontCurveMap(level.getFrontCurveMap().entrySet().stream().collect(Collectors.toMap( + entry-> DateUtil.parse(entry.getKey(),DateUtil.PATTERN_DATETIME).getHours(), + Map.Entry::getValue))); } /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/controller/HydroelectricController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/controller/HydroelectricController.java index fb32444..414d475 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/controller/HydroelectricController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/controller/HydroelectricController.java @@ -47,4 +47,5 @@ public class HydroelectricController extends BladeController { public R group() { return R.data(hydroelectricService.group()); } + } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java index 936a09d..7f05544 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java @@ -17,8 +17,10 @@ import com.hnac.hzims.operational.homePage.hydroelectric.constant.HydroelectricC import com.hnac.hzims.operational.homePage.hydroelectric.vo.*; import com.hnac.hzims.operational.homePage.service.HydroelectricService; import com.hnac.hzims.operational.main.service.IWeatherService; +import com.hnac.hzims.operational.main.vo.ActivePowerVo; import com.hnac.hzims.operational.main.vo.HydropowerUnitRealVo; import com.hnac.hzims.operational.main.vo.HydropowerUnitTargetVo; +import com.hnac.hzims.operational.main.vo.WaterLevelVo; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.service.IStationService; import lombok.RequiredArgsConstructor; @@ -62,6 +64,7 @@ public class HydroelectricServiceImpl implements HydroelectricService { private final RedisTemplate redisTemplate; + private final static String LOADWATER_LEVEL_KEY = "hzims:operation:loadwater:level:key"; private final static String RECENT_YEAR_POWER_DATA = "hzims:operation:key:power:data"; private final static String LOAD_HYDROPOWER_REAL_KEY = "hzims:operation:loadhydropowerunit:real:key"; private final static String LOAD_HYDROPOWER_TARGET_KEY = "hzims:operation:loadhydropowerunit:target:key"; @@ -87,13 +90,15 @@ public class HydroelectricServiceImpl implements HydroelectricService { // 指标数据 List targets = (List) redisTemplate.opsForValue().get(LOAD_HYDROPOWER_TARGET_KEY); // 降雨数据 - List> rains = this.nearThirtyRains(station.getCode()); + //List> rains = this.nearThirtyRains(station.getCode()); // 七日天气 Map weathers = this.weekWeather(Collections.singletonList(station.getCode())); // 近3年发电量 Map> map = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); // 计划发电量 List plans = planClient.getPlanPowerByYear(station.getCode(), Integer.parseInt(DateUtil.format(new Date(),"yyyy"))); + // 水位数据 + List waterLevels = (List) redisTemplate.opsForValue().get(LOADWATER_LEVEL_KEY); // 步骤3.数据处理、赋值 HydroelectricStationVo result = new HydroelectricStationVo(); @@ -196,8 +201,12 @@ public class HydroelectricServiceImpl implements HydroelectricService { result.setPowerDay(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerDay).sum()); result.setPowerYesterDay(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerYesterDay).sum()); } + // 站点水位 + result.setWater(this.water(waterLevels,station.getCode())); // 近30日降雨量/发电量 - result.setPowerRains(this.stationPowerRains(result.getDevices(),rains)); + //result.setPowerRains(this.stationPowerRains(result.getDevices(),rains)); + // 近24小时总有功率/水位 + result.setLoadWaters(this.stationLoadWaters(targets,waterLevels,station)); // 电站月发电/计划发电 result.setGenerateMons(this.stationGenerateMons(plans,map.get(station.getCode()))); return result; @@ -732,6 +741,23 @@ public class HydroelectricServiceImpl implements HydroelectricService { } /** + * 站点水位 + * @param waterLevels + * @param code + * @return + */ + private Double water(List waterLevels, String code) { + if(CollectionUtil.isEmpty(waterLevels)){ + return 0.0; + } + Optional optional = waterLevels.stream().filter(o->code.equals(o.getStationCode())).findFirst(); + if(optional.isPresent() && ObjectUtil.isNotEmpty(optional.get().getFrontWaterLevel())){ + return optional.get().getFrontWaterLevel(); + } + return 0.0; + } + + /** * 站点近30天降雨量/发电量 * @param devices * @return @@ -788,6 +814,81 @@ public class HydroelectricServiceImpl implements HydroelectricService { return powerRains; } + + /** + * 站点近24小时总有功率/水位 + * @param targets + * @param waterLevels + * @param station + * @return + */ + private List stationLoadWaters(List targets, List waterLevels, StationEntity station) { + // 功率 + List loads = new ArrayList<>(); + if(CollectionUtil.isNotEmpty(targets)){ + List devices = targets.stream().filter(o->station.getRefDept().equals(o.getDeptId())).collect(Collectors.toList()); + if(CollectionUtil.isNotEmpty(devices)){ + for(HydropowerUnitTargetVo device : devices){ + if(CollectionUtil.isNotEmpty(device.getActivePowerVoList())){ + loads.addAll(device.getActivePowerVoList().stream().map(o->{ + HydroelectricLoadVo load = new HydroelectricLoadVo(); + load.setTime(o.getStrHour()); + load.setLoad(o.getActivePower()); + return load; + }).collect(Collectors.toList())); + } + } + } + } + + // 水位 + List waters = new ArrayList<>(); + if(CollectionUtil.isNotEmpty(waterLevels)){ + List devices = waterLevels.stream().filter(o->station.getCode().equals(o.getStationCode())).collect(Collectors.toList()); + if(CollectionUtil.isNotEmpty(devices)){ + for(WaterLevelVo device : devices){ + if(CollectionUtil.isNotEmpty(device.getFrontCurveMap())){ + waters.addAll(device.getFrontCurveMap().entrySet().stream().map(entry -> { + HydroelectricWaterVo water = new HydroelectricWaterVo(); + Date time = DateUtil.parse(entry.getKey(),DateUtil.PATTERN_DATETIME); + water.setTime(entry.getKey()); + water.setWater(entry.getValue()); + return water; + }).collect(Collectors.toList())); + } + } + } + } + + List loadWaters = new ArrayList<>(); + // 时间遍历 + Calendar calendar = Calendar.getInstance(); + Date end = calendar.getTime(); + calendar.add(Calendar.HOUR_OF_DAY,-23); + Date start = calendar.getTime(); + while (start.compareTo(end) <= 0){ + HydroelectricLoadWaterVo loadWater = new HydroelectricLoadWaterVo(); + loadWater.setTime(DateUtil.format(start,"yyyy-MM-dd HH")); + loadWater.setHour(start.getHours()); + // 功率 + if(CollectionUtil.isEmpty(loads)){ + loadWater.setLoad(0.0); + }else{ + loadWater.setLoad(loads.stream().filter(load->load.getTime().contains(loadWater.getTime())).mapToDouble(o->Double.parseDouble(o.getLoad())).sum()); + } + // 水位 + if(CollectionUtil.isEmpty(waters)){ + loadWater.setWater(0.0); + }else{ + loadWater.setWater(waters.stream().filter(water->water.getTime().contains(loadWater.getTime())).mapToDouble(o->Double.parseDouble(o.getWater())).sum()); + } + loadWaters.add(loadWater); + calendar.add(Calendar.HOUR_OF_DAY,1); + start = calendar.getTime(); + } + return loadWaters; + } + /** * 站点电站月发电/计划发电 * @param plans 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 62da01b..1d305c2 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 @@ -569,7 +569,9 @@ public class HydropowerServiceImpl implements HydropowerService { WaterLevelVo level = validList.get(0); // 前池水位、当日水位曲线 response.setFrontWaterLevel(level.getFrontWaterLevel()); - response.setFrontCurveMap(level.getFrontCurveMap()); + response.setFrontCurveMap(level.getFrontCurveMap().entrySet().stream().collect(Collectors.toMap( + entry-> DateUtil.parse(entry.getKey(),DateUtil.PATTERN_DATETIME).getHours(), + Map.Entry::getValue))); } /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java index ceee58f..30d7981 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java @@ -654,9 +654,13 @@ public class WaterServiceImpl implements IWaterService { // 获取全年水位map Map map; if(flag == 0){ - map = list.get(0).getFrontCurveMap(); + map = list.get(0).getFrontCurveMap().entrySet().stream().collect(Collectors.toMap( + entry-> DateUtil.parse(entry.getKey(),DateUtil.PATTERN_DATETIME).getHours(), + Map.Entry::getValue)); } else { - map = list.get(0).getRearCurveMap(); + map = list.get(0).getRearCurveMap().entrySet().stream().collect(Collectors.toMap( + entry-> DateUtil.parse(entry.getKey(),DateUtil.PATTERN_DATETIME).getHours(), + Map.Entry::getValue)); } if(MapUtils.isEmpty(map)){ return null; From 8ee3dccc353d1cb0b144cbddeaad9dc40b074f8b Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Wed, 11 Sep 2024 17:23:16 +0800 Subject: [PATCH 3/3] =?UTF-8?q?#=E6=96=B0=E7=89=88=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=B0=B4=E4=BD=8D=E7=BB=9F=E8=AE=A1=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/operation/home/impl/RealTargetServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java index c5dfd55..f61cec6 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java @@ -1296,10 +1296,10 @@ public class RealTargetServiceImpl implements RealTargetService { Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); // 结束时间 - String end = DateUtil.format(calendar.getTime(),"yyyy-MM-dd HH:") + "59:59"; + String end = DateUtil.format(calendar.getTime(),"yyyy-MM-dd HH") + ":59:59"; calendar.add(Calendar.HOUR_OF_DAY,-23); // 开始时间 - String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); + String start = DateUtil.format(calendar.getTime(),"yyyy-MM-dd HH") + ":00:00"; List datas = dataService.periodTargetData(start, end,6, 2,instanceCode,signage); if(CollectionUtil.isEmpty(datas)){ return new HashMap<>(); @@ -1559,7 +1559,7 @@ public class RealTargetServiceImpl implements RealTargetService { calendar.add(Calendar.HOUR_OF_DAY,-23); // 开始日期 Date start = calendar.getTime(); - List records = dataService.periodTargetData(DateUtil.format(start,"yyyy-MM-dd HH") + ":00:00", DateUtil.format(end,DateUtil.PATTERN_DATETIME), 3, 2, device.getEmCode(), HomePageConstant.PV_LOAD); + List records = dataService.periodTargetData(DateUtil.format(start,"yyyy-MM-dd HH") + ":00:00", DateUtil.format(start,"yyyy-MM-dd HH") + ":59:59", 3, 2, device.getEmCode(), HomePageConstant.PV_LOAD); List activePowers = new ArrayList<>(); while (start.compareTo(end) <= 0){ String time = DateUtil.format(start,"yyyy-MM-dd HH");