龚焕茏
2024-07-09 577107bf478b4d2fb7da1b7b0d9f0f87fef5b2be
feat:封装优云接口
4个文件已修改
3个文件已添加
1 文件已复制
4 文件已重命名
221 ■■■■ 已修改文件
pom.xml 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-pojo/src/main/java/com/ycl/platform/domain/param/CameraParam.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-pojo/src/main/java/com/ycl/platform/domain/param/OnlineParam.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-pojo/src/main/java/com/ycl/platform/domain/param/RecordMetaDSumParam.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-pojo/src/main/java/com/ycl/platform/domain/result/CameraResult.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-pojo/src/main/java/com/ycl/platform/domain/result/OnlineResult.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-pojo/src/main/java/com/ycl/platform/domain/result/OsdMonitorResult.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-pojo/src/main/java/com/ycl/platform/domain/result/RecordMetaDSumResult.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/java/com/ycl/PlatformApplication.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/java/com/ycl/task/CheckScoreTask.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/java/com/ycl/web/UYClient.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ycl-server/src/main/resources/mapper/zgyw/CheckScoreMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml
@@ -252,6 +252,14 @@
            <artifactId>easyexcel</artifactId>
            <version>${easyexcel.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
            <version>${spring-boot.version}</version>
        </dependency>
    </dependencies>
    <build>
ycl-pojo/src/main/java/com/ycl/platform/domain/param/CameraParam.java
New file
@@ -0,0 +1,29 @@
package com.ycl.platform.domain.param;
import lombok.Data;
import lombok.experimental.Accessors;
/**
 * 摄像头参数
 *
 * @author gonghl
 * @since 2024/7/1 下午 4:52
 */
@Data
@Accessors(chain = true)
public class CameraParam {
    /**
     * 分页
     */
    private String offset;
    private String limit;
    /**
     * 摄像机国标编码
     */
    private String code;
}
ycl-pojo/src/main/java/com/ycl/platform/domain/param/OnlineParam.java
New file
@@ -0,0 +1,34 @@
package com.ycl.platform.domain.param;
import lombok.Data;
import lombok.experimental.Accessors;
/**
 * 点位在线参数
 *
 * @author gonghl
 * @since 2024/7/1 下午 4:52
 */
@Data
@Accessors(chain = true)
public class OnlineParam {
    /**
     * 行政区域编码
     */
    private String arealayerno;
    private Object[] dbConditionItems;
    /**
     * 动态条件,json 格式
     */
    private String dynamicConditionJson;
    /**
     * 排序字段
     */
    private String sortFiled;
}
ycl-pojo/src/main/java/com/ycl/platform/domain/param/RecordMetaDSumParam.java
copy from ycl-pojo/src/main/java/com/ycl/platform/domain/dto/VideoAvailabilityDTO.java copy to ycl-pojo/src/main/java/com/ycl/platform/domain/param/RecordMetaDSumParam.java
File was copied from ycl-pojo/src/main/java/com/ycl/platform/domain/dto/VideoAvailabilityDTO.java
@@ -1,14 +1,20 @@
package com.ycl.platform.domain.dto;
package com.ycl.platform.domain.param;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
 * 录像可用性
 * 录像可用参数
 *
 * @author gonghl
 * @since 2024/7/2 上午 11:38
 */
@Data
public class VideoAvailabilityDTO {
@Accessors(chain = true)
public class RecordMetaDSumParam {
    /**
     * 行政区域名称
@@ -21,7 +27,7 @@
    private String arealayerno;
    /**
     * 创建时间,格式为日期时间字符串
     * 创建时间
     */
    private Date createTime;
@@ -41,7 +47,7 @@
    private String id;
    /**
     * 缺失时长,数值类型为双精度浮点数
     * 缺失时长
     */
    private Double missDuration;
@@ -51,17 +57,17 @@
    private String platId;
    /**
     * 录像时长,数值类型为双精度浮点数
     * 录像时长
     */
    private Double recordDuration;
    /**
     * 录像完整状态,1:完整,0:间歇,-1:异常
     * 录像完整状态 1:完整 0:间歇 -1:异常
     */
    private Integer recordStatus;
    /**
     * 统计时间,格式为日期字符串
     * 统计时间
     */
    private Date statTime;
@@ -70,4 +76,5 @@
     */
    private String tenantId;
}
}
ycl-pojo/src/main/java/com/ycl/platform/domain/result/CameraResult.java
File was renamed from ycl-pojo/src/main/java/com/ycl/platform/domain/dto/DeviceInfoDTO.java
@@ -1,4 +1,4 @@
package com.ycl.platform.domain.dto;
package com.ycl.platform.domain.result;
import lombok.Data;
@@ -11,7 +11,7 @@
 * @since 2024-4-19 11:33:34
 */
@Data
public class DeviceInfoDTO {
public class CameraResult {
    /**
     * 设备编码,20位:中心编码、行业编码、设备类型、网络标识、设备序号,与联网平台/共享平台国标编码一致。
ycl-pojo/src/main/java/com/ycl/platform/domain/result/OnlineResult.java
File was renamed from ycl-pojo/src/main/java/com/ycl/platform/domain/dto/OnlineStatisticsDTO.java
@@ -1,4 +1,4 @@
package com.ycl.platform.domain.dto;
package com.ycl.platform.domain.result;
import lombok.Data;
@@ -9,8 +9,7 @@
 * @since 2024-4-19 11:37:30
 */
@Data
public class OnlineStatisticsDTO {
public class OnlineResult {
    /**
     * 行政区划编码
ycl-pojo/src/main/java/com/ycl/platform/domain/result/OsdMonitorResult.java
File was renamed from ycl-pojo/src/main/java/com/ycl/platform/domain/dto/VideoAnnotationDTO.java
@@ -1,4 +1,4 @@
package com.ycl.platform.domain.dto;
package com.ycl.platform.domain.result;
import lombok.Data;
@@ -11,7 +11,7 @@
 * @since 2024-4-19 11:52:09
 */
@Data
public class VideoAnnotationDTO {
public class OsdMonitorResult {
    /**
     * 区域路径信息
ycl-pojo/src/main/java/com/ycl/platform/domain/result/RecordMetaDSumResult.java
File was renamed from ycl-pojo/src/main/java/com/ycl/platform/domain/dto/VideoAvailabilityDTO.java
@@ -1,4 +1,4 @@
package com.ycl.platform.domain.dto;
package com.ycl.platform.domain.result;
import lombok.Data;
@@ -6,9 +6,10 @@
/**
 * 录像可用性
 * @author gonghl
 */
@Data
public class VideoAvailabilityDTO {
public class RecordMetaDSumResult {
    /**
     * 行政区域名称
ycl-server/src/main/java/com/ycl/PlatformApplication.java
@@ -4,11 +4,13 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Slf4j
@EnableCaching
@EnableTransactionManagement
@EnableFeignClients(basePackages = {"com.ycl.web"})
@SpringBootApplication
public class PlatformApplication {
    public static void main(String[] args) {
ycl-server/src/main/java/com/ycl/task/CheckScoreTask.java
@@ -86,50 +86,31 @@
                //根据模板的考核标签查各区县对应省厅或市局人脸数据
                List<CheckIndexFace> checkIndexFaces = faceService.selectCheckIndexFaceList(checkIndexFace);
                for (CheckIndexFace indexFace : checkIndexFaces) {
                    addToList(templateId, checkTemplate, examineTag, templateRuleList, scoreList, indexFace, CheckConstants.Rule_Category_Face);
                    addToList(templateId, checkTemplate, examineTag, templateRuleList, scoreList, indexFace,CheckConstants.Rule_Category_Face);
                }
            }
            //储存分数
            scoreMapper.saveBatch(scoreList);
            //TODO:根据报警分数阈值,添加报警信息
            log.info("模板执行完成");
        }
        log.info("定时任务执行完成");
    }
    //查mongo数据归档到mysql
    public void dataArchiving() {
        //TODO:归档check_index_car,区分省厅市局,每个区县一条数据
        CheckIndexCar checkIndexCar = new CheckIndexCar();
        //TODO:归档check_index_face
        CheckIndexFace checkIndexFace = new CheckIndexFace();
        //TODO:归档check_index_video
        CheckIndexVideo checkIndexVideo = new CheckIndexVideo();
    }
    private <T extends CheckIndex> void addToList(Integer templateId, CheckTemplate checkTemplate, Short examineTag, List<CheckTemplateRule> templateRuleList, List<CheckScore> scoreList, T indexObject, Short checkCategory) {
    private <T extends CheckIndex>void addToList(Integer templateId, CheckTemplate checkTemplate, Short examineTag, List<CheckTemplateRule> templateRuleList, List<CheckScore> scoreList, T indexObject,Short checkCategory) {
        CheckScore checkScore = new CheckScore();
        BigDecimal scoreFinal = BigDecimal.ZERO;
        BigDecimal alarmScore = checkTemplate.getAlarmScore();
        for (CheckTemplateRule templateRule : templateRuleList) {
            //计算分数
            scoreFinal = getScoreFinal(indexObject, scoreFinal, templateRule);
            //TODO:根据报警分数阈值,添加报警信息
            if(scoreFinal.compareTo(alarmScore)<0){
            }
        }
        //补充checkScore
        fillCheckScore(templateId, checkTemplate, examineTag, indexObject, checkScore, scoreFinal, checkCategory);
        fillCheckScore(templateId, checkTemplate, examineTag, indexObject, checkScore, scoreFinal,checkCategory);
        scoreList.add(checkScore);
    }
    //通用方法计算分数
    private <T> BigDecimal getScoreFinal(T object, BigDecimal scoreFinal, CheckTemplateRule templateRule) {
    private <T>BigDecimal getScoreFinal(T object, BigDecimal scoreFinal, CheckTemplateRule templateRule) {
        String ruleIndex = templateRule.getRuleIndex();
        //将a_b_c转换为aBC
        String camelRuleIndex = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, ruleIndex);
@@ -142,27 +123,37 @@
            BigDecimal score = index.multiply(templateRule.getWeight());
            scoreFinal = scoreFinal.add(score);
        } catch (Exception e) {
            log.info("反射异常", e);
            log.info("反射异常",e);
        }
        return scoreFinal;
    }
    //设置checkScore对象
    private void fillCheckScore(Integer templateId, CheckTemplate checkTemplate, Short examineTag, CheckIndex checkIndex, CheckScore checkScore, BigDecimal scoreFinal, Short checkCategory) {
    private void fillCheckScore(Integer templateId, CheckTemplate checkTemplate, Short examineTag, CheckIndex checkIndex, CheckScore checkScore, BigDecimal scoreFinal,Short checkCategory) {
        //根据调整系数调整最终分数大小
        String adjustWay = checkTemplate.getAdjustWay();
        BigDecimal adjustCoefficient = checkTemplate.getAdjustCoefficient();
        if (CheckConstants.Multiply.equals(adjustWay)) {
        if(CheckConstants.Multiply.equals(adjustWay)){
            scoreFinal = adjustCoefficient.multiply(scoreFinal).multiply(new BigDecimal(100));
        } else if (CheckConstants.Divided.equals(adjustWay)) {
        }else if(CheckConstants.Divided.equals(adjustWay)){
            //四舍五入保留小数后四位
            scoreFinal = scoreFinal.divide(adjustCoefficient, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
            scoreFinal = scoreFinal.divide(adjustCoefficient,4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
        }
        checkScore.setCreateTime(new Date());
        checkScore.setExamineTag(Integer.parseInt(examineTag + ""));
        checkScore.setExamineTag(Integer.parseInt(examineTag +""));
        checkScore.setExamineCategory(checkCategory);
        checkScore.setDeptId(checkIndex.getDeptId());
        checkScore.setTemplateId(templateId);
        checkScore.setScore(scoreFinal);
    }
    //查mongo数据归档到mysql
    public void dataArchiving() {
        //TODO:归档check_index_car,区分省厅市局,每个区县一条数据
        CheckIndexCar checkIndexCar = new CheckIndexCar();
        //TODO:归档check_index_face
        CheckIndexFace checkIndexFace = new CheckIndexFace();
        //TODO:归档check_index_video
        CheckIndexVideo checkIndexVideo = new CheckIndexVideo();
    }
}
ycl-server/src/main/java/com/ycl/web/UYClient.java
New file
@@ -0,0 +1,51 @@
package com.ycl.web;
import com.alibaba.fastjson2.JSONObject;
import com.ycl.platform.domain.param.CameraParam;
import com.ycl.platform.domain.param.OnlineParam;
import com.ycl.platform.domain.param.RecordMetaDSumParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
/**
 * @author gonghl
 * @since 2024/7/1 下午 4:01
 */
@Component
@FeignClient(name = "UYClient", url = "${request.youYunDomain}")
public interface UYClient {
    /**
     * 一机一档
     *
     * @param cameraParam 请求参数
     * @return 查询摄像机清单集合
     */
    @GetMapping("/VIID/Cameras")
    JSONObject cameraList(CameraParam cameraParam);
    /**
     * 点位在线
     *
     * @param onlineParam 请求参数
     * @return 查询在线统计列表
     */
    @GetMapping("/openapi/v1/report/online/list")
    JSONObject onlineList(OnlineParam onlineParam);
    /**
     * 录像可用
     *
     * @param recordMetaDSumParam 请求参数
     * @return 查询满足条件的录像汇总信息
     */
    @PostMapping("/report/recordMetaDSum/list")
    JSONObject recordMetaDSumList(RecordMetaDSumParam recordMetaDSumParam);
    @GetMapping("/api/v1/app/osdMonitor/list")
    JSONObject osdMonitorList();
}
ycl-server/src/main/resources/mapper/zgyw/CheckScoreMapper.xml
@@ -35,7 +35,6 @@
            <if test="deptId != null "> and tcs.dept_id = #{deptId}</if>
            ${params.dataScope}
        </where>
        order by create_time desc
    </select>
    
    <select id="selectCheckScoreById" parameterType="Long" resultMap="CheckScoreResult">