Commit 5aabe1c0a264bd90def6ca6ea6ad74e1a11b30f9

Authored by 黄灿宏
1 parent 07670a44

畅游通核销app: 1.增加扫码配置

build.gradle
  1 +import java.text.SimpleDateFormat
  2 +
1 3 //apply plugin: 'android'
2 4 apply plugin: 'com.android.application'
3 5 buildscript {
... ... @@ -81,6 +83,15 @@ android {
81 83 }
82 84 }
83 85  
  86 + //在apk文件后边生成版本号信息
  87 + android.applicationVariants.all {
  88 + variant ->
  89 + variant.outputs.all {
  90 + //在这里修改apk文件名 Selfserviceticketingandroid_V1.0.5_202006220953
  91 + outputFileName = "CYTAndroid_V${variant.versionName}_${releaseTime()}.apk"
  92 + }
  93 + }
  94 +
84 95 sourceSets {
85 96 main {
86 97 manifest.srcFile 'AndroidManifest.xml'
... ... @@ -133,6 +144,9 @@ android {
133 144 // }
134 145  
135 146 }
  147 +def releaseTime() {
  148 + return new SimpleDateFormat("yyyyMMddHHmm").format(new Date())
  149 +}
136 150  
137 151 repositories {
138 152 maven {
... ...
src/com/ectrip/cyt/ui/PhomeScanerOrderActivity.java
... ... @@ -20,8 +20,10 @@ import android.view.View.OnClickListener;
20 20 import android.view.Window;
21 21 import android.view.WindowManager;
22 22 import android.widget.TextView;
  23 +import android.widget.Toast;
23 24  
24 25 import com.ectrip.cyt.bean.ConfigBean;
  26 +import com.ectrip.cyt.config.DevicTool;
25 27 import com.ectrip.cyt.constant.constant;
26 28 import com.ectrip.cyt.db.DbManager;
27 29 import com.ectrip.cyt.shield_home.LockLayer.MToast;
... ... @@ -130,6 +132,10 @@ public class PhomeScanerOrderActivity extends BaseActivity implements Callback {
130 132 playBeepSoundAndVibrate();
131 133 String resultString = result.getText().trim();
132 134 LogUtil.i(TAG, "扫码数据 = " + resultString);
  135 + if (resultString.startsWith("PZ")) {
  136 + configIdent(resultString);
  137 + return;
  138 + }
133 139 if (resultString.equals("")) {
134 140 MToast(PhomeScanerOrderActivity.this,
135 141 getString(R.string.scan_fail), MToast.LENGTH_SHORT);
... ... @@ -177,7 +183,7 @@ public class PhomeScanerOrderActivity extends BaseActivity implements Callback {
177 183 QRCodeOrderListActivity.class);
178 184 intent.putExtra("mode", 1);
179 185 intent.putExtra("input_orid", resultString);
180   - LogUtil.i(TAG,getString(R.string.scan_result) + resultString);
  186 + LogUtil.i(TAG, getString(R.string.scan_result) + resultString);
181 187 intent.putExtra("titleName", getString(R.string.show_result));
182 188 intent.putExtra("typeScan", typeScan);
183 189 startActivity(intent);
... ... @@ -192,6 +198,48 @@ public class PhomeScanerOrderActivity extends BaseActivity implements Callback {
192 198  
193 199 }
194 200  
  201 + private void configIdent(String resultString) {
  202 + String[] split = resultString.split(";");
  203 + String serviceIp = split[0].split("=")[1];
  204 + String encode = split[1].split("=")[1];
  205 + String identity = split[2].split("=")[1];
  206 + if (!identity.equals("")) {
  207 + try {
  208 + identity = AESEncryptor.decrypt(constant.decrypt, identity);
  209 + LogUtil.d(TAG, getString(R.string.enterprise_communication_identifier)
  210 + + identity);
  211 + identity = AESEncryptor.encrypt(constant.decrypt, identity);
  212 + } catch (Exception ex) {
  213 + try {
  214 + identity = AESEncryptor.encrypt(constant.decrypt,
  215 + identity);
  216 + LogUtil.d(TAG, getString(R.string.not_successfully_decrypt)
  217 + + identity);
  218 + } catch (Exception e) {
  219 + e.printStackTrace();
  220 + return;
  221 + }
  222 + }
  223 + ArrayList<ConfigBean> beans = DbManager.GetConfigs();
  224 + ConfigBean bean = new ConfigBean();
  225 + String mac = DevicTool.getInstance().getDevId().trim();
  226 + bean.setEc_id(0 + "");
  227 + bean.setEc_ip(serviceIp.trim());
  228 + bean.setEc_identity(encode.trim());
  229 + bean.setEc_mac(mac.toUpperCase());
  230 + bean.setEc_passwd("123456");
  231 + bean.setEc_signkey(identity);
  232 + if (1 == beans.get(0).getEc_isPrint()) {
  233 + bean.setEc_isPrint(beans.get(0).getEc_isPrint());
  234 + }else {
  235 + bean.setEc_isPrint(0);
  236 + }
  237 + DbManager.ClearConfig();
  238 + DbManager.InsertConfig(bean);
  239 + Toast.makeText(this,"配置成功",Toast.LENGTH_SHORT);
  240 + }
  241 + }
  242 +
195 243 private void initCamera(SurfaceHolder surfaceHolder) {
196 244 try {
197 245 CameraManager.get().openDriver(surfaceHolder, PhomeScanerOrderActivity.this);
... ...