YYC
2026-02-27 1369c87ddcc0e76e17d01208ef66261ee0cd27da
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
86
87
package com.fzzy.igds.api.v1.service;
 
import com.alibaba.fastjson.JSONObject;
import com.fzzy.igds.api.v1.data.ApiV1Req;
import com.fzzy.igds.api.v1.data.ApiV1Resp;
import com.fzzy.igds.api.v1.data.Param3033;
import com.fzzy.igds.domain.GatewaySer;
import com.fzzy.igds.domain.WeighbridgeSnap;
import com.fzzy.igds.service.FileService;
import com.fzzy.igds.service.WeighbridgeSnapService;
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;
 
/**
 * @Description AI事件解析
 * @Author CZT
 * @Date 2026/1/7 11:09
 */
@Slf4j
@Component
public class ApiV1Service3033 {
 
    @Resource
    private WeighbridgeSnapService weighbridgeSnapService;
    @Resource
    private FileService fileService;
 
    /**
     * @param req
     * @param gatewaySer
     * @return
     */
    public ApiV1Resp<Object> analysis(ApiV1Req<Object> req, GatewaySer gatewaySer) throws Exception {
 
        //转化为对象
        Param3033 param = JSONObject.parseObject(JSONObject.toJSONString(req.getData()), Param3033.class);
 
        if (null == param) {
            return ApiV1Resp.error("抓拍信息为空,不解析!", req);
        }
 
        step1(param, gatewaySer);
 
        return ApiV1Resp.success(null, req);
 
    }
 
    /**
     * 异步解析
     *
     * @param param
     */
    @Async
    public void step1(Param3033 param, GatewaySer gatewaySer) throws Exception {
 
        WeighbridgeSnap info = new WeighbridgeSnap();
        info.setId(ContextUtil.generateId());
        info.setCompanyId(gatewaySer.getCompanyId());
        info.setDeptId(gatewaySer.getDeptId());
        info.setSerId(param.getCameraId());
        info.setName(param.getName());
        info.setWeight(param.getWeight());
 
        info.setTime(DateUtils.parseDate(param.getTime(), "yyyy-MM-dd HH:mm:ss"));
        info.setTags(param.getTags());
 
        //base64转化为图片保存
        String savePath = fileService.getFileSavePath("WEIGHTNAP");
        String fileName = ContextUtil.UUID() + ".jpg";
        String filePath = savePath + fileName;
        fileService.baseImg2Disk(filePath, param.getImgBase64());
 
        //设置保存图片路径
        info.setImgName(filePath.replace(FrameworkConfig.getProfile(), "/profile/"));
 
        weighbridgeSnapService.addData(info);
 
        log.info("质押监管接口V1,3033接口解析完成");
 
    }
 
}