| | |
| | | import static com.moral.common.util.ResourceUtil.getValue;
|
| | | import static com.moral.common.util.WebUtils.getParametersStartingWith;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.io.InputStreamReader;
|
| | | import java.io.*;
|
| | | import java.util.HashMap;
|
| | | import java.util.LinkedHashMap;
|
| | | import java.util.Map;
|
| | |
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import com.moral.common.xml.Version;
|
| | | import org.apache.commons.net.ftp.FTPClient;
|
| | | import org.dom4j.Document;
|
| | | import org.dom4j.Element;
|
| | | import org.dom4j.io.SAXReader;
|
| | | import org.springframework.beans.factory.annotation.Value;
|
| | | import org.springframework.data.redis.core.RedisTemplate;
|
| | | import org.springframework.web.bind.annotation.CrossOrigin;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.PostMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestParam;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import org.springframework.web.bind.annotation.*;
|
| | |
|
| | | import com.alibaba.fastjson.JSON;
|
| | | import com.alibaba.fastjson.JSONReader;
|
| | |
| | | import com.moral.service.DeviceService;
|
| | | import com.moral.service.HistoryService;
|
| | | import com.moral.service.MachineActivateService;
|
| | | import org.xml.sax.InputSource;
|
| | |
|
| | | /**
|
| | | * The Class ScreenController.大屏接口
|
| | |
| | | return new ResultBean<Integer>(result);
|
| | | }
|
| | |
|
| | | /*********************************************
|
| | | * 大屏程序在线升级配置读取
|
| | | *********************************************/
|
| | | private String fileName = "Version.xml";
|
| | | private String ip = "121.40.92.176";
|
| | | private String userName = "ftp_user";
|
| | | private String userPwd = "qwer1234";
|
| | | private int port = 21;
|
| | | private String path = "/";
|
| | |
|
| | | @RequestMapping(value = "/upgrade", method = RequestMethod.GET)
|
| | | public Version index() {
|
| | | Version version = new Version();
|
| | | FTPClient ftpClient = new FTPClient();
|
| | | try {
|
| | | ftpClient.connect(ip, port);
|
| | | ftpClient.login(userName, userPwd);
|
| | | ftpClient.changeWorkingDirectory(path);
|
| | | //ftpClient.enterRemotePassiveMode();
|
| | | ftpClient.enterLocalPassiveMode();
|
| | | 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();
|
| | | }
|
| | | SAXReader saxReader = new SAXReader();
|
| | | Document document = saxReader.read(new InputSource(new ByteArrayInputStream(content.getBytes("utf-8"))));
|
| | | Element root = document.getRootElement();
|
| | | version.setVer(root.element("Ver").getText());
|
| | | version.setFileName(root.element("FileName").getText());
|
| | | version.setFileMD5Hash(root.element("FileMD5Hash").getText());
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return version;
|
| | | }
|
| | | }
|