fengxiang
2018-09-27 243e009a18d738543baab77b107dea475cf2e8bd
src/main/java/com/moral/controller/ScreenController.java
@@ -10,6 +10,7 @@
import javax.servlet.http.HttpServletRequest;
import com.alibaba.fastjson.*;
import com.moral.common.util.BeanUtils;
import com.moral.common.util.ParameterUtils;
import com.moral.common.util.StringUtils;
import com.moral.entity.*;
@@ -106,6 +107,13 @@
    private  OrganizationService organizationService;
   @Resource
    private  DictionaryDataService dictionaryDataService;
   @Resource
   private WeatherService weatherService;
   @Resource
   private QualityDailyService qualityDailyService;
   /**
    * Screen login. 大屏登录
    * 
@@ -128,21 +136,29 @@
                StringBuilder areaNamesBuilder = new StringBuilder("中国");
                if(!((Integer) orgId).equals(dictionaryDataService.querySupperOrgId())) {
                    Organization organization = organizationService.getOrganizationById((Integer) orgId);
                    if(organization.getAreaNames()!=null){
                        AreaNames areaNames =  organization.getAreaNames();
                        if(!StringUtils.isNullOrEmpty(areaNames.getProvinceName())){
                            areaNamesBuilder.append("/");
                            areaNamesBuilder.append(areaNames.getProvinceName());
                            if(!StringUtils.isNullOrEmpty(areaNames.getCityName())){
                                areaNamesBuilder.append("/");
                                areaNamesBuilder.append(areaNames.getCityName());
                                if(!StringUtils.isNullOrEmpty(areaNames.getAreaName())){
                                    areaNamesBuilder.append("/");
                                    areaNamesBuilder.append(areaNames.getAreaName());
                                }
                            }
                        }
                    }
                  if(organization.getAreaNames()!=null){
                     Map<String,String> areaNameMap = BeanUtils.beanToMap(organization.getAreaNames());
                     List<String> names = areaNameMap.entrySet().stream().filter(item -> {
                        return item.getValue()!=null;
                     }).map(item -> {
                        return  item.getValue();
                     }).collect(Collectors.toList());
                     AreaNames areaNames =  organization.getAreaNames();
                     areaNamesBuilder.append("/");
                     areaNamesBuilder.append(String.join("/",names));
                  }
               // 企业用户
               if( 0 == organization.getRank()) {
                  resultMap.put("type","enterprise");
                    }else{
                  resultMap.put("type","government");
               }
               resultMap.put("areaCode",
                     organization.getVillageCode()|
                     organization.getTownCode()|
                     organization.getAreaCode()*1000000|
                     organization.getCityCode()*1000000|
                     organization.getProvinceCode()*1000000);
                }
                resultMap.put("mapPath",areaNamesBuilder.toString());
            }
@@ -415,7 +431,7 @@
    * @return
    */
   @RequestMapping(value = "/map-page", method = RequestMethod.GET)
   public ModelAndView map(ModelAndView model, @RequestParam("areaCode")int code, @RequestParam("accountId")int accountId){
   public ModelAndView map(ModelAndView model, @RequestParam("areaCode")long code, @RequestParam("accountId")int accountId){
      Account account = accountService.getAccountById(accountId);
      String regionName = areaService.queryFullNameByCode(code);
      if(account!=null&&regionName!=null){
@@ -547,7 +563,8 @@
   @GetMapping("report_alarm_datas")
   public ResultBean<List<Map<String, Object>>> getAlarmData(HttpServletRequest request) throws Exception {
      Map<String, Object> parameters = getParametersStartingWith(request, null);
      parameters.put("type", "month");
      ParameterUtils.getTimeType4Time(parameters);
      //parameters.put("type", "month");
      String sensorKey = "list";
      if (ObjectUtils.isEmpty(parameters.get("sensorKey"))) {
         parameters.put("description", "description");
@@ -698,4 +715,40 @@
        result.put("device",deviceSummary);
        return new ResultBean<>(result);
   }
   @GetMapping("weather")
   @ApiOperation(value = "获取区域天气情况", notes = "获取区域天气情况")
   @ApiImplicitParams(value = {
         @ApiImplicitParam(name = "organizationId",defaultValue = "5", value = "登录账号的组织id", required = true, paramType = "query", dataType = "String")
   })
   public ResultBean<Map<String, Object>> getWeatherDataByRegion(HttpServletRequest request) throws Exception {
      Map<String, Object> parameters = getParametersStartingWith(request, null);
      Map<String, Object> map = weatherService.getWeatherDataByRegion(parameters);
      return new ResultBean<Map<String,Object>>(map);
   }
   @GetMapping("actual")
   @ApiOperation(value = "获取监测因子实时最大值", notes = "获取监测因子实时最大值")
   @ApiImplicitParams(value = {
         @ApiImplicitParam(name = "accountId",defaultValue = "1", value = "登录账号的id", required = true, paramType = "query", dataType = "String"),
         @ApiImplicitParam(name = "sensorKey",defaultValue = "e1,e2,e3", value = "传感器key,如有多个用逗号分隔", required = true, paramType = "query", dataType = "String"),
         @ApiImplicitParam(name = "time",defaultValue = "", value = "时间(long类型时间)", required = false, paramType = "query", dataType = "String"),
         @ApiImplicitParam(name = "interval",defaultValue = "30", value = "时间间隔(秒)", required = true, paramType = "query", dataType = "Integer"),
   })
   public ResultBean<Map<String, Object>> getActualDataByRegion(HttpServletRequest request) throws Exception {
      Map<String, Object> parameters = getParametersStartingWith(request, null);
      Map<String, Object> map = historyService.getActualDataByRegion(parameters);
      return new ResultBean<Map<String, Object>>(map);
   }
   @GetMapping("quality")
   @ApiOperation(value = "获取优良天数", notes = "获取优良天数")
   @ApiImplicitParams(value = {
         @ApiImplicitParam(name = "organizationId",defaultValue = "5", value = "登录账号的组织id", required = true, paramType = "query", dataType = "String")
   })
   public ResultBean<Map<String, Object>> getQualityCountDayByRegion(HttpServletRequest request) throws Exception {
      Map<String, Object> parameters = getParametersStartingWith(request, null);
      Map<String, Object> map = qualityDailyService.getQualityCountDayByRegion(parameters);
      return new ResultBean<Map<String, Object>>(map);
   }
}