|
@@ -10,6 +10,8 @@ import javax.swing.*;
|
|
|
import java.awt.*;
|
|
import java.awt.*;
|
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.ActionEvent;
|
|
|
import java.awt.event.ActionListener;
|
|
import java.awt.event.ActionListener;
|
|
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
|
|
+import java.net.URLEncoder;
|
|
|
|
|
|
|
|
public class LoginFarme extends JFrame {
|
|
public class LoginFarme extends JFrame {
|
|
|
//登录模块组件
|
|
//登录模块组件
|
|
@@ -44,11 +46,11 @@ public class LoginFarme extends JFrame {
|
|
|
userPasswordLabel.setBounds(300, 150, 120, 40);
|
|
userPasswordLabel.setBounds(300, 150, 120, 40);
|
|
|
userPasswordLabel.setFont(new java.awt.Font("Dialog", 1, 16));
|
|
userPasswordLabel.setFont(new java.awt.Font("Dialog", 1, 16));
|
|
|
userNameTxt = new JTextField(20);
|
|
userNameTxt = new JTextField(20);
|
|
|
- userNameTxt.setText("system");
|
|
|
|
|
|
|
+ userNameTxt.setText("");
|
|
|
userNameTxt.setBounds(400, 105, 150, 30);
|
|
userNameTxt.setBounds(400, 105, 150, 30);
|
|
|
userPasswordTxt = new JPasswordField(20);
|
|
userPasswordTxt = new JPasswordField(20);
|
|
|
userPasswordTxt.setBounds(400, 155, 150, 30);
|
|
userPasswordTxt.setBounds(400, 155, 150, 30);
|
|
|
- userPasswordTxt.setText("Aa111111");
|
|
|
|
|
|
|
+ userPasswordTxt.setText("");
|
|
|
loginButton.setFont(new java.awt.Font("Dialog", 1, 16));
|
|
loginButton.setFont(new java.awt.Font("Dialog", 1, 16));
|
|
|
loginButton.setBounds(300, 200, 255, 40);
|
|
loginButton.setBounds(300, 200, 255, 40);
|
|
|
loginButton.setIcon(new ImageIcon(MesClient.class.getResource("/bg/user.png")));
|
|
loginButton.setIcon(new ImageIcon(MesClient.class.getResource("/bg/user.png")));
|
|
@@ -96,8 +98,8 @@ public class LoginFarme extends JFrame {
|
|
|
JOptionPane.showMessageDialog(MesClient.mesClientFrame,"用户名或密码不能为空","提示窗口", JOptionPane.INFORMATION_MESSAGE);
|
|
JOptionPane.showMessageDialog(MesClient.mesClientFrame,"用户名或密码不能为空","提示窗口", JOptionPane.INFORMATION_MESSAGE);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- String username = Base64Utils.getBase64(user_str);
|
|
|
|
|
- String password = Base64Utils.getBase64(password_str);
|
|
|
|
|
|
|
+ String username = urlEncode(Base64Utils.getBase64(user_str));
|
|
|
|
|
+ String password = urlEncode(Base64Utils.getBase64(password_str));
|
|
|
System.out.println("&username=" + username + "&password=" + password);
|
|
System.out.println("&username=" + username + "&password=" + password);
|
|
|
String url = "http://"+MesClient.mes_server_ip+":8980/js/a/login?__ajax=json&username="+username+"&password="+password+"&validCode=&__sid=";
|
|
String url = "http://"+MesClient.mes_server_ip+":8980/js/a/login?__ajax=json&username="+username+"&password="+password+"&validCode=&__sid=";
|
|
|
String loginResult = HttpUtils.sendRequest(url);
|
|
String loginResult = HttpUtils.sendRequest(url);
|
|
@@ -124,7 +126,7 @@ public class LoginFarme extends JFrame {
|
|
|
String scanContent = JOptionPane.showInputDialog(null, "请扫码工牌二维码");
|
|
String scanContent = JOptionPane.showInputDialog(null, "请扫码工牌二维码");
|
|
|
System.out.println("scanContent="+scanContent);
|
|
System.out.println("scanContent="+scanContent);
|
|
|
if(scanContent!=null&&!scanContent.equalsIgnoreCase("")) {
|
|
if(scanContent!=null&&!scanContent.equalsIgnoreCase("")) {
|
|
|
- String url = "http://"+MesClient.mes_server_ip+":8980/js/a/mes/mesLogin/login?__login=true&__ajax=json&username="+scanContent;
|
|
|
|
|
|
|
+ String url = "http://"+MesClient.mes_server_ip+":8980/js/a/mes/mesLogin/login?__login=true&__ajax=json&username="+urlEncode(scanContent);
|
|
|
String loginResult = HttpUtils.sendRequest(url);
|
|
String loginResult = HttpUtils.sendRequest(url);
|
|
|
System.out.println("loginResult="+loginResult);
|
|
System.out.println("loginResult="+loginResult);
|
|
|
if(loginResult.equalsIgnoreCase("false")) {
|
|
if(loginResult.equalsIgnoreCase("false")) {
|
|
@@ -156,7 +158,7 @@ public class LoginFarme extends JFrame {
|
|
|
MesClient.sessionid = retObj.get("sessionid").toString();
|
|
MesClient.sessionid = retObj.get("sessionid").toString();
|
|
|
if(MesClient.sessionid!=null&&!MesClient.sessionid.equalsIgnoreCase("")) {
|
|
if(MesClient.sessionid!=null&&!MesClient.sessionid.equalsIgnoreCase("")) {
|
|
|
//请求权限
|
|
//请求权限
|
|
|
- String url_authority = "http://"+MesClient.mes_server_ip+":8980/js/a/mes/mesLineProcess/userAuth?__ajax=json&type=0&__sid="+MesClient.sessionid+"&oprno="+MesClient.mes_gw+"&lineSn="+MesClient.mes_line_sn;
|
|
|
|
|
|
|
+ String url_authority = "http://"+MesClient.mes_server_ip+":8980/js/a/mes/mesLineProcess/userAuth?__ajax=json&type=0&__sid="+urlEncode(MesClient.sessionid)+"&oprno="+urlEncode(MesClient.mes_gw)+"&lineSn="+urlEncode(MesClient.mes_line_sn);
|
|
|
String authorityResult = HttpUtils.sendRequest(url_authority);
|
|
String authorityResult = HttpUtils.sendRequest(url_authority);
|
|
|
System.out.println("authorityResult="+authorityResult);
|
|
System.out.println("authorityResult="+authorityResult);
|
|
|
JSONObject authorityObj = JSONObject.parseObject(authorityResult);
|
|
JSONObject authorityObj = JSONObject.parseObject(authorityResult);
|
|
@@ -181,14 +183,14 @@ public class LoginFarme extends JFrame {
|
|
|
MesClient.startGetCurSn();
|
|
MesClient.startGetCurSn();
|
|
|
|
|
|
|
|
if(MesClient.jfxPanel == null){
|
|
if(MesClient.jfxPanel == null){
|
|
|
- String url = "http://"+ MesClient.mes_server_ip+":8980/js/a/mes/mesProductRecord/work?__sid="+MesClient.sessionid+"&oprno="+MesClient.mes_gw+"&lineSn="+MesClient.mes_line_sn;
|
|
|
|
|
|
|
+ String url = "http://"+ MesClient.mes_server_ip+":8980/js/a/mes/mesProductRecord/work?__sid="+urlEncode(MesClient.sessionid)+"&oprno="+urlEncode(MesClient.mes_gw)+"&lineSn="+urlEncode(MesClient.mes_line_sn);
|
|
|
MesClient.jfxPanel = new MesWebView(url);
|
|
MesClient.jfxPanel = new MesWebView(url);
|
|
|
MesClient.jfxPanel.setSize(990, 550);
|
|
MesClient.jfxPanel.setSize(990, 550);
|
|
|
MesClient.indexPanelB.add(MesClient.jfxPanel);
|
|
MesClient.indexPanelB.add(MesClient.jfxPanel);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if(MesClient.jfxPanel2 == null){
|
|
if(MesClient.jfxPanel2 == null){
|
|
|
- String url = "http://"+ MesClient.mes_server_ip+":8980/js/a/mes/mesProcessCheckRecord/ulist?__sid="+MesClient.sessionid+"&oprno="+MesClient.mes_gw+"&lineSn="+MesClient.mes_line_sn;
|
|
|
|
|
|
|
+ String url = "http://"+ MesClient.mes_server_ip+":8980/js/a/mes/mesProcessCheckRecord/ulist?__sid="+urlEncode(MesClient.sessionid)+"&oprno="+urlEncode(MesClient.mes_gw)+"&lineSn="+urlEncode(MesClient.mes_line_sn);
|
|
|
MesClient.jfxPanel2 = new MesWebView(url);
|
|
MesClient.jfxPanel2 = new MesWebView(url);
|
|
|
MesClient.jfxPanel2.setSize(990, 550);
|
|
MesClient.jfxPanel2.setSize(990, 550);
|
|
|
MesClient.indexPanelC.add(MesClient.jfxPanel2);
|
|
MesClient.indexPanelC.add(MesClient.jfxPanel2);
|
|
@@ -204,4 +206,12 @@ public class LoginFarme extends JFrame {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ private static String urlEncode(String value) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ return URLEncoder.encode(value == null ? "" : value, "UTF-8");
|
|
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|