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. 教你下载BarTender 2016

    BarTender是全球领先标签.条形码.RFID和证卡设计打印软件,功能强大,操作简单,具有很强的灵活性.目前,BarTender软件已更新至最新版BarTender 2016.BarTender ...

  2. 使用java启动mybatis generator

    1.java工程目录结构: |src/main/java |com.leslie.mybatis.generator |MybatisGeneratorUtil.java |src/main/reso ...

  3. jquery ajax 请求中 中文汉字的 转码问题

    1.汉字参数直接跟在请求连接的后面,这样需要使用encodeURIComponent(fileName)或者encodeURI(fileName)转码两次 后台使用URLDecoder.decode( ...

  4. oracle 按照时间间隔进行分组

    select sum(SHOW_NUMBER) as SHOW_NUMBER ,d.dt from T_RECOMMEND_ANALYSIS t,( ) dt ) d group by d.dt 按照 ...

  5. 修改centos的时间,解决时间比本地实际时间快了8小时

    1.vi /etc/sysconfig/clock #编辑文件ZONE="Asia/Shanghai"UTC=false #设置为false,硬件时钟不于utc时间一致ARC=fa ...

  6. 【转载】springboot + swagger

    注:本文参考自 http://www.jianshu.com/p/0465a2b837d2 https://www.cnblogs.com/java-zhao/p/5348113.html swagg ...

  7. CentOS 6.3下搭建Web服务器

    准备前的工作: 1.修改selinux配置文件(/etc/sysconfig/selinux) 关闭防火墙 (1)把SELINUX=enforcing注释掉 (2)并添加SELINUX=disable ...

  8. php 自定义 分页函数

    <?php /** * 分页函数 * @param type $num 数据总数 * @param type $perpage 每页总数 * @param type $curpage 当前分页 ...

  9. Echarts调整图表上下左右的间距,Echarts调整柱状图左右的间距

    Echarts调整图表上下左右的间距,Echarts调整柱状图左右的间距 >>>>>>>>>>>>>>>> ...

  10. iOS开发--tarBarItem右上方显示badgeValue

    直接设置tabBarItem.badgeValue没有效果,找原因半天发现ViewController被NavigationViewController包着 需这样设置才行: self.navigat ...