lyhzzz пре 10 месеци
родитељ
комит
f2ea494c3d

+ 5 - 2
pom.xml

@@ -9,7 +9,6 @@
     <version>1.0.0</version>
     <packaging>jar</packaging>
 
-
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
@@ -41,7 +40,11 @@
             <version>3.0.0-SNAPSHOT</version>
         </dependency>
 
-
+        <dependency>
+            <groupId>com.fdkankan</groupId>
+            <artifactId>4dkankan-utils-fyun-obs</artifactId>
+            <version>3.0.0-SNAPSHOT</version>
+        </dependency>
         <dependency>
             <groupId>com.fdkankan</groupId>
             <artifactId>4dkankan-utils-redis</artifactId>

+ 3 - 0
src/main/java/com/fdkankan/ucenter/common/constants/ResultCode.java

@@ -47,4 +47,7 @@ public class ResultCode {
 
     public static final int FAILURE_CODE_400017  = 400017 ;
     public static final String FAILURE_MSG_400017 = "相机不存在" ;
+
+    public static final int FAILURE_CODE_500017  = 500017 ;
+    public static final String FAILURE_MSG_500017 = "相机类型不存在" ;
 }

+ 10 - 0
src/main/java/com/fdkankan/ucenter/controller/inner/InnerController.java

@@ -13,6 +13,7 @@ import com.fdkankan.ucenter.service.IInnerService;
 import com.fdkankan.ucenter.service.IUserService;
 import com.fdkankan.ucenter.service.impl.LoginService;
 import com.fdkankan.ucenter.vo.request.CameraDetailParam;
+import com.fdkankan.ucenter.vo.request.CameraInStoreParam;
 import com.fdkankan.ucenter.vo.request.CameraParam;
 import com.fdkankan.ucenter.vo.request.SceneParam;
 import com.fdkankan.ucenter.vo.response.CameraVo;
@@ -137,4 +138,13 @@ public class InnerController extends BaseController {
         }
         return Result.success(innerService.getSceneBySnCode(param));
     }
+
+    @PostMapping(value = "/cameraInStore")
+    public ResultData cameraInStore(@RequestBody CameraInStoreParam param){
+        Boolean flag = innerService.checkSign(getSign());
+        if(!flag){
+            throw new BusinessException(-1,"签名失败");
+        }
+        return ResultData.ok(innerService.cameraInStore(param));
+    }
 }

+ 3 - 0
src/main/java/com/fdkankan/ucenter/service/ICameraService.java

@@ -3,6 +3,7 @@ package com.fdkankan.ucenter.service;
 import com.fdkankan.ucenter.common.PageInfo;
 import com.fdkankan.ucenter.entity.Camera;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.fdkankan.ucenter.vo.request.CameraInStoreParam;
 import com.fdkankan.ucenter.vo.request.CameraParam;
 import com.fdkankan.ucenter.vo.response.CameraAppVo;
 import com.fdkankan.ucenter.vo.response.CameraVo;
@@ -53,4 +54,6 @@ public interface ICameraService extends IService<Camera> {
     List<Camera> findLikeChildName(String searchKey);
 
     List<Camera> getBySnCodes(List<String> snCodes);
+
+    Camera newCamera(CameraInStoreParam param);
 }

+ 4 - 0
src/main/java/com/fdkankan/ucenter/service/IInnerService.java

@@ -1,6 +1,8 @@
 package com.fdkankan.ucenter.service;
 
 import com.fdkankan.ucenter.common.Result;
+import com.fdkankan.ucenter.entity.Camera;
+import com.fdkankan.ucenter.vo.request.CameraInStoreParam;
 import com.fdkankan.ucenter.vo.request.SceneParam;
 import com.fdkankan.ucenter.vo.response.LaserSceneInfoVo;
 
@@ -31,4 +33,6 @@ public interface IInnerService {
     Object getSceneBySnCode(SceneParam param);
 
     Boolean checkSign(String sign);
+
+    Camera cameraInStore(CameraInStoreParam param);
 }

+ 23 - 3
src/main/java/com/fdkankan/ucenter/service/impl/CameraServiceImpl.java

@@ -20,6 +20,7 @@ import com.fdkankan.ucenter.mapper.ICameraMapper;
 import com.fdkankan.ucenter.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fdkankan.ucenter.util.DateUserUtil;
+import com.fdkankan.ucenter.vo.request.CameraInStoreParam;
 import com.fdkankan.ucenter.vo.request.CameraParam;
 import com.fdkankan.ucenter.vo.response.CameraAppVo;
 import com.fdkankan.ucenter.vo.response.CameraSpaceVo;
@@ -319,9 +320,7 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
         sceneProService.bindOrUnCamera(cameraIds,user.getId());
         scenePlusService.bindOrUnCamera(cameraIds,user.getId());
 
-        if("local".equals(NacosProperty.uploadType)){   //局域网绑定相机,添加权益
-            userIncrementService.addByCameraAndUser(cameraIds,user.getId());
-        }
+        userIncrementService.addByCameraAndUser(cameraIds,user.getId());
     }
 
     @Override
@@ -504,4 +503,25 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
         wrapper.in(Camera::getSnCode,snCodes);
         return this.list(wrapper);
     }
+
+    @Override
+    public Camera newCamera(CameraInStoreParam param) {
+        CameraType cameraType = cameraTypeService.getByCameraType(param.getCameraType());
+        if(cameraType == null){
+            throw new BusinessException(ResultCode.FAILURE_CODE_500017,ResultCode.FAILURE_MSG_500017);
+        }
+
+        Camera camera = new Camera();
+        camera.setChildName(param.getSnCode());
+        camera.setSnCode(param.getSnCode());
+        camera.setWifiName(cameraType.getWifiNamePrefix() + param.getSnCode());
+        this.save(camera);
+
+        CameraDetail cameraDetail = new CameraDetail();
+        cameraDetail.setType(param.getCameraType());
+        cameraDetail.setCameraId(camera.getId());
+        cameraDetailService.save(cameraDetail);
+
+        return camera;
+    }
 }

+ 16 - 6
src/main/java/com/fdkankan/ucenter/service/impl/InnerServiceImpl.java

@@ -23,6 +23,7 @@ import com.fdkankan.ucenter.constant.LoginConstant;
 import com.fdkankan.ucenter.entity.*;
 import com.fdkankan.ucenter.service.*;
 import com.fdkankan.ucenter.vo.RelicsSceneInitQueueDTO;
+import com.fdkankan.ucenter.vo.request.CameraInStoreParam;
 import com.fdkankan.ucenter.vo.request.SceneParam;
 import com.fdkankan.ucenter.util.RsaUtils;
 import com.fdkankan.ucenter.vo.response.LaserSceneInfoVo;
@@ -265,12 +266,6 @@ public class InnerServiceImpl implements IInnerService {
 
     }
 
-    public static void main(String[] args) {
-        JSONObject jsonObject = new JSONObject();
-        jsonObject.put("appId","ucenter");
-        jsonObject.put("timestamp",new Date().getTime());
-        System.out.println(jsonObject);
-    }
 
 
     @Override
@@ -339,4 +334,19 @@ public class InnerServiceImpl implements IInnerService {
         dto.setShootCount(scenePlusExt.getShootCount());
         return dto;
     }
+
+
+    @Override
+    public Camera cameraInStore(CameraInStoreParam param) {
+        if(param.getCameraType() == null || StringUtils.isBlank(param.getSnCode())){
+            throw new BusinessException(ErrorCode.FAILURE_CODE_3001);
+        }
+        Camera camera = cameraService.getBySnCode(param.getSnCode());
+        if(camera != null){
+            return camera;
+        }
+        return cameraService.newCamera(param);
+
+    }
+
 }

+ 0 - 92
src/main/java/com/fdkankan/ucenter/task/TaskService.java

@@ -69,7 +69,6 @@ public class TaskService {
 
 
 
-
     private void updateSceneViewCount() {
         String redisKey = RedisKeyUtil.V4_SCENE_VISIT_CNT;
         Map<String,String> hmget = redisUtil.hmget(redisKey);
@@ -98,74 +97,6 @@ public class TaskService {
         }
     }
 
-    @Autowired
-    IUserIncrementService userIncrementService;
-
-    @Scheduled(cron = "${task.cron.increment_sendMsg:0 0 12 * * ?}")
-    public void job11() {
-        if("local".equals(NacosProperty.uploadType)){
-            return;
-        }
-        log.info("每天12:00开始执行定时任务:短信提醒增值权益准备到期");
-        try {
-            userIncrementService.incrementExpireSendSms();
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error(e.getMessage());
-        }
-    }
-
-
-
-    @Scheduled(cron = "${task.cron.update_order_status:0 0 0 * * ?}")
-    public void checkIncrementExpire() {
-        if("local".equals(NacosProperty.uploadType)){
-            return;
-        }
-        log.info("每天00:00开始执行定时任务:增值权益到期检查");
-        try {
-            userIncrementService.incrementExpire();
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error(e.getMessage());
-        }
-    }
-
-    @Autowired
-    IOrderService orderService;
-
-    @Scheduled(cron = "${task.cron.update_order_status:0 0 1 * * ?}")
-    public void updateOrderStatus() {
-        if("local".equals(NacosProperty.uploadType)){
-            return;
-        }
-        log.info("每天01:00开始执行定时任务:更新收货状态");
-        try {
-            //更新收货状态,发货后15天,默认用户已经收到货物
-            orderService.autoUpdateOrderStatus();
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error(e.getMessage());
-        }
-    }
-
-    @Autowired
-    ISceneStatisticsService sceneStatisticsService;
-    @Scheduled(cron = "${task.cron.add_baidu_data:0 0 2 * * ?}")
-    public void addBaiduData() {
-        if("local".equals(NacosProperty.uploadType)){
-            return;
-        }
-        log.info("每天02:00开始执行定时任务:获取百度统计的数据入库");
-        try {
-            String dateStr = DateUtil.date2String(DateUtil.daysCalculate(new Date(), -1), DateUtil.YYYYMMDD_DATA_FORMAT);
-            Map<String, Map<String, Double>> map = StatisticsUtil.findStatisticsData(dateStr);
-            sceneStatisticsService.addData(map, dateStr);
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error(e.getMessage());
-        }
-    }
 
     /**
      * 清理场景nas资源
@@ -184,27 +115,4 @@ public class TaskService {
         log.info("清除场景计算目录任务执行完成");
     }
 
-    /**
-     * 清除订阅信息
-     */
-    @Autowired
-    IIncrementAutoOrderService incrementAutoOrderService;
-
-    @Scheduled(cron = "${task.cron.del_subscription:0 */1 * * * ?}")
-    public void delSub(){
-        LambdaQueryWrapper<IncrementAutoOrder> wrapper = new LambdaQueryWrapper<>();
-        wrapper.isNull(IncrementAutoOrder::getSubscriptionId);
-        List<IncrementAutoOrder> list = incrementAutoOrderService.list(wrapper);
-        List<Integer> delList = new ArrayList<>();
-        for (IncrementAutoOrder autoOrder : list) {
-            Long time = autoOrder.getCreateTime().getTime() + 1000 * 60 * 10;
-            if(new Date().getTime() > time){
-                delList.add(autoOrder.getId());
-            }
-        }
-        if(delList.size() >0){
-            log.info("超过十分钟未付款删除订阅信息:{}",delList.size());
-            incrementAutoOrderService.removeByIds(delList);
-        }
-    }
 }

+ 9 - 0
src/main/java/com/fdkankan/ucenter/vo/request/CameraInStoreParam.java

@@ -0,0 +1,9 @@
+package com.fdkankan.ucenter.vo.request;
+
+import lombok.Data;
+
+@Data
+public class CameraInStoreParam {
+    private Integer cameraType;
+    private String snCode;
+}