Commit 41c5f097755f94d2312d2ad5d8c38ad71ad84f76

Authored by liquanyu
1 parent eba744208f

update

Showing 3 changed files with 158 additions and 25 deletions

platform-operate-api/src/main/java/com/lyms/hospitalapi/hs/SyncBaseInfoService.java View file @ 41c5f09
... ... @@ -144,14 +144,14 @@
144 144 return obj == null ? null : String.valueOf(obj);
145 145 }
146 146  
147   -
  147 + private static final int BATCH_SIZE = 20;
148 148 public void doHandleBirth(String ckNo1,String ckPrefix1)
149 149 {
150 150 int page = 0;
151 151  
152 152 //查询孕妇档案
153 153 do {
154   - String sql1 = "SELECT ck_no,ck_prefix from cert_birthnocheck ORDER BY ck_opertime desc limit "+page+",100";
  154 + String sql1 = "SELECT ck_no,ck_prefix from cert_birthnocheck ORDER BY ck_opertime desc limit "+(page * 100)+",100";
155 155 System.out.println(sql1);
156 156 List<Map<String, Object>> list = JDBCUtil.getMysqlListDataBySql(sql1);
157 157 if (CollectionUtils.isEmpty(list))
158 158  
159 159  
160 160  
161 161  
162 162  
... ... @@ -159,29 +159,56 @@
159 159 System.out.println("查询数据完成");
160 160 break;
161 161 }
162   - if (CollectionUtils.isNotEmpty(list))
163   - {
164   - for(Map<String, Object> data : list)
165   - {
166   - String ckNo = getString(data.get("ck_no"));
167   - String ckPrefix = getString(data.get("ck_prefix"));
  162 + int batchSize = BATCH_SIZE;
  163 + int end = 0;
168 164  
169   - String sql = "SELECT M.CK_NO,M.CK_PREGDAY,M.CK_BABBYBIRTHDAY,M.CK_PREFIX FROM MOMMY_BIRTHNOCHECK M WHERE M.CK_NO='"+ckNo+"' AND M.CK_PREFIX='"+ckPrefix+"'";
  165 + //线程数
  166 + int threadCount = list.size() % BATCH_SIZE == 0 ? list.size() / BATCH_SIZE : list.size() / BATCH_SIZE + 1;
170 167  
171   - List<Map<String, Object>> list1 = JDBCUtil.getOracleListDataBySql(sql);
172   - if (CollectionUtils.isNotEmpty(list1))
173   - {
174   - Map<String, Object> obj = list1.get(0);
175   - Date birth = HsDataUtil.getDate(obj.get("CK_BABBYBIRTHDAY"));
176   - String day = HsDataUtil.getString(obj.get("CK_PREGDAY"));
177   - System.out.println(DateUtil.getyyyy_MM_dd_hms(birth));
178   - int count = JDBCUtil.mysqlUpdate(" update cert_birthnocheck set ck_pregday="+day+",ck_babbybirthday='"+ DateUtil.getyyyy_MM_dd_hms(birth)+"' where ck_no='"+ckNo+"' and ck_prefix='"+ckPrefix+"'");
179   - System.out.println("update count "+count);
  168 + final CountDownLatch countDownLatch = new CountDownLatch(threadCount);
180 169  
181   - }
  170 + for (int i = 0; i < list.size(); i += batchSize) {
  171 + end = (end + batchSize);
  172 + if (end > list.size()) {
  173 + end = list.size();
182 174 }
  175 + System.out.println("start:" + i + ",end:" + end);
  176 + final List<Map<String, Object>> tempList = list.subList(i, end);
  177 + commonThreadPool.execute(new Runnable() {
  178 + @Override
  179 + public void run() {
  180 + if (CollectionUtils.isNotEmpty(tempList))
  181 + {
  182 + for(Map<String, Object> data : tempList)
  183 + {
  184 + String ckNo = getString(data.get("ck_no"));
  185 + String ckPrefix = getString(data.get("ck_prefix"));
  186 +
  187 + String sql = "SELECT M.CK_NO,M.CK_PREGDAY,M.CK_BABBYBIRTHDAY,M.CK_PREFIX FROM MOMMY_BIRTHNOCHECK M WHERE M.CK_NO='"+ckNo+"' AND M.CK_PREFIX='"+ckPrefix+"'";
  188 +
  189 + List<Map<String, Object>> list1 = JDBCUtil.getOracleListDataBySql(sql);
  190 + if (CollectionUtils.isNotEmpty(list1))
  191 + {
  192 + Map<String, Object> obj = list1.get(0);
  193 + Date birth = HsDataUtil.getDate(obj.get("CK_BABBYBIRTHDAY"));
  194 + String day = HsDataUtil.getString(obj.get("CK_PREGDAY"));
  195 + System.out.println(DateUtil.getyyyy_MM_dd_hms(birth));
  196 + int count = JDBCUtil.mysqlUpdate(" update cert_birthnocheck set ck_pregday="+day+",ck_babbybirthday='"+ DateUtil.getyyyy_MM_dd_hms(birth)+"' where ck_no='"+ckNo+"' and ck_prefix='"+ckPrefix+"'");
  197 + System.out.println("update count "+count);
  198 +
  199 + }
  200 + }
  201 + }
  202 + countDownLatch.countDown();
  203 + }
  204 + });
183 205 }
184 206 page++;
  207 + try {
  208 + countDownLatch.await();
  209 + Thread.sleep(5000);
  210 + } catch (InterruptedException e) {
  211 + }
185 212 }while (true);
186 213 }
187 214  
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java View file @ 41c5f09
... ... @@ -3559,6 +3559,7 @@
3559 3559 patients.setId(null);
3560 3560 patients.setEnable("2");
3561 3561 patients.setHospitalId(maternalDeliverModel.getFmHospital());
  3562 + patients.setFmHospital(maternalDeliverModel.getFmHospital());
3562 3563 patients.setSource(source);
3563 3564  
3564 3565 if(StringUtils.isEmpty(patients.getBookbuildingDoctor()))
... ... @@ -3572,7 +3573,7 @@
3572 3573 }
3573 3574 }
3574 3575  
3575   - patientsService.addPatient(patients);
  3576 + patients = patientsService.addPatient(patients);
3576 3577 System.out.println(patients.getId());
3577 3578 maternalDeliverModel.setParentId(patients.getId());
3578 3579 matDeliverService.updateOne(maternalDeliverModel,maternalDeliverModel.getId());
... ... @@ -3633,6 +3634,111 @@
3633 3634 }
3634 3635 return "updatePatientBuildDoctor start......";
3635 3636 }
  3637 +
  3638 +
  3639 +
  3640 +
  3641 +
  3642 + @ResponseBody
  3643 + @RequestMapping(value = "/updateHsFmHospital", method = RequestMethod.GET)
  3644 + public String updateHsFmHospital(@RequestParam(required = false) String hospitalId,String startDate,String endDate) {
  3645 + final MatDeliverQuery matDeliverQuery = new MatDeliverQuery();
  3646 + matDeliverQuery.setYn(YnEnums.YES.getId());
  3647 + matDeliverQuery.setCreatedStart(DateUtil.parseYMD(startDate));
  3648 + matDeliverQuery.setEndStart(DateUtil.parseYMD(endDate));
  3649 + if (StringUtils.isNotEmpty(hospitalId)) {
  3650 + matDeliverQuery.setFmHospital(hospitalId);
  3651 + }
  3652 + // 查询
  3653 + List<MaternalDeliverModel> maternalDeliverModelList = matDeliverService.query(matDeliverQuery);
  3654 + System.out.println("本次读取了【" + maternalDeliverModelList.size() + "】条数据");
  3655 + int batchSize = 1000;
  3656 + int end = 0;
  3657 + for (int i = 0; i < maternalDeliverModelList.size(); i += batchSize) {
  3658 + end = (end + batchSize);
  3659 + if (end > maternalDeliverModelList.size()) {
  3660 + end = maternalDeliverModelList.size();
  3661 + }
  3662 + final List<MaternalDeliverModel> tempList = maternalDeliverModelList.subList(i, end);
  3663 + new Thread(new Runnable() {
  3664 + @Override
  3665 + public void run() {
  3666 + if (CollectionUtils.isNotEmpty(tempList)) {
  3667 + for (MaternalDeliverModel maternalDeliverModel : tempList) {
  3668 + Patients patients = patientsService.findOnePatientById(maternalDeliverModel.getParentId());
  3669 + if (patients != null && StringUtils.isNotEmpty(maternalDeliverModel.getFmHospital())
  3670 + && StringUtils.isNotEmpty(patients.getFmHospital())) {
  3671 + if (!maternalDeliverModel.getFmHospital().equals(patients.getFmHospital()))
  3672 + {
  3673 + patients.setFmHospital(maternalDeliverModel.getFmHospital());
  3674 + patientsService.updatePatient(patients);
  3675 + }
  3676 + }
  3677 +
  3678 + PatientsQuery patientsQuery1 = new PatientsQuery();
  3679 + patientsQuery1.setHospitalId(maternalDeliverModel.getFmHospital());
  3680 + patientsQuery1.setYn(YnEnums.YES.getId());
  3681 + patientsQuery1.setSort("created");
  3682 + patientsQuery1.setPid(maternalDeliverModel.getPid());
  3683 + List<Patients> list = patientsService.queryPatient(patientsQuery1);
  3684 + if (CollectionUtils.isNotEmpty(list))
  3685 + {
  3686 + Patients pat = list.get(0);
  3687 + if (!maternalDeliverModel.getParentId().equals(pat.getId()))
  3688 + {
  3689 + System.out.println("分娩数据修改parentid" );
  3690 + maternalDeliverModel.setParentId(pat.getId());
  3691 + matDeliverService.updateOne(maternalDeliverModel, maternalDeliverModel.getId());
  3692 + }
  3693 +
  3694 + }
  3695 +
  3696 + }
  3697 + }
  3698 + }
  3699 + }).start();
  3700 + }
  3701 + return "updateHsFmHospital start......";
  3702 + }
  3703 +
  3704 +
  3705 +
  3706 + @ResponseBody
  3707 + @RequestMapping(value = "/setPatientLastMenses", method = RequestMethod.GET)
  3708 + public BaseObjectResponse setPatientLastMenses(String cardNo,String lastMenses) {
  3709 + BaseObjectResponse objectResponse = new BaseObjectResponse();
  3710 +
  3711 + PatientsQuery patientsQuery1 = new PatientsQuery();
  3712 + patientsQuery1.setCardNo(cardNo);
  3713 + patientsQuery1.setYn(YnEnums.YES.getId());
  3714 + patientsQuery1.setSort("created");
  3715 + List<Patients> list = patientsService.queryPatient(patientsQuery1);
  3716 + if (CollectionUtils.isNotEmpty(list))
  3717 + {
  3718 + PersonModel persons = mongoTemplate.findOne(Query.query(Criteria.where("cardNo").is(cardNo)), PersonModel.class);
  3719 + if (persons != null)
  3720 + {
  3721 + persons.setType(1);
  3722 + personService.updatePerson(persons, persons.getId());
  3723 + Patients pat = list.get(0);
  3724 + if ("0001-01-01".equals(DateUtil.getyyyy_MM_dd(pat.getLastMenses())))
  3725 + {
  3726 + Date lastMensesDate = DateUtil.parseYMD(lastMenses);
  3727 + pat.setLastMenses(lastMensesDate);
  3728 + pat.setDueDate(DateUtil.addDay(lastMensesDate, 280));
  3729 + pat.setIsAutoFm(0);
  3730 + pat.setType(1);
  3731 + patientsService.updatePatient(pat);
  3732 + this.mongoTemplate.updateFirst(new Query(Criteria.where("id").is(pat.getId())), Update.update("fmDate", null), Patients.class);
  3733 + }
  3734 + }
  3735 + }
  3736 +
  3737 + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
  3738 + objectResponse.setErrormsg(ErrorCodeConstants.SUCCESS_DESCRIPTION);
  3739 + return new BaseObjectResponse();
  3740 + }
  3741 +
3636 3742  
3637 3743 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/ApplyOrderFacade.java View file @ 41c5f09
... ... @@ -790,8 +790,7 @@
790 790  
791 791 }
792 792 }catch (Exception e){
793   - e.printStackTrace();
794   - logger.error("调用华大接口失败", e);
  793 + ExceptionUtils.catchException(e,"调用华大接口失败");
795 794 }
796 795 }
797 796 return result;
798 797  
... ... @@ -1790,8 +1789,9 @@
1790 1789  
1791 1790 String json = JsonUtil.obj2JsonString(map);
1792 1791 System.out.println("saveSampleInfo param="+json);
  1792 + ExceptionUtils.catchException("saveSampleInfo param="+json);
1793 1793 String s = HttpClientUtil.doPostSSL(HUADA_URL + "/external/saveSampleInfos.do", json);
1794   - System.out.println(s);
  1794 + ExceptionUtils.catchException("saveSampleInfo param=" + json+ "=======result"+s);
1795 1795 JSONObject jsonObject = JSONObject.parseObject(s);
1796 1796  
1797 1797 Object codeObj = jsonObject.get("code");