| | |
| | | import java.util.Set;
|
| | |
|
| | | import org.apache.commons.collections.MapUtils;
|
| | | import org.apache.commons.lang.StringUtils;
|
| | | import org.apache.commons.lang.time.DateUtils;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | |
| | | parameters.put("mac", "898602b8191630065884");
|
| | | parameters.put("macKey", "e1");
|
| | | Map<String, Object> average = historyMapper.getMonthAverageBySensor(parameters);
|
| | |
|
| | | // 本月平均值
|
| | | if (MapUtils.isNotEmpty(average)) {
|
| | | resultMap.putAll(average);
|
| | | } else {
|
| | | resultMap.put("average", 0);
|
| | | }
|
| | | //
|
| | |
|
| | | //AQI 指数
|
| | | String[] macKeys = { "e1", "e2", "e10", "e11", "e15", "e16" };
|
| | | List<Double> IAQIs = new ArrayList<Double>();
|
| | | for (String macKey : macKeys) {
|
| | |
| | | double maxIAQI = Double.valueOf(IAQIValues[index + 1]);
|
| | | IAQIs.add(calculateIAQI(maxIAQI, minIAQI, maxMacKey, minMacKey, avg));
|
| | | }
|
| | | resultMap.put("standard", 35);
|
| | | if (!resultMap.containsKey("AQI")) {
|
| | | resultMap.put("AQI", Collections.max(IAQIs));
|
| | | }
|
| | | |
| | | //实际标准值
|
| | | String standard = ResourceUtil.getValue(parameters.get("macKey")+"-standard");
|
| | | if (StringUtils.isBlank(standard)) {
|
| | | standard = "50";
|
| | | }
|
| | | resultMap.put("standard", standard);
|
| | | return resultMap;
|
| | | }
|
| | |
|
| | |
| | | return result;
|
| | | }
|
| | |
|
| | | public void setOrgIdsByAccount(Map<String, Object> parameters) {
|
| | | AccountEntity account = accountMapper.selectByPrimaryKey((Integer.valueOf((String) parameters.get("accountId"))));
|
| | | String organization = account.getOrganization();
|
| | | //不是摩瑞尔账号的需要根据组织来获取数据权限
|
| | | if (!("-1".equals(organization) || "5212b9dfb55448e699889e01fa0fa6a2".equals(organization))) {
|
| | | Set<String> orgIds = organizationService.getChildOrganizationIds(account.getOrganization());
|
| | | parameters.put("orgIds", orgIds);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Map<String, Object> getEquipmentStates(Map<String, Object> parameters) {
|
| | | Map<String, Object> result = new HashMap<String, Object>();
|
| | |
| | | return result;
|
| | | }
|
| | |
|
| | | public void setOrgIdsByAccount(Map<String, Object> parameters) {
|
| | | AccountEntity account = accountMapper.selectByPrimaryKey((Integer.valueOf((String) parameters.get("accountId"))));
|
| | | String organization = account.getOrganization();
|
| | | //不是摩瑞尔账号的需要根据组织来获取数据权限
|
| | | if (!("-1".equals(organization) || "5212b9dfb55448e699889e01fa0fa6a2".equals(organization))) {
|
| | | Set<String> orgIds = organizationService.getChildOrganizationIds(account.getOrganization());
|
| | | parameters.put("orgIds", orgIds);
|
| | | }
|
| | | }
|
| | |
|
| | | private double calculateIAQI(double maxIAQI, double minIAQI, double maxMacKey, double minMacKey,double avg) {
|
| | | return (maxIAQI - minIAQI) * (avg - minMacKey) / (maxMacKey - minMacKey) + minIAQI;
|
| | | }
|
| | |
| | | e11=0,50,150,475,800,1600,2100,2620
|
| | | e15=0,100,160,215,265,800,1000,1200
|
| | | e16=0,40,80,180,280,565,750,940
|
| | | IAQI=0,50,100,150,200,300,400,500 |
| | | IAQI=0,50,100,150,200,300,400,500
|
| | | e1-standard=35
|
| | | e2-standard=50
|
| | | e3-standard=
|
| | | e4-standard=
|
| | | e5-standard=
|
| | | e6-standard=
|
| | | e7-standard=
|
| | | e8-standard=
|
| | | e9-standard=
|
| | | e10-standard=2
|
| | | e11-standard=50
|
| | | e12-standard=
|
| | | e13-standard=
|
| | | e14-standard=100
|
| | | e15-standard=100
|
| | | e16-standard=40
|
| | | e17-standard=
|
| | | e18-standard=
|
| | | e19-standard= |