|  |  | 
 |  |  | import org.springframework.util.ObjectUtils; | 
 |  |  | import org.springframework.util.StringUtils; | 
 |  |  |  | 
 |  |  | import java.math.BigDecimal; | 
 |  |  | import java.util.Date; | 
 |  |  | import java.util.HashMap; | 
 |  |  | import java.util.List; | 
 |  |  | 
 |  |  | public class AdjustDataUtils { | 
 |  |  |     /** | 
 |  |  |      * @param deviceData    设备数据 | 
 |  |  |      * @param adjustFormula 校准公式 | 
 |  |  |      * @param adjustFormula 校准公式,包含所有因子校准公式,key为因子code,value为校准公式(各个时间段的公式List) | 
 |  |  |      * @param aqiMap        与设备绑定的国控站点aqi数据 | 
 |  |  |      * @return Map<String, Object> 校准后数据 | 
 |  |  |      */ | 
 |  |  | 
 |  |  |             Set<String> dateKey = deviceData.keySet(); | 
 |  |  |             for (String adjustKey : adjustFormula.keySet()) { | 
 |  |  |                 if (!dateKey.contains(adjustKey)) { | 
 |  |  |                     deviceData.put(adjustKey, 0F); | 
 |  |  |                     deviceData.put(adjustKey, "0"); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  | 
 |  |  |                         if (aqiMap != null) { | 
 |  |  |                             aqiValue = aqiMap.get(key); | 
 |  |  |                         } | 
 |  |  |                         env.put("aqi", ObjectUtils.isEmpty(aqiValue) ? 0F : Float.parseFloat((String) aqiValue)); | 
 |  |  |                         env.put("aqi", ObjectUtils.isEmpty(aqiValue) ? 0F : new BigDecimal(String.valueOf(aqiValue)).floatValue()); | 
 |  |  |                     } | 
 |  |  |                     if (formula.contains("vocs")) { | 
 |  |  |                         Object vocsValue = ObjectUtils.isEmpty(deviceData.get(Constants.SENSOR_CODE_VOCS)) ? 0F : deviceData.get(Constants.SENSOR_CODE_VOCS); | 
 |  |  |                         env.put("vocs", vocsValue); | 
 |  |  |                     } | 
 |  |  |                     if (formula.contains("cel")) { | 
 |  |  |                         env.put("cel", Float.parseFloat((String) measuredValue)); | 
 |  |  |                         //env.put("cel", Float.parseFloat((String) measuredValue)); | 
 |  |  |                         env.put("cel", new BigDecimal(String.valueOf(measuredValue)).floatValue()); | 
 |  |  |                     } | 
 |  |  |                     //校准 | 
 |  |  |                     measuredValue = expression.execute(env); |