java 传入json 转换成java对象 返回java对象转成json
来源:互联网 发布:java上线项目 编辑:程序博客网 时间:2024/05/24 16:15
package com.dr.service.server.fanhua.service;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.dr.service.common.exception.SRConts;
import com.dr.service.server.fanhua.dto.request.createtaskb.CreateTaskB;
import com.dr.service.server.fanhua.dto.response.createtaskb.CreateTaskBResponse;
import com.dr.service.server.fanhua.util.FanHuaUtil;
import com.dr.service.server.fanhua.util.HttpClientUtils;
import com.dr.service.server.fanhua.util.Logger;
import com.dr.service.server.fanhua.util.MD5Util;
import com.dr.util.Constants;
import com.dr.util.FileUtil;
@Service("createTaskBService")
public class CreateTaskBService {
protected Logger logger = Logger.getLogger(this.getClass());
public CreateTaskBResponse createTaskB(CreateTaskB createTaskB) {
CreateTaskBResponse jb = new CreateTaskBResponse();
try {
Map headerMap = new HashMap();
Properties dbProps = new Properties();
dbProps.load(FanHuaUtil.loads());
logger.info("==================CreateTaskB标准(接口)发送报文========================");
JSONObject body = (JSONObject) JSON.toJSON(createTaskB);
FileUtil.createFanHuaFBXLog("CreateTaskBService", "FanHua",
body.toString(), Constants.REQUEST);
// JSONObject body=(JSONObject)JSONObject.fromObject(fo);
headerMap.put("channelId", dbProps.getProperty("channelId"));
headerMap
.put("sign",
MD5Util.encode(body
+ dbProps.getProperty("channelSecret")));
logger.info(body + dbProps.getProperty("channelSecret"));
logger.info("==================CreateTaskB标准(接口)返回报文========================");
Map map = HttpClientUtils.HttpClientJsonPostHeader(
dbProps.getProperty("createTaskB"), body.toString(),
dbProps.getProperty("encoding"), headerMap);
logger.info(map.get("info"));
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.dr.service.common.exception.SRConts;
import com.dr.service.server.fanhua.dto.request.createtaskb.CreateTaskB;
import com.dr.service.server.fanhua.dto.response.createtaskb.CreateTaskBResponse;
import com.dr.service.server.fanhua.util.FanHuaUtil;
import com.dr.service.server.fanhua.util.HttpClientUtils;
import com.dr.service.server.fanhua.util.Logger;
import com.dr.service.server.fanhua.util.MD5Util;
import com.dr.util.Constants;
import com.dr.util.FileUtil;
@Service("createTaskBService")
public class CreateTaskBService {