diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/constants/AccessRules.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/constants/AccessRules.java new file mode 100644 index 0000000..ec1215b --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/constants/AccessRules.java @@ -0,0 +1,49 @@ +package com.hnac.gglm.bigmodel.business.constants; + +import lombok.Getter; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * @Author: ypj + * @Date: 2024/9/20 22:39 + */ +@Getter +public enum AccessRules { + MOST_EARLY("0", "最早值"), + LARGEST("1", "最大值"), + SMALLEST("2", "最小值"), + AVERAGE("3", "平均值"), + SUM("4", "累计值/和值"), + CHANGE("5", "变化值/差值"), + LAST("6", "最新值/最后值"); + + private final String code; + private final String desc; + + private static final Map map = new ConcurrentHashMap<>(); + + static { + for (AccessRules accessRules : AccessRules.values()) { + map.put(accessRules.code, accessRules); + } + } + + AccessRules(String code, String desc) { + this.code = code; + this.desc = desc; + } + + public static AccessRules getByCode(String code) { + return map.get(code); + } + + public static String getDescByCode(String code) { + AccessRules rule = getByCode(code); + if (null != rule) { + return rule.getDesc(); + } + return null; + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/controller/VectorDataController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/controller/VectorDataController.java index 0d4c8d1..437465a 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/controller/VectorDataController.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/controller/VectorDataController.java @@ -1,12 +1,17 @@ package com.hnac.gglm.bigmodel.business.controller; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.gglm.bigmodel.business.service.KnowledgeDataService; import com.hnac.gglm.bigmodel.business.service.VectorDataService; import com.hnac.gglm.bigmodel.business.vo.DeviceModelData; +import com.hnac.gglm.bigmodel.maintenance.dto.KnowledgeData; import com.hnac.hzinfo.api.annotation.ApiInterface; +import com.hnac.hzinfo.sdk.v5.device.dto.DeviceAttrInfoDTO; +import com.hnac.hzinfo.sdk.v5.device.dto.DeviceFuncInfoDTO; import com.hnac.hzinfo.sdk.v5.model.vo.ModelAttrVO; import com.hnac.hzinfo.sdk.v5.model.vo.ModelEventVO; import com.hnac.hzinfo.sdk.v5.model.vo.ModelFuncVO; +import com.hnac.hzinfo.sdk.v5.scada.vo.CanvasInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; @@ -30,7 +35,7 @@ import java.util.List; public class VectorDataController { private final VectorDataService vectorDataService; - + private final KnowledgeDataService knowledgeDataService; @GetMapping("/getModelAttributeData") @ApiOperation(value = "获取模型属性数据") @@ -63,4 +68,38 @@ public class VectorDataController { public R> getModelData() { return R.data(vectorDataService.getModelData()); } + + + @GetMapping("/getDeviceAttr") + @ApiOperation(value = "获取设备属性数据") + @ApiOperationSupport(order = 5) + @ApiInterface + public R> getDeviceAttr() { + return R.data(vectorDataService.getDeviceAttr()); + } + + @GetMapping("/getDeviceFunc") + @ApiOperation(value = "获取设备功能数据") + @ApiOperationSupport(order = 6) + @ApiInterface + public R> getDeviceFunc() { + return R.data(vectorDataService.getDeviceFunc()); + } + + @GetMapping("/listKnowledgeData") + @ApiOperation(value = "获取知识库数据") + @ApiOperationSupport(order = 7) + @ApiInterface + public R> listKnowledgeData() { + return R.data(knowledgeDataService.listKnowledgeData()); + } + + @GetMapping("/listCanvas") + @ApiOperation(value = "获取画布数据") + @ApiOperationSupport(order = 8) + @ApiInterface + public R> listCanvas() { + return R.data(vectorDataService.getScadaCanvas()); + } + } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/KnowledgeDataService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/KnowledgeDataService.java new file mode 100644 index 0000000..650dbd5 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/KnowledgeDataService.java @@ -0,0 +1,13 @@ +package com.hnac.gglm.bigmodel.business.service; + +import com.hnac.gglm.bigmodel.maintenance.dto.KnowledgeData; + +import java.util.List; + +/** + * @Author: ypj + * @Date: 2024/9/20 15:04 + */ +public interface KnowledgeDataService { + List listKnowledgeData(); +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/VectorDataService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/VectorDataService.java index 0c20182..afa5941 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/VectorDataService.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/VectorDataService.java @@ -1,9 +1,12 @@ package com.hnac.gglm.bigmodel.business.service; import com.hnac.gglm.bigmodel.business.vo.DeviceModelData; +import com.hnac.hzinfo.sdk.v5.device.dto.DeviceAttrInfoDTO; +import com.hnac.hzinfo.sdk.v5.device.dto.DeviceFuncInfoDTO; import com.hnac.hzinfo.sdk.v5.model.vo.ModelAttrVO; import com.hnac.hzinfo.sdk.v5.model.vo.ModelEventVO; import com.hnac.hzinfo.sdk.v5.model.vo.ModelFuncVO; +import com.hnac.hzinfo.sdk.v5.scada.vo.CanvasInfo; import java.util.List; @@ -20,4 +23,10 @@ public interface VectorDataService { List getModelEventData(); List getModelData(); + + List getDeviceAttr(); + + List getDeviceFunc(); + + List getScadaCanvas(); } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/impl/KnowledgeDataServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/impl/KnowledgeDataServiceImpl.java new file mode 100644 index 0000000..a498431 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/impl/KnowledgeDataServiceImpl.java @@ -0,0 +1,49 @@ +package com.hnac.gglm.bigmodel.business.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.dynamic.datasource.annotation.DS; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.hnac.gglm.bigmodel.business.service.KnowledgeDataService; +import com.hnac.gglm.bigmodel.maintenance.dto.KnowledgeData; +import com.hnac.gglm.bigmodel.maintenance.mapper.KnowledgeFileFragmentMapper; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * @Author: ypj + * @Date: 2024/9/20 15:04 + */ +@Service +@Slf4j +@AllArgsConstructor +@DS("hznlm") +public class KnowledgeDataServiceImpl implements KnowledgeDataService { + KnowledgeFileFragmentMapper knowledgeFileFragmentMapper; + + @Override + public List listKnowledgeData() { + List resourceList = knowledgeFileFragmentMapper.listKnowledgeData(); + List resultList = new ArrayList<>(); + for (KnowledgeData item : resourceList) { + String question = item.getDocQs(); + List questionList = JSONObject.parseArray(question, String.class); + for (String q : questionList) { + KnowledgeData data = new KnowledgeData(); + data.setDocId(item.getDocId()); + data.setDocContent(item.getDocContent()); + data.setDocPageIndex(item.getDocPageIndex()); + data.setDocQs(q); + data.setArea(item.getArea()); + data.setLevel(item.getLevel()); + resultList.add(data); + } + } + return resultList; + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/impl/VectorDataServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/impl/VectorDataServiceImpl.java index 574562f..795a628 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/impl/VectorDataServiceImpl.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/impl/VectorDataServiceImpl.java @@ -1,11 +1,17 @@ package com.hnac.gglm.bigmodel.business.service.impl; +import com.hnac.gglm.bigmodel.business.constants.AccessRules; import com.hnac.gglm.bigmodel.business.service.VectorDataService; import com.hnac.gglm.bigmodel.business.vo.DeviceModelData; +import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; +import com.hnac.hzinfo.sdk.v5.device.dto.DeviceAttrInfoDTO; +import com.hnac.hzinfo.sdk.v5.device.dto.DeviceFuncInfoDTO; import com.hnac.hzinfo.sdk.v5.model.ModelClient; import com.hnac.hzinfo.sdk.v5.model.vo.ModelAttrVO; import com.hnac.hzinfo.sdk.v5.model.vo.ModelEventVO; import com.hnac.hzinfo.sdk.v5.model.vo.ModelFuncVO; +import com.hnac.hzinfo.sdk.v5.scada.ScadaClient; +import com.hnac.hzinfo.sdk.v5.scada.vo.CanvasInfo; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.api.R; @@ -24,6 +30,8 @@ import java.util.stream.Collectors; @AllArgsConstructor public class VectorDataServiceImpl implements VectorDataService { private final ModelClient modelClient; + private final DeviceClient deviceClient; + private final ScadaClient scadaClient; @Override @@ -61,4 +69,29 @@ public class VectorDataServiceImpl implements VectorDataService { } return modelDataList; } + + @Override + public List getDeviceAttr() { + List list = deviceClient.listDeviceAttr().getData(); + if (null != list && !list.isEmpty()) { + list.forEach(item -> { + item.setItemName(item.getProjectName() + " " + item.getDeviceName() + " " + item.getName()); + String rule = AccessRules.getDescByCode(item.getRule()); + if (null != rule) { + item.setRule(rule); + } + }); + } + return list; + } + + @Override + public List getDeviceFunc() { + return deviceClient.listDeviceFunc().getData(); + } + + @Override + public List getScadaCanvas() { + return scadaClient.listCanvas().getData(); + } } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/DataInstructController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/DataInstructController.java new file mode 100644 index 0000000..f588e6f --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/DataInstructController.java @@ -0,0 +1,69 @@ +package com.hnac.gglm.bigmodel.maintenance.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.gglm.bigmodel.maintenance.dto.DeviceFuncDTO; +import com.hnac.gglm.bigmodel.maintenance.entity.DataInstructEntity; +import com.hnac.gglm.bigmodel.maintenance.service.DataInstructService; +import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; +import com.hnac.hzinfo.api.annotation.ApiInterface; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +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 javax.validation.Valid; +import java.util.List; + +@RestController +@RequestMapping("/dataInstruct") +@Api(value = "控制指令管理",tags = "控制指令管理") +@AllArgsConstructor +public class DataInstructController { + + private DataInstructService dataInstructService; + + + @PostMapping("/save") + @ApiOperation("保存控制指令") + @ApiOperationSupport(order = 1) + public R save(@RequestBody @Valid DataInstructEntity req) { + return R.data(dataInstructService.save(req)); + } + + @PostMapping("/update") + @ApiOperation("编辑控制指令") + @ApiOperationSupport(order = 2) + public R update(@RequestBody DataInstructEntity req) { + return R.data(dataInstructService.updateById(req)); + } + + @GetMapping("/listPage") + @ApiOperation("控制指令列表查询") + @ApiOperationSupport(order = 3) + public R> listPage(Query query, DataInstructEntity req) { + return R.data(dataInstructService.page(Condition.getPage(query),Condition.getQueryWrapper(req).lambda())); + } + + @DeleteMapping("/removeByIds") + @ApiOperation("删除控制指令") + @ApiOperationSupport(order = 4) + public R removeByIds(@RequestParam @ApiParam("id,按逗号分隔") String ids) { + return R.status(dataInstructService.removeByIds(Func.toLongList(",",ids))); + } + + + @GetMapping ("/getDataInstructList") + @ApiOperationSupport(order = 210) + @ApiOperation(value = "查询指令记录") + @ApiInterface + public R> getDataInstructList() { + return R.data(dataInstructService.getDataInstructList()); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/DataRecordController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/DataRecordController.java new file mode 100644 index 0000000..d561cf4 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/DataRecordController.java @@ -0,0 +1,66 @@ +package com.hnac.gglm.bigmodel.maintenance.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.gglm.bigmodel.maintenance.dto.DeviceAttrDTO; +import com.hnac.gglm.bigmodel.maintenance.entity.DataRecordEntity; +import com.hnac.gglm.bigmodel.maintenance.service.DataRecordService; +import com.hnac.hzinfo.api.annotation.ApiInterface; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +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 javax.validation.Valid; +import java.util.List; + +@RestController +@RequestMapping("/dataRecord") +@Api(value = "数据记录管理",tags = "数据记录管理") +@AllArgsConstructor +public class DataRecordController { + + private DataRecordService dataRecordService; + + @PostMapping("/save") + @ApiOperation("保存数据记录信息") + @ApiOperationSupport(order = 1) + public R save(@RequestBody @Valid DataRecordEntity req) { + return R.data(dataRecordService.save(req)); + } + + @PostMapping("/update") + @ApiOperation("编辑数据记录信息") + @ApiOperationSupport(order = 2) + public R update(@RequestBody DataRecordEntity req) { + return R.data(dataRecordService.updateById(req)); + } + + @GetMapping("/listPage") + @ApiOperation("数据记录列表查询") + @ApiOperationSupport(order = 3) + public R> listPage(Query query, DataRecordEntity req) { + return R.data(dataRecordService.page(Condition.getPage(query),Condition.getQueryWrapper(req).lambda())); + } + + @DeleteMapping("/removeByIds") + @ApiOperation("删除数据记录") + @ApiOperationSupport(order = 4) + public R removeByIds(@RequestParam @ApiParam("id,按逗号分隔") String ids) { + return R.status(dataRecordService.removeByIds(Func.toLongList(",",ids))); + } + + @GetMapping ("/getDataRecordList") + @ApiOperationSupport(order = 200) + @ApiOperation(value = "查询数据记录记录") + @ApiInterface + public R> getDataRecordList() { + return R.data(dataRecordService.getDataRecordList()); + } + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceAttrDTO.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceAttrDTO.java new file mode 100644 index 0000000..adcc3d4 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceAttrDTO.java @@ -0,0 +1,33 @@ +package com.hnac.gglm.bigmodel.maintenance.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class DeviceAttrDTO { + + + @ApiModelProperty("item") + private String itemId; + + @ApiModelProperty("站点名称") + private String stationName; + + @ApiModelProperty("站点ID") + private String stationId; + + @ApiModelProperty("遥控的设备名称") + private String deviceName; + + @ApiModelProperty("遥控的设备ID") + private String deviceId; + + @ApiModelProperty("用于展示和匹配的全称,一般可设为 站点名称-遥控名称") + private String itemName; + + @ApiModelProperty("记录名称") + private String recordName; + + @ApiModelProperty("取数规则") + private String rule; +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceFuncDTO.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceFuncDTO.java new file mode 100644 index 0000000..c60ee79 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceFuncDTO.java @@ -0,0 +1,28 @@ +package com.hnac.gglm.bigmodel.maintenance.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + + +@Data +public class DeviceFuncDTO { + + @ApiModelProperty("item") + private String itemId; + + @ApiModelProperty("站点名称") + private String stationName; + + @ApiModelProperty("站点ID") + private String stationId; + + @ApiModelProperty("遥控的设备名称") + private String deviceName; + + @ApiModelProperty("遥控的设备ID") + private String deviceId; + + @ApiModelProperty("用于展示和匹配的全称,一般可设为 站点名称-遥控名称") + private String itemName; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/KnowledgeData.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/KnowledgeData.java new file mode 100644 index 0000000..6e1d3ce --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/KnowledgeData.java @@ -0,0 +1,36 @@ +package com.hnac.gglm.bigmodel.maintenance.dto; + +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Author: ypj + * @Date: 2024/9/20 15:07 + */ +@Data +@ApiModel(value = "知识库文件分片信息", description = "知识库文件分片信息") +public class KnowledgeData { + @ApiModelProperty("文档ID") + @TableField("DOC_ID") + private Long docId; + + @ApiModelProperty("文档问题") + @TableField("DOC_QS") + private String docQs; + + @ApiModelProperty("文档内容") + @TableField("DOC_CONTENT") + private String docContent; + + @ApiModelProperty("文档页码") + @TableField("DOC_PAGE_INDEX") + private Integer docPageIndex; + + @ApiModelProperty("知识库领域") + private String area; + + @ApiModelProperty("等级") + private Integer level; +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/DataInstructEntity.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/DataInstructEntity.java new file mode 100644 index 0000000..d6f4a4a --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/DataInstructEntity.java @@ -0,0 +1,42 @@ +package com.hnac.gglm.bigmodel.maintenance.entity; + +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; + +@Data +@EqualsAndHashCode +@TableName("gglm_data_instruct") +@ApiModel(value = "自定义控制指令表",description = "自定义控制指令表") +public class DataInstructEntity extends TenantEntity { + + @ApiModelProperty("item") + private String itemId; + + @ApiModelProperty("站点名称") + @QueryField(condition = SqlCondition.LIKE) + private String stationName; + + @ApiModelProperty("站点ID") + private String stationId; + + @ApiModelProperty("遥控的设备名称") + @QueryField(condition = SqlCondition.LIKE) + private String deviceName; + + @ApiModelProperty("遥控的设备ID") + private String deviceId; + + @ApiModelProperty("遥控名称(不包含站点)") + @QueryField(condition = SqlCondition.LIKE) + private String ykName; + + @ApiModelProperty("用于展示和匹配的全称,一般可设为 站点名称-遥控名称") + private String itemName; + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/DataRecordEntity.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/DataRecordEntity.java index c94fdd6..81cb222 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/DataRecordEntity.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/DataRecordEntity.java @@ -1,6 +1,12 @@ package com.hnac.gglm.bigmodel.maintenance.entity; +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; /** @@ -8,10 +14,42 @@ import org.springblade.core.tenant.mp.TenantEntity; * @Date: 2024/07/04 15:45 */ @Data +@EqualsAndHashCode +@TableName("gglm_data_record") +@ApiModel(value = "自定义数据查询表",description = "自定义数据查询表") public class DataRecordEntity extends TenantEntity { - private String tableId; + @ApiModelProperty("item") + @QueryField(condition = SqlCondition.EQUAL) + private String itemId; + + @ApiModelProperty("站点名称") + @QueryField(condition = SqlCondition.LIKE) + private String stationName; + + @ApiModelProperty("站点ID") + private String stationId; + + @ApiModelProperty("遥控的设备名称") + @QueryField(condition = SqlCondition.LIKE) + private String deviceName; + + @ApiModelProperty("遥控的设备ID") + private String deviceId; + + @ApiModelProperty("用于展示和匹配的全称,一般可设为 站点名称-遥控名称") + private String itemName; + + @ApiModelProperty("记录名称") + @QueryField(condition = SqlCondition.LIKE) + private String recordName; + + @ApiModelProperty("单位") + private String unit; + + @ApiModelProperty("取数规则") + private String rule; } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/DataInstructMapper.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/DataInstructMapper.java new file mode 100644 index 0000000..cca88da --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/DataInstructMapper.java @@ -0,0 +1,8 @@ +package com.hnac.gglm.bigmodel.maintenance.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.gglm.bigmodel.maintenance.entity.DataInstructEntity; + +public interface DataInstructMapper extends BaseMapper { + +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/DataRecordMapper.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/DataRecordMapper.java new file mode 100644 index 0000000..f36ba0f --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/DataRecordMapper.java @@ -0,0 +1,7 @@ +package com.hnac.gglm.bigmodel.maintenance.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.gglm.bigmodel.maintenance.entity.DataRecordEntity; + +public interface DataRecordMapper extends BaseMapper { +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/KnowledgeFileFragmentMapper.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/KnowledgeFileFragmentMapper.java index 3846042..df86ed2 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/KnowledgeFileFragmentMapper.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/KnowledgeFileFragmentMapper.java @@ -1,11 +1,15 @@ package com.hnac.gglm.bigmodel.maintenance.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.gglm.bigmodel.maintenance.dto.KnowledgeData; import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileFragment; +import java.util.List; + /** * @Author: ypj * @Date: 2024/9/11 10:49 */ public interface KnowledgeFileFragmentMapper extends BaseMapper { + List listKnowledgeData(); } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/KnowledgeFileFragmentMapper.xml b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/KnowledgeFileFragmentMapper.xml new file mode 100644 index 0000000..c4f82cd --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/KnowledgeFileFragmentMapper.xml @@ -0,0 +1,19 @@ + + + + + + + + \ No newline at end of file diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataInstructService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataInstructService.java new file mode 100644 index 0000000..11ac798 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataInstructService.java @@ -0,0 +1,68 @@ +package com.hnac.gglm.bigmodel.maintenance.service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.hnac.gglm.bigmodel.business.service.VectorDataService; +import com.hnac.gglm.bigmodel.maintenance.dto.DeviceFuncDTO; +import com.hnac.gglm.bigmodel.maintenance.entity.DataInstructEntity; +import com.hnac.gglm.bigmodel.maintenance.mapper.DataInstructMapper; +import com.hnac.hzinfo.sdk.v5.device.dto.DeviceFuncInfoDTO; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.utils.BeanUtil; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; + +@Service +@Slf4j +@AllArgsConstructor +public class DataInstructService extends BaseServiceImpl { + + private final VectorDataService vectorDataService; + + public boolean save(DataInstructEntity entity) { + //对遥控名称判重 + LambdaQueryWrapper queryWrapper = new QueryWrapper() + .lambda().eq(DataInstructEntity::getYkName, entity.getYkName()); + Long count = baseMapper.selectCount(queryWrapper); + if (count > 0) { + return false; + } + //保存信息 + return save(entity); + } + + public boolean updateById(DataInstructEntity entity) { + //对遥控名称判重 + LambdaQueryWrapper queryWrapper = new QueryWrapper() + .lambda().eq(DataInstructEntity::getItemName, entity.getItemName()) + .ne(DataInstructEntity::getId, entity.getId()); + Long count = baseMapper.selectCount(queryWrapper); + if (count > 0) { + return false; + } + //修改信息 + return true; + } + + public List getDataInstructList() { + List list = baseMapper.selectList(null); + List deviceFuncDTOS = BeanUtil.copyProperties(list, DeviceFuncDTO.class); + List deviceFuncList = vectorDataService.getDeviceFunc(); + for (DeviceFuncInfoDTO deviceFunc : deviceFuncList) { + DeviceFuncDTO deviceFuncDTO = new DeviceFuncDTO(); + deviceFuncDTO.setDeviceId(deviceFunc.getDeviceId()); + deviceFuncDTO.setDeviceName(deviceFunc.getDeviceName()); + deviceFuncDTO.setItemId(deviceFunc.getSignage()); + deviceFuncDTO.setItemName(deviceFunc.getItemName()); + deviceFuncDTO.setStationName(deviceFunc.getProjectName()); + deviceFuncDTO.setStationId(deviceFunc.getProjectId()); + deviceFuncDTOS.add(deviceFuncDTO); + } + return deviceFuncDTOS; + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataRecordService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataRecordService.java new file mode 100644 index 0000000..06cf331 --- /dev/null +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataRecordService.java @@ -0,0 +1,65 @@ +package com.hnac.gglm.bigmodel.maintenance.service; + +import com.hnac.gglm.bigmodel.business.service.VectorDataService; +import com.hnac.gglm.bigmodel.maintenance.dto.DeviceAttrDTO; +import com.hnac.gglm.bigmodel.maintenance.dto.DeviceFuncDTO; +import com.hnac.gglm.bigmodel.maintenance.entity.DataRecordEntity; +import com.hnac.gglm.bigmodel.maintenance.mapper.DataRecordMapper; +import com.hnac.hzinfo.sdk.v5.device.dto.DeviceAttrInfoDTO; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.utils.BeanUtil; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +@Slf4j +@AllArgsConstructor +public class DataRecordService extends BaseServiceImpl { + + private final VectorDataService vectorDataService; + + public boolean save(DataRecordEntity entity) { + splicing(entity); + return save(entity); + } + + public boolean updateById(DataRecordEntity entity) { + splicing(entity); + return updateById(entity); + } + + /** + * //拼接itemName + * @param entity + */ + private void splicing(DataRecordEntity entity) { + String stationName = entity.getStationName() == null ? "" : entity.getStationName(); + String deviceName = entity.getDeviceName() == null ? "" : entity.getDeviceName(); + String recordName = entity.getRecordName() == null ? "" : entity.getRecordName(); + entity.setItemName(new StringBuffer(stationName) + .append(" ").append(deviceName) + .append(" ").append(recordName).toString()); + } + + public List getDataRecordList() { + List list = baseMapper.selectList(null); + List deviceAttrDTOS = BeanUtil.copyProperties(list, DeviceAttrDTO.class); + List deviceAttrList = vectorDataService.getDeviceAttr(); + for (DeviceAttrInfoDTO deviceAttr : deviceAttrList) { + DeviceAttrDTO deviceAttrDTO = new DeviceAttrDTO(); + deviceAttrDTO.setDeviceId(deviceAttr.getDeviceId()); + deviceAttrDTO.setDeviceName(deviceAttr.getDeviceName()); + deviceAttrDTO.setStationName(deviceAttr.getProjectName()); + deviceAttrDTO.setStationId(deviceAttr.getProjectId()); + deviceAttrDTO.setRecordName(deviceAttr.getName()); + deviceAttrDTO.setItemId(deviceAttr.getSignage()); + deviceAttrDTO.setRule(deviceAttr.getRule()); + deviceAttrDTO.setItemName(deviceAttr.getItemName()); + deviceAttrDTOS.add(deviceAttrDTO); + } + return deviceAttrDTOS; + } +} diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java index 12c6a60..88e1d4c 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java @@ -172,7 +172,7 @@ public class VideoTaskSchedule { record.setUpdateUser(task.getUpdateUser()); record.setCurrentStatus("1"); CameraInfoEntity camera = this.getCameraByProIdAndConId(project.getProjectId(), content.getContentId()); - log.info("【taskId:" + task.getId() + "】视频巡检任务执行,获取视频巡检结果,camera:" + Optional.of(camera).map(JsonUtil::toJson).orElse("null")); + log.info("【taskId:" + task.getId() + "】视频巡检任务执行,获取视频巡检结果,camera:" + Optional.ofNullable(camera).map(JsonUtil::toJson).orElse("null")); if (Func.isNotEmpty(camera)) { // 获取计划时间段内视频的告警信息设置是否异常 if (Func.isNotEmpty(camera.getEmCode())) { @@ -182,12 +182,21 @@ public class VideoTaskSchedule { } } + String picUrl = null; // 调用海康威视api实现手动截屏回传至fileUrl if (Func.isNotEmpty(camera.getPointCode())) { - String picUrl = hikApiService.manualCapture(camera.getPointCode()); + try { + picUrl = hikApiService.manualCapture(camera.getPointCode()); + } catch (Exception e) { + log.error("get picture url fail", e); + } + } + if (Func.isNotEmpty(picUrl)) { record.setFileUrl(picUrl); record.setCurrentValue(picUrl); pictureHandle(picUrl, content.getContentId(), record, task); + } else { + record.setCurrentValue("获取视频地址失败"); } } return record; @@ -250,7 +259,8 @@ public class VideoTaskSchedule { } } catch (IOException e) { log.error("获取截图文件失败", e); - throw new HzServiceException("获取截图文件失败"); + record.setCurrentValue("获取截图文件失败"); + return; } R fileResponse = ossClient.putFileByNameAndTenantId("file", multipartFile, task.getTenantId()); log.info("【taskId:{}}】视频巡检任务执行,上传minio结果,{}", task.getId(), Optional.ofNullable(fileResponse).map(JsonUtil::toJson).orElse("null")); @@ -260,6 +270,7 @@ public class VideoTaskSchedule { ContentEntity content = contentService.getById(contentId); if (StringUtil.isBlank(content.getMultiCheckTypeSon())) { + record.setCurrentValue("没有找到巡检内容"); return; } @@ -272,7 +283,9 @@ public class VideoTaskSchedule { BigModelAnalysisResponseDTO analysisResponse = bigModelClient.analysis(analysisRequest); log.info("【taskId:{}}】视频巡检任务执行,大模型分析结果,{}", task.getId(), Optional.ofNullable(analysisResponse).map(JsonUtil::toJson).orElse("null")); if (!analysisResponse.getSuccess() || CollectionUtil.isEmpty(analysisResponse.getData())) { - throw new HzServiceException("大模型识别失败"); + record.setCurrentValue("大模型分析失败"); + log.error("【taskId:{}}】,返回消息 : {}" , task.getId(),Optional.ofNullable(analysisResponse).map(JsonUtil::toJson).orElse("null")); + return; } List results = analysisResponse.getData(); StringBuilder stringBuilder = new StringBuilder(); @@ -314,7 +327,7 @@ public class VideoTaskSchedule { messageDTO.setContent(textBuilder.toString()); R booleanR = messageClient.sendAppAndWsMsgByUsers(messageDTO); if (!booleanR.isSuccess()) { - throw new ServiceException("消息推送失败"); + log.error("【taskId:{}}】,返回的消息为{}", task.getId(), booleanR.getMsg()); } log.info("推送成功~"); }