Commit b1327e74cf3bdf48970cd2c10eae567d0994ac16

Authored by liquanyu
1 parent 022adb8d41

update code

Showing 1 changed file with 125 additions and 39 deletions

platform-operate-api/src/main/java/com/lyms/hospitalapi/Nczxyy/NczxyyLisService.java View file @ b1327e7
... ... @@ -2,12 +2,20 @@
2 2  
3 3 import com.alibaba.fastjson.JSONObject;
4 4 import com.lyms.hospitalapi.pojo.*;
  5 +import com.lyms.platform.common.enums.RiskDefaultTypeEnum;
  6 +import com.lyms.platform.common.enums.YnEnums;
5 7 import com.lyms.platform.common.utils.DateUtil;
  8 +import com.lyms.platform.common.utils.ExceptionUtils;
  9 +import com.lyms.platform.operate.web.result.RiskReportResult;
6 10 import com.lyms.platform.operate.web.utils.HttpClientUtil;
  11 +import com.lyms.platform.pojo.BasicConfig;
  12 +import com.lyms.platform.query.PatientsQuery;
7 13 import org.springframework.stereotype.Service;
8 14  
  15 +import java.text.DecimalFormat;
9 16 import java.text.SimpleDateFormat;
10 17 import java.util.*;
  18 +import java.util.concurrent.*;
11 19  
12 20 /**
13 21 * Created by Administrator on 2017/5/17.
... ... @@ -15,6 +23,9 @@
15 23 @Service("nczxyyLisService")
16 24 public class NczxyyLisService {
17 25  
  26 +
  27 + private static ExecutorService pool = Executors.newFixedThreadPool(3);
  28 +
18 29 public List<CheckByDate> queryCheckListupdate(String cardNo,int ftype){
19 30  
20 31 if(1==ftype){
... ... @@ -221,7 +232,6 @@
221 232 }
222 233  
223 234 public static List<CheckResponse> queryLisCheckList(String cardNo){
224   - SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd ");
225 235 List<CheckResponse> result = new ArrayList<>();
226 236 Calendar c = Calendar.getInstance();
227 237 SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
... ... @@ -230,7 +240,7 @@
230 240 c.add(Calendar.YEAR, -1);
231 241 Date date = c.getTime();
232 242 String StartDate=df.format(date);
233   - String url="http://mihp.nc120.cn/PlatformService/platform/api";
  243 + final String url="http://mihp.nc120.cn/PlatformService/platform/api";
234 244 String js="{\"api_id\":\"800010\",\"EndDate\":\""+EndDate+"\",\"active_key\":\"LYMS\",\"StartDate\":\""+StartDate+"\",\"user_token\":\"LYMS\",\"operator_id\":\"YD_WX\",\"CardNo\":\""+cardNo+"\"}";
235 245 Map<String,Object> map1=new HashMap<String,Object>();
236 246 map1.put("result", HttpClientUtil.doPostHTTP(url, js));
237 247  
238 248  
239 249  
240 250  
241 251  
242 252  
... ... @@ -238,50 +248,126 @@
238 248 Nczxyy2 nczxyy2=null;
239 249 nczxyy2=(Nczxyy2)json.getObject("result", Nczxyy2.class);
240 250 if(nczxyy2.getList()!=null && !nczxyy2.getList().isEmpty()) {
241   - for (int i = 0; i < nczxyy2.getList().size(); i++) {
242   - String DetailId = nczxyy2.getList().get(i).getId();
243   - String Str = "{\"api_id\":\"800020\",\"active_key\":\"LYMS\",\"user_token\":\"LYMS\",\"operator_id\":\"YD_WX\",\"DetailId\":\"" + DetailId + "\"}";
244   - map1.put("result1", HttpClientUtil.doPostHTTP(url, Str));
245   - JSONObject json1 = new JSONObject(map1);
246   - NczxyyXQ2 nczxyyxq2 = null;
247   - nczxyyxq2 = (NczxyyXQ2) json1.getObject("result1", NczxyyXQ2.class);
248   - if (nczxyyxq2 != null) {
249   - try {
250   - CheckResponse CheckResponse = new CheckResponse();
251   - CheckResponse.setHospitalName("四川省南充市中心医院");
252   - CheckResponse.setName(nczxyyxq2.getData().get姓名());
253   - CheckResponse.setModified(formatter.parse(nczxyyxq2.getData().get报告时间()));
254   - CheckResponse.setType(1);
255   - CheckResponse.setDoctor(nczxyyxq2.getData().get申请医师());
256   - CheckResponse.setTitle(nczxyyxq2.getData().get申请项目());
257   - CheckResponse.setAge(nczxyyxq2.getData().get年龄());
258   - CheckResponse.setApplyDate(formatter.parse(nczxyyxq2.getData().get申请时间()));
259   - CheckResponse.setApplyDateStr(nczxyyxq2.getData().get申请时间());
260   - CheckResponse.setCheckDept(nczxyyxq2.getData().get科室());
261   - CheckResponse.setSex(nczxyyxq2.getData().get性别());
262   - List<CheckItemResponse> itemlist = new ArrayList<CheckItemResponse>();
263   - CheckResponse.setItemList(itemlist);
264   - for (int j = 0; j < nczxyyxq2.getData().getLisPatResults().size(); j++) {
265   - CheckItemResponse item = new CheckItemResponse();
266   - item.setName(nczxyyxq2.getData().getLisPatResults().get(j).get名称());
267   - item.setCode(nczxyyxq2.getData().getLisPatResults().get(j).get项目号());
268   - item.setRefer(nczxyyxq2.getData().getLisPatResults().get(j).get临界值());
269   - item.setResult(nczxyyxq2.getData().getLisPatResults().get(j).get检验值());
270   - item.setUnit(nczxyyxq2.getData().getLisPatResults().get(j).get单位());
271   - item.setSpecial(nczxyyxq2.getData().getLisPatResults().get(j).get结论());
272   - itemlist.add(item);
  251 + int batchSize = 1;
  252 + int end = 0;
  253 + List<Future> futures = new ArrayList<>();
  254 + for (int i = 0; i < nczxyy2.getList().size(); i += batchSize) {
  255 + end = (end + batchSize);
  256 + if (end > nczxyy2.getList().size()) {
  257 + end = nczxyy2.getList().size();
  258 + }
  259 + final List<Nczxyy1> lises = nczxyy2.getList().subList(i, end);
  260 + Callable callable = new Callable() {
  261 + @Override
  262 + public List<CheckResponse> call() throws Exception {
  263 + List<CheckResponse> result = new ArrayList<>();
  264 + for (Nczxyy1 nc : lises) {
  265 +
  266 + Map<String,Object> map1=new HashMap<String,Object>();
  267 + String DetailId = nc.getId();
  268 + String Str = "{\"api_id\":\"800020\",\"active_key\":\"LYMS\",\"user_token\":\"LYMS\",\"operator_id\":\"YD_WX\",\"DetailId\":\"" + DetailId + "\"}";
  269 + map1.put("result1", HttpClientUtil.doPostHTTP(url, Str));
  270 + JSONObject json1 = new JSONObject(map1);
  271 + NczxyyXQ2 nczxyyxq2 = null;
  272 + nczxyyxq2 = (NczxyyXQ2) json1.getObject("result1", NczxyyXQ2.class);
  273 + if (nczxyyxq2 != null) {
  274 + try {
  275 + CheckResponse CheckResponse = new CheckResponse();
  276 + CheckResponse.setHospitalName("四川省南充市中心医院");
  277 + CheckResponse.setName(nczxyyxq2.getData().get姓名());
  278 + CheckResponse.setModified(DateUtil.parseYMD(nczxyyxq2.getData().get报告时间()));
  279 + CheckResponse.setType(1);
  280 + CheckResponse.setDoctor(nczxyyxq2.getData().get申请医师());
  281 + CheckResponse.setTitle(nczxyyxq2.getData().get申请项目());
  282 + CheckResponse.setAge(nczxyyxq2.getData().get年龄());
  283 + CheckResponse.setApplyDate(DateUtil.parseYMD(nczxyyxq2.getData().get申请时间()));
  284 + CheckResponse.setApplyDateStr(nczxyyxq2.getData().get申请时间());
  285 + CheckResponse.setCheckDept(nczxyyxq2.getData().get科室());
  286 + CheckResponse.setSex(nczxyyxq2.getData().get性别());
  287 + List<CheckItemResponse> itemlist = new ArrayList<CheckItemResponse>();
  288 + CheckResponse.setItemList(itemlist);
  289 + for (int j = 0; j < nczxyyxq2.getData().getLisPatResults().size(); j++) {
  290 + CheckItemResponse item = new CheckItemResponse();
  291 + item.setName(nczxyyxq2.getData().getLisPatResults().get(j).get名称());
  292 + item.setCode(nczxyyxq2.getData().getLisPatResults().get(j).get项目号());
  293 + item.setRefer(nczxyyxq2.getData().getLisPatResults().get(j).get临界值());
  294 + item.setResult(nczxyyxq2.getData().getLisPatResults().get(j).get检验值());
  295 + item.setUnit(nczxyyxq2.getData().getLisPatResults().get(j).get单位());
  296 + item.setSpecial(nczxyyxq2.getData().getLisPatResults().get(j).get结论());
  297 + itemlist.add(item);
  298 + }
  299 + result.add(CheckResponse);
  300 + } catch (Exception e) {
  301 + e.printStackTrace();
  302 + }
  303 + }
  304 +
273 305 }
274   - result.add(CheckResponse);
275   - } catch (Exception e) {
276   - e.printStackTrace();
277   - }
278 306  
  307 + return result;
  308 + }
  309 + };
  310 + Future f = pool.submit(callable);
  311 + futures.add(f);
  312 + }
  313 + for (Future f : futures) {
  314 + try {
  315 + result.addAll((List) f.get(30, TimeUnit.SECONDS));
  316 + } catch (Exception e) {
  317 + ExceptionUtils.catchException(e, "queryLisCheckList nc lis.");
279 318 }
280   -
281 319 }
  320 +
282 321 }
  322 +// for (int i = 0; i < nczxyy2.getList().size(); i++) {
  323 +// String DetailId = nczxyy2.getList().get(i).getId();
  324 +// String Str = "{\"api_id\":\"800020\",\"active_key\":\"LYMS\",\"user_token\":\"LYMS\",\"operator_id\":\"YD_WX\",\"DetailId\":\"" + DetailId + "\"}";
  325 +// map1.put("result1", HttpClientUtil.doPostHTTP(url, Str));
  326 +// JSONObject json1 = new JSONObject(map1);
  327 +// NczxyyXQ2 nczxyyxq2 = null;
  328 +// nczxyyxq2 = (NczxyyXQ2) json1.getObject("result1", NczxyyXQ2.class);
  329 +// if (nczxyyxq2 != null) {
  330 +// try {
  331 +// CheckResponse CheckResponse = new CheckResponse();
  332 +// CheckResponse.setHospitalName("四川省南充市中心医院");
  333 +// CheckResponse.setName(nczxyyxq2.getData().get姓名());
  334 +// CheckResponse.setModified(formatter.parse(nczxyyxq2.getData().get报告时间()));
  335 +// CheckResponse.setType(1);
  336 +// CheckResponse.setDoctor(nczxyyxq2.getData().get申请医师());
  337 +// CheckResponse.setTitle(nczxyyxq2.getData().get申请项目());
  338 +// CheckResponse.setAge(nczxyyxq2.getData().get年龄());
  339 +// CheckResponse.setApplyDate(formatter.parse(nczxyyxq2.getData().get申请时间()));
  340 +// CheckResponse.setApplyDateStr(nczxyyxq2.getData().get申请时间());
  341 +// CheckResponse.setCheckDept(nczxyyxq2.getData().get科室());
  342 +// CheckResponse.setSex(nczxyyxq2.getData().get性别());
  343 +// List<CheckItemResponse> itemlist = new ArrayList<CheckItemResponse>();
  344 +// CheckResponse.setItemList(itemlist);
  345 +// for (int j = 0; j < nczxyyxq2.getData().getLisPatResults().size(); j++) {
  346 +// CheckItemResponse item = new CheckItemResponse();
  347 +// item.setName(nczxyyxq2.getData().getLisPatResults().get(j).get名称());
  348 +// item.setCode(nczxyyxq2.getData().getLisPatResults().get(j).get项目号());
  349 +// item.setRefer(nczxyyxq2.getData().getLisPatResults().get(j).get临界值());
  350 +// item.setResult(nczxyyxq2.getData().getLisPatResults().get(j).get检验值());
  351 +// item.setUnit(nczxyyxq2.getData().getLisPatResults().get(j).get单位());
  352 +// item.setSpecial(nczxyyxq2.getData().getLisPatResults().get(j).get结论());
  353 +// itemlist.add(item);
  354 +// }
  355 +// result.add(CheckResponse);
  356 +// } catch (Exception e) {
  357 +// e.printStackTrace();
  358 +// }
  359 +//
  360 +// }
  361 +//
  362 +// }
283 363  
284 364 return result;
  365 + }
  366 +
  367 + public static void main(String[] args)
  368 + {
  369 + List<CheckResponse> list = queryLisCheckList("1002332625");
  370 + System.out.println(list.size());
285 371 }
286 372 }