package com.lyms.hospital.controller; import javax.servlet.http.HttpServletRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import com.alibaba.fastjson.JSONObject; import com.lyms.spring.PropertiesUtil; import com.lyms.sync.data.constants.SyncStatus; import com.lyms.sync.data.service.SyncDataBasicService; import com.lyms.web.controller.BaseController; @RestController @RequestMapping(value = "/sync", method = RequestMethod.POST) public class CenterCallHospitalController extends BaseController { private static Logger log = LoggerFactory.getLogger(CenterCallHospitalController.class); private static final String ALLOW_IP = PropertiesUtil.getString("sync_allow_ip"); @Autowired private SyncDataBasicService syncDataBasicService; @ResponseBody @RequestMapping(value = "/getNeedSyncData", method = RequestMethod.POST) public String getNeedSyncData(HttpServletRequest request) { if (isAllow(request)) { return getMsg(SyncStatus.SUCCESS,syncDataBasicService.getNeedSyncData()); }else{ return getMsg(SyncStatus.NOTALLOW); } } private boolean isAllow(HttpServletRequest request){ String ip = getHost(request); if (ip.equalsIgnoreCase(ALLOW_IP)) { return true; } log.info("不是受理允许的ip【{}】地址请求基础数据同步!", ip); return false; } /** *