| | |
| | | import android.widget.Toast;
|
| | |
|
| | | import cn.com.basic.face.base.BaseApplication;
|
| | | import cn.com.basic.face.base.MainActivity;
|
| | | import cn.com.basic.face.discern.common.CommonVariables;
|
| | | import cn.com.basic.face.discern.common.ResultBean;
|
| | | import cn.com.basic.face.discern.common.SqliteSqlBean;
|
| | | import cn.com.basic.face.discern.entity.Register;
|
| | | import cn.com.basic.face.discern.query.item.CheckInQueryItem;
|
| | | import cn.com.basic.face.discern.query.item.OfflineAttenderRegisterItem;
|
| | | import cn.com.basic.face.discern.query.item.OfflineVisitorRegisterItem;
|
| | | import cn.com.basic.face.fragment.AttenderRegisterFragment;
|
| | | import cn.com.basic.face.fragment.CheckInFragment;
|
| | | import cn.com.basic.face.fragment.VisitorRegisterFragment;
|
| | | import cn.com.basic.face.service.sqlite.CheckInDao;
|
| | | import cn.com.basic.face.service.sqlite.RegisterDao;
|
| | | import cn.com.basic.face.util.AppApi;
|
| | |
|
| | | import org.xutils.http.RequestParams;
|
| | |
| | |
|
| | | import java.io.File;
|
| | | import java.io.FileWriter;
|
| | | import java.util.List;
|
| | |
|
| | | import cn.com.basic.face.discern.common.BaseCommonCallBack;
|
| | | import cn.com.basic.face.util.IdCard;
|
| | | import cn.com.basic.face.util.SqliteSqlUtil;
|
| | |
|
| | | public class RegisterMng {
|
| | |
|
| | |
| | | return instance;
|
| | | }
|
| | |
|
| | | public void add(RequestParams params) {
|
| | | public void add(RequestParams params, String idCardHeadPhoto, Register offlineVisitorRegisterItem) {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | if (BaseApplication.getInstance().networkAvailable()) {
|
| | | try {
|
| | | File path = BaseApplication.getInstance().getFilesDir();
|
| | | File rawSurveillancePhotoFile = new File(path, "rawSurveillancePhoto");
|
| | | if (!rawSurveillancePhotoFile.exists()) {
|
| | | rawSurveillancePhotoFile.createNewFile();
|
| | | }
|
| | | File f0 = new File(path, "f0");
|
| | | if (!f0.exists()) {
|
| | | f0.createNewFile();
|
| | | }
|
| | | File surveillancePhotoFile = new File(path, "surveillancePhoto");
|
| | | if (!surveillancePhotoFile.exists()) {
|
| | | surveillancePhotoFile.createNewFile();
|
| | | }
|
| | | File uploadCustomPhotoFile = new File(path, "uploadCustomPhoto");
|
| | | if (!uploadCustomPhotoFile.exists()) {
|
| | | uploadCustomPhotoFile.createNewFile();
|
| | | }
|
| | | File idCardPhotoFile = new File(path, "idCardPhoto");
|
| | | if (!idCardPhotoFile.exists()) {
|
| | | idCardPhotoFile.createNewFile();
|
| | | }
|
| | |
|
| | | FileWriter fw0 = new FileWriter(f0);
|
| | | fw0.write("test1");
|
| | | fw0.close();
|
| | | params.setUri(AppApi.BASE_URL +AppApi.REGISTER_ADD);
|
| | | params.addBodyParameter("f0", f0);
|
| | | params.addBodyParameter("rawSurveillancePhoto", rawSurveillancePhotoFile);
|
| | | params.addBodyParameter("surveillancePhoto", surveillancePhotoFile);
|
| | | params.addBodyParameter("uploadCustomPhoto", uploadCustomPhotoFile);
|
| | | params.addBodyParameter("idCardPhoto", idCardPhotoFile);
|
| | | params.addBodyParameter("deviceCompanyId", BaseApplication.getInstance().getAndroidDevice().getCompanyId());
|
| | | if (idCardHeadPhoto != null && !"".equals(idCardHeadPhoto)) {
|
| | | File f5 = new File(idCardHeadPhoto);
|
| | | if (!f5.exists()) {
|
| | | f5.createNewFile();
|
| | | }
|
| | | params.addBodyParameter("idCardHeadPhoto", f5);
|
| | | }
|
| | | x.http().post(params, new BaseCommonCallBack() {
|
| | | @Override
|
| | | public void success() {
|
| | | SqliteSqlUtil.insert(getExtraList(SqliteSqlBean.class));
|
| | | Toast.makeText(BaseApplication.getInstance(),"添加成功", Toast.LENGTH_SHORT).show();
|
| | | VisitorRegisterFragment.getInstance().resetForm();
|
| | | MainActivity.selectPage(2);
|
| | | List<CheckInQueryItem> checkInLeftVisitorList = getList(CheckInQueryItem.class);
|
| | | CheckInFragment.getInstance().get_fragment_check_in_left_visitor().show(checkInLeftVisitorList);
|
| | | if (checkInLeftVisitorList.size() > 0) {
|
| | | CheckInFragment.getInstance().checkInFromHomePage(checkInLeftVisitorList.get(0));
|
| | | }
|
| | | }
|
| | | });
|
| | | }catch(Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | } else {
|
| | | try {
|
| | | long registerId = RegisterDao.getInstance().add(offlineVisitorRegisterItem);
|
| | | if (registerId > 0) {
|
| | | MainActivity.selectPage(2);
|
| | | final ResultBean resultBean = (ResultBean) CheckInDao.getInstance().findCheckInLeftVisitorListByVisitorId(registerId);
|
| | |
|
| | | MainActivity.getInstance().runOnUiThread(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | CheckInMng.getInstance().findCheckInLeftListAfterReturn(resultBean, true, false, false);
|
| | | List<CheckInQueryItem> list = (List<CheckInQueryItem>)resultBean.getData();
|
| | | if (list != null && list.size() > 0) {
|
| | | CheckInFragment.getInstance().checkInFromHomePage(list.get(0));
|
| | | }
|
| | | Toast.makeText(BaseApplication.getInstance(),"添加成功", Toast.LENGTH_SHORT).show();
|
| | | VisitorRegisterFragment.getInstance().resetForm();
|
| | | }
|
| | | });
|
| | | } else {
|
| | | MainActivity.getInstance().runOnUiThread(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | Toast.makeText(MainActivity.getInstance(), "添加失败", Toast.LENGTH_SHORT).show();
|
| | | }
|
| | | });
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public void compareSurveillancePhotoAndIdCardPhoto(RequestParams params, final IdCard idCard) {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | try {
|
| | | File path = BaseApplication.getInstance().getFilesDir();
|
| | | File f1 = new File(path, "1.txt");
|
| | | if (!f1.exists()) {
|
| | | f1.createNewFile();
|
| | | File f0 = new File(path, "f0");
|
| | | if (!f0.exists()) {
|
| | | f0.createNewFile();
|
| | | }
|
| | | File f2 = new File(path, "2.txt");
|
| | | if (!f2.exists()) {
|
| | | f2.createNewFile();
|
| | | File surveillancePhotoFile = new File(path, "surveillancePhoto");
|
| | | if (!surveillancePhotoFile.exists()) {
|
| | | surveillancePhotoFile.createNewFile();
|
| | | }
|
| | | FileWriter fw1 = new FileWriter(f1);
|
| | | fw1.write("test1");
|
| | | fw1.close();
|
| | | FileWriter fw2 = new FileWriter(f2);
|
| | | fw2.write("test2");
|
| | | fw2.close();
|
| | | params.setUri(AppApi.BASE_URL +AppApi.REGISTER_ADD);
|
| | | params.addBodyParameter("file1", f1);
|
| | | params.addBodyParameter("file2", f2);
|
| | | File idCardHeadPhotoFile = new File(path, "idCardHeadPhoto");
|
| | | if (!idCardHeadPhotoFile.exists()) {
|
| | | idCardHeadPhotoFile.createNewFile();
|
| | | }
|
| | | FileWriter fw0 = new FileWriter(f0);
|
| | | fw0.write("test1");
|
| | | fw0.close();
|
| | |
|
| | | params.setUri(AppApi.BASE_URL +AppApi.REGISTER_ID_CARD_AUTH);
|
| | | params.addBodyParameter("f0", f0);
|
| | | params.addBodyParameter("surveillancePhoto", surveillancePhotoFile);
|
| | | params.addBodyParameter("idCardPhoto", idCardHeadPhotoFile);
|
| | | params.addBodyParameter("deviceCompanyId", BaseApplication.getInstance().getAndroidDevice().getCompanyId());
|
| | | x.http().post(params, new BaseCommonCallBack() {
|
| | | @Override
|
| | | public void success() {
|
| | | if (!VisitorRegisterFragment.getInstance().visitorRegisterFragmentVisible
|
| | | && !AttenderRegisterFragment.getInstance().attenderRegisterFragmentVisible
|
| | | ) {
|
| | | return;
|
| | | }
|
| | | List<Double> percents = resultBean.getList(Double.class);
|
| | | if (percents != null && percents.size() > 0) {
|
| | | double percent = percents.get(0);
|
| | | if (percent >= 70) {
|
| | | Toast.makeText(BaseApplication.getInstance(),"认证通过", Toast.LENGTH_SHORT).show();
|
| | | if (CommonVariables.Register.VISITOR_REGISTER_SELECTED) {
|
| | | VisitorRegisterFragment.getInstance().fillFormWithIdCard(idCard);
|
| | | } else {
|
| | | AttenderRegisterFragment.getInstance().fillFormWithIdCard(idCard);
|
| | | }
|
| | | return;
|
| | | }
|
| | | System.out.println("percent="+percent);
|
| | | }
|
| | | Toast.makeText(BaseApplication.getInstance(),"认证失败", Toast.LENGTH_SHORT).show();
|
| | | }
|
| | | });
|
| | |
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | Toast.makeText(BaseApplication.getInstance(),"认证失败", Toast.LENGTH_SHORT).show();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public void addAttender(RequestParams params, String idCardHeadPhoto, OfflineAttenderRegisterItem offlineAttenderRegisterItem) {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | if (BaseApplication.getInstance().networkAvailable()) {
|
| | | try {
|
| | | File path = BaseApplication.getInstance().getFilesDir();
|
| | | File rawSurveillancePhotoFile = new File(path, "rawSurveillancePhoto_attender");
|
| | | if (!rawSurveillancePhotoFile.exists()) {
|
| | | rawSurveillancePhotoFile.createNewFile();
|
| | | }
|
| | | File f0 = new File(path, "f0");
|
| | | if (!f0.exists()) {
|
| | | f0.createNewFile();
|
| | | }
|
| | | File surveillancePhotoFile = new File(path, "surveillancePhoto_attender");
|
| | | if (!surveillancePhotoFile.exists()) {
|
| | | surveillancePhotoFile.createNewFile();
|
| | | }
|
| | | File uploadCustomPhotoFile = new File(path, "uploadCustomPhoto_attender");
|
| | | if (!uploadCustomPhotoFile.exists()) {
|
| | | uploadCustomPhotoFile.createNewFile();
|
| | | }
|
| | | File idCardPhotoFile = new File(path, "idCardPhoto_attender");
|
| | | if (!idCardPhotoFile.exists()) {
|
| | | idCardPhotoFile.createNewFile();
|
| | | }
|
| | |
|
| | | FileWriter fw0 = new FileWriter(f0);
|
| | | fw0.write("test1");
|
| | | fw0.close();
|
| | | params.setUri(AppApi.BASE_URL +AppApi.ATTENDER_REGISTER_ADD);
|
| | | params.addBodyParameter("f0", f0);
|
| | | params.addBodyParameter("rawSurveillancePhoto", rawSurveillancePhotoFile);
|
| | | params.addBodyParameter("surveillancePhoto", surveillancePhotoFile);
|
| | | params.addBodyParameter("uploadCustomPhoto", uploadCustomPhotoFile);
|
| | | params.addBodyParameter("idCardPhoto", idCardPhotoFile);
|
| | | params.addBodyParameter("deviceCompanyId", BaseApplication.getInstance().getAndroidDevice().getCompanyId());
|
| | | if (idCardHeadPhoto != null && !"".equals(idCardHeadPhoto)) {
|
| | | File f5 = new File(idCardHeadPhoto);
|
| | | if (!f5.exists()) {
|
| | | f5.createNewFile();
|
| | | }
|
| | | params.addBodyParameter("idCardHeadPhoto_attender", f5);
|
| | | }
|
| | | x.http().post(params, new BaseCommonCallBack() {
|
| | | @Override
|
| | | public void success() {
|
| | | SqliteSqlUtil.insert(getExtraList(SqliteSqlBean.class));
|
| | | Toast.makeText(BaseApplication.getInstance(),"添加成功", Toast.LENGTH_SHORT).show();
|
| | | AttenderRegisterFragment.getInstance().resetForm();
|
| | | }
|
| | | });
|
| | | }catch(Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | } else {
|
| | | RegisterDao.getInstance().addAttender(offlineAttenderRegisterItem, idCardHeadPhoto);
|
| | | Toast.makeText(BaseApplication.getInstance(),"添加成功", Toast.LENGTH_SHORT).show();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public void sendOfflineVisitorRegisterToServer() {
|
| | | final OfflineVisitorRegisterItem item = RegisterDao.getInstance().readOfflineVisitorRegister();
|
| | | RequestParams params = new RequestParams();
|
| | |
|
| | | params.addBodyParameter(Register.FieldNames.username, item.getUsername());
|
| | | params.addBodyParameter(Register.FieldNames.mobilePhone, item.getMobilePhone());
|
| | | params.addBodyParameter(Register.FieldNames.genderId, item.getGenderId());
|
| | | params.addBodyParameter(Register.FieldNames.identityTypeId, item.getIdentityTypeId());
|
| | | params.addBodyParameter(Register.FieldNames.countryId, item.getCountryId());
|
| | | params.addBodyParameter(Register.FieldNames.visitorTypeId, item.getVisitorTypeId());
|
| | | params.addBodyParameter(Register.FieldNames.identifyNum, item.getIdentifyNum());
|
| | | params.addBodyParameter(Register.FieldNames.companyId, item.getCompanyId());
|
| | | params.addBodyParameter(Register.FieldNames.birthday, item.getBirthday());
|
| | | params.addBodyParameter(Register.FieldNames.remark, item.getRemark());
|
| | | params.addBodyParameter("width", item.getRawSurveillancePhotoWidth());
|
| | | params.addBodyParameter("height", item.getRawSurveillancePhotoHeight());
|
| | |
|
| | | item.loadFiles();
|
| | |
|
| | | params.addBodyParameter("rawSurveillancePhoto", item.getRawSurveillancePhotoPath());
|
| | | params.addBodyParameter("surveillancePhoto", item.getSurveillancePhoto());
|
| | | params.addBodyParameter("uploadCustomPhoto", item.getUploadCustomPhoto());
|
| | | params.addBodyParameter("idCardPhoto", item.getIdCardPhoto());
|
| | | params.addBodyParameter("deviceCompanyId", BaseApplication.getInstance().getAndroidDevice().getCompanyId());
|
| | | try {
|
| | | File path = BaseApplication.getInstance().getFilesDir();
|
| | | File f0 = new File(path, "f0");
|
| | | if (!f0.exists()) {
|
| | | f0.createNewFile();
|
| | | }
|
| | | FileWriter fw0 = new FileWriter(f0);
|
| | | fw0.write("test1");
|
| | | fw0.close();
|
| | | params.setUri(AppApi.BASE_URL +AppApi.REGISTER_ADD);
|
| | | params.addBodyParameter("f0", f0);
|
| | | x.http().post(params, new BaseCommonCallBack() {
|
| | | @Override
|
| | | public void success() {
|
| | | SqliteSqlUtil.insert(getExtraList(SqliteSqlBean.class));
|
| | | Toast.makeText(BaseApplication.getInstance(),"添加成功", Toast.LENGTH_SHORT).show();
|
| | | VisitorRegisterFragment.getInstance().resetForm();
|
| | | RegisterDao.getInstance().removeOfflineVisitorRegister(item);
|
| | | }
|
| | | });
|
| | | }catch(Exception e) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public boolean hasOfflineVisitorRegisterData() {
|
| | | return RegisterDao.getInstance().hasOfflineVisitorRegisterData();
|
| | | }
|
| | |
|
| | | public void sendOfflineAttenderRegisterToServer() {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | try {
|
| | | RequestParams params = new RequestParams();
|
| | | File path = BaseApplication.getInstance().getFilesDir();
|
| | | File rawSurveillancePhotoFile = new File(path, "rawSurveillancePhoto_attender");
|
| | | if (!rawSurveillancePhotoFile.exists()) {
|
| | | rawSurveillancePhotoFile.createNewFile();
|
| | | }
|
| | | File f0 = new File(path, "f0");
|
| | | if (!f0.exists()) {
|
| | | f0.createNewFile();
|
| | | }
|
| | | File surveillancePhotoFile = new File(path, "surveillancePhoto_attender");
|
| | | if (!surveillancePhotoFile.exists()) {
|
| | | surveillancePhotoFile.createNewFile();
|
| | | }
|
| | | File uploadCustomPhotoFile = new File(path, "uploadCustomPhoto_attender");
|
| | | if (!uploadCustomPhotoFile.exists()) {
|
| | | uploadCustomPhotoFile.createNewFile();
|
| | | }
|
| | | File idCardPhotoFile = new File(path, "idCardPhoto_attender");
|
| | | if (!idCardPhotoFile.exists()) {
|
| | | idCardPhotoFile.createNewFile();
|
| | | }
|
| | |
|
| | | FileWriter fw0 = new FileWriter(f0);
|
| | | fw0.write("test1");
|
| | | fw0.close();
|
| | | params.setUri(AppApi.BASE_URL +AppApi.ATTENDER_REGISTER_ADD);
|
| | | params.addBodyParameter("f0", f0);
|
| | | params.addBodyParameter("rawSurveillancePhoto", rawSurveillancePhotoFile);
|
| | | params.addBodyParameter("surveillancePhoto", surveillancePhotoFile);
|
| | | params.addBodyParameter("uploadCustomPhoto", uploadCustomPhotoFile);
|
| | | params.addBodyParameter("idCardPhoto", idCardPhotoFile);
|
| | | params.addBodyParameter("deviceCompanyId", BaseApplication.getInstance().getAndroidDevice().getCompanyId());
|
| | | // if (idCardHeadPhoto != null && !"".equals(idCardHeadPhoto)) {
|
| | | // File f5 = new File(idCardHeadPhoto);
|
| | | // if (!f5.exists()) {
|
| | | // f5.createNewFile();
|
| | | // }
|
| | | // params.addBodyParameter("idCardHeadPhoto_attender", f5);
|
| | | // }
|
| | | x.http().post(params, new BaseCommonCallBack() {
|
| | | @Override
|
| | | public void success() {
|
| | | SqliteSqlUtil.insert(getExtraList(SqliteSqlBean.class));
|
| | | Toast.makeText(BaseApplication.getInstance(),"添加成功", Toast.LENGTH_SHORT).show();
|
| | | AttenderRegisterFragment.getInstance().resetForm();
|
| | | }
|
| | | });
|
| | | }catch(Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | public boolean hasOfflineAttenderRegisterData() {
|
| | | return RegisterDao.getInstance().hasOfflineAttenderRegisterData();
|
| | | }
|
| | | }
|