|
@@ -21,8 +21,10 @@ import com.sunwin.visitorapp.adapter.DepartmentAdapter;
|
|
|
import com.sunwin.visitorapp.adapter.NetInfoAdapter;
|
|
|
import com.sunwin.visitorapp.db.DatabaseManager;
|
|
|
import com.sunwin.visitorapp.db.UserInfoModel;
|
|
|
+import com.sunwin.visitorapp.face.SwFaceLoop;
|
|
|
import com.sunwin.visitorapp.model.DepartmentResult;
|
|
|
import com.sunwin.visitorapp.model.NetInfo;
|
|
|
+import com.sunwin.visitorapp.model.OpenDoorByFaceNetResultInfo;
|
|
|
import com.sunwin.visitorapp.net.ApiService;
|
|
|
import com.sunwin.visitorapp.net.BaseRsult;
|
|
|
import com.sunwin.visitorapp.net.CommonRequest;
|
|
@@ -64,12 +66,13 @@ public class VisitorRegisterAc extends BaseActivity implements View.OnClickListe
|
|
|
private EditText mEditByVisitPeople;
|
|
|
private Spinner mEditByVisitDepartment;
|
|
|
private TextView mTextButtonSure;
|
|
|
+ private Spinner sp_net;
|
|
|
private TimePickerDialog timePickerDialog;
|
|
|
private long tenYears = 10L * 365 * 1000 * 60 * 60 * 24L;
|
|
|
private int dateLabel;
|
|
|
private List<DepartmentResult> mDepartmentList;
|
|
|
private List<NetInfo> mNetInfoList;
|
|
|
- private Spinner sp_net;
|
|
|
+ private OpenDoorByFaceNetResultInfo userInfo;
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
@@ -77,9 +80,8 @@ public class VisitorRegisterAc extends BaseActivity implements View.OnClickListe
|
|
|
setContentView(R.layout.ac_visitor_register);
|
|
|
mDepartmentList = DatabaseManager.getInstance().getQueryAll(DepartmentResult.class);
|
|
|
mNetInfoList = DatabaseManager.getInstance().getQueryAll(NetInfo.class);
|
|
|
-
|
|
|
-
|
|
|
currentFacePath = getIntent().getStringExtra(Constant.IIntentValue.CURRENTFACEPATH);
|
|
|
+ userInfo = (OpenDoorByFaceNetResultInfo) getIntent().getSerializableExtra(Constant.IIntentValue.RECOGNIZE_INFO);
|
|
|
UINav uiNav = findViewById(R.id.UINav);
|
|
|
uiNav.setData(this, "访客登记");
|
|
|
initView();
|
|
@@ -131,8 +133,8 @@ public class VisitorRegisterAc extends BaseActivity implements View.OnClickListe
|
|
|
mComeReason = findViewById(R.id.comeReason);
|
|
|
mEditCompany = (EditText) findViewById(R.id.EditCompany);
|
|
|
mEditCarPlate = (EditText) findViewById(R.id.EditCarPlate);
|
|
|
- mEditVisitTimeBegin = findViewById(R.id.EditVisitTimeBegin);
|
|
|
- mEditVisitTimeEnd = findViewById(R.id.EditVisitTimeEnd);
|
|
|
+ mEditVisitTimeBegin = findViewById(R.id.EditVisitTimeBegin);
|
|
|
+ mEditVisitTimeEnd = findViewById(R.id.EditVisitTimeEnd);
|
|
|
mEditVisitNumber = (EditText) findViewById(R.id.EditVisitNumber);
|
|
|
mEditVisitPeopleCount = (EditText) findViewById(R.id.EditVisitPeopleCount);
|
|
|
mEditICCode = (EditText) findViewById(R.id.EditICCode);
|
|
@@ -144,8 +146,16 @@ public class VisitorRegisterAc extends BaseActivity implements View.OnClickListe
|
|
|
mEditVisitTimeBegin.setOnClickListener(this);
|
|
|
mEditVisitTimeEnd.setOnClickListener(this);
|
|
|
|
|
|
- showHead(currentFacePath, mImageVisitorPhoto);
|
|
|
sp_net = findViewById(R.id.sp_net);
|
|
|
+ initViewInfo();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initViewInfo() {
|
|
|
+ //
|
|
|
+ showHead(currentFacePath, mImageVisitorPhoto);
|
|
|
+ mTextVisitorIdCode.setText(userInfo.getIdNum());
|
|
|
+ mTextVisitorName.setText(userInfo.getPerson_name());
|
|
|
}
|
|
|
|
|
|
private void showHead(String path, ImageView iv_head) {
|
|
@@ -172,6 +182,7 @@ public class VisitorRegisterAc extends BaseActivity implements View.OnClickListe
|
|
|
}
|
|
|
|
|
|
private void submit() {
|
|
|
+ UserInfoModel oldUserinfo = null;
|
|
|
loadingDialog.showLoadingDialog("");
|
|
|
|
|
|
String phone = mEditPhone.getText().toString().trim();
|
|
@@ -189,7 +200,6 @@ public class VisitorRegisterAc extends BaseActivity implements View.OnClickListe
|
|
|
String comeReason = mComeReason.getText().toString().trim();
|
|
|
String company = mEditCompany.getText().toString().trim();
|
|
|
|
|
|
- idNum = "330101199011112580";
|
|
|
UserInfoModel infoModel = new UserInfoModel();
|
|
|
infoModel.setPhone(phone);
|
|
|
infoModel.setVisitorLpCode(carPlate);
|
|
@@ -197,17 +207,27 @@ public class VisitorRegisterAc extends BaseActivity implements View.OnClickListe
|
|
|
infoModel.setLostDate(endTime);
|
|
|
infoModel.setCardNo(cardNum);
|
|
|
infoModel.setIdNum(idNum);
|
|
|
- infoModel.setStatus(-2);
|
|
|
+ if (isLogin) {
|
|
|
+ infoModel.setStatus(0);
|
|
|
+ } else {
|
|
|
+ infoModel.setStatus(-2);
|
|
|
+ }
|
|
|
infoModel.setType(2);
|
|
|
infoModel.setPersonName(name);
|
|
|
- infoModel.setDeptId(deptNo+"");
|
|
|
+ infoModel.setDeptId(deptNo + "");
|
|
|
infoModel.setCategoryId(categoryId);
|
|
|
|
|
|
+ List<UserInfoModel> userInfoModels = DatabaseManager.getInstance().query(UserInfoModel.class, "idNum", idNum);
|
|
|
+ if (userInfoModels.size() != 0) {
|
|
|
+ oldUserinfo = userInfoModels.get(0);
|
|
|
+ infoModel.setPersonId(oldUserinfo.getPersonId());
|
|
|
+ }
|
|
|
|
|
|
ApiService apiService = RetrofitUtil.getApiService();
|
|
|
MediaType textType = MediaType.parse("text/plain");
|
|
|
final RequestBody requestBody = RequestBody.create(textType, RetrofitUtil.bean2Json(infoModel));
|
|
|
Call<BaseRsult<String>> call = apiService.saveOrUpdatePersonInfo(requestBody);
|
|
|
+ UserInfoModel finalOldUserinfo = oldUserinfo;
|
|
|
call.enqueue(new Callback<BaseRsult<String>>() {
|
|
|
@Override
|
|
|
public void onResponse(Call<BaseRsult<String>> call, Response<BaseRsult<String>> response) {
|
|
@@ -220,8 +240,16 @@ public class VisitorRegisterAc extends BaseActivity implements View.OnClickListe
|
|
|
int code = response.body().getCode();
|
|
|
LogUtil.e(TAG, "--code--" + code);
|
|
|
if (code == 0) {
|
|
|
- String result = response.body().getResult();
|
|
|
- addFace(currentFacePath, result);
|
|
|
+ String personId = response.body().getResult();
|
|
|
+ String faceToken = SwFaceLoop.getInstance().addFace(currentFacePath);
|
|
|
+
|
|
|
+ infoModel.setInsetTime(TimeUtils.stampToDate(System.currentTimeMillis()));
|
|
|
+ infoModel.setFaceToken(faceToken);
|
|
|
+ infoModel.setPersonId(personId);
|
|
|
+ addFace(currentFacePath, personId);
|
|
|
+ if (finalOldUserinfo != null) {
|
|
|
+ DatabaseManager.getInstance().delete(finalOldUserinfo);
|
|
|
+ }
|
|
|
//存入数据库
|
|
|
long insert = DatabaseManager.getInstance().insert(infoModel);
|
|
|
LogUtil.e(TAG, "存入用户" + insert);
|