329 lines
11 KiB
Java
329 lines
11 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.JBOFactory;
|
|
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;
|
|
|
|
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{
|
|
Sqlca.executeSQL("update LM_GPS_ORDER_TEMP set RESULT='"+result+"',MESSAGE='新增工单失败,"+job.getString("message")+"' where APPLY_NO='"+applyNo+"'");
|
|
return "提交失败!";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 天易--根据申请编号查询工单
|
|
* @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);
|
|
|
|
return GpsCommon.tyQueryDataPersistence(data,applyNo,tableName,Sqlca);
|
|
}
|
|
|
|
/**
|
|
* 天易--根据车架号查询工单
|
|
* @throws Exception
|
|
*/
|
|
public boolean queryOrderToVin() 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("***************天易--根据车架号查询工单返回参数*****************");
|
|
|
|
JBOTransaction tx = JBOFactory.createJBOTransaction();
|
|
Transaction Sqlca = Transaction.createTransaction(tx);
|
|
//日志参数
|
|
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);
|
|
Sqlca.disConnect();
|
|
return GpsCommon.tyQueryToVinDataPersistence(data);
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* 天易--修改工单
|
|
* @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='修改成功' 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 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();
|
|
return strb.toString();
|
|
}
|
|
}
|