md
This commit is contained in:
parent
ad8eb5d7f7
commit
70a82c868e
@ -20,6 +20,7 @@ import com.xdadan.erp.oms.domain.vo.AddressParseResult;
|
|||||||
import com.xdadan.erp.oms.service.*;
|
import com.xdadan.erp.oms.service.*;
|
||||||
import com.xdadan.erp.oms.service.svc.IApiwebSvc;
|
import com.xdadan.erp.oms.service.svc.IApiwebSvc;
|
||||||
import com.xdadan.erp.oms.service.svc.IRpcCommonSvc;
|
import com.xdadan.erp.oms.service.svc.IRpcCommonSvc;
|
||||||
|
import com.xdadan.erp.oms.utils.TraceUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -65,5 +66,10 @@ public class Oms2cCommonController extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/queryTraceInfo")
|
||||||
|
AjaxResult queryTraceInfo(String mailno,String tail4){
|
||||||
|
return TraceUtils.queryTraceInfo(mailno,tail4);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,275 @@
|
|||||||
|
package com.xdadan.erp.oms.utils;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.xdadan.erp.oms.common.core.domain.AjaxResult;
|
||||||
|
import com.xdadan.erp.oms.common.utils.HTTPHelperV3;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
public class TraceUtils {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询轨迹信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static AjaxResult queryTraceInfoByZtd(String mailno, String tail4){
|
||||||
|
|
||||||
|
AjaxResult ar = new AjaxResult();
|
||||||
|
|
||||||
|
String allResult = "";
|
||||||
|
try {
|
||||||
|
|
||||||
|
// 保存数据
|
||||||
|
String postUrl = "http://gzh.tanex56.com/HMWXServer/msg/getScanByCode?code="+mailno;
|
||||||
|
|
||||||
|
allResult= HTTPHelperV3.get(postUrl);
|
||||||
|
if (allResult.contains("code")) {
|
||||||
|
JSONObject jObjRst = JSONObject.parseObject(allResult);
|
||||||
|
String code=jObjRst.getString("code");
|
||||||
|
String message=jObjRst.getString("message");
|
||||||
|
if("200".equals(code) ) {
|
||||||
|
|
||||||
|
JSONArray jArraySteps = new JSONArray();
|
||||||
|
JSONArray jsonArraySteps=jObjRst.getJSONObject("data").getJSONArray("scanData");;
|
||||||
|
// System.out.println(jsonArraySteps.toString());
|
||||||
|
if(jsonArraySteps.size()>0) {
|
||||||
|
for (Object object : jsonArraySteps) {
|
||||||
|
JSONObject tmpObj = (JSONObject) object;
|
||||||
|
String opCode = tmpObj.getString("scanType");
|
||||||
|
JSONObject jsonObjStep = new JSONObject();
|
||||||
|
jsonObjStep.put("content", cvtOpCodeToContent(tmpObj));
|
||||||
|
jsonObjStep.put("time", tmpObj.getString("scanDate"));
|
||||||
|
jsonObjStep.put("status", cvtOpCodeToStatusWord(opCode));
|
||||||
|
jArraySteps.add(jsonObjStep);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return AjaxResult.success("查询成功",jArraySteps);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
JSONArray jArSteps = new JSONArray();
|
||||||
|
return AjaxResult.error("查询成功,无路由信息",jArSteps);
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
AjaxResult.error("查询失败");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
AjaxResult.error("查询失败E004");
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch (Exception ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
AjaxResult.error("查询失败E003");
|
||||||
|
}
|
||||||
|
return ar;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static String cvtOpCodeToContent(JSONObject jsonObjStep) {
|
||||||
|
String scanMan = jsonObjStep.getString("scanMan");
|
||||||
|
String opCode = jsonObjStep.getString("scanType");
|
||||||
|
String scanSite = jsonObjStep.getString("scanSite");
|
||||||
|
String preOrNextStation = jsonObjStep.getString("preOrNextStation");
|
||||||
|
String content = "" ;
|
||||||
|
if(!StringUtils.isEmpty(preOrNextStation) && !"null".equals(preOrNextStation) ){
|
||||||
|
preOrNextStation = " 【"+preOrNextStation+"】 ";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!StringUtils.isEmpty(scanSite) && !"null".equals(scanSite) ){
|
||||||
|
scanSite = " 【"+scanSite+"】 ";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!StringUtils.isEmpty(scanMan) && !"null".equals(scanMan)) {
|
||||||
|
// scanMan = " 操作员:" + scanMan;
|
||||||
|
}else{
|
||||||
|
scanMan="";
|
||||||
|
}
|
||||||
|
|
||||||
|
content = scanSite ;
|
||||||
|
if(opCode.contains("收件")) {
|
||||||
|
content=content+" 快件已揽收 ,业务员:"+scanMan;
|
||||||
|
}
|
||||||
|
else if(opCode.contains("到达") || opCode.contains("到件")) {
|
||||||
|
content=content+"快件已到达"+scanSite;
|
||||||
|
}
|
||||||
|
else if(opCode.contains("发件") ) {
|
||||||
|
content=content+"快件已离开"+scanSite +" 发往 "+preOrNextStation;
|
||||||
|
}
|
||||||
|
else if(opCode.contains("派件扫描") ) {
|
||||||
|
content=content+"派件扫描,派件员:"+scanMan;
|
||||||
|
}
|
||||||
|
else if(opCode.contains("派件") ) {
|
||||||
|
content=content+"派件中,派件员:"+scanMan;
|
||||||
|
}
|
||||||
|
else if(opCode.contains("签收") ) {
|
||||||
|
content=content+"已签收,签收人:"+scanMan;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
content=content+""+opCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String cvtEmisOpCodeToStatusWord(String opCode) {
|
||||||
|
String statusWord="other";
|
||||||
|
|
||||||
|
/*
|
||||||
|
got : 揽件
|
||||||
|
arrival: 到站
|
||||||
|
departure:出站
|
||||||
|
sent_scan : 派件
|
||||||
|
signed : 签收
|
||||||
|
other :其他
|
||||||
|
|
||||||
|
*/
|
||||||
|
if(opCode.equals("10")) {
|
||||||
|
statusWord="got";
|
||||||
|
}
|
||||||
|
else if(opCode.equals("30")) {
|
||||||
|
statusWord="arrival";
|
||||||
|
}
|
||||||
|
else if(opCode.equals("20") ) {
|
||||||
|
statusWord="departure";
|
||||||
|
}
|
||||||
|
else if(opCode.equals("40") ) {
|
||||||
|
statusWord="sent_scan";
|
||||||
|
}
|
||||||
|
else if(opCode.equals("50") ) {
|
||||||
|
statusWord="signed";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
statusWord="other";
|
||||||
|
}
|
||||||
|
|
||||||
|
return statusWord;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String cvtOpCodeToStatusWord(String opCode) {
|
||||||
|
String statusWord="other";
|
||||||
|
|
||||||
|
/*
|
||||||
|
got : 揽件
|
||||||
|
arrival: 到站
|
||||||
|
departure:出站
|
||||||
|
sent_scan : 派件
|
||||||
|
signed : 签收
|
||||||
|
other :其他
|
||||||
|
|
||||||
|
*/
|
||||||
|
if(opCode.contains("收件")) {
|
||||||
|
statusWord="got";
|
||||||
|
}
|
||||||
|
else if(opCode.contains("到达") || opCode.contains("到件")) {
|
||||||
|
statusWord="arrival";
|
||||||
|
}
|
||||||
|
else if(opCode.contains("发件") ) {
|
||||||
|
statusWord="departure";
|
||||||
|
}
|
||||||
|
else if(opCode.contains("派件扫描") ) {
|
||||||
|
statusWord="sent_scan";
|
||||||
|
}
|
||||||
|
else if(opCode.contains("派件") ) {
|
||||||
|
statusWord="sent";
|
||||||
|
}
|
||||||
|
else if(opCode.contains("签收") || opCode.contains("送达") ) {
|
||||||
|
statusWord="signed";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
statusWord="other";
|
||||||
|
}
|
||||||
|
|
||||||
|
return statusWord;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询轨迹信息 tanexEmis
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static AjaxResult queryTraceInfoByEmis(String mailno,String tail4){
|
||||||
|
|
||||||
|
String allResult = "";
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
String qParams="appId=xdadan20240614&mainNo="+mailno+"&lang=&sign=123&tail4="+tail4;
|
||||||
|
|
||||||
|
String postUrl = "http://api.emis.tanex56.com/api/bizsvr/emis/common/queryTraceInfo?"+qParams;
|
||||||
|
|
||||||
|
allResult=HTTPHelperV3.get(postUrl);
|
||||||
|
if (allResult.contains("code")) {
|
||||||
|
JSONObject jObjRst = JSONObject.parseObject(allResult);
|
||||||
|
String code=jObjRst.getString("code");
|
||||||
|
String msg=jObjRst.getString("msg");
|
||||||
|
if("200".equals(code) ) {
|
||||||
|
|
||||||
|
JSONArray jArraySteps = new JSONArray();
|
||||||
|
|
||||||
|
JSONArray jsonArrayData=jObjRst.getJSONArray("data");
|
||||||
|
JSONObject jObjItem0=jsonArrayData.getJSONObject(0);
|
||||||
|
|
||||||
|
JSONArray jsonArraySteps=jObjItem0.getJSONArray("steps");;
|
||||||
|
if(jsonArraySteps.size()>0) {
|
||||||
|
for (Object object : jsonArraySteps) {
|
||||||
|
JSONObject tmpObj = (JSONObject) object;
|
||||||
|
String status = tmpObj.getString("status");
|
||||||
|
JSONObject jsonObjStep = new JSONObject();
|
||||||
|
jsonObjStep.put("content", tmpObj.getString("content"));
|
||||||
|
jsonObjStep.put("time", tmpObj.getString("time"));
|
||||||
|
jsonObjStep.put("status", cvtEmisOpCodeToStatusWord(status));
|
||||||
|
jArraySteps.add(jsonObjStep);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return AjaxResult.success("查询成功",jArraySteps);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
JSONArray jArSteps = new JSONArray();
|
||||||
|
return AjaxResult.success("查询成功,无路由信息",jArSteps);
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
return AjaxResult.error("查询失败");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return AjaxResult.error("查询失败E004");
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch (Exception ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
return AjaxResult.error("查询失败E003");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AjaxResult queryTraceInfo(String mailno,String tail4) {
|
||||||
|
|
||||||
|
if(!StringUtils.isEmpty(mailno)){
|
||||||
|
if(mailno.length()>=14){
|
||||||
|
return queryTraceInfoByEmis(mailno,tail4);
|
||||||
|
}else{
|
||||||
|
return queryTraceInfoByZtd(mailno,tail4);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
|
||||||
|
return AjaxResult.error("查询参数错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// AjaxResult res=queryTraceInfoByZtd("T7080374113","123");
|
||||||
|
// System.out.println(res);
|
||||||
|
AjaxResult res=queryTraceInfo("T7080300043695","123");
|
||||||
|
// AjaxResult res=queryTraceInfo("T7080374113","123");
|
||||||
|
System.out.println(JSON.toJSONString(res));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user