| | |
| | | import java.io.ByteArrayInputStream;
|
| | | import java.io.InputStream;
|
| | | import java.io.InputStreamReader;
|
| | | import java.net.InetAddress;
|
| | | import java.util.ArrayList;
|
| | | import java.util.HashMap;
|
| | | import java.util.LinkedHashMap;
|
| | |
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import com.moral.entity.alarm.AlarmConfig;
|
| | | import org.apache.commons.collections.CollectionUtils;
|
| | | import org.apache.commons.net.ftp.FTPClient;
|
| | | import org.apache.log4j.Logger;
|
| | |
| | | import com.moral.entity.alarm.AlarmSensorLevel;
|
| | | import com.moral.service.AccountService;
|
| | | import com.moral.service.AlarmConfigService;
|
| | | import com.moral.service.AlarmService;
|
| | | import com.moral.service.AlarmDailyService;
|
| | | import com.moral.service.AreaService;
|
| | | import com.moral.service.DeviceService;
|
| | | import com.moral.service.HistoryMinutelyService;
|
| | |
| | | private String levelKey = "alarm_";
|
| | |
|
| | | @Resource
|
| | | private AlarmService alarmService;
|
| | | private AlarmDailyService alarmDailyService;
|
| | | /**
|
| | | * Screen login. 大屏登录
|
| | | *
|
| | |
| | | ftpClient.connect(ip, port);
|
| | | ftpClient.login(userName, userPwd);
|
| | | ftpClient.changeWorkingDirectory(path);
|
| | | //ftpClient.enterRemotePassiveMode();
|
| | | //ftpClient.enterLocalPassiveMode();
|
| | | ftpClient.enterLocalPassiveMode();
|
| | | //ftpClient.enterLocalActiveMode();
|
| | | ftpClient.enterRemoteActiveMode(InetAddress.getByName(ip), port);
|
| | |
|
| | | InputStream ins = ftpClient.retrieveFileStream(fileName);
|
| | | BufferedReader reader = new BufferedReader(new InputStreamReader(ins,"utf-8"));
|
| | | String line;
|
| | |
| | | ftpClient.logout();
|
| | | ftpClient.disconnect();
|
| | | }
|
| | |
|
| | | // String urlStr = "http://www.7drlb.com/apps/Version.xml";
|
| | | // URL realUrl = new URL(urlStr);
|
| | | // URLConnection connection = realUrl.openConnection();
|
| | | // connection.connect();
|
| | | // StringBuffer result = new StringBuffer();
|
| | | // BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));
|
| | | // String line;
|
| | | // while ((line = in.readLine()) != null) {
|
| | | // result.append(line);
|
| | | // }
|
| | | // String content = result.toString();
|
| | |
|
| | | SAXReader saxReader = new SAXReader();
|
| | | Document document = saxReader.read(new InputSource(new ByteArrayInputStream(content.getBytes("utf-8"))));
|
| | | Element root = document.getRootElement();
|
| | |
| | |
|
| | | public static void main(String[] args) {
|
| | | ScreenController sc = new ScreenController();
|
| | | sc.index();
|
| | | Version a = sc.index();
|
| | | System.out.println(a.getVer());
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | parameters.remove("organizationId");
|
| | | }
|
| | | }
|
| | | Map pieData = alarmService.getPieData(parameters);
|
| | | Map pieData = alarmDailyService.getPieData(parameters);
|
| | | List<Map<String, Object>> list = (List<Map<String, Object>>) pieData.get(sensorKey);
|
| | | return new ResultBean<List<Map<String, Object>>>(list);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取报警阀值
|
| | | * @param mpid
|
| | | * @return
|
| | | */
|
| | | @GetMapping("getalevels")
|
| | | public ResultBean<Map<String,AlarmSensorLevel>> getAlarmLevelByMonitorPointId(int mpid){
|
| | | AlarmConfig alarmConfig = alarmConfigService.queryByMonitorPointId(mpid).get();
|
| | | Map<String,AlarmSensorLevel> alarmSensorLevelMap = alarmConfig.getValue().getAlarmLevels();
|
| | | // 当前非取默认值,未设值将用默认值覆盖
|
| | | if(alarmConfig.getId()!=null){
|
| | | AlarmConfigValue defaultAlarmValue = alarmConfigService.getDefaultAlarmConfigValue();
|
| | | Map<String,AlarmSensorLevel> defaultSensorLevelMap = defaultAlarmValue.getAlarmLevels();
|
| | | Map<String,AlarmSensorLevel> alarmSensorLevelMapNotZO = alarmSensorLevelMap.entrySet().stream().collect(
|
| | | HashMap::new,
|
| | | (map,entry) -> {
|
| | | AlarmSensorLevel alarmSensorLevel = entry.getValue();
|
| | | if(alarmSensorLevel.isEnable()||alarmSensorLevel.isDegressEnable()){
|
| | | map.put(entry.getKey(),entry.getValue());
|
| | | }
|
| | | },
|
| | | (oMap,nMap) -> {
|
| | | oMap.putAll(nMap);
|
| | | }
|
| | | );
|
| | | // 已设置的选项覆盖默认选项
|
| | | defaultSensorLevelMap.putAll(alarmSensorLevelMapNotZO);
|
| | | alarmSensorLevelMap = defaultSensorLevelMap;
|
| | | }
|
| | |
|
| | | ResultBean<Map<String,AlarmSensorLevel>> resultBean = new ResultBean();
|
| | | resultBean.setCode(ResultBean.SUCCESS);
|
| | | resultBean.setData(alarmSensorLevelMap);
|
| | | return resultBean;
|
| | | }
|
| | | }
|