|
|
|
|
@ -2,6 +2,7 @@ package com.example.writeepc;
|
|
|
|
|
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.content.IntentFilter;
|
|
|
|
|
import android.os.Build;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
|
|
|
|
|
@ -20,6 +21,8 @@ import com.lzy.okgo.model.Response;
|
|
|
|
|
import com.lzy.okgo.request.base.Request;
|
|
|
|
|
import com.uhf.api.cls.Reader;
|
|
|
|
|
|
|
|
|
|
import java.time.Year;
|
|
|
|
|
|
|
|
|
|
public class ShuangqianActivity extends BaseActivity implements MyScannerCall {
|
|
|
|
|
|
|
|
|
|
private ActivityShuangqianBinding binding;
|
|
|
|
|
@ -29,19 +32,15 @@ public class ShuangqianActivity extends BaseActivity implements MyScannerCall {
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
|
|
binding = DataBindingUtil.setContentView(this, R.layout.activity_shuangqian);
|
|
|
|
|
|
|
|
|
|
String ACTION_SCAN_INIT = "com.rfid.SCAN_INIT";
|
|
|
|
|
Intent intent = new Intent();
|
|
|
|
|
intent.setAction(ACTION_SCAN_INIT);
|
|
|
|
|
sendBroadcast(intent);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initUHFRManager1();
|
|
|
|
|
initDialog();
|
|
|
|
|
int powerBinding = Integer.parseInt(SharedPreferencesUtils.getstring("powerBinding", "22"));
|
|
|
|
|
Reader.READER_ERR readerErr = uhfrManager.setPower(powerBinding, powerBinding);
|
|
|
|
|
// Reader.READER_ERR readerErr = uhfrManager.setPower(powerBinding, powerBinding);
|
|
|
|
|
myReceiver = new MyScannerReceiver(this);
|
|
|
|
|
IntentFilter intentFilter = new IntentFilter();
|
|
|
|
|
intentFilter.addAction("com.rfid.SCAN");
|
|
|
|
|
@ -50,6 +49,10 @@ public class ShuangqianActivity extends BaseActivity implements MyScannerCall {
|
|
|
|
|
binding.setTitle(type ? "MES轮胎绑定" : "解绑");
|
|
|
|
|
binding.setType(type);
|
|
|
|
|
// uriLastStr = type ? "barcodeAndRFIDBinding" : "unBinding";
|
|
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
|
|
binding.socketYear.setText(String.valueOf(Year.now().getValue()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 读取
|
|
|
|
|
@ -73,50 +76,53 @@ public class ShuangqianActivity extends BaseActivity implements MyScannerCall {
|
|
|
|
|
public void submit(View view) {
|
|
|
|
|
String epc = binding.socketEpc.getText().toString();
|
|
|
|
|
String code = binding.socketBarcode.getText().toString();
|
|
|
|
|
if (epc.isEmpty() || code.isEmpty()) return;
|
|
|
|
|
haohuaSubmit(epc, code);
|
|
|
|
|
// callWebService(buildSoapRequest(epc, code));//双钱
|
|
|
|
|
String year = binding.socketYear.getText().toString();
|
|
|
|
|
if (epc.isEmpty() || code.isEmpty() || year.isEmpty()) return;
|
|
|
|
|
// haohuaSubmit(epc, code);
|
|
|
|
|
callWebService(buildSoapRequest(epc, code, year));// 双钱
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 解绑
|
|
|
|
|
public void unBindingSubmit(View view) {
|
|
|
|
|
String epc = binding.socketEpc.getText().toString();
|
|
|
|
|
String code = binding.socketBarcode.getText().toString();
|
|
|
|
|
|
|
|
|
|
haohuaSubmit(epc, code);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void haohuaSubmit(String epc, String code) {
|
|
|
|
|
OkGo.<MyResult>post("http://192.168.26.26:5050/UMInterface/RFID/" + uriLastStr)
|
|
|
|
|
.params("rfid", epc).params("barCode", code).execute(new MyRecultCall(dialog, this) {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Response<MyResult> response) {
|
|
|
|
|
super.onSuccess(response);
|
|
|
|
|
MyResult body = response.body();
|
|
|
|
|
try {
|
|
|
|
|
if (body.getCode() == 200) {
|
|
|
|
|
tipsDialog.setTip(true, body.getInfo());
|
|
|
|
|
tipsDialog.show();
|
|
|
|
|
binding.socketBarcode.setText(null);
|
|
|
|
|
binding.socketEpc.setText(null);
|
|
|
|
|
} else {
|
|
|
|
|
tipsDialog.setTip(false, body.getInfo());
|
|
|
|
|
tipsDialog.show();
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
tipsDialog.setTip(false, "接口返回信息异常");
|
|
|
|
|
tipsDialog.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Response<MyResult> response) {
|
|
|
|
|
super.onSuccess(response);
|
|
|
|
|
MyResult body = response.body();
|
|
|
|
|
try {
|
|
|
|
|
if (body.getCode() == 200) {
|
|
|
|
|
tipsDialog.setTip(true, body.getInfo());
|
|
|
|
|
tipsDialog.show();
|
|
|
|
|
binding.socketBarcode.setText(null);
|
|
|
|
|
binding.socketEpc.setText(null);
|
|
|
|
|
} else {
|
|
|
|
|
tipsDialog.setTip(false, body.getInfo());
|
|
|
|
|
tipsDialog.show();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
tipsDialog.setTip(false, "接口返回信息异常");
|
|
|
|
|
tipsDialog.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void callWebService(String soapRequest) {
|
|
|
|
|
// 发送 POST 请求
|
|
|
|
|
OkGo.<String>post("http://10.135.55.206:99/WebService.asmx").headers("Content-Type", "text/xml; charset=utf-8").upString(soapRequest, mediaType).execute(new StringCallback() {
|
|
|
|
|
OkGo.<String>post(SharedPreferencesUtils.getstring("ip", "http://10.72.36.3:8090/FSRFID.asmx"))
|
|
|
|
|
.headers("Content-Type", "text/xml; charset=utf-8")
|
|
|
|
|
.upString(soapRequest, mediaType)
|
|
|
|
|
.execute(new StringCallback() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onStart(Request<String, ? extends Request> request) {
|
|
|
|
|
super.onStart(request);
|
|
|
|
|
@ -128,40 +134,20 @@ public class ShuangqianActivity extends BaseActivity implements MyScannerCall {
|
|
|
|
|
// 处理响应结果
|
|
|
|
|
String result = response.body();
|
|
|
|
|
try {
|
|
|
|
|
String str = "<faultstring>";
|
|
|
|
|
int faultstringIndex = result.indexOf(str);
|
|
|
|
|
if (faultstringIndex > -1) {
|
|
|
|
|
String faultstring =
|
|
|
|
|
result.substring(faultstringIndex + str.length(), result.indexOf("</faultstring>"));
|
|
|
|
|
tipsDialog.setTip(false, faultstring);
|
|
|
|
|
tipsDialog.show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int codeIndex = result.indexOf("<Code>");
|
|
|
|
|
if (codeIndex > -1) {
|
|
|
|
|
String resultCode =
|
|
|
|
|
result.substring(codeIndex + 6, result.indexOf("</Code>"));
|
|
|
|
|
String resultMsg =
|
|
|
|
|
result.substring(result.indexOf("<Msg>") + 5, result.indexOf("</Msg>"));
|
|
|
|
|
if (resultCode.equals("200")) {
|
|
|
|
|
tipsDialog.setTip(true, resultMsg);
|
|
|
|
|
tipsDialog.show();
|
|
|
|
|
binding.socketBarcode.setText(null);
|
|
|
|
|
binding.socketEpc.setText(null);
|
|
|
|
|
} else {
|
|
|
|
|
tipsDialog.setTip(false, resultMsg);
|
|
|
|
|
tipsDialog.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// clearView(null);
|
|
|
|
|
}
|
|
|
|
|
String str = "<SubmitRFIDBindingInfoResult>";
|
|
|
|
|
String subStringResult =
|
|
|
|
|
result.substring(result.indexOf(str) + str.length(), result.indexOf("</SubmitRFIDBindingInfoResult>")).trim();
|
|
|
|
|
|
|
|
|
|
boolean equals = subStringResult.equals("OK");
|
|
|
|
|
tipsDialog.setTip(equals, subStringResult);
|
|
|
|
|
tipsDialog.show();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
tipsDialog.setTip(false, "接口返回信息异常");
|
|
|
|
|
tipsDialog.show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFinish() {
|
|
|
|
|
super.onFinish();
|
|
|
|
|
@ -171,20 +157,26 @@ public class ShuangqianActivity extends BaseActivity implements MyScannerCall {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 创建提交信息
|
|
|
|
|
private String buildSoapRequest(String epcid, String barcode) {
|
|
|
|
|
String soapRequest = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
|
|
|
|
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
|
|
|
|
|
"<soap:Body>" +
|
|
|
|
|
"<RFID_BarcodBind xmlns=\"http://tempuri.org/\">" +
|
|
|
|
|
"<epcid>" + epcid + "</epcid>" +
|
|
|
|
|
"<barcode>" + barcode + "</barcode>" +
|
|
|
|
|
"</RFID_BarcodBind>" +
|
|
|
|
|
"</soap:Body>" +
|
|
|
|
|
"</soap:Envelope>";
|
|
|
|
|
return soapRequest;
|
|
|
|
|
private String buildSoapRequest(String epcid, String barcode, String year) {
|
|
|
|
|
return String.format("""
|
|
|
|
|
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
|
|
|
|
|
<soap:Header>
|
|
|
|
|
<tem:MySoapHeader>
|
|
|
|
|
<tem:UserName>RFID-MES</tem:UserName>
|
|
|
|
|
<tem:PassWord>Yh#14ulh!6hk9ue4ml</tem:PassWord>
|
|
|
|
|
</tem:MySoapHeader>
|
|
|
|
|
</soap:Header>
|
|
|
|
|
<soap:Body>
|
|
|
|
|
<tem:SubmitRFIDBindingInfo>
|
|
|
|
|
<tem:RFIDCode>%s</tem:RFIDCode>
|
|
|
|
|
<tem:GreenTyreNo>%s</tem:GreenTyreNo>
|
|
|
|
|
<tem:YearNo>%s</tem:YearNo>
|
|
|
|
|
</tem:SubmitRFIDBindingInfo>
|
|
|
|
|
</soap:Body>
|
|
|
|
|
</soap:Envelope>
|
|
|
|
|
""", epcid, barcode, year);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void getScannerData(String data) {
|
|
|
|
|
binding.socketBarcode.setText(data);
|
|
|
|
|
|