Kaynağa Gözat

添加大华后台相关

yang 3 yıl önce
ebeveyn
işleme
83b5499d1e

+ 128 - 0
beeboxs/src/main/java/com/huimv/beeboxs/dahuaVideo/controller/SetDahuaAccountToFarmInfoController.java

@@ -0,0 +1,128 @@
+package com.huimv.beeboxs.dahuaVideo.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.huimv.beeboxs.common.utils.Result;
+import com.huimv.beeboxs.common.utils.ResultCode;
+import com.huimv.beeboxs.entity.FarmVideoAccount;
+import com.huimv.beeboxs.entity.HiveBaseStation;
+import com.huimv.beeboxs.mapper.FarmVideoAccountMapper;
+import com.huimv.beeboxs.mapper.HiveBaseStationMapper;
+import com.huimv.beeboxs.service.FarmVideoAccountService;
+import com.huimv.beeboxs.service.IBaseHiveFarmService;
+import com.huimv.beeboxs.service.IHiveBaseStationService;
+import com.huimv.beeboxs.service.impl.HiveBaseStationServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.querydsl.QuerydslRepositoryInvokerAdapter;
+import org.springframework.web.bind.annotation.*;
+
+
+import java.util.Map;
+
+/**
+ * TODO
+ *添加大华的账号到牧场信息上
+ * @author CodeYang.
+ * @date 2022/4/24 16:16
+ */
+
+
+@CrossOrigin
+@RestController
+@RequestMapping(value = "/dahua")
+public class SetDahuaAccountToFarmInfoController {
+
+
+    @Autowired
+    private FarmVideoAccountMapper farmVideoAccountMapper;
+
+    @Autowired
+    private IBaseHiveFarmService  iBaseHiveFarmService;
+
+ 
+
+    @Autowired
+    private IHiveBaseStationService baseStationService;
+
+
+
+    @Autowired
+    private HiveBaseStationMapper hiveBaseStationMapper;
+
+
+    @Autowired
+    private FarmVideoAccountService   farmVideoAccountService;
+
+    /**
+     * 给牧场绑定大华账户
+     * @param map
+     * @return
+     */
+    @PostMapping("/showDahuaaccount")
+    public Result changeDirection(@RequestBody Map map) {
+
+        QueryWrapper<FarmVideoAccount> FarmVideoAccountQueryWrapper = new QueryWrapper<>();
+        FarmVideoAccountQueryWrapper.eq("farm_id", map.get("farmId"));
+        FarmVideoAccount farmVideoAccounts = farmVideoAccountMapper.selectOne(FarmVideoAccountQueryWrapper);
+
+        return new Result(ResultCode.SUCCESS, farmVideoAccounts);
+
+    }
+
+
+        /**
+         * 给牧场绑定大华账户  账号唯一
+         * @param map
+         * @return
+         */
+        @PostMapping("/addDahuaAccount")
+        public Result addDahuaaccount(@RequestBody Map map){
+
+            QueryWrapper<FarmVideoAccount> FarmVideoAccountQueryWrapper = new QueryWrapper<>();
+            FarmVideoAccountQueryWrapper.eq("farm_id",map.get("farmId"));
+            FarmVideoAccount farmVideoAccounts = farmVideoAccountMapper.selectOne(FarmVideoAccountQueryWrapper);
+            if(farmVideoAccounts!=null){
+                return new Result(ResultCode.FAIL,"一个牧场只能绑定一个账号, 请勿重复添加");
+            }
+            FarmVideoAccount farmVideoAccount = new FarmVideoAccount();
+            farmVideoAccount.setFarmId((Integer)map.get("farmId"));
+            farmVideoAccount.setDahuaAppid((String) map.get("DahuaAppid"));
+            farmVideoAccount.setDahuaSecret((String) map.get("DahuaSecret"));
+            farmVideoAccount.setFarmName( iBaseHiveFarmService.getById((Integer)map.get("farmId")).getFarmName());
+            farmVideoAccount.setRemark((String) map.get("Remark"));
+            farmVideoAccountService.save(farmVideoAccount);
+            return new Result(ResultCode.SUCCESS  );
+
+}
+
+    /**
+     * 给牧场绑定大华账户
+     * @param
+     * @return
+     */
+    @PostMapping("/updateDahuaAccount")
+    public Result updateDahuaaccount(@RequestBody Map map){
+        FarmVideoAccount farmVideoAccount = farmVideoAccountService.getOne(new QueryWrapper<FarmVideoAccount>().eq("farm_id", map.get("farmId")));
+        System.out.println(farmVideoAccount);
+        //只能更改大华的信息  牧场信息不能变
+        farmVideoAccount.setDahuaAppid((String) map.get("DahuaAppid"));
+        farmVideoAccount.setDahuaSecret((String) map.get("DahuaSecret"));
+        farmVideoAccount.setFarmName( iBaseHiveFarmService.getById((Integer)map.get("farmId")).getFarmName());
+        farmVideoAccount.setRemark((String) map.get("Remark"));
+        farmVideoAccountService.updateById(farmVideoAccount);
+        return new Result(ResultCode.SUCCESS );
+    }
+     //绑定摄像头到基站
+
+
+    @PostMapping("/updateCameraToDevice")
+    public Result updateVideo(@RequestBody Map map){
+
+        HiveBaseStation hex = baseStationService.getOne(new QueryWrapper<HiveBaseStation>().eq("id", (String)map.get("Id")));
+        hex.setDeviceId((String) map.get("deviceId"));
+        hex.setChannelId((String) map.get("channelId"));
+        hex.setChannelName((String) map.get("channelName"));
+        baseStationService.updateById(hex);
+        return new Result(10000,"操作成功",true);
+    }
+
+}

+ 0 - 18
beeboxs/src/main/java/com/huimv/beeboxs/service/CamareDevideBindService.java

@@ -1,18 +0,0 @@
-package com.huimv.beeboxs.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.huimv.beeboxs.entity.CamareDevideBind;
-
-import java.util.Map;
-
-/**
- * 
- *
- * @author chenshun
- * @email sunlightcs@gmail.com
- * @date 2022-04-24 19:20:53
- */
-public interface CamareDevideBindService extends IService<CamareDevideBind> {
-
-}
-

+ 21 - 0
beeboxs/src/main/java/com/huimv/beeboxs/service/FarmVideoAccountService.java

@@ -0,0 +1,21 @@
+package com.huimv.beeboxs.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.huimv.beeboxs.entity.FarmVideoAccount;
+import com.huimv.beeboxs.entity.HiveBeehiveOut;
+import org.springframework.stereotype.Service;
+
+/**
+ * TODO
+ *
+ * @author CodeYang.
+ * @date 2022/4/24 16:23
+ */
+
+public interface FarmVideoAccountService extends IService<FarmVideoAccount> {
+    
+    
+    
+    
+    
+}

+ 0 - 19
beeboxs/src/main/java/com/huimv/beeboxs/service/impl/CamareDevideBindServiceImpl.java

@@ -1,19 +0,0 @@
-package com.huimv.beeboxs.service.impl;
-
-import com.baomidou.mybatisplus.core.conditions.query.Query;
-import com.huimv.beeboxs.entity.CamareDevideBind;
-import com.huimv.beeboxs.mapper.CamareDevideBindMapper;
-import com.huimv.beeboxs.service.CamareDevideBindService;
-import org.springframework.stereotype.Service;
-import java.util.Map;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
-
-
-@Service("camareDevideBindService")
-public class CamareDevideBindServiceImpl extends ServiceImpl<CamareDevideBindMapper, CamareDevideBind> implements CamareDevideBindService {
-
-
-}

+ 41 - 0
beeboxs/src/test/java/com/huimv/beebox/test/test001.java

@@ -0,0 +1,41 @@
+/*
+package com.huimv.beebox.test;
+
+import com.huimv.beeboxs.BeeboxsApplication;
+import com.huimv.beeboxs.entity.FarmVideoAccount;
+import com.huimv.beeboxs.mapper.FarmVideoAccountMapper;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.data.redis.core.ValueOperations;
+
+import java.util.List;
+
+*/
+/**
+ * TODO
+ *
+ * @author CodeYang.
+ * @date 2022/4/24 17:46
+ *//*
+
+
+
+
+@SpringBootTest(classes = BeeboxsApplication.class)
+public class test001 {
+
+    @Autowired
+    FarmVideoAccountMapper  farmVideoAccountMapper;
+
+    @Test
+    public void  test001(){
+
+        List<FarmVideoAccount> farmVideoAccounts = farmVideoAccountMapper.selectList(null);
+        System.out.println(farmVideoAccounts);
+
+    }
+
+
+}
+*/