添加中瑞gps支持

This commit is contained in:
gityjf 2020-08-20 15:40:00 +08:00
parent 4b929ba65c
commit 0beea9bac6
11 changed files with 1261 additions and 940 deletions

View File

@ -1,3 +1,4 @@
<%@ page import="com.tenwa.apzl.comm.GpsEnum" %>
<%@ page contentType="text/html; charset=GBK"%>
<%@ include file="/Frame/resources/include/include_begin_list.jspf"%><%
/*
@ -6,7 +7,18 @@
History Log:
*/
String ProjectNo = CurPage.getParameter("ProjectNo");
String source = CurPage.getParameter("source");
ASObjectModel doTemp = new ASObjectModel("LmGpsLocationList");
if(GpsEnum.ZR.getCode().equals(source)){
doTemp.setDDDWCodeTable("RUN_STATUS","0,未启用,1,离线,2,禁止,3,行驶中");
doTemp.setDDDWCodeTable("LOCATE_TYPE","0,GPS定位,1,基站定位");
doTemp.setDDDWCodeTable("MODEL","0,无线,1,有线");
doTemp.setColumnAttribute("STATUS", "COLVISIBLE", "0");
doTemp.setColumnAttribute("STATUS_USING", "COLVISIBLE", "0");
doTemp.setColumnAttribute("SPD", "COLVISIBLE", "0");
doTemp.setColumnAttribute("DIR", "COLVISIBLE", "0");
doTemp.setColumnAttribute("RECEIVE_TIME", "COLVISIBLE", "0");
}
ASObjectWindow dwTemp = new ASObjectWindow(CurPage,doTemp,request);
dwTemp.Style="1"; //--设置为Grid风格--
dwTemp.ReadOnly = "1"; //只读模式

View File

@ -1,5 +1,6 @@
<%@ page contentType="text/html; charset=GBK"%>
<%@ page import="java.math.BigDecimal"%>
<%@ page import="com.tenwa.apzl.comm.GpsEnum" %>
<%@ include file="/Frame/resources/include/include_begin_info.jspf"%><%
/*
Author: undefined 2019-07-11
@ -8,6 +9,8 @@
*/
String userId = CurUser.getUserID();
String ProjectNo = CurPage.getParameter("ProjectNo");
//gps来源 中瑞1 天易0
String source = CurPage.getParameter("gpsVendor");
String ProjectId = CurPage.getParameter("ProjectId");
String PhaseNo = CurPage.getParameter("PhaseNo");
String flowunid = CurPage.getParameter("ObjectNo");
@ -15,14 +18,12 @@
String frameNumber = Sqlca.getString("select FRAME_NUMBER from LB_EQUIPMENT_CAR_TEMP where FLOWUNID='"+flowunid+"'");
String id = Sqlca.getString("select id from LM_GPS_ORDER_TEMP where APPLY_NO='"+ProjectNo+"'");
String contact_name = Sqlca.getString("select CONTACT_NAME from GPS_config_info where isenable='1' ");//现场联系人
String contact_phone = Sqlca.getString("select CONTACT_PHONE from GPS_config_info where isenable='1' ");//现场联系人电话
String contact_name = Sqlca.getString("select CONTACT_NAME from GPS_config_info where isenable='1' ");//派工联系人
String contact_phone = Sqlca.getString("select CONTACT_PHONE from GPS_config_info where isenable='1' ");//派工联系人电话
String distributor_id = Sqlca.getString("select distributor_id from lb_project_info where id='"+ProjectId+"'");//获取经销商ID
String distributor_name = Sqlca.getString("select distributor_name from distributor_info where distributor_no='"+distributor_id+"'");//获取经销名称
BigDecimal incomNuber = new BigDecimal(Sqlca.getString("select INCOME_NUMBER from LC_CALC_CONDITION_TEMP where FLOWUNID='"+flowunid+"'"));
List<String> images = new ArrayList<String>();
String sql = "select lgp.URL from lm_gps_photo lgp where APPLY_NO='"+ProjectNo+"'";
@ -34,11 +35,17 @@
String period = incomNuber.divide(new BigDecimal("12"),0,BigDecimal.ROUND_UP).toString();
String sTempletNo = "LmGpsOrderInfo";//--模板号--
ASObjectModel doTemp = new ASObjectModel(sTempletNo);
if(GpsEnum.ZR.getCode().equals(source)){
doTemp.setColumnAttribute("CARTYPE", "COLVISIBLE", "0");
doTemp.setColumnAttribute("USERNAME", "COLVISIBLE", "0");
doTemp.setColumnAttribute("USERPHONE", "COLVISIBLE", "0");
doTemp.setColumnAttribute("SHOPNAME", "COLVISIBLE", "0");
}
ASObjectWindow dwTemp = new ASObjectWindow(CurPage, doTemp,request);
dwTemp.Style = "2";//freeform
//dwTemp.ReadOnly = "-2";//只读模式
dwTemp.genHTMLObjectWindow(ProjectNo);
dwTemp.replaceColumn("LOCATION", "<iframe type='iframe' id='frame_list' name=\"frame_list\" width=\"100%\" height=\"280px\" frameborder=\"0\" src=\""+sWebRootPath+"/Tenwa/Gps/LmGpsLocationList.jsp?CompClientID="+compClientID+"&ProjectNo="+ProjectNo+"\"></iframe>", CurPage.getObjectWindowOutput());
dwTemp.replaceColumn("LOCATION", "<iframe type='iframe' id='frame_list' name=\"frame_list\" width=\"100%\" height=\"280px\" frameborder=\"0\" src=\""+sWebRootPath+"/Tenwa/Gps/LmGpsLocationList.jsp?CompClientID="+compClientID+"&ProjectNo="+ProjectNo+"&source="+source+"\"></iframe>", CurPage.getObjectWindowOutput());
String [][] sButtons;
if("0010".equals(PhaseNo)){
sButtons = new String[][]{
@ -67,6 +74,7 @@
setItemValue(0,getRow(0),"PICCONTACT_NAME",'<%=contact_name%>');
setItemValue(0,getRow(0),"PICCONTACT_PHONE",'<%=contact_phone%>');
setItemValue(0,getRow(0),"CAR_ACCOUNT",'<%=distributor_name%>');
setItemValue(0,getRow(0),"SOURCE",'<%=source%>');
var status = getItemValue(0,getRow(),"STATUS");
@ -103,7 +111,7 @@
})
function submitOrder(){
var result =AsControl.RunJavaMethodTrans("com.tenwa.gps.GpsController","createOrder","applyNo=<%=ProjectNo%>,flowUnid=<%=flowunid%>,projectId=<%=ProjectId%>,userId=<%=userId%>");
var result =AsControl.RunJavaMethodTrans("com.tenwa.gps.GpsController","createOrder","applyNo=<%=ProjectNo%>,flowUnid=<%=flowunid%>,projectId=<%=ProjectId%>,userId=<%=userId%>,source=<%=source%>");
alert(result)
location.reload();
}
@ -116,7 +124,7 @@
alert("请先提交工单!");
return;
}
var result =AsControl.RunJavaMethodTrans("com.tenwa.gps.GpsController","queryOrder","applyNo=<%=ProjectNo%>,projectId=<%=ProjectId%>,userId=<%=userId%>,flowUnid=<%=flowunid%>,tableName=LM_GPS_ORDER_TEMP,orderNo="+orderNo+",vin="+vin);
var result =AsControl.RunJavaMethodTrans("com.tenwa.gps.GpsController","queryOrder","applyNo=<%=ProjectNo%>,projectId=<%=ProjectId%>,userId=<%=userId%>,flowUnid=<%=flowunid%>,tableName=LM_GPS_ORDER_TEMP,orderNo="+orderNo+",vin="+vin+",source=<%=source%>");
alert(result)
location.reload();
}
@ -150,6 +158,10 @@
alert("请先提交工单!");
return;
}
if('<%=source%>' == '1'){
alert("中瑞GPS派单暂无此功能!");
return;
}
window.parent.showImage();
}
@ -159,6 +171,10 @@
alert("请先提交工单!");
return;
}
if('<%=source%>' == '1'){
alert("中瑞GPS派单暂时无法修改!");
return;
}
var params = getItemValue(0,getRow(),"CONTACT_NAME");
params += "@"+getItemValue(0,getRow(),"CONTACT_PHONE");
params += "@"+getItemValue(0,getRow(),"PICCONTACT_NAME");
@ -186,7 +202,7 @@
return;
}
if(confirm('取消工单后此申请编号无法重新派单!请谨慎操作!是否继续取消工单?')){
var result =AsControl.RunJavaMethodTrans("com.tenwa.gps.GpsController","cancelOrder","applyNo=<%=ProjectNo%>,userId=<%=userId%>,projectId=<%=ProjectId%>,flowUnid=<%=flowunid%>");
var result =AsControl.RunJavaMethodTrans("com.tenwa.gps.GpsController","cancelOrder","applyNo=<%=ProjectNo%>,userId=<%=userId%>,projectId=<%=ProjectId%>,flowUnid=<%=flowunid%>,source=<%=source%>");
alert(result)
location.reload();
}

View File

@ -2336,7 +2336,7 @@
<attributes>
<attribute name="ID" label="主键" type="STRING" length="32"/>
<attribute name="APPLY_NO" label="申请编号" type="STRING" length="32"/>
<attribute name="ORDER_NO" label="工单编号" type="STRING" length="32"/>
<attribute name="ORDER_NO" label="工单编号" type="STRING" length="40"/>
<attribute name="CONTACT_NAME" label="现场联系人" type="STRING" length="256"/>
<attribute name="CONTACT_PHONE" label="现场联系人电话" type="STRING" length="32"/>
<attribute name="PICCONTACT_NAME" label="派工联系人" type="STRING" length="256"/>
@ -2355,6 +2355,11 @@
<attribute name="STATUS" label="订单状态" type="STRING" length="32"/>
<attribute name="PROJECT_ID" label="项目编号" type="STRING" length="32"/>
<attribute name="FLOWUNID" label="流程编号" type="STRING" length="32"/>
<attribute name="CARTYPE" label="车型" type="STRING" length="100"/>
<attribute name="USERNAME" label="车主名称" type="STRING" length="32"/>
<attribute name="USERPHONE" label="车主电话" type="STRING" length="11"/>
<attribute name="SHOPNAME" label="安装店面" type="STRING" length="100"/>
<attribute name="SOURCE" label="GPS来源" type="STRING" length="10"/>
<attribute name="INPUTTIME" label="录入时间" type="STRING" length="32"/>
<attribute name="INPUTUSERID" label="录入人" type="STRING" length="32"/>
<attribute name="INPUTORGID" label="录入部门" type="STRING" length="32"/>
@ -2373,7 +2378,7 @@
<attributes>
<attribute name="ID" label="主键" type="STRING" length="32"/>
<attribute name="APPLY_NO" label="申请编号" type="STRING" length="32"/>
<attribute name="ORDER_NO" label="工单编号" type="STRING" length="32"/>
<attribute name="ORDER_NO" label="工单编号" type="STRING" length="40"/>
<attribute name="CONTACT_NAME" label="现场联系人" type="STRING" length="256"/>
<attribute name="CONTACT_PHONE" label="现场联系人电话" type="STRING" length="32"/>
<attribute name="PICCONTACT_NAME" label="派工联系人" type="STRING" length="256"/>
@ -2392,7 +2397,12 @@
<attribute name="STATUS" label="订单状态" type="STRING" length="32"/>
<attribute name="PROJECT_ID" label="项目编号" type="STRING" length="32"/>
<attribute name="FLOWUNID" label="流程编号" type="STRING" length="32"/>
<attribute name="INPUTTIME" label="录入时间" type="STRING" length="32"/>
<attribute name="CARTYPE" label="车型" type="STRING" length="100"/>
<attribute name="USERNAME" label="车主名称" type="STRING" length="32"/>
<attribute name="USERPHONE" label="车主电话" type="STRING" length="11"/>
<attribute name="SHOPNAME" label="安装店面" type="STRING" length="100"/>
<attribute name="SOURCE" label="GPS来源" type="STRING" length="10"/>
<attribute name="INPUTTIME" label="录入时间" type="STRING" length="32"/>
<attribute name="INPUTUSERID" label="录入人" type="STRING" length="32"/>
<attribute name="INPUTORGID" label="录入部门" type="STRING" length="32"/>
<attribute name="UPDATETIME" label="修改时间" type="STRING" length="32"/>

View File

@ -4,3 +4,13 @@ TYsign=3474A2D7CFEC5DECD54DE8A263F7A4A9
TYsign2=3474a2d7cfec5decd54de8a263f7a4a9
TYUrl=http://121.43.178.183:9989/dispatch_intf/apiController/order
TYQueryOrderToVin=http://121.43.178.183:80/gps-intf/api2/getGpsInfosByCarVin
# \u4E2D\u745EProductId
ZR_ProfuctId=d5e89c74-6014-11e9-bdb3-6c92bf61e2
# \u4E2D\u745EappKey
ZR_AppKey=2C6074D0-C8E4-4BA4-A50A-E3A46EAD394A
# \u65b0\u589e\u5de5\u5355
ZR_create_url=http://gatewayapi.lunztech.cn/api/ApiPlat/AddOrderWithVpsInfos
# \u67e5\u8be2\u5de5\u5355
ZR_query_url=http://gatewayapi.lunztech.cn/api/ApiPlat/GetAllEqPositionsByVIN
# \u53d6\u6d88\u5de5\u5355
ZR_cancel_url=http://gatewayapi.lunztech.cn/api/ApiPlat/CancelVpsAddOrder

View File

@ -19,6 +19,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import apx.com.amarsoft.als.apzl.apply.business.doc.detail.process.DocLibraryStateUpdate;
import com.tenwa.apzl.comm.GpsEnum;
import jbo.app.tenwa.customer.CUSTOMER_ACCOUNT;
import jbo.app.tenwa.customer.CUSTOMER_ACCOUNT_HIS;
import jbo.app.tenwa.customer.CUSTOMER_ACCOUNT_TEMP;
@ -402,12 +403,11 @@ public class FlowDataServiceImpl implements FlowDataService{
BizObject lect = lectManage.createQuery(" FLOWUNID=:FlowUnid ").setParameter("FlowUnid", flowunid).getSingleResult(false);
String distributor_id = sqlca.getString("select distributor_id from lb_project_info where id='"+projectId+"'");//获取经销商ID
BizObjectManager lgtManage = JBOFactory.getFactory().getManager(LM_GPS_ORDER_TEMP.CLASS_NAME);
BizObject lgt = lgtManage.createQuery(" APPLY_NO=:APPLY_NO ").setParameter("APPLY_NO", projectNo).getSingleResult(false);
if(lgt == null){
//gps来源
String gpsVendor = sqlca.getString("select psl.GPS_VENDOR from prd_specific_library psl join flow_bussiness_object fbo on psl.PRODUCTID = fbo.productId where fbo.flow_unid = '"+flowunid+"'");
body.put("APPLY_NO", flowParms.get("ProjectNo"));//申请编号
body.put("CAR_VIN", lect == null ? "": lect.getAttribute("FRAME_NUMBER").toString());//车架号
body.put("CONTACT_NAME", "");//现场联系人
@ -418,12 +418,19 @@ public class FlowDataServiceImpl implements FlowDataService{
body.put("ADDRESS_DETAIL", "");//详细地址
body.put("WIRED_NUM", "1");//有线设备数量
body.put("WIRELESS_NUM", "1");//无线设备数量
body.put("CAR_ACCOUNT", "");//Ŕ­łľŐËşĹ
body.put("RESULT", "");//请求结果 MESSAGE
body.put("MESSAGE", "");//处理信息
body.put("STATUS", "未提交");//订单状态
body.put("PROJECT_ID", projectId);//项目id
body.put("CAR_ACCOUNT", sqlca.getString("select distributor_name from distributor_info where distributor_no='"+distributor_id+"'"));//ĎîÄżid
body.put("CAR_ACCOUNT", sqlca.getString("select distributor_name from distributor_info where distributor_no='"+distributor_id+"'"));//拉车账号
if(GpsEnum.ZR.getCode().equals(gpsVendor)){
body.put("CARTYPE","");
body.put("USERNAME","");
body.put("USERPHONE","");
body.put("SHOPNAME","");
}
body.put("SOURCE", GpsEnum.ZR.getCode().equals(gpsVendor)?GpsEnum.ZR.getCode():GpsEnum.TY.getCode());//GPS来源
body.put("SOURCEDESCRIP", GpsEnum.ZR.getCode().equals(gpsVendor)?GpsEnum.ZR.getName():GpsEnum.TY.getName());//GPS来源描述
}else{
body.put("APPLY_NO", lgt.getAttribute("APPLY_NO").toString());//申请编号
body.put("CAR_VIN", lgt.getAttribute("CAR_VIN").toString());//车架号
@ -441,7 +448,17 @@ public class FlowDataServiceImpl implements FlowDataService{
body.put("STATUS", NameManager.getItemName("gps_status",lgt.getAttribute("STATUS").toString()));//订单状态
body.put("PROJECT_ID", lgt.getAttribute("PROJECT_ID").toString());//项目id
body.put("CAR_ACCOUNT", lgt.getAttribute("CAR_ACCOUNT").toString());//项目id
if(GpsEnum.ZR.getCode().equals(String.valueOf(lgt.getAttribute("SOURCE")))){
body.put("CARTYPE",lgt.getAttribute("CARTYPE").toString());
body.put("USERNAME",lgt.getAttribute("USERNAME").toString());
body.put("USERPHONE",lgt.getAttribute("USERPHONE").toString());
body.put("SHOPNAME",lgt.getAttribute("SHOPNAME").toString());
body.put("SOURCE",GpsEnum.ZR.getCode());
body.put("SOURCEDESCRIP",GpsEnum.ZR.getName());
}else{
body.put("SOURCE",GpsEnum.TY.getCode());
body.put("SOURCEDESCRIP",GpsEnum.TY.getName());
}
}
body.put("flowunid", flowunid);//流程id
System.out.println("GPS返回参数"+body);
@ -480,6 +497,11 @@ public class FlowDataServiceImpl implements FlowDataService{
lgt.setAttributeValue("ADDRESS_DETAIL", fieldMap.get("ADDRESS_DETAIL") == null ? "" : fieldMap.get("ADDRESS_DETAIL").toString());//详细地址
lgt.setAttributeValue("WIRED_NUM", fieldMap.get("WIRED_NUM") == null ? "" : fieldMap.get("WIRED_NUM").toString());//有线设备数量
lgt.setAttributeValue("WIRELESS_NUM", fieldMap.get("WIRELESS_NUM") == null ? "" : fieldMap.get("WIRELESS_NUM").toString());//无线设备数量
lgt.setAttributeValue("CARTYPE", fieldMap.get("CARTYPE") == null ? "" : fieldMap.get("CARTYPE").toString());//车型
lgt.setAttributeValue("USERNAME", fieldMap.get("USERNAME") == null ? "" : fieldMap.get("USERNAME").toString());//车主名称
lgt.setAttributeValue("USERPHONE", fieldMap.get("USERPHONE") == null ? "" : fieldMap.get("USERPHONE").toString());//车主电话
lgt.setAttributeValue("SHOPNAME", fieldMap.get("SHOPNAME") == null ? "" : fieldMap.get("SHOPNAME").toString());//安装店面
}else{
body.put("statusCode", "01");
body.put("flowunid", flowunid);//流程id
@ -506,6 +528,11 @@ public class FlowDataServiceImpl implements FlowDataService{
lgt.setAttributeValue("WIRELESS_PERIOD",period);
lgt.setAttributeValue("FLOWUNID",flowunid);
lgt.setAttributeValue("PROJECT_ID", projectId );//项目id
lgt.setAttributeValue("CARTYPE", fieldMap.get("CARTYPE") == null ? "" : fieldMap.get("CARTYPE").toString());//车型
lgt.setAttributeValue("USERNAME", fieldMap.get("USERNAME") == null ? "" : fieldMap.get("USERNAME").toString());//车主名称
lgt.setAttributeValue("USERPHONE", fieldMap.get("USERPHONE") == null ? "" : fieldMap.get("USERPHONE").toString());//车主电话
lgt.setAttributeValue("SHOPNAME", fieldMap.get("SHOPNAME") == null ? "" : fieldMap.get("SHOPNAME").toString());//安装店面
lgt.setAttributeValue("SOURCE", fieldMap.get("SOURCE") == null ? "" : fieldMap.get("SOURCE").toString());
if(GpsConfig.size()>0){
lgt.setAttributeValue("PICCONTACT_NAME",GpsConfig.get(0).get("CONTACT_NAME"));
lgt.setAttributeValue("PICCONTACT_PHONE",GpsConfig.get(0).get("CONTACT_PHONE"));
@ -523,6 +550,7 @@ public class FlowDataServiceImpl implements FlowDataService{
gpsC.setFlowUnid(flowunid);
gpsC.setProjectId(projectId);
gpsC.setUserId(userid);
gpsC.setSource(fieldMap.get("SOURCE").toString());
String message = gpsC.createOrder(tx);
if("提交成功!".equals(message)){
body.put("statusCode", "00");
@ -557,6 +585,7 @@ public class FlowDataServiceImpl implements FlowDataService{
gpsC.setTableName("LM_GPS_ORDER_TEMP");
gpsC.setOrderNo(gpslgot.getAttribute("ORDER_NO").getString());
gpsC.setVin(gpslgot.getAttribute("CAR_VIN").getString());
gpsC.setSource(gpslgot.getAttribute("SOURCE").getString());
String queryOrder = gpsC.queryOrder(tx);
body.put("statusCode", "00");
body.put("msg", queryOrder);
@ -589,8 +618,6 @@ public class FlowDataServiceImpl implements FlowDataService{
String address_detail = fieldMap.get("ADDRESS_DETAIL") == null ? "" : fieldMap.get("ADDRESS_DETAIL").toString();//详细地址
String wired_num = fieldMap.get("WIRED_NUM") == null ? "" : fieldMap.get("WIRED_NUM").toString();//有线设备数量
String wireless_num = fieldMap.get("WIRELESS_NUM") == null ? "" : fieldMap.get("WIRELESS_NUM").toString();//无线设备数量
BizObjectManager lgtManage = JBOFactory.getFactory().getManager(LM_GPS_ORDER_TEMP.CLASS_NAME,tx);
BizObject gpslgot =lgtManage.createQuery(" flowunid=:flowunid ").setParameter("flowunid", flowunid).getSingleResult(true);
GpsController gpsC = new GpsController();
@ -661,6 +688,7 @@ public class FlowDataServiceImpl implements FlowDataService{
gpsC.setProjectId(gpslgot.getAttribute("PROJECT_ID").getString());
gpsC.setUserId(userid);
gpsC.setFlowUnid(flowunid);
gpsC.setSource(gpslgot.getAttribute("SOURCE").getString());
String cancelOrder = gpsC.cancelOrder(tx);
body.put("statusCode", "00");

View File

@ -22,7 +22,7 @@ public interface LM_GPS_ORDER{
*/
public static final String APPLY_NO = "APPLY_NO";
/**
* 묏데긍뵀 STRING(32)<br>
* 工单编号 STRING(40)<br>
*/
public static final String ORDER_NO = "ORDER_NO";
/**
@ -98,6 +98,26 @@ public interface LM_GPS_ORDER{
*/
public static final String FLOWUNID = "FLOWUNID";
/**
* 车型 STRING(100)<br>
*/
public static final String CARTYPE = "CARTYPE";
/**
* 车主名称 STRING(32)<br>
*/
public static final String USERNAME = "USERNAME";
/**
* 车主电话 STRING(11)<br>
*/
public static final String USERPHONE = "USERPHONE";
/**
* 安装店面 STRING(100)<br>
*/
public static final String SHOPNAME = "SHOPNAME";
/**
* GPS来源 STRING(10)<br>
*/
public static final String SOURCE = "SOURCE";
/**
* 录入时间 STRING(32)<br>
*/
public static final String INPUTTIME = "INPUTTIME";

View File

@ -22,7 +22,7 @@ public interface LM_GPS_ORDER_TEMP{
*/
public static final String APPLY_NO = "APPLY_NO";
/**
* 묏데긍뵀 STRING(32)<br>
* 工单编号 STRING(40)<br>
*/
public static final String ORDER_NO = "ORDER_NO";
/**
@ -98,6 +98,26 @@ public interface LM_GPS_ORDER_TEMP{
*/
public static final String FLOWUNID = "FLOWUNID";
/**
* 车型 STRING(100)<br>
*/
public static final String CARTYPE = "CARTYPE";
/**
* 车主名称 STRING(32)<br>
*/
public static final String USERNAME = "USERNAME";
/**
* 车主电话 STRING(11)<br>
*/
public static final String USERPHONE = "USERPHONE";
/**
* 安装店面 STRING(100)<br>
*/
public static final String SHOPNAME = "SHOPNAME";
/**
* GPS来源 STRING(10)<br>
*/
public static final String SOURCE = "SOURCE";
/**
* 录入时间 STRING(32)<br>
*/
public static final String INPUTTIME = "INPUTTIME";

View File

@ -0,0 +1,27 @@
package com.tenwa.apzl.comm;
/**
* Created by Administrator on 2020/8/19.
* gps 分类
*/
public enum GpsEnum {
TY("0","天易"),
ZR("1","中瑞");
private String code;
private String name;
GpsEnum(String code, String name) {
this.code = code;
this.name = name;
}
public String getCode() {
return code;
}
public String getName() {
return name;
}
}

View File

@ -1,203 +1,270 @@
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;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
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();
}
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 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 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();
if (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.containsKey("lng") ? terminal.getString("lng") : "") + "','" + (terminal.containsKey("lat") ? 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;
}
/**
*
* 天易--编辑查询/取消工单请求参数
* @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 flowUnid
* @param applyNo
* @param tx
* @return
* @throws Exception
*/
public static String zrEditCreateParameter(String applyNo, Transaction Sqlca) throws Exception {
ASResultSet res = Sqlca.getASResultSet(new SqlObject("select CAR_VIN,ADDRESS_CODE,SHOPNAME,CONTACT_NAME,CONTACT_PHONE,INSTALL_TIME,ADDRESS_DETAIL,CARTYPE,USERNAME,USERPHONE from LM_GPS_ORDER_TEMP where APPLY_NO='" + applyNo + "'"));
JSONObject params = new JSONObject();
while (res.next()) {
params.put("AppCode", applyNo);
params.put("ProductId", GPSConfigure.get("ZR_ProfuctId"));
params.put("VIN", res.getString("CAR_VIN"));
params.put("DistrictCode", res.getString("ADDRESS_CODE"));
params.put("ShopName", res.getString("SHOPNAME"));
params.put("LinkMan", res.getString("CONTACT_NAME"));
params.put("LinkPhone", res.getString("CONTACT_PHONE"));
params.put("InstallTime", res.getString("INSTALL_TIME"));
params.put("InstallAdd", res.getString("ADDRESS_DETAIL"));
params.put("CarType", res.getString("CARTYPE"));
params.put("UserName", res.getString("USERNAME"));
params.put("UserPhone", res.getString("USERPHONE"));
}
res.close();
return params.toString();
}
/**
*
* 天易--编辑车架号查询工单请求参数
* @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.containsKey("lng")?terminal.getString("lng"):"")+"','"+(terminal.containsKey("lat")?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;
}
/**
* 中瑞--车架号查询工单请求参数
*
* @param applyNo
* @return
*/
public static boolean zrQueryToVinDataPersistence(String data, String vin, Transaction Sqlca) throws Exception {
JSONObject job = JSONObject.fromObject(data);
boolean startUsing = job.getBoolean("Success");
if (!startUsing) {
System.err.println("********************AllMessages****************");
System.err.println(job.getString("AllMessages"));
System.err.println("********************AllMessages****************");
return false;
}
//有GPS终端设备运行异常
if (!job.getJSONObject("Data").getBoolean("allnormal")) {
startUsing = false;
}
JSONArray dataArr = job.getJSONObject("Data").getJSONArray("postions");
Sqlca.executeSQL("delete from lm_gps_location where car_vin = '" + vin + "'");
StringBuilder sb = new StringBuilder("insert into lm_gps_location (ID,APPLY_NO,MODEL,RUN_STATUS,IMEI,CAR_VIN,GPS_TIME,LNG,LAT,LOCATE_TYPE,INPUTTIME) values ");
String insertVal = null;
for (int i = 0; i < dataArr.size(); i++) {
job = dataArr.getJSONObject(i);
if (i > 0) {
sb.append(",");
}
insertVal = "replace(uuid(),'-',''),'" + job.getString("appcode") + "','"+job.getString("flag")+"','" + job.getString("sbcstatus") + "'"
+ ",'" + job.getString("imei") + "','" + job.getString("vin") + "','" + job.getString("locationTime") + "'"
+ ",'" + job.getString("lng") + "','" + job.getString("lat") + "','" + job.getString("LocateMode") + "',date_format(now(),'%Y/%m/%d %H:%i:%s')";
sb.append("(").append(insertVal).append(")");
}
if (insertVal != null) Sqlca.executeSQL(sb.toString());
if (startUsing)Sqlca.executeSQL("update LM_GPS_ORDER_TEMP set RESULT='0',STATUS='3',MESSAGE='查询成功' where CAR_VIN='" + vin + "'");
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")+"')");
}
/**
* 调用日志
*
* @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") + "')");
}
}

View File

@ -1,329 +1,418 @@
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.are.lang.StringX;
import com.amarsoft.awe.util.ASResultSet;
import com.amarsoft.awe.util.SqlObject;
import com.amarsoft.awe.util.Transaction;
import com.google.common.collect.ImmutableMap;
import com.tenwa.apzl.comm.GpsEnum;
import com.tenwa.httpclient.resources.GPSConfigure;
import org.apache.commons.lang3.StringUtils;
import net.sf.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
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;
private String applyNo;
private String orderNo;
private String flowUnid;
private String tableName;
private String vin;
private String projectId;
private String userId;
private String params;
private String source;
public String getParams() {
return params;
}
/**
* 新增工单
*
* @throws Exception
*/
public String createOrder(JBOTransaction tx) throws Exception {
Transaction Sqlca = Transaction.createTransaction(tx);
String url, params, tips = null;
Map<String, String> header = null;
if (GpsEnum.ZR.getCode().equals(source)) {
url = GPSConfigure.get("ZR_create_url");
params = GpsCommon.zrEditCreateParameter(applyNo, Sqlca);
header = ImmutableMap.of("appKey", GPSConfigure.get("ZR_AppKey"));
tips = GpsEnum.ZR.getName();
} else {
url = GPSConfigure.get("TYUrl");
params = GpsCommon.tyEditCreateParameter(applyNo, Sqlca);
tips = GpsEnum.TY.getName();
}
if (url == null || params == null) return "组装请求工单信息失败,联系管理员!";
System.err.println("***************" + tips + "--新增工单上传参数*****************");
System.err.println(params);
System.err.println("***************" + tips + "--新增工单上传参数*****************");
Map<String, String> resultMap = HttpClientSUtil.doPostJson(url, params, header);
String data = resultMap.get("data");
System.err.println("***************" + tips + "--新增返回上传参数*****************");
System.err.println(data);
System.err.println("***************" + tips + "--新增返回上传参数*****************");
//日志参数
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", tips + "--新增工单");
logMap.put("CALL_STATUS", resultMap.get("status"));//http请求状态
//添加日志记录
GpsCommon.callRecord(logMap, Sqlca);
JSONObject job = JSONObject.fromObject(data);
String result = null;
boolean orderStatus = false;//订单是否成功状态
String orderNo = "";//工单ID
if (GpsEnum.ZR.getCode().equals(source)) {
orderStatus = job.getBoolean("Success");
result = orderStatus ? "0" : "9";
if(orderStatus){
orderNo = job.getJSONObject("Data").getString("Id");
}
} else {
result = job.getString("result");
orderStatus = !StringX.isSpace(result) && "0".equals(result) ? true : false;
if(orderStatus){
orderNo = job.getString("orderNo");
}
}
if (orderStatus) {
Sqlca.executeSQL("update LM_GPS_ORDER_TEMP set RESULT='" + result + "',ORDER_NO='" + orderNo + "',STATUS='8',MESSAGE='提交成功' where APPLY_NO='" + applyNo + "'");
return "提交成功!";
} else {
String errorMsg = "新增工单失败,";
if (GpsEnum.ZR.getCode().equals(source)) {
errorMsg += job.getString("AllMessages");
} else {
errorMsg += job.getString("message");
}
Sqlca.executeSQL("update LM_GPS_ORDER_TEMP set RESULT='" + result + "',MESSAGE='" + errorMsg + "' where APPLY_NO='" + applyNo + "'");
return errorMsg;
}
}
public void setParams(String params) {
this.params = params;
}
/**
* 取消工单
*
* @throws Exception
*/
public String cancelOrder(JBOTransaction tx) throws Exception {
Transaction Sqlca = Transaction.createTransaction(tx);
String url, tips = null;
Map<String, String> params = null;
Map<String, String> header = null;
if (GpsEnum.ZR.getCode().equals(source)) {
params = ImmutableMap.of("Appcode", applyNo);
url = GPSConfigure.get("ZR_cancel_url");
tips = GpsEnum.ZR.getName();
header = ImmutableMap.of("appKey", GPSConfigure.get("ZR_AppKey"));
} else {
params = params = GpsCommon.tyEditQueryParameter(applyNo);
url = GPSConfigure.get("TYUrl");
tips = GpsEnum.TY.getName();
}
System.err.println("***************" + tips + "--取消工单URL*****************");
System.err.println(url);
System.err.println("***************" + tips + "--取消工单URL*****************");
String params2 = JSON.toJSONString(params);
System.err.println("***************" + tips + "--取消工单上传参数*****************");
System.err.println(params2);
System.err.println("***************" + tips + "--取消工单上传参数*****************");
Map<String, String> resultMap = null;
if (GpsEnum.ZR.getCode().equals(source)) {
resultMap = HttpClientSUtil.doPostJson(url, params2, header);
}else{
resultMap = HttpClientSUtil.doPatchJson(url, params2);
}
String data = resultMap.get("data");
System.err.println("***************" + tips + "--取消工单返回参数*****************");
System.err.println(data);
System.err.println("***************" + tips + "--取消工单返回参数*****************");
public String getProjectId() {
return projectId;
}
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", tips + "--取消工单");
logMap.put("CALL_STATUS", resultMap.get("status"));
GpsCommon.callRecord(logMap, Sqlca);
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);
}
JSONObject job = JSONObject.fromObject(data);
String result = null;
boolean orderStatus = false;//订单是否成功状态
if (GpsEnum.ZR.getCode().equals(source)) {
orderStatus = job.getBoolean("Success");
result = orderStatus ? "0" : "9";
} else {
result = job.getString("result");
orderStatus = !StringX.isSpace(result) && "0".equals(result) ? true : false;
}
if (orderStatus) {
boolean succ = job.containsKey("success") ? job.getBoolean("success") : false;
//中瑞或天易[succ=true]
if (succ || GpsEnum.ZR.getCode().equals(source)) {
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 {
String errorMsg = "取消失败,";
if (GpsEnum.ZR.getCode().equals(source)) {
errorMsg += job.getString("AllMessages");
} else {
errorMsg += job.getString("message");
}
Sqlca.executeSQL("update LM_GPS_ORDER_TEMP set RESULT='" + result + "',MESSAGE='" + errorMsg + "' where APPLY_NO='" + applyNo + "'");
return errorMsg;
}
}
/**
* 根据车架号查询工单
*
* @throws Exception
*/
public boolean queryOrderToVin(Transaction Sqlca) throws Exception {
String url, tips = null;
Map<String, String> params = null;
if(StringX.isSpace(source)) source = Sqlca.getString("select source from LM_GPS_ORDER_TEMP where FLOWUNID ='"+flowUnid+"'");
if (GpsEnum.ZR.getCode().equals(source)) {
params = ImmutableMap.of("VIN", vin);
url = GPSConfigure.get("ZR_query_url");
tips = GpsEnum.ZR.getName();
} else {
params = GpsCommon.tyEditQueryToVinParameter(vin);
url = GPSConfigure.get("TYQueryOrderToVin");
tips = GpsEnum.TY.getName();
}
System.err.println("***************" + tips + "--根据车架号查询工单URL*****************");
System.err.println(url);
System.err.println("***************" + tips + "--根据车架号查询工单URL*****************");
System.err.println("***************" + tips + "--根据车架号查询工单上传参数*****************");
System.err.println(params);
System.err.println("***************" + tips + "--根据车架号查询工单上传参数*****************");
Map<String, String> resultMap = HttpClientSUtil.doGet(url, params, GpsEnum.ZR.getCode().equals(source) ? GPSConfigure.get("ZR_AppKey") : null);
String data = resultMap.get("data");
System.err.println("***************" + tips + "--根据车架号查询工单返回参数*****************");
System.err.println(data);
System.err.println("***************" + tips + "--根据车架号查询工单返回参数*****************");
//日志参数
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", tips + "--根据车架号查询工单");
logMap.put("CALL_STATUS", resultMap.get("status"));
GpsCommon.callRecord(logMap, Sqlca);
if (GpsEnum.ZR.getCode().equals(source)) {
return GpsCommon.zrQueryToVinDataPersistence(data, vin, 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("***************天易--修改工单上传参数*****************");
/**
* 根据申请编号查询工单
*
* @throws Exception
*/
public String queryOrder(JBOTransaction tx) throws Exception {
Transaction Sqlca = Transaction.createTransaction(tx);
if(GpsEnum.ZR.getCode().equals(source)){
String result2 = queryOrderToVin(Sqlca) == true ? "查询成功!" : "查询失败!";
return "车架号查询定位信息:" + result2;
}
String url = GPSConfigure.get("TYUrl") + "/" + orderNo + "," + applyNo;
System.err.println("***************天易--根据申请编号查询工单URL*****************");
System.err.println(url);
System.err.println("***************天易--根据申请编号查询工单URL*****************");
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> params = GpsCommon.tyEditQueryParameter(applyNo);
System.err.println("***************天易--根据申请编号查询工单上传参数*****************");
System.err.println(params);
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);
Map<String, String> resultMap = HttpClientSUtil.doGet(url, params, null);
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");
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");
}
}
//日志参数
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 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();
if (strb == null)
return "null";
return strb.toString();
}
/**
* 天易--获取图片
* @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();
}
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;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
}

View File

@ -1,16 +1,10 @@
package com.tenwa.gps;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPatch;
import org.apache.http.client.methods.HttpPost;
@ -20,6 +14,11 @@ import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class HttpClientSUtil {
private static HttpClient httpClient = HttpClientBuilder.create().build();;
@ -81,6 +80,29 @@ public class HttpClientSUtil {
return resultMap;
}
//Post请求参数为json,加header
public static Map<String, String> doPostJson(String url, String json,Map<String,String> header) throws Exception{
HttpPost post = new HttpPost(url);
if(header!=null) {
for (Map.Entry<String, String> entry: header.entrySet()) {
post.setHeader(entry.getKey(),entry.getValue());
}
}
//设置参数以及编码
StringEntity entity = new StringEntity(json,"UTF-8");
//设置请求头服务器接收参数的格式以及编码格式
entity.setContentType("application/json;charset=UTF-8");
//发起httpPost请求
post.setEntity(entity);
HttpResponse response = httpClient.execute(post);
//返回结果解析
HttpEntity httpEntity =response.getEntity();
Map<String,String> resultMap = new HashMap<String, String>();
resultMap.put("data",EntityUtils.toString(response.getEntity(),"UTF-8"));
resultMap.put("status",String.valueOf(response.getStatusLine().getStatusCode()));
return resultMap;
}
//PostÇëÇ󣬲ÎÊýΪxml
public static Map<String, String> doPostXml(String url, String xml) throws Exception{