vince
2023-11-09 93e01fa050330ead95041ed11cc85e9765c19fc1
src/main/java/com/fzzy/gateway/hx2023/service/HxGatewaySyncGrainImpl.java
@@ -13,6 +13,7 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@@ -22,7 +23,7 @@
 */
@Slf4j
@Data
@Component
@Service
public class HxGatewaySyncGrainImpl implements GatewaySyncGranService {
@@ -70,8 +71,10 @@
        double tMIn = 20, tMax = 25;
        if (null != weather) {
            double tOut = Double.valueOf(weather.getTem());
            tMIn = tOut - 2;
            tMax = tOut + 3;
            tMIn = tOut - 4;
            if(tMIn < 4)tMIn = 5;
            tMax = tOut + 0;
            if(tMax< 15)tMax = 15;
        }
@@ -103,7 +106,26 @@
        double randomNumber = tMIn;
        int x = 0, y = 0, z = 0;
        for (int i = 0; i < sumNum; i++) {
            randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            if((i) % Integer.valueOf(cableRule[0]) == 0){
                randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            } else if ((i) % Integer.valueOf(cableRule[0]) == 1) {
                randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            }else if ((i) % Integer.valueOf(cableRule[0]) == 2) {
                randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            }else if ((i) % Integer.valueOf(cableRule[0]) == 3) {
                randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            }else if ((i) % Integer.valueOf(cableRule[0]) == 4) {
                randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            }else {
                randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            }
           // randomNumber = Math.random() * (tMax - tMIn + 1) + tMIn;
            curTemp = NumberUtil.keepPrecision(randomNumber, 1);
            position = i;
            z = i % cableZ + 1;
@@ -114,7 +136,6 @@
            //根号
            cableNum = (i / cableZ) + 1;
            temperature.add(new GrainTemp(cableNum + "", z + "", curTemp + "", position + ""));
        }
@@ -122,6 +143,20 @@
        grain.setOutPut(outPut);
        //气象信息
        GrainWeather weatherStation = new GrainWeather();
        weatherStation.setMessageId(ScConstant.getMessageId());
        weatherStation.setId(device.getDeviceId());
        weatherStation.setAirPressure(weather.getPressure());
        weatherStation.setHumidity(weather.getHumidity());
        weatherStation.setPm(weather.getAir_pm25());
        weatherStation.setRadiation("0");
        weatherStation.setRainfallAmount(weather.getWea());
        weatherStation.setTemperature(weather.getTem());
        weatherStation.setWindDirection(weather.getWin());
        weatherStation.setWindPower(weather.getWin_meter());
        weatherStation.setWindSpeed(weather.getWin_speed());
        grain.setWeatherStation(weatherStation);
        BaseResp resp = new BaseResp();
        resp.setData(JSONObject.toJSONString(grain));