diff --git a/WebContent/Tenwa/Gps/LmGpsLocationList.jsp b/WebContent/Tenwa/Gps/LmGpsLocationList.jsp index a391507ae..9d3682946 100644 --- a/WebContent/Tenwa/Gps/LmGpsLocationList.jsp +++ b/WebContent/Tenwa/Gps/LmGpsLocationList.jsp @@ -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"; //只读模式 diff --git a/WebContent/Tenwa/Gps/LmGpsOrderInfo.jsp b/WebContent/Tenwa/Gps/LmGpsOrderInfo.jsp index 23a714889..7b3bc16b0 100644 --- a/WebContent/Tenwa/Gps/LmGpsOrderInfo.jsp +++ b/WebContent/Tenwa/Gps/LmGpsOrderInfo.jsp @@ -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 images = new ArrayList(); 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", "", CurPage.getObjectWindowOutput()); + dwTemp.replaceColumn("LOCATION", "", 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(); } diff --git a/WebContent/WEB-INF/etc/jbo/jbo_sys.xml b/WebContent/WEB-INF/etc/jbo/jbo_sys.xml index 6d21ca6ae..98812897d 100644 --- a/WebContent/WEB-INF/etc/jbo/jbo_sys.xml +++ b/WebContent/WEB-INF/etc/jbo/jbo_sys.xml @@ -2145,235 +2145,198 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + - - + - + @@ -2392,12 +2355,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2405,53 +2415,53 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3104,128 +3114,128 @@ - - + + - - - - + + + + - - - + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/gps.properties b/config/gps.properties index e9244cc30..9884cb81e 100644 --- a/config/gps.properties +++ b/config/gps.properties @@ -3,4 +3,14 @@ TYtoken=9999 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 \ No newline at end of file +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 \ No newline at end of file diff --git a/src_app_fresh/apx/com/amarsoft/als/apzl/flow/data/service/Impl/FlowDataServiceImpl.java b/src_app_fresh/apx/com/amarsoft/als/apzl/flow/data/service/Impl/FlowDataServiceImpl.java index 9ae753de2..6fe0d121d 100644 --- a/src_app_fresh/apx/com/amarsoft/als/apzl/flow/data/service/Impl/FlowDataServiceImpl.java +++ b/src_app_fresh/apx/com/amarsoft/als/apzl/flow/data/service/Impl/FlowDataServiceImpl.java @@ -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; @@ -52,7 +53,7 @@ import apx.com.amarsoft.als.apzl.flow.data.service.FlowDataService; public class FlowDataServiceImpl implements FlowDataService{ private Map fieldMap; - + @Override public Map getFlowBankCard(HttpServletRequest request, HttpServletResponse response, JBOTransaction tx, Transaction sqlca, @@ -104,7 +105,7 @@ public class FlowDataServiceImpl implements FlowDataService{ public Map saveFlowBankCard(HttpServletRequest request, HttpServletResponse response, JBOTransaction tx, Transaction sqlca, ReturnMapUtil ReturnMapUtil) throws Exception { - + Map testMap = (Map) MultipartDataUtil.readRequestParam(request, "UTF-8"); BizObjectManager catManage = JBOFactory.getBizObjectManager(CUSTOMER_ACCOUNT_TEMP.CLASS_NAME,sqlca); System.out.println("============业务申请扣款卡信息保存参数====================="); @@ -148,7 +149,7 @@ public class FlowDataServiceImpl implements FlowDataService{ cat.setAttributeValue("updateuserid", userid); cat.setAttributeValue("updateorgid", CurUser.getOrgID()); cat.setAttributeValue("updatetime", DateUtil.getSystemTimeByFormat("yyyy/MM/dd HH:mm:ss")); - + } String acc_number = fieldMap.get("acc_number") == null ? "" : fieldMap.get("acc_number").toString(); String bank_name = fieldMap.get("bank_name") == null ? "" : fieldMap.get("bank_name").toString(); @@ -177,7 +178,7 @@ public class FlowDataServiceImpl implements FlowDataService{ } //项目扣款卡中间表插入数据 public String savaCustomerAccountTomiddle(String projectid,String acc_number,String bank_name,String account,String mobile,String flowUnid,String contractid,Transaction Sqlca) { - + String selectSql="";// 查询SQL String updateSql="";// 变更SQL String insertSql="";// 新增SQL @@ -185,16 +186,16 @@ public class FlowDataServiceImpl implements FlowDataService{ String sign_status = "N"; String trueOrfalse="true"; String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); - try { + try { // 查询页面上的数据是否与正式表匹配 selectSql="SELECT PROJECT_ID FROM CUSTOMER_ACCOUNT WHERE PROJECT_ID='"+projectid+"' AND ACC_NUMBER='"+acc_number+"' AND BANK_NAME='"+bank_name+"' AND ACCOUNT='"+account+"' AND MOBILE='"+mobile+"' and SIGN_STATUS='Y'"; List> dataList = DataOperatorUtil.getDataBySql(Sqlca, selectSql, null); - + // 如果不匹配, 说明是变更的, 判断数据在中间表是否已存在; if(dataList ==null || dataList.size()==0){ selectSql="SELECT PROJECT_ID FROM CUSTOMER_ACCOUNT_MIDDLE WHERE PROJECT_ID='"+projectid+"'"; List> dataList2=DataOperatorUtil.getDataBySql(Sqlca, selectSql, null); - + //检查历史表 String selectHis = "SELECT SIGN_STATUS FROM CUSTOMER_ACCOUNT_HIS WHERE PROJECT_ID='"+projectid+"' AND ACC_NUMBER='"+acc_number+"' AND BANK_NAME='"+bank_name+"' AND ACCOUNT='"+account+"' AND MOBILE='"+mobile+"'"; List> HisList=DataOperatorUtil.getDataBySql(Sqlca, selectHis, null); @@ -219,12 +220,12 @@ public class FlowDataServiceImpl implements FlowDataService{ Sqlca.executeSQL(deleteSql); } } catch (Exception e) { - + e.printStackTrace(); } return trueOrfalse; - } - + } + @Override public Map getContractMakeBankCard( HttpServletRequest request, HttpServletResponse response, @@ -267,7 +268,7 @@ public class FlowDataServiceImpl implements FlowDataService{ data.put("project_id", projectid); data.put("mobile", ""); data.put("certid", ""); - + body.put("statusCode", "01"); } data.put("contract_id", ContractId); @@ -290,7 +291,7 @@ public class FlowDataServiceImpl implements FlowDataService{ System.out.println("===================="); fieldMap = (Map) testMap.get("fieldMap"); // 参数 List> fileList = (List>) testMap.get("fileList"); - + Map body = new HashMap(); String projectId = fieldMap.get("project_id") == null ? "" : fieldMap.get("project_id").toString(); String ContractId = fieldMap.get("contract_id") == null ? "" : fieldMap.get("contract_id").toString(); @@ -310,7 +311,7 @@ public class FlowDataServiceImpl implements FlowDataService{ if(fileList!=null&&fileList.size()>0){ this.savaBankCardFile(flowParms.get("ProjectId"), flowParms.get("ApplyType"), fileList, CurUser, tx); } - + BizObjectManager ldclManager = JBOFactory.getBizObjectManager(LB_DOC_CONTRACT_LIST.CLASS_NAME); List ldcls = ldclManager.createQuery("select * from O where file_flag='yes' and ( flow_unid=:flowunid or contract_id=:contractid ) ").setParameter("flowunid", FlowUnid).setParameter("contractid", ContractId).getResultList(false); body.put("FlowUnid", FlowUnid); @@ -330,7 +331,7 @@ public class FlowDataServiceImpl implements FlowDataService{ .setParameter("account", ca.getAttribute("account").toString()).setParameter("acc_number", ca.getAttribute("acc_number").toString()).setParameter("bank_name", ca.getAttribute("bank_name").toString()).setParameter("mobile", ca.getAttribute("mobile").toString()).getSingleResult(false); if(cah == null ){ Map signFromCondtion=new HashMap(); - signFromCondtion.put("PROJECT_ID",projectId); + signFromCondtion.put("PROJECT_ID",projectId); DataOperatorUtil.copyJBOSet(CUSTOMER_ACCOUNT.CLASS_NAME, signFromCondtion,CUSTOMER_ACCOUNT_HIS.CLASS_NAME, null, null,null, tx); } } @@ -351,7 +352,7 @@ public class FlowDataServiceImpl implements FlowDataService{ RestfullConstant.baseProperty.get("success").toString(), ""); return ReturnMapUtil.getReturnMap(); } - + public String getSigStatus(String account,String acc_number,String bank_name,String mobile) throws Exception{ BizObjectManager cahManage = JBOFactory.getFactory().getManager(CUSTOMER_ACCOUNT_HIS.CLASS_NAME); BizObject cah = cahManage.createQuery(" account=:account and acc_number=:acc_number and bank_name=:bank_name and mobile=:mobile and sign_status='Y'") @@ -385,7 +386,7 @@ public class FlowDataServiceImpl implements FlowDataService{ public Map getGpsInfo(HttpServletRequest request, HttpServletResponse response, JBOTransaction tx, Transaction sqlca, ReturnMapUtil ReturnMapUtil) throws Exception { - + Map testMap = (Map) MultipartDataUtil .readRequestParam(request, "UTF-8"); fieldMap = (Map) testMap.get("fieldMap"); // 参数 @@ -401,13 +402,12 @@ public class FlowDataServiceImpl implements FlowDataService{ BizObjectManager lectManage = JBOFactory.getFactory().getManager(LB_EQUIPMENT_CAR_TEMP.CLASS_NAME); 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); @@ -454,7 +471,7 @@ public class FlowDataServiceImpl implements FlowDataService{ public Map submitOrder(HttpServletRequest request, HttpServletResponse response, JBOTransaction tx, Transaction sqlca, ReturnMapUtil ReturnMapUtil) throws Exception { - + Map testMap = (Map) MultipartDataUtil .readRequestParam(request, "UTF-8"); fieldMap = (Map) testMap.get("fieldMap"); // 参数 @@ -469,7 +486,7 @@ public class FlowDataServiceImpl implements FlowDataService{ BizObjectManager lgtManage = JBOFactory.getFactory().getManager(LM_GPS_ORDER_TEMP.CLASS_NAME,tx); BizObject lgt = lgtManage.createQuery(" flowunid=:flowunid ").setParameter("flowunid", flowunid).getSingleResult(true); - + if(lgt != null){ String gpsStatus = lgt.getAttribute("STATUS")==null?"":lgt.getAttribute("STATUS").getString(); if(gpsStatus.length() == 0 || "7".equals(gpsStatus)){ @@ -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(); @@ -608,7 +635,7 @@ public class FlowDataServiceImpl implements FlowDataService{ params.append("@"+wireless_num); params.append("@"+gpslgot.getAttribute("WIRELESS_PERIOD")); params.append("@"+gpslgot.getAttribute("CAR_ACCOUNT")); - + gpsC.setApplyNo(gpslgot.getAttribute("APPLY_NO").getString()); gpsC.setProjectId(gpslgot.getAttribute("PROJECT_ID").getString()); gpsC.setUserId(userid); @@ -631,7 +658,7 @@ public class FlowDataServiceImpl implements FlowDataService{ body.put("statusCode", "01"); body.put("msg", alterOrder); } - + }else{ body.put("statusCode", "01"); body.put("msg", checkGPSStatus); @@ -656,12 +683,13 @@ public class FlowDataServiceImpl implements FlowDataService{ if("true".equals(checkGPSStatus)){ BizObject gpslgot = this.gpsBizObject(flowunid); GpsController gpsC = new GpsController(); - + gpsC.setApplyNo(gpslgot.getAttribute("APPLY_NO").getString()); 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"); body.put("msg", cancelOrder); @@ -684,16 +712,16 @@ public class FlowDataServiceImpl implements FlowDataService{ fieldMap = (Map) testMap.get("fieldMap"); // 参数 Map body = new HashMap(); String flowunid = fieldMap.get("flowunid") == null ? "" : fieldMap.get("flowunid").toString(); - + ReturnMapUtil.setReturnMap(body, RestfullConstant.baseProperty.get("success").toString(), ""); return ReturnMapUtil.getReturnMap(); } - + public BizObject gpsBizObject(String flowunid) throws Exception{ BizObjectManager lgtManage = JBOFactory.getFactory().getManager(LM_GPS_ORDER_TEMP.CLASS_NAME); return lgtManage.createQuery(" flowunid=:flowunid ").setParameter("flowunid", flowunid).getSingleResult(true); - + } public String checkGPSStatus(String flowUnid) throws Exception{ String message = "true"; @@ -705,12 +733,12 @@ public class FlowDataServiceImpl implements FlowDataService{ if("7".equals(gpsStatus)){ message = "请先提交工单!"; }else{ - + } } return message; } - + @Override public Map isGPS(HttpServletRequest request, HttpServletResponse response, JBOTransaction tx, Transaction sqlca, @@ -734,16 +762,16 @@ public class FlowDataServiceImpl implements FlowDataService{ ReturnMapUtil.setReturnMap(null, RestfullConstant.baseProperty.get("fail").toString(), "没有查询到对应的流程实例!"); } - + return ReturnMapUtil.getReturnMap(); } - + public void savaBankCardFile(String projectId,String applyFlow,List> fileList,ASUser user,JBOTransaction tx) throws Exception{ BizObjectManager relaManage = JBOFactory.getBizObjectManager(LB_DOCRELATIVE.CLASS_NAME); BizObject rela = null; if("BusinessApplyApply".equals(applyFlow)||"BusinessChangeApply".equals(applyFlow)||"BusinessCancelApply".equals(applyFlow)||"BContractApproveApply".equals(applyFlow)||"BContractCancelApply".equals(applyFlow)||"BContractChangeApply".equals(applyFlow)){ rela = relaManage.createQuery(" objecttype='BusinessApplyFlow' AND proj_id=:projectId ").setParameter("projectId", projectId).getSingleResult(false); - + }else{ rela = relaManage.createQuery(" objecttype=:objecttype AND proj_id=:projectId ").setParameter("objecttype", applyFlow).setParameter("projectId", projectId).getSingleResult(false); } @@ -774,14 +802,14 @@ public class FlowDataServiceImpl implements FlowDataService{ attr.setAttributeValue("InputOrgId", user.getOrgID()); attr.setAttributeValue("InputTime",StringFunction.getTodayNow()); attr.setAttributeValue("objectType", applyFlow); - + //得到不带路径的文件名 String sFileName = StringFunction.getFileName(file.get("fileName").toString()); - sFileName = URLDecoder.decode(URLDecoder.decode(sFileName,"UTF-8"),"UTF-8"); - + sFileName = URLDecoder.decode(URLDecoder.decode(sFileName,"UTF-8"),"UTF-8"); + //定义数据库操作变量 String sFileSavePath = CurConfig.getConfigure("FileSavePath"); - + String uuid=java.util.UUID.randomUUID().toString().replaceAll("-", ""); String sFullPath =com.tenwa.officetempalte.util.FileOperatorUtil.getuploadFileDir(sFileSavePath) +uuid+"_"+sFileName; InputStream is = (InputStream) file.get("file"); @@ -794,10 +822,10 @@ public class FlowDataServiceImpl implements FlowDataService{ int i = is.read(b, 0, Integer.valueOf(sFileSize) - 1); fileout.write(b, 0, b.length); // 将文件数据存盘 fileout.close(); - + //得到带相对路径的文件名 String sFilePath = sFullPath.replace(sFileSavePath, ""); - attr.setAttributeValue("FilePath",sFilePath); + attr.setAttributeValue("FilePath",sFilePath); attr.setAttributeValue("FullPath",sFullPath); attr.setAttributeValue("Content_Type", isImage(f,file.get("fileContentType"))); attr.setAttributeValue("FileSize", file.get("fileSize")); @@ -808,7 +836,7 @@ public class FlowDataServiceImpl implements FlowDataService{ String time = StringFunction.getTodayNow(); DocLibraryStateUpdate.update(libraryId, "1", user, time, tx); } - + public Object isImage(File file,Object object) throws Exception{ String reg = "(mp4|flv|avi|rm|rmvb|wmv)"; Pattern p = Pattern.compile(reg); diff --git a/src_jbo/jbo/sys/LM_GPS_ORDER.java b/src_jbo/jbo/sys/LM_GPS_ORDER.java index bd0356261..268f54142 100644 --- a/src_jbo/jbo/sys/LM_GPS_ORDER.java +++ b/src_jbo/jbo/sys/LM_GPS_ORDER.java @@ -22,7 +22,7 @@ public interface LM_GPS_ORDER{ */ public static final String APPLY_NO = "APPLY_NO"; /** - * 工单编号 STRING(32)
+ * 工单编号 STRING(40)
*/ 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)
+ */ + public static final String CARTYPE = "CARTYPE"; + /** + * 车主名称 STRING(32)
+ */ + public static final String USERNAME = "USERNAME"; + /** + * 车主电话 STRING(11)
+ */ + public static final String USERPHONE = "USERPHONE"; + /** + * 安装店面 STRING(100)
+ */ + public static final String SHOPNAME = "SHOPNAME"; + /** + * GPS来源 STRING(10)
+ */ + public static final String SOURCE = "SOURCE"; + /** * 录入时间 STRING(32)
*/ public static final String INPUTTIME = "INPUTTIME"; diff --git a/src_jbo/jbo/sys/LM_GPS_ORDER_TEMP.java b/src_jbo/jbo/sys/LM_GPS_ORDER_TEMP.java index 8c88d4a54..28cbb8013 100644 --- a/src_jbo/jbo/sys/LM_GPS_ORDER_TEMP.java +++ b/src_jbo/jbo/sys/LM_GPS_ORDER_TEMP.java @@ -22,7 +22,7 @@ public interface LM_GPS_ORDER_TEMP{ */ public static final String APPLY_NO = "APPLY_NO"; /** - * 工单编号 STRING(32)
+ * 工单编号 STRING(40)
*/ 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)
+ */ + public static final String CARTYPE = "CARTYPE"; + /** + * 车主名称 STRING(32)
+ */ + public static final String USERNAME = "USERNAME"; + /** + * 车主电话 STRING(11)
+ */ + public static final String USERPHONE = "USERPHONE"; + /** + * 安装店面 STRING(100)
+ */ + public static final String SHOPNAME = "SHOPNAME"; + /** + * GPS来源 STRING(10)
+ */ + public static final String SOURCE = "SOURCE"; + /** * 录入时间 STRING(32)
*/ public static final String INPUTTIME = "INPUTTIME"; diff --git a/src_tenwa/com/tenwa/apzl/comm/GpsEnum.java b/src_tenwa/com/tenwa/apzl/comm/GpsEnum.java new file mode 100644 index 000000000..29b7d2a04 --- /dev/null +++ b/src_tenwa/com/tenwa/apzl/comm/GpsEnum.java @@ -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; + } +} diff --git a/src_tenwa/com/tenwa/gps/GpsCommon.java b/src_tenwa/com/tenwa/gps/GpsCommon.java index 64ca350da..bd8fd834d 100644 --- a/src_tenwa/com/tenwa/gps/GpsCommon.java +++ b/src_tenwa/com/tenwa/gps/GpsCommon.java @@ -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(); - } - - /** - * 天易--编辑修改工单请求参数 - * @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 tyEditQueryParameter(String applyNo){ - Map params = new HashMap(); - params.put("userAccount",TYuserAccount); - params.put("token",TYtoken); - params.put("sign",TYsign); - params.put("applyNo",applyNo); - return params; - } - - /** - * - * 天易--编辑车架号查询工单请求参数 - * @param applyNo - * @return - */ - public static Map tyEditQueryToVinParameter(String vin){ - Map params = new HashMap(); - 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;i0) continue; - JSONArray photoMsgs = terminal.getJSONArray("photoMsg"); - for(int j=0;j 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")+"')"); - } + + 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(); + 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 tyEditQueryParameter(String applyNo) { + Map params = new HashMap(); + params.put("userAccount", TYuserAccount); + params.put("token", TYtoken); + params.put("sign", TYsign); + params.put("applyNo", applyNo); + return params; + } + + /** + * 天易--编辑车架号查询工单请求参数 + * + * @param applyNo + * @return + */ + public static Map tyEditQueryToVinParameter(String vin) { + Map params = new HashMap(); + 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 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 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 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") + "')"); + } } diff --git a/src_tenwa/com/tenwa/gps/GpsController.java b/src_tenwa/com/tenwa/gps/GpsController.java index 642810e0b..571953ff1 100644 --- a/src_tenwa/com/tenwa/gps/GpsController.java +++ b/src_tenwa/com/tenwa/gps/GpsController.java @@ -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; - - public String getParams() { - return 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 void setParams(String params) { - this.params = params; - } + /** + * 新增工单 + * + * @throws Exception + */ + public String createOrder(JBOTransaction tx) throws Exception { + Transaction Sqlca = Transaction.createTransaction(tx); + String url, params, tips = null; + Map 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 resultMap = HttpClientSUtil.doPostJson(url, params, header); + String data = resultMap.get("data"); + System.err.println("***************" + tips + "--新增返回上传参数*****************"); + System.err.println(data); + System.err.println("***************" + tips + "--新增返回上传参数*****************"); + //日志参数 + Map logMap = new HashMap(); + 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 String getProjectId() { - return projectId; - } + /** + * 取消工单 + * + * @throws Exception + */ + public String cancelOrder(JBOTransaction tx) throws Exception { + Transaction Sqlca = Transaction.createTransaction(tx); + String url, tips = null; + Map params = null; + Map 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 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 void setProjectId(String projectId) { - this.projectId = projectId; - } - - public String getUserId() { - return userId; - } + Map logMap = new HashMap(); + 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 setUserId(String userId) { - this.userId = userId; - } + 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; + } + } - public String getVin() { - return vin; - } - public void setVin(String vin) { - this.vin = vin; - } + /** + * 根据车架号查询工单 + * + * @throws Exception + */ + public boolean queryOrderToVin(Transaction Sqlca) throws Exception { + String url, tips = null; + Map 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 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 logMap = new HashMap(); + 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); + } - public String getTableName() { - return tableName; - } + /** + * 根据申请编号查询工单 + * + * @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*****************"); - public void setTableName(String tableName) { - this.tableName = tableName; - } + Map params = GpsCommon.tyEditQueryParameter(applyNo); + System.err.println("***************天易--根据申请编号查询工单上传参数*****************"); + System.err.println(params); + System.err.println("***************天易--根据申请编号查询工单上传参数*****************"); - public String getApplyNo() { - return applyNo; - } + Map resultMap = HttpClientSUtil.doGet(url, params, null); + String data = resultMap.get("data"); + System.err.println("***************天易--根据申请编号查询工单返回参数*****************"); + System.err.println(data); + System.err.println("***************天易--根据申请编号查询工单返回参数*****************"); - public void setApplyNo(String applyNo) { - this.applyNo = applyNo; - } + //日志参数 + Map logMap = new HashMap(); + 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); - public String getOrderNo() { - return orderNo; - } + String result1 = GpsCommon.tyQueryDataPersistence(data, applyNo, tableName, Sqlca); + String result2 = queryOrderToVin(Sqlca) == true ? "查询成功!" : "查询失败!"; - public void setOrderNo(String orderNo) { - this.orderNo = orderNo; - } - - public String getFlowUnid() { - return flowUnid; - } + return "申请编号查询定位信息:" + result1 + ",车架号查询定位信息:" + result2; + } - public void setFlowUnid(String flowUnid) { - this.flowUnid = flowUnid; - } + /** + * 天易--修改工单 + * + * @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 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 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 logMap = new HashMap(); - 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 params = GpsCommon.tyEditQueryParameter(applyNo); - System.err.println("***************天易--根据申请编号查询工单上传参数*****************"); - System.err.println(params); - System.err.println("***************天易--根据申请编号查询工单上传参数*****************"); - - Map resultMap = HttpClientSUtil.doGet(url, params, null); - String data = resultMap.get("data"); - System.err.println("***************天易--根据申请编号查询工单返回参数*****************"); - System.err.println(data); - System.err.println("***************天易--根据申请编号查询工单返回参数*****************"); - - //日志参数 - Map logMap = new HashMap(); - 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 params = GpsCommon.tyEditQueryToVinParameter(vin); - System.err.println("***************天易--根据车架号查询工单上传参数*****************"); - System.err.println(params); - System.err.println("***************天易--根据车架号查询工单上传参数*****************"); - - Map resultMap = HttpClientSUtil.doGet(url, params, null); - String data = resultMap.get("data"); - System.err.println("***************天易--根据车架号查询工单返回参数*****************"); - System.err.println(data); - System.err.println("***************天易--根据车架号查询工单返回参数*****************"); - - //日志参数 - Map logMap = new HashMap(); - 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 resultMap = HttpClientSUtil.doPutJson(url, params); - String data = resultMap.get("data"); - System.err.println("***************天易--修改工单返回参数*****************"); - System.err.println(data); - System.err.println("***************天易--修改工单返回参数*****************"); - - Map logMap = new HashMap(); - 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 params = GpsCommon.tyEditQueryParameter(applyNo); - String params2 = JSON.toJSONString(params); - System.err.println("***************天易--取消工单上传参数*****************"); - System.err.println(params2); - System.err.println("***************天易--取消工单上传参数*****************"); - - Map resultMap = HttpClientSUtil.doPatchJson(url, params2); - String data = resultMap.get("data"); - System.err.println("***************天易--查询工单返回参数*****************"); - System.err.println(data); - System.err.println("***************天易--查询工单返回参数*****************"); + Map resultMap = HttpClientSUtil.doPutJson(url, params); + String data = resultMap.get("data"); + System.err.println("***************天易--修改工单返回参数*****************"); + System.err.println(data); + System.err.println("***************天易--修改工单返回参数*****************"); - Map logMap = new HashMap(); - 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(); - } + Map logMap = new HashMap(); + 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(); + } + + + 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; + } } diff --git a/src_tenwa/com/tenwa/gps/HttpClientSUtil.java b/src_tenwa/com/tenwa/gps/HttpClientSUtil.java index 9200fab41..2f021a2ff 100644 --- a/src_tenwa/com/tenwa/gps/HttpClientSUtil.java +++ b/src_tenwa/com/tenwa/gps/HttpClientSUtil.java @@ -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();; @@ -80,7 +79,30 @@ public class HttpClientSUtil { resultMap.put("status",String.valueOf(response.getStatusLine().getStatusCode())); return resultMap; } - + + //Post请求,参数为json,加header + public static Map doPostJson(String url, String json,Map header) throws Exception{ + HttpPost post = new HttpPost(url); + if(header!=null) { + for (Map.Entry 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 resultMap = new HashMap(); + resultMap.put("data",EntityUtils.toString(response.getEntity(),"UTF-8")); + resultMap.put("status",String.valueOf(response.getStatusLine().getStatusCode())); + return resultMap; + } + //Post请求,参数为xml public static Map doPostXml(String url, String xml) throws Exception{