Преглед на файлове

更新了, 查询锁行,for update

wuweihao преди 4 години
родител
ревизия
0bb1f53e3b

+ 1 - 1
cms_pano_fcb/gis_common/src/main/java/com/gis/common/util/FileUtils.java

@@ -248,7 +248,7 @@ public class FileUtils {
         aliyunOssUtil.upload(savePath, ossPath);
 //        asyncTask.uploadOss(savePath, ossPath);
 
-        String ossUrl = ossDomain + ossPath;
+        String ossUrl = ossDomain + ossPath + "?d=" + System.currentTimeMillis();
         log.info("ossUrl: {}", ossUrl);
 
 

+ 12 - 0
cms_pano_fcb/gis_mapper/src/main/java/com/gis/mapper/SceneMapper.java

@@ -66,4 +66,16 @@ public interface SceneMapper extends IBaseMapper<SceneEntity, String> {
 
     @Select("select * from tb_scene where is_delete = 0 and status = #{status} and house_id = #{houseId}")
     List<SceneEntity> findByHouseIdAndStatus(String houseId, String status);
+
+    /**
+     * for update 锁表更新完,才能进行更新,需要开启事务
+     * 并发量大作会出现脏数据
+     *
+     * @param id
+     * @return
+     */
+    @Select("select * from tb_scene where is_delete = 0 and id = #{id} for update")
+    SceneEntity findByIdForUpdate(String id);
+
+
 }

+ 0 - 9
cms_pano_fcb/gis_service/src/main/java/com/gis/service/impl/IBaseServiceImpl.java

@@ -89,31 +89,22 @@ public abstract class IBaseServiceImpl<T extends BaseEntity, ID extends Serializ
     @Override
     public int save(T entity) {
         //migration之后要删掉判断
-        if (entity.getCreateTime() == null){
             entity.setCreateTime(new Date());
-        }
-        if (entity.getUpdateTime() == null){
             entity.setUpdateTime(new Date());
-        }
-//        entity.setIsDelete(0);
         return getBaseMapper().insertSelective(entity);
     }
 
     @Override
     public int update(T entity) {
         //migration之后要删掉判断
-        if (entity.getUpdateTime() == null){
             entity.setUpdateTime(new Date());
-        }
         return getBaseMapper().updateByPrimaryKeySelective(entity);
     }
 
     @Override
     public int updateAll(T entity) {
         //migration之后要删掉判断
-        if (entity.getUpdateTime() == null){
             entity.setUpdateTime(new Date());
-        }
         return getBaseMapper().updateByPrimaryKey(entity);
     }
 

+ 7 - 20
cms_pano_fcb/gis_service/src/main/java/com/gis/service/impl/SceneServiceImpl.java

@@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.transaction.Transactional;
 import javax.validation.constraints.NotBlank;
 import java.io.*;
 import java.time.LocalDateTime;
@@ -36,6 +37,7 @@ import java.util.*;
  */
 @Slf4j
 @Service
+@Transactional
 public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> implements SceneService {
 
     @Autowired
@@ -265,8 +267,9 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
 
             // TODO: 2021/1/8 0008 调用720云数据
             search = entityMapper.search(param);
-
         PageInfo<SceneEntity> page = new PageInfo<>(search);
+        log.info("page size: " + page.getSize());
+        log.info("page total: " + page.getTotal());
         return Result.success(page);
     }
 
@@ -616,28 +619,10 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
         } else {
             entity = this.findById(id);
             BeanUtils.copyProperties(param, entity);
-//            if (index.size() == 0) {
-//                entity.setIsIndex(1);
-//
-//                HouseSceneIndexDto indexDto = new HouseSceneIndexDto();
-//                indexDto.setId(entity.getHouseId());
-//                indexDto.setSceneNum(entity.getSceneCode());
-//                indexDto.setUpdateTime(LocalDateTime.now());
-//                indexDto.setFcbHouseId(entity.getHengdaId());
-//                Result result = houseFeign.updateHouseSceneIndex(indexDto);
-//
-//                if (result.getCode() == 0) {
-//                    log.info("更新了初始场景到VR项目完成");
-//                } else {
-//                    log.error("更新了初始场景到VR项目异常");
-//                    return Result.failure(result.getMsg());
-//                }
-//            }
             entity.setUpdateTime(new Date());
             this.update(entity);
             log.info("更新VR模型完成");
         }
-
         return Result.success();
     }
 
@@ -695,7 +680,8 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
     public Result editXml(XmlDataDto param) {
         long start = System.currentTimeMillis();
         String id = param.getId();
-        SceneEntity entity = findById(id);
+//        SceneEntity entity = findById(id);
+        SceneEntity entity = entityMapper.findByIdForUpdate(id);
         if (entity == null) {
             log.error("对象不存在,id : " + id);
             return Result.failure("场景码不存在");
@@ -740,6 +726,7 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, String> impl
         jsonObject.put("hlookat", hlookat);
         jsonObject.put("vlookat", vlookat);
         entity.setInitVisual(jsonObject.toJSONString());
+
         this.update(entity);
 
 

+ 2 - 0
cms_pano_fcb/gis_web/src/main/java/com/gis/web/controller/CommonController.java

@@ -64,6 +64,8 @@ public class CommonController extends BaseController {
     @ApiOperation(value = "场景列表-H5", position = 1)
     @PostMapping("list")
     public Result list(@RequestBody ScenePageDto param) {
+        log.info("场景列表-H5");
+        log.info("request param: " + param.toString());
         return sceneService.search(param);
     }
 

+ 4 - 1
cms_pano_fcb/gis_web/src/main/java/com/gis/web/controller/SceneController.java

@@ -229,7 +229,9 @@ public class SceneController extends BaseController {
             @ApiImplicitParam(name = "icon", value = "iconURL", dataType = "String", required = true)
     })
     public Result saveIndex(@RequestParam String sceneId, @RequestParam String icon) {
-        SceneEntity entity = sceneService.findById(sceneId);
+        log.info("保存初始画面");
+//        SceneEntity entity = sceneService.findb(sceneId);
+        SceneEntity entity = sceneMapper.findByIdForUpdate(sceneId);
         if (entity == null) {
             log.error("对象不存在: {}", sceneId);
             return Result.failure("对象不存在");
@@ -238,6 +240,7 @@ public class SceneController extends BaseController {
         entity.setIcon(icon);
         entity.setUpdateTime(new Date());
         sceneService.update(entity);
+        log.info("更新初始画面成功");
 
         return Result.success();
     }

+ 14 - 0
cms_pano_fcb/remark.md

@@ -96,11 +96,16 @@ sit:
    krpanotools makepano -config=templates/vtour-multires.config /mnt/cms_pano_fcb_data/test/test.jpg
    
    更新代码工具
+   
+   
    ex_031306460
    4Dade_hy01
    
    /tmp/a/
    
+   进入mysql : mysql -h 10.71.184.146 -u user_4dkankan_rw -p
+   密码: y2b9a42wRwGNKkJjCm1o
+   
    web: 
    https://vr-web01-uat.fcb.com.cn/evergrande/#/login
     https://vr-web01-uat.fcb.com.cn/
@@ -108,4 +113,13 @@ sit:
 # 720yun 需求
  1. 先上传全景图
  2. 在编辑场景
+ 
+ 
+# 交换状态逻辑
+    1. 720云只有一个初始场景(楼盘、园林、户型有且只有一个初始场景, isIndex=1)
+    2. 图片计算成功(未审核)status=3, 已审核status=4
+    3. VR项目下线,管理后台调用720接口修改状态为status 4 -> 3
+    4. 管理后台预览,预览是初始场景(isIndex=1的场景码) 
+    5. 预览是H5打开的首页(H5调用免token的list接口去匹配那个是初始场景,H5可以获取很多数据)
+    6. 先保存VR项目,才能添加场景