|
@@ -0,0 +1,117 @@
|
|
|
+package com.fdkankan.job.job;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
+import com.fdkankan.job.entity.ScenePlus;
|
|
|
+import com.fdkankan.job.entity.SceneEditInfo;
|
|
|
+import com.fdkankan.job.service.IScenePlusExtService;
|
|
|
+import com.fdkankan.job.service.IScenePlusService;
|
|
|
+import com.fdkankan.job.service.ISceneEditInfoService;
|
|
|
+import com.fdkankan.model.constants.UploadFilePath;
|
|
|
+import com.fdkankan.redis.constant.RedisKey;
|
|
|
+import com.fdkankan.redis.util.RedisUtil;
|
|
|
+import com.xxl.job.core.context.XxlJobHelper;
|
|
|
+import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 根据floorplan_cad.json生成floorpan.json
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author dengsixing
|
|
|
+ * @since 2022/12/16
|
|
|
+ **/
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class SceneVersionHandler {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusService scenePlusService;
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusExtService scenePlusExtService;
|
|
|
+ @Autowired
|
|
|
+ private FYunFileServiceInterface fYunFileService;
|
|
|
+ @Autowired
|
|
|
+ private ISceneEditInfoService sceneEditInfoService;
|
|
|
+ @Autowired
|
|
|
+ private RedisUtil redisUtil;
|
|
|
+
|
|
|
+ @XxlJob("sceneVersionRepair")
|
|
|
+ private void sceneVersionRepair(){
|
|
|
+ XxlJobHelper.log("sceneVersionRepair start.....");
|
|
|
+
|
|
|
+ List<String> faildNumList = new ArrayList<>();
|
|
|
+
|
|
|
+ List<String> numList = null;
|
|
|
+ String nums = XxlJobHelper.getJobParam();
|
|
|
+ if(StrUtil.isNotEmpty(nums)){
|
|
|
+ numList = Arrays.asList(nums.split(","));
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaQueryWrapper<ScenePlus> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ if(CollUtil.isNotEmpty(numList)){
|
|
|
+ queryWrapper.in(ScenePlus::getNum, numList);
|
|
|
+ }
|
|
|
+ List<ScenePlus> list = scenePlusService.list(queryWrapper);
|
|
|
+
|
|
|
+ if(CollUtil.isNotEmpty(list)){
|
|
|
+ list.parallelStream().forEach(plus->{
|
|
|
+ String num = plus.getNum();
|
|
|
+ try {
|
|
|
+ //是否需要修复
|
|
|
+ boolean flag = false;
|
|
|
+
|
|
|
+ SceneEditInfo sceneEditInfo = sceneEditInfoService.getOne(new LambdaQueryWrapper<SceneEditInfo>().eq(SceneEditInfo::getScenePlusId, plus.getId()));
|
|
|
+ int version = 0;
|
|
|
+ int imgVersion = 0;
|
|
|
+ int linkVersion = 0;
|
|
|
+ String sceneJsonPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json";
|
|
|
+ String sceneJsonStr = fYunFileService.getFileContent(sceneJsonPath);
|
|
|
+ JSONObject sceneJson = JSON.parseObject(sceneJsonStr);
|
|
|
+ version = sceneJson.getIntValue("version");
|
|
|
+ imgVersion = sceneJson.getIntValue("imgVersion");
|
|
|
+ linkVersion = sceneJson.getIntValue("linkVersion");
|
|
|
+ if(version > sceneEditInfo.getVersion()){
|
|
|
+ flag = true;
|
|
|
+ sceneEditInfo.setVersion(version + 1);
|
|
|
+ sceneJson.put("version", sceneEditInfo.getVersion());
|
|
|
+ }
|
|
|
+ if(imgVersion > sceneEditInfo.getImgVersion()){
|
|
|
+ flag = true;
|
|
|
+ sceneEditInfo.setImgVersion(imgVersion + 1);
|
|
|
+ sceneJson.put("imgVersion", sceneEditInfo.getImgVersion());
|
|
|
+ }
|
|
|
+ if(linkVersion > sceneEditInfo.getLinkVersion()){
|
|
|
+ flag = true;
|
|
|
+ sceneEditInfo.setLinkVersion(linkVersion + 1);
|
|
|
+ sceneJson.put("linkVersion", sceneEditInfo.getLinkVersion());
|
|
|
+ }
|
|
|
+ if(flag){
|
|
|
+ sceneEditInfoService.updateById(sceneEditInfo);
|
|
|
+ fYunFileService.uploadFile(sceneJson.toJSONString().getBytes(), sceneJsonPath);
|
|
|
+ redisUtil.del(String.format(RedisKey.SCENE_JSON, num));
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("修正版本号失败" + num, e);
|
|
|
+ faildNumList.add(plus.getNum());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ XxlJobHelper.log("sceneVersionRepair end.....");
|
|
|
+ XxlJobHelper.log("丢正版本号失败:" + JSON.toJSONString(faildNumList));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|