package com.yihu.hos.central.rest.controllers; import com.yihu.ehr.util.rest.Envelop; import com.yihu.hos.central.rest.common.util.ImportDataToDataBase; import com.yihu.hos.central.rest.feign.RedisClient; import com.yihu.hos.central.rest.services.crawler.CrawlerManager; import com.yihu.hos.central.rest.services.qc.EsSimplePackage; import com.yihu.hos.central.rest.services.upload.UploadDetailService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.sql.SQLException; import java.util.Arrays; import java.util.Date; /** * 从EHR 微服务获取档案数据,并写入到中间库 *

* Created by Airhead on 2015/12/16. */ @RequestMapping("/crawlerInsert") @RestController("crawlerInsertController") @Api(protocols = "http", value = "CrawlerController", description = "档案采集写入接口,用于从资源中获取数据并写入特定中间表中", tags = {"档案上传"}) public class CrawlerController { @Autowired private CrawlerManager crawlerManager; @Autowired private UploadDetailService uploadDetailService; @Autowired private RedisClient redisClient; @RequestMapping(value = "/test", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @ApiOperation(value = "测试服务器可以正常连接", produces = "application/json", notes = "测试服务器可以正常连接") public String test() { System.out.println("接口调用成功?,日志乱码?"); return "test"; } @RequestMapping(value = "/testSql", produces = "application/json;charset=UTF-8", method = RequestMethod.POST) @ApiOperation(value = "测试sql语法", produces = "application/json", notes = "测试sql语法") public String testSql( @ApiParam(name = "sql", value = "sql", required = true) @RequestParam(value = "sql") String sql) throws SQLException { ImportDataToDataBase.exportSqlToOracle(Arrays.asList(sql)); return "test"; } @RequestMapping(value = "updateUploadDetail", method = RequestMethod.GET) @ApiOperation(value = "更新上传情况", produces = "application/json", notes = "更新上传情况") public void update() throws Exception { uploadDetailService.saveOrUpdate(new Date()); } @RequestMapping(value = "/packQcReport/setStartTime", method = RequestMethod.GET) @ApiOperation(value = "设置上传数据集统计数据 - 抽取时间") public Envelop setStartTime( @ApiParam(name = "date", value = "日期", required = true) @RequestParam(value = "date") String date) throws Exception { Envelop envelop = new Envelop(); redisClient.set("start_upload_date",date); envelop.setSuccessFlg(true); return envelop; } @RequestMapping(value = "test2", method = RequestMethod.GET) @ApiOperation(value = "测试接口,后续删除", produces = "application/json", notes = "test2") public void test2() throws Exception { EsSimplePackage pack = new EsSimplePackage(); pack.setPatient_id("RY00278359"); pack.setPatient_name("刘明"); pack.setEvent_no("20180103-7394"); pack.setEvent_type(0); pack.setEvent_date("2018-01-03 09:59:36"); pack.setRowkey("492330267_20180103-7394_1514944776000"); pack.setOrg_code("492330267"); crawlerManager.collectProcessByRowkey(pack); } }