|
|
@@ -6,6 +6,11 @@ import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.lang.UUID;
|
|
|
import cn.hutool.core.thread.ThreadUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.db.Db;
|
|
|
+import cn.hutool.db.Entity;
|
|
|
+import cn.hutool.db.ds.simple.SimpleDataSource;
|
|
|
+import cn.hutool.db.nosql.redis.RedisDS;
|
|
|
+import cn.hutool.setting.Setting;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
@@ -24,6 +29,7 @@ import com.fdkankan.redis.constant.RedisKey;
|
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
|
import com.fdkankan.scene.bean.BodySegmentStatusBean;
|
|
|
import com.fdkankan.scene.config.FdkkLaserConfig;
|
|
|
+import com.fdkankan.scene.dto.SyncSceneDTO;
|
|
|
import com.fdkankan.scene.entity.*;
|
|
|
import com.fdkankan.scene.mapper.ISceneMapper;
|
|
|
import com.fdkankan.scene.oss.OssUtil;
|
|
|
@@ -44,16 +50,20 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
+import redis.clients.jedis.Jedis;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.imageio.ImageIO;
|
|
|
+import javax.sql.DataSource;
|
|
|
import java.awt.*;
|
|
|
import java.awt.image.BufferedImage;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.nio.file.FileSystemException;
|
|
|
+import java.sql.SQLException;
|
|
|
import java.util.List;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
@@ -70,6 +80,16 @@ public class SceneServiceImpl extends ServiceImpl<ISceneMapper, Scene> implement
|
|
|
private String bodySegmentBucket;
|
|
|
@Value("${oss.bodySegment.point:oss-cn-shanghai.aliyuncs.com}")
|
|
|
private String bodySegmentHost;
|
|
|
+ @Value("low-version.mysql.url")
|
|
|
+ private String mysqlUrl;
|
|
|
+ @Value("low-version.mysql.user")
|
|
|
+ private String mysqlUser;
|
|
|
+ @Value("low-version.mysql.pass")
|
|
|
+ private String mysqlPass;
|
|
|
+ @Value("low-version.redis.host")
|
|
|
+ private String redisHost;
|
|
|
+ @Value("low-version.redis.port")
|
|
|
+ private String redisPort;
|
|
|
|
|
|
@Autowired
|
|
|
private OssBodySegmentUtil ossBodySegmentUtil;
|
|
|
@@ -147,10 +167,6 @@ public class SceneServiceImpl extends ServiceImpl<ISceneMapper, Scene> implement
|
|
|
return ResultData.ok(uuid);
|
|
|
}
|
|
|
|
|
|
- public static void main(String[] args) throws IOException {
|
|
|
- Image rotateImg = ImgUtil.rotate(ImageIO.read(new File("C:\\Users\\dsx\\Desktop\\IMG_0231.HEIC.JPG")), 0);
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public void bodySegmentHandler(String imgUrl, String uuid) {
|
|
|
String progress = redisUtil.hget(RedisKey.SCENE_BODY_SEGMENT, uuid);
|
|
|
@@ -614,4 +630,172 @@ public class SceneServiceImpl extends ServiceImpl<ISceneMapper, Scene> implement
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public void syncScene(SyncSceneDTO dto) throws SQLException {
|
|
|
+ //创建数据源
|
|
|
+ Db db = Db.use(new SimpleDataSource(mysqlUrl, mysqlUser, mysqlPass));
|
|
|
+
|
|
|
+ //t_scene_plus
|
|
|
+ Entity oldScenePlus = db.get("t_scene_plus", "num", dto.getNum());
|
|
|
+ if(oldScenePlus == null){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5012);
|
|
|
+ }
|
|
|
+ Long plusId = oldScenePlus.getLong("id");
|
|
|
+
|
|
|
+ //t_scene_plus_ext
|
|
|
+ Entity oldScenePlusExt = db.get("t_scene_plus_ext", "plus_id", plusId);
|
|
|
+ if(oldScenePlusExt == null){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5012);
|
|
|
+ }
|
|
|
+
|
|
|
+ //t_scene_edit_info
|
|
|
+ Entity oldSceneEditInfo = db.get("t_scene_edit_info", "scene_plus_id", plusId);
|
|
|
+ if(oldSceneEditInfo == null){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5012);
|
|
|
+ }
|
|
|
+ Long editInfoId = oldSceneEditInfo.getLong("id");
|
|
|
+
|
|
|
+ //t_scene_edit_info_ext
|
|
|
+ Entity oldSceneEditInfoExt = db.get("t_scene_edit_info_ext", "edit_info_id", editInfoId);
|
|
|
+ if(oldSceneEditInfoExt == null){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5012);
|
|
|
+ }
|
|
|
+
|
|
|
+ //t_scene_edit_controls
|
|
|
+ Entity oldSceneEditControls = db.get("t_scene_edit_controls", "edit_info_id", editInfoId);
|
|
|
+ if(oldSceneEditControls == null){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5012);
|
|
|
+ }
|
|
|
+
|
|
|
+ //开始处理redis
|
|
|
+ Setting setting = new Setting();
|
|
|
+ setting.set("host", redisHost);
|
|
|
+ setting.set("port", redisPort);
|
|
|
+ Jedis jedis = RedisDS.create(setting, null).getJedis();
|
|
|
+
|
|
|
+ //马赛克
|
|
|
+ String mosaicKey = String.format(RedisKey.SCENE_MOSAIC_DATA, dto.getNum());
|
|
|
+ Map<String, String> mosaicMap = jedis.hgetAll(mosaicKey);
|
|
|
+ if(CollUtil.isNotEmpty(mosaicMap)){
|
|
|
+ redisUtil.del(mosaicKey);//应对导入失败时,后续重试的情况,所以这里先清除脏数据
|
|
|
+ redisUtil.hmset(mosaicKey, mosaicMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ //热点
|
|
|
+ String hotDataKey = String.format(RedisKey.SCENE_HOT_DATA, dto.getNum());
|
|
|
+ Map<String, String> hotMap = jedis.hgetAll(hotDataKey);
|
|
|
+ if(CollUtil.isNotEmpty(hotMap)){
|
|
|
+ redisUtil.del(mosaicKey);
|
|
|
+ redisUtil.hmset(hotDataKey, hotMap);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //热点图标
|
|
|
+ String hotIconKey = String.format(RedisKey.SCENE_HOT_ICONS, dto.getNum());
|
|
|
+ Set<String> set = jedis.smembers(hotIconKey);
|
|
|
+ if(CollUtil.isNotEmpty(set)){
|
|
|
+ redisUtil.del(mosaicKey);
|
|
|
+ redisUtil.sSet(hotIconKey, set.toArray());
|
|
|
+ }
|
|
|
+
|
|
|
+ //场景关联
|
|
|
+ String linkPanKey = String.format(RedisKey.SCENE_LINKPAN_DATA, dto.getNum());
|
|
|
+ Map<String, String> linkPanMap = jedis.hgetAll(linkPanKey);
|
|
|
+ if(CollUtil.isNotEmpty(linkPanMap)){
|
|
|
+ redisUtil.del(mosaicKey);
|
|
|
+ redisUtil.hmset(linkPanKey, linkPanMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ //滤镜
|
|
|
+ String filterKey = String.format(RedisKey.SCENE_filter_DATA, dto.getNum());
|
|
|
+ List<String> filterList = jedis.lrange(filterKey, 0, -1);
|
|
|
+ if(CollUtil.isNotEmpty(filterList)){
|
|
|
+ redisUtil.del(mosaicKey);
|
|
|
+ redisUtil.lRightPushAll(filterKey, filterList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //指示牌
|
|
|
+ String billboardKey = String.format(RedisKey.SCENE_BILLBOARDS, dto.getNum());
|
|
|
+ Map<String, String> billboardKeyMap = jedis.hgetAll(billboardKey);
|
|
|
+ if(CollUtil.isNotEmpty(billboardKeyMap)){
|
|
|
+ redisUtil.del(mosaicKey);
|
|
|
+ redisUtil.hmset(billboardKey, billboardKeyMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ //指示牌风格
|
|
|
+ String billboardStylesKey = String.format(RedisKey.SCENE_BILLBOARDS_STYLES, dto.getNum());
|
|
|
+ Map<String, String> billboardStylesMap = jedis.hgetAll(billboardStylesKey);
|
|
|
+ if(CollUtil.isNotEmpty(billboardStylesMap)){
|
|
|
+ redisUtil.del(mosaicKey);
|
|
|
+ redisUtil.hmset(billboardStylesKey, billboardStylesMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ //模型裁剪
|
|
|
+ String cutModelKey = String.format(RedisKey.SCENE_CUT_MODEL, dto.getNum());
|
|
|
+ Map<String, String> cutModelMap = jedis.hgetAll(cutModelKey);
|
|
|
+ if(CollUtil.isNotEmpty(cutModelMap)){
|
|
|
+ redisUtil.del(mosaicKey);
|
|
|
+ redisUtil.hmset(cutModelKey, cutModelMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ //空间绘制
|
|
|
+ String sceneDrawKey = String.format(RedisKey.SCENE_DRAW, dto.getNum());
|
|
|
+ Map<String, String> sceneDrawMap = jedis.hgetAll(sceneDrawKey);
|
|
|
+ if(CollUtil.isNotEmpty(sceneDrawMap)){
|
|
|
+ redisUtil.del(mosaicKey);
|
|
|
+ redisUtil.hmset(sceneDrawKey, sceneDrawMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ String scenePlusStr = JSON.toJSONString(oldScenePlus);
|
|
|
+ ScenePlus scenePlus = JSON.parseObject(scenePlusStr, ScenePlus.class);
|
|
|
+ scenePlus.setId(null);
|
|
|
+ scenePlus.setLastEditTime(new Date());
|
|
|
+ scenePlusService.save(scenePlus);
|
|
|
+
|
|
|
+ String scenePlusExtStr = JSON.toJSONString(oldScenePlusExt);
|
|
|
+ ScenePlusExt scenePlusExt = JSON.parseObject(scenePlusExtStr, ScenePlusExt.class);
|
|
|
+ scenePlusExt.setId(null);
|
|
|
+ scenePlusExt.setPlusId(scenePlus.getId());
|
|
|
+ scenePlusExt.setDataSource(dto.getDataSource());
|
|
|
+ scenePlusExt.setYunFileBucket(dto.getBucket());
|
|
|
+ scenePlusExtService.save(scenePlusExt);
|
|
|
+
|
|
|
+ String sceneEditInfoStr = JSON.toJSONString(oldSceneEditInfo);
|
|
|
+ SceneEditInfo sceneEditInfo = JSON.parseObject(sceneEditInfoStr, SceneEditInfo.class);
|
|
|
+ sceneEditInfo.setId(null);
|
|
|
+ sceneEditInfo.setScenePlusId(scenePlus.getId());
|
|
|
+ sceneEditInfoService.save(sceneEditInfo);
|
|
|
+
|
|
|
+ String sceneEditInfoExtStr = JSON.toJSONString(oldSceneEditInfoExt);
|
|
|
+ SceneEditInfoExt sceneEditInfoExt = JSON.parseObject(sceneEditInfoExtStr, SceneEditInfoExt.class);
|
|
|
+ sceneEditInfoExt.setId(null);
|
|
|
+ sceneEditInfoExt.setEditInfoId(sceneEditInfo.getId());
|
|
|
+ sceneEditInfoExt.setScenePlusId(scenePlus.getId());
|
|
|
+ sceneEditInfoExtService.save(sceneEditInfoExt);
|
|
|
+
|
|
|
+ String sceneEditControlsStr = JSON.toJSONString(oldSceneEditControls);
|
|
|
+ SceneEditControls sceneEditControls = JSON.parseObject(sceneEditControlsStr, SceneEditControls.class);
|
|
|
+ sceneEditControls.setId(null);
|
|
|
+ sceneEditControls.setEditInfoId(sceneEditInfo.getId());
|
|
|
+ sceneEditControlsService.save(sceneEditControls);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) throws IOException, SQLException {
|
|
|
+
|
|
|
+ //t_scene_plus
|
|
|
+ Db db = Db.use(new SimpleDataSource("jdbc:mysql://120.24.144.164:3306/4dkankan_v4?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true", "root", "4Dage@4Dage#@168"));
|
|
|
+ Entity oldScenePlus = db.get("t_scene_plus", "num", "KJ-t-uXkEAQarVGH");
|
|
|
+ if(oldScenePlus == null){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5012);
|
|
|
+ }
|
|
|
+ String jsonString = JSON.toJSONString(oldScenePlus);
|
|
|
+ ScenePlus scenePlus = JSON.parseObject(jsonString, ScenePlus.class);
|
|
|
+ System.out.println(scenePlus);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|