|
@@ -0,0 +1,162 @@
|
|
|
+package com.fdkankan.manage_jp.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.fdkankan.manage_jp.common.PageInfo;
|
|
|
+import com.fdkankan.manage_jp.common.ResultCode;
|
|
|
+import com.fdkankan.manage_jp.entity.*;
|
|
|
+import com.fdkankan.manage_jp.exception.BusinessException;
|
|
|
+import com.fdkankan.manage_jp.mapper.ITmColdStorageMapper;
|
|
|
+import com.fdkankan.manage_jp.service.*;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fdkankan.manage_jp.util.SceneSourceUtils;
|
|
|
+import com.fdkankan.manage_jp.vo.request.ColdStorageParam;
|
|
|
+import com.fdkankan.manage_jp.vo.request.SceneParam;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.sql.BatchUpdateException;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author
|
|
|
+ * @since 2024-02-21
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class TmColdStorageServiceImpl extends ServiceImpl<ITmColdStorageMapper, TmColdStorage> implements ITmColdStorageService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IScenePlusService scenePlusService;
|
|
|
+ @Autowired
|
|
|
+ IScenePlusExtService scenePlusExtService;
|
|
|
+ @Autowired
|
|
|
+ ISceneProService sceneProService;
|
|
|
+ @Autowired
|
|
|
+ IUserService userService;
|
|
|
+ @Autowired
|
|
|
+ ICameraService cameraService;
|
|
|
+ @Autowired
|
|
|
+ ICameraDetailService cameraDetailService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object pageList(ColdStorageParam param) {
|
|
|
+ LambdaQueryWrapper<TmColdStorage> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ if(StringUtils.isNotBlank(param.getUserName())){
|
|
|
+ wrapper.like(TmColdStorage::getUserName,param.getUserName());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(param.getShootingStartTime())){
|
|
|
+ wrapper.ge(TmColdStorage::getShootingTime,param.getShootingStartTime());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(param.getShootingEndTime())){
|
|
|
+ wrapper.le(TmColdStorage::getShootingTime,param.getShootingEndTime());
|
|
|
+ }
|
|
|
+ if(param.getType() != null){
|
|
|
+ List<Integer> sceneSourceByType = SceneSourceUtils.getSceneSourceByType(param.getType());
|
|
|
+ wrapper.in(TmColdStorage::getSceneSource,sceneSourceByType);
|
|
|
+ if(param.getType() == 4){
|
|
|
+ wrapper.eq(TmColdStorage::getIsObj,1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Page<TmColdStorage> page = this.page(new Page<>(param.getPageNum(), param.getPageSize()), wrapper);
|
|
|
+ return PageInfo.PageInfo(page);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void coldStorage(SceneParam param) {
|
|
|
+ if(param.getNumList().isEmpty()){
|
|
|
+ throw new BusinessException(ResultCode.PARAM_ERROR);
|
|
|
+ }
|
|
|
+ for (String num :param.getNumList()) {
|
|
|
+ List<TmColdStorage> tmColdStorages = this.getByNum(num);
|
|
|
+ if(!tmColdStorages.isEmpty()){
|
|
|
+ throw new BusinessException(ResultCode.SCENE_COLD_STORAGE);
|
|
|
+ }
|
|
|
+ ScenePlus scenePlus = scenePlusService.getByNum(num);
|
|
|
+ ScenePro scenePro = sceneProService.getByNum(num);
|
|
|
+ if(scenePlus == null && scenePro == null){
|
|
|
+ throw new BusinessException(ResultCode.SCENE_NOT_EXIT);
|
|
|
+ }
|
|
|
+ Long userId = scenePro == null ? scenePlus.getUserId() :scenePro.getUserId();
|
|
|
+ Long cameraId = scenePro == null ? scenePlus.getCameraId() :scenePro.getCameraId();
|
|
|
+
|
|
|
+ ScenePlusExt scenePlusExt = null;
|
|
|
+ if(scenePlus != null){
|
|
|
+ scenePlusExt = scenePlusExtService.getByPlusId(scenePlus.getId());
|
|
|
+ if(scenePlusExt == null){
|
|
|
+ throw new BusinessException(ResultCode.SCENE_NOT_EXIT);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ TmColdStorage coldStorage = new TmColdStorage();
|
|
|
+ if(cameraId != null){
|
|
|
+ Camera camera = cameraService.getById(cameraId);
|
|
|
+ if(camera != null){
|
|
|
+ coldStorage.setCameraId(camera.getId());
|
|
|
+ coldStorage.setSnCode(camera.getSnCode());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(userId != null){
|
|
|
+ User user = userService.getById(userId);
|
|
|
+ if(user != null){
|
|
|
+ coldStorage.setUserName(user.getUserName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ coldStorage.setSceneId(scenePro == null ?scenePlus.getId():scenePro.getId());
|
|
|
+ coldStorage.setSceneName(scenePro == null ?scenePlus.getTitle():scenePro.getSceneName());
|
|
|
+ coldStorage.setSceneNum(scenePro == null ?scenePlus.getNum():scenePro.getNum());
|
|
|
+ coldStorage.setSceneWebsite(scenePro == null ?scenePlusExt.getWebSite():scenePro.getWebSite());
|
|
|
+ coldStorage.setSceneThumb(scenePro == null ?scenePlusExt.getThumb():scenePro.getThumb());
|
|
|
+ coldStorage.setSceneStatus(scenePro == null ?scenePlus.getSceneStatus(): scenePro.getStatus());
|
|
|
+ coldStorage.setUserId(scenePro == null ?scenePlus.getUserId():scenePro.getUserId());
|
|
|
+ coldStorage.setShootingTime(scenePro == null ?scenePlus.getCreateTime():scenePro.getCreateTime());
|
|
|
+ coldStorage.setSceneSource(scenePro == null?scenePlus.getSceneSource():scenePro.getSceneSource());
|
|
|
+ coldStorage.setSceneVersion(scenePro == null?"v3":"v4");
|
|
|
+ coldStorage.setIsObj(scenePro == null?scenePlusExt.getIsObj():scenePro.getIsObj());
|
|
|
+ this.save(coldStorage);
|
|
|
+ scenePlusService.updatePayStatus(num,scenePro == null ?"v3":"v4",scenePro == null?scenePlus.getSceneSource():scenePro.getSceneSource(),-2,null,null);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void restore(SceneParam param) {
|
|
|
+ if(param.getNumList().isEmpty() || StringUtils.isBlank(param.getWifiName())){
|
|
|
+ throw new BusinessException(ResultCode.PARAM_ERROR);
|
|
|
+ }
|
|
|
+ for (String num : param.getNumList()) {
|
|
|
+ List<TmColdStorage> tmColdStorages = this.getByNum(num);
|
|
|
+ if(tmColdStorages.isEmpty()){
|
|
|
+ throw new BusinessException(ResultCode.SCENE_NO_COLD_STORAGE);
|
|
|
+ }
|
|
|
+ ScenePlus scenePlus = scenePlusService.getByNum(num);
|
|
|
+ ScenePro scenePro = sceneProService.getByNum(num);
|
|
|
+ if(scenePlus == null && scenePro == null){
|
|
|
+ throw new BusinessException(ResultCode.SCENE_NOT_EXIT);
|
|
|
+ }
|
|
|
+ Long cameraId = scenePro == null ? scenePlus.getCameraId() : scenePro.getCameraId();
|
|
|
+ CameraDetail oldCameraDetail = cameraDetailService.getByCameraId(cameraId);
|
|
|
+ CameraDetail cameraDetail = cameraDetailService.getByWiFiName(param.getWifiName());
|
|
|
+ if(!oldCameraDetail.getType().equals(cameraDetail.getType())){
|
|
|
+ throw new BusinessException(ResultCode.RESTORE_ERROR);
|
|
|
+ }
|
|
|
+ scenePlusService.updatePayStatus(num,scenePro == null ?"v3":"v4",scenePro == null?scenePlus.getSceneSource():scenePro.getSceneSource(),1,cameraDetail.getCameraId(),cameraDetail.getUserId());
|
|
|
+ this.removeByIds(tmColdStorages);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private List<TmColdStorage> getByNum(String num) {
|
|
|
+ LambdaQueryWrapper<TmColdStorage> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(TmColdStorage::getSceneNum,num);
|
|
|
+ return this.list(wrapper);
|
|
|
+ }
|
|
|
+}
|