Commit 3c5eb986572e3a9909859e5d8526a10f2db61c0a

Authored by wtt
1 parent e5f07457ee

3.0、2.0建档代码和历史建档同步

Showing 3 changed files with 192 additions and 133 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java View file @ 3c5eb98
... ... @@ -22,7 +22,7 @@
22 22 import com.lyms.platform.operate.web.service.ITrackDownService;
23 23 import com.lyms.platform.operate.web.utils.JdbcUtil;
24 24 import com.lyms.platform.operate.web.worker.CorrectDataWorker;
25   -import com.lyms.platform.operate.web.worker.CorrectDataWorker2;
  25 +import com.lyms.platform.operate.web.worker.SyncV2HistoryWorkerx;
26 26 import com.lyms.platform.permission.dao.master.CouponMapper;
27 27 import com.lyms.platform.permission.model.Organization;
28 28 import com.lyms.platform.permission.model.OrganizationQuery;
... ... @@ -46,6 +46,7 @@
46 46 import org.springframework.data.mongodb.core.query.Query;
47 47 import org.springframework.http.HttpHeaders;
48 48 import org.springframework.http.MediaType;
  49 +import org.springframework.http.ResponseEntity;
49 50 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
50 51 import org.springframework.stereotype.Component;
51 52 import org.springframework.web.client.RestTemplate;
... ... @@ -58,6 +59,7 @@
58 59 import java.sql.*;
59 60 import java.util.*;
60 61 import java.util.Date;
  62 +import java.util.concurrent.Future;
61 63 import java.util.concurrent.atomic.AtomicLong;
62 64  
63 65 /**
... ... @@ -214,7 +216,7 @@
214 216 patientsQuery.setCardNo(yunRequest.getPregnantCertificateNum());
215 217 //判断该身份证号码是否有孕妇建档 在该医院
216 218 List<Patients> patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery);
217   - if (CollectionUtils.isNotEmpty(patients) && patients.get(0).getLastMenses().getTime() < DateUtil.parseYMD(yunRequest.getLastMenstrualPeriod()).getTime()) {
  219 + if (CollectionUtils.isNotEmpty(patients) && patients.get(0).getLastMenses().getTime() < DateUtil.parseYMD(yunRequest.getLastMenstrualPeriod()).getTime()) {
218 220 br.setErrorcode(ErrorCodeConstants.DATA_EXIST);
219 221 br.setErrormsg("该身份证在医院已经建档");
220 222 return br;
... ... @@ -225,7 +227,7 @@
225 227 patientsQuery.setPhone(yunRequest.getPregnantPhone());
226 228 //判断该手机号码在 孕期内有没有建档
227 229 List<Patients> patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery);
228   - if (CollectionUtils.isNotEmpty(patients) && patients.get(0).getLastMenses().getTime() < DateUtil.parseYMD(yunRequest.getLastMenstrualPeriod()).getTime()) {
  230 + if (CollectionUtils.isNotEmpty(patients) && patients.get(0).getLastMenses().getTime() < DateUtil.parseYMD(yunRequest.getLastMenstrualPeriod()).getTime()) {
229 231 br.setErrorcode(ErrorCodeConstants.DATA_EXIST);
230 232 br.setErrormsg("该手机号码已经建档");
231 233 return br;
... ... @@ -239,7 +241,7 @@
239 241 patientsQuery.setVcCardNo(yunRequest.getVcCardNo());
240 242 patientsQuery.setHospitalId(yunRequest.getHospitalId());
241 243 List<Patients> patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery);
242   - if (CollectionUtils.isNotEmpty(patients) && patients.get(0).getLastMenses().getTime() < DateUtil.parseYMD(yunRequest.getLastMenstrualPeriod()).getTime()) {
  244 + if (CollectionUtils.isNotEmpty(patients) && patients.get(0).getLastMenses().getTime() < DateUtil.parseYMD(yunRequest.getLastMenstrualPeriod()).getTime()) {
243 245 br.setErrorcode(ErrorCodeConstants.DATA_EXIST);
244 246 br.setErrormsg("该就诊卡号在该医院已经建档");
245 247 return br;
246 248  
... ... @@ -420,12 +422,11 @@
420 422 }
421 423 //秦皇岛建档获取分娩信息
422 424 if ("4".equals(HIS_VERSION) && "216".equals(tempP.getHospitalId())) {
423   - Date startDate = DateUtil.addMonth(new Date(),-3);
  425 + Date startDate = DateUtil.addMonth(new Date(), -3);
424 426 Date endDate = DateUtil.addDay(new Date(), 1);
425 427 qhdfyFmService.syncByCardNo(DateUtil.getyyyy_MM_dd(startDate), DateUtil.getyyyy_MM_dd(endDate), tempP.getCardNo());
426 428 }
427   - if (filePath != null && filePath.getId() == null)
428   - {
  429 + if (filePath != null && filePath.getId() == null) {
429 430 filePath.setPatientId(tempP.getId());
430 431 yunBookbuildingService.addFilePath(filePath);
431 432 }
432 433  
433 434  
434 435  
435 436  
... ... @@ -433,27 +434,24 @@
433 434 ArchiveDataQuery query = new ArchiveDataQuery();
434 435 query.setIdCard(tempP.getCardNo());
435 436  
436   - List<ArchiveData> list = archiveDataServicer.query(query, Sort.Direction.DESC,"created");
  437 + List<ArchiveData> list = archiveDataServicer.query(query, Sort.Direction.DESC, "created");
437 438  
438 439 ArchiveData archiveData = new ArchiveData();
439 440 archiveData.setBuildDate(new Date());
440 441 archiveData.setId(tempP.getHospitalId() + ":" + tempP.getCardNo());
441 442 archiveDataServicer.update(archiveData);
442 443  
443   - if (CollectionUtils.isNotEmpty(list))
444   - {
  444 + if (CollectionUtils.isNotEmpty(list)) {
445 445 Patients patients = new Patients();
446   - if (list.get(0).getAssistUserId() != null && tempP.getId() != null)
447   - {
  446 + if (list.get(0).getAssistUserId() != null && tempP.getId() != null) {
448 447 patients.setAssistUserId(list.get(0).getAssistUserId());
449   - yunBookbuildingService.updatePregnant(patients,tempP.getId());
  448 + yunBookbuildingService.updatePregnant(patients, tempP.getId());
450 449 }
451 450 }
452 451 }
453 452 });
454 453  
455   - if (yunRequest != null)
456   - {
  454 + if (yunRequest != null) {
457 455 deleteImg(yunRequest);
458 456 }
459 457  
460 458  
... ... @@ -718,11 +716,12 @@
718 716  
719 717 /**
720 718 * 保存/更新数据成功后,将数据同步到2.0系统中
721   - * @param patients
722   - * @param id 更新保存标识
723   - * @param userId userId
  719 + *
  720 + * @param patients
  721 + * @param id 更新保存标识
  722 + * @param userId userId
724 723 */
725   - private void syncDataToV2(final Patients patients, String id, Integer userId){
  724 + private void syncDataToV2(final Patients patients, String id, Integer userId) {
726 725 try {
727 726 Thread syncThread = new Thread(new Runnable() {
728 727 @Override
729 728  
730 729  
... ... @@ -731,14 +730,17 @@
731 730 HttpHeaders headers = new HttpHeaders();
732 731 headers.setContentType(MediaType.APPLICATION_JSON);
733 732 JSONObject jsonObject = getQueryParam(patients);
734   - String result = restTemplate.postForObject(syncToV2Url + "/v3/bookbuilding/savaOrUpdate", jsonObject, String.class);
735   - logger.info("建档数据同步到2.0系统,返回结果: {}", result);
  733 +// String result = restTemplate.postForObject(syncToV2Url + "/v3/bookbuilding/savaOrUpdate", jsonObject, String.class);
  734 +// logger.info("建档数据同步到2.0系统,返回结果: {}", result);
  735 + Map<String, JSONObject> map = new HashMap<>();
  736 + map.put("jsonObject", jsonObject);
  737 + ResponseEntity<String> responseEntity = restTemplate.getForEntity(syncToV2Url +"/GetPatient.asmx/GetPatientInfo?data={jsonObject}", String.class, map);
736 738 }
737 739 });
738 740 syncThread.start();
739   - }catch (Exception e){
  741 + } catch (Exception e) {
740 742 e.printStackTrace();
741   - logger.error("建档数据同步到2.0系统失败",e);
  743 + logger.error("建档数据同步到2.0系统失败", e);
742 744 }
743 745 }
744 746  
745 747  
746 748  
... ... @@ -792,13 +794,13 @@
792 794 jsonObject.put("P_HOSPITALID", "todo");//建党机构
793 795 jsonObject.put("P_ISVIP", patients.getBookbuildingDate());//建档时间
794 796  
795   - if(patients.getReqHusband()!=null){//丈夫信息是否必须
796   - if(patients.getReqHusband()){
  797 + if (patients.getReqHusband() != null) {//丈夫信息是否必须
  798 + if (patients.getReqHusband()) {
797 799 jsonObject.put("P_HUSBANDUNPROVIDE", 1);
798   - }else if(!patients.getReqHusband()){
  800 + } else if (!patients.getReqHusband()) {
799 801 jsonObject.put("P_HUSBANDUNPROVIDE", 2);
800 802 }
801   - }else {
  803 + } else {
802 804 jsonObject.put("P_HUSBANDUNPROVIDE", "");
803 805 }
804 806  
805 807  
806 808  
... ... @@ -1026,18 +1028,14 @@
1026 1028 updateAntExLastMenses(patients.getLastMenses(), patients.getPid(), patients.getBookbuildingDate());
1027 1029  
1028 1030 FilePathModel filePath = yunRequest.getFilePath();
1029   - if (filePath != null && filePath.getId() != null)
1030   - {
  1031 + if (filePath != null && filePath.getId() != null) {
1031 1032 yunBookbuildingService.updateFilePath(filePath);
1032   - }
1033   - else if (filePath != null)
1034   - {
  1033 + } else if (filePath != null) {
1035 1034 filePath.setPatientId(patient.getId());
1036 1035 yunBookbuildingService.addFilePath(filePath);
1037 1036 }
1038 1037  
1039   - if (yunRequest != null)
1040   - {
  1038 + if (yunRequest != null) {
1041 1039 deleteImg(yunRequest);
1042 1040 }
1043 1041  
... ... @@ -1049,8 +1047,6 @@
1049 1047 }
1050 1048  
1051 1049  
1052   -
1053   -
1054 1050 /**
1055 1051 * 修改初诊 复诊的末次月经字段
1056 1052 *
... ... @@ -1379,7 +1375,7 @@
1379 1375 }
1380 1376 }
1381 1377  
1382   - if(StringUtils.isNotEmpty(yunRequest.getHusbandBirth())){//如果前端传入的丈夫生日,则用传入的数据
  1378 + if (StringUtils.isNotEmpty(yunRequest.getHusbandBirth())) {//如果前端传入的丈夫生日,则用传入的数据
1383 1379 patient.setHusbandBirth(DateUtil.parseYMD(yunRequest.getHusbandBirth()));
1384 1380 }
1385 1381  
... ... @@ -1423,7 +1419,7 @@
1423 1419 //建档开通增值服务,以前数据
1424 1420 if (CollectionUtils.isNotEmpty(yunRequest.getSerInfos())) {
1425 1421 for (Map<String, String> serInfo : yunRequest.getSerInfos()) {
1426   - if(serInfo.get("serType")==null){
  1422 + if (serInfo.get("serType") == null) {
1427 1423 continue;
1428 1424 }
1429 1425 //标准服务
... ... @@ -2220,7 +2216,7 @@
2220 2216 public BaseResponse uploadImg(MultipartFile file) {
2221 2217 //如果文件不为空,写入上传路径
2222 2218 BaseObjectResponse objectResponse = new BaseObjectResponse();
2223   - if(file.isEmpty()) {
  2219 + if (file.isEmpty()) {
2224 2220 objectResponse.setErrorcode(ErrorCodeConstants.NO_DATA);
2225 2221 objectResponse.setErrormsg("没有上传数据");
2226 2222 return objectResponse;
2227 2223  
... ... @@ -2228,9 +2224,9 @@
2228 2224 try {
2229 2225  
2230 2226 String imgPath = DateUtil.getYmd(new Date());
2231   - String filename = StringUtils.uuid()+"."+FileUtil.getFileSuffix(file.getOriginalFilename());
  2227 + String filename = StringUtils.uuid() + "." + FileUtil.getFileSuffix(file.getOriginalFilename());
2232 2228  
2233   - File filepath = new File(BASE_IMG_PATH+File.separator+imgPath,filename);
  2229 + File filepath = new File(BASE_IMG_PATH + File.separator + imgPath, filename);
2234 2230 //判断路径是否存在,如果不存在就创建一个
2235 2231 if (!filepath.getParentFile().exists()) {
2236 2232 filepath.getParentFile().mkdirs();
... ... @@ -2241,7 +2237,7 @@
2241 2237 objectResponse.setErrormsg("成功");
2242 2238 return objectResponse;
2243 2239 } catch (IOException e) {
2244   - ExceptionUtils.catchException(e,"上传文件发生异常");
  2240 + ExceptionUtils.catchException(e, "上传文件发生异常");
2245 2241 objectResponse.setErrorcode(ErrorCodeConstants.SYSTEM_ERROR);
2246 2242 objectResponse.setErrormsg(ErrorCodeConstants.SYSTEM_ERROR_DESCRIPTION);
2247 2243 return objectResponse;
2248 2244  
2249 2245  
... ... @@ -2252,24 +2248,19 @@
2252 2248 public void deleteImg(YunBookbuildingAddRequest yunRequest) {
2253 2249 List<String> files = new ArrayList<>();
2254 2250 List<String> delFiles = yunRequest.getDelFiles();
2255   - if (CollectionUtils.isNotEmpty(delFiles))
2256   - {
  2251 + if (CollectionUtils.isNotEmpty(delFiles)) {
2257 2252 files.addAll(delFiles);
2258 2253 }
2259 2254  
2260 2255 List<String> hdelFiles = yunRequest.getHdelFiles();
2261   - if (CollectionUtils.isNotEmpty(hdelFiles))
2262   - {
  2256 + if (CollectionUtils.isNotEmpty(hdelFiles)) {
2263 2257 files.addAll(hdelFiles);
2264 2258 }
2265 2259  
2266   - if (CollectionUtils.isNotEmpty(files))
2267   - {
2268   - for (String filePath : files)
2269   - {
2270   - File filepath = new File(BASE_IMG_PATH+File.separator+filePath);
2271   - if (filepath.exists())
2272   - {
  2260 + if (CollectionUtils.isNotEmpty(files)) {
  2261 + for (String filePath : files) {
  2262 + File filepath = new File(BASE_IMG_PATH + File.separator + filePath);
  2263 + if (filepath.exists()) {
2273 2264 filepath.delete();
2274 2265 }
2275 2266 }
... ... @@ -2281,7 +2272,7 @@
2281 2272  
2282 2273  
2283 2274 BaseObjectResponse objectResponse = new BaseObjectResponse();
2284   - if(!StringUtils.isNotEmpty(imgRequest.getImg())) {
  2275 + if (!StringUtils.isNotEmpty(imgRequest.getImg())) {
2285 2276 objectResponse.setErrorcode(ErrorCodeConstants.NO_DATA);
2286 2277 objectResponse.setErrormsg("没有上传数据");
2287 2278 return objectResponse;
2288 2279  
2289 2280  
2290 2281  
... ... @@ -2289,22 +2280,22 @@
2289 2280 try {
2290 2281  
2291 2282 String imgPath = DateUtil.getYmd(new Date());
2292   - String filename = StringUtils.uuid()+".jpg";
  2283 + String filename = StringUtils.uuid() + ".jpg";
2293 2284  
2294   - String fileAllPath = BASE_IMG_PATH+File.separator+"id_photo"+File.separator+imgPath+File.separator+filename;
  2285 + String fileAllPath = BASE_IMG_PATH + File.separator + "id_photo" + File.separator + imgPath + File.separator + filename;
2295 2286 System.out.println("fileAllPath=" + fileAllPath);
2296 2287 File filepath = new File(fileAllPath);
2297 2288 //判断路径是否存在,如果不存在就创建一个
2298 2289 if (!filepath.getParentFile().exists()) {
2299 2290 filepath.getParentFile().mkdirs();
2300 2291 }
2301   - FileUtil.generateImage(imgRequest.getImg(),fileAllPath);
  2292 + FileUtil.generateImage(imgRequest.getImg(), fileAllPath);
2302 2293 objectResponse.setData("id_photo" + "/" + imgPath + "/" + filename);
2303 2294 objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
2304 2295 objectResponse.setErrormsg("成功");
2305 2296 return objectResponse;
2306 2297 } catch (Exception e) {
2307   - ExceptionUtils.catchException(e,"上传图片发生异常");
  2298 + ExceptionUtils.catchException(e, "上传图片发生异常");
2308 2299 objectResponse.setErrorcode(ErrorCodeConstants.SYSTEM_ERROR);
2309 2300 objectResponse.setErrormsg(ErrorCodeConstants.SYSTEM_ERROR_DESCRIPTION);
2310 2301 return objectResponse;
2311 2302  
... ... @@ -2314,10 +2305,10 @@
2314 2305 /**
2315 2306 * 更新v2.0的数据
2316 2307 *
2317   - * @param id 主键
2318   - * @param param 请求参数
  2308 + * @param id 主键
  2309 + * @param param 请求参数
2319 2310 * @param userId 用户ID
2320   - * @param b 是否同步数据
  2311 + * @param b 是否同步数据
2321 2312 * @return BaseResponse
2322 2313 */
2323 2314 public BaseResponse updatePregnantByIdV2(String id, SyncV2YunBookbuildingRequest param, Integer userId, boolean b) {
2324 2315  
... ... @@ -2329,9 +2320,9 @@
2329 2320 /**
2330 2321 * 保存v2.0的数据
2331 2322 *
2332   - * @param param 主键
  2323 + * @param param 主键
2333 2324 * @param userId 请求参数
2334   - * @param b 是否同步数据
  2325 + * @param b 是否同步数据
2335 2326 * @return BaseResponse
2336 2327 */
2337 2328 public BaseResponse addPregnantBookbuildingV2(SyncV2YunBookbuildingRequest param, Integer userId, boolean b) {
2338 2329  
2339 2330  
2340 2331  
... ... @@ -2347,15 +2338,15 @@
2347 2338 * @param param
2348 2339 * @return
2349 2340 */
2350   - private YunBookbuildingAddRequest getYunBookbuildingAddRequest( SyncV2YunBookbuildingRequest param) {
  2341 + private YunBookbuildingAddRequest getYunBookbuildingAddRequest(SyncV2YunBookbuildingRequest param) {
2351 2342 // TODO 2019/6/7 14:07 dongqing 修改
2352 2343  
2353 2344 //丈夫信息是否必须,映射
2354   - if (param.getReqHusbandInt()==1){
  2345 + if (param.getReqHusbandInt() == 1) {
2355 2346 param.setReqHusband(true);
2356   - }else if(param.getReqHusbandInt()==2){
  2347 + } else if (param.getReqHusbandInt() == 2) {
2357 2348 param.setReqHusband(false);
2358   - }else {
  2349 + } else {
2359 2350 param.setReqHusband(null);
2360 2351 }
2361 2352 param.setHospitalId("todo");
... ... @@ -2368,7 +2359,7 @@
2368 2359 * @param param 请求参数
2369 2360 * @return BaseResponse
2370 2361 */
2371   - public BaseResponse saveByV2(SyncV2HistoryRequest param) {
  2362 + public BaseResponse saveByV2(SyncV2HistoryRequest param) {
2372 2363 //获取2.0历史建档数据
2373 2364 String startTime = param.getStartTime();
2374 2365 String endTime = param.getEndTime();
2375 2366  
2376 2367  
... ... @@ -2378,26 +2369,25 @@
2378 2369 String sql = getSqlString(startTime, endTime);
2379 2370 QueryRunner queryRunner = new QueryRunner(true);
2380 2371 List<SyncV2HistoryRequest> lists = queryRunner.query(connection, sql, new BeanListHandler<SyncV2HistoryRequest>(SyncV2HistoryRequest.class));
2381   - // TODO 2019/6/5 15:39 dongqing 分批次请求保存,明天加上
  2372 + // TODO 2019/6/5 15:39 dongqing 分批次请求保存
2382 2373  
2383   -
2384   - if(CollectionUtils.isNotEmpty(lists)){
2385   - int batchSize = 400;
2386   - int end = 0;
2387   - java.util.concurrent.atomic.AtomicLong counter=new AtomicLong();
2388   - for (int i = 0; i < lists.size(); i += batchSize) {
2389   - end = (end + batchSize);
2390   - if (end > lists.size()) {
2391   - end = lists.size();
2392   - }
2393   -// commonThreadPool.submit(new CorrectDataWorker2(lists.subList(i, end),postReviewService,patientsService,anExService,antExFacade,counter));
2394   - }
2395   -// logger.info("hand hospitalId :" +hospitalId+", update count "+counter.get());
  2374 + for (YunBookbuildingAddRequest list : lists) {
  2375 + list.setHospitalId("216216");
  2376 + list.setBookbuildingDoctor("1000000185");
  2377 + System.out.println("建档孕妇身份证号cardNo=="+list.getPregnantCertificateNum());
  2378 + addPregnantBookbuilding(list, null, false);//Integer.parseInt(list.getBookbuildingDoctor()
2396 2379 }
2397 2380  
2398   -// for (SyncV2HistoryRequest list : lists) {
2399   -// BaseObjectResponse p = addPregnantBookbuilding(list, null, false);//Integer.parseInt(list.getBookbuildingDoctor()
2400   -// System.out.println(p.getData());
  2381 +// if (CollectionUtils.isNotEmpty(lists)) {
  2382 +// int batchSize = 2;
  2383 +// int end = 0;
  2384 +// for (int i = 0; i < lists.size(); i += batchSize) {
  2385 +// end = (end + batchSize);
  2386 +// if (end > lists.size()) {
  2387 +// end = lists.size();
  2388 +// }
  2389 +// Future f = commonThreadPool.submit(new SyncV2HistoryWorkerx(new BookbuildingFacade(), lists.subList(i, end)));
  2390 +// }
2401 2391 // }
2402 2392  
2403 2393 } catch (Exception e) {
2404 2394  
... ... @@ -2417,52 +2407,61 @@
2417 2407 }
2418 2408  
2419 2409 private String getSqlString(String startTime, String endTime) {
2420   - return "SELECT " +
2421   - "P_CARDTYPE as pregnantCertificateTypeId," +//证件类型
2422   - "P_ADDRESSPROVINCE as pregnantCensusProvinceId," +//居住地-省
2423   - "P_ADDRESSCITY as pregnantCensusCityId," +//居住地 -城市
2424   - "P_ADDRESSCOUNTY as pregnantCensusAreaId," +//居住地区
2425   - "P_ADDRESSSTREET as pregnantCensusStreetId," +//居住地 -街道
2426   - "P_COUNTRY as pregnantCountryId," +//国籍
2427   - "P_HUSBANDCOUNTRY as husbandCountryId," +//丈夫国籍
2428   - "P_HUSBANDCARDTYPE as husbandCertificateTypeId," +//丈夫证件类型
2429   - "P_NATION as pregnantNationId," +//民族
2430   - "P_HUSBANDNATION as husbandNationId," +//丈夫民族
2431   - "P_DOCID as bookbuildingDoctor," +//建档医生
2432   - "P_CARDNO as pregnantCertificateNum," +//证件号
2433   - "P_CARDNO as pregnantNationId," +// 孕妇民族
2434   - "P_CARDNO as pregnantPhone," +// 孕妇手机号
2435   - "P_RRPROVINCE as pregnantLiveProvinceId," +//户口——省
2436   - "P_RRCITY as pregnantLiveCityId," +//户口——市
2437   - "P_RRCOUNTY as pregnantLiveAreaId," +//户口——区县
2438   - "P_RRSTREET as pregnantLiveStreetId," +//户口——街道
2439   - "P_POSTPARTUMPROVINCE as childbirthProvinceId," +//产后——省
2440   - "P_POSTPARTUMCITY as childbirthCityId," +//产后——市
2441   - "P_POSTPARTUMCOUNTY as childbirthAreaId," +//产后——区县
2442   - "P_POSTPARTUMSTREET as childbirthStreetId," +//产后——街道
2443   - "P_HUSBANDNAME as husbandName," +//丈夫姓名
2444   - "P_HUSBANDCARDNO as husbandCertificateNum," +//丈夫证件号码
2445   - "P_HUSBANDBIRTHDAY as husbandBirth," +//丈夫出生日期
2446   - "P_HUSBANDRRPROVINCE as husbandProvinceRegisterId," +//丈夫户口所在地 省
2447   - "P_HUSBANDRRCITY as husbandCityRegisterId," +//丈夫户口所在地 市
2448   - "P_HUSBANDRRCOUNTY as husbandAreaRegisterId," +//丈夫户口所在地 县
2449   - "P_HUSBANDRRSTREET as husbandStreetRegisterId," +//丈夫户口所在地 街道
2450   - "VC_CARDNO as vcCardNo, " +//就诊卡号 条码号
2451   - "P_BIRTHDAY as birthday, " +//孕妇生日
2452   - "P_LASTMENSTRUALPERIOD as lastMenstrualPeriod," +//末次月经
2453   - "YCQ as dueDate," +//预产期
2454   - "P_FILINGTIME as bookbuildingDate," +//建档日期
2455   - "P_HOSPITALID as hospitalId " +//医院Id
2456   - " FROM V_SYNC_TO_V3_PATIENT T " +
2457   - "LEFT join v_sync_to_v3_pdr pdr on pdr.p_no = t.p_no "+
2458   - "WHERE TRUNC(T.P_FILINGTIME) between TO_DATE('" + startTime + "','YYYY-MM-DD') AND TO_DATE('" + endTime + "','YYYY-MM-DD') " +
2459   - "and pdr.p_no is null " +
2460   - "and ( P_ADDRESSCOUNTY='160' " +//居住地区(桃城区)
2461   - "OR P_POSTPARTUMCOUNTY='160' " +//产后区县(桃城区)
2462   - "OR P_RRCOUNTY ='160')";
  2410 + String str = "t.P_CARDTYPE as pregnantCertificateTypeId," +//证件类型
  2411 + "t.P_ADDRESSPROVINCE as pregnantCensusProvinceId," +//居住地-省
  2412 + "t.P_ADDRESSCITY as pregnantCensusCityId," +//居住地 -城市
  2413 + "t.P_ADDRESSCOUNTY as pregnantCensusAreaId," +//居住地区
  2414 + "t.P_ADDRESSSTREET as pregnantCensusStreetId," +//居住地 -街道
  2415 + "t.P_COUNTRY as pregnantCountryId," +//国籍
  2416 + "t.P_HUSBANDCOUNTRY as husbandCountryId," +//丈夫国籍
  2417 + "t.P_HUSBANDCARDTYPE as husbandCertificateTypeId," +//丈夫证件类型
  2418 + "t.P_NATION as pregnantNationId," +//民族
  2419 + "t.P_HUSBANDNATION as husbandNationId," +//丈夫民族
  2420 + "t.P_DOCID as bookbuildingDoctor," +//建档医生
  2421 + "t.P_CARDNO as pregnantCertificateNum," +//证件号
  2422 + "t.P_CARDNO as pregnantNationId," +// 孕妇民族
  2423 + "t.P_CARDNO as pregnantPhone," +// 孕妇手机号
  2424 + "t.P_RRPROVINCE as pregnantLiveProvinceId," +//户口——省
  2425 + "t.P_RRCITY as pregnantLiveCityId," +//户口——市
  2426 + "t.P_RRCOUNTY as pregnantLiveAreaId," +//户口——区县
  2427 + "t.P_RRSTREET as pregnantLiveStreetId," +//户口——街道
  2428 + "t.P_POSTPARTUMPROVINCE as childbirthProvinceId," +//产后——省
  2429 + "t.P_POSTPARTUMCITY as childbirthCityId," +//产后——市
  2430 + "t.P_POSTPARTUMCOUNTY as childbirthAreaId," +//产后——区县
  2431 + "t.P_POSTPARTUMSTREET as childbirthStreetId," +//产后——街道
  2432 + "t.P_HUSBANDNAME as husbandName," +//丈夫姓名
  2433 + "t.P_HUSBANDCARDNO as husbandCertificateNum," +//丈夫证件号码
  2434 + "t.P_HUSBANDBIRTHDAY as husbandBirth," +//丈夫出生日期
  2435 + "t.P_HUSBANDRRPROVINCE as husbandProvinceRegisterId," +//丈夫户口所在地 省
  2436 + "t.P_HUSBANDRRCITY as husbandCityRegisterId," +//丈夫户口所在地 市
  2437 + "t.P_HUSBANDRRCOUNTY as husbandAreaRegisterId," +//丈夫户口所在地 县
  2438 + "t.P_HUSBANDRRSTREET as husbandStreetRegisterId," +//丈夫户口所在地 街道
  2439 + "t.VC_CARDNO as vcCardNo, " +//就诊卡号 条码号
  2440 + "t.P_BIRTHDAY as birthday, " +//孕妇生日
  2441 + "t.P_LASTMENSTRUALPERIOD as lastMenstrualPeriod," +//末次月经
  2442 + "t.YCQ as dueDate," +//预产期
  2443 + "t.P_FILINGTIME as bookbuildingDate," +//建档日期
  2444 + "t.P_HOSPITALID as hospitalId ";//医院Id
  2445 +
  2446 + String sql = "select " + str + " from " +
  2447 + " (select p.* from V_SYNC_TO_V3_PATIENT p " +
  2448 + " left join V_SYNC_TO_V3_PDR pdr on pdr.p_no = p.p_no " +
  2449 + " where pdr.p_no is null and (TRUNC(p.P_FILINGTIME) BETWEEN TO_DATE('" + startTime + "','YYYY-MM-DD') AND TO_DATE('" + endTime + "','YYYY-MM-DD')) and ( p.P_ADDRESSCOUNTY='160' OR p.P_POSTPARTUMCOUNTY='160' OR p.P_RRCOUNTY ='160')" +
  2450 + " union " +
  2451 + " select p.* from V_SYNC_TO_V3_PATIENT p " +
  2452 + " right join V_SYNC_TO_V3_PDR pdr on pdr.p_no = p.p_no " +
  2453 + " where pdr.PDR_CHILDBIRTHDAY > sysdate - 29 and pdr.p_no is not null and to_char(pdr.PDR_CHILDBIRTHDAY,'YYYY-MM-DD') BETWEEN TO_DATE('" + startTime + "','YYYY-MM-DD') AND TO_DATE('" + endTime + "','YYYY-MM-DD')" +
  2454 + ") t";
  2455 + return sql;
2463 2456 }
2464 2457  
2465   -
  2458 + /*
  2459 + WHERE TRUNC(T.P_FILINGTIME) between TO_DATE('" + startTime + "','YYYY-MM-DD') AND TO_DATE('" + endTime + "','YYYY-MM-DD') " +
  2460 + "and pdr.p_no is null " +
  2461 + "and ( P_ADDRESSCOUNTY='160' " +//居住地区(桃城区)
  2462 + "OR P_POSTPARTUMCOUNTY='160' " +//产后区县(桃城区)
  2463 + "OR P_RRCOUNTY ='160')";
  2464 + */
2466 2465 public static Connection getConnection() {
2467 2466 Connection connection;
2468 2467 try {
2469 2468  
... ... @@ -2481,11 +2480,11 @@
2481 2480 PreparedStatement preparedStatement = connection.prepareStatement("select * from MOMMY_PATIENT");
2482 2481 ResultSet resultSet = preparedStatement.executeQuery();
2483 2482 ResultSetMetaData metaData = resultSet.getMetaData();
2484   - int i=1;
2485   - while (resultSet.next()){
  2483 + int i = 1;
  2484 + while (resultSet.next()) {
2486 2485 String tableName = metaData.getColumnName(++i);
2487 2486 System.out.println(tableName);
2488   - // System.out.println(resultSet.getString(tableName));
  2487 + // System.out.println(resultSet.getString(tableName));
2489 2488 }
2490 2489  
2491 2490 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/SyncV2HistoryWorkerx.java View file @ 3c5eb98
  1 +package com.lyms.platform.operate.web.worker;
  2 +
  3 +import com.lyms.platform.biz.service.AntenatalExaminationService;
  4 +import com.lyms.platform.biz.service.PatientsService;
  5 +import com.lyms.platform.biz.service.PostReviewService;
  6 +import com.lyms.platform.common.enums.YnEnums;
  7 +import com.lyms.platform.common.result.BaseObjectResponse;
  8 +import com.lyms.platform.common.utils.ExceptionUtils;
  9 +import com.lyms.platform.operate.web.facade.AntenatalExaminationFacade;
  10 +import com.lyms.platform.operate.web.facade.BookbuildingFacade;
  11 +import com.lyms.platform.operate.web.request.SyncV2HistoryRequest;
  12 +import com.lyms.platform.operate.web.request.YunBookbuildingAddRequest;
  13 +import com.lyms.platform.pojo.AntExChuModel;
  14 +import com.lyms.platform.pojo.AntenatalExaminationModel;
  15 +import com.lyms.platform.pojo.Patients;
  16 +import com.lyms.platform.query.AntExChuQuery;
  17 +import com.lyms.platform.query.AntExQuery;
  18 +import com.lyms.platform.query.PostReviewQuery;
  19 +import org.apache.commons.collections.CollectionUtils;
  20 +import org.springframework.data.domain.Sort;
  21 +
  22 +import java.util.Date;
  23 +import java.util.List;
  24 +import java.util.concurrent.Callable;
  25 +import java.util.concurrent.atomic.AtomicLong;
  26 +
  27 +/**
  28 + * 纠正数据线程
  29 + * <p/>
  30 + * Created by Administrator on 2016/10/25 0025.
  31 + */
  32 +public class SyncV2HistoryWorkerx implements Callable {
  33 +
  34 + private BookbuildingFacade bookbuildingFacade;
  35 +
  36 + private List<SyncV2HistoryRequest> lists;
  37 +
  38 + public SyncV2HistoryWorkerx(BookbuildingFacade bookbuildingFacade, List<SyncV2HistoryRequest> lists) {
  39 + this.bookbuildingFacade = bookbuildingFacade;
  40 + this.lists = lists;
  41 + }
  42 +
  43 + @Override
  44 + public BaseObjectResponse call() throws Exception {
  45 + BaseObjectResponse p=null;
  46 + for (YunBookbuildingAddRequest list : lists) {
  47 + //董勤让写死的
  48 + list.setHospitalId("216216");
  49 + list.setBookbuildingDoctor("1000000185");
  50 + System.out.println("建档孕妇身份证号=="+list.getPregnantCertificateNum());
  51 + p = bookbuildingFacade.addPregnantBookbuilding(list, null, false);//Integer.parseInt(list.getBookbuildingDoctor()
  52 + }
  53 + return p;
  54 + }
  55 +
  56 +
  57 +
  58 +
  59 +
  60 +}
platform-operate-api/src/main/resources/config.properties View file @ 3c5eb98
... ... @@ -33,5 +33,5 @@
33 33 ams_url=http://ams.api.stage.healthbaby.com.cn
34 34  
35 35 #同步数据到v2.0
36   -sync_to_v2_url=http://localhost:8080
  36 +sync_to_v2_url=http://hengshui.mamibeibi.com:8091