Commit 285cc36cd3cf9fe11e97a8730a06fcb58000a295
1 parent
bcbca346f5
Exists in
master
and in
8 other branches
add import test
Showing 4 changed files with 159 additions and 0 deletions
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/SyncDataService.java
- 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/service/SyncDataTaskService.java
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/SyncDataService.java
View file @
285cc36
platform-operate-api/src/main/java/com/lyms/hospitalapi/qhdfy/QhdfyHisService.java
View file @
285cc36
1 | 1 | package com.lyms.hospitalapi.qhdfy; |
2 | 2 | |
3 | +import com.lyms.hospitalapi.pojo.CheckItemResponse; | |
4 | +import com.lyms.hospitalapi.pojo.CheckResponse; | |
5 | +import com.lyms.hospitalapi.pojo.LisCheckInfo; | |
6 | +import com.lyms.hospitalapi.pojo.LisCheckResult; | |
3 | 7 | import com.lyms.platform.biz.dal.AssayConfigDao; |
4 | 8 | import com.lyms.platform.biz.param.AssayConfigQuery; |
5 | 9 | import com.lyms.platform.biz.service.AssayConfigService; |
... | ... | @@ -15,6 +19,7 @@ |
15 | 19 | import org.apache.commons.dbutils.DbUtils; |
16 | 20 | import org.apache.commons.dbutils.QueryRunner; |
17 | 21 | import org.apache.commons.dbutils.handlers.BeanListHandler; |
22 | +import org.apache.commons.lang.StringUtils; | |
18 | 23 | import org.joda.time.DateTime; |
19 | 24 | import org.springframework.beans.factory.annotation.Autowired; |
20 | 25 | import org.springframework.stereotype.Service; |
... | ... | @@ -126,6 +131,61 @@ |
126 | 131 | lisCrisisItemService.addLisCrisisItem(crisisItem); |
127 | 132 | } |
128 | 133 | } |
134 | + } | |
135 | + } | |
136 | + } | |
137 | + } | |
138 | + DbUtils.closeQuietly(conn); | |
139 | + return result; | |
140 | + } catch (SQLException e) { | |
141 | + DbUtils.closeQuietly(conn); | |
142 | + e.printStackTrace(); | |
143 | + return result; | |
144 | + } | |
145 | + } | |
146 | + return result; | |
147 | + } | |
148 | + | |
149 | + public List<CheckResponse> queryLisCheckList(String cardNo) { | |
150 | + List<CheckResponse> result = new ArrayList<>(); | |
151 | + if (StringUtils.isNotBlank(cardNo)) { | |
152 | + Connection conn = ConnTools.makeLisConnection(); | |
153 | + QueryRunner queryRunner = new QueryRunner(); | |
154 | + try { | |
155 | + List<LisCheckInfo> list = queryRunner.query(conn, "select * from lis_check_info where P_CARD = '"+cardNo+"'", new BeanListHandler<LisCheckInfo>(LisCheckInfo.class)); | |
156 | + if (list.size() > 0) { | |
157 | + for (LisCheckInfo info:list) { | |
158 | + if (StringUtils.isNotBlank(info.getP_APPLICATIONNUM())) { | |
159 | + List<LisCheckResult> resultList = queryRunner.query(conn, "select * from lis_check_result where P_APPLICATIONNUM = '"+info.getP_APPLICATIONNUM()+"'", new BeanListHandler<LisCheckResult>(LisCheckResult.class)); | |
160 | + if (resultList != null && resultList.size() > 0) { | |
161 | + CheckResponse check = new CheckResponse(); | |
162 | + check.setModified(DateUtil.parseYMDHMS(info.getMODIFIED())); | |
163 | + check.setType(1); | |
164 | + check.setName(info.getP_NAME()); | |
165 | + check.setTitle(info.getP_TITLE()); | |
166 | + check.setAge(info.getP_AGE()); | |
167 | + check.setApplyDate(DateUtil.parseYMDHMS(info.getP_CHECKTIME())); | |
168 | + check.setApplyDateStr(DateUtil.getyyyy_MM_dd(DateUtil.parseYMDHMS(info.getP_CHECKTIME()))); | |
169 | + check.setCheckDept(info.getP_CHECKDEPARTNAME()); | |
170 | + check.setDoctor(info.getP_APPLATIONDOCNAME()); | |
171 | + if ("1".equals(info.getP_SEX())) { | |
172 | + check.setSex("็ท"); | |
173 | + } else if ("2".equals(info.getP_SEX())) { | |
174 | + check.setSex("ๅฅณ"); | |
175 | + } | |
176 | + List<CheckItemResponse> itemList = new ArrayList<>(); | |
177 | + check.setItemList(itemList); | |
178 | + for (LisCheckResult checkItem:resultList) { | |
179 | + CheckItemResponse item = new CheckItemResponse(); | |
180 | + item.setName(checkItem.getP_ITEMNAME()); | |
181 | + item.setCode(checkItem.getP_ITEMCODE()); | |
182 | + item.setRefer(checkItem.getP_REFERENCEVALUE()); | |
183 | + item.setResult(checkItem.getP_ITEMRESULT()); | |
184 | + item.setUnit(checkItem.getP_UNIT()); | |
185 | + item.setSpecial(checkItem.getP_HIGHANDLOWMARK()); | |
186 | + itemList.add(item); | |
187 | + } | |
188 | + result.add(check); | |
129 | 189 | } |
130 | 190 | } |
131 | 191 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/SyncDataController.java
View file @
285cc36
1 | +package com.lyms.platform.operate.web.controller; | |
2 | + | |
3 | +import com.lyms.platform.biz.service.SyncDataService; | |
4 | +import com.lyms.platform.common.base.BaseController; | |
5 | +import com.lyms.platform.common.pojo.SyncDataModel; | |
6 | +import com.lyms.platform.common.utils.JsonUtil; | |
7 | +import com.lyms.platform.query.SyncDataQuery; | |
8 | +import org.apache.commons.lang.StringUtils; | |
9 | +import org.springframework.beans.factory.annotation.Autowired; | |
10 | +import org.springframework.stereotype.Controller; | |
11 | +import org.springframework.web.bind.annotation.RequestMapping; | |
12 | +import org.springframework.web.bind.annotation.RequestMethod; | |
13 | + | |
14 | +import javax.servlet.http.HttpServletResponse; | |
15 | +import java.util.List; | |
16 | + | |
17 | +/** | |
18 | + * Created by riecard on 2016/10/20. | |
19 | + */ | |
20 | +@Controller | |
21 | +public class SyncDataController extends BaseController { | |
22 | + | |
23 | + @Autowired | |
24 | + private SyncDataService syncDataService; | |
25 | + | |
26 | + @RequestMapping(value = "/findSyncData", method = RequestMethod.POST) | |
27 | + public void findSyncData(HttpServletResponse response) { | |
28 | + SyncDataQuery syncDataQuery = new SyncDataQuery(); | |
29 | + syncDataQuery.setNeed("y"); | |
30 | + syncDataQuery.setLimit(100); | |
31 | + syncDataQuery.setStatus(1); | |
32 | + List<SyncDataModel> list = syncDataService.querySyncData(syncDataQuery); | |
33 | + writeJson(response, JsonUtil.array2JsonString(list)); | |
34 | + } | |
35 | + | |
36 | + @RequestMapping(value = "/updateSyncData", method = RequestMethod.POST) | |
37 | + public void updateSyncData(HttpServletResponse response, String ids) { | |
38 | + if (StringUtils.isNotBlank(ids)) { | |
39 | + String[] array = ids.split(","); | |
40 | + for (String id:array) { | |
41 | + SyncDataModel model = new SyncDataModel(); | |
42 | + model.setId(id); | |
43 | + model.setStatus(0); | |
44 | + syncDataService.updateSyncData(model); | |
45 | + } | |
46 | + writeString(response,"updateSyncData success"); | |
47 | + } | |
48 | + writeString(response, "updateSyncData fail"); | |
49 | + } | |
50 | + | |
51 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/SyncDataTaskService.java
View file @
285cc36
1 | 1 | package com.lyms.platform.operate.web.service; |
2 | 2 | |
3 | +import com.lyms.platform.biz.service.MongoSyncService; | |
3 | 4 | import com.lyms.platform.biz.service.SyncDataService; |
4 | 5 | import com.lyms.platform.common.pojo.SyncDataModel; |
6 | +import com.lyms.platform.common.utils.JsonUtil; | |
7 | +import com.lyms.platform.common.utils.MessageUtil; | |
5 | 8 | import com.lyms.platform.common.utils.MongoSyncUtil; |
6 | 9 | import com.lyms.platform.query.SyncDataQuery; |
10 | +import org.apache.commons.httpclient.HttpClient; | |
11 | +import org.apache.commons.httpclient.NameValuePair; | |
12 | +import org.apache.commons.httpclient.methods.PostMethod; | |
7 | 13 | import org.springframework.beans.factory.annotation.Autowired; |
8 | 14 | import org.springframework.stereotype.Service; |
9 | 15 | |
... | ... | @@ -19,6 +25,9 @@ |
19 | 25 | @Autowired |
20 | 26 | private SyncDataService syncDataService; |
21 | 27 | |
28 | + @Autowired | |
29 | + private MongoSyncService mongoSyncService; | |
30 | + | |
22 | 31 | public void syncData() { |
23 | 32 | SyncDataQuery query = new SyncDataQuery(); |
24 | 33 | query.setStatus(1); |
... | ... | @@ -31,6 +40,43 @@ |
31 | 40 | model.setModified(new Date()); |
32 | 41 | syncDataService.updateSyncData(model); |
33 | 42 | } |
43 | + } | |
44 | + } | |
45 | + | |
46 | + public void qhdfySyncData() { | |
47 | + try { | |
48 | + HttpClient client = new HttpClient(); | |
49 | + client.getHttpConnectionManager().getParams().setConnectionTimeout(10000); | |
50 | + client.getHttpConnectionManager().getParams().setSoTimeout(10000); | |
51 | + PostMethod post = new MessageUtil.UTF8PostMethod("http://121.22.16.246:18018/findSyncData"); | |
52 | + client.executeMethod(post); | |
53 | + int statusCode = post.getStatusCode(); | |
54 | + String json = post.getResponseBodyAsString(); | |
55 | + System.out.println(json); | |
56 | + post.releaseConnection(); | |
57 | + StringBuffer ids = new StringBuffer(); | |
58 | + if (200 == statusCode) { | |
59 | + List<SyncDataModel> list = JsonUtil.toList(json,SyncDataModel.class); | |
60 | + for (SyncDataModel model:list) { | |
61 | + boolean boo = mongoSyncService.syncData(model.getAction(),model.getDataId(), model.getClassName(), model.getJsonData()); | |
62 | + if (boo) { | |
63 | + ids.append(model.getId()); | |
64 | + ids.append(","); | |
65 | + } | |
66 | + } | |
67 | + if (ids.length() > 0) { | |
68 | + PostMethod post1 = new MessageUtil.UTF8PostMethod("http://121.22.16.246:18018/updateSyncData"); | |
69 | + NameValuePair[] pairs = { | |
70 | + new NameValuePair("ids", ids.toString()), | |
71 | + }; | |
72 | + post1.setRequestBody(pairs); | |
73 | + client.executeMethod(post1); | |
74 | + System.out.println(post1.getResponseBodyAsString()); | |
75 | + post.releaseConnection(); | |
76 | + } | |
77 | + } | |
78 | + } catch (Exception e) { | |
79 | + e.printStackTrace(); | |
34 | 80 | } |
35 | 81 | } |
36 | 82 |