Gps
This commit is contained in:
parent
4b83ac8ff0
commit
1d7dd7ac46
194
src_tenwa/com/tenwa/gps/GpsCommon.java
Normal file
194
src_tenwa/com/tenwa/gps/GpsCommon.java
Normal file
@ -0,0 +1,194 @@
|
||||
package com.tenwa.gps;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.amarsoft.are.jbo.JBOException;
|
||||
import com.amarsoft.awe.util.ASResultSet;
|
||||
import com.amarsoft.awe.util.SqlObject;
|
||||
import com.amarsoft.awe.util.Transaction;
|
||||
import com.tenwa.httpclient.resources.GPSConfigure;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
public class GpsCommon {
|
||||
|
||||
private static String TYuserAccount = GPSConfigure.get("TYuserAccount");
|
||||
private static String TYtoken = GPSConfigure.get("TYtoken");
|
||||
private static String TYsign = GPSConfigure.get("TYsign");
|
||||
/**
|
||||
*
|
||||
* 天易--编辑新增工单请求参数
|
||||
* @param flowUnid
|
||||
* @param applyNo
|
||||
* @param tx
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String tyEditCreateParameter(String applyNo,Transaction Sqlca) throws Exception{
|
||||
ASResultSet res = Sqlca.getASResultSet(new SqlObject("select CONTACT_NAME,CONTACT_PHONE,PICCONTACT_NAME,PICCONTACT_PHONE,INSTALL_TIME,ADDRESS_CODE,ADDRESS_DETAIL,CAR_VIN,WIRED_NUM,WIRED_PERIOD,WIRELESS_NUM,WIRELESS_PERIOD,CAR_ACCOUNT from LM_GPS_ORDER_TEMP where APPLY_NO='"+applyNo+"'"));
|
||||
JSONObject params = new JSONObject();
|
||||
while(res.next()){
|
||||
params.put("userAccount",TYuserAccount);
|
||||
params.put("token",TYtoken);
|
||||
params.put("sign",TYsign);
|
||||
params.put("applyNo",applyNo);
|
||||
params.put("contactName",res.getString("CONTACT_NAME"));
|
||||
params.put("contactPhone",res.getString("CONTACT_PHONE"));
|
||||
params.put("piccontactName",res.getString("PICCONTACT_NAME"));
|
||||
params.put("piccontactPhone",res.getString("PICCONTACT_PHONE"));
|
||||
params.put("installtime",res.getString("INSTALL_TIME"));
|
||||
params.put("addressCode",res.getString("ADDRESS_CODE"));
|
||||
params.put("addressDetail",res.getString("ADDRESS_DETAIL"));
|
||||
params.put("carVin",res.getString("CAR_VIN"));
|
||||
params.put("wiredNum",res.getString("WIRED_NUM"));
|
||||
params.put("wiredPeriod",res.getString("WIRED_PERIOD"));
|
||||
params.put("wirelessNum",res.getString("WIRELESS_NUM"));
|
||||
params.put("wirelessPeriod",res.getString("WIRELESS_PERIOD"));
|
||||
params.put("carAccount",res.getString("CAR_ACCOUNT"));
|
||||
}
|
||||
res.close();
|
||||
return params.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 天易--编辑修改工单请求参数
|
||||
* @param applyNo
|
||||
* @param params
|
||||
* @param sqlca
|
||||
* @return
|
||||
*/
|
||||
public static String tyEditAlterParameter(String applyNo, String params,Transaction sqlca) {
|
||||
String [] paramArr = params.split("@");
|
||||
int i=0;
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("userAccount",TYuserAccount);
|
||||
json.put("token",TYtoken);
|
||||
json.put("sign",TYsign);
|
||||
json.put("applyNo",applyNo);
|
||||
json.put("contactName",paramArr[i++]);
|
||||
json.put("contactPhone",paramArr[i++]);
|
||||
json.put("piccontactName",paramArr[i++]);
|
||||
json.put("piccontactPhone",paramArr[i++]);
|
||||
json.put("installtime",paramArr[i++]);
|
||||
json.put("addressCode",paramArr[i++]);
|
||||
json.put("addressDetail",paramArr[i++]);
|
||||
json.put("carVin",paramArr[i++]);
|
||||
json.put("wiredNum",paramArr[i++]);
|
||||
json.put("wiredPeriod",paramArr[i++]);
|
||||
json.put("wirelessNum",paramArr[i++]);
|
||||
json.put("wirelessPeriod",paramArr[i++]);
|
||||
json.put("carAccount",paramArr[i++]);
|
||||
return json.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 天易--编辑查询/取消工单请求参数
|
||||
* @param applyNo
|
||||
* @return
|
||||
*/
|
||||
public static Map<String,String> tyEditQueryParameter(String applyNo){
|
||||
Map<String,String> params = new HashMap<String,String>();
|
||||
params.put("userAccount",TYuserAccount);
|
||||
params.put("token",TYtoken);
|
||||
params.put("sign",TYsign);
|
||||
params.put("applyNo",applyNo);
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 天易--编辑车架号查询工单请求参数
|
||||
* @param applyNo
|
||||
* @return
|
||||
*/
|
||||
public static Map<String,String> tyEditQueryToVinParameter(String vin){
|
||||
Map<String,String> params = new HashMap<String,String>();
|
||||
params.put("userAccount",TYuserAccount);
|
||||
params.put("token",TYtoken);
|
||||
params.put("sign",TYsign);
|
||||
params.put("carVin",vin);
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 天易--查询订单结果入表
|
||||
* @param tableName
|
||||
* @param flowUnid
|
||||
* @return
|
||||
* @throws JBOException
|
||||
*/
|
||||
public static String tyQueryDataPersistence(String data,String applyNo, String tableName,Transaction Sqlca) throws Exception{
|
||||
JSONObject job = JSONObject.fromObject(data);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
||||
String thisDate = sdf.format(new Date());
|
||||
String result = job.getString("result");
|
||||
if(!"0".equals(result)){
|
||||
Sqlca.executeSQL("update "+tableName+" set RESULT='"+result+"',MESSAGE='查询失败,"+job.getString("message")+"' where APPLY_NO='"+applyNo+"'");
|
||||
return job.getString("message");
|
||||
}
|
||||
String carVin = "";
|
||||
String status = job.getJSONObject("data").getString("status");
|
||||
if("3".equals(status)){
|
||||
JSONArray terminals = job.getJSONObject("data").getJSONArray("terminal");
|
||||
Sqlca.executeSQL("delete from lm_gps_location where APPLY_NO='"+applyNo+"'");
|
||||
for(int i=0;i<terminals.size();i++){
|
||||
JSONObject terminal = terminals.getJSONObject(i);
|
||||
//定位信息入表
|
||||
Sqlca.executeSQL("insert into lm_gps_location value(replace(uuid(),\"-\",\"\"),'"+applyNo+"','"+terminal.getString("model")+"','"+terminal.getString("runStatus")+"','"+terminal.getString("status")+"','"+terminal.getString("imei")+"','"+terminal.getString("receiveTime")+"','"+terminal.getString("gpsTime")+"','"+terminal.getString("lng")+"','"+terminal.getString("lat")+"','"+thisDate+"')");
|
||||
//获取车架号
|
||||
carVin = terminal.getString("carVin");
|
||||
//安装图入表
|
||||
int number = Integer.valueOf(Sqlca.getString("select COUNT(1) as number from LM_GPS_PHOTO lgp where lgp.APPLY_NO='"+applyNo+"'"));
|
||||
if(number>0) continue;
|
||||
JSONArray photoMsgs = terminal.getJSONArray("photoMsg");
|
||||
for(int j=0;j<photoMsgs.size();j++){
|
||||
JSONObject photoMsg = photoMsgs.getJSONObject(j);
|
||||
Sqlca.executeSQL("insert into LM_GPS_PHOTO value(replace(uuid(),\"-\",\"\"),'"+applyNo+"','"+photoMsg.getString("photoId")+"','"+photoMsg.getString("url")+"','"+thisDate+"')");
|
||||
}
|
||||
}
|
||||
}
|
||||
Sqlca.executeSQL("update "+tableName+" set RESULT='"+result+"',STATUS='"+status+"',MESSAGE='查询成功',CAR_VIN='"+carVin+"' where APPLY_NO='"+applyNo+"'");
|
||||
return "查询成功!";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 天易--根据车架查询订单结果解析
|
||||
* @param tableName
|
||||
* @param flowUnid
|
||||
* @return
|
||||
* @throws JBOException
|
||||
*/
|
||||
public static boolean tyQueryToVinDataPersistence(String data) throws Exception{
|
||||
JSONObject job = JSONObject.fromObject(data);
|
||||
String result = job.getString("result");
|
||||
if(!"0".equals(result))
|
||||
return false;
|
||||
|
||||
JSONArray dataArr = job.getJSONArray("data");
|
||||
for(int i=0;i<dataArr.size();i++){
|
||||
if("0".equals(dataArr.getJSONObject(i).getString("status")));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 调用日志
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void callRecord(Map<String,String> params,Transaction Sqlca) throws Exception{
|
||||
Sqlca.executeSQL(" insert into lm_gps_log values(replace(uuid(),\"-\",\"\"),'"+params.get("UPLOAD_PARAMETER")+"','"+params.get("RETURN_PARAMETER")+"',DATE_FORMAT(NOW(),'%Y/%m/%d %H:%i:%s'),'"+params.get("CALL_USERID")+"','"+params.get("FLOWUNID")+"','"+params.get("PROJECT_ID")+"','"+params.get("URL")+"','"+params.get("CALL_PURPOSE")+"','"+params.get("CALL_STATUS")+"')");
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user