YYC
2026-02-27 8759f874989ccbb7cbbdfbfd9208e2b580a312b5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package com.fzzy.igds.api.v1.service;
 
import com.fzzy.igds.api.v1.data.ApiV1Req;
import com.fzzy.igds.api.v1.data.ApiV1Resp;
import com.fzzy.igds.api.v1.data.Param3030;
import com.fzzy.igds.domain.GatewaySer;
import com.alibaba.fastjson.JSONObject;
import com.fzzy.igds.domain.SnapRecord;
import com.fzzy.igds.service.FileService;
import com.fzzy.igds.service.SnapRecordService;
import com.fzzy.igds.utils.ContextUtil;
import com.ruoyi.common.config.FrameworkConfig;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.util.List;
 
/**
 * @Description 抓拍解析
 * @Author CZT
 * @Date 2026/1/7 11:07
 */
@Slf4j
@Component
public class ApiV1Service3030 {
 
    @Resource
    private SnapRecordService snapRecordService;
    @Resource
    private FileService fileService;
 
    /**
     * @param req
     * @param gatewaySer
     * @return
     */
    public ApiV1Resp<Object> analysis(ApiV1Req<Object> req, GatewaySer gatewaySer) throws Exception {
 
        //转化为对象
        Param3030 param = JSONObject.parseObject(JSONObject.toJSONString(req.getData()), Param3030.class);
 
        if (null == param) {
            return ApiV1Resp.error("抓拍信息为空,不解析!", req);
        }
 
        step1(param, gatewaySer);
 
        return ApiV1Resp.success(null, req);
    }
 
    /**
     * 异步解析
     *
     * @param param3030
     */
    @Async
    public void step1(Param3030 param3030, GatewaySer gatewaySer) throws Exception {
 
        SnapRecord snapRecord = new SnapRecord();
        snapRecord.setId(ContextUtil.generateId());
        snapRecord.setCompanyId(gatewaySer.getCompanyId());
        snapRecord.setDeptId(gatewaySer.getDeptId());
        snapRecord.setCameraId(param3030.getCameraId());
        snapRecord.setResult(param3030.getResult());
        snapRecord.setTags(param3030.getTags());
        snapRecord.setSnapTime(DateUtils.parseDate(param3030.getSnapTime(), "yyyy-MM-dd HH:mm:ss"));
 
        //base64转化为图片保存
        String savePath = fileService.getFileSavePath("SNAP");
        String fileName = ContextUtil.UUID() + ".jpg";
        String filePath = savePath + fileName;
        fileService.baseImg2Disk(filePath, param3030.getImgBase64());
 
        //设置保存图片路径
        snapRecord.setImgName(filePath.replace(FrameworkConfig.getProfile(), "/profile/"));
 
        snapRecordService.addData(snapRecord);
 
        log.info("质押监管接口V1,3030接口解析完成");
    }
 
}