|
|
@ -18,31 +18,30 @@ import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
public class goodManager {
|
|
|
|
public class goodManager {
|
|
|
|
|
|
|
|
|
|
|
|
private static final String TAG = "goodDao";
|
|
|
|
private static final String TAG = "goodManager";
|
|
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
Connection connection = DBOpenHelper.getConn();//DBO连接数据库
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 = ?";
|
|
|
|
String sql = "select * from goods where id = ?";//搜索指定取件码(=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));
|
|
|
|
ps.setInt(1,Integer.parseInt(id));//设置sql语句中id号
|
|
|
|
ResultSet rs = ps.executeQuery();
|
|
|
|
ResultSet rs = ps.executeQuery();//执行sql语句并返回结果到rs
|
|
|
|
|
|
|
|
|
|
|
|
int count = rs.getMetaData().getColumnCount();
|
|
|
|
int count = rs.getMetaData().getColumnCount();
|
|
|
|
while(rs.next()){
|
|
|
|
while(rs.next()){//遍历返回结果加入map中
|
|
|
|
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));
|
|
|
@ -53,14 +52,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()){
|
|
|
|
for(String key:map.keySet()){//搜索map中的key值
|
|
|
|
if(key.equals("phonenum")){
|
|
|
|
if(key.equals("phonenum")){//搜索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();
|
|
|
@ -89,11 +88,14 @@ 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{
|
|
|
@ -105,9 +107,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();
|
|
|
@ -121,13 +123,16 @@ 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");
|
|
|
@ -162,7 +167,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();
|
|
|
@ -175,11 +180,13 @@ 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();
|
|
|
@ -195,7 +202,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()){
|
|
|
@ -206,12 +213,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
|
|
|
@ -235,6 +242,8 @@ 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|