Compare commits

...

21 Commits

@ -1,2 +1,2 @@
# xcr_se
# xcr_se

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

@ -12,6 +12,6 @@
</deviceKey>
</Target>
</targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2022-04-09T14:47:05.327585300Z" />
<timeTargetWasSelectedWithDropDown value="2022-05-08T06:33:21.724571700Z" />
</component>
</project>

@ -16,15 +16,20 @@
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/drawable/tab_menu_text.xml" value="0.1" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/drawable/translucent_button.xml" value="0.194" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/drawable/translucent_edit.xml" value="0.1135" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/activity_main.xml" value="0.10235507246376811" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/activity_history.xml" value="0.22" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/activity_main.xml" value="0.1" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/activity_main2.xml" value="0.10235507246376811" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/activity_menu.xml" value="0.33" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/activity_no_pick.xml" value="0.2" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/activity_sign_up.xml" value="0.10235507246376811" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/activity_wait.xml" value="0.18" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/buttom.xml" value="0.10235507246376811" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/forget.xml" value="0.2630208333333333" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/fragment_my.xml" value="0.10235507246376811" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/item.xml" value="0.22" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/my_fragment1.xml" value="0.1" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/my_fragment2.xml" value="0.18489583333333334" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/my_fragment3.xml" value="0.18489583333333334" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/my_fragment3.xml" value="0.2" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/pickup.xml" value="0.5" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/tab1.xml" value="0.10235507246376811" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/top.xml" value="0.3717105263157895" />

@ -28,13 +28,20 @@ android {
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.jakewharton:butterknife:10.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
implementation files('libs/json-simple-1.1.jar')
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation files('libs\\mysql-connector-java-5.0.7.jar')
implementation 'androidx.navigation:navigation-fragment:2.3.5'
implementation 'androidx.navigation:navigation-ui:2.3.5'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation "org.java-websocket:Java-WebSocket:1.4.0"
}

@ -0,0 +1,20 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.example.logistics",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-release.apk"
}
],
"elementType": "File"
}

@ -1,23 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.logistics"
xmlns:tools="http://schemas.android.com/tools">
xmlns:tools="http://schemas.android.com/tools"
package="com.example.logistics">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:usesCleartextTraffic="true"
android:name="com.example.logistics.tools.RCApplication"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Logistics" >
android:theme="@style/Theme.Logistics">
<activity
android:name=".ui.HistoryActivity"
android:exported="false" />
<activity
android:name=".ui.NoPickActivity"
android:exported="false" />
<activity
android:name=".ui.MenuActivity"
android:exported="false" />
<activity
android:name=".ui.MainActivity"
android:exported="true" >
android:name=".ui.LoginActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

File diff suppressed because one or more lines are too long

@ -0,0 +1,121 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script type="text/javascript" type="text/javascript">
function callJS(){
var ros = new ROSLIB.Ros({
url : 'ws://192.168.43.20:9090'
});
ros.on('connection', function() {
console.log('Connected to websocket server.');
});
ros.on('error', function(error) {
console.log('Error connecting to websocket server: ', error);
});
ros.on('close', function() {
console.log('Connection to websocket server closed.');
});
// 发布一个话题
var move_base= new ROSLIB.ActionClient({
ros : ros,
serverName : '/move_base',
actionName : 'move_base_msgs/MoveBaseAction'
});
var currentTime = new Date();
var secs = Math.floor(currentTime.getTime()/1000)
var nsecs = Math.round(1000000000*(currentTime.getTime()/1000-secs))
var goal = new ROSLIB.Goal({
actionClient: move_base,
goalMessage:{
target_pose:{
header:{
frame_id:'map',
stamp:{
secs: secs,
nsecs:nsecs
}
},
pose:{
position:{
x:-3.97, //-0.743 -0.0273 取件点
y:1.68, //3.00 -0.09
z:0.000
},
orientation:{
x:0.000,
y:0.000,
z:0.000,
w:1.000
}
}
}
}
});
goal.on('feedback', function(feedback) {
console.log('Feedback: ' + feedback.sequence);
});
goal.on('result', function(result) {
console.log('Final Result: ' + result.sequence);
});
ros.on('connection', function() {
console.log('Connected to websocket server.');
});
ros.on('error', function(error) {
console.log('Error connecting to websocket server: ', error);
});
ros.on('close', function() {
console.log('Connection to websocket server closed.');
});
//goal.send();
var cmdVel = new ROSLIB.Topic({
ros : ros,
name : '/cmd_vel',
messageType : 'geometry_msgs/Twist'
});
var twist = new ROSLIB.Message({
linear : {
x : 0.2,
y : 0.0,
z : 0.0
},
angular : {
x : 0.0,
y : 0.0,
z : 0.0
}
});
cmdVel.publish(twist);
}
</script>
</head>
<body>
<h1>Simple roslib Example</h1>
<p>Check your Web Console for output.</p>
</body>
</html>

File diff suppressed because one or more lines are too long

@ -1,86 +0,0 @@
package com.example.logistics.dao;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Looper;
import android.util.Log;
import com.example.logistics.tools.DBOpenHelper;
import com.example.logistics.tools.MD5Utils;
import com.example.logistics.ui.MainActivity;
import com.example.logistics.ui.MenuActivity;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashMap;
public class goodDao {
private static final String TAG = "goodDao";
public int search(String id, String phonenum, Context context){
HashMap<String, Object> map = new HashMap<>();
Connection connection = DBOpenHelper.getConn();
int msg = 0;
try{
String sql = "select * from goods where id = ?";
if(connection != null){
PreparedStatement ps = connection.prepareStatement(sql);
if(ps != null){
Log.e(TAG, "id: " + id);
ps.setInt(1,Integer.parseInt(id));
ResultSet rs = ps.executeQuery();
int count = rs.getMetaData().getColumnCount();
while(rs.next()){
for(int i = 1; i <= count; i++){
String field = rs.getMetaData().getColumnName(i);
map.put(field, rs.getString(field));
}
}
connection.close();
ps.close();
if(map.size() != 0){
StringBuilder s = new StringBuilder();
for(String key:map.keySet()){
if(key.equals("phonenum")){
String strphone = String.valueOf(map.get(key));
Log.d("abc", strphone);
if(phonenum.equals(strphone.substring(7,11))){
msg = 1; //phonenum correct
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("快件位置");
builder.setMessage("\n第 "+ map.get("shelfnum")+ " 号货架\n第 " + map.get("floornum")+ " 层");
Looper.prepare();
builder.show();
Looper.loop();
}else{
msg = 2; //phonenum incorrect
}
break;
}
}
}else{
Log.e(TAG, "result is null");
msg = 3; //result is null
}
}else{
Log.e(TAG, "ps is null");
msg = 0;
}
}else{
Log.e(TAG, "connection is null");
msg = 0;
}
}catch (Exception e){
e.printStackTrace();
Log.d(TAG, "search bug: " + e.getMessage());
msg = 0;
}
return msg;
}
}

@ -1,57 +0,0 @@
package com.example.logistics.dao;
import android.util.Log;
import com.example.logistics.entity.User;
import com.example.logistics.tools.DBOpenHelper;
import com.example.logistics.tools.MD5Utils;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
public class operationDao {
private static final String TAG = "operationDao";
public boolean add(String pickupcode, String phonenum){
HashMap<String, Object> map = new HashMap<>();
Connection connection = DBOpenHelper.getConn();
try{
SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
Date date = new Date();
String time = format1.format(date);
String sql = "insert into operations(pickupcode, phonenum, time) values (?,?,?)";
if(connection != null){
PreparedStatement ps = connection.prepareStatement(sql);
if(ps != null){
ps.setString(1, pickupcode);
ps.setString(2, phonenum);
ps.setString(3, time);
int rs = ps.executeUpdate();
if(rs > 0){
return true;
}else{
return false;
}
}else{
return false;
}
}else{
return false;
}
}catch(Exception e){
e.printStackTrace();
Log.e(TAG, "异常 add operation");
return false;
}
}
}

@ -0,0 +1,223 @@
package com.example.logistics.manager;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Looper;
import android.util.Log;
import com.example.logistics.tools.DBOpenHelper;
import com.example.logistics.tools.MD5Utils;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class goodManager {
private static final String TAG = "goodDao";
public int search(String id, String phonenum, Context context){
HashMap<String, Object> map = new HashMap<>();
Connection connection = DBOpenHelper.getConn();
int msg = 0;
try{
String sql = "select * from goods where id = ?";
if(connection != null){
PreparedStatement ps = connection.prepareStatement(sql);
if(ps != null){
Log.e(TAG, "id: " + id);
ps.setInt(1,Integer.parseInt(id));
ResultSet rs = ps.executeQuery();
int count = rs.getMetaData().getColumnCount();
while(rs.next()){
for(int i = 1; i <= count; i++){
String field = rs.getMetaData().getColumnName(i);
map.put(field, rs.getString(field));
}
}
connection.close();
ps.close();
if(map.size() != 0){
StringBuilder s = new StringBuilder();
for(String key:map.keySet()){
if(key.equals("phonenum")){
String strphone = String.valueOf(map.get(key));
Log.d("abc", strphone);
if(phonenum.equals(strphone.substring(7,11))){
msg = 1; //phonenum correct
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("快件位置");
builder.setMessage("\n第 "+ map.get("shelfnum")+ " 号货架\n第 " + map.get("floornum")+ " 层");
Looper.prepare();
builder.show();
Looper.loop();
}else{
msg = 2; //phonenum incorrect
}
break;
}
}
}else{
Log.e(TAG, "result is null");
msg = 3; //result is null
}
}else{
Log.e(TAG, "ps is null");
msg = 0;
}
}else{
Log.e(TAG, "connection is null");
msg = 0;
}
}catch (Exception e){
e.printStackTrace();
Log.d(TAG, "search bug: " + e.getMessage());
msg = 0;
}
return msg;
}
public boolean delete(String pickupcode){
Connection connection = DBOpenHelper.getConn();
try{
String sql = "delete from goods where id = ?";
if(connection != null){
PreparedStatement ps = connection.prepareStatement(sql);
if(ps != null){
Log.e(TAG, "pickupcode: " + pickupcode);
ps.setString(1,pickupcode);
ps.executeUpdate();
connection.close();
ps.close();
return true;
}else{
Log.e(TAG, "ps is null");
return false;
}
}else{
Log.e(TAG, "connection is null");
return false;
}
}catch(Exception e){
e.printStackTrace();
Log.d(TAG, "delete bug" + e.getMessage());
}
return false;
}
public List<Map<String, Object>> nopick(String phonenum){
Connection connection = DBOpenHelper.getConn();
List<Map<String, Object>> datalist;
datalist = new ArrayList<Map<String, Object>>();
try{
String sql = "select * from goods where phonenum = ?";
if(connection != null){
PreparedStatement ps = connection.prepareStatement(sql);
if(ps != null){
Log.e(TAG, "phonenum: " + phonenum);
ps.setString(1,phonenum);
ResultSet rs = ps.executeQuery();
int count = rs.getMetaData().getColumnCount();
while(rs.next()){
Map<String, Object> map = new HashMap<String, Object>();
for(int i = 1; i <= count; i++){
String field = rs.getMetaData().getColumnName(i);
if(field.equals("id")){
map.put(field, rs.getString(field));
}
if(field.equals("time")) {
map.put(field, rs.getString(field));
}
}
datalist.add(map);
}
connection.close();
ps.close();
}else{
Log.e(TAG, "ps is null");
}
}else{
Log.e(TAG, "connection is null");
}
}catch (Exception e){
e.printStackTrace();
Log.d(TAG, "search bug: " + e.getMessage());
}
return datalist;
}
public int pickup(String pickupcode, String phonenum){
HashMap<String, Object> map = new HashMap<>();
Connection connection = DBOpenHelper.getConn();
int msg = 0;
try{
String sql = "select * from goods where id=?";
if(connection != null){
PreparedStatement ps = connection.prepareStatement(sql);
if(ps != null){
Log.e(TAG, "pickupcode: " + pickupcode);
ps.setInt(1,Integer.parseInt(pickupcode));
ResultSet rs = ps.executeQuery();
int count = rs.getMetaData().getColumnCount();
while(rs.next()){
for(int i = 1; i <= count; i++){
String field = rs.getMetaData().getColumnName(i);
map.put(field, rs.getString(field));
}
}
connection.close();
ps.close();
if(map.size() != 0){
StringBuilder s = new StringBuilder();
for(String key:map.keySet()){
if(key.equals("phonenum")){
if(phonenum.equals(map.get(key).toString().substring(7,11))){
msg = 1; //password correct
}else{
msg = 2; //password incorrect
}
break;
}
}
}else{
Log.e(TAG, "result is null");
msg = 3; //result is null
}
}else{
Log.e(TAG, "ps is null");
msg = 0;
}
}else{
Log.e(TAG, "connection is null");
msg = 0;
}
}catch (Exception e){
e.printStackTrace();
Log.d(TAG, "login bug: " + e.getMessage());
msg = 0;
}
return msg;
}
}

@ -0,0 +1,104 @@
package com.example.logistics.manager;
import android.util.Log;
import com.example.logistics.tools.DBOpenHelper;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class operationManager {
private static final String TAG = "operationDao";
public boolean add(String pickupcode, String phonenum){
HashMap<String, Object> map = new HashMap<>();
Connection connection = DBOpenHelper.getConn();
try{
SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
Date date = new Date();
String time = format1.format(date);
String sql = "insert into operations(pickupcode, phonenum, time) values (?,?,?)";
if(connection != null){
PreparedStatement ps = connection.prepareStatement(sql);
if(ps != null){
ps.setString(1, pickupcode);
ps.setString(2, phonenum);
ps.setString(3, time);
int rs = ps.executeUpdate();
if(rs > 0){
return true;
}else{
return false;
}
}else{
return false;
}
}else{
return false;
}
}catch(Exception e){
e.printStackTrace();
Log.e(TAG, "异常 add operation");
return false;
}
}
public List<Map<String, Object>> history(String phonenum){
Connection connection = DBOpenHelper.getConn();
List<Map<String, Object>> datalist;
datalist = new ArrayList<Map<String, Object>>();
try{
String sql = "select * from operations where phonenum = ?";
if(connection != null){
PreparedStatement ps = connection.prepareStatement(sql);
if(ps != null){
Log.e(TAG, "phonenum: " + phonenum);
ps.setString(1,phonenum);
ResultSet rs = ps.executeQuery();
int count = rs.getMetaData().getColumnCount();
while(rs.next()){
Map<String, Object> map = new HashMap<String, Object>();
for(int i = 1; i <= count; i++){
String field = rs.getMetaData().getColumnName(i);
if(field.equals("pickupcode")){
map.put(field, rs.getString(field));
}
if(field.equals("time")) {
map.put(field, rs.getString(field));
}
}
datalist.add(map);
}
connection.close();
ps.close();
}else{
Log.e(TAG, "ps is null");
}
}else{
Log.e(TAG, "connection is null");
}
}catch (Exception e){
e.printStackTrace();
Log.d(TAG, "search bug: " + e.getMessage());
}
return datalist;
}
}

@ -1,4 +1,4 @@
package com.example.logistics.dao;
package com.example.logistics.manager;
import android.util.Log;
@ -12,7 +12,7 @@ import java.util.HashMap;
import java.sql.ResultSet;
import java.sql.Connection;
public class userDao {
public class userManager {
private static final String TAG = "userDao";
@ -46,6 +46,66 @@ public class userDao {
StringBuilder s = new StringBuilder();
for(String key:map.keySet()){
if(key.equals("password")){
if(password.equals(map.get(key))){
msg = 1; //password correct
}else{
msg = 2; //password incorrect
}
break;
}
}
}else{
Log.e(TAG, "result is null");
msg = 3; //result is null
}
}else{
Log.e(TAG, "ps is null");
msg = 0;
}
}else{
Log.e(TAG, "connection is null");
msg = 0;
}
}catch (Exception e){
e.printStackTrace();
Log.d(TAG, "login bug: " + e.getMessage());
msg = 0;
}
return msg;
}
public int loginByPhone(String phonenum, String password){
HashMap<String, Object> map = new HashMap<>();
Connection connection = DBOpenHelper.getConn();
int msg = 0;
try{
String sql = "select * from users where phonenum = ?";
if(connection != null){
PreparedStatement ps = connection.prepareStatement(sql);
if(ps != null){
Log.e(TAG, "phonenum: " + phonenum);
ps.setString(1,phonenum);
ResultSet rs = ps.executeQuery();
int count = rs.getMetaData().getColumnCount();
while(rs.next()){
for(int i = 1; i <= count; i++){
String field = rs.getMetaData().getColumnName(i);
map.put(field, rs.getString(field));
}
}
connection.close();
ps.close();
password = MD5Utils.md5(password);
if(map.size() != 0){
StringBuilder s = new StringBuilder();
for(String key:map.keySet()){
if(key.equals("password")){
if(password.equals(map.get(key))){
msg = 1; //password correct
}else{
@ -136,4 +196,42 @@ public class userDao {
}
}
public int change(String phonenum, String password){
HashMap<String, Object> map = new HashMap<>();
Connection connection = DBOpenHelper.getConn();
int msg = 0;
try{
String sql = "update users set password = ? where phonenum = ?";
if(connection != null){
PreparedStatement ps = connection.prepareStatement(sql);
if(ps != null){
Log.e(TAG, "phonenum: " + phonenum);
password = MD5Utils.md5(password);
ps.setString(1,password);
ps.setString(2,phonenum);
ps.executeUpdate();
connection.close();
ps.close();
msg = 1;
}else{
Log.e(TAG, "ps is null");
msg = 0;
}
}else{
Log.e(TAG, "connection is null");
msg = 0;
}
}catch (Exception e){
e.printStackTrace();
Log.d(TAG, "login bug: " + e.getMessage());
msg = 0;
}
return msg;
}
}

@ -1,28 +0,0 @@
package com.example.logistics.mysqlconnection;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DBOpenHelper {
private static String diver = "com.mysql.jdbc.Driver";
//加入utf-8是为了后面往表中输入中文表中不会出现乱码的情况
private static String url = "jdbc:mysql://49.235.83.73:3306/logistics?characterEncoding=utf-8";
private static String user = "root";//用户名
private static String password = "123";//密码
/*
*
* */
public static Connection getConn(){
Connection conn = null;
try {
Class.forName(diver);
conn = (Connection) DriverManager.getConnection(url,user,password);//获取连接
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
}

@ -7,9 +7,9 @@ import java.sql.SQLException;
public class DBOpenHelper {
private static String diver = "com.mysql.jdbc.Driver";
//加入utf-8是为了后面往表中输入中文表中不会出现乱码的情况
private static String url = "jdbc:mysql://49.235.83.73:3306/logistics?characterEncoding=utf-8";
private static String url = "jdbc:mysql://192.168.43.203:3306/logistics?characterEncoding=utf-8";
private static String user = "root";//用户名
private static String password = "123";//密码
private static String password = "";//密码
/*
*
* */

@ -0,0 +1,35 @@
package com.example.logistics.tools;
import android.util.Log;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.handshake.ServerHandshake;
import java.net.URI;
public class JWebSocketClient extends WebSocketClient {
public JWebSocketClient(URI serverUri) {
super(serverUri, new Draft_6455());
}
@Override
public void onOpen(ServerHandshake handshakedata) {
Log.e("JWebSocketClient", "onOpen()");
}
@Override
public void onMessage(String message) {
Log.e("JWebSocketClient", "onMessage()");
}
@Override
public void onClose(int code, String reason, boolean remote) {
Log.e("JWebSocketClient", "onClose()");
}
@Override
public void onError(Exception ex) {
Log.e("JWebSocketClient", "onError()");
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save