330 lines
12 KiB
Java
330 lines
12 KiB
Java
package com.tenwa.gps;
|
||
|
||
import java.util.HashMap;
|
||
import java.util.Map;
|
||
import net.sf.json.JSONObject;
|
||
import com.alibaba.fastjson.JSON;
|
||
import com.amarsoft.are.jbo.JBOTransaction;
|
||
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 org.apache.commons.lang3.StringUtils;
|
||
|
||
public class GpsController {
|
||
|
||
private String applyNo;
|
||
private String orderNo;
|
||
private String flowUnid;
|
||
private String tableName;
|
||
private String vin;
|
||
private String projectId;
|
||
private String userId;
|
||
private String params;
|
||
|
||
public String getParams() {
|
||
return params;
|
||
}
|
||
|
||
public void setParams(String params) {
|
||
this.params = params;
|
||
}
|
||
|
||
public String getProjectId() {
|
||
return projectId;
|
||
}
|
||
|
||
public void setProjectId(String projectId) {
|
||
this.projectId = projectId;
|
||
}
|
||
|
||
public String getUserId() {
|
||
return userId;
|
||
}
|
||
|
||
public void setUserId(String userId) {
|
||
this.userId = userId;
|
||
}
|
||
|
||
public String getVin() {
|
||
return vin;
|
||
}
|
||
|
||
public void setVin(String vin) {
|
||
this.vin = vin;
|
||
}
|
||
|
||
public String getTableName() {
|
||
return tableName;
|
||
}
|
||
|
||
public void setTableName(String tableName) {
|
||
this.tableName = tableName;
|
||
}
|
||
|
||
public String getApplyNo() {
|
||
return applyNo;
|
||
}
|
||
|
||
public void setApplyNo(String applyNo) {
|
||
this.applyNo = applyNo;
|
||
}
|
||
|
||
public String getOrderNo() {
|
||
return orderNo;
|
||
}
|
||
|
||
public void setOrderNo(String orderNo) {
|
||
this.orderNo = orderNo;
|
||
}
|
||
|
||
public String getFlowUnid() {
|
||
return flowUnid;
|
||
}
|
||
|
||
public void setFlowUnid(String flowUnid) {
|
||
this.flowUnid = flowUnid;
|
||
}
|
||
|
||
/**
|
||
* ÌìÒ×--ÐÂÔö¹¤µ¥
|
||
* @throws Exception
|
||
*/
|
||
public String createOrder(JBOTransaction tx) throws Exception{
|
||
Transaction Sqlca = Transaction.createTransaction(tx);
|
||
String url = GPSConfigure.get("TYUrl");
|
||
String params = GpsCommon.tyEditCreateParameter(applyNo,Sqlca);
|
||
System.err.println("***************ÌìÒ×--ÐÂÔö¹¤µ¥ÉÏ´«²ÎÊý*****************");
|
||
System.err.println(params);
|
||
System.err.println("***************ÌìÒ×--ÐÂÔö¹¤µ¥ÉÏ´«²ÎÊý*****************");
|
||
Map<String,String> resultMap = HttpClientSUtil.doPostJson(url,params);
|
||
String data = resultMap.get("data");
|
||
System.err.println("***************ÌìÒ×--ÐÂÔö·µ»ØÉÏ´«²ÎÊý*****************");
|
||
System.err.println(data);
|
||
System.err.println("***************ÌìÒ×--ÐÂÔö·µ»ØÉÏ´«²ÎÊý*****************");
|
||
JSONObject job = JSONObject.fromObject(data);
|
||
String result = job.getString("result");
|
||
//ÈÕÖ¾²ÎÊý
|
||
Map<String,String> logMap = new HashMap<String,String>();
|
||
logMap.put("URL",url);
|
||
logMap.put("UPLOAD_PARAMETER",params);
|
||
logMap.put("RETURN_PARAMETER",data);
|
||
logMap.put("CALL_USERID",userId);
|
||
logMap.put("FLOWUNID",flowUnid);
|
||
logMap.put("PROJECT_ID",projectId);
|
||
logMap.put("CALL_PURPOSE","ÌìÒ×--ÐÂÔö¹¤µ¥");
|
||
logMap.put("CALL_STATUS",resultMap.get("status"));
|
||
GpsCommon.callRecord(logMap, Sqlca);
|
||
|
||
if("0".equals(result)){
|
||
Sqlca.executeSQL("update LM_GPS_ORDER_TEMP set RESULT='"+result+"',ORDER_NO='"+job.getString("orderNo")+"',STATUS='8',MESSAGE='Ìá½»³É¹¦' where APPLY_NO='"+applyNo+"'");
|
||
return "Ìá½»³É¹¦!";
|
||
}else{
|
||
String message = job.getString("message");
|
||
Sqlca.executeSQL("update LM_GPS_ORDER_TEMP set RESULT='"+result+"',MESSAGE='ÐÂÔö¹¤µ¥Ê§°Ü,"+message+"' where APPLY_NO='"+applyNo+"'");
|
||
return StringUtils.isNotBlank(message) ? message:"Ìύʧ°Ü!";
|
||
}
|
||
}
|
||
|
||
/**
|
||
* ÌìÒ×--¸ù¾ÝÉêÇë±àºÅ²éѯ¹¤µ¥
|
||
* @throws Exception
|
||
*/
|
||
public String queryOrder(JBOTransaction tx) throws Exception{
|
||
Transaction Sqlca = Transaction.createTransaction(tx);
|
||
String url = GPSConfigure.get("TYUrl")+"/"+orderNo+","+applyNo;
|
||
|
||
System.err.println("***************ÌìÒ×--¸ù¾ÝÉêÇë±àºÅ²éѯ¹¤µ¥URL*****************");
|
||
System.err.println(url);
|
||
System.err.println("***************ÌìÒ×--¸ù¾ÝÉêÇë±àºÅ²éѯ¹¤µ¥URL*****************");
|
||
|
||
Map<String,String> params = GpsCommon.tyEditQueryParameter(applyNo);
|
||
System.err.println("***************ÌìÒ×--¸ù¾ÝÉêÇë±àºÅ²éѯ¹¤µ¥ÉÏ´«²ÎÊý*****************");
|
||
System.err.println(params);
|
||
System.err.println("***************ÌìÒ×--¸ù¾ÝÉêÇë±àºÅ²éѯ¹¤µ¥ÉÏ´«²ÎÊý*****************");
|
||
|
||
Map<String,String> resultMap = HttpClientSUtil.doGet(url, params, null);
|
||
String data = resultMap.get("data");
|
||
System.err.println("***************ÌìÒ×--¸ù¾ÝÉêÇë±àºÅ²éѯ¹¤µ¥·µ»Ø²ÎÊý*****************");
|
||
System.err.println(data);
|
||
System.err.println("***************ÌìÒ×--¸ù¾ÝÉêÇë±àºÅ²éѯ¹¤µ¥·µ»Ø²ÎÊý*****************");
|
||
|
||
//ÈÕÖ¾²ÎÊý
|
||
Map<String,String> logMap = new HashMap<String,String>();
|
||
logMap.put("URL",url);
|
||
logMap.put("UPLOAD_PARAMETER",params.toString());
|
||
logMap.put("RETURN_PARAMETER",data);
|
||
logMap.put("CALL_USERID",userId);
|
||
logMap.put("FLOWUNID",flowUnid);
|
||
logMap.put("PROJECT_ID",projectId);
|
||
logMap.put("CALL_PURPOSE","ÌìÒ×--¸ù¾ÝÉêÇë±àºÅ²éѯ¹¤µ¥");
|
||
logMap.put("CALL_STATUS",resultMap.get("status"));
|
||
GpsCommon.callRecord(logMap, Sqlca);
|
||
|
||
String result1 = GpsCommon.tyQueryDataPersistence(data,applyNo,tableName,Sqlca);
|
||
String result2 = queryOrderToVin(Sqlca)==true?"²éѯ³É¹¦!":"²éѯʧ°Ü!";
|
||
|
||
return "ÉêÇë±àºÅ²éѯ¶¨Î»ÐÅÏ¢£º"+result1+"£¬³µ¼ÜºÅ²éѯ¶¨Î»ÐÅÏ¢£º"+result2;
|
||
}
|
||
|
||
/**
|
||
* ÌìÒ×--¸ù¾Ý³µ¼ÜºÅ²éѯ¹¤µ¥
|
||
* @throws Exception
|
||
*/
|
||
public boolean queryOrderToVin(Transaction Sqlca) throws Exception {
|
||
String url = GPSConfigure.get("TYQueryOrderToVin");
|
||
|
||
System.err.println("***************ÌìÒ×--¸ù¾Ý³µ¼ÜºÅ²éѯ¹¤µ¥URL*****************");
|
||
System.err.println(url);
|
||
System.err.println("***************ÌìÒ×--¸ù¾Ý³µ¼ÜºÅ²éѯ¹¤µ¥URL*****************");
|
||
|
||
Map<String,String> params = GpsCommon.tyEditQueryToVinParameter(vin);
|
||
System.err.println("***************ÌìÒ×--¸ù¾Ý³µ¼ÜºÅ²éѯ¹¤µ¥ÉÏ´«²ÎÊý*****************");
|
||
System.err.println(params);
|
||
System.err.println("***************ÌìÒ×--¸ù¾Ý³µ¼ÜºÅ²éѯ¹¤µ¥ÉÏ´«²ÎÊý*****************");
|
||
|
||
Map<String,String> resultMap = HttpClientSUtil.doGet(url, params, null);
|
||
String data = resultMap.get("data");
|
||
System.err.println("***************ÌìÒ×--¸ù¾Ý³µ¼ÜºÅ²éѯ¹¤µ¥·µ»Ø²ÎÊý*****************");
|
||
System.err.println(data);
|
||
System.err.println("***************ÌìÒ×--¸ù¾Ý³µ¼ÜºÅ²éѯ¹¤µ¥·µ»Ø²ÎÊý*****************");
|
||
|
||
//ÈÕÖ¾²ÎÊý
|
||
Map<String,String> logMap = new HashMap<String,String>();
|
||
logMap.put("URL",url);
|
||
logMap.put("UPLOAD_PARAMETER",params.toString());
|
||
logMap.put("RETURN_PARAMETER",data);
|
||
logMap.put("CALL_USERID",userId);
|
||
logMap.put("FLOWUNID",flowUnid);
|
||
logMap.put("PROJECT_ID",projectId);
|
||
logMap.put("CALL_PURPOSE","ÌìÒ×--¸ù¾Ý³µ¼ÜºÅ²éѯ¹¤µ¥");
|
||
logMap.put("CALL_STATUS",resultMap.get("status"));
|
||
GpsCommon.callRecord(logMap, Sqlca);
|
||
return GpsCommon.tyQueryToVinDataPersistence(data,Sqlca);
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* ÌìÒ×--Ð޸Ťµ¥
|
||
* @throws Exception
|
||
*/
|
||
public String alterOrder(JBOTransaction tx) throws Exception{
|
||
Transaction Sqlca = Transaction.createTransaction(tx);
|
||
String url = GPSConfigure.get("TYUrl");
|
||
String params = GpsCommon.tyEditAlterParameter(applyNo,this.params,Sqlca);
|
||
System.err.println("***************ÌìÒ×--Ð޸Ťµ¥ÉÏ´«²ÎÊý*****************");
|
||
System.err.println(params);
|
||
System.err.println("***************ÌìÒ×--Ð޸Ťµ¥ÉÏ´«²ÎÊý*****************");
|
||
|
||
Map<String,String> resultMap = HttpClientSUtil.doPutJson(url, params);
|
||
String data = resultMap.get("data");
|
||
System.err.println("***************ÌìÒ×--Ð޸Ťµ¥·µ»Ø²ÎÊý*****************");
|
||
System.err.println(data);
|
||
System.err.println("***************ÌìÒ×--Ð޸Ťµ¥·µ»Ø²ÎÊý*****************");
|
||
|
||
Map<String,String> logMap = new HashMap<String,String>();
|
||
logMap.put("URL",url);
|
||
logMap.put("UPLOAD_PARAMETER",params.toString());
|
||
logMap.put("RETURN_PARAMETER",data);
|
||
logMap.put("CALL_USERID",userId);
|
||
logMap.put("FLOWUNID",flowUnid);
|
||
logMap.put("PROJECT_ID",projectId);
|
||
logMap.put("CALL_PURPOSE","ÌìÒ×--Ð޸Ťµ¥");
|
||
logMap.put("CALL_STATUS",resultMap.get("status"));
|
||
GpsCommon.callRecord(logMap, Sqlca);
|
||
|
||
JSONObject job = JSONObject.fromObject(data);
|
||
String result = job.getString("result");
|
||
if("0".equals(result)){
|
||
String success = job.getString("success");
|
||
if("true".equals(success)){
|
||
Sqlca.executeSQL("update LM_GPS_ORDER_TEMP set RESULT='"+result+"',MESSAGE='Ð޸ijɹ¦' where APPLY_NO='"+applyNo+"'");
|
||
return "Ð޸ijɹ¦!";
|
||
}else{
|
||
String orderStep = job.getString("orderStep");
|
||
String itemname = Sqlca.getString("select cl.itemname from code_library cl where cl.codeno='gps_order_step' and cl.itemno='"+orderStep+"'");
|
||
return "ÐÞ¸Äʧ°Ü£¬µ±Ç°¶©µ¥×´Ì¬Îª"+itemname;
|
||
}
|
||
}else{
|
||
Sqlca.executeSQL("update LM_GPS_ORDER_TEMP set RESULT='"+result+"',MESSAGE='ÐÞ¸Äʧ°Ü,"+job.getString("message")+"' where APPLY_NO='"+applyNo+"'");
|
||
return "ÐÞ¸Äʧ°Ü,"+job.getString("message");
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* ÌìÒ×--È¡Ïû¹¤µ¥
|
||
* @throws Exception
|
||
*/
|
||
public String cancelOrder(JBOTransaction tx) throws Exception{
|
||
Transaction Sqlca = Transaction.createTransaction(tx);
|
||
String url = GPSConfigure.get("TYUrl");
|
||
System.err.println("***************ÌìÒ×--È¡Ïû¹¤µ¥URL*****************");
|
||
System.err.println(url);
|
||
System.err.println("***************ÌìÒ×--È¡Ïû¹¤µ¥URL*****************");
|
||
|
||
Map<String,String> params = GpsCommon.tyEditQueryParameter(applyNo);
|
||
String params2 = JSON.toJSONString(params);
|
||
System.err.println("***************ÌìÒ×--È¡Ïû¹¤µ¥ÉÏ´«²ÎÊý*****************");
|
||
System.err.println(params2);
|
||
System.err.println("***************ÌìÒ×--È¡Ïû¹¤µ¥ÉÏ´«²ÎÊý*****************");
|
||
|
||
Map<String,String> resultMap = HttpClientSUtil.doPatchJson(url, params2);
|
||
String data = resultMap.get("data");
|
||
System.err.println("***************ÌìÒ×--²éѯ¹¤µ¥·µ»Ø²ÎÊý*****************");
|
||
System.err.println(data);
|
||
System.err.println("***************ÌìÒ×--²éѯ¹¤µ¥·µ»Ø²ÎÊý*****************");
|
||
|
||
Map<String,String> logMap = new HashMap<String,String>();
|
||
logMap.put("URL",url);
|
||
logMap.put("UPLOAD_PARAMETER",params.toString());
|
||
logMap.put("RETURN_PARAMETER",data);
|
||
logMap.put("CALL_USERID",userId);
|
||
logMap.put("FLOWUNID",flowUnid);
|
||
logMap.put("PROJECT_ID",projectId);
|
||
logMap.put("CALL_PURPOSE","ÌìÒ×--È¡Ïû¹¤µ¥");
|
||
logMap.put("CALL_STATUS",resultMap.get("status"));
|
||
GpsCommon.callRecord(logMap, Sqlca);
|
||
|
||
JSONObject job = JSONObject.fromObject(data);
|
||
String result = job.getString("result");
|
||
if("0".equals(result)){
|
||
String success = job.getString("success");
|
||
if("true".equals(success)){
|
||
Sqlca.executeSQL("update LM_GPS_ORDER_TEMP set RESULT='"+result+"',MESSAGE='È¡Ïû³É¹¦' where APPLY_NO='"+applyNo+"'");
|
||
return "È¡Ïû³É¹¦!";
|
||
}else{
|
||
String orderStep = job.getString("orderStep");
|
||
String itemname = Sqlca.getString("select cl.itemname from code_library cl where cl.codeno='gps_order_step' and cl.itemno='"+orderStep+"'");
|
||
return "È¡Ïûʧ°Ü£¬µ±Ç°¶©µ¥×´Ì¬Îª"+itemname;
|
||
}
|
||
}else{
|
||
Sqlca.executeSQL("update LM_GPS_ORDER_TEMP set RESULT='"+result+"',MESSAGE='È¡Ïûʧ°Ü,"+job.getString("message")+"' where APPLY_NO='"+applyNo+"'");
|
||
return "È¡Ïûʧ°Ü,"+job.getString("message");
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* ÌìÒ×--»ñȡͼƬ
|
||
* @throws Exception
|
||
*/
|
||
public String getImage(JBOTransaction tx) throws Exception{
|
||
Transaction Sqlca = Transaction.createTransaction(tx);
|
||
ASResultSet res = Sqlca.getASResultSet(new SqlObject("SELECT url FROM lm_gps_photo WHERE apply_no='"+applyNo+"'"));
|
||
StringBuffer strb = null;
|
||
while(res.next()){
|
||
if(strb==null){
|
||
strb = new StringBuffer(res.getString("url"));
|
||
}else{
|
||
strb.append(","+res.getString("url"));
|
||
}
|
||
}
|
||
res.close();
|
||
if(strb==null)
|
||
return "null";
|
||
return strb.toString();
|
||
}
|
||
}
|