Browse Source

Merge remote-tracking branch 'origin/prod-5.1.3' into prod-5.1.3

zhongwei
haungxing 3 months ago
parent
commit
5996a8136a
  1. 14
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/entity/HistoryTemplateEntity.java
  2. 20
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/vo/HistoryDevicePointVo.java
  3. 20
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/vo/HistoryFactoryPointVo.java
  4. 31
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/VideoRecordEntity.java
  5. 38
      hzims-service/equipment/src/main/java/com/hnac/hzims/history/controller/DeviceHistoryController.java
  6. 4
      hzims-service/equipment/src/main/java/com/hnac/hzims/history/controller/HistoryTemplateController.java
  7. 14
      hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/IHistoryDeviceService.java
  8. 91
      hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryDeviceServiceImpl.java
  9. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/config/ZhipuAiConfig.java
  10. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/config/ZhipuAiConfigProperties.java
  11. 32
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/AnalysisResultType.java
  12. 22
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ComparisonType.java
  13. 31
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultDataType.java
  14. 39
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultStrategyType.java
  15. 22
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/controller/ZhipuAnalysisInfoController.java
  16. 8
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java
  17. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/AbstractZhipuAnalysisHandler.java
  18. 40
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultBooleanStrategy.java
  19. 22
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultCommonStrategy.java
  20. 44
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultStrategy.java
  21. 12
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalyser.java
  22. 19
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java
  23. 4
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/mapper/ZhipuAnalysisInfoMapper.java
  24. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/ZhipuAnalysisInfoService.java
  25. 1
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisInfoServiceImpl.java
  26. 27
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java
  27. 7
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisFileResponse.java
  28. 3
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisInfoVO.java
  29. 32
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisResult.java
  30. 1
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/controller/HistoryController.java
  31. 47
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoRecordController.java
  32. 12
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/VideoRecordMapper.java
  33. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/VideoRecordMapper.xml
  34. 10
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/VideoRecordService.java
  35. 19
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/VideoRecordServiceImpl.java

14
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/entity/HistoryTemplateEntity.java

@ -19,7 +19,7 @@ import org.springblade.core.tenant.mp.TenantEntity;
public class HistoryTemplateEntity extends TenantEntity { public class HistoryTemplateEntity extends TenantEntity {
@ApiModelProperty(value = "模板名称") @ApiModelProperty(value = "模板名称")
private Long templateName; private String templateName;
@ApiModelProperty(value = "站点编码") @ApiModelProperty(value = "站点编码")
private String stationId; private String stationId;
@ -27,24 +27,36 @@ public class HistoryTemplateEntity extends TenantEntity {
@ApiModelProperty(value = "站点名称") @ApiModelProperty(value = "站点名称")
private String stationName; private String stationName;
@ApiModelProperty(value = "厂组ID1")
private String factoryId1;
@ApiModelProperty(value = "属性1") @ApiModelProperty(value = "属性1")
private String realId1; private String realId1;
@ApiModelProperty(value = "属性1名称") @ApiModelProperty(value = "属性1名称")
private String realName1; private String realName1;
@ApiModelProperty(value = "厂组ID2")
private String factoryId2;
@ApiModelProperty(value = "属性2") @ApiModelProperty(value = "属性2")
private String realId2; private String realId2;
@ApiModelProperty(value = "属性2名称") @ApiModelProperty(value = "属性2名称")
private String realName2; private String realName2;
@ApiModelProperty(value = "厂组ID3")
private String factoryId3;
@ApiModelProperty(value = "属性3") @ApiModelProperty(value = "属性3")
private String realId3; private String realId3;
@ApiModelProperty(value = "属性3名称") @ApiModelProperty(value = "属性3名称")
private String realName3; private String realName3;
@ApiModelProperty(value = "厂组ID4")
private String factoryId4;
@ApiModelProperty(value = "属性4") @ApiModelProperty(value = "属性4")
private String realId4; private String realId4;

20
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/vo/HistoryDevicePointVo.java

@ -0,0 +1,20 @@
package com.hnac.hzims.history.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
*/
@Data
public class HistoryDevicePointVo {
@ApiModelProperty(value = "设备编号")
private String deviceCode;
@ApiModelProperty(value = "点位名称")
private String name;
@ApiModelProperty(value = "点位属性标识")
private String signage;
}

20
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/history/vo/HistoryFactoryPointVo.java

@ -0,0 +1,20 @@
package com.hnac.hzims.history.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
*/
@Data
public class HistoryFactoryPointVo {
@ApiModelProperty(value = "厂租Id")
private String factoryId;
@ApiModelProperty(value = "点位名称")
private String name;
@ApiModelProperty(value = "点位Id")
private String factoryAttrId;
}

31
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/VideoRecordEntity.java

@ -0,0 +1,31 @@
package com.hnac.hzims.operational.station.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springblade.core.tenant.mp.TenantEntity;
/**
* @author ysj
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("hzims_station_video_record")
public class VideoRecordEntity extends TenantEntity {
@ApiModelProperty("站点ID")
private String stationId;
@ApiModelProperty("站点名称")
private String stationName;
@ApiModelProperty("视频保存配置ID,用逗号分割")
private String videoIds;
@ApiModelProperty("视频保存名称,用逗号分割")
private String videoNames;
}

38
hzims-service/equipment/src/main/java/com/hnac/hzims/history/controller/DeviceHistoryController.java

@ -3,8 +3,12 @@ package com.hnac.hzims.history.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.history.service.IHistoryDeviceService; import com.hnac.hzims.history.service.IHistoryDeviceService;
import com.hnac.hzims.history.vo.HistoryDataParamVo; import com.hnac.hzims.history.vo.HistoryDataParamVo;
import com.hnac.hzims.history.vo.HistoryDevicePointVo;
import com.hnac.hzims.history.vo.HistoryFactoryPointVo;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO;
import com.hnac.hzinfo.sdk.v5.hzfac.vo.FacDeviceAttrVO;
import com.hnac.hzinfo.sdk.v5.hzfac.vo.FacDeviceVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -29,24 +33,42 @@ public class DeviceHistoryController extends BladeController {
@GetMapping ("/device") @GetMapping ("/device")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
@ApiOperation(value = "查询项目设备列表", notes = "传入TrainEntity") @ApiOperation(value = "查询项目设备列表", notes = "传入projectId")
public R<List<DeviceInstanceVO>> device(@RequestParam(value="projectId") String projectId) { public R<List<DeviceInstanceVO>> device(@RequestParam(value="projectId") String projectId) {
return R.data(service.device(projectId)); return R.data(service.device(projectId));
} }
@GetMapping ("/device_point")
@GetMapping ("/monitor_point") @ApiOperationSupport(order = 2)
@ApiOperationSupport(order = 1) @ApiOperation(value = "设备监测点查询", notes = "传入projectId、deviceCode、deviceName、attrName")
@ApiOperation(value = "设备监测点查询", notes = "传入TrainEntity") public R<List<HistoryDevicePointVo>> device_point(@RequestParam(value="projectId",required = false) String projectId,
public R<List<DeviceInstanceAttrVO>> monitor_point(@RequestParam(value="projectId",required = false) String projectId,
@RequestParam(value="deviceCode",required = false) String deviceCode, @RequestParam(value="deviceCode",required = false) String deviceCode,
@RequestParam(value="deviceName",required = false) String deviceName, @RequestParam(value="deviceName",required = false) String deviceName,
@RequestParam(value="attrName",required = false) String attrName) { @RequestParam(value="attrName",required = false) String attrName) {
return R.data(service.monitor_point(projectId,deviceCode,deviceName,attrName)); return R.data(service.device_point(projectId,deviceCode,deviceName,attrName));
}
@GetMapping ("/factory")
@ApiOperationSupport(order = 3)
@ApiOperation(value = "查询项目厂组列表", notes = "传入projectId")
public R<List<FacDeviceVO>> factory(@RequestParam(value="projectId") String projectId) {
return R.data(service.factory(projectId));
} }
@GetMapping ("/factory_point")
@ApiOperationSupport(order = 4)
@ApiOperation(value = "查询厂组点位信息", notes = "传入TrainEntity")
public R<List<HistoryFactoryPointVo>> factory_point(@RequestParam(value = "projectId",required = false) String projectId,
@RequestParam(value = "facDeviceId",required = false) String facDeviceId,
@RequestParam(value="facDeviceName",required = false) String facDeviceName,
@RequestParam(value = "attrName",required = false) String attrName) {
return R.data(service.factory_point(projectId,facDeviceId,facDeviceName,attrName));
}
@PostMapping("/history_curve") @PostMapping("/history_curve")
@ApiOperationSupport(order = 5) @ApiOperationSupport(order = 3)
@ApiOperation(value = "设备历史数据曲线图", notes = "获取设备历史数据曲线图") @ApiOperation(value = "设备历史数据曲线图", notes = "获取设备历史数据曲线图")
public R<Map<String, Object>> historyCurve(@RequestBody HistoryDataParamVo param) { public R<Map<String, Object>> historyCurve(@RequestBody HistoryDataParamVo param) {
return R.data(service.historyCurve(param)); return R.data(service.historyCurve(param));

4
hzims-service/equipment/src/main/java/com/hnac/hzims/history/controller/HistoryTemplateController.java

@ -29,14 +29,14 @@ public class HistoryTemplateController extends BladeController {
@PostMapping("/save") @PostMapping("/save")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
@ApiOperation(value = "新增历史数据模板", notes = "传入TrainEntity") @ApiOperation(value = "新增历史数据模板", notes = "传入HistoryTemplateEntity")
public R save(@RequestBody HistoryTemplateEntity entity) { public R save(@RequestBody HistoryTemplateEntity entity) {
return R.status(service.save(entity)); return R.status(service.save(entity));
} }
@GetMapping("/pages") @GetMapping("/pages")
@ApiOperationSupport(order = 5) @ApiOperationSupport(order = 5)
@ApiOperation(value = "分页历史数据模板", notes = "查询条件:entity") @ApiOperation(value = "分页历史数据模板", notes = "查询条件:params、query")
public R<IPage<HistoryTemplateEntity>> pageCondition(HistoryTemplateParamVo params, Query query) { public R<IPage<HistoryTemplateEntity>> pageCondition(HistoryTemplateParamVo params, Query query) {
return R.data(service.pageCondition(params, Condition.getPage(query))); return R.data(service.pageCondition(params, Condition.getPage(query)));
} }

14
hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/IHistoryDeviceService.java

@ -1,8 +1,12 @@
package com.hnac.hzims.history.service; package com.hnac.hzims.history.service;
import com.hnac.hzims.history.vo.HistoryDataParamVo; import com.hnac.hzims.history.vo.HistoryDataParamVo;
import com.hnac.hzims.history.vo.HistoryDevicePointVo;
import com.hnac.hzims.history.vo.HistoryFactoryPointVo;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO;
import com.hnac.hzinfo.sdk.v5.hzfac.vo.FacDeviceAttrVO;
import com.hnac.hzinfo.sdk.v5.hzfac.vo.FacDeviceVO;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -14,7 +18,13 @@ public interface IHistoryDeviceService {
List<DeviceInstanceVO> device(String projectId); List<DeviceInstanceVO> device(String projectId);
List<DeviceInstanceAttrVO> monitor_point(String projectId,String deviceCode,String deviceName, String attrName); List<HistoryDevicePointVo> device_point(String projectId, String deviceCode, String deviceName, String attrName);
List<FacDeviceVO> factory(String projectId);
List<HistoryFactoryPointVo> factory_point(String projectId, String facDeviceId, String facDeviceName, String attrName);
Map<String, Object> historyCurve(HistoryDataParamVo param);
Map<String, Object> historyCurve(HistoryDataParamVo param);
} }

91
hzims-service/equipment/src/main/java/com/hnac/hzims/history/service/impl/HistoryDeviceServiceImpl.java

@ -2,11 +2,16 @@ package com.hnac.hzims.history.service.impl;
import com.hnac.hzims.history.service.IHistoryDeviceService; import com.hnac.hzims.history.service.IHistoryDeviceService;
import com.hnac.hzims.history.vo.HistoryDataParamVo; import com.hnac.hzims.history.vo.HistoryDataParamVo;
import com.hnac.hzims.history.vo.HistoryDevicePointVo;
import com.hnac.hzims.history.vo.HistoryFactoryPointVo;
import com.hnac.hzinfo.sdk.core.response.Result; import com.hnac.hzinfo.sdk.core.response.Result;
import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient;
import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO;
import com.hnac.hzinfo.sdk.v5.hzfac.HzFacClient;
import com.hnac.hzinfo.sdk.v5.hzfac.vo.FacDeviceAttrVO;
import com.hnac.hzinfo.sdk.v5.hzfac.vo.FacDeviceVO;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
@ -26,6 +31,7 @@ import java.util.stream.Collectors;
@AllArgsConstructor @AllArgsConstructor
public class HistoryDeviceServiceImpl implements IHistoryDeviceService { public class HistoryDeviceServiceImpl implements IHistoryDeviceService {
private final HzFacClient hzFacClient;
private final DeviceClient deviceClient; private final DeviceClient deviceClient;
@ -52,8 +58,8 @@ public class HistoryDeviceServiceImpl implements IHistoryDeviceService {
* @return * @return
*/ */
@Override @Override
public List<DeviceInstanceAttrVO> monitor_point(String projectId,String deviceCode,String deviceName, String attrName) { public List<HistoryDevicePointVo> device_point(String projectId,String deviceCode,String deviceName, String attrName) {
List<DeviceInstanceAttrVO> result = new ArrayList<>(); List<HistoryDevicePointVo> result = new ArrayList<>();
// 查询所有 // 查询所有
if(StringUtil.isEmpty(deviceCode)){ if(StringUtil.isEmpty(deviceCode)){
R<List<DeviceInstanceVO>> instances = deviceClient.getOnlineDeviceInstanceSearchName(projectId,""); R<List<DeviceInstanceVO>> instances = deviceClient.getOnlineDeviceInstanceSearchName(projectId,"");
@ -65,22 +71,93 @@ public class HistoryDeviceServiceImpl implements IHistoryDeviceService {
if(!attrs.isSuccess() || CollectionUtil.isEmpty(attrs.getData())){ if(!attrs.isSuccess() || CollectionUtil.isEmpty(attrs.getData())){
return; return;
} }
result.addAll(attrs.getData().stream().filter(o-> StringUtil.isNotBlank(o.getFacDeviceAttrId())).peek(attr->{ result.addAll(attrs.getData().stream().filter(o-> StringUtil.isNotBlank(o.getSignage())).map(attr->{
attr.setName(instance.getName() + "-" + attr.getName()); HistoryDevicePointVo point = new HistoryDevicePointVo();
point.setDeviceCode(instance.getCode());
point.setName(instance.getName() + "-" + attr.getName());
point.setSignage(attr.getSignage());
return point;
}).collect(Collectors.toList())); }).collect(Collectors.toList()));
}); });
return result;
} }
// 根据设备查询 // 根据设备查询
Result<List<DeviceInstanceAttrVO>> attrs = deviceClient.getDeviceAttrByName(deviceCode,attrName); Result<List<DeviceInstanceAttrVO>> attrs = deviceClient.getDeviceAttrByName(deviceCode,attrName);
if(!attrs.isSuccess() || CollectionUtil.isEmpty(attrs.getData())){ if(!attrs.isSuccess() || CollectionUtil.isEmpty(attrs.getData())){
return result; return result;
} }
return attrs.getData().stream().filter(o-> StringUtil.isNotBlank(o.getFacDeviceAttrId())).peek(attr->{ return attrs.getData().stream().filter(o-> StringUtil.isNotBlank(o.getSignage())).map(attr->{
attr.setName(deviceName + "-" + attr.getName()); HistoryDevicePointVo point = new HistoryDevicePointVo();
point.setDeviceCode(deviceCode);
point.setName(deviceName + "-" + attr.getName());
point.setSignage(attr.getSignage());
return point;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
/** /**
* 项目厂组列表
* @param projectId
* @return
*/
@Override
public List<FacDeviceVO> factory(String projectId) {
Result<List<FacDeviceVO>> result = hzFacClient.facDeviceByProjectId(projectId,"");
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return new ArrayList<>();
}
return result.getData();
}
/**
* 厂租点位列表
* @param projectId
* @param facDeviceId
* @param facDeviceName
* @param attrName
* @return
*/
@Override
public List<HistoryFactoryPointVo> factory_point(String projectId, String facDeviceId, String facDeviceName, String attrName) {
List<HistoryFactoryPointVo> result = new ArrayList<>();
// 查询所有
if(StringUtil.isEmpty(facDeviceId)){
Result<List<FacDeviceVO>> instances = hzFacClient.facDeviceByProjectId(projectId,attrName);
if(!instances.isSuccess() || CollectionUtil.isEmpty(instances.getData())){
return new ArrayList<>();
}
instances.getData().stream().sorted(Comparator.comparing(FacDeviceVO::getName)).forEach(instance->{
Result<List<FacDeviceAttrVO>> attrs = hzFacClient.facDeviceAttrList(facDeviceId,attrName);
if(!attrs.isSuccess() || CollectionUtil.isEmpty(attrs.getData())){
return;
}
result.addAll(attrs.getData().stream().filter(o-> StringUtil.isNotBlank(o.getSignage())).map(attr->{
HistoryFactoryPointVo point = new HistoryFactoryPointVo();
point.setFactoryId(instance.getId());
point.setName(attr.getName());
point.setFactoryAttrId(attr.getId());
return point;
}).collect(Collectors.toList()));
});
return result;
}
Result<List<FacDeviceAttrVO>> attrs = hzFacClient.facDeviceAttrList(facDeviceId,attrName);
if(!attrs.isSuccess() || CollectionUtil.isEmpty(attrs.getData())){
return new ArrayList<>();
}
return attrs.getData().stream().filter(o-> StringUtil.isNotBlank(o.getSignage())).map(attr->{
HistoryFactoryPointVo point = new HistoryFactoryPointVo();
point.setFactoryId(facDeviceId);
point.setName(attr.getName());
point.setFactoryAttrId(attr.getId());
return point;
}).collect(Collectors.toList());
}
/**
* 设备历史数据曲线图 * 设备历史数据曲线图
* @param param * @param param
* @return * @return
@ -99,7 +176,7 @@ public class HistoryDeviceServiceImpl implements IHistoryDeviceService {
param.getStartTime(), param.getStartTime(),
param.getEndTime(), param.getEndTime(),
// 默认查询设备 : 0-厂组点, 1-设备 // 默认查询设备 : 0-厂组点, 1-设备
1, 0,
intervalType, intervalType,
param.getIsPage(), param.getIsPage(),
param.getCurrent(), param.getCurrent(),

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/config/ZhipuAiConfig.java

@ -6,8 +6,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import javax.annotation.Resource;
/** /**
* @Author: ypj * @Author: ypj
* @Date: 2024/8/9 17:01 * @Date: 2024/8/9 17:01

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/config/ZhipuAiConfigProperties.java

@ -2,8 +2,6 @@ package com.hnac.hzims.bigmodel.zhipuai.config;
import lombok.Data; import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;
/** /**
* @Author: ypj * @Author: ypj

32
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/AnalysisResultType.java

@ -1,32 +0,0 @@
package com.hnac.hzims.bigmodel.zhipuai.constants;
import lombok.Getter;
import org.apache.poi.ss.formula.functions.T;
import java.math.BigDecimal;
/**
* @Author: ypj
* @Date: 2024/8/8 15:27
*/
@Getter
public enum AnalysisResultType implements BaseEnum {
BOOLEAN("BOOLEAN", "是非判断", "是", Boolean.class),
NUMBER("NUMBER", "确定数量", null, Integer.class),
DECIMAL("DECIMAL", "获取数值", null, BigDecimal.class);
private final String code;
private final String msg;
private final String condition;
private final Class<T> clazz;
AnalysisResultType(String code, String msg, String condition, Class clazz) {
this.code = code;
this.msg = msg;
this.condition = condition;
this.clazz = clazz;
}
}

22
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ComparisonType.java

@ -0,0 +1,22 @@
package com.hnac.hzims.bigmodel.zhipuai.constants;
import lombok.Getter;
/**
* @Author: ypj
* @Date: 2024/8/14 9:23
*/
@Getter
public enum ComparisonType implements BaseEnum {
EQUAL("equal", "相等"),
GREATER("greater","大于"),
LESS("less","小于");
private final String code;
private final String msg;
ComparisonType(String code, String msg) {
this.code = code;
this.msg = msg;
}
}

31
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultDataType.java

@ -0,0 +1,31 @@
package com.hnac.hzims.bigmodel.zhipuai.constants;
import lombok.Getter;
/**
* @Author: ypj
* @Date: 2024/8/14 8:28
*/
@Getter
public enum ResultDataType implements BaseEnum {
OBJECT("Object", "Object类型", Object.class.getName(), null),
STRING("String", "String类型", String.class.getName(), null),
BOOLEAN("Boolean","Boolean类型",Boolean.class.getName(),"parseBoolean"),
INTEGER("Integer","Integer类型",Integer.class.getName(),"parseInt");
private final String code;
private final String msg;
private final String className;
private final String method;
ResultDataType(String code, String msg, String className, String method) {
this.code = code;
this.msg = msg;
this.className = className;
this.method = method;
}
}

39
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/constants/ResultStrategyType.java

@ -0,0 +1,39 @@
package com.hnac.hzims.bigmodel.zhipuai.constants;
import com.hnac.hzims.bigmodel.zhipuai.handler.ResultBooleanStrategy;
import com.hnac.hzims.bigmodel.zhipuai.handler.ResultCommonStrategy;
import com.hnac.hzims.bigmodel.zhipuai.handler.ResultStrategy;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
/**
* @Author: ypj
* @Date: 2024/8/8 15:27
*/
@Getter
@Slf4j
public enum ResultStrategyType implements BaseEnum {
COMMON("ResultCommonStrategy", "普通值", ResultCommonStrategy.class),
BOOLEAN("ResultBooleanStrategy", "是非判断", ResultBooleanStrategy.class);
private final String code;
private final String msg;
private final Class<? extends ResultStrategy> strategyClass;
ResultStrategyType(String code, String msg, Class<? extends ResultStrategy> strategy) {
this.code = code;
this.msg = msg;
this.strategyClass = strategy;
}
public ResultStrategy getStrategy() {
try {
return strategyClass.newInstance();
} catch (Exception e) {
log.error("get result strategy fail", e);
}
return null;
}
}

22
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/controller/ZhipuAnalysisInfoController.java

@ -1,12 +1,16 @@
package com.hnac.hzims.bigmodel.zhipuai.controller; package com.hnac.hzims.bigmodel.zhipuai.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisInfoService; import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisInfoService;
import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisInfoVO; import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisInfoVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor; 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.api.R;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -33,7 +37,21 @@ public class ZhipuAnalysisInfoController {
@GetMapping("/remove") @GetMapping("/remove")
@ApiOperation("批量删除智谱分析信息") @ApiOperation("批量删除智谱分析信息")
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
public R<Boolean> remove (@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { public R<Boolean> remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) {
return R.status(analysisInfoService.removeByIds(Func.toLongList(",",ids))); return R.status(analysisInfoService.removeByIds(Func.toLongList(",", ids)));
}
@GetMapping("/selectPage")
@ApiOperation("分页查询智谱分析配置信息")
@ApiOperationSupport(order = 3)
public R<IPage<ZhipuAnalysisInfoEntity>> selectPage(Query query, ZhipuAnalysisInfoEntity requestData) {
return R.data(analysisInfoService.page(Condition.getPage(query), Condition.getQueryWrapper(new ZhipuAnalysisInfoEntity(), requestData)));
}
@PutMapping("/update")
@ApiOperation("更新智谱分析配置信息")
@ApiOperationSupport(order = 4)
public R<Boolean> update(@RequestBody @Validated ZhipuAnalysisInfoEntity requestData) {
return R.status(analysisInfoService.updateById(requestData));
} }
} }

8
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java

@ -1,5 +1,6 @@
package com.hnac.hzims.bigmodel.zhipuai.entity; package com.hnac.hzims.bigmodel.zhipuai.entity;
import com.baomidou.mybatisplus.annotation.SqlCondition;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
@ -7,16 +8,18 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity; import org.springblade.core.mp.base.BaseEntity;
import org.springblade.core.mp.support.QueryField;
import org.springblade.core.tenant.mp.TenantEntity;
/** /**
* @Author: ypj * @Author: ypj
* @Date: 2024/8/8 15:17 * @Date: 2024/8/8 15:17
*/ */
@ApiModel(value ="大模型分析信息") @ApiModel(value = "大模型分析信息")
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@TableName("hzims_analysis_info") @TableName("hzims_analysis_info")
public class ZhipuAnalysisInfoEntity extends BaseEntity { public class ZhipuAnalysisInfoEntity extends TenantEntity {
@ApiModelProperty(value = "策略编码") @ApiModelProperty(value = "策略编码")
@TableField("CODE") @TableField("CODE")
@ -24,6 +27,7 @@ public class ZhipuAnalysisInfoEntity extends BaseEntity {
@ApiModelProperty(value = "策略名称") @ApiModelProperty(value = "策略名称")
@TableField("NAME") @TableField("NAME")
@QueryField(condition = SqlCondition.LIKE)
private String name; private String name;
@ApiModelProperty(value = "调用模型名称") @ApiModelProperty(value = "调用模型名称")

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/AbstractZhipuAnalysisHandler.java

@ -3,7 +3,6 @@ package com.hnac.hzims.bigmodel.zhipuai.handler;
import com.zhipu.oapi.ClientV4; import com.zhipu.oapi.ClientV4;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Base64;
/** /**
* @Author: ypj * @Author: ypj
@ -11,7 +10,6 @@ import java.util.Base64;
*/ */
public abstract class AbstractZhipuAnalysisHandler implements ZhipuAnalyser { public abstract class AbstractZhipuAnalysisHandler implements ZhipuAnalyser {
protected final String requestIdTemplate = "big_model-%d"; protected final String requestIdTemplate = "big_model-%d";
protected final String resultKey = "结果";
@Resource @Resource
protected ClientV4 client; protected ClientV4 client;

40
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultBooleanStrategy.java

@ -0,0 +1,40 @@
package com.hnac.hzims.bigmodel.zhipuai.handler;
import com.hnac.hzims.bigmodel.zhipuai.constants.BaseEnum;
import com.hnac.hzims.bigmodel.zhipuai.constants.ComparisonType;
import com.hnac.hzims.bigmodel.zhipuai.constants.ResultStrategyType;
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
import com.hnac.hzinfo.exception.HzServiceException;
import org.springframework.util.Assert;
import java.util.Objects;
/**
* @Author: ypj
* @Date: 2024/8/14 7:41
*/
public class ResultBooleanStrategy implements ResultStrategy<Boolean> {
@Override
public String getCode() {
return ResultStrategyType.BOOLEAN.getCode();
}
@Override
public Boolean getResult(ZhipuAnalysisInfoEntity info, Object resultData) {
Object comparator = convertOriginalData(info.getResultCondition(), info.getResultType());
Assert.isTrue(Objects.nonNull(comparator), () -> {
throw new HzServiceException("没有获取到对比对象");
});
ComparisonType comparisonType = BaseEnum.getInstance(info.getResultJudgeModel(), ComparisonType.class);
switch (comparisonType) {
case EQUAL:
return comparator.equals(resultData);
case GREATER:
return ((Comparable) comparator).compareTo(resultData) < 0;
case LESS:
return ((Comparable) comparator).compareTo(resultData) > 0;
}
return null;
}
}

22
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultCommonStrategy.java

@ -0,0 +1,22 @@
package com.hnac.hzims.bigmodel.zhipuai.handler;
import com.hnac.hzims.bigmodel.zhipuai.constants.ResultStrategyType;
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
/**
* @Author: ypj
* @Date: 2024/8/13 10:33
*/
public class ResultCommonStrategy implements ResultStrategy<Object> {
@Override
public String getCode() {
return ResultStrategyType.COMMON.getCode();
}
@Override
public Object getResult(ZhipuAnalysisInfoEntity info, Object data) {
return data;
}
}

44
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ResultStrategy.java

@ -0,0 +1,44 @@
package com.hnac.hzims.bigmodel.zhipuai.handler;
import com.hnac.hzims.bigmodel.zhipuai.constants.BaseEnum;
import com.hnac.hzims.bigmodel.zhipuai.constants.ResultDataType;
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.core.tool.utils.StringUtil;
import java.lang.reflect.Method;
/**
* @Author: ypj
* @Date: 2024/8/13 10:00
*/
public interface ResultStrategy<T> {
String getCode();
default boolean isSupport(String strategyCode) {
return getCode().equals(strategyCode);
}
default Object convertOriginalData(String originalData, String className) {
ResultDataType type = BaseEnum.getInstance(className, ResultDataType.class);
if (null != type && StringUtil.isNotBlank(type.getMethod())) {
try {
Class<?> clazz = Class.forName(type.getClassName());
Method method = clazz.getMethod(type.getMethod(), String.class);
return method.invoke(null, originalData);
} catch (Exception ignore) {
Logger logger = LoggerFactory.getLogger(ResultStrategy.class);
logger.info("parse data error", ignore);
}
}
return originalData;
}
default T getResult(ZhipuAnalysisInfoEntity info, String originalData) {
return getResult(info, convertOriginalData(originalData, info.getResultType()));
}
T getResult(ZhipuAnalysisInfoEntity info, Object resultData);
}

12
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalyser.java

@ -1,6 +1,9 @@
package com.hnac.hzims.bigmodel.zhipuai.handler; package com.hnac.hzims.bigmodel.zhipuai.handler;
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
import org.springblade.core.tool.jackson.JsonUtil;
import java.util.Map;
/** /**
* @Author: ypj * @Author: ypj
@ -12,8 +15,8 @@ public interface ZhipuAnalyser<Req, Resp> {
String getAnalysisModel(); String getAnalysisModel();
default boolean isSupport(String modelName) { default boolean isSupport(String strategyCode) {
return getAnalysisStrategy().equals(modelName); return getAnalysisStrategy().equals(strategyCode);
} }
Resp sendRequest(ZhipuAnalysisInfoEntity info, String url); Resp sendRequest(ZhipuAnalysisInfoEntity info, String url);
@ -21,4 +24,9 @@ public interface ZhipuAnalyser<Req, Resp> {
Req getRequest(ZhipuAnalysisInfoEntity info, String url); Req getRequest(ZhipuAnalysisInfoEntity info, String url);
String getResult(ZhipuAnalysisInfoEntity info, String url); String getResult(ZhipuAnalysisInfoEntity info, String url);
default Object getResultValue(ZhipuAnalysisInfoEntity info, String url) {
Map<String, Object> resultMap = JsonUtil.toMap(getResult(info, url));
return resultMap.get(info.getResultKey());
}
} }

19
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java

@ -1,6 +1,5 @@
package com.hnac.hzims.bigmodel.zhipuai.handler; package com.hnac.hzims.bigmodel.zhipuai.handler;
import com.hnac.hzims.bigmodel.zhipuai.constants.AnalysisModel;
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
import com.zhipu.oapi.Constants; import com.zhipu.oapi.Constants;
import com.zhipu.oapi.service.v4.model.ChatCompletionRequest; import com.zhipu.oapi.service.v4.model.ChatCompletionRequest;
@ -36,7 +35,7 @@ public class ZhipuAnalysisHandlerGlm4v extends AbstractZhipuAnalysisHandler {
@Override @Override
public ModelApiResponse sendRequest(ZhipuAnalysisInfoEntity info, String url) { public ModelApiResponse sendRequest(ZhipuAnalysisInfoEntity info, String url) {
ChatCompletionRequest request = getRequest(info, url); ChatCompletionRequest request = getRequest(info, url);
log.info("send zhipu ai request :{}", Optional.ofNullable(request).map(i -> JsonUtil.toJson(i)).orElse("null")); log.info("send zhipu ai request :{}", Optional.ofNullable(request).map(req -> JsonUtil.toJson(req)).orElse("null"));
return client.invokeModelApi(request); return client.invokeModelApi(request);
} }
@ -71,15 +70,17 @@ public class ZhipuAnalysisHandlerGlm4v extends AbstractZhipuAnalysisHandler {
@Override @Override
public String getResult(ZhipuAnalysisInfoEntity info, String url) { public String getResult(ZhipuAnalysisInfoEntity info, String url) {
ModelApiResponse response = sendRequest(info, url); ModelApiResponse response = sendRequest(info, url);
log.info("get zhi pu ai response : {}", Optional.ofNullable(response).map(r -> JsonUtil.toJson(r)).orElse("null")); log.info("get zhi pu ai response : {}", Optional.ofNullable(response).map(resp -> JsonUtil.toJson(resp)).orElse("null"));
if (response.isSuccess()) { if (response.isSuccess()) {
String resultJson = response.getData().getChoices().get(0).getMessage().getContent().toString(); try {
resultJson = resultJson.substring(resultJson.indexOf("{"), resultJson.indexOf("}") + 1).trim(); String resultJson = response.getData().getChoices().get(0).getMessage().getContent().toString();
Map<String, Object> resultMap = JsonUtil.toMap(resultJson); resultJson = resultJson.substring(resultJson.indexOf("{"), resultJson.lastIndexOf("}") + 1).trim();
return resultMap.get(resultKey).toString(); return resultJson;
} else { } catch (Exception e) {
return "访问失败"; log.info("get data from response error", e);
}
} }
return null;
} }
} }

4
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/mapper/ZhipuAnalysisInfoMapper.java

@ -1,11 +1,11 @@
package com.hnac.hzims.bigmodel.zhipuai.mapper; package com.hnac.hzims.bigmodel.zhipuai.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
/** /**
* @Author: ypj * @Author: ypj
* @Date: 2024/8/12 20:05 * @Date: 2024/8/12 20:05
*/ */
public interface ZhipuAnalysisInfoMapper extends BaseMapper<ZhipuAnalysisInfoEntity> { public interface ZhipuAnalysisInfoMapper extends UserDataScopeBaseMapper<ZhipuAnalysisInfoEntity> {
} }

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/ZhipuAnalysisInfoService.java

@ -1,7 +1,9 @@
package com.hnac.hzims.bigmodel.zhipuai.service; package com.hnac.hzims.bigmodel.zhipuai.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
import org.springblade.core.mp.support.Query;
/** /**
* @Author: ypj * @Author: ypj

1
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisInfoServiceImpl.java

@ -12,4 +12,5 @@ import org.springframework.stereotype.Service;
*/ */
@Service @Service
public class ZhipuAnalysisInfoServiceImpl extends ServiceImpl<ZhipuAnalysisInfoMapper, ZhipuAnalysisInfoEntity> implements ZhipuAnalysisInfoService { public class ZhipuAnalysisInfoServiceImpl extends ServiceImpl<ZhipuAnalysisInfoMapper, ZhipuAnalysisInfoEntity> implements ZhipuAnalysisInfoService {
} }

27
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java

@ -1,7 +1,10 @@
package com.hnac.hzims.bigmodel.zhipuai.service.impl; package com.hnac.hzims.bigmodel.zhipuai.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.bigmodel.zhipuai.constants.BaseEnum;
import com.hnac.hzims.bigmodel.zhipuai.constants.ResultStrategyType;
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
import com.hnac.hzims.bigmodel.zhipuai.handler.ResultStrategy;
import com.hnac.hzims.bigmodel.zhipuai.handler.ZhipuAnalyser; import com.hnac.hzims.bigmodel.zhipuai.handler.ZhipuAnalyser;
import com.hnac.hzims.bigmodel.zhipuai.handler.ZhipuAnalysisFactory; import com.hnac.hzims.bigmodel.zhipuai.handler.ZhipuAnalysisFactory;
import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisInfoService; import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisInfoService;
@ -17,6 +20,7 @@ import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import java.util.Objects;
import java.util.Optional; import java.util.Optional;
/** /**
@ -37,12 +41,31 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService {
Assert.isTrue(StringUtil.isNotBlank(request.getFilePath()) || StringUtil.isNotBlank(request.getUrl()), () -> { Assert.isTrue(StringUtil.isNotBlank(request.getFilePath()) || StringUtil.isNotBlank(request.getUrl()), () -> {
throw new HzServiceException("文件为空"); throw new HzServiceException("文件为空");
}); });
ZhipuAnalysisFileResponse response = new ZhipuAnalysisFileResponse();
ZhipuAnalysisInfoEntity info = getAnalysisInfo(request); ZhipuAnalysisInfoEntity info = getAnalysisInfo(request);
Assert.isTrue(Objects.nonNull(info), () -> {
throw new HzServiceException("没有找到对应的策略信息");
});
ZhipuAnalyser analyser = analysisFactory.getAnalysisStrategy(info.getModel()); ZhipuAnalyser analyser = analysisFactory.getAnalysisStrategy(info.getModel());
Object resultObject = analyser.getResultValue(info, getSendUrl(request));
Assert.isTrue(Objects.nonNull(resultObject), () -> {
throw new HzServiceException("智谱平台分析失败");
});
String resultStr = resultObject.toString();
ResultStrategyType strategyType = BaseEnum.getInstance(info.getResultStrategy(), ResultStrategyType.class);
Assert.isTrue(Objects.nonNull(strategyType), () -> {
throw new HzServiceException("没有找到对应的结果数据解析策略");
});
ResultStrategy strategy = strategyType.getStrategy();
Object resultValue = strategy.convertOriginalData(resultStr, info.getResultType());
Object conclusion = strategy.getResult(info, resultValue);
String resultStr = analyser.getResult(info, getSendUrl(request));
ZhipuAnalysisFileResponse response = new ZhipuAnalysisFileResponse();
response.setResultStr(resultStr); response.setResultStr(resultStr);
response.setResult(conclusion);
return response; return response;
} }

7
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisFileResponse.java

@ -1,7 +1,6 @@
package com.hnac.hzims.bigmodel.zhipuai.vo; package com.hnac.hzims.bigmodel.zhipuai.vo;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
/** /**
@ -9,9 +8,7 @@ import lombok.Data;
* @Date: 2024/8/12 10:23 * @Date: 2024/8/12 10:23
*/ */
@Data @Data
@ApiModel(value = "智谱分析返回",description = "智谱分析返回") @ApiModel(value = "智谱分析返回", description = "智谱分析返回")
public class ZhipuAnalysisFileResponse { public class ZhipuAnalysisFileResponse<T> extends ZhipuAnalysisResult {
@ApiModelProperty("返回结果")
String resultStr;
} }

3
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisInfoVO.java

@ -9,6 +9,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.BeanUtil;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@ -20,7 +21,7 @@ import javax.validation.constraints.NotNull;
@ApiModel(value = "大模型分析信息") @ApiModel(value = "大模型分析信息")
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
public class ZhipuAnalysisInfoVO { public class ZhipuAnalysisInfoVO extends TenantEntity {
@JsonSerialize(using = ToStringSerializer.class) @JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty(value = "主键id") @ApiModelProperty(value = "主键id")
@TableId(value = "id", type = IdType.ASSIGN_ID) @TableId(value = "id", type = IdType.ASSIGN_ID)

32
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisResult.java

@ -0,0 +1,32 @@
package com.hnac.hzims.bigmodel.zhipuai.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Optional;
/**
* @Author: ypj
* @Date: 2024/8/13 16:18
*/
@Data
@ApiModel(description = "分析返回信息")
public class ZhipuAnalysisResult<T> implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "是否成功", required = true)
private Boolean success = null;
@ApiModelProperty(value = "承载数据")
private T result;
@ApiModelProperty(value = "结果描述")
private String resultStr;
public Boolean getSuccess() {
return Optional.ofNullable(success).orElse(null != result);
}
}

1
hzims-service/operational/src/main/java/com/hnac/hzims/operational/history/controller/HistoryController.java

@ -58,6 +58,7 @@ public class HistoryController extends BladeController {
@RequestParam(value = "attrName",required = false) String attrName) { @RequestParam(value = "attrName",required = false) String attrName) {
return R.data(pointService.projectFacDeviceAttr(facDeviceId,attrName)); return R.data(pointService.projectFacDeviceAttr(facDeviceId,attrName));
} }
@GetMapping("/projectDeviceInstance") @GetMapping("/projectDeviceInstance")
@ApiOperationSupport(order = 3) @ApiOperationSupport(order = 3)
@ApiOperation(value = "站点虚拟设备息", notes = "根据站点id查询虚拟设备") @ApiOperation(value = "站点虚拟设备息", notes = "根据站点id查询虚拟设备")

47
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoRecordController.java

@ -0,0 +1,47 @@
package com.hnac.hzims.operational.station.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.station.entity.VideoRecordEntity;
import com.hnac.hzims.operational.station.service.VideoRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
/**
* @author ysj
*/
@RestController
@RequestMapping("/station/videoRecord")
@RequiredArgsConstructor
@Api(value = "站点视频播放保存记录", tags = "视频播放保存记录")
public class StationVideoRecordController extends BladeController {
private final VideoRecordService videoRecordService;
@PostMapping("/submit")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "新增或修改站点视频播放保存记录", notes = "传入VideoRecordEntity")
public R submit(@Valid @RequestBody VideoRecordEntity entity) {
return R.status(videoRecordService.saveOrUpdate(entity));
}
@GetMapping("/query")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "查询站点视频播放保存记录", notes = "传入VideoRecordEntity")
public R query(@RequestParam("stationId") String stationId,
@RequestParam("userId") String userId) {
return R.data(videoRecordService.getOne(Wrappers.<VideoRecordEntity>lambdaQuery()
.eq(VideoRecordEntity::getStationId,stationId)
.eq(VideoRecordEntity::getCreateUser,userId)
));
}
}

12
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/VideoRecordMapper.java

@ -0,0 +1,12 @@
package com.hnac.hzims.operational.station.mapper;
import com.hnac.hzims.operational.station.entity.VideoRecordEntity;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
/**
* @author ysj
*/
public interface VideoRecordMapper extends UserDataScopeBaseMapper<VideoRecordEntity> {
}

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/VideoRecordMapper.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.operational.station.mapper.VideoRecordMapper">
</mapper>

10
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/VideoRecordService.java

@ -0,0 +1,10 @@
package com.hnac.hzims.operational.station.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.operational.station.entity.VideoRecordEntity;
/**
* @author ysj
*/
public interface VideoRecordService extends IService<VideoRecordEntity> {
}

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

@ -0,0 +1,19 @@
package com.hnac.hzims.operational.station.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.operational.station.entity.VideoRecordEntity;
import com.hnac.hzims.operational.station.mapper.VideoRecordMapper;
import com.hnac.hzims.operational.station.service.VideoRecordService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* @author 86187
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class VideoRecordServiceImpl extends ServiceImpl<VideoRecordMapper, VideoRecordEntity> implements VideoRecordService {
}
Loading…
Cancel
Save