|
@@ -24,6 +24,7 @@ Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意
|
|
|
*/
|
|
|
package com.huimv.modular.collectorregister.controller;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.huimv.core.annotion.BusinessLog;
|
|
|
import com.huimv.core.annotion.DataScope;
|
|
@@ -32,11 +33,15 @@ import com.huimv.core.enums.LogAnnotionOpTypeEnum;
|
|
|
import com.huimv.core.pojo.response.ErrorResponseData;
|
|
|
import com.huimv.core.pojo.response.ResponseData;
|
|
|
import com.huimv.core.pojo.response.SuccessResponseData;
|
|
|
+import com.huimv.modular.basepigpen.entity.BasePigpen;
|
|
|
+import com.huimv.modular.basepigpen.mapper.BasePigpenMapper;
|
|
|
+import com.huimv.modular.basepigpen.service.BasePigpenService;
|
|
|
import com.huimv.modular.collectorregister.entity.CollectorRegister;
|
|
|
import com.huimv.modular.collectorregister.param.CollectorRegisterParam;
|
|
|
import com.huimv.modular.collectorregister.service.CollectorRegisterService;
|
|
|
import com.huimv.modular.eartagregister.entity.EartagRegister;
|
|
|
import com.huimv.modular.eartagregister.service.EartagRegisterService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -44,7 +49,9 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 设备管理控制器
|
|
@@ -61,6 +68,88 @@ public class CollectorRegisterController {
|
|
|
@Resource
|
|
|
private EartagRegisterService eartagRegisterService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private BasePigpenService basePigpenService;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BasePigpenMapper basePigpenMapper;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //批量添加采集器----客户接口
|
|
|
+ @PostMapping ("/collectorRegister/addPro")
|
|
|
+ public ResponseData addPro(@RequestBody Map<String, Object> params) {
|
|
|
+ //批量添加 基站
|
|
|
+ String deviceCodeList = (String) params.get("deviceCodeList"); //耳基站号码 不止一个
|
|
|
+ String penName = (String) params.get("penName");
|
|
|
+ String unitName = (String) params.get("unitName");
|
|
|
+ String farmName = (String) params.get("farmName");
|
|
|
+ String farmId = (String) params.get("farmId");
|
|
|
+
|
|
|
+
|
|
|
+ //一进来先添加栋舍 拿到 id 再添加舍
|
|
|
+ BasePigpen basePigpen = new BasePigpen();
|
|
|
+ basePigpen.setFarmCode(farmId); //记录牧场
|
|
|
+ basePigpen.setPigpenName(penName); //记录舍名
|
|
|
+ basePigpen.setType(1);//栋
|
|
|
+ basePigpen.setParentId(0);//栋 阶段啥的全部空着
|
|
|
+ basePigpenService.save(basePigpen);
|
|
|
+
|
|
|
+ //拿最新的id 很麻烦直接查一次
|
|
|
+
|
|
|
+
|
|
|
+ LambdaQueryWrapper<BasePigpen> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.orderByDesc().last("limit 1");
|
|
|
+ BasePigpen pigpen = basePigpenMapper.selectOne(wrapper);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //添加舍得信息
|
|
|
+ BasePigpen basePigpenunit = new BasePigpen();
|
|
|
+ basePigpenunit.setFarmCode(farmId); //记录牧场
|
|
|
+ basePigpenunit.setPigpenName(unitName); //记录舍名
|
|
|
+ basePigpenunit.setType(2);//栋
|
|
|
+ basePigpenunit.setParentId(pigpen.getId());//栋 阶段啥的全部空着
|
|
|
+ basePigpenService.save(basePigpenunit);
|
|
|
+
|
|
|
+
|
|
|
+ LambdaQueryWrapper<BasePigpen> wrapper1 = Wrappers.lambdaQuery();
|
|
|
+ wrapper1.orderByDesc(BasePigpen::getId).last("limit 1");
|
|
|
+ BasePigpen pigpenUnite = basePigpenMapper.selectOne(wrapper1);
|
|
|
+
|
|
|
+ //主从关系直接在这里创建 存到云服务器的只有设备编号 不存在其他的东西 转发IP 我们给他写死就可以了
|
|
|
+
|
|
|
+ String[] as = deviceCodeList.split(",");
|
|
|
+ for (int i = 0; i < as.length; i++) {
|
|
|
+
|
|
|
+ CollectorRegister collectorRegister = new CollectorRegister();
|
|
|
+ collectorRegister.setDeviceCode(as[i]);
|
|
|
+ collectorRegister.setFarmCode(farmId);
|
|
|
+ collectorRegister.setFarmName(farmName);
|
|
|
+ collectorRegister.setRegisterTime(new Date());
|
|
|
+ collectorRegister.setOrgId(123456L);
|
|
|
+ collectorRegister.setPenName(penName);
|
|
|
+ collectorRegister.setUnitName(unitName);
|
|
|
+ collectorRegister.setUnitId(pigpenUnite.getId());
|
|
|
+ collectorRegister.setPigpenId(pigpen.getId());
|
|
|
+ collectorRegister.setPort(6859);
|
|
|
+ collectorRegister.setServerIp("195.125.635.3");
|
|
|
+ collectorRegisterService.save(collectorRegister);
|
|
|
+
|
|
|
+ }
|
|
|
+ SuccessResponseData successResponseData = new SuccessResponseData();
|
|
|
+ successResponseData.setCode(200);
|
|
|
+ successResponseData.setSuccess(true);
|
|
|
+ successResponseData.setMessage("保存成功");
|
|
|
+ return successResponseData;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 查询设备管理
|
|
|
*
|