|
@@ -0,0 +1,481 @@
|
|
|
+package com.huimv.produce.timer;
|
|
|
+
|
|
|
+
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.huimv.common.utils.DataUill;
|
|
|
+import com.huimv.produce.entity.*;
|
|
|
+import com.huimv.produce.service.*;
|
|
|
+import com.huimv.produce.sgd.Global;
|
|
|
+import com.huimv.produce.sgd.entity.Item;
|
|
|
+import com.huimv.produce.sgd.entity.Monitory;
|
|
|
+import com.huimv.produce.sgd.entity.MonitoryGetArgs;
|
|
|
+import com.huimv.produce.sgd.entity.MonitoryValue;
|
|
|
+import com.huimv.produce.sgd.fbox.ConsoleLoggerFactory;
|
|
|
+import com.huimv.produce.sgd.fbox.ServerCaller;
|
|
|
+import com.huimv.produce.sgd.fbox.StaticCredentialProvider;
|
|
|
+import com.huimv.produce.sgd.fbox.TokenManager;
|
|
|
+import com.huimv.produce.sgd.fbox.models.BoxGroup;
|
|
|
+import com.huimv.produce.sgd.fbox.models.BoxReg;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Component
|
|
|
+public class SgdTimer {
|
|
|
+ private static final long SLEEP_TIME = 1000;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IBaseBoxService baseBoxService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IBaseRoomService baseRoomService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysHumidityService humidityService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysTemperatureService temperatureService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysDayWaterService dayWaterService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysMonthWaterService monthWaterService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysFodderService fodderService;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /* //更新盒子,房间信息
|
|
|
+ @Scheduled(cron = "0 0 0 1/7 * ?")
|
|
|
+// @Scheduled(cron = "0 0/6 * * * ?")
|
|
|
+ private void updateBox(){
|
|
|
+
|
|
|
+ ConsoleLoggerFactory loggerFactory = new ConsoleLoggerFactory();
|
|
|
+ // 指定连接服务器的凭据参数
|
|
|
+ TokenManager tokenManager = new TokenManager(new StaticCredentialProvider(Global.clientId, Global.clientSecret, Global.username, Global.password), Global.idServerUrl, loggerFactory);
|
|
|
+ ServerCaller appServer = new ServerCaller(tokenManager, Global.appServerApiUrl, Global.signalrClientId, loggerFactory);
|
|
|
+ ServerCaller apiBaseServer = new ServerCaller(tokenManager, Global.apiBaserUrl, Global.signalrClientId, loggerFactory);
|
|
|
+ Global.appServer = appServer;
|
|
|
+ Global.apiBaseServer = apiBaseServer;
|
|
|
+ try {
|
|
|
+ BoxGroup[] boxGroups = appServer.executeGet("api/client/box/grouped", BoxGroup[].class);
|
|
|
+ List<BaseBox> boxs = new ArrayList<>();
|
|
|
+ List<BaseRoom> rooms = new ArrayList<>();
|
|
|
+ for (BoxGroup group : boxGroups) {
|
|
|
+ //盒子
|
|
|
+ for (BoxReg boxReg : group.boxRegs) {
|
|
|
+ String alias = boxReg.alias;
|
|
|
+ if (alias.endsWith("层环控系统")) {
|
|
|
+ if (alias.startsWith("海盐青莲1号楼")){
|
|
|
+ boxs.add( new BaseBox(boxReg.boxUid,alias,1));
|
|
|
+ }
|
|
|
+ if (alias.startsWith("海盐青莲2号楼")){
|
|
|
+ boxs.add( new BaseBox(boxReg.boxUid,alias,2));
|
|
|
+ }
|
|
|
+ if (alias.startsWith("海盐青莲3号楼")){
|
|
|
+ boxs.add( new BaseBox(boxReg.boxUid,alias,3));
|
|
|
+ }
|
|
|
+ for (int i= 1 ;i <= 6 ;i++){
|
|
|
+ BaseRoom baseRoom = new BaseRoom();
|
|
|
+ baseRoom.setBoxId(boxReg.boxUid);
|
|
|
+ baseRoom.setRoomName("房舍"+i);
|
|
|
+ baseRoom.setAlias(alias.substring(4,9));
|
|
|
+ rooms.add(baseRoom);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ baseBoxService.remove(null);
|
|
|
+ baseBoxService.saveBatch(boxs);
|
|
|
+
|
|
|
+ baseRoomService.remove(null);
|
|
|
+ baseRoomService.saveBatch(rooms);
|
|
|
+ System.out.println("更新房舍信息,更新时间------------->"+ new Date());
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }*/
|
|
|
+
|
|
|
+ //更新环境数据
|
|
|
+ @Scheduled(cron = "0 0/30 * * * ?")
|
|
|
+ private void updateEnv(){
|
|
|
+ ConsoleLoggerFactory loggerFactory = new ConsoleLoggerFactory();
|
|
|
+ // 指定连接服务器的凭据参数
|
|
|
+ TokenManager tokenManager = new TokenManager(new StaticCredentialProvider(Global.clientId, Global.clientSecret, Global.username, Global.password), Global.idServerUrl, loggerFactory);
|
|
|
+ ServerCaller apiBaseServer = new ServerCaller(tokenManager, Global.apiBaserUrl, Global.signalrClientId, loggerFactory);
|
|
|
+ Global.apiBaseServer = apiBaseServer;
|
|
|
+ DecimalFormat df = new DecimalFormat("#.00");
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ List<BaseBox> boxes = baseBoxService.list();
|
|
|
+ for (BaseBox box : boxes) {
|
|
|
+ String uid = box.getUid();
|
|
|
+ Monitory[] monitories = apiBaseServer.executeGet("/v2/box/" + uid + "/dmon/grouped", Monitory[].class);
|
|
|
+ List names = new ArrayList();
|
|
|
+ for (Monitory monitory : monitories) {
|
|
|
+ for (Item item : monitory.items) {
|
|
|
+ String name = item.name;
|
|
|
+ if (monitory.name.contains("每个房间") && name != null&& name.startsWith("房舍")) {
|
|
|
+ if (name.contains("平均温度") || name.contains("湿度")) {
|
|
|
+ names.add(name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (ObjectUtil.isNotEmpty(names)) {
|
|
|
+ MonitoryValue[] monitoryValues = apiBaseServer.executePost("/v2/box/" +uid + "/dmon/value/get", new MonitoryGetArgs(names, null, new ArrayList()), MonitoryValue[].class);
|
|
|
+ List<SysTemperature> temList = new ArrayList();
|
|
|
+ List<SysHumidity> humList = new ArrayList<>();
|
|
|
+ for (MonitoryValue monitoryValue : monitoryValues) {
|
|
|
+ if (ObjectUtil.isEmpty(monitoryValue)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String name = monitoryValue.getName();
|
|
|
+ String[] split = name.split("-");
|
|
|
+ BaseRoom room = baseRoomService.getOne(new QueryWrapper<BaseRoom>().eq("room_name", split[0]).eq("box_id", uid));
|
|
|
+ Integer roomId = room.getId();
|
|
|
+ if (split[1].contains("温度")){
|
|
|
+ SysTemperature sysTemperature = new SysTemperature();
|
|
|
+ if (ObjectUtil.isNotEmpty(monitoryValue.getValue())){
|
|
|
+ Double value = (Double)monitoryValue.getValue() * 0.1;
|
|
|
+ sysTemperature.setId(monitoryValue.getId());
|
|
|
+ sysTemperature.setRoomId(roomId);
|
|
|
+ if (value != 0.0){
|
|
|
+ sysTemperature.setValue(df.format(value));
|
|
|
+ }else {
|
|
|
+ sysTemperature.setValue(value+"");
|
|
|
+ }
|
|
|
+ sysTemperature.setCreateTime(monitoryValue.getTimestamp());
|
|
|
+ temList.add(sysTemperature);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (split[1].contains("湿度")){
|
|
|
+ SysHumidity humidity = new SysHumidity();
|
|
|
+ Double value = (Double)monitoryValue.getValue() ;
|
|
|
+ humidity.setId(monitoryValue.getId());
|
|
|
+ humidity.setRoomId(roomId);
|
|
|
+ if (ObjectUtil.isNotEmpty(value)){
|
|
|
+ if (value != 0.0){
|
|
|
+ humidity.setValue(df.format(value));
|
|
|
+ }else{
|
|
|
+ humidity.setValue(value+"");
|
|
|
+ }
|
|
|
+
|
|
|
+ humidity.setCreateTime(monitoryValue.getTimestamp());
|
|
|
+ humList.add(humidity);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ humidityService.saveBatch(humList);
|
|
|
+ temperatureService.saveBatch(temList);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ System.out.println("更新温湿度信息,更新时间------------->"+ new Date());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //更新日用水 9
|
|
|
+ @Scheduled(cron = "0 55 8 * * ? ")
|
|
|
+// @Scheduled(cron = "0 * * * * ?")
|
|
|
+ private void updateDayWater(){
|
|
|
+ ConsoleLoggerFactory loggerFactory = new ConsoleLoggerFactory();
|
|
|
+ // 指定连接服务器的凭据参数
|
|
|
+ TokenManager tokenManager = new TokenManager(new StaticCredentialProvider(Global.clientId, Global.clientSecret, Global.username, Global.password), Global.idServerUrl, loggerFactory);
|
|
|
+ ServerCaller apiBaseServer = new ServerCaller(tokenManager, Global.apiBaserUrl, Global.signalrClientId, loggerFactory);
|
|
|
+ Global.apiBaseServer = apiBaseServer;
|
|
|
+ DecimalFormat df = new DecimalFormat("#.00");
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ List<BaseBox> boxes = baseBoxService.list();
|
|
|
+ for (BaseBox box : boxes) {
|
|
|
+ String uid = box.getUid();
|
|
|
+ Monitory[] monitories = apiBaseServer.executeGet("/v2/box/" + uid + "/dmon/grouped", Monitory[].class);
|
|
|
+ List names = new ArrayList();
|
|
|
+ if (ObjectUtil.isEmpty(monitories)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for (Monitory monitory : monitories) {
|
|
|
+ for (Item item : monitory.items) {
|
|
|
+ String name = item.name;
|
|
|
+ if (monitory.name.contains("每个房间") && name != null&& name.startsWith("房舍")) {
|
|
|
+ if (name.contains("日用水量") ) {
|
|
|
+ names.add(name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (ObjectUtil.isNotEmpty(names)) {
|
|
|
+ MonitoryValue[] monitoryValues = apiBaseServer.executePost("/v2/box/" +uid + "/dmon/value/get", new MonitoryGetArgs(names, null, new ArrayList()), MonitoryValue[].class);
|
|
|
+
|
|
|
+ List<SysDayWater> dayWatersList = new ArrayList();
|
|
|
+ for (MonitoryValue monitoryValue : monitoryValues) {
|
|
|
+ if (ObjectUtil.isEmpty(monitoryValue)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String name = monitoryValue.getName();
|
|
|
+ String[] split = name.split("-");
|
|
|
+ BaseRoom room = baseRoomService.getOne(new QueryWrapper<BaseRoom>().eq("room_name", split[0]).eq("box_id", uid));
|
|
|
+ Integer roomId = room.getId();
|
|
|
+
|
|
|
+ SysDayWater dayWater = new SysDayWater();
|
|
|
+ Double value = (Double)monitoryValue.getValue();
|
|
|
+
|
|
|
+ dayWater.setId(monitoryValue.getId());
|
|
|
+ dayWater.setRoomId(roomId);
|
|
|
+ if (value == null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (0.0 != value){
|
|
|
+ String format = df.format(value);
|
|
|
+ if (format.length()==3){
|
|
|
+ dayWater.setValue(0+format);
|
|
|
+ }else {
|
|
|
+ dayWater.setValue(format);
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ dayWater.setValue(value+"");
|
|
|
+ }
|
|
|
+ dayWater.setCreateTime(monitoryValue.getTimestamp());
|
|
|
+ dayWatersList.add(dayWater);
|
|
|
+ }
|
|
|
+ dayWaterService.saveBatch(dayWatersList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ System.out.println("更新日用水信息,更新时间------------->"+ new Date());
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新两个小时用水
|
|
|
+ @Scheduled(cron = "0 59 0,2,4,6,8,10,12,14,16,18,20,22 * * ? ")
|
|
|
+// @Scheduled(cron = "0 0/5 * * * ?")
|
|
|
+ private void updateMonthWater(){
|
|
|
+ ConsoleLoggerFactory loggerFactory = new ConsoleLoggerFactory();
|
|
|
+ // 指定连接服务器的凭据参数
|
|
|
+ TokenManager tokenManager = new TokenManager(new StaticCredentialProvider(Global.clientId, Global.clientSecret, Global.username, Global.password), Global.idServerUrl, loggerFactory);
|
|
|
+ ServerCaller apiBaseServer = new ServerCaller(tokenManager, Global.apiBaserUrl, Global.signalrClientId, loggerFactory);
|
|
|
+ Global.apiBaseServer = apiBaseServer;
|
|
|
+ DecimalFormat df = new DecimalFormat("#.00");
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ List<BaseBox> boxes = baseBoxService.list();
|
|
|
+ for (BaseBox box : boxes) {
|
|
|
+ String uid = box.getUid();
|
|
|
+ Monitory[] monitories = apiBaseServer.executeGet("/v2/box/" + uid + "/dmon/grouped", Monitory[].class);
|
|
|
+ List names = new ArrayList();
|
|
|
+ for (Monitory monitory : monitories) {
|
|
|
+ for (Item item : monitory.items) {
|
|
|
+ String name = item.name;
|
|
|
+ if (monitory.name.contains("每个房间") && name != null&& name.startsWith("房舍")) {
|
|
|
+ if (name.contains("日用水量") ) {
|
|
|
+ names.add(name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (ObjectUtil.isNotEmpty(names)) {
|
|
|
+ MonitoryValue[] monitoryValues = apiBaseServer.executePost("/v2/box/" +uid + "/dmon/value/get", new MonitoryGetArgs(names, null, new ArrayList()), MonitoryValue[].class);
|
|
|
+ List<SysMonthWater> dayWatersList = new ArrayList();
|
|
|
+ for (MonitoryValue monitoryValue : monitoryValues) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (ObjectUtil.isEmpty(monitoryValue)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String name = monitoryValue.getName();
|
|
|
+ String[] split = name.split("-");
|
|
|
+ BaseRoom room = baseRoomService.getOne(new QueryWrapper<BaseRoom>().eq("room_name", split[0]).eq("box_id", uid));
|
|
|
+ Integer roomId = room.getId();
|
|
|
+ SysMonthWater oldWater = monthWaterService.getOne(
|
|
|
+ new QueryWrapper<SysMonthWater>()
|
|
|
+ .ge("create_time", DataUill.getTimesmorning())
|
|
|
+ .eq("room_id", roomId)
|
|
|
+ .last("ORDER BY create_time LIMIT 1"));
|
|
|
+
|
|
|
+ SysMonthWater monthWater = new SysMonthWater();
|
|
|
+ Double newValue = (Double)monitoryValue.getValue();
|
|
|
+ Double add =0.0 ;
|
|
|
+ if (ObjectUtil.isEmpty(oldWater)){
|
|
|
+ add = newValue;
|
|
|
+ }else {
|
|
|
+ Double oldValue = Double.parseDouble(oldWater.getValue());
|
|
|
+ if (newValue >= oldValue){
|
|
|
+ add = newValue -oldValue;
|
|
|
+ }else {
|
|
|
+ add = oldValue - newValue + newValue;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (add != 0.0){
|
|
|
+ String format = df.format(add);
|
|
|
+ if (format.length()==3){
|
|
|
+ monthWater.setIncreaseValue(0+format);
|
|
|
+ }else {
|
|
|
+ monthWater.setIncreaseValue(format);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ monthWater.setIncreaseValue(add+"");
|
|
|
+ }
|
|
|
+
|
|
|
+ monthWater.setId(monitoryValue.getId());
|
|
|
+ monthWater.setRoomId(roomId);
|
|
|
+ if (newValue != 0.0){
|
|
|
+ String format = df.format(newValue);
|
|
|
+ if (format.length()==3){
|
|
|
+ monthWater.setValue(0+format);
|
|
|
+ }else {
|
|
|
+ monthWater.setValue(format);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ monthWater.setValue(newValue+"");
|
|
|
+ }
|
|
|
+ monthWater.setCreateTime(monitoryValue.getTimestamp());
|
|
|
+ dayWatersList.add(monthWater);
|
|
|
+
|
|
|
+ }
|
|
|
+ monthWaterService.saveBatch(dayWatersList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ System.out.println("更新月用水信息,更新时间------------->"+ new Date());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //更新料控
|
|
|
+ @Scheduled(cron = "0 0/3 * * * ? ")
|
|
|
+// @Scheduled(cron = "0 0/5 * * * ?")
|
|
|
+ private void updateFodder() throws IOException {
|
|
|
+ ConsoleLoggerFactory loggerFactory = new ConsoleLoggerFactory();
|
|
|
+ // 指定连接服务器的凭据参数
|
|
|
+ TokenManager tokenManager = new TokenManager(new StaticCredentialProvider(Global.clientId, Global.clientSecret, Global.username, Global.password), Global.idServerUrl, loggerFactory);
|
|
|
+ ServerCaller apiBaseServer = new ServerCaller(tokenManager, Global.apiBaserUrl, Global.signalrClientId, loggerFactory);
|
|
|
+ Global.apiBaseServer = apiBaseServer;
|
|
|
+
|
|
|
+ List names = new ArrayList();
|
|
|
+ String oneUid = "-1277226674647203111";
|
|
|
+ String twoUid = "-1277176930335980834";
|
|
|
+ String threeUid = "-1277075358654397725";
|
|
|
+ names.add("累计重量");
|
|
|
+
|
|
|
+ MonitoryValue[] monitoryValues = apiBaseServer.executePost("/v2/box/" + oneUid + "/dmon/value/get", new MonitoryGetArgs(names, null, new ArrayList()), MonitoryValue[].class);
|
|
|
+
|
|
|
+ MonitoryValue monitoryValue = monitoryValues[0];
|
|
|
+ Double value = (Double)monitoryValue.getValue();
|
|
|
+ SysFodder oneFodder = fodderService.getOne(new QueryWrapper<SysFodder>().eq("floor_id", 1).last("ORDER BY fodder_id DESC limit 1"));
|
|
|
+ Double oldVale = oneFodder.getValue();
|
|
|
+ if (oldVale < value){
|
|
|
+ oneFodder.setValue(value);
|
|
|
+ fodderService.updateById(oneFodder);
|
|
|
+ System.out.println("一号楼更新------------>"+monitoryValue);
|
|
|
+ }else if (value < oldVale){
|
|
|
+ SysFodder fodder = new SysFodder();
|
|
|
+ fodder.setValue(value);
|
|
|
+ fodder.setCreateTime(monitoryValue.getTimestamp());
|
|
|
+ fodder.setFloorId(1);
|
|
|
+ fodder.setId(monitoryValue.getId());
|
|
|
+ fodderService.save(fodder);
|
|
|
+ System.out.println("一号楼新增------------>"+monitoryValue);
|
|
|
+ }else {
|
|
|
+ System.out.println("一号楼舍弃------------>"+monitoryValue);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ MonitoryValue[] twoMonitoryValues = apiBaseServer.executePost("/v2/box/" + twoUid + "/dmon/value/get", new MonitoryGetArgs(names, null, new ArrayList()), MonitoryValue[].class);
|
|
|
+ MonitoryValue twoMonitoryValue = twoMonitoryValues[0];
|
|
|
+ Double twoValue = (Double)twoMonitoryValue.getValue();
|
|
|
+ SysFodder twoFodder = fodderService.getOne(new QueryWrapper<SysFodder>().eq("floor_id", 2).last("ORDER BY fodder_id DESC limit 1"));
|
|
|
+ Double twoOldVale = twoFodder.getValue();
|
|
|
+ if (twoOldVale < twoValue){
|
|
|
+ twoFodder.setValue(twoValue);
|
|
|
+ fodderService.updateById(twoFodder);
|
|
|
+ System.out.println("二号楼更新------------>"+twoFodder);
|
|
|
+ }else if (twoValue < twoOldVale){
|
|
|
+ SysFodder fodder = new SysFodder();
|
|
|
+ fodder.setValue(twoValue);
|
|
|
+ fodder.setCreateTime(twoMonitoryValue.getTimestamp());
|
|
|
+ fodder.setFloorId(2);
|
|
|
+ fodder.setId(twoMonitoryValue.getId());
|
|
|
+ fodderService.save(fodder);
|
|
|
+ System.out.println("二号楼新增------------>"+twoMonitoryValue);
|
|
|
+ }else {
|
|
|
+ System.out.println("二号楼舍弃------------>"+twoMonitoryValue);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ MonitoryValue[] threeMonitoryValues = apiBaseServer.executePost("/v2/box/" + threeUid + "/dmon/value/get", new MonitoryGetArgs(names, null, new ArrayList()), MonitoryValue[].class);
|
|
|
+ MonitoryValue threeMonitoryValue = threeMonitoryValues[0];
|
|
|
+ Double threeValue = (Double)threeMonitoryValue.getValue();
|
|
|
+ SysFodder threeFodder = fodderService.getOne(new QueryWrapper<SysFodder>().eq("floor_id", 3).last("ORDER BY fodder_id DESC limit 1"));
|
|
|
+ Double threeOldVale = threeFodder.getValue();
|
|
|
+ if (threeOldVale < threeValue){
|
|
|
+ threeFodder.setValue(threeValue);
|
|
|
+ fodderService.updateById(threeFodder);
|
|
|
+ System.out.println("三号楼更新------------>"+threeFodder);
|
|
|
+ }else if (threeValue < threeOldVale){
|
|
|
+ SysFodder fodder = new SysFodder();
|
|
|
+ fodder.setValue(threeValue);
|
|
|
+ fodder.setCreateTime(threeMonitoryValue.getTimestamp());
|
|
|
+ fodder.setFloorId(3);
|
|
|
+ fodder.setId(threeMonitoryValue.getId());
|
|
|
+ fodderService.save(fodder);
|
|
|
+ System.out.println("三号楼新增------------>"+threeMonitoryValue);
|
|
|
+ }else {
|
|
|
+ System.out.println("三号楼舍弃------------>"+threeMonitoryValue);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ System.out.println("更新料塔信息,更新时间------------->" + new Date());
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|