添加功能:查询快件 #9

Merged
pyxu2pz5g merged 1 commits from Fanyiwen_branch into dev 3 years ago

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

@ -48,7 +48,9 @@ public class goodDao {
StringBuilder s = new StringBuilder();
for(String key:map.keySet()){
if(key.equals("phonenum")){
if(phonenum.equals(map.get(key))){
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("快件位置");

@ -0,0 +1,57 @@
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,47 @@
package com.example.logistics.entity;
import android.provider.ContactsContract;
public class Operation {
private int id;
private String pickUpCode;
private String phoneNum;
private String time;
public Operation(){
}
public int getId(){
return id;
}
public void setId(int id){
this.id = id;
}
public String getPickUpCode(){
return pickUpCode;
}
public void setPickUpCode(String PickUpCode){
this.pickUpCode = PickUpCode;
}
public String getPhoneNum(){
return phoneNum;
}
public void setPhoneNum(String PhoneNum){
this.phoneNum = PhoneNum;
}
public String getTime(){
return time;
}
public void setTime(String time){
this.time = time;
}
}

@ -2,6 +2,7 @@ package com.example.logistics.ui;
import com.example.logistics.R;
import com.example.logistics.dao.userDao;
import com.example.logistics.entity.User;
import com.example.logistics.tools.MD5Utils;
import android.annotation.SuppressLint;
@ -65,7 +66,9 @@ public class MainActivity extends Activity {
Log.e("MAin", "msg");
hand1.sendEmptyMessage(msg);
if(msg == 1){
User owner = userDao.findUser(userName.getText().toString().trim());
Intent intent = new Intent(MainActivity.this, MenuActivity.class);
intent.putExtra("name", owner.getPhoneNum());
startActivity(intent);
}
}

@ -2,7 +2,10 @@ package com.example.logistics.ui;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
@ -23,12 +26,17 @@ public class MenuActivity extends AppCompatActivity implements View.OnClickListe
private Fragment mFrag2;
private Fragment mFrag3;
private String owner;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
bindView();
Intent intent = getIntent();
owner = intent.getStringExtra("name");
selectTab(0);
}
@ -97,7 +105,11 @@ public class MenuActivity extends AppCompatActivity implements View.OnClickListe
mTextNum2.setVisibility(View.INVISIBLE);
if (mFrag2 == null) {
mFrag2 = new MyFragment2();
transaction.add(R.id.fragment_container, mFrag2);
Bundle bundle = new Bundle();
bundle.putString("user", owner);
mFrag2.setArguments(bundle);
transaction.add(R.id.fragment_container, mFrag2, "frag2");
} else {
transaction.show(mFrag2);
}
@ -129,4 +141,17 @@ public class MenuActivity extends AppCompatActivity implements View.OnClickListe
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
Log.d("on", "Activity");
FragmentManager fm = getSupportFragmentManager();
Fragment fr = fm.findFragmentByTag("frag2");
fr.onActivityResult(requestCode, resultCode, data);
}
public String getOwner(){
return owner;
}
}

@ -7,6 +7,9 @@ import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -18,6 +21,9 @@ import android.widget.Toast;
import androidx.annotation.Nullable;
import com.example.logistics.R;
import com.example.logistics.dao.operationDao;
import com.example.logistics.dao.userDao;
import com.example.logistics.entity.User;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
import com.journeyapps.barcodescanner.CaptureActivity;
@ -36,6 +42,7 @@ public class MyFragment2 extends Fragment implements View.OnClickListener{
View view = inflater.inflate(R.layout.my_fragment2,container,false);
mButton = (Button)view.findViewById(R.id.Pick_Button);
mButton.setOnClickListener(this);
mContext = getActivity();
return view;
}
@ -84,22 +91,33 @@ public class MyFragment2 extends Fragment implements View.OnClickListener{
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(mContext, "取件成功", Toast.LENGTH_LONG).show();
String pickupcode = PickUpCode.getText().toString().trim();
String phonenum = PhoneNum.getText().toString().trim();
Log.d("onclick", "123");
String QR_pickup = result.split(" ")[0];
String QR_phone = result.split(" ")[1];
if(pickupcode.equals(QR_pickup) && pickupcode.equals(QR_phone)){
if (pickupcode.equals(QR_pickup) && pickupcode.equals(QR_phone)) {
Toast.makeText(mContext, "取件成功", Toast.LENGTH_LONG).show();
}else{
new Thread() {
@Override
public void run() {
operationDao operationDao = new operationDao();
Bundle bundle = getArguments();
String user = bundle.getString("user");
boolean flag = operationDao.add(pickupcode, user);
if (flag) {
Log.d("add", "success");
} else {
Log.d("add", "failed");
}
}
}.start();
} else {
Toast.makeText(mContext, "取件失败", Toast.LENGTH_LONG).show();
}
}
});
}
}
}

@ -18,4 +18,5 @@ android.useAndroidX=true
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.nonTransitiveRClass=true
android.enableJetifier=true
Loading…
Cancel
Save