|
|
@@ -427,10 +427,10 @@ public class MesMsgUtils {
|
|
|
String mes_rs = " ";
|
|
|
if(!ret.equalsIgnoreCase("")) {
|
|
|
//保存成功
|
|
|
- mes_rs = ret;//"RSOK";
|
|
|
+ mes_rs = isQualityResultMsg(reMsgType) ? formatReturnResult(ret) : ret;//"RSOK";
|
|
|
}else {
|
|
|
//未保存成功
|
|
|
- mes_rs = mes_lx+"NS";
|
|
|
+ mes_rs = isQualityResultMsg(reMsgType) ? formatReturnResult(mes_lx+"NS") : mes_lx+"NS";
|
|
|
}
|
|
|
String da = "DA" + DateLocalUtils.getCurrentDate();
|
|
|
String zt = "ZT" + DateLocalUtils.getCurrentTimeHMS();
|
|
|
@@ -461,6 +461,36 @@ public class MesMsgUtils {
|
|
|
return start + msgType + mes_gw + mes_gy + mes_id + mes_rs + da + zt;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ private static boolean isQualityResultMsg(String msgType) {
|
|
|
+ return "AQDW".equalsIgnoreCase(msgType) || "MQDW".equalsIgnoreCase(msgType);
|
|
|
+ }
|
|
|
+ private static String formatReturnResult(String ret) {
|
|
|
+ if (ret == null) {
|
|
|
+ ret = "";
|
|
|
+ }
|
|
|
+ ret = ret.trim();
|
|
|
+ if (ret.length() < 2) {
|
|
|
+ return rightPad("RS", 3) + rightPad(ret, 2);
|
|
|
+ }
|
|
|
+ String result = ret.substring(ret.length() - 2);
|
|
|
+ String lx = ret.substring(0, ret.length() - 2).trim();
|
|
|
+ if (lx.length() == 0) {
|
|
|
+ lx = "RS";
|
|
|
+ }
|
|
|
+ return rightPad(lx, 3) + rightPad(result, 2);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static String rightPad(String str, int size) {
|
|
|
+ if (str == null) {
|
|
|
+ str = "";
|
|
|
+ }
|
|
|
+ if (str.length() > size) {
|
|
|
+ return str.substring(0, size);
|
|
|
+ }
|
|
|
+ return String.format("%-" + size + "s", str);
|
|
|
+ }
|
|
|
private static String productRecordPost(String msg,String channel_ip,String msg_type){
|
|
|
// msg = msg.replaceAll("_", " ");
|
|
|
int lastIndex = msg.lastIndexOf("_");
|