1 files added
19 files modified
| | |
| | | import java.lang.reflect.Array; |
| | | import java.text.DateFormat; |
| | | import java.text.DecimalFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | |
| | | |
| | | import com.rabbitmq.client.*; |
| | | import com.rabbitmq.client.Channel; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.models.auth.In; |
| | | import jdk.nashorn.internal.runtime.regexp.joni.Regex; |
| | | import net.sf.json.JSONString; |
| | | |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.apache.commons.collections.MapUtils; |
| | | import org.apache.commons.net.ftp.FTPClient; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | import org.xml.sax.InputSource; |
| | | |
| | | import static com.moral.common.util.ResourceUtil.getValue; |
| | | import static com.moral.common.util.WebUtils.getParametersStartingWith; |
| | | import static java.util.Calendar.*; |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | @GetMapping("/contrastFactor") |
| | | @ApiOperation(value = "因子对比", notes = "因子对比") |
| | | @ApiImplicitParams(value = { |
| | |
| | | return alarmData; |
| | | } |
| | | |
| | | @GetMapping("multiDeviceContrast") |
| | | @ApiOperation(value = "多设备因子对比", notes = "多设备因子对比") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "macs", value = "设备mac,如有多个用逗号分隔", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "sensorKey", value = "传感器key", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "time", value = "时间,日期(格式:2018-03-12)", required = true, paramType = "query", dataType = "String"),}) |
| | | public ResultBean<List<Map<String, Object>>> multiDeviceSensor(HttpServletRequest request) throws Exception { |
| | | Map<String, Object> parameters = getParametersStartingWith(request, null); |
| | | ParameterUtils.getTimeType4Time(parameters); |
| | | List<Map<String, Object>> list = historyMinutelyService.getMultiDeviceSensorData(parameters); |
| | | return new ResultBean<List<Map<String, Object>>>(list); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/tellAlarm") |
| | | @ResponseBody |
| | | public List<List> tellAlarm(@Param("states") String states, |
| | | @Param("orgId") String orgId, |
| | | @Param("accountId") String accountId, |
| | | @Param("states1") String states1, |
| | | @Param("regionCode") String regionCode) { |
| | | JSONArray stateList = JSONArray.parseArray(states);//最新的设备数据 |
| | | JSONArray stateList1 = JSONArray.parseArray(states1);//前10秒的设备数据 |
| | | List<List> lookList = new ArrayList<>(); |
| | | Map params = new HashMap(); |
| | | String lookString = ""; |
| | | //判断前十秒数据和现在数据是否相等,如果不相等进入方法 |
| | | //第一次进入接口前十秒数据为null |
| | | if (stateList1 != null && !states.equals(states1)) { |
| | | List<Map> listDevice = JSONObject.parseArray(stateList.toJSONString(), Map.class); |
| | | List<Map> listDevice1 = JSONObject.parseArray(stateList1.toJSONString(), Map.class); |
| | | //将所有设备放到同一个集合下 |
| | | List<Map> deviceList = new ArrayList<Map>(); |
| | | List<Map> deviceList1 = new ArrayList<Map>(); |
| | | //存放所有组织的id |
| | | List orgList = new ArrayList(); |
| | | for (Map devices : listDevice) { |
| | | int monitorId = Integer.parseInt((String) devices.get("id")); |
| | | MonitorPoint monitorPoint = monitorPointService.byIdGetMonitorPoint(monitorId); |
| | | int org_id = monitorPoint.getOrganizationId(); |
| | | orgList.add(org_id); |
| | | List<Map> devicesList = (List<Map>) devices.get("devices"); |
| | | if (!devicesList.isEmpty()) { |
| | | if (devicesList.size() > 1) { |
| | | for (Map map : devicesList) { |
| | | deviceList.add(map); |
| | | } |
| | | } else { |
| | | deviceList.add((Map) ((List) devices.get("devices")).get(0)); |
| | | } |
| | | } |
| | | } |
| | | for (Map devices1 : listDevice1) { |
| | | int monitorId = Integer.parseInt((String) devices1.get("id")); |
| | | MonitorPoint monitorPoint = monitorPointService.byIdGetMonitorPoint(monitorId); |
| | | int org_id = monitorPoint.getOrganizationId(); |
| | | List<Map> devicesList = (List<Map>) devices1.get("devices"); |
| | | if (!devicesList.isEmpty()) { |
| | | if (devicesList.size() > 1) { |
| | | for (Map map : devicesList) { |
| | | deviceList1.add(map); |
| | | } |
| | | } else { |
| | | deviceList1.add((Map) ((List) devices1.get("devices")).get(0)); |
| | | } |
| | | } |
| | | } |
| | | List<String> macList = new ArrayList<String>(); |
| | | //获得两个时间的设备状态改变的mac号 |
| | | for (Map map : deviceList) { |
| | | String state = (String) map.get("state"); |
| | | String mac = (String) map.get("mac"); |
| | | for (Map map1 : deviceList1) { |
| | | String state1 = (String) map1.get("state"); |
| | | String mac1 = (String) map1.get("mac"); |
| | | if (mac.equals(mac1)) { |
| | | if (Integer.parseInt(state) > Integer.parseInt(state1) && Integer.parseInt(state) != 4 /*&& Integer.parseInt(state1) == 0*/) { |
| | | macList.add(mac + "-" + state + "-" + state1); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //存放不重合的数组 |
| | | LinkedHashSet<Integer> orgS = new LinkedHashSet<Integer>(orgList); |
| | | SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | Date date = new Date(System.currentTimeMillis()); |
| | | Date date1 = new Date(System.currentTimeMillis() - 1000); |
| | | //系统当前时间 |
| | | String time = formatter.format(date); |
| | | //系统当前时间的前一秒 |
| | | String time1 = formatter.format(date1); |
| | | List<Map> alarmList = new ArrayList<Map>(); |
| | | for (Integer org : orgS) { |
| | | int orgNum = alarmConfigService.containOrgId(org); |
| | | Map<String, Object> eMap = new HashMap<String, Object>(); |
| | | if (orgNum == 1) { |
| | | String alarmConfig = alarmConfigService.getValueByOrganizationId(Integer.parseInt(String.valueOf(org))); |
| | | Map hashMap = JSON.parseObject(alarmConfig, HashMap.class); |
| | | Map alarmLevels = (Map) hashMap.get("alarmLevels"); |
| | | //数据库因子表只有106个因子 |
| | | for (int i = 1; i < 106; i++) { |
| | | if (alarmLevels.containsKey("e" + i)) { |
| | | Map map = (Map) alarmLevels.get("e" + i); |
| | | if (!map.isEmpty()) { |
| | | Integer enable = (Integer) map.get("enable"); |
| | | List increment = (List) map.get("increment"); |
| | | if (enable == 1) { |
| | | if (!(increment.get(0).toString().equals("0") && increment.get(1).toString().equals("0"))) { |
| | | eMap.put("e" + i, increment); |
| | | } else { |
| | | continue; |
| | | } |
| | | } else { |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | String defultAlarm = dictionaryDataService.getDefultAlarm(); |
| | | Map hashMap = JSON.parseObject(defultAlarm, HashMap.class); |
| | | Map alarmLevels = (Map) hashMap.get("alarmLevels"); |
| | | //数据库因子表只有106个因子 |
| | | for (int i = 1; i < 106; i++) { |
| | | if (alarmLevels.containsKey("e" + i)) { |
| | | Map map = (Map) alarmLevels.get("e" + i); |
| | | if (!map.isEmpty()) { |
| | | Integer enable = (Integer) map.get("enable"); |
| | | List increment = (List) map.get("increment"); |
| | | if (enable == 1) { |
| | | if (!(increment.get(0).toString().equals("0") && increment.get(1).toString().equals("0"))) { |
| | | eMap.put("e" + i, increment); |
| | | } else { |
| | | continue; |
| | | } |
| | | } else { |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | Map map = new HashMap(); |
| | | map.put("eMap", eMap); |
| | | map.put("org", org); |
| | | alarmList.add(map); |
| | | } |
| | | for (Map aEMap : alarmList) { |
| | | List<Map> values = new ArrayList<Map>(); |
| | | if (macList.size() > 0) { |
| | | for (String sMac : macList) { |
| | | String[] aMac = sMac.split("-"); |
| | | String mac = aMac[0]; |
| | | //因为数据库数据是两秒钟插入一条,所以通过两个时间区间获取一条数据,防止一个时间获取数据为空的情况 |
| | | String value = historyService.getValueByMacAndTime(mac, time, time1); |
| | | Map<String, String> map = new HashMap<String, String>(); |
| | | if (value == null) { |
| | | Date date2 = new Date(System.currentTimeMillis() - 2000); |
| | | //系统当前时间的前两秒 |
| | | String time2 = formatter.format(date1); |
| | | value = historyService.getValueByMacAndTime(mac, time, time2); |
| | | if (value == null) { |
| | | Date date3 = new Date(System.currentTimeMillis() - 3000); |
| | | //系统当前时间的前三秒 |
| | | String time3 = formatter.format(date1); |
| | | value = historyService.getValueByMacAndTime(mac, time, time3); |
| | | } |
| | | } |
| | | if (value != null) { |
| | | map.put("mac", mac); |
| | | map.put("value", value); |
| | | map.put("state", aMac[1]); |
| | | map.put("state1", aMac[2]); |
| | | values.add(map); |
| | | } else { |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (values.size() > 0 && values.size() == macList.size()) { |
| | | for (Map dataMap : values) { |
| | | String oId = deviceService.byMacGetOrgId((String) dataMap.get("mac")); |
| | | if (!(aEMap.get("org").toString()).equals(oId)) { |
| | | continue; |
| | | } |
| | | List<String> list = new ArrayList<String>(); |
| | | Map sensorMap = JSONObject.parseObject((String) dataMap.get("value")); |
| | | Iterator<String> iter = sensorMap.keySet().iterator(); |
| | | while (iter.hasNext()) { |
| | | String key = iter.next(); |
| | | list.add(key); |
| | | } |
| | | String state = (String) dataMap.get("state"); |
| | | String state1 = (String) dataMap.get("state1"); |
| | | List<Map> mapList=new ArrayList(); |
| | | for (String key : list) { |
| | | if (((Map) aEMap.get("eMap")).containsKey(key)) { |
| | | Double val = Double.valueOf(sensorMap.get(key).toString()); |
| | | List valueList = (List) ((Map) aEMap.get("eMap")).get(key); |
| | | Device device = deviceService.byMacGetDevice((String) dataMap.get("mac")); |
| | | Map<String, Object> sensors = sensorService.getSensorBySensorKey(key); |
| | | if (key.equals("e1") || key.equals("e2") || key.equals("e10") || key.equals("e11") || key.equals("e15") || key.equals("e16")) { |
| | | //判断六参因子超标 |
| | | if ((state1.equals("0") || state1.equals("1")) && Integer.parseInt(state) > 1) { |
| | | if (val > Double.valueOf(String.valueOf(valueList.get(1)))) { |
| | | Map lookMap = new HashMap(); |
| | | lookMap.put("time",time); |
| | | lookMap.put("name",device.getName()); |
| | | lookMap.put("sensor",sensors.get("description")); |
| | | lookMap.put("value",val + ""+sensors.get("unit")); |
| | | mapList.add(lookMap); |
| | | //lookString = time+" "+device.getName()+sensors.get("description")+"="+val + sensors.get("unit")+"超标"; |
| | | //System.out.println(time + "====" + device.getName() + "=====" + sensors.get("description") + "======" + val + sensors.get("unit")); |
| | | } |
| | | } |
| | | }else {//判断非六参因子超标 |
| | | if (state1.equals("0")) { |
| | | if (val > Double.valueOf(String.valueOf(valueList.get(0)))) { |
| | | Map lookMap = new HashMap(); |
| | | lookMap.put("time",time); |
| | | lookMap.put("name",device.getName()); |
| | | lookMap.put("sensor",sensors.get("description")); |
| | | lookMap.put("value",val + ""+sensors.get("unit")); |
| | | mapList.add(lookMap); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | if (mapList.size()>0){ |
| | | lookList.add(mapList); |
| | | }else { |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return lookList; |
| | | } |
| | | |
| | | /* @GetMapping("/lianxian") |
| | | @ApiOperation(value = "连线", notes = "连线" ) |
| | | @GetMapping("multiDeviceContrast") |
| | | @ApiOperation(value = "多设备因子对比", notes = "多设备因子对比") |
| | | @ApiImplicitParams(value = { |
| | |
| | | List<Map<String, Object>> list = historyMinutelyService.getDevicesSensorsToExcel(parameters); |
| | | return new ResultBean<List<Map<String, Object>>>(list); |
| | | } |
| | | } |
| | | } |
| | |
| | | import java.util.Map; |
| | | |
| | | import com.moral.entity.alarm.AlarmConfig; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | public interface AlarmConfigMapper { |
| | | int deleteByPrimaryKey(Integer id); |
| | |
| | | AlarmConfig selectByMonitorPointId(Integer mpId); |
| | | |
| | | AlarmConfig selectByDeviceMac(String mac); |
| | | |
| | | public String getValueByOrganizationId(@Param("organizationId") int organizationId); |
| | | |
| | | int containOrgId(@Param("orgId")Integer orgId); |
| | | } |
| | |
| | | import org.apache.ibatis.annotations.Param;
|
| | | import tk.mybatis.mapper.entity.Example;
|
| | |
|
| | | public interface DeviceMapper extends BaseMapper<Device>{
|
| | | public interface DeviceMapper extends BaseMapper<Device> {
|
| | |
|
| | | List<Map<String, Object>> getDeviceStatesByAccount(Map<String, Object> parameters);
|
| | | List<Device> selectWithRelationData(Example example);
|
| | | List<Map<String, Object>> getSensorsByDevice(@Param("mac")String mac);
|
| | | List<String> getDeviceMacByMonitorPointAndDeviceVersion(@Param("monitorPointId")Integer monitorPointId,@Param("deviceVersionId")Integer deviceVersionId);
|
| | | List<Map<String, Object>> getDeviceStatesByAccount(Map<String, Object> parameters);
|
| | |
|
| | | List<Map<String, Object>> getDeviceVersionIdByMonitorPoint(Integer monitorPointId);
|
| | | List<Device> selectWithRelationData(Example example);
|
| | |
|
| | | List<Device> selectByOrgIdAndDevName(@Param("orgId")Integer orgId, @Param("orgIds")List<Integer> orgIds,@Param("devState") String state,@Param("name")String name);
|
| | | List<Map<String, Object>> getSensorsByDevice(@Param("mac") String mac);
|
| | |
|
| | | /**
|
| | | *
|
| | | * @param orgId
|
| | | * @param mpId
|
| | | * @return 返回未删除结果
|
| | | */
|
| | | List<Device> selectByOrgIdAndMpId(@Param("orgId")Integer orgId,@Param("orgIds")List<Integer> orgIds,@Param("mpId")Integer mpId);
|
| | | List<Device> selectByMap(Map<String, Object> params);
|
| | | Device selectWithOrgIdsByMac(String mac);
|
| | | List<Integer> getDeviceVersionIdByAreaCode(Map<String, Object> parameters);
|
| | | Integer getDeviceCountByRegion(Map<String, Object> parameters);
|
| | | List<Map> countByTimes(@Param("start")Date start,@Param("end")Date end,@Param("format")String format);
|
| | | List<String> getDeviceMacByMonitorPointAndDeviceVersion(@Param("monitorPointId") Integer monitorPointId, @Param("deviceVersionId") Integer deviceVersionId);
|
| | |
|
| | | List<Device> getDevicesByProfession(Map<String, Object> parameters);
|
| | | List<Map<String, Object>> getDeviceVersionIdByMonitorPoint(Integer monitorPointId);
|
| | |
|
| | | List<Device> getDevicesByOrganizationId(Map<String, Object> parameters);
|
| | | List<Map<String, Object>> getDevicesStateByRegion(Map<String, Object> parameters);
|
| | | List<Device> selectByOrgIdAndDevName(@Param("orgId") Integer orgId, @Param("orgIds") List<Integer> orgIds, @Param("devState") String state, @Param("name") String name);
|
| | |
|
| | | List<Device> getDeviceList(Example example);
|
| | | String getLimitDataByDevice(Map<String, Object> parameters);
|
| | | /**
|
| | | * @param orgId
|
| | | * @param mpId
|
| | | * @return 返回未删除结果
|
| | | */
|
| | | List<Device> selectByOrgIdAndMpId(@Param("orgId") Integer orgId, @Param("orgIds") List<Integer> orgIds, @Param("mpId") Integer mpId);
|
| | |
|
| | | List<Device> selectByMap(Map<String, Object> params);
|
| | |
|
| | | Device selectWithOrgIdsByMac(String mac);
|
| | |
|
| | | List<Integer> getDeviceVersionIdByAreaCode(Map<String, Object> parameters);
|
| | |
|
| | | Integer getDeviceCountByRegion(Map<String, Object> parameters);
|
| | |
|
| | | List<Map> countByTimes(@Param("start") Date start, @Param("end") Date end, @Param("format") String format);
|
| | |
|
| | | List<Device> getDevicesByProfession(Map<String, Object> parameters);
|
| | |
|
| | | List<Device> getDevicesByOrganizationId(Map<String, Object> parameters);
|
| | |
|
| | | List<Map<String, Object>> getDevicesStateByRegion(Map<String, Object> parameters);
|
| | |
|
| | | List<Device> getDeviceList(Example example);
|
| | |
|
| | | String getLimitDataByDevice(Map<String, Object> parameters);
|
| | |
|
| | | List<String> getMacsByOrganizationId(@Param("organizationIdList") List<Object> organizationIdList);
|
| | |
|
| | | List<Device> getDeviceById1(@Param("id") int id);
|
| | | List<Device> getDeviceById1(@Param("id") int id);
|
| | |
|
| | | //获取厂界设备
|
| | | List<Device> getDeviceById2(@Param("id") int id);
|
| | | //获取厂界设备
|
| | | List<Device> getDeviceById2(@Param("id") int id);
|
| | |
|
| | | List<Device> getDeviceById3(@Param("id") int id);
|
| | | List<Device> getDeviceById3(@Param("id") int id);
|
| | |
|
| | | List<Integer> getHasWindDirAndWindSpeedDeviceVersion();
|
| | | List<Integer> getHasWindDirAndWindSpeedDeviceVersion();
|
| | |
|
| | | List<Device> selectDevicesAll(Map<String, Object> params);
|
| | | List<Device> selectDevicesAll(Map<String, Object> params);
|
| | |
|
| | | List<DeviceAndWind> getAllDevice();
|
| | | List<DeviceAndWind> getAllDevice();
|
| | |
|
| | | List<String> getAllMac();
|
| | | List<String> getAllMac();
|
| | |
|
| | | Device byMacGetDevice(@Param("mac") String mac);
|
| | | Device byMacGetDevice(@Param("mac") String mac);
|
| | |
|
| | | DeviceAndWind getDeviceAndWindByMac(@Param("mac") String mac,@Param("time") String time,
|
| | | @Param("table") String table);
|
| | | DeviceAndWind getDeviceAndWindByMac(@Param("mac") String mac, @Param("time") String time,
|
| | | @Param("table") String table);
|
| | |
|
| | | List<DeviceAndWind> byMonitorIdGetDeviceAndWind(@Param("id") int id,@Param("time") String time, @Param("table") String table);
|
| | | DeviceAndWind byMacGetDeviceAndWind(@Param("mac") String mac,@Param("time") String time, @Param("table") String table);
|
| | | List<DeviceAndWind> byMonitorIdGetDeviceAndWind(@Param("id") int id, @Param("time") String time, @Param("table") String table);
|
| | |
|
| | | List<String> getMacsByMonitorPointIds(List<Integer> list);
|
| | | DeviceAndWind byMacGetDeviceAndWind(@Param("mac") String mac, @Param("time") String time, @Param("table") String table);
|
| | |
|
| | | Map<String, Object> selectAllFieldByMac(Map<String, Object> params);
|
| | | List<String> getMacsByMonitorPointIds(List<Integer> list);
|
| | |
|
| | | List getDeviceByCode(Map<String, Object> params);
|
| | | Map<String, Object> selectAllFieldByMac(Map<String, Object> params);
|
| | |
|
| | | List getDeviceByCode(Map<String, Object> params);
|
| | |
|
| | | List<Device> getDeviceByCodeAndId(@Param("code") String code, @Param("id") String id);
|
| | |
|
| | | String byMacGetOrgId(String mac);
|
| | | } |
| | |
| | | public interface DictionaryDataMapper extends BaseMapper<DictionaryData> { |
| | | public Integer selectSupperOrgId(); |
| | | public boolean isSupperOrgId(Integer orgId); |
| | | String getDefultAlarm(); |
| | | } |
| | |
| | |
|
| | | public interface HistoryMapper{
|
| | | String selectValueByMacAndTime(@Param("mac")String mac, @Param("time")Date time);
|
| | | String getValueByMacAndTime(@Param("mac")String mac, @Param("time")String time,@Param("time1")String time1);
|
| | | List<Map<String, Object>> getAreaAllDataByAccount(Map<String, Object> parameters);
|
| | |
|
| | | List<Map<String, Object>> getRegionRankingData(Map<String, Object> parameters);
|
| | |
| | | public interface AlarmConfigService { |
| | | public Optional<AlarmConfig> queryValueByOrganizationId(int organizationId); |
| | | public Optional<AlarmConfig> queryByOrganizationId(int organizationId); |
| | | public String getValueByOrganizationId(int organizationId); |
| | | public Optional<AlarmConfig> queryByMonitorPointId(int mpId); |
| | | public AlarmConfigValue getDefaultAlarmConfigValue(); |
| | | |
| | |
| | | |
| | | void addOrModify(AlarmConfig alarmConfig); |
| | | |
| | | int containOrgId(Integer orgId); |
| | | } |
| | |
| | | List<DeviceAndWind> byMonitorIdGetDeviceAndWind(String id,String time,String tab);
|
| | | List<DeviceAndWind> byMonitorIdGetDeviceAndWindSpecial(String id,String time,String tab);
|
| | |
|
| | | List<Device> getDeviceByCodeAndId(String code,String id);
|
| | |
|
| | | String byMacGetOrgId(String mac);
|
| | | }
|
| | |
| | | List<DictionaryData> queryByKey(String dictDataKey); |
| | | |
| | | Integer querySupperOrgId(); |
| | | |
| | | String getDefultAlarm(); |
| | | } |
| | |
| | |
|
| | | String queryValueByMacAndTime(String mac, Date time);
|
| | |
|
| | | String getValueByMacAndTime(String mac, String time,String time1);
|
| | |
|
| | | List<Map<String, Object>> getRegionRankingData(Map<String, Object> parameters);
|
| | |
|
| | | List<Map<String, Object>> getSensorsDataByDevice(Map<String, Object> parameters);
|
| | |
| | | } |
| | | |
| | | @Override |
| | | public String getValueByOrganizationId(int organizationId) { |
| | | return alarmConfigMapper.getValueByOrganizationId(organizationId); |
| | | } |
| | | |
| | | @Override |
| | | public Optional<AlarmConfig> queryByMonitorPointId(int mpId) { |
| | | AlarmConfig alarmConfig = alarmConfigMapper.selectByMonitorPointId(mpId); |
| | | if(alarmConfig==null){ |
| | |
| | | throw ex; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int containOrgId(Integer orgId) { |
| | | return alarmConfigMapper.containOrgId(orgId); |
| | | } |
| | | |
| | | public AlarmConfigValue simplifyAlarmConfigValue(AlarmConfigValue value){ |
| | | Map<String,AlarmSensorLevel> alarmSensorLevelMap = value.getAlarmLevels(); |
| | | List<String> cleanKeys = new ArrayList<>(); |
| | |
| | | Integer orgId = Integer.parseInt(orgIdObj.toString());
|
| | | List<Integer> orgIds = orgMapper.selectLowerOrgIds(orgId);
|
| | | params.put("orgIds", orgIds);
|
| | | System.out.println(params);
|
| | | deviceList = deviceMapper.selectByMap(params);
|
| | | // loadDeviceState(deviceList);
|
| | | }
|
| | |
| | | if (tvoc==null){
|
| | | tvoc=0.0;
|
| | | }
|
| | | Double dir = (270.0 - windDir * Math.PI / 180.0);
|
| | | Double dir = (270.0 + windDir * Math.PI / 180.0);
|
| | |
|
| | | U = windSpeed * Math.cos(dir);
|
| | | V = windSpeed * Math.sin(dir);
|
| | |
| | | return list;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Device> getDeviceByCodeAndId(String code, String id) {
|
| | | return deviceMapper.getDeviceByCodeAndId(code,id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String byMacGetOrgId(String mac) {
|
| | | return deviceMapper.byMacGetOrgId(mac);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | public Integer querySupperOrgId() { |
| | | return dataMapper.selectSupperOrgId(); |
| | | } |
| | | |
| | | @Override |
| | | public String getDefultAlarm() { |
| | | return dataMapper.getDefultAlarm(); |
| | | } |
| | | } |
| | |
| | | public String queryValueByMacAndTime(String mac, Date time) {
|
| | | return historyMapper.selectValueByMacAndTime(mac, time);
|
| | | }
|
| | |
|
| | | public String getValueByMacAndTime(String mac, String time,String time1) {
|
| | | return historyMapper.getValueByMacAndTime(mac, time,time1);
|
| | | }
|
| | | @Override
|
| | | public List<Map<String, Object>> getRegionRankingData(Map<String, Object> parameters) {
|
| | | ValidateUtil.notNull(parameters.get("regionCode"), "param.is.null");
|
| | |
| | | where dev.mac = #{mac,jdbcType=VARCHAR} |
| | | limit 0,1 |
| | | </select> |
| | | <select id="getValueByOrganizationId" resultType="java.lang.String"> |
| | | select `value` |
| | | from alarm_config |
| | | where organization_id = #{organizationId,jdbcType=INTEGER} |
| | | limit 0,1 |
| | | </select> |
| | | <select id="containOrgId" resultType="java.lang.Integer"> |
| | | select COUNT(*) from alarm_config where id=#{orgId} |
| | | </select> |
| | | </mapper> |
| | |
| | | </select> |
| | | |
| | | <select id="selectDevicesAll" parameterType="java.util.Map" resultType="com.moral.entity.Device"> |
| | | SELECT dev.name,dev.address,dev.id,dev.state,dev.mac,dev.longitude,dev.latitude,dev.device_version_id deviceVersionId from device dev |
| | | SELECT dev.name,dev.address,dev.id,dev.state,dev.mac,dev.longitude,dev.latitude,dev.device_version_id |
| | | deviceVersionId from device dev |
| | | left join monitor_point mpt on dev.monitor_point_id = mpt.id |
| | | <where> |
| | | <if test="@com.moral.common.bean.Constants@isNotSpecialOrgId(orgId)"> |
| | |
| | | where d.mac=h.mac and h.time=#{time} |
| | | and d.mac=#{mac} |
| | | </select> |
| | | <select id="getDeviceByCodeAndId" resultType="com.moral.entity.Device" resultMap="BaseResultMap"> |
| | | select * from device where monitor_point_id in( |
| | | SELECT mpt.id |
| | | FROM monitor_point mpt,organization org |
| | | where mpt.organization_id=org.id |
| | | and org.id=#{id} |
| | | ) |
| | | </select> |
| | | <select id="byMacGetOrgId" resultType="java.lang.String"> |
| | | SELECT organization_id FROM `monitor_point` as mt ,device as d where d.monitor_point_id=mt.id and mac=#{mac} |
| | | </select> |
| | | </mapper> |
| | |
| | | select count(*) from dictionary_data |
| | | where dict_data_key = 'auth_config_super_org' and dict_data_value = #{orgId,jdbcType=INTEGER} |
| | | </select> |
| | | <select id="getDefultAlarm" resultType="java.lang.String"> |
| | | select dict_data_value from dictionary_data |
| | | where dict_data_key = 'default_alarm_config_value' |
| | | </select> |
| | | </mapper> |
| | |
| | | select `json` from ${table}
|
| | | where time = #{time} and mac = #{mac}
|
| | | </select>
|
| | | <select id="getValueByMacAndTime" resultType="java.lang.String">
|
| | | select `value` from history
|
| | | where mac = #{mac} and time >= #{time1} and time <=#{time}
|
| | | limit 0,1
|
| | | </select>
|
| | |
|
| | | </mapper> |
| | |
| | | }) |
| | | } |
| | | |
| | | |
| | | moralMap.WindMarker = function (option, moralMap) { |
| | | var _option = option; |
| | | var _pointObj = new BMap.Point(_option['longitude'], _option['latitude']); |
| | | var _iconObj = _getWindIcon(1); |
| | | var _iconObj = _getWindIcon(0); |
| | | this._point = _pointObj; |
| | | |
| | | function _getWindIcon(speedLevel) { |
| | | speedLevel = speedLevel == null ? 0 : speedLevel; |
| | | var windIcon = _option["windIcon"]; |
| | | var windUrl = windIcon["url"] + speedLevel + ".png"; |
| | | |
| | | return new BMap.Icon(windUrl, new BMap.Size(windIcon["width"], windIcon["height"]), { |
| | | imageSize: new BMap.Size(windIcon["width"], windIcon["height"]) |
| | | }); |
| | |
| | | offset: new BMap.Size(0, -11), |
| | | enableMassClear: true |
| | | }) |
| | | |
| | | |
| | | return $.extend(this, { |
| | | refreshWindDir: function (windDir, windSpeed) { |
| | | //状态发生变化的时候设置图标风向 |
| | |
| | | if (speedLevel == 0) { |
| | | moralMap.removeOverlay(this); |
| | | } else { |
| | | moralMap.addOverlay(this); |
| | | var iconObj = _getWindIcon(speedLevel); |
| | | this.setIcon(iconObj); |
| | | this.setRotation(windDir); |
| | |
| | | }, |
| | | setOption: function (option) { |
| | | _option = option; |
| | | } |
| | | }, |
| | | |
| | | }) |
| | | |
| | | } |
| | |
| | | |
| | | var deviceStates; |
| | | var monitorPointStates; |
| | | moralMap.refreshState = function (states) { |
| | | moralMap.refreshState = function (states, orgId, regionCode, accountId) { |
| | | var state = JSON.stringify(states); |
| | | var state1 = $(".pp2").html() |
| | | var paramMap = {}; |
| | | var abc = ''; |
| | | paramMap["orgId"] = orgId; |
| | | paramMap["regionCode"] = regionCode; |
| | | paramMap["accountId"] = accountId; |
| | | paramMap["states"] = state; |
| | | paramMap["states1"] = state1; |
| | | $.ajax({ |
| | | url: "/screen/tellAlarm", |
| | | type: "get", |
| | | dataType: "json", |
| | | data: paramMap, |
| | | success: function (info) { |
| | | var alarm = JSON.parse(JSON.stringify(info)); |
| | | if (alarm.length > 0) { |
| | | $("#box").attr("style", "display:block;");//显示div |
| | | $("#tou").attr("style", "display:block;color: #d9534f;font-size: 20px;");//显示div |
| | | for (var i = 0; i < alarm.length; i++) { |
| | | var text = "<span style='line-height: 25px><p style='line-height: 25px'>"; |
| | | var lookString = alarm[i][0]["time"] + " " + alarm[i][0]["name"]; |
| | | for (var j = 0; j < alarm[i].length; j++) { |
| | | var value = ""; |
| | | if (alarm[i].length > 1) { |
| | | if (j == 0) { |
| | | value = alarm[i][j]["sensor"] + "=" + alarm[i][j]["value"]; |
| | | lookString = lookString + value; |
| | | } else { |
| | | value = alarm[i][j]["sensor"] + "=" + alarm[i][j]["value"]; |
| | | lookString = lookString + "," + value; |
| | | } |
| | | } else { |
| | | value = alarm[i][j]["sensor"] + "=" + alarm[i][j]["value"]; |
| | | lookString = lookString + value; |
| | | } |
| | | text = text + lookString + "超标" + "</p><hr></hr></span>"; |
| | | $("#box1").prepend(text); |
| | | } |
| | | |
| | | } |
| | | for (var j = 0; j < $("#box1").children("span").length; j++) { |
| | | if ($("#box1").children("span").length > 50) { |
| | | $("#box1 span:last").remove() ; |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | }) |
| | | state1 = $(".pp2").html(state); |
| | | monitorPointStates = states; |
| | | deviceStates = []; |
| | | for (var i in states) { |
New file |
| | |
| | | <%@ page contentType="text/html;charset=UTF-8" language="java" %> |
| | | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> |
| | | <%@page isELIgnored="false" %> |
| | | |
| | | <!DOCTYPE html> |
| | | <html> |
| | | <head> |
| | | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> |
| | | <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/> |
| | | <style type="text/css"> |
| | | body, html, #allmap { |
| | | width: 100%; |
| | | height: 100%; |
| | | overflow: hidden; |
| | | margin: 0; |
| | | font-family: "微软雅黑"; |
| | | } |
| | | #box { |
| | | width:300px; |
| | | height:400px; |
| | | top:30px; |
| | | right:30px; |
| | | position:absolute; |
| | | z-index:1; |
| | | border:2px solid red; |
| | | background-color:gainsboro; |
| | | opacity: 0.8; |
| | | } |
| | | #cpm,#cpm1{ |
| | | width: 300px; |
| | | height: 100px; |
| | | position: absolute; |
| | | background-color: #ffffff; |
| | | display: none; |
| | | left: 50%; |
| | | top: 50%; |
| | | margin-left: -150px; |
| | | margin-top: -50px; |
| | | z-index: 11; |
| | | color: #000000; |
| | | border: 2px solid #FF7F50; |
| | | font-size: 14px; |
| | | line-height: 100px; |
| | | text-align: center; |
| | | } |
| | | </style> |
| | | <script type="text/javascript" |
| | | src="http://api.map.baidu.com/api?v=2.0&ak=rER1sgBIcQxkfNSlm2wmBGZGgEERrooM"></script> |
| | | <script type="text/javascript" src="/js/jquery.min.js"></script> |
| | | <script type="text/javascript" src="/js/utils.js"></script> |
| | | <script type="text/javascript"> |
| | | if (typeof (JSON) == 'undefined') { |
| | | $.getScript("js/json2.js"); |
| | | } |
| | | </script> |
| | | <script type="text/javascript" src="/js/paging.js"></script> |
| | | <title>地图展示</title> |
| | | </head> |
| | | <body> |
| | | <div id="allmap" style="z-index: 0" ;> |
| | | </div> |
| | | |
| | | <div id="mapParams" style="display: none;"> |
| | | ${requestScope.params} |
| | | </div> |
| | | </body> |
| | | |
| | | </html> |
| | | <script type="text/javascript"> |
| | | // 百度地图API功能 |
| | | var map = new BMap.Map("allmap",{minZoom:14,maxZoom:19}); // 创建Map实例 |
| | | map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放 |
| | | var params = $.parseJSON($("#mapParams").html()); |
| | | var point=new BMap.Point(params["ll"][0], params["ll"][1]); |
| | | map.centerAndZoom(point, 18.5); // 初始化地图,设置中心点坐标和地图级别 |
| | | |
| | | var icon1 = new BMap.Icon("/img/ico00.png", new BMap.Size(48, 48)); |
| | | var mark1 = new BMap.Marker(new BMap.Point(params["ll"][0], params["ll"][1]), {icon: icon1}); |
| | | map.addOverlay(mark1); |
| | | |
| | | |
| | | var icon2 = new BMap.Icon("/img/ico05.png", new BMap.Size(48, 48)); |
| | | var mark2 = new BMap.Marker(new BMap.Point(116.885217,38.299148), {icon: icon2}); |
| | | map.addOverlay(mark2); |
| | | var label = new BMap.Label("新华区沧县城建局国控站--distance="+params["mt"],{offset:new BMap.Size(20,-10)}); |
| | | mark2.setLabel(label); |
| | | var icon3 = new BMap.Icon("/img/ico05.png", new BMap.Size(48, 48)); |
| | | var mark3 = new BMap.Marker(new BMap.Point(116.87061,38.322828), {icon: icon3}); |
| | | map.addOverlay(mark3); |
| | | |
| | | var label = new BMap.Label("新华区环保局国控站--distance="+params["mt1"],{offset:new BMap.Size(20,-10)}); |
| | | mark3.setLabel(label); |
| | | |
| | | var icon4 = new BMap.Icon("/img/ico05.png", new BMap.Size(48, 48)); |
| | | var mark4 = new BMap.Marker(new BMap.Point(116.855206,38.325162), {icon: icon4}); |
| | | map.addOverlay(mark4); |
| | | |
| | | var label = new BMap.Label("运河区电视转播国控站 --distance="+params["mt2"],{offset:new BMap.Size(20,-10)}); |
| | | mark4.setLabel(label); |
| | | |
| | | var polyline1 = new BMap.Polyline([ |
| | | new BMap.Point(params["ll"][0], params["ll"][1]), |
| | | new BMap.Point(116.885217,38.299148) |
| | | ], {strokeColor:"red", strokeWeight:8, strokeOpacity:0.5}); //创建折线 |
| | | |
| | | |
| | | var polyline2 = new BMap.Polyline([ |
| | | new BMap.Point(params["ll"][0], params["ll"][1]), |
| | | new BMap.Point(116.87061,38.322828) |
| | | ], {strokeColor:"yellow", strokeWeight:8, strokeOpacity:0.5}); //创建折线 |
| | | var polyline3 = new BMap.Polyline([ |
| | | new BMap.Point(params["ll"][0], params["ll"][1]), |
| | | new BMap.Point(116.855206,38.325162) |
| | | ], {strokeColor:"blue", strokeWeight:8, strokeOpacity:0.5}); //创建折线 |
| | | map.addOverlay(polyline1); //增加折线 |
| | | map.addOverlay(polyline2); //增加折线 |
| | | map.addOverlay(polyline3); //增加折线 |
| | | |
| | | |
| | | //添加地图类型控件 |
| | | map.addControl(new BMap.MapTypeControl({ |
| | | mapTypes: [ |
| | | BMAP_HYBRID_MAP, |
| | | BMAP_NORMAL_MAP |
| | | ] |
| | | })); |
| | | map.setMapType(BMAP_NORMAL_MAP); |
| | | |
| | | |
| | | |
| | | |
| | | </script> |
| | | |
| | |
| | | .wind_explain li img { |
| | | vertical-align: top; |
| | | } |
| | | #box { |
| | | overflow: auto; |
| | | width: 300px; |
| | | height: 400px; |
| | | top: 30px; |
| | | right: 30px; |
| | | position: absolute; |
| | | z-index: 1; |
| | | border: 1px solid gainsboro; |
| | | background-color: gainsboro; |
| | | opacity: 0.8; |
| | | display: none; |
| | | } |
| | | </style> |
| | | <body> |
| | | <div> |
| | |
| | | <textarea id="close" hidden></textarea> |
| | | |
| | | <div class="main_body"> |
| | | <div class="tools_box"> |
| | | <%-- <div class="tools_box"> |
| | | <div class="charts_btn"> |
| | | </div> |
| | | </div> |
| | |
| | | <li><img src="/img/icoWind07.png" width="25" height="25"><span>7级风</span></li> |
| | | <li><img src="/img/icoWind08.png" width="25" height="25"><span>8级风及以上</span></li> |
| | | </ul> |
| | | </div>--%> |
| | | |
| | | <div id="box"> |
| | | <span id="tou">因子超标报警</span> |
| | | <div id="box1" style="margin-top: 15px"></div> |
| | | </div> |
| | | <%-- <div class="search_box"> |
| | | <button id="searchBtn" type="button">搜索</button> |
| | | <textarea style="width: 300px;height:400px;" id="searchParam"></textarea> |
| | | </div>--%> |
| | | <!-- <div id="popup_box"> |
| | | <div id="equ_list" class="listview"> |
| | | </div> |
| | | </div> --> |
| | | <div class="pp1" style="display:none;" ></div> |
| | | <div class="pp2" style="display:none;" ></div> |
| | | <div id="mapCanvas"></div> |
| | | <div id="mapParams" style="display: none;"> |
| | | ${requestScope.mapParams} |
| | |
| | | </html> |
| | | <script> |
| | | //页面初始化 |
| | | var orgId; |
| | | var regionCode; |
| | | var accountId; |
| | | (function ($) { |
| | | var hostAndPort = document.location.host; |
| | | var moralMap = window.moralMap; |
| | | var params = $.parseJSON($("#mapParams").html()); |
| | | moralMap['params'] = params; |
| | | var orgId = params["orgId"]; |
| | | var regionCode = params["regionCode"]; |
| | | var accountId = params["accountId"]; |
| | | orgId = params["orgId"]; |
| | | regionCode = params["regionCode"]; |
| | | accountId = params["accountId"]; |
| | | var provinceCode = regionCode.toString().substring(0, 2) + "0000"; |
| | | var mapType = getUrlParam("mapType"); |
| | | var mapOption = {}; |
| | |
| | | //列表对象 |
| | | var listView = moralMap.initListView({id: "#equ_list", pageSize: 12}); |
| | | window["listView"] = listView; |
| | | |
| | | //展示设备列表,click事件触发 |
| | | function showEqus(obj) { |
| | | |
| | |
| | | }); |
| | | } |
| | | }, 500); |
| | | |
| | | } |
| | | |
| | | function loadOverlays(url, callback) { |
| | |
| | | //获得消息事件 |
| | | ws.onmessage = function (msg) { |
| | | // $("#searchParam").val(JSON.parse(msg.data)); |
| | | //moralMap.getRoad(JSON.parse(JSON.parse(msg.data)),regionCode); |
| | | // moralMap.getRoad(JSON.parse(JSON.parse(msg.data)),regionCode); |
| | | moralMap.refreshWindDir(JSON.parse(JSON.parse(msg.data))); |
| | | /* if (moralMap.showSensors && typeof (moralMap.showSensors) == "function") { |
| | | moralMap.showSensors(JSON.parse(JSON.parse(msg.data))); |
| | |
| | | moralMap.showSensors(JSON.parse(JSON.parse(msg.data))); |
| | | }; |
| | | |
| | | //关闭事件 |
| | | ws.onclose = function () { |
| | | $("#close").html("websocket已经关闭"); |
| | | }; |
| | | //发生了错误事件 |
| | | ws.onerror = function () { |
| | | $("#close").html("websocket关闭错误"); |
| | | }; |
| | | //关闭事件 |
| | | ws.onclose = function () { |
| | | $("#close").html("websocket已经关闭"); |
| | | }; |
| | | //发生了错误事件 |
| | | ws.onerror = function () { |
| | | $("#close").html("websocket关闭错误"); |
| | | }; |
| | | } |
| | | |
| | | })(jQuery); |
| | | var _intervalNum = -1; |
| | | |
| | | function startRefreshPage() { |
| | | if (_intervalNum == -1) { |
| | | _intervalNum = self.setInterval(function () { |
| | |
| | | cache: false, |
| | | async: true, |
| | | success: function (data) { |
| | | console.log(data) |
| | | if (data != null && typeof data === 'object') { |
| | | var resultMap = data["extData"]; |
| | | if (resultMap == null) { |
| | |
| | | moralMap.callJS(jsonData); |
| | | } else if ("RefreshState" == methodName) { |
| | | var states = jsonData.states; |
| | | moralMap.refreshState(states); |
| | | $(".pp1").html(JSON.stringify(states)) |
| | | moralMap.refreshState(states,orgId,regionCode,accountId); |
| | | } else if ("CloseMq" == methodName) { |
| | | $("#close").html(methodName); |
| | | } |