7c48c5286fc87a51b4ec9eb89bf78ecdf5baa944.svn-base 9.43 KB
package com.thinkgem.jeesite.modules.reg.web.httprest.httpRestController;

import java.io.File;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.io.FileUtils;
import org.codehaus.jackson.JsonParser.Feature;
import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.bitservice.adi.WSEndpointServiceLocator;
import com.bitservice.adi.WSService;
import com.google.common.collect.Maps;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.mapper.JsonMapper;
import com.thinkgem.jeesite.common.service.ServiceException;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.modules.act.web.ActTaskController;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusSlsq;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseHService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusRightsService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusSlsqService;
import com.thinkgem.jeesite.modules.reg.service.qjxt.InterfacelogService;
import com.thinkgem.jeesite.modules.reg.utils.Base64;
import com.thinkgem.jeesite.modules.reg.web.bus.registlog.JrrzService;
import com.thinkgem.jeesite.modules.reg.web.bus.registlog.JrrzServiceService;
import com.thinkgem.jeesite.modules.reg.web.httprest.httpRestService.HttpRestToService;
import com.thinkgem.jeesite.modules.reg.web.httprest.utils.DatatypeUtil;

/**
 * 一窗受理接口类
 * @author LENOVO
 *2018-11-10
 */
@Controller
@RequestMapping(value="/rest/v1.0")
public class HttpRestTest extends BaseController{
	
	protected Logger logger = LoggerFactory.getLogger(getClass());
	@Autowired
	private RegBaseHService regBaseHService;
	@Autowired
	private RegBusRightsService regBusRightsService;
	@Autowired
	private HttpRestToService httpresttoservice;
	@Autowired
	private InterfacelogService interfacelogService;
	@Autowired
	private ActTaskController  actTaskController;
	
	@Autowired
	private HttpRestPush restPush;

	   
	/**
	 * 日志上报
	 * @param request
	 * @param response
	 * @param handler
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/bdcrzsb/rzsb", method = RequestMethod.POST)
	public void rzsb(HttpServletRequest request,HttpServletResponse response) throws Exception{
		String msg = "";
		try{  
			String jsonstr = DatatypeUtil.reqReceive(request);
			logger.info("传入参数{}",jsonstr); 
			//日期
			Date date = new Date();
			SimpleDateFormat myFmt = new SimpleDateFormat("yyyyMMdd");
			String accessDate = myFmt.format(date);
			System.out.println("开始发送"+"********");
			JrrzServiceService jrrzsservice = new JrrzServiceService();
			JrrzService jrrzsb = jrrzsservice.getJrrzServicePort();
			msg = jrrzsb.exchangeInfo(jsonstr.toString());
			System.out.println("结束发送"+"********");
			String filePath=Global.getUserfilesBaseDir() + Global.LOGBOOK_URL+accessDate+System.currentTimeMillis()+".txt";
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			FileUtils.writeStringToFile(new File(filePath), jsonstr.toString()+"\n"+msg+"\n"+"当前上报日志日期为:"+df.format(new Date())+",返回结果为:"+msg, "UTF-8");
		} catch (Exception e) {
			System.out.println("日志上报失败 :"+e.getMessage());
			logger.error(DatatypeUtil.errorTrackSpace(e));
		}
		renderString(response, msg);
	}
	
	/**
	 * 测试方法 登记缮证登薄后将该不动产单元状态推送给一窗
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(value = "/ycsl/dbxx", method = RequestMethod.POST)
	public  void dbxx(HttpServletRequest request,HttpServletResponse response) throws Exception{
		String url = "http://" + request.getServerName()	    //服务器地址  
        + ":"+ request.getServerPort()  //端口号  
        + request.getContextPath()      //项目名称  
        + request.getServletPath();    //请求页面或其他地址  
		Map resmap = Maps.newHashMap();
		Map head = Maps.newHashMap();
		Map data = Maps.newHashMap();
		String jsonstr = "";
		Exception exception = null;
		try{
			jsonstr = DatatypeUtil.reqReceive(request);
			logger.info("传入参数{}",jsonstr); 
			head.put("regionCode", "0000");
			head.put("msg", "成功");
		}catch(ServiceException s){	
			head.put("regionCode", "1000");
			head.put("msg", "业务错误,"+s.getMessage());
			exception = s;
			s.printStackTrace();
		}catch(Exception e){
			head.put("regionCode", "2000");
			head.put("msg", "代码未知错误");
			exception = e;
			e.printStackTrace();
		}finally {
			resmap.put("head", head);
			resmap.put("data", data);
		}
		interfacelogService.saveUsByProperty(url, "一窗受理", jsonstr, JsonMapper.toJsonString(resmap), exception);
		renderString(response, resmap);
	}
	
	/**
	 * 测试方法  获取业务办理状态接口
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(value = "/ycsl/getywzt", method = RequestMethod.POST)
	public  void getywzt(HttpServletRequest request,HttpServletResponse response) throws Exception{
		String url = "http://" + request.getServerName()	    //服务器地址  
        + ":"+ request.getServerPort()  //端口号  
        + request.getContextPath()      //项目名称  
        + request.getServletPath();    //请求页面或其他地址  
		Map resmap = Maps.newHashMap();
		Map head = Maps.newHashMap();
		Map data = Maps.newHashMap();
		String jsonstr = "";
		Exception exception = null;
		try{
			jsonstr = DatatypeUtil.reqReceive(request);
			logger.info("传入参数{}",jsonstr); 
			head.put("regionCode", "0000");
			head.put("msg", "成功");
		}catch(ServiceException s){	
			head.put("regionCode", "1000");
			head.put("msg", "业务错误,"+s.getMessage());
			exception = s;
			s.printStackTrace();
		}catch(Exception e){
			head.put("regionCode", "2000");
			head.put("msg", "代码未知错误");
			exception = e;
			e.printStackTrace();
		}finally {
			resmap.put("head", head);
			resmap.put("data", data);
		}
		interfacelogService.saveUsByProperty(url, "一窗受理", jsonstr, JsonMapper.toJsonString(resmap), exception);
		renderString(response, resmap);
	}
	
	/**
	 * 测试方法  获取业务办理状态接口
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(value = "/ycsl/gettoken", method = RequestMethod.POST)
	public  void gettoken(HttpServletRequest request,HttpServletResponse response) throws Exception{
		String url = "http://" + request.getServerName()	    //服务器地址  
        + ":"+ request.getServerPort()  //端口号  
        + request.getContextPath()      //项目名称  
        + request.getServletPath();    //请求页面或其他地址  
		Map resmap = Maps.newHashMap();
		Map head = Maps.newHashMap();
		Map data = Maps.newHashMap();
		String jsonstr = "";
		Exception exception = null;
		head.put("regionCode", "");
		head.put("orgid", "");
		try{
			jsonstr = DatatypeUtil.reqReceive(request);
			logger.info("传入参数{}",jsonstr); 
			head.put("statusCode", "0000");
			head.put("msg", "成功");
			
			data.put("token", UUID.randomUUID().toString());
		}catch(ServiceException s){	
			head.put("statusCode", "1000");
			head.put("msg", "业务错误,"+s.getMessage());
			exception = s;
			s.printStackTrace();
		}catch(Exception e){
			head.put("statusCode", "2000");
			head.put("msg", "代码未知错误");
			exception = e;
			e.printStackTrace();
		}finally {
			resmap.put("head", head);
			resmap.put("data", data);
		}
		interfacelogService.saveUsByProperty(url, "一窗受理", jsonstr, JsonMapper.toJsonString(resmap), exception);
		renderString(response, resmap);
	}
	
	/**
	 * 测试方法 接口主要用于登记系退件情况,登记发现业务内容有错误,发起退件请求,一窗进行响应,并进行退件逻辑处理
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(value = "/ycsl/sjth", method = RequestMethod.POST)
	public  void sjth(HttpServletRequest request,HttpServletResponse response) throws Exception{
		String url = "http://" + request.getServerName()	    //服务器地址  
        + ":"+ request.getServerPort()  //端口号  
        + request.getContextPath()      //项目名称  
        + request.getServletPath();    //请求页面或其他地址  
		Map resmap = Maps.newHashMap();
		Map head = Maps.newHashMap();
		Map data = Maps.newHashMap();
		String jsonstr = "";
		Exception exception = null;
		try{
			jsonstr = DatatypeUtil.reqReceive(request);
			logger.info("传入参数{}",jsonstr); 
			head.put("regionCode", "0000");
			head.put("msg", "成功");
		}catch(ServiceException s){	
			head.put("regionCode", "1000");
			head.put("msg", "业务错误,"+s.getMessage());
			exception = s;
			s.printStackTrace();
		}catch(Exception e){
			head.put("regionCode", "2000");
			head.put("msg", "代码未知错误");
			exception = e;
			e.printStackTrace();
		}finally {
			resmap.put("head", head);
			resmap.put("data", data);
		}
		interfacelogService.saveUsByProperty(url, "一窗受理", jsonstr, JsonMapper.toJsonString(resmap), exception);
		renderString(response, resmap);
	}

 
	
	
}