mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 19:15:35 +08:00
新增 相机相关Service方法
This commit is contained in:
@@ -1,11 +1,45 @@
|
||||
package com.jsowell.thirdparty.camera.service;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.pile.dto.camera.CameraIdentifyResultsDTO;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* 相机管理系统 Service
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2023/12/5 11:11:32
|
||||
*/
|
||||
@Service
|
||||
public class CameraService {
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
|
||||
public void receiveIdentifyResults(JSONObject jsonObject) {
|
||||
|
||||
// 获取背景图片
|
||||
JSONArray bgImgs = jsonObject.getJSONArray("bg_img");
|
||||
List<CameraIdentifyResultsDTO.BgImg> bgImgList = bgImgs.toList(CameraIdentifyResultsDTO.BgImg.class);
|
||||
if (CollectionUtils.isEmpty(bgImgList)) {
|
||||
return;
|
||||
}
|
||||
for (CameraIdentifyResultsDTO.BgImg bgImg : bgImgList) {
|
||||
String image = bgImg.getImage(); // 图片的 base64 编码
|
||||
String key = bgImg.getKey(); // 索引id
|
||||
String redisKey = "receiveCameraImageByKey_" + key;
|
||||
// 根据索引id存入缓存
|
||||
redisCache.setCacheObject(redisKey, image, 10, TimeUnit.HOURS);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user