haungxing
3 months ago
35 changed files with 618 additions and 84 deletions
@ -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; |
||||
} |
@ -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; |
||||
} |
@ -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; |
||||
} |
@ -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; |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
|
||||
} |
@ -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; |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
|
||||
} |
@ -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; |
||||
} |
||||
|
||||
} |
@ -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); |
||||
} |
@ -1,11 +1,11 @@
|
||||
package com.hnac.hzims.bigmodel.zhipuai.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; |
||||
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; |
||||
|
||||
/** |
||||
* @Author: ypj |
||||
* @Date: 2024/8/12 20:05 |
||||
*/ |
||||
public interface ZhipuAnalysisInfoMapper extends BaseMapper<ZhipuAnalysisInfoEntity> { |
||||
public interface ZhipuAnalysisInfoMapper extends UserDataScopeBaseMapper<ZhipuAnalysisInfoEntity> { |
||||
} |
||||
|
@ -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); |
||||
} |
||||
} |
@ -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) |
||||
)); |
||||
} |
||||
|
||||
|
||||
} |
@ -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> { |
||||
|
||||
} |
@ -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> |
@ -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> { |
||||
} |
@ -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…
Reference in new issue