Compare commits

..

No commits in common. 'master' and 'Litianhong_branch' have entirely different histories.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 MiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 263 KiB

After

Width:  |  Height:  |  Size: 263 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 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.

Before

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 163 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.

Before

Width:  |  Height:  |  Size: 113 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.

Before

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 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.

Before

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 165 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 347 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 490 KiB

After

Width:  |  Height:  |  Size: 488 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 KiB

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 KiB

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 KiB

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 157 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

After

Width:  |  Height:  |  Size: 136 KiB

@ -7,11 +7,11 @@
<deviceKey> <deviceKey>
<Key> <Key>
<type value="VIRTUAL_DEVICE_PATH" /> <type value="VIRTUAL_DEVICE_PATH" />
<value value="E:\SDK\avd\.android\avd\Pixel_XL_API_30.avd" /> <value value="D:\AndroidSDK\.android\.android\avd\Pixel_2_API_31.avd" />
</Key> </Key>
</deviceKey> </deviceKey>
</Target> </Target>
</targetSelectedWithDropDown> </targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2022-07-10T02:39:23.302314100Z" /> <timeTargetWasSelectedWithDropDown value="2022-06-14T12:27:15.523840400Z" />
</component> </component>
</project> </project>

@ -19,9 +19,9 @@
<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_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_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_main2.xml" value="0.10235507246376811" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/activity_menu.xml" value="0.25" /> <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_no_pick.xml" value="0.2" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/activity_sign_up.xml" value="0.22" /> <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/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/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/forget.xml" value="0.2630208333333333" />
@ -30,7 +30,7 @@
<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_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_fragment2.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/my_fragment3.xml" value="0.2" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/pickup.xml" value="0.1" /> <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/tab1.xml" value="0.10235507246376811" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/top.xml" value="0.3717105263157895" /> <entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/top.xml" value="0.3717105263157895" />
<entry key="..\:/无人物流/xcr_se/src/Logistics/app/src/main/res/drawable-v24/ic_launcher_foreground.xml" value="0.1" /> <entry key="..\:/无人物流/xcr_se/src/Logistics/app/src/main/res/drawable-v24/ic_launcher_foreground.xml" value="0.1" />

@ -16,16 +16,16 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.Logistics"> android:theme="@style/Theme.Logistics">
<activity <activity
android:name=".ui.HistoryUI" android:name=".ui.HistoryActivity"
android:exported="false" /> android:exported="false" />
<activity <activity
android:name=".ui.SearchUI" android:name=".ui.SearchActivity"
android:exported="false" /> android:exported="false" />
<activity <activity
android:name=".ui.MenuActivity" android:name=".ui.MenuActivity"
android:exported="false" /> android:exported="false" />
<activity <activity
android:name=".ui.LoginUI" android:name=".ui.LoginActivity"
android:exported="true"> android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -33,7 +33,7 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".ui.SignUpUI" /> <activity android:name=".ui.SignUpActivity" />
<activity <activity
android:name="com.journeyapps.barcodescanner.CaptureActivity" android:name="com.journeyapps.barcodescanner.CaptureActivity"
android:screenOrientation="portrait" android:screenOrientation="portrait"

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head title="pickup"> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<script type="text/javascript" type="text/javascript"> <script type="text/javascript" type="text/javascript">

@ -2,11 +2,10 @@ package com.example.logistics.entity;
public class Good { public class Good {
private int id; private int id;
private String phoneNum;
private String phoneNum;//货主手机号 private int shelfNum;
private int shelfNum;//货架号 private int floorNum;
private int floorNum;//货架层号 private String time;
private String time;//入库时间
public Good(){ public Good(){

@ -4,9 +4,9 @@ import android.provider.ContactsContract;
public class Operation { public class Operation {
private int id; private int id;
private String pickUpCode;//取件码 private String pickUpCode;
private String phoneNum;//货主手机号 private String phoneNum;
private String time;//取件时间 private String time;
public Operation(){ public Operation(){

@ -2,9 +2,9 @@ package com.example.logistics.entity;
public class User { public class User {
private int userId; private int userId;
private String userName;//用户名 private String userName;
private String passWord;//密码 private String passWord;
private String phoneNum;//手机吗 private String phoneNum;
public User(){ public User(){

@ -18,30 +18,31 @@ import java.util.Map;
public class goodManager { public class goodManager {
private static final String TAG = "goodManager"; private static final String TAG = "goodDao";
public int search(String id, String phonenum, Context context){//搜索快件位置id手机号 public int search(String id, String phonenum, Context context){//搜索快件位置id手机号
Log.d(TAG, "search"); Log.d(TAG, "search");
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
Connection connection = DBOpenHelper.getConn();//DBO连接数据库 Connection connection = DBOpenHelper.getConn();
int msg = 0; int msg = 0;
try{ try{
Log.d(TAG, "select goods"); Log.d(TAG, "select goods");
String sql = "select * from goods where id = ?";//搜索指定取件码(=id号的快件信息 String sql = "select * from goods where id = ?";
if(connection != null){ if(connection != null){
Log.d(TAG, "connection!"); Log.d(TAG, "connection!");
PreparedStatement ps = connection.prepareStatement(sql); PreparedStatement ps = connection.prepareStatement(sql);
if(ps != null){ if(ps != null){
Log.e(TAG, "id: " + id); Log.e(TAG, "id: " + id);
ps.setInt(1,Integer.parseInt(id));//设置sql语句中id号 ps.setInt(1,Integer.parseInt(id));
ResultSet rs = ps.executeQuery();//执行sql语句并返回结果到rs ResultSet rs = ps.executeQuery();
int count = rs.getMetaData().getColumnCount(); int count = rs.getMetaData().getColumnCount();
while(rs.next()){//遍历返回结果加入map中 while(rs.next()){
for(int i = 1; i <= count; i++){ for(int i = 1; i <= count; i++){
String field = rs.getMetaData().getColumnName(i); String field = rs.getMetaData().getColumnName(i);
map.put(field, rs.getString(field)); map.put(field, rs.getString(field));
@ -52,14 +53,14 @@ public class goodManager {
if(map.size() != 0){ if(map.size() != 0){
Log.d(TAG, "map isnot null"); Log.d(TAG, "map isnot null");
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
for(String key:map.keySet()){//搜索map中的key值 for(String key:map.keySet()){
if(key.equals("phonenum")){//搜索phonenum属性 if(key.equals("phonenum")){
String strphone = String.valueOf(map.get(key)); String strphone = String.valueOf(map.get(key));
Log.d(TAG, strphone); Log.d(TAG, strphone);
if(phonenum.equals(strphone.substring(7,11))){//如果手机尾号后四位相等 if(phonenum.equals(strphone.substring(7,11))){
msg = 1; //phonenum correct msg = 1; //phonenum correct
Log.d(TAG, "phonenum correct"); Log.d(TAG, "phonenum correct");
AlertDialog.Builder builder = new AlertDialog.Builder(context);//弹出快件位置信息 AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("快件位置"); builder.setTitle("快件位置");
builder.setMessage("\n第 "+ map.get("shelfnum")+ " 号货架\n第 " + map.get("floornum")+ " 层"); builder.setMessage("\n第 "+ map.get("shelfnum")+ " 号货架\n第 " + map.get("floornum")+ " 层");
Looper.prepare(); Looper.prepare();
@ -88,14 +89,11 @@ public class goodManager {
e.printStackTrace(); e.printStackTrace();
Log.d(TAG, "search bug: " + e.getMessage()); Log.d(TAG, "search bug: " + e.getMessage());
msg = 0; msg = 0;
} finally {
} }
return msg; return msg;
} }
public boolean delete(String pickupcode){//根据取件码删除快递 public boolean delete(String pickupcode){
Connection connection = DBOpenHelper.getConn(); Connection connection = DBOpenHelper.getConn();
try{ try{
@ -107,9 +105,9 @@ public class goodManager {
PreparedStatement ps = connection.prepareStatement(sql); PreparedStatement ps = connection.prepareStatement(sql);
if(ps != null){ if(ps != null){
Log.e(TAG, "pickupcode: " + pickupcode); Log.e(TAG, "pickupcode: " + pickupcode);
ps.setString(1,pickupcode);//设置参数 ps.setString(1,pickupcode);
ps.executeUpdate();//删除操作 ps.executeUpdate();
connection.close(); connection.close();
ps.close(); ps.close();
@ -123,16 +121,13 @@ public class goodManager {
return false; return false;
} }
}catch(Exception e){ }catch(Exception e){
e.printStackTrace(); e.printStackTrace();
Log.d(TAG, "delete bug" + e.getMessage()); Log.d(TAG, "delete bug" + e.getMessage());
}finally {
} }
return false; return false;
} }
public List<Map<String, Object>> nopick(String phonenum){//根据手机号查询未取的件 public List<Map<String, Object>> nopick(String phonenum){
Connection connection = DBOpenHelper.getConn(); Connection connection = DBOpenHelper.getConn();
Log.d(TAG, "nopick goods"); Log.d(TAG, "nopick goods");
@ -167,7 +162,7 @@ public class goodManager {
map.put(field, rs.getString(field)); map.put(field, rs.getString(field));
} }
} }
datalist.add(map);//加入即将显示的列表中 datalist.add(map);
} }
connection.close(); connection.close();
ps.close(); ps.close();
@ -180,13 +175,11 @@ public class goodManager {
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
Log.d(TAG, "search bug: " + e.getMessage()); Log.d(TAG, "search bug: " + e.getMessage());
} finally {
} }
return datalist; return datalist;
} }
public int pickup(String pickupcode, String phonenum){//根据取件码与手机号取件 public int pickup(String pickupcode, String phonenum){
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
Connection connection = DBOpenHelper.getConn(); Connection connection = DBOpenHelper.getConn();
@ -202,7 +195,7 @@ public class goodManager {
if(ps != null){ if(ps != null){
Log.e(TAG, "pickupcode: " + pickupcode); Log.e(TAG, "pickupcode: " + pickupcode);
ps.setInt(1,Integer.parseInt(pickupcode)); ps.setInt(1,Integer.parseInt(pickupcode));
ResultSet rs = ps.executeQuery();//获取要取的件信息 ResultSet rs = ps.executeQuery();
int count = rs.getMetaData().getColumnCount(); int count = rs.getMetaData().getColumnCount();
while(rs.next()){ while(rs.next()){
@ -213,12 +206,12 @@ public class goodManager {
} }
connection.close(); connection.close();
ps.close(); ps.close();
if(map.size() != 0){//如果找不到对应快件 if(map.size() != 0){
Log.d(TAG, "map has value"); Log.d(TAG, "map has value");
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
for(String key:map.keySet()){ for(String key:map.keySet()){
if(key.equals("phonenum")){ if(key.equals("phonenum")){
if(phonenum.equals(map.get(key).toString().substring(7,11))){//如果手机尾号相等 if(phonenum.equals(map.get(key).toString().substring(7,11))){
msg = 1; //password correct msg = 1; //password correct
}else{ }else{
msg = 2; //password incorrect msg = 2; //password incorrect
@ -242,8 +235,6 @@ public class goodManager {
e.printStackTrace(); e.printStackTrace();
Log.d(TAG, "login bug: " + e.getMessage()); Log.d(TAG, "login bug: " + e.getMessage());
msg = 0; msg = 0;
} finally {
} }
return msg; return msg;
} }

@ -15,19 +15,21 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class operationManager { public class operationManager {
private static final String TAG = "operationManager"; private static final String TAG = "operationDao";
public boolean add(String pickupcode, String phonenum){//根据取件码与手机号添加操作记录 public boolean add(String pickupcode, String phonenum){
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
Connection connection = DBOpenHelper.getConn(); Connection connection = DBOpenHelper.getConn();
try{ try{
SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
Log.d(TAG, "add");
SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");//时间格式
Date date = new Date(); Date date = new Date();
String time = format1.format(date);//时间格式字符串化
String time = format1.format(date);
String sql = "insert into operations(pickupcode, phonenum, time) values (?,?,?)"; String sql = "insert into operations(pickupcode, phonenum, time) values (?,?,?)";
if(connection != null){ if(connection != null){
PreparedStatement ps = connection.prepareStatement(sql); PreparedStatement ps = connection.prepareStatement(sql);
@ -52,21 +54,16 @@ public class operationManager {
e.printStackTrace(); e.printStackTrace();
Log.e(TAG, "异常 add operation"); Log.e(TAG, "异常 add operation");
return false; return false;
}finally {
} }
} }
public List<Map<String, Object>> history(String phonenum){//根据手机号查询历史记录 public List<Map<String, Object>> history(String phonenum){
Connection connection = DBOpenHelper.getConn(); Connection connection = DBOpenHelper.getConn();
List<Map<String, Object>> datalist;//查询结果显示列表 List<Map<String, Object>> datalist;
datalist = new ArrayList<Map<String, Object>>(); datalist = new ArrayList<Map<String, Object>>();
try{ try{
Log.d(TAG, "history");
String sql = "select * from operations where phonenum = ?"; String sql = "select * from operations where phonenum = ?";
if(connection != null){ if(connection != null){
@ -101,8 +98,6 @@ public class operationManager {
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
Log.d(TAG, "search bug: " + e.getMessage()); Log.d(TAG, "search bug: " + e.getMessage());
}finally {
} }
return datalist; return datalist;
} }

@ -14,18 +14,15 @@ import java.sql.Connection;
public class userManager { public class userManager {
private static final String TAG = "userManager"; private static final String TAG = "userDao";
public int login(String username, String password){//根据用户名与密码登录 public int login(String username, String password){
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
Connection connection = DBOpenHelper.getConn(); Connection connection = DBOpenHelper.getConn();
int msg = 0; int msg = 0;
try{ try{
Log.d(TAG, "login");
String sql = "select * from users where username = ?"; String sql = "select * from users where username = ?";
if(connection != null){ if(connection != null){
@ -44,16 +41,16 @@ public class userManager {
} }
connection.close(); connection.close();
ps.close(); ps.close();
password = MD5Utils.md5(password);//密码md5加密 password = MD5Utils.md5(password);
if(map.size() != 0){ if(map.size() != 0){
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
for(String key:map.keySet()){ for(String key:map.keySet()){
if(key.equals("password")){//查看password属性 if(key.equals("password")){
if(password.equals(map.get(key))){ if(password.equals(map.get(key))){
msg = 1; //密码正确 msg = 1; //password correct
}else{ }else{
msg = 2; //密码错误 msg = 2; //password incorrect
} }
break; break;
} }
@ -71,27 +68,20 @@ public class userManager {
msg = 0; msg = 0;
} }
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
Log.d(TAG, "login bug: " + e.getMessage()); Log.d(TAG, "login bug: " + e.getMessage());
msg = 0; msg = 0;
} finally {
} }
return msg; return msg;
} }
public int loginByPhone(String phonenum, String password){//通过手机号登录 public int loginByPhone(String phonenum, String password){
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
Connection connection = DBOpenHelper.getConn(); Connection connection = DBOpenHelper.getConn();
int msg = 0; int msg = 0;
try{ try{
Log.d(TAG, "loginByPhone");
String sql = "select * from users where phonenum = ?"; String sql = "select * from users where phonenum = ?";
if(connection != null){ if(connection != null){
@ -110,7 +100,6 @@ public class userManager {
} }
connection.close(); connection.close();
ps.close(); ps.close();
password = MD5Utils.md5(password); password = MD5Utils.md5(password);
if(map.size() != 0){ if(map.size() != 0){
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
@ -141,20 +130,15 @@ public class userManager {
e.printStackTrace(); e.printStackTrace();
Log.d(TAG, "login bug: " + e.getMessage()); Log.d(TAG, "login bug: " + e.getMessage());
msg = 0; msg = 0;
} finally {
} }
return msg; return msg;
} }
public User findUser(String username){//查看是否已有该用户 public User findUser(String username){
Connection connection = DBOpenHelper.getConn(); Connection connection = DBOpenHelper.getConn();
User user = null; User user = null;
try{ try{
Log.d(TAG, "findUser");
String sql = "select * from users where username = ?"; String sql = "select * from users where username = ?";
if(connection != null){ if(connection != null){
PreparedStatement ps = connection.prepareStatement(sql); PreparedStatement ps = connection.prepareStatement(sql);
@ -168,26 +152,21 @@ public class userManager {
String passWord = rs.getString(3); String passWord = rs.getString(3);
String phoneNum = rs.getString(4); String phoneNum = rs.getString(4);
user = new User(userId, userName, passWord, phoneNum);//若已有用户,生成用户类并返回 user = new User(userId, userName, passWord, phoneNum);
} }
} }
} }
} catch (SQLException throwables) { } catch (SQLException throwables) {
throwables.printStackTrace(); throwables.printStackTrace();
} finally {
} }
return user; return user;
} }
public boolean register(User user){//注册功能 public boolean register(User user){
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
Connection connection = DBOpenHelper.getConn(); Connection connection = DBOpenHelper.getConn();
try{ try{
Log.d(TAG, "register");
String sql = "insert into users(username, password, phonenum) values (?,?,?)"; String sql = "insert into users(username, password, phonenum) values (?,?,?)";
if(connection != null){ if(connection != null){
@ -214,21 +193,16 @@ public class userManager {
e.printStackTrace(); e.printStackTrace();
Log.e(TAG, "异常 register"); Log.e(TAG, "异常 register");
return false; return false;
} finally {
} }
} }
public int change(String phonenum, String password){//修改密码 public int change(String phonenum, String password){
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
Connection connection = DBOpenHelper.getConn(); Connection connection = DBOpenHelper.getConn();
int msg = 0; int msg = 0;
try{ try{
Log.d(TAG, "change");
String sql = "update users set password = ? where phonenum = ?"; String sql = "update users set password = ? where phonenum = ?";
if(connection != null){ if(connection != null){
@ -256,8 +230,6 @@ public class userManager {
e.printStackTrace(); e.printStackTrace();
Log.d(TAG, "login bug: " + e.getMessage()); Log.d(TAG, "login bug: " + e.getMessage());
msg = 0; msg = 0;
} finally {
} }
return msg; return msg;
} }

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

@ -32,8 +32,6 @@ public class MD5Utils {
e.printStackTrace(); e.printStackTrace();
//发送异常return空字符串 //发送异常return空字符串
return ""; return "";
} finally {
} }
} }
} }

@ -19,34 +19,26 @@ import androidx.fragment.app.Fragment;
import com.example.logistics.R; import com.example.logistics.R;
import com.example.logistics.manager.goodManager; import com.example.logistics.manager.goodManager;
//查询快件存放地
public class FindUI extends Fragment implements View.OnClickListener{
private String TAG = "FindUI";
public class FindActivity extends Fragment implements View.OnClickListener{
private Context mContext; private Context mContext;
private Button mButton; private Button mButton;
private EditText mPickUpCode; private EditText mPickUpCode;
private EditText mPhoneNum; private EditText mPhoneNum;
public FindUI(){ public FindActivity(){
} }
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.my_fragment1,container,false);
Log.d(TAG, "onCreateView");
View view = inflater.inflate(R.layout.frag_find,container,false);
mButton = (Button)view.findViewById(R.id.Sea_Button); mButton = (Button)view.findViewById(R.id.Sea_Button);
mPickUpCode = (EditText)view.findViewById(R.id.Sea_PickUpCode); mPickUpCode = (EditText)view.findViewById(R.id.Sea_PickUpCode);
mPhoneNum = (EditText)view.findViewById(R.id.Sea_PhoneNum); mPhoneNum = (EditText)view.findViewById(R.id.Sea_PhoneNum);
mButton.setOnClickListener(this); mButton.setOnClickListener(this);
mContext = getActivity(); mContext = getActivity();
return view; return view;
} }
@ -54,10 +46,7 @@ public class FindUI extends Fragment implements View.OnClickListener{
public void onClick(View v) { public void onClick(View v) {
switch(v.getId()){ switch(v.getId()){
case R.id.Sea_Button: case R.id.Sea_Button:
Log.d(TAG, "search");
search(v); search(v);
break; break;
} }
} }
@ -68,7 +57,7 @@ public class FindUI extends Fragment implements View.OnClickListener{
@Override @Override
public void run(){ public void run(){
goodManager goodManager = new goodManager(); goodManager goodManager = new goodManager();
int msg = goodManager.search(mPickUpCode.getText().toString().trim(), mPhoneNum.getText().toString().trim(), getActivity());//查询快件位置并返回结果 int msg = goodManager.search(mPickUpCode.getText().toString().trim(), mPhoneNum.getText().toString().trim(), getActivity());
Log.e("Main", "msg"); Log.e("Main", "msg");
hand1.sendEmptyMessage(msg); hand1.sendEmptyMessage(msg);
} }
@ -79,7 +68,6 @@ public class FindUI extends Fragment implements View.OnClickListener{
final Handler hand1 = new Handler(){ final Handler hand1 = new Handler(){
@Override @Override
public void handleMessage(Message msg){ public void handleMessage(Message msg){
if(msg.what == 0){ if(msg.what == 0){
Toast.makeText(mContext, "搜索失败", Toast.LENGTH_SHORT).show(); Toast.makeText(mContext, "搜索失败", Toast.LENGTH_SHORT).show();
}else if(msg.what == 2){ }else if(msg.what == 2){
@ -87,7 +75,6 @@ public class FindUI extends Fragment implements View.OnClickListener{
}else if(msg.what == 3){ }else if(msg.what == 3){
Toast.makeText(mContext, "取件码不存在", Toast.LENGTH_SHORT).show(); Toast.makeText(mContext, "取件码不存在", Toast.LENGTH_SHORT).show();
} }
} }
}; };
} }

@ -25,10 +25,9 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class HistoryUI extends Activity implements OnItemClickListener, OnScrollListener, View.OnClickListener { public class HistoryActivity extends Activity implements OnItemClickListener, OnScrollListener, View.OnClickListener {
private String TAG = "HistoryUI"; private String TAG = "HistoryActivity";
//绑定界面元素
private ListView lv_history; private ListView lv_history;
private ArrayAdapter<String> arr_adapter; private ArrayAdapter<String> arr_adapter;
private SimpleAdapter simp_adapter; private SimpleAdapter simp_adapter;
@ -38,9 +37,6 @@ public class HistoryUI extends Activity implements OnItemClickListener, OnScroll
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "onCreate");
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_history); setContentView(R.layout.activity_history);
sync_his = (ImageButton) findViewById(R.id.sync_his); sync_his = (ImageButton) findViewById(R.id.sync_his);
@ -56,7 +52,6 @@ public class HistoryUI extends Activity implements OnItemClickListener, OnScroll
Intent intent = getIntent(); Intent intent = getIntent();
phonenum = intent.getStringExtra("user"); phonenum = intent.getStringExtra("user");
Log.d(TAG, "onCreate");
sync(); sync();
} }
@ -71,12 +66,12 @@ public class HistoryUI extends Activity implements OnItemClickListener, OnScroll
public void onClick(View v){ public void onClick(View v){
switch(v.getId()){ switch(v.getId()){
case R.id.sync_his: case R.id.sync_his:
sync();//调用同步按钮同步记录 sync();
Toast.makeText(this, "同步成功", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "同步成功", Toast.LENGTH_SHORT).show();
} }
} }
@Override @Override
public void onScrollStateChanged(AbsListView view, int scrollState){//上下划动屏幕查看操作记录 public void onScrollStateChanged(AbsListView view, int scrollState){
// TODO Auto-generated method stub // TODO Auto-generated method stub
switch(scrollState){ switch(scrollState){
case SCROLL_STATE_FLING: case SCROLL_STATE_FLING:
@ -99,14 +94,11 @@ public class HistoryUI extends Activity implements OnItemClickListener, OnScroll
} }
public void sync(){ public void sync(){
Log.d(TAG, "sync");
new Thread(){ new Thread(){
@Override @Override
public void run(){ public void run(){
operationManager operationManager = new operationManager(); operationManager operationManager = new operationManager();
dataList = operationManager.history(phonenum);//调用operationManager的查询历史记录 dataList = operationManager.history(phonenum);
int msg = 1; int msg = 1;
hand1.sendEmptyMessage(msg); hand1.sendEmptyMessage(msg);
@ -119,7 +111,7 @@ public class HistoryUI extends Activity implements OnItemClickListener, OnScroll
@Override @Override
public void handleMessage(Message msg){ public void handleMessage(Message msg){
if(msg.what == 1){ if(msg.what == 1){
simp_adapter=new SimpleAdapter(HistoryUI.this, dataList, R.layout.item, new String[]{"pickupcode","time"}, new int[]{R.id.np_id,R.id.np_time}); simp_adapter=new SimpleAdapter(HistoryActivity.this, dataList, R.layout.item, new String[]{"pickupcode","time"}, new int[]{R.id.np_id,R.id.np_time});
lv_history.setAdapter(simp_adapter); lv_history.setAdapter(simp_adapter);
} }
} }

@ -1,12 +1,15 @@
package com.example.logistics.ui; package com.example.logistics.ui;
import com.example.logistics.R; import com.example.logistics.R;
import com.example.logistics.manager.goodManager;
import com.example.logistics.manager.operationManager;
import com.example.logistics.manager.userManager; import com.example.logistics.manager.userManager;
import com.example.logistics.entity.User; import com.example.logistics.entity.User;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
@ -17,10 +20,13 @@ import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Toast; import android.widget.Toast;
import org.json.JSONException;
import org.json.JSONObject;
public class LoginUI extends Activity {
public class LoginActivity extends Activity {
private int islogin = 0;
private Button loginButton; private Button loginButton;
private Button signUpButton; private Button signUpButton;
private Button forgetButton; private Button forgetButton;
@ -29,29 +35,26 @@ public class LoginUI extends Activity {
private Button changeButton; private Button changeButton;
private EditText fphonenum; private EditText fphonenum;
private EditText fpassword; private EditText fpassword;
private int islogin = 0;
int flag = 0; //flag = 0 是用户名登录;=1是手机号 int flag = 0; //flag = 0 是用户名登录;=1是手机号
// 调用Actvity // 调用Actvity
private String TAG = "LoginUI"; private String TAG = "LoginActivity";
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login); setContentView(R.layout.activity_main);
loginButton = (Button) this.findViewById(R.id.LoginButton); loginButton = (Button) this.findViewById(R.id.LoginButton);
signUpButton = (Button) this.findViewById(R.id.SignUpButton); signUpButton = (Button) this.findViewById(R.id.SignUpButton);
forgetButton = (Button) this.findViewById(R.id.forget); forgetButton = (Button) this.findViewById(R.id.forget);
phonenumButton = (Button) this.findViewById(R.id.phonenum); phonenumButton = (Button) this.findViewById(R.id.phonenum);
//设置对话框引用Activity对象
AlertDialog.Builder builder = new AlertDialog.Builder(LoginUI.this);
//使用别的layout AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
View view2 = View.inflate(LoginUI.this, R.layout.forget, null);
builder.setTitle("忘记密码").setView(view2); View view2 = View.inflate(LoginActivity.this, R.layout.forget, null);
builder.setTitle("取件").setView(view2);
alert = builder.create(); alert = builder.create();
@ -73,7 +76,7 @@ public class LoginUI extends Activity {
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(LoginUI.this, SignUpUI.class); Intent intent = new Intent(LoginActivity.this, SignUpActivity.class);
Log.d(TAG, "signup"); Log.d(TAG, "signup");
startActivity(intent); startActivity(intent);
} }
@ -103,7 +106,6 @@ public class LoginUI extends Activity {
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
//输入提示
userName.setHint("请输入手机号"); userName.setHint("请输入手机号");
flag = 1; flag = 1;
} }
@ -113,22 +115,18 @@ public class LoginUI extends Activity {
} }
public void change(View view){ public void change(View view){
//trim() 方法用于删除字符串的头尾空白符,空白符包括:空格、制表符 tab、换行符等其他空白符等。
String phoneunm = fphonenum.getText().toString().trim(); String phoneunm = fphonenum.getText().toString().trim();
String password = fpassword.getText().toString().trim(); String password = fpassword.getText().toString().trim();
new Thread() { new Thread() {
@Override @Override
public void run() { public void run() {
//后端用来和数据库交互
userManager userManager = new userManager(); userManager userManager = new userManager();
//msg=0代表操作成功
int msg = userManager.change(phoneunm, password); int msg = userManager.change(phoneunm, password);
Log.d(TAG, "change"); Log.d(TAG, "change");
if(msg != 1){ if(msg != 1){
Log.d(TAG, "pickup,failed"); Log.d(TAG, "pickup,failed");
//处理异步消息int类型的msg最终会转化为hander的msg类型
hand2.sendEmptyMessage(msg); hand2.sendEmptyMessage(msg);
return; return;
} }
@ -140,8 +138,6 @@ public class LoginUI extends Activity {
} }
public void login(View view){ public void login(View view){
Log.d(TAG, "login");
EditText userName = (EditText) this.findViewById(R.id.UserNameEdit); EditText userName = (EditText) this.findViewById(R.id.UserNameEdit);
EditText passWord = (EditText) this.findViewById(R.id.PassWordEdit); EditText passWord = (EditText) this.findViewById(R.id.PassWordEdit);
@ -158,12 +154,10 @@ public class LoginUI extends Activity {
} }
Log.e("MAin", "msg"); Log.e("MAin", "msg");
hand1.sendEmptyMessage(msg); hand1.sendEmptyMessage(msg);
//msg==1表示登录成功
if(msg == 1){ if(msg == 1){
User owner = userManager.findUser(userName.getText().toString().trim()); User owner = userManager.findUser(userName.getText().toString().trim());
Intent intent = new Intent(LoginUI.this, MenuActivity.class); Intent intent = new Intent(LoginActivity.this, MenuActivity.class);
if(flag == 1){ if(flag == 1){
//不同activity之间传递数据
intent.putExtra("user", userName.getText().toString().trim()); intent.putExtra("user", userName.getText().toString().trim());
}else{ }else{
intent.putExtra("user", owner.getPhoneNum()); intent.putExtra("user", owner.getPhoneNum());
@ -196,9 +190,9 @@ public class LoginUI extends Activity {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
if(msg.what == 0){ if(msg.what == 0){
Toast.makeText(LoginUI.this, "修改失败", Toast.LENGTH_SHORT).show(); Toast.makeText(LoginActivity.this, "修改失败", Toast.LENGTH_SHORT).show();
}else if(msg.what == 1) { }else if(msg.what == 1) {
Toast.makeText(LoginUI.this, "修改成功", Toast.LENGTH_SHORT).show(); Toast.makeText(LoginActivity.this, "修改成功", Toast.LENGTH_SHORT).show();
} }
} }
}; };

@ -1,4 +1,5 @@
package com.example.logistics.ui; package com.example.logistics.ui;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction; import androidx.fragment.app.FragmentTransaction;
@ -16,74 +17,68 @@ import androidx.fragment.app.FragmentManager;
import com.example.logistics.R; import com.example.logistics.R;
public class MenuActivity extends AppCompatActivity implements View.OnClickListener{ public class MenuActivity extends AppCompatActivity implements View.OnClickListener{
private LinearLayout ly_one,ly_two,ly_three;
private LinearLayout ly_one,ly_two,ly_three; //线性布局变量 private TextView mTextView1,mTextView2,mTextView3;
private TextView mTextView1,mTextView2,mTextView3; //文本框变量 private TextView mTextNum1,mTextNum2,mTextNum3;
private TextView mTextNum1,mTextNum2,mTextNum3; //第二类文本框变量 private ImageView mImageView;
private ImageView mImageView; //图像视图变量
//创建一系列成员变量:
private Fragment mFrag1; private Fragment mFrag1;
private Fragment mFrag2; private Fragment mFrag2;
private Fragment mFrag3; private Fragment mFrag3;
//创建Frag变量
private String owner; //唯一标识用户 private String owner;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
super.onCreate(savedInstanceState); //调用父类的构造函数 bindView();
setContentView(R.layout.activity_menu); //将类和布局文件绑定
bindView(); //调用bindView()
Intent intent = getIntent(); Intent intent = getIntent();
owner = intent.getStringExtra("user"); owner = intent.getStringExtra("user");
selectTab(0); selectTab(0);
} //类的构造函数 }
private void bindView() { private void bindView() {
ly_one = (LinearLayout)findViewById(R.id.ly_tab_menu_deal); ly_one = (LinearLayout)findViewById(R.id.ly_tab_menu_deal);
ly_two = (LinearLayout)findViewById(R.id.ly_tab_menu_poi); ly_two = (LinearLayout)findViewById(R.id.ly_tab_menu_poi);
ly_three = (LinearLayout)findViewById(R.id.ly_tab_menu_more); //把三个布局绑定到布局变量上 ly_three = (LinearLayout)findViewById(R.id.ly_tab_menu_more);
mTextView1 = (TextView)findViewById(R.id.tab_menu_deal); mTextView1 = (TextView)findViewById(R.id.tab_menu_deal);
mTextView2 = (TextView)findViewById(R.id.tab_menu_poi); mTextView2 = (TextView)findViewById(R.id.tab_menu_poi);
mTextView3 = (TextView)findViewById(R.id.tab_menu_more); //把三个文本框绑定到变量上 mTextView3 = (TextView)findViewById(R.id.tab_menu_more);
mTextNum1 = (TextView)findViewById(R.id.tab_menu_deal_num); mTextNum1 = (TextView)findViewById(R.id.tab_menu_deal_num);
mTextNum2 = (TextView)findViewById(R.id.tab_menu_poi_num); mTextNum2 = (TextView)findViewById(R.id.tab_menu_poi_num);
mTextNum3 = (TextView)findViewById(R.id.tab_menu_more_num); //把三个第二类文本框绑定到变量上 mTextNum3 = (TextView)findViewById(R.id.tab_menu_more_num);
ly_one.setOnClickListener(this); ly_one.setOnClickListener(this);
ly_two.setOnClickListener(this); ly_two.setOnClickListener(this);
ly_three.setOnClickListener(this); //监听器:点击三个区域绑定三个功能 ly_three.setOnClickListener(this);
} //绑定变量和布局元素 }
//重置所有文本的选中状态 //重置所有文本的选中状态
private void setSelected() { private void setSelected() {
mTextView1.setSelected(false); mTextView1.setSelected(false);
mTextView2.setSelected(false); mTextView2.setSelected(false);
mTextView3.setSelected(false); mTextView3.setSelected(false);
} //每次选中一按钮,先全设为未选中 }
@Override @Override
public void onClick(View v) { //点击某区域实现某功能 public void onClick(View v) {
setSelected(); //全部设为未选中 setSelected();
switch (v.getId()) { switch (v.getId()) {
case R.id.ly_tab_menu_deal: //倘若点到这个id对应的 case R.id.ly_tab_menu_deal:
selectTab(0); //使第一个标签变蓝色 selectTab(0);
break; break;
case R.id.ly_tab_menu_poi: case R.id.ly_tab_menu_poi:
selectTab(1); selectTab(1);
break; break;
case R.id.ly_tab_menu_more: case R.id.ly_tab_menu_more:
selectTab(2); selectTab(2);
break; //分析已点击区域对应的功能 break;
} }
} }
@ -98,7 +93,7 @@ public class MenuActivity extends AppCompatActivity implements View.OnClickListe
mTextView1.setSelected(true); mTextView1.setSelected(true);
mTextNum1.setVisibility(View.INVISIBLE); mTextNum1.setVisibility(View.INVISIBLE);
if (mFrag1 == null) { if (mFrag1 == null) {
mFrag1 = new FindUI(); mFrag1 = new FindActivity();
transaction.add(R.id.fragment_container, mFrag1); transaction.add(R.id.fragment_container, mFrag1);
@ -111,7 +106,7 @@ public class MenuActivity extends AppCompatActivity implements View.OnClickListe
mTextView2.setSelected(true); mTextView2.setSelected(true);
mTextNum2.setVisibility(View.INVISIBLE); mTextNum2.setVisibility(View.INVISIBLE);
if (mFrag2 == null) { if (mFrag2 == null) {
mFrag2 = new PickUpUI(); mFrag2 = new PickUpActivity();
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("user", owner); bundle.putString("user", owner);
mFrag2.setArguments(bundle); mFrag2.setArguments(bundle);
@ -125,7 +120,7 @@ public class MenuActivity extends AppCompatActivity implements View.OnClickListe
mTextView3.setSelected(true); mTextView3.setSelected(true);
mTextNum3.setVisibility(View.INVISIBLE); mTextNum3.setVisibility(View.INVISIBLE);
if (mFrag3 == null) { if (mFrag3 == null) {
mFrag3 = new SetUI(); mFrag3 = new SetActivity();
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("user", owner); bundle.putString("user", owner);
mFrag3.setArguments(bundle); mFrag3.setArguments(bundle);

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

Loading…
Cancel
Save