204 lines
8.2 KiB
Java
204 lines
8.2 KiB
Java
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");
|
|
private static String TYsign2 = GPSConfigure.get("TYsign2");
|
|
/**
|
|
*
|
|
* 天易--编辑新增工单请求参数
|
|
* @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",TYsign2);
|
|
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 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(ID,APPLY_NO,MODEL,RUN_STATUS,STATUS,IMEI,CAR_VIN,RECEIVE_TIME,GPS_TIME,LNG,LAT,INPUTTIME) value(replace(uuid(),\"-\",\"\"),'"+applyNo+"','"+terminal.getString("model")+"','"+terminal.getString("runStatus")+"','"+terminal.getString("status")+"','"+terminal.getString("imei")
|
|
+"','"+terminal.getString("carVin")+"','"+terminal.getString("receiveTime")+"','"+terminal.getString("gpsTime")+"','"+(terminal.getString("lng")==null?"":terminal.getString("lng"))+"','"+(terminal.getString("lat")==null?"":terminal.getString("lat"))+"','"+thisDate+"')");
|
|
//安装图入表
|
|
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='查询成功' where APPLY_NO='"+applyNo+"'");
|
|
return "查询成功!";
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 天易--根据车架查询订单结果解析
|
|
* @param tableName
|
|
* @param flowUnid
|
|
* @return
|
|
* @throws JBOException
|
|
*/
|
|
public static boolean tyQueryToVinDataPersistence(String data,Transaction Sqlca) throws Exception{
|
|
JSONObject job = JSONObject.fromObject(data);
|
|
String result = job.getString("result");
|
|
if(!"0".equals(result)){
|
|
System.err.println("********************result****************");
|
|
System.err.println(result);
|
|
System.err.println("********************result****************");
|
|
return false;
|
|
}
|
|
|
|
boolean startUsing = true;
|
|
JSONArray dataArr = job.getJSONArray("data");
|
|
for(int i=0;i<dataArr.size();i++){
|
|
Sqlca.executeSQL("update lm_gps_location set SPD='"+dataArr.getJSONObject(i).getString("spd")+"',DIR='"+dataArr.getJSONObject(i).getString("dir")+"',LOCATE_TYPE='"+dataArr.getJSONObject(i).getString("locateType")+"',STATUS_USING='"+dataArr.getJSONObject(i).getString("status")+"' where IMEI='"+dataArr.getJSONObject(i).getString("imei")+"'");
|
|
if("0".equals(dataArr.getJSONObject(i).getString("status"))){
|
|
System.err.println("********************status****************");
|
|
System.err.println(dataArr.getJSONObject(i).getString("status"));
|
|
System.err.println("********************status****************");
|
|
startUsing = false;
|
|
}
|
|
}
|
|
return startUsing;
|
|
}
|
|
|
|
|
|
/**
|
|
* 调用日志
|
|
* @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")+"')");
|
|
}
|
|
}
|