|
|
|
|
@ -37,6 +37,8 @@ import java.io.IOException;
|
|
|
|
|
import java.io.StringReader;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
public class ShuangqianActivity2 extends BaseActivity {
|
|
|
|
|
private ActivityShuangqian2Binding binding;
|
|
|
|
|
@ -46,6 +48,7 @@ public class ShuangqianActivity2 extends BaseActivity {
|
|
|
|
|
private Handler handler = new Handler();
|
|
|
|
|
private Runnable runnable;
|
|
|
|
|
private MyKeyReceiver keyReceiver;
|
|
|
|
|
private List<MESInfo> mesInfos;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
@ -59,7 +62,10 @@ public class ShuangqianActivity2 extends BaseActivity {
|
|
|
|
|
Log.e("TAG", "追溯设置功率" + powerTrace1 + ":" + readerErr.name());
|
|
|
|
|
initDialog();
|
|
|
|
|
adapter = new MyMesInfoAdapter(this);
|
|
|
|
|
mesInfos = new ArrayList<>();
|
|
|
|
|
adapter.setList(mesInfos);
|
|
|
|
|
binding.setAdapter(adapter);
|
|
|
|
|
|
|
|
|
|
traceSanButton = binding.traceSanButton;
|
|
|
|
|
runnable = new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
@ -95,7 +101,7 @@ public class ShuangqianActivity2 extends BaseActivity {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void afterTextChanged(Editable s) {
|
|
|
|
|
if (s.length()==24){
|
|
|
|
|
if (s.length() == 24) {
|
|
|
|
|
haohuaMesSelect(s.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -131,7 +137,7 @@ public class ShuangqianActivity2 extends BaseActivity {
|
|
|
|
|
|
|
|
|
|
if (readState) {
|
|
|
|
|
dataReadRFID(null);
|
|
|
|
|
// callWebService(buildSelectRequest(result));
|
|
|
|
|
callWebService(buildSelectRequest(result));
|
|
|
|
|
// haohuaMesSelect(result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -185,7 +191,7 @@ public class ShuangqianActivity2 extends BaseActivity {
|
|
|
|
|
|
|
|
|
|
private void callWebService(String soapRequest) {
|
|
|
|
|
// 发送 POST 请求
|
|
|
|
|
OkGo.<String>post("http://10.135.55.206:99/WebService.asmx")
|
|
|
|
|
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() {
|
|
|
|
|
@ -198,39 +204,42 @@ public class ShuangqianActivity2 extends BaseActivity {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Response<String> response) {
|
|
|
|
|
// 处理响应结果
|
|
|
|
|
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);
|
|
|
|
|
mesInfos.clear();
|
|
|
|
|
String result = response.body();
|
|
|
|
|
String regex = "<Table .*\">";
|
|
|
|
|
Pattern pattern = Pattern.compile(regex);
|
|
|
|
|
Matcher matcher = pattern.matcher(result);
|
|
|
|
|
if (!matcher.find()) {
|
|
|
|
|
tipsDialog.setTip(false, "未找到匹配的内容");
|
|
|
|
|
tipsDialog.show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int codeIndex = result.indexOf("<Code>");
|
|
|
|
|
if (codeIndex > -1) {
|
|
|
|
|
String resultCode =
|
|
|
|
|
result.substring(codeIndex + 6, result.indexOf("</Code>"));
|
|
|
|
|
if (resultCode.equals("200")) {
|
|
|
|
|
String resultMsg =
|
|
|
|
|
result.substring(result.indexOf("<Entity>") + 8, result.indexOf("</Entity>"));
|
|
|
|
|
|
|
|
|
|
jiexi(resultMsg);
|
|
|
|
|
String matched = matcher.group();// 匹配内容
|
|
|
|
|
int beginIndex = matcher.start() + matched.length();
|
|
|
|
|
int endIndex = result.indexOf("</Table>");
|
|
|
|
|
Log.e("TAG", "test1:" + beginIndex);
|
|
|
|
|
Log.e("TAG", "test2:" + endIndex);
|
|
|
|
|
if (beginIndex >= endIndex) {
|
|
|
|
|
tipsDialog.setTip(false, "未找到匹配的内容");
|
|
|
|
|
tipsDialog.show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
String resultMsg =
|
|
|
|
|
result.substring(result.indexOf("<Msg>") + 5, result.indexOf("</Msg>"));
|
|
|
|
|
tipsDialog.setTip(false, resultMsg);
|
|
|
|
|
tipsDialog.show();
|
|
|
|
|
String[] str = new String[]{"品牌", "规格", "花纹类型", "胎号", "DOT"};
|
|
|
|
|
for (String s : str) {
|
|
|
|
|
String tag = "<" + s + ">";
|
|
|
|
|
MESInfo mesInfo = new MESInfo();
|
|
|
|
|
mesInfo.setTitle(s);
|
|
|
|
|
mesInfo.setInfo(result.substring(result.indexOf(tag) + tag.length(), result.indexOf("</" + s + ">")));
|
|
|
|
|
mesInfos.add(mesInfo);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
tipsDialog.setTip(false, "接口返回信息异常");
|
|
|
|
|
tipsDialog.show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFinish() {
|
|
|
|
|
@ -242,16 +251,22 @@ public class ShuangqianActivity2 extends BaseActivity {
|
|
|
|
|
|
|
|
|
|
// 创建验证信息
|
|
|
|
|
private String buildSelectRequest(String epcid) {
|
|
|
|
|
StringBuilder soapRequest = new StringBuilder();
|
|
|
|
|
soapRequest.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
|
|
|
|
soapRequest.append("<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/\">");
|
|
|
|
|
soapRequest.append("<soap:Body>");
|
|
|
|
|
soapRequest.append("<TyreTracingBack xmlns=\"http://tempuri.org/\">");
|
|
|
|
|
soapRequest.append("<epcid>").append(epcid).append("</epcid>");
|
|
|
|
|
soapRequest.append("</TyreTracingBack>");
|
|
|
|
|
soapRequest.append("</soap:Body>");
|
|
|
|
|
soapRequest.append("</soap:Envelope>");
|
|
|
|
|
return soapRequest.toString();
|
|
|
|
|
String soapRequest = 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:GetRFIDBindingInfo>
|
|
|
|
|
<tem:RFIDCode>%s</tem:RFIDCode>
|
|
|
|
|
</tem:GetRFIDBindingInfo>
|
|
|
|
|
</soap:Body>
|
|
|
|
|
</soap:Envelope>
|
|
|
|
|
""", epcid);
|
|
|
|
|
return soapRequest;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void jiexi(String msg) {
|
|
|
|
|
@ -330,6 +345,12 @@ public class ShuangqianActivity2 extends BaseActivity {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onDestroy() {
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
unregisterReceiver(keyReceiver);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class MyKeyReceiver extends BroadcastReceiver {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@ -340,10 +361,4 @@ public class ShuangqianActivity2 extends BaseActivity {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onDestroy() {
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
unregisterReceiver(keyReceiver);
|
|
|
|
|
}
|
|
|
|
|
}
|