ZhuDongming
2019-08-29 ef3a45a366ea8451f2581547fa6a3894bd1d672f
src/main/java/com/moral/service/impl/HistoryServiceImpl.java
@@ -33,6 +33,7 @@
import com.moral.entity.Sensor;
import com.moral.mapper.DeviceMapper;
import com.moral.mapper.HistoryMapper;
import com.moral.mapper.OrganizationRelationMapper;
import com.moral.mapper.SensorMapper;
import com.moral.mapper.SensorUnitMapper;
import com.moral.service.AccountService;
@@ -57,6 +58,9 @@
    @Resource
    private ProfessionService professionService;
    @Resource
    private OrganizationRelationMapper organizationRelationMapper;
   @Override
   public Map<String, Object> getAllSensorAverageByDevice(Map<String, Object> parameters) throws Exception {
@@ -287,7 +291,7 @@
         if (sensorUnits.containsKey(sensorKey)) {
            Map<String, Object> sensorUnit  = (Map<String, Object>) sensorUnits.get(sensorKey);
            String rules = sensorUnit.get("rules").toString();
            rules = rules.replace("d", "").replace("{0}", "sensorKeyValue");
            rules = rules.replace("d", "").replace("{0}", "value");
            Expression expression = AviatorEvaluator.compile(rules);
            Map<String, Object> env = new HashMap<String, Object>();
            env.put("value", Double.valueOf(sensorKeyValue.toString()));
@@ -376,4 +380,38 @@
      
      return returnMap;
   }
   @Override
   public Map<String, Object> getMointorPointRankByOrganizationId(Map<String, Object> parameters) {
      //获取组织id
      String organizationId = parameters.get("organization_id").toString();
      //声明一个集合存放要查询站点数据的组织id
      List<Object> organizationIdList = new ArrayList<>();
      organizationIdList.add(organizationId);
      //声明一个集合存放父组织id
      List<Object> parentIdList = new ArrayList<>();
      parentIdList.add(organizationId);
      //进行循环
      for(int i=0;i<10;i++) {
         if(!parentIdList.isEmpty()) {
            //或去该组织下的子组织
            System.out.println("parentIdList:"+parentIdList);
            List<Map<String, Object>> childIdList = organizationRelationMapper.getChildIdByParentId(parentIdList);
            //清空父组织id集合
            parentIdList.clear();
            System.out.println("childIdList:"+childIdList);
            //将子组织id放入到集合中
            for (Map<String, Object> map : childIdList) {
               organizationIdList.add(map.get("child_id"));
               parentIdList.add(map.get("child_id"));
            }
         }else {
            break;
         }
      }
      System.out.println(organizationIdList);
      return null;
   }
}