package com.lyms.hospital.controller; import java.io.IOException; import javax.servlet.http.HttpServletRequest; import org.apache.commons.lang3.builder.ToStringBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.lyms.sync.ParamsAdpter; import com.lyms.sync.SyncHandler; import com.lyms.sync.SyncUtils; import com.lyms.sync.channel.ChannelData; import com.lyms.web.controller.BaseController; /** *
  • @ClassName: RouterController *
  • @Description: 远程接口调用数据处理分发 *
  • @author maliang *
  • @date 2017年3月14日 *
  • */ @RestController @RequestMapping("/remote") public class RouterController extends BaseController { private static final Logger log = LoggerFactory.getLogger(RouterController.class); //@RequestMapping(value = "/pull", produces = { MediaType.APPLICATION_JSON_VALUE }) public Object pull(HttpServletRequest request) throws Exception { ChannelData data = SyncUtils.conver(request); log.debug("节点数据被中心拉取:" + ToStringBuilder.reflectionToString(data)); Object handResult = SyncHandler.handler(data); if (data.getLoop()) { data = (ChannelData) handResult; } else { data.setData(ParamsAdpter.builder().push(handResult).toJsonString()); } data.setAck(true); return data; } //@RequestMapping(value = "/push", produces = { MediaType.APPLICATION_JSON_VALUE }) public Object push(HttpServletRequest request) throws Exception { ChannelData data = SyncUtils.conver(request); log.debug("中心推送数据到节点:" + ToStringBuilder.reflectionToString(data)); Object handResult = SyncHandler.handler(data); if (data.getLoop()) { data = (ChannelData) handResult; } else { data.setData(ParamsAdpter.builder().push(handResult).toJsonString()); } return data; } }