| | |
| | | return new ResultBean<List<MonitorPoint>>(monitorPoints);
|
| | | }
|
| | |
|
| | |
|
| | | @GetMapping("devices-state")
|
| | | @ApiOperation(value = "刷新设备状态", notes = "刷新设备状态")
|
| | | @ApiImplicitParams(value = {
|
| | | @ApiImplicitParam(name = "organizationId",defaultValue = "8", value = "登录账号的组织id", required = true, paramType = "query", dataType = "Integer"),
|
| | | @ApiImplicitParam(name = "regionCode",defaultValue = "320583", value = "区域码", required = true, paramType = "query", dataType = "String")
|
| | | })
|
| | | public ResultBean<Collection<Object>> getDevicesStateByRegion(HttpServletRequest request) throws Exception {
|
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
|
| | | Collection<Object> monitorPoints= monitorPointService.getDevicesStateByRegion(parameters);
|
| | | return new ResultBean<Collection<Object>>(monitorPoints);
|
| | | }
|
| | | }
|
| | |
| | | List<Device> getDevicesByProfession(Map<String, Object> parameters);
|
| | |
|
| | | List<Device> getDevicesByOrganizationId(Map<String, Object> parameters);
|
| | | List<Map<String, Object>> getDevicesStateByRegion(Map<String, Object> parameters);
|
| | | } |
| | |
| | | package com.moral.service;
|
| | |
|
| | | import java.util.Collection;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | |
| | | MonitorPoint queryMonitorPointById(Integer mpointId);
|
| | |
|
| | | List<MonitorPoint> getMonitorPointsAndDevicesByRegion(Map<String, Object> parameters);
|
| | |
|
| | | Collection<Object> getDevicesStateByRegion(Map<String, Object> parameters);
|
| | | }
|
| | |
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.Collection;
|
| | | import java.util.HashMap;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | |
| | | }
|
| | | return monitorPoints;
|
| | | }
|
| | |
|
| | | @SuppressWarnings("unchecked")
|
| | | @Override
|
| | | public Collection<Object> getDevicesStateByRegion(Map<String, Object> parameters) {
|
| | | //校验参数
|
| | | Object organizationId = parameters.remove("organizationId");
|
| | | ValidateUtil.notNull(organizationId, "param.is.null");
|
| | | ValidateUtil.notNull(parameters.get("regionCode"), "param.is.null");
|
| | |
|
| | | //组装查询条件
|
| | | ParameterUtils.getRegionType4RegionCode(parameters);
|
| | | |
| | | if (Constants.isNotSpecialOrgId(Integer.valueOf(organizationId.toString()))) {
|
| | | Set<Integer> organizationIds = organizationService.getChildOrganizationIds(Integer.valueOf(organizationId.toString()));
|
| | | parameters.put("orgIds", organizationIds);
|
| | | }
|
| | | List<Map<String, Object>> monitorPoints = deviceMapper.getDevicesStateByRegion(parameters);
|
| | | Map<String, Object> result = new HashMap<String, Object>();
|
| | | Map<String,Object> device;
|
| | | List<Map<String, Object>> devices;
|
| | | for (Map<String, Object> map : monitorPoints) {
|
| | | String id = map.get("id").toString();
|
| | |
|
| | | device = new HashMap<String,Object>();
|
| | | device.put("id", map.remove("deviceId"));
|
| | | device.put("name", map.remove("deviceName"));
|
| | | device.put("state", map.remove("state"));
|
| | | device.put("mac", map.remove("mac"));
|
| | |
|
| | | if (result.containsKey(id)) {
|
| | | Map<String, Object> monitorPoint = (Map<String, Object>) result.get(id);
|
| | | devices = (List<Map<String, Object>>) monitorPoint.get("devices");
|
| | | } else {
|
| | | devices = new ArrayList<Map<String, Object>>();
|
| | | result.put(id, map);
|
| | | }
|
| | | devices.add(device);
|
| | | map.put("devices", devices);
|
| | | result.put(id, map);
|
| | | }
|
| | | |
| | | return result.values();
|
| | | }
|
| | | }
|
| | |
| | | AND mp.is_delete = 0 |
| | | AND mp.organization_id = #{organizationId} |
| | | </select> |
| | | |
| | | |
| | | <select id="getDevicesStateByRegion" resultType="map"> |
| | | SELECT |
| | | d.id deviceId,d.mac,d.state,d.name deviceName, |
| | | mp.id,mp.name |
| | | FROM |
| | | device d , |
| | | monitor_point mp |
| | | <where> |
| | | d.monitor_point_id = mp.id |
| | | AND d.is_delete = 0 |
| | | AND mp.is_delete = 0 |
| | | AND mp.${regionType}_code = #{regionCode} |
| | | <if test="orgIds != null and orgIds.size > 0"> |
| | | AND mp.organization_id IN |
| | | <foreach collection="orgIds" open="(" separator="," close=")" item="listItem"> |
| | | #{listItem} |
| | | </foreach> |
| | | </if> |
| | | </where> |
| | | </select> |
| | | </mapper> |