1 files added
8 files modified
| | |
| | | ResultBean resultBean = new ResultBean(parameters);
|
| | | return resultBean;
|
| | | }
|
| | | |
| | | @GetMapping("mointorPointRank")
|
| | | @ApiOperation(value = "获取站点排名", notes = "获取站点排名")
|
| | | @ApiImplicitParams(value = {
|
| | | @ApiImplicitParam(name = "accountId", value = "账号id", required = true, paramType = "query", dataType = "String")
|
| | | })
|
| | | public ResultBean<Map<String, Object>> getMointorPointRank(HttpServletRequest request){
|
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
|
| | | String id = parameters.get("accountId").toString();
|
| | | Map<String, Object> account = accountService.getOrganizationIdByAccountId(id);
|
| | | //通过组织id来获取站点和设备信息
|
| | | System.out.println(account);
|
| | | historyService.getMointorPointRankByOrganizationId(account);
|
| | | return new ResultBean<Map<String, Object>>(account);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | public interface AccountMapper extends BaseMapper<Account> {
|
| | | List<Map<String, Object>> getRoleNameByAccountId(Integer accountId);
|
| | | Account getByAccountName(String name);
|
| | | Map<String, Object> getOrganizationIdByAccountId(Integer accountId);
|
| | | } |
| | |
| | | package com.moral.mapper;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import org.apache.ibatis.annotations.Param;
|
| | |
|
| | |
|
| | | import com.moral.common.mapper.BaseMapper;
|
| | | import com.moral.entity.OrganizationRelation;
|
| | |
|
| | | public interface OrganizationRelationMapper extends BaseMapper<OrganizationRelation> {
|
| | | |
| | | List<Map<String, Object>> getChildIdByParentId(@Param("parentIdList") List<Object> parentIdList);
|
| | | |
| | | } |
| | |
| | | Optional<Account> queryAccountByName(String accountName);
|
| | |
|
| | | Account companyLogin(Map<String, Object> parameters);
|
| | | |
| | | Map<String, Object> getOrganizationIdByAccountId(String id);
|
| | | }
|
| | |
| | | Map<String, Object> getSensorUnitByDeviceMac(Map<String, Object> parameters);
|
| | |
|
| | | Map<String, Object> gitHourlyAQIByMacAndTimeslot(Map<String, Object> parameters);
|
| | | |
| | | Map<String, Object> getMointorPointRankByOrganizationId(Map<String, Object> parameters);
|
| | |
|
| | | }
|
| | |
| | | account.setPassword(parameters.get("password").toString());
|
| | | return account;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Map<String, Object> getOrganizationIdByAccountId(String id) {
|
| | | Integer accountId = Integer.parseInt(id);
|
| | | Map<String, Object> map = accountMapper.getOrganizationIdByAccountId(accountId);
|
| | | return map;
|
| | | }
|
| | | }
|
| | |
| | | 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;
|
| | |
| | |
|
| | | @Resource
|
| | | private ProfessionService professionService;
|
| | | |
| | | @Resource
|
| | | private OrganizationRelationMapper organizationRelationMapper;
|
| | |
|
| | | @Override
|
| | | public Map<String, Object> getAllSensorAverageByDevice(Map<String, Object> parameters) throws Exception {
|
| | |
| | |
|
| | | 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;
|
| | | }
|
| | | }
|
| | |
| | | ar.role_id = r.id |
| | | AND ar.account_id = #{accountId} |
| | | </select> |
| | | |
| | | <select id="getOrganizationIdByAccountId" resultType="java.util.Map"> |
| | | SELECT organization_id |
| | | FROM account |
| | | WHERE id=#{id} |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.moral.mapper.OrganizationRelationMapper"> |
| | | <select id="getChildIdByParentId" resultType="java.util.Map"> |
| | | SELECT child_id |
| | | FROM organization_relation |
| | | WHERE parent_id IN |
| | | <foreach collection="parentIdList" index="index" item="parentId" open="(" separator="," close=")"> |
| | | #{parentId} |
| | | </foreach> |
| | | </select> |
| | | </mapper> |