| | |
| | | import java.io.ByteArrayInputStream;
|
| | | import java.io.InputStream;
|
| | | import java.io.InputStreamReader;
|
| | | import java.net.InetAddress;
|
| | | import java.net.URL;
|
| | | import java.net.URLConnection;
|
| | | import java.util.ArrayList;
|
| | | import java.util.HashMap;
|
| | | import java.util.LinkedHashMap;
|
| | |
| | | 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. 大屏登录
|
| | | *
|
| | |
| | | private int port = 21;
|
| | | private String path = "/";
|
| | |
|
| | | private String urlStr = "http://www.7drlb.com/apps/Version.xml";
|
| | |
|
| | | @RequestMapping(value = "/upgrade", method = RequestMethod.GET)
|
| | | public Version index() {
|
| | | Version version = new Version();
|
| | | // FTPClient ftpClient = new FTPClient();
|
| | | FTPClient ftpClient = new FTPClient();
|
| | | try {
|
| | | // ftpClient.connect(ip, port);
|
| | | //// ftpClient.login(userName, userPwd);
|
| | | //// ftpClient.changeWorkingDirectory(path);
|
| | | //// //ftpClient.enterRemotePassiveMode();
|
| | | //// //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;
|
| | | //// StringBuilder builder = new StringBuilder();
|
| | | //// while ((line = reader.readLine()) != null) {
|
| | | //// builder.append(line);
|
| | | //// }
|
| | | //// reader.close();
|
| | | //// if (ins != null) {
|
| | | //// ins.close();
|
| | | //// }
|
| | | //// ftpClient.getReply();
|
| | | //// String content = builder.toString();
|
| | | //// if(ftpClient.isConnected()) {
|
| | | //// ftpClient.logout();
|
| | | //// ftpClient.disconnect();
|
| | | //// }
|
| | | ftpClient.connect(ip, port);
|
| | | ftpClient.login(userName, userPwd);
|
| | | ftpClient.changeWorkingDirectory(path);
|
| | | ftpClient.enterLocalPassiveMode();
|
| | | //ftpClient.enterLocalActiveMode();
|
| | |
|
| | | 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"));
|
| | | InputStream ins = ftpClient.retrieveFileStream(fileName);
|
| | | BufferedReader reader = new BufferedReader(new InputStreamReader(ins,"utf-8"));
|
| | | String line;
|
| | | while ((line = in.readLine()) != null) {
|
| | | result.append(line);
|
| | | StringBuilder builder = new StringBuilder();
|
| | | while ((line = reader.readLine()) != null) {
|
| | | builder.append(line);
|
| | | }
|
| | | String content = result.toString();
|
| | | reader.close();
|
| | | if (ins != null) {
|
| | | ins.close();
|
| | | }
|
| | | ftpClient.getReply();
|
| | | String content = builder.toString();
|
| | | if(ftpClient.isConnected()) {
|
| | | 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"))));
|
| | |
| | | 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);
|
| | | }
|