Commit a6738c1cfb53c9fc05f98af072a0f0ec1a11202b
1 parent
594a54ecad
Exists in
master
and in
6 other branches
update code
Showing 6 changed files with 91 additions and 25 deletions
- platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/QhdfyHisService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/SyncDataController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/SyncDataTaskService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/HttpClientUtil.java
- platform-operate-api/src/main/resources/spring/applicationContext-quartz.xml
platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/QhdfyHisService.java
View file @
a6738c1
... | ... | @@ -51,12 +51,17 @@ |
51 | 51 | private ReferConfigService referConfigService; |
52 | 52 | |
53 | 53 | |
54 | - public void syncLisReportTask() { | |
55 | - DateTime dt = new DateTime(); | |
56 | - dt = dt.minusDays(1); | |
57 | - queryLisReport(dt.toDate()); | |
54 | + public void syncLisReportTimer() { | |
55 | + Date date = new Date(); | |
56 | + queryLisReport(new Date(date.getTime()-1000*60*60)); | |
58 | 57 | } |
59 | 58 | |
59 | + public void syncLisReportTask(String dateStr) { | |
60 | +// DateTime dt = new DateTime(); | |
61 | +// dt = dt.minusDays(1); | |
62 | + queryLisReport(DateUtil.parseYMD(dateStr)); | |
63 | + } | |
64 | + | |
60 | 65 | public List<QhdfyLisReport> queryLisReport(Date startDate) { |
61 | 66 | //TODO |
62 | 67 | Integer hospitalId = 216; |
63 | 68 | |
... | ... | @@ -75,10 +80,11 @@ |
75 | 80 | referValueMap.put(referValue.getCode(), referValue); |
76 | 81 | } |
77 | 82 | PatientsQuery patientsQuery = new PatientsQuery(); |
78 | - String sql = "select top 100000 shenqinghao as hospitalId,bingrenid as patientFid,zhuyuanhao as patientHid,kahao as vcCardNo,phone,huanzhexingming as name,xingbie as sex,nianling as age,shenqingkeshidaima as deptCode,shenqingkeshimingcheng as deptName,shenqingyishengdaima as applyDoctorCode,shenqingyishengmingcheng as applyDoctorName,jianchayishengdaima as checkDoctorCode,jianchayishengxingming as checkDoctorName,baogaofabushijian as publishTime from valllist_ex_en where phone is not null and phone !='' and shenqinghao is not null order by shenqinghao desc"; | |
83 | + String sql = "select top 100000 shenqinghao as hospitalId,bingrenid as patientFid,zhuyuanhao as patientHid,kahao as vcCardNo,phone,huanzhexingming as name,xingbie as sex,nianling as age,shenqingkeshidaima as deptCode,shenqingkeshimingcheng as deptName,shenqingyishengdaima as applyDoctorCode,shenqingyishengmingcheng as applyDoctorName,jianchayishengdaima as checkDoctorCode,jianchayishengxingming as checkDoctorName,baogaofabushijian as publishTime from valllist_ex_en where baogaofabushijian > CONVERT(DATETIME,'"+startDate+"', 20) and phone is not null and phone !='' and shenqinghao is not null order by shenqinghao desc"; | |
79 | 84 | String subSql = "select top 1000 sheqingdanhao as id,xiangmudaima as code,xiangmumingcheng as name,xiangmujieguo as result,zifujieguo as charResult,shuzijieguo as numberResult,gaodibiaozhi as flag,cankaozhi as ref,danwei as unit,jieguoleixing as result from valresult_ex_en where sheqingdanhao='"; |
80 | 85 | Object[] params = {startDate}; |
81 | - List<LisReport> list = queryRunner.query(conn, sql, new BeanListHandler<LisReport>(LisReport.class)); | |
86 | + List<LisReport> list = queryRunner.query(conn, sql, new BeanListHandler<LisReport>(LisReport.class),startDate); | |
87 | + System.out.println("危急值====> " + list.size()); | |
82 | 88 | if (list.size() > 0) { |
83 | 89 | MongoCondition mongoCondition = MongoCondition.newInstance("hospitalId", ""+hospitalId, MongoOper.IS); |
84 | 90 | List<AssayConfig> assayConfigList = assayConfigDao.query(mongoCondition.toMongoQuery()); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/SyncDataController.java
View file @
a6738c1
... | ... | @@ -31,7 +31,7 @@ |
31 | 31 | public void findSyncData(HttpServletResponse response) { |
32 | 32 | SyncDataQuery syncDataQuery = new SyncDataQuery(); |
33 | 33 | syncDataQuery.setNeed("y"); |
34 | - syncDataQuery.setLimit(100); | |
34 | + syncDataQuery.setLimit(2000); | |
35 | 35 | syncDataQuery.setStatus(1); |
36 | 36 | List<SyncDataModel> list = syncDataService.querySyncData(syncDataQuery); |
37 | 37 | for (SyncDataModel model:list) { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java
View file @
a6738c1
... | ... | @@ -212,8 +212,8 @@ |
212 | 212 | |
213 | 213 | @RequestMapping(value = "/syncLisReportTask", method = RequestMethod.GET) |
214 | 214 | @ResponseBody |
215 | - public String syncLisReportTask() { | |
216 | - qhdfyHisService.syncLisReportTask(); | |
215 | + public String syncLisReportTask(@RequestParam(required = true)String time) { | |
216 | + qhdfyHisService.syncLisReportTask(time); | |
217 | 217 | return "finish"; |
218 | 218 | } |
219 | 219 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/SyncDataTaskService.java
View file @
a6738c1
... | ... | @@ -29,6 +29,7 @@ |
29 | 29 | import org.apache.http.util.EntityUtils; |
30 | 30 | import org.joda.time.DateTime; |
31 | 31 | import org.springframework.beans.factory.annotation.Autowired; |
32 | +import org.springframework.data.domain.Sort; | |
32 | 33 | import org.springframework.stereotype.Service; |
33 | 34 | |
34 | 35 | import javax.print.attribute.standard.DateTimeAtCompleted; |
35 | 36 | |
36 | 37 | |
37 | 38 | |
... | ... | @@ -135,23 +136,60 @@ |
135 | 136 | |
136 | 137 | try{ |
137 | 138 | |
138 | - StringBuffer ids = new StringBuffer(); | |
139 | + | |
139 | 140 | String json = HttpClientUtil.doPost("https://area-qhd-api.healthbaby.com.cn:18019/findSyncData", new HashMap<String, String>(), "utf-8"); |
140 | 141 | if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(json)) |
141 | 142 | { |
142 | 143 | List<SyncDataModel> list = JsonUtil.toList(json, SyncDataModel.class); |
143 | - for (SyncDataModel model : list) { | |
144 | - boolean boo = mongoSyncService.syncData(model.getAction(), model.getDataId(), model.getClassName(), model.getJsonData()); | |
145 | - if (boo) { | |
146 | - ids.append(model.getId()); | |
147 | - ids.append(","); | |
144 | + System.out.println("syncdata size = "+ list.size()); | |
145 | + | |
146 | + | |
147 | + int batchSize = 200; | |
148 | + int end = 0; | |
149 | + for (int i = 0; i < list.size(); i += batchSize) { | |
150 | + end = (end + batchSize); | |
151 | + if (end > list.size()) { | |
152 | + end = list.size(); | |
148 | 153 | } |
154 | + System.out.println("start:" + i + ",end:" + end); | |
155 | + final List<SyncDataModel> tempList = list.subList(i, end); | |
156 | + new Thread(new Runnable() { | |
157 | + @Override | |
158 | + public void run() { | |
159 | + if (CollectionUtils.isNotEmpty(tempList)) | |
160 | + { | |
161 | + StringBuffer ids = new StringBuffer(); | |
162 | + for (SyncDataModel model : tempList) { | |
163 | + boolean boo = mongoSyncService.syncData(model.getAction(), model.getDataId(), model.getClassName(), model.getJsonData()); | |
164 | + if (boo) { | |
165 | + ids.append(model.getId()); | |
166 | + ids.append(","); | |
167 | + } | |
168 | + } | |
169 | + if (ids.length() > 0) { | |
170 | + Map<String,String> params = new HashMap<String, String>(); | |
171 | + params.put("ids", ids.toString()); | |
172 | + String result = HttpClientUtil.doPost("https://area-qhd-api.healthbaby.com.cn:18019/updateSyncData", params, "utf-8"); | |
173 | + System.out.println("exc result = "+ result); | |
174 | + } | |
175 | + } | |
176 | + } | |
177 | + }).start(); | |
149 | 178 | } |
150 | - if (ids.length() > 0) { | |
151 | - Map<String,String> params = new HashMap<String, String>(); | |
152 | - params.put("ids", ids.toString()); | |
153 | - HttpClientUtil.doPost("https://area-qhd-api.healthbaby.com.cn:18019/updateSyncData", params, "utf-8"); | |
154 | - } | |
179 | + | |
180 | +// for (SyncDataModel model : list) { | |
181 | +// boolean boo = mongoSyncService.syncData(model.getAction(), model.getDataId(), model.getClassName(), model.getJsonData()); | |
182 | +// if (boo) { | |
183 | +// ids.append(model.getId()); | |
184 | +// ids.append(","); | |
185 | +// } | |
186 | +// } | |
187 | +// if (ids.length() > 0) { | |
188 | +// Map<String,String> params = new HashMap<String, String>(); | |
189 | +// params.put("ids", ids.toString()); | |
190 | +// String result = HttpClientUtil.doPost("https://area-qhd-api.healthbaby.com.cn:18019/updateSyncData", params, "utf-8"); | |
191 | +// System.out.println("exc result = "+ result); | |
192 | +// } | |
155 | 193 | } |
156 | 194 | }catch(Exception ex){ |
157 | 195 | ExceptionUtils.catchException(ex, "qhdfySyncDataSSL Error."); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/HttpClientUtil.java
View file @
a6738c1
... | ... | @@ -50,10 +50,13 @@ |
50 | 50 | return result; |
51 | 51 | } |
52 | 52 | |
53 | -// public static void main(String[] args) throws Exception { | |
54 | -// | |
55 | -// String s = doPost("https://area-qhd-api.healthbaby.com.cn:18019/findSyncData", new HashMap<String, String>(), "utf-8"); | |
56 | -// System.out.println(s); | |
57 | -// } | |
53 | + public static void main(String[] args) throws Exception { | |
54 | + | |
55 | + long start = System.currentTimeMillis(); | |
56 | + String s = doPost("https://area-qhd-api.healthbaby.com.cn:18019/findSyncData", new HashMap<String, String>(), "utf-8"); | |
57 | + long end = System.currentTimeMillis(); | |
58 | + System.out.print(end -start); | |
59 | + System.out.println(s); | |
60 | + } | |
58 | 61 | } |
platform-operate-api/src/main/resources/spring/applicationContext-quartz.xml
View file @
a6738c1
... | ... | @@ -38,6 +38,24 @@ |
38 | 38 | </bean> |
39 | 39 | |
40 | 40 | |
41 | + <!--危急数据--> | |
42 | + <bean id="crisisJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> | |
43 | + <!-- 要调用的bean --> | |
44 | + <property name="targetObject" ref="qhdfyHisService"></property> | |
45 | + <!-- 要调用的Method --> | |
46 | + <property name="targetMethod" value="syncLisReportTimer"></property> | |
47 | + <!-- 是否并发,false表示 如果发生错误也不影响下一次的调用 --> | |
48 | + <property name="concurrent" value="false"></property> | |
49 | + </bean> | |
50 | + | |
51 | + <!-- 配置一个触发器 --> | |
52 | + <bean id="crisisTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> | |
53 | + <property name="jobDetail" ref="crisisJob"></property> | |
54 | + <property name="cronExpression" value="0 0/3 0 * * ?"></property> | |
55 | + </bean> | |
56 | + | |
57 | + | |
58 | + | |
41 | 59 | <!-- 秦皇岛医院分娩接口--> |
42 | 60 | <bean id="qhdFmTimerWork" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> |
43 | 61 | <!-- 要调用的bean --> |
... | ... | @@ -97,6 +115,7 @@ |
97 | 115 | <ref bean="addSieveJobTrigger"/> |
98 | 116 | <ref bean="correctSieveOrderTrigger"/> |
99 | 117 | <ref bean="qhdFmTrigger"/> |
118 | + <!--<ref bean="crisisTrigger"/>--> | |
100 | 119 | </list> |
101 | 120 | </property> |
102 | 121 | </bean> |