DatacollectManager.java 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. package com.yihu.ehr.service;
  2. import com.yihu.ehr.dbhelper.common.DBList;
  3. import com.yihu.ehr.dbhelper.common.DBQuery;
  4. import com.yihu.ehr.dbhelper.common.QueryCondition;
  5. import com.yihu.ehr.dbhelper.common.QueryEntity;
  6. import com.yihu.ehr.dbhelper.common.enums.Logical;
  7. import com.yihu.ehr.dbhelper.common.enums.Operation;
  8. import com.yihu.ehr.dbhelper.jdbc.DBHelper;
  9. import com.yihu.ehr.framework.model.DataGridResult;
  10. import com.yihu.ehr.framework.model.Result;
  11. import com.yihu.ehr.service.intf.IDatacollectManager;
  12. import org.springframework.stereotype.Service;
  13. import org.springframework.transaction.annotation.Transactional;
  14. import java.util.UUID;
  15. /**
  16. * 采集管理
  17. * Created by HZP on 2016/02/26.
  18. */
  19. @Service("datacollectManager")
  20. public class DatacollectManager implements IDatacollectManager {
  21. DBQuery query = new DBQuery();
  22. DBHelper db = new DBHelper();
  23. /*
  24. 获取数据集
  25. */
  26. @Override
  27. public DataGridResult getDataset(String name) throws Exception
  28. {
  29. String sql = "select * from adapter_dataset where org_dataset_id is not null";
  30. if(name!=null&&name.length()>0)
  31. {
  32. sql += " and (org_dataset_code like '%"+name+"%' or org_dataset_name like '%"+name+"%')";
  33. }
  34. DBList list = query.queryBySql(sql);
  35. return DataGridResult.fromDBList(list);
  36. }
  37. /*
  38. 获取数据元
  39. */
  40. @Override
  41. public DataGridResult getMetadata(String name,String adapterDatasetId,int page,int size) throws Exception
  42. {
  43. String sql = "select a.*,b.definition,b.type,b.format from adapter_metadata a left join org_metadata b on a.org_metadata_id = b.id where a.org_metadata_id is not null";
  44. if(adapterDatasetId!=null&& adapterDatasetId.length()>0)
  45. {
  46. sql += " and a.adapter_dataset_id = '"+adapterDatasetId+"'";
  47. }
  48. if(name!=null&&name.length()>0)
  49. {
  50. sql += " and (a.org_metadata_code like '%"+name+"%' or a.org_metadata_name like '%"+name+"%')";
  51. }
  52. DBList list = query.queryBySql(sql,page,size);
  53. return DataGridResult.fromDBList(list);
  54. }
  55. /*
  56. 获取跟踪数据
  57. */
  58. @Override
  59. public DataGridResult getJobLog(String patientId,String eventNo,String status,int page,int size) throws Exception
  60. {
  61. String sql = "select * from task_track where 1=1";
  62. if(patientId!=null&& patientId.length()>0)
  63. {
  64. sql += " and patient_id = '"+patientId+"'";
  65. }
  66. if(eventNo!=null&& eventNo.length()>0)
  67. {
  68. sql += " and event_no = '"+eventNo+"'";
  69. }
  70. if(status!=null&& status.length()>0)
  71. {
  72. sql += " and status = '"+status+"'";
  73. }
  74. DBList list = query.queryBySql(sql,page,size);
  75. return DataGridResult.fromDBList(list);
  76. }
  77. /*
  78. 获取补采数据
  79. */
  80. @Override
  81. public DataGridResult getJobRepeat(int page,int size) throws Exception
  82. {
  83. String sql = "select * from crawler_supply where 1=1 and start_time is not null and end_time is not null";
  84. DBList list = query.queryBySql(sql,page,size);
  85. return DataGridResult.fromDBList(list);
  86. }
  87. /*
  88. 新增补采
  89. */
  90. @Override
  91. @Transactional
  92. public Result addJobRepeat(String startTime,String endTime) throws Exception
  93. {
  94. String sql = "insert into crawler_supply (id,start_time,end_time,status) values ('"+ UUID.randomUUID() +"','"+startTime+"','"+endTime+"','0')";
  95. if(db.execute(sql))
  96. {
  97. return Result.success("保存成功!");
  98. }
  99. else{
  100. return Result.error(db.errorMessage);
  101. }
  102. }
  103. /*
  104. 删除补采
  105. */
  106. @Override
  107. @Transactional
  108. public Result deleteJobRepeat(String id) throws Exception
  109. {
  110. String sql = "delete from crawler_supply where id = '"+id+"'";
  111. if(db.execute(sql))
  112. {
  113. return Result.success("删除成功!");
  114. }
  115. else{
  116. return Result.error(db.errorMessage);
  117. }
  118. }
  119. }