|
@@ -6,6 +6,7 @@ import com.huimv.center.service.BizDeviceRegisterService;
|
|
import com.huimv.center.service.BizFarmService;
|
|
import com.huimv.center.service.BizFarmService;
|
|
import com.huimv.center.utils.Const;
|
|
import com.huimv.center.utils.Const;
|
|
import com.huimv.center.utils.DateUtil;
|
|
import com.huimv.center.utils.DateUtil;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
@@ -35,28 +36,47 @@ public class SysBaseConfigListener {
|
|
@RabbitListener(queues = Const.QUEUE_SYNC_SYS_CONFIG)
|
|
@RabbitListener(queues = Const.QUEUE_SYNC_SYS_CONFIG)
|
|
@RabbitHandler
|
|
@RabbitHandler
|
|
public void syncSysBaseConfig(Map<String,String> params) throws ParseException {
|
|
public void syncSysBaseConfig(Map<String,String> params) throws ParseException {
|
|
|
|
+
|
|
|
|
+ System.out.println("======================收到基础配置信息同步"+params);
|
|
//查询牧场表是否有数据
|
|
//查询牧场表是否有数据
|
|
String farmCode = params.get("farmCode");
|
|
String farmCode = params.get("farmCode");
|
|
String chipId = params.get("chipId");
|
|
String chipId = params.get("chipId");
|
|
String deviceCode = params.get("deviceCode");
|
|
String deviceCode = params.get("deviceCode");
|
|
String bizFarmByFarmCode = bizFarmService.getBizFarmByFarmCode(farmCode);
|
|
String bizFarmByFarmCode = bizFarmService.getBizFarmByFarmCode(farmCode);
|
|
- if (Objects.isNull(bizFarmByFarmCode)){
|
|
|
|
|
|
+ System.out.println("-------------------"+bizFarmByFarmCode);
|
|
|
|
+ if (StringUtils.isBlank(bizFarmByFarmCode)){
|
|
//插入数据
|
|
//插入数据
|
|
bizFarmService.save(params.get("areaName"),farmCode,"","","",params.get("areaName"));
|
|
bizFarmService.save(params.get("areaName"),farmCode,"","","",params.get("areaName"));
|
|
|
|
+ insertRegistration(params);
|
|
}else {
|
|
}else {
|
|
|
|
+ System.out.println("******************查到了数据******");
|
|
BizFarm bizFarm = bizFarmService.getBizFarm(farmCode);
|
|
BizFarm bizFarm = bizFarmService.getBizFarm(farmCode);
|
|
//1、更新农场表
|
|
//1、更新农场表
|
|
bizFarmService.edit(bizFarm.getId(),params.get("areaName"),farmCode,"","","",params.get("areaName"));
|
|
bizFarmService.edit(bizFarm.getId(),params.get("areaName"),farmCode,"","","",params.get("areaName"));
|
|
- //2、注册表中是否有数据
|
|
|
|
- List<BizDeviceRegister> oneByChipIdAndDeviceCode = bizDeviceRegisterService.getOneByChipIdAndDeviceCode(chipId, deviceCode);
|
|
|
|
- if (null == oneByChipIdAndDeviceCode || oneByChipIdAndDeviceCode.size() == 0){
|
|
|
|
- //插入数据到注册表中
|
|
|
|
- bizDeviceRegisterService.add(params.get("areaName"),farmCode,chipId,deviceCode,params.get("ip"),params.get("port"),"");
|
|
|
|
- }else {
|
|
|
|
- //更新注册表
|
|
|
|
- BizDeviceRegister bizDeviceRegister = oneByChipIdAndDeviceCode.get(0);
|
|
|
|
- bizDeviceRegisterService.edit(bizDeviceRegister.getId(),chipId,deviceCode,params.get("ip"),params.get("port"),"");
|
|
|
|
- }
|
|
|
|
|
|
+ //2、更新注册表中数据
|
|
|
|
+ insertRegistration(params);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @description: 注册表中添加数据
|
|
|
|
+ * @author: 静静
|
|
|
|
+ * @date: s 9:46 上午
|
|
|
|
+ * @param: params
|
|
|
|
+ **/
|
|
|
|
+ private void insertRegistration(Map<String,String> params) throws ParseException {
|
|
|
|
+ String farmCode = params.get("farmCode");
|
|
|
|
+ String chipId = params.get("chipId");
|
|
|
|
+ String deviceCode = params.get("deviceCode");
|
|
|
|
+
|
|
|
|
+ List<BizDeviceRegister> oneByChipIdAndDeviceCode = bizDeviceRegisterService.getOneByChipIdAndDeviceCode(chipId, deviceCode);
|
|
|
|
+ if (null == oneByChipIdAndDeviceCode || oneByChipIdAndDeviceCode.size() == 0){
|
|
|
|
+ //插入数据到注册表中
|
|
|
|
+ bizDeviceRegisterService.add(params.get("areaName"),farmCode,chipId,deviceCode,params.get("ip"),params.get("port"),"");
|
|
|
|
+ }else {
|
|
|
|
+ //更新注册表
|
|
|
|
+ BizDeviceRegister bizDeviceRegister = oneByChipIdAndDeviceCode.get(0);
|
|
|
|
+ bizDeviceRegisterService.edit(bizDeviceRegister.getId(),chipId,deviceCode,params.get("ip"),params.get("port"),"");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|