localhost:8080/hbinterface/orderInterface/sIReverseAccept.do?bizType=4&&bnetAccount=ESBTEST20150522OP&&bnetId=GD101140264&&customerType={accNbr:"13316268440","bnetId":"D101140264","bnetAccount":"ESBTEST20150522OP","contactTelephone":"13316268440","contactPersonName":"13316268440","identitySerialNumber":"13316268440",identityType:1,"nodeId":"100000",
servNbr:"GZ200000008536710189","offeringType":{"offeringSpecId":"GD9900405","servNbr":"GZ200000008536710189","productType":[{"productSpecId":"GD9900404","productAttributeList":[{"attributeId":"1","attributeValue":"1","productSpecId":"GD9900405"},{"attributeId":"1","attributeValue":"1","productSpecId":"GD9900108"}]},{"productSpecId":"GD9900406","productAttributeList":[{"attributeId":"1","attributeValue":"1","productSpecId":"GD9900415"}]}]}}

  

后台解析:

package com.eshore.ismp.hbinterface.webapi.controller.b;

import java.util.ArrayList;
import java.util.List; import javax.servlet.http.HttpServletRequest; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.eshore.ismp.common.entity.ResultInfo;
import com.eshore.ismp.common.hb.esb.b.CustomerType;
import com.eshore.ismp.common.hb.esb.b.OfferingType;
import com.eshore.ismp.common.hb.esb.b.OnlineAcceptType;
import com.eshore.ismp.common.hb.esb.b.ProductAttributeType;
import com.eshore.ismp.common.hb.esb.b.ProductType;
import com.eshore.ismp.common.util.ConstVal;
import com.eshore.ismp.hbinterface.entity.webapi.ReverseOrderEntity;
import com.eshore.ismp.hbinterface.esb.b.BizAcceptService;
import com.eshore.ismp.hbinterface.respository.webapi.ReverseOrderRepository; /**
* @author mercy
*反向订购接口
*/
@RestController
@RequestMapping("/orderInterface")
public class ReverseAcceptHttpProcess {
private static final Log log = LogFactory.getLog(ReverseAcceptHttpProcess.class);
@Autowired
private BizAcceptService service;
@Autowired
private ReverseOrderRepository dao; /**
* @return
* 集团反向订购
* 只做校验
*/
@RequestMapping("/groupReverseAccept")
public String groupReverseAccept(HttpServletRequest request){
ResultInfo resultInfo = new ResultInfo(ConstVal.RESULT_CODE_SUCCESS, ConstVal.RESULT_DETAIL_SUCCESS, "");
OnlineAcceptType oaType=new OnlineAcceptType();
CustomerType cType=new CustomerType();
OfferingType oType=new OfferingType();
List<ProductType> pTypeList=new ArrayList<ProductType>();
List<ProductAttributeType> lpTypeList=new ArrayList<ProductAttributeType>();
long bizType=Long.parseLong(request.getParameter("bizType"));
String bnetId=request.getParameter("bnetId");
String bnetAccount=request.getParameter("bnetAccount");
log.info("bizType:"+bizType+",bnetId:"+bnetId+",bnetAccount"+bnetAccount+"\n");
oaType.setBizType(bizType);
oaType.setBnetId(bnetId);
//oaType.setBnetAccount(bnetAccount);
String customerType=request.getParameter("customerType");
ReverseOrderEntity entity=new ReverseOrderEntity();
String msg="bizType="+bizType+"&&bnetId="+bnetId+"&&bnetAccount="+bnetAccount+"&&customerType="+customerType;
entity.setMsg(msg);
entity.setType(1);
dao.save(entity);
if(isEmpty(customerType)){
resultInfo.setResult_code(-1);
resultInfo.setResult_detail("参数customerType不能为空");
return JSONObject.toJSONString(resultInfo);
}
JSONObject cuType=(JSONObject) JSONObject.parse(customerType);
String accNbr=cuType.getString("accNbr");
String cbnetId=cuType.getString("bnetId");
String cbnetAccount=cuType.getString("bnetAccount");
String contactTelephone=cuType.getString("contactTelephone");
String contactPersonName=cuType.getString("contactPersonName");
//经办人证件号码
String identitySerialNumber=cuType.getString("identitySerialNumber");
//经办人证件类型
long identityType=cuType.getLongValue("identityType");
String identityAddress=cuType.getString("identityAddress");
String nodeId=cuType.getString("nodeId");
String servNbr=cuType.getString("servNbr");
if(isEmpty(cbnetId)){
resultInfo.setResult_code(-1);
resultInfo.setResult_detail("参数bnetId不能为空");
return JSONObject.toJSONString(resultInfo);
}
if(isEmpty(cbnetAccount)){
resultInfo.setResult_code(-1);
resultInfo.setResult_detail("参数bnetAccount不能为空");
return JSONObject.toJSONString(resultInfo);
}
if(isEmpty(nodeId)){
resultInfo.setResult_code(-1);
resultInfo.setResult_detail("参数nodeId不能为空");
return JSONObject.toJSONString(resultInfo);
}
if(isEmpty(servNbr)){
resultInfo.setResult_code(-1);
resultInfo.setResult_detail("参数servNbr不能为空");
return JSONObject.toJSONString(resultInfo);
}
if(isEmpty(identityType)){
resultInfo.setResult_code(-1);
resultInfo.setResult_detail("参数identityType不能为空");
return JSONObject.toJSONString(resultInfo);
}
if(isEmpty(identitySerialNumber)){
resultInfo.setResult_code(-1);
resultInfo.setResult_detail("参数identitySerialNumber不能为空");
return JSONObject.toJSONString(resultInfo);
}
if(isEmpty(identityAddress)){
resultInfo.setResult_code(-1);
resultInfo.setResult_detail("参数identityAddress不能为空");
return JSONObject.toJSONString(resultInfo);
}
//long state=cuType.getLongValue("state");
log.info("accNbr:"+accNbr+",bnetAccount:"+cbnetAccount+",bnetId"+cbnetId+",contactTelephone:"+contactTelephone
+",contactPersonName:"+contactPersonName+",identitySerialNumber:"+identitySerialNumber+",identityType:"+identityType
+",identityAddress:"+identityAddress+",nodeId:"+nodeId+",servNbr:"+servNbr+"\n");
cType.setAccNbr(accNbr);
//cType.setBnetId(cbnetId);
cType.setBnetAccount(cbnetAccount);
cType.setContactTelephone(contactTelephone);
cType.setCompanyName(contactPersonName);
cType.setIdentitySerialNumber(identitySerialNumber);
cType.setIdentityType(identityType);
cType.setIdentityAddress(identityAddress);
cType.setNodeId(nodeId);
cType.setServNbr(servNbr);
//cType.setState(state);
String offeringType=cuType.getString("offeringType");
log.info("====offeringType:"+offeringType+"\n");
JSONObject ofType=(JSONObject) JSONObject.parse(offeringType);
//String oaccNbr=ofType.getString("accNbr");
//String obnetId=ofType.getString("bnetId");
//String onodeId=ofType.getString("nodeId");
String oofferingSpecId=ofType.getString("offeringSpecId");
String oservNbr=ofType.getString("servNbr");
//oType.setAccNbr(oaccNbr);
//oType.setBnetId(obnetId);
//oType.setNodeId(onodeId);
log.info("offeringSpecId:"+oofferingSpecId+",servNbr:"+oservNbr);
oType.setOfferingSpecId(oofferingSpecId);
oType.setServNbr(oservNbr);
String productTypeList=ofType.getString("productType");
log.info("===productTypeList:"+productTypeList);
List<ProductType> pTypeList1=JSONArray.parseArray(productTypeList,ProductType.class);
for(ProductType pt:pTypeList1){
ProductType pType=new ProductType();
//String pbnetId=pt.getBnetId();
//String pnodeId=pt.getNodeId();
String productSpecId=pt.getProductSpecId();
//pType.setBnetId(pbnetId);
//pType.setNodeId(pnodeId);
pType.setProductSpecId(productSpecId);
log.info("===list productSpecId:"+productSpecId);
List<ProductAttributeType> lpTypeList1=pt.getProductAttributeList();
for(ProductAttributeType ls:lpTypeList1){
ProductAttributeType paType=new ProductAttributeType();
String attributeId=ls.getAttributeId();
String attributeValue=ls.getAttributeValue();
String lproductSpecId=ls.getProductSpecId();
log.info("===AttributeList attributeId:"+attributeId+",attributeValue:"+attributeValue+",productSpecId:"+lproductSpecId);
paType.setAttributeId(attributeId);
paType.setAttributeValue(attributeValue);
paType.setProductSpecId(lproductSpecId);
lpTypeList.add(paType);
}
pType.setProductAttributeList(lpTypeList);
pTypeList.add(pType);
}
oType.setProductList(pTypeList);
oaType.setOfferingType(oType);
oaType.setCustomerType(cType);
log.info("oaTypeToString:"+JSONObject.toJSONString(oaType));
String result=JSONObject.toJSONString(service.newGroupProd(oaType));
return result;
}
/**
* @return
* SI反向订购改号
* 只做校验
*/
@RequestMapping("/sIReverseAccept")
public String sIReverseAccept(HttpServletRequest request){
ResultInfo resultInfo = new ResultInfo(ConstVal.RESULT_CODE_SUCCESS, ConstVal.RESULT_DETAIL_SUCCESS, "");
OnlineAcceptType oaType=new OnlineAcceptType();
CustomerType cType=new CustomerType();
OfferingType oType=new OfferingType();
List<ProductType> pTypeList=new ArrayList<ProductType>();
List<ProductAttributeType> lpTypeList=new ArrayList<ProductAttributeType>();
long bizType=Long.parseLong(request.getParameter("bizType"));
String bnetId=request.getParameter("bnetId");
String bnetAccount=request.getParameter("bnetAccount");
log.info("bizType:"+bizType+",bnetId:"+bnetId+",bnetAccount"+bnetAccount+"\n");
oaType.setBizType(bizType);
oaType.setBnetId(bnetId);
//oaType.setBnetAccount(bnetAccount);
String customerType=request.getParameter("customerType");
ReverseOrderEntity entity=new ReverseOrderEntity();
String msg="bizType="+bizType+"&&bnetId="+bnetId+"&&bnetAccount="+bnetAccount+"&&customerType="+customerType;
entity.setMsg(msg);
entity.setType(2);
dao.save(entity);
if(isEmpty(customerType)){
resultInfo.setResult_code(-1);
resultInfo.setResult_detail("参数customerType不能为空");
return JSONObject.toJSONString(resultInfo);
}
JSONObject cuType=(JSONObject) JSONObject.parse(customerType);
String accNbr=cuType.getString("accNbr");
String cbnetId=cuType.getString("bnetId");
String cbnetAccount=cuType.getString("bnetAccount");
String contactTelephone=cuType.getString("contactTelephone");
String contactPersonName=cuType.getString("contactPersonName");
//经办人证件号码
String identitySerialNumber=cuType.getString("identitySerialNumber");
//经办人证件类型
long identityType=cuType.getLongValue("identityType");
String identityAddress=cuType.getString("identityAddress");
String nodeId=cuType.getString("nodeId");
String servNbr=cuType.getString("servNbr");
if(isEmpty(cbnetId)){
resultInfo.setResult_code(-1);
resultInfo.setResult_detail("参数bnetId不能为空");
return JSONObject.toJSONString(resultInfo);
}
if(isEmpty(cbnetAccount)){
resultInfo.setResult_code(-1);
resultInfo.setResult_detail("参数bnetAccount不能为空");
return JSONObject.toJSONString(resultInfo);
}
if(isEmpty(nodeId)){
resultInfo.setResult_code(-1);
resultInfo.setResult_detail("参数nodeId不能为空");
return JSONObject.toJSONString(resultInfo);
}
if(isEmpty(servNbr)){
resultInfo.setResult_code(-1);
resultInfo.setResult_detail("参数servNbr不能为空");
return JSONObject.toJSONString(resultInfo);
}
if(isEmpty(identityType)){
resultInfo.setResult_code(-1);
resultInfo.setResult_detail("参数identityType不能为空");
return JSONObject.toJSONString(resultInfo);
}
if(isEmpty(identitySerialNumber)){
resultInfo.setResult_code(-1);
resultInfo.setResult_detail("参数identitySerialNumber不能为空");
return JSONObject.toJSONString(resultInfo);
}
if(isEmpty(identityAddress)){
resultInfo.setResult_code(-1);
resultInfo.setResult_detail("参数identityAddress不能为空");
return JSONObject.toJSONString(resultInfo);
}
//long state=cuType.getLongValue("state");
log.info("accNbr:"+accNbr+",bnetAccount:"+cbnetAccount+",bnetId"+cbnetId+",contactTelephone:"+contactTelephone
+",contactPersonName:"+contactPersonName+",identitySerialNumber:"+identitySerialNumber+",identityType:"+identityType
+",identityAddress:"+identityAddress+",nodeId:"+nodeId+",servNbr:"+servNbr+"\n");
cType.setAccNbr(accNbr);
//cType.setBnetId(cbnetId);
cType.setBnetAccount(cbnetAccount);
cType.setContactTelephone(contactTelephone);
cType.setCompanyName(contactPersonName);
cType.setIdentitySerialNumber(identitySerialNumber);
cType.setIdentityType(identityType);
cType.setIdentityAddress(identityAddress);
cType.setNodeId(nodeId);
cType.setServNbr(servNbr);
//cType.setState(state);
String offeringType=cuType.getString("offeringType");
log.info("====offeringType:"+offeringType+"\n");
JSONObject ofType=(JSONObject) JSONObject.parse(offeringType);
//String oaccNbr=ofType.getString("accNbr");
//String obnetId=ofType.getString("bnetId");
//String onodeId=ofType.getString("nodeId");
String oofferingSpecId=ofType.getString("offeringSpecId");
String oservNbr=ofType.getString("servNbr");
//oType.setAccNbr(oaccNbr);
//oType.setBnetId(obnetId);
//oType.setNodeId(onodeId);
log.info("offeringSpecId:"+oofferingSpecId+",servNbr:"+oservNbr);
oType.setOfferingSpecId(oofferingSpecId);
oType.setServNbr(oservNbr);
String productTypeList=ofType.getString("productType");
log.info("===productTypeList:"+productTypeList);
List<ProductType> pTypeList1=JSONArray.parseArray(productTypeList,ProductType.class);
for(ProductType pt:pTypeList1){
ProductType pType=new ProductType();
//String pbnetId=pt.getBnetId();
//String pnodeId=pt.getNodeId();
String productSpecId=pt.getProductSpecId();
//pType.setBnetId(pbnetId);
//pType.setNodeId(pnodeId);
pType.setProductSpecId(productSpecId);
log.info("===list productSpecId:"+productSpecId);
List<ProductAttributeType> lpTypeList1=pt.getProductAttributeList();
for(ProductAttributeType ls:lpTypeList1){
ProductAttributeType paType=new ProductAttributeType();
String attributeId=ls.getAttributeId();
String attributeValue=ls.getAttributeValue();
String lproductSpecId=ls.getProductSpecId();
log.info("===AttributeList attributeId:"+attributeId+",attributeValue:"+attributeValue+",productSpecId:"+lproductSpecId);
paType.setAttributeId(attributeId);
paType.setAttributeValue(attributeValue);
paType.setProductSpecId(lproductSpecId);
lpTypeList.add(paType);
}
pType.setProductAttributeList(lpTypeList);
pTypeList.add(pType);
}
oType.setProductList(pTypeList);
oaType.setOfferingType(oType);
oaType.setCustomerType(cType);
log.info("oaTypeToString:"+JSONObject.toJSONString(oaType));
String result=JSONObject.toJSONString(service.modifyGroupProd(oaType));
return result;
}
public boolean isEmpty(Object obj){
if(null==obj||obj.equals("")){
return true;
}
return false; } }

  

http后台json解析实例的更多相关文章

  1. JSON解析实例——使用Json-lib

    JSON解析实例——使用Json-lib Json-lib下载及使用 本文介绍用一个类库进行JSON解析. 工具下载地址:http://sourceforge.net/projects/json-li ...

  2. Json解析实例

    using System; using System.Collections.Generic; using System.Runtime.Serialization; using System.Win ...

  3. Javascript调用C#后台方法及JSon解析

    Javascript调用C#后台方法及JSon解析   如何使用Ajax 调用C# 后台方法. 本文目录 如何使用Ajax 调用C# 后台方法. 1.后台(.cs)测试方法 2.前台调用(javasc ...

  4. Android Json生成及解析实例

    JSON的定义: 一种轻量级的数据交换格式,具有良好的可读和便于快速编写的特性.业内主流技术为其提供了完整的解决方案(有点类似于正则表达式 ,获得了当今大部分语言的支持),从而可以在不同平台间进行数据 ...

  5. Android网络请求框架AsyncHttpClient实例详解(配合JSON解析调用接口)

    最近做项目要求使用到网络,想来想去选择了AsyncHttpClient框架开进行APP开发.在这里把我工作期间遇到的问题以及对AsyncHttpClient的使用经验做出相应总结,希望能对您的学习有所 ...

  6. java后台常用json解析工具问题小结

    若排版紊乱可查看我的个人博客原文地址 java后台常用json解析工具问题小结 这里不细究造成这些问题的底层原因,只是单纯的描述我碰到的问题及对应的解决方法 jackson将java对象转json字符 ...

  7. C# Json.Net解析实例

    本文以一个简单的小例子,简述Json.Net的相关知识,仅供学习分享使用,如有不足之处,还请指正. 概述 Json.Net is a Popular high-performance JSON fra ...

  8. json-lib-2.4-jdk15.jar所需全部JAR包.rar java jsoup解析开彩网api接口json数据实例

    json-lib-2.4-jdk15.jar所需全部JAR包.rar  java jsoup解析开彩网api接口json数据实例 json-lib-2.4-jdk15.jar所需全部JAR包.rar  ...

  9. android json 解析简单实例

    Android JSON解析跟JAVA 的JSON解析原理是一样的. Android自带的JSON方式跟方便,不需要导包啥的.不深究原理了,直接上代码: public class JsonActivi ...

随机推荐

  1. 谁应该在CCB(变更控制委员会)中?

    In software development, a Change Control Board (CCB) or Software Change Control Board (SCCB) is a c ...

  2. VS2008 远程调试器未成功安装,没法使用?

    Win7 64位系统,安装VS2008后,想使用远程调试功能,结果不能使用! 在VS2008的安装包下有个 Remote Debugger 的文件夹,在里面找到 x64 的 rdbgsetup.exe ...

  3. 【转】ZooKeeper详细介绍和使用第一节

    一.分布式协调技术 在给大家介绍ZooKeeper之前先来给大家介绍一种技术——分布式协调技术.那么什么是分布式协调技术?那么我来告诉大家,其实分布式协调技术 主要用来解决分布式环境当中多个进程之间的 ...

  4. PHPCMS V9 全站通用日期时间标签

    用PHPCMS V9 建站时,经常会用到时间标签,它是通用标签调用-日期时间格式化,适用全站. 1.日期时间格式化显示: a\标准型:{date('Y-m-d H:i:s', $rs['inputti ...

  5. MyBatis踩坑记录

    在线文档: 动态SQL  http://www.mybatis.org/mybatis-3/zh/dynamic-sql.html 1. Error setting null for paramete ...

  6. ajax之cache血与泪~~

    场景:项目以ie5渲染页面,点击导出列表数据(Excel形式),点击导出发送get请求,后台生成Excel文件,返回文件地址信息 异常:ie第一次返回的信息正常,之后返回的都是第一次的结果,googl ...

  7. 8 -- 深入使用Spring -- 2...6 Spring 4.0 增强的自动装配和精确装配

    8.2.6 Spring 4.0 增强的自动装配和精确装配 Spring提供了@Autowired 注解来指定自动装配,@Autowired可以修饰setter方法.普通方法.实例变量和构造器等.当使 ...

  8. mysql的in查询分析

    群里山楂大仙和电台大神探讨到mysql的in查询的问题,问题如下: student表有class_id的索引,但是只查询一个的时候用索引,查两个就不用索引了 这是很奇怪的现象,我试了一下也是这样,真是 ...

  9. Android开发-- findViewById()方法得到空指针

    如果想通过调用findViewById()方法获取到相应的控件,必须要求当前Activity的layout通过setContentView. 如果你通过其他方法添加了一个layout,如需获取这个la ...

  10. error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version

    更新的软件可以解决 TortoiseGit-preview-2.5.7.0-20180127-b2d00f8-64bit.msi和Git-2.16.2-64-bit.exe. 链接地址为: https ...