Commit 944c7af5d9d3fec4f52c4580ad6ddb4e28850160
1 parent
828afbc805
Exists in
master
and in
6 other branches
生成优惠券id
Showing 6 changed files with 2062 additions and 1821 deletions
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PregnantBuildController.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/facade/BookbuildingFacade.java
- platform-operate-api/src/main/resources/database.properties
- platform-operate-api/src/main/resources/spring/applicationContext-quartz.xml
- platform-operate-api/src/main/resources/spring/applicationContext.xml
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PregnantBuildController.java
View file @
944c7af
| 1 | 1 | package com.lyms.platform.operate.web.controller; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | +import com.lyms.platform.biz.service.GenSequenceIdService; | |
| 4 | 5 | import com.lyms.platform.biz.service.YunBookbuildingService; |
| 5 | 6 | import com.lyms.platform.common.annotation.TokenRequired; |
| 6 | 7 | import com.lyms.platform.common.base.BaseController; |
| ... | ... | @@ -44,6 +45,9 @@ |
| 44 | 45 | |
| 45 | 46 | @Autowired |
| 46 | 47 | private AntenatalExaminationFacade antenatalExaminationFacade; |
| 48 | + | |
| 49 | + @Autowired | |
| 50 | + private GenSequenceIdService genSequenceIdService; | |
| 47 | 51 | |
| 48 | 52 | |
| 49 | 53 | /** |
| ... | ... | @@ -76,6 +80,24 @@ |
| 76 | 80 | return p; |
| 77 | 81 | } |
| 78 | 82 | |
| 83 | + /** | |
| 84 | + * 添加孕妇建档 | |
| 85 | + * @param request | |
| 86 | + * @return | |
| 87 | + */ | |
| 88 | + @RequestMapping(method = RequestMethod.POST, value = "/createOrUpdateYunBuild") | |
| 89 | + @ResponseBody | |
| 90 | + @TokenRequired | |
| 91 | + public BaseResponse getSequenceId(@RequestBody YunBookbuildingAddRequest yunBookbuildingAddRequest,HttpServletRequest request) { | |
| 92 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
| 93 | + if (yunBookbuildingAddRequest != null && !StringUtils.isEmpty(yunBookbuildingAddRequest.getId()) ) | |
| 94 | + { | |
| 95 | + return bookbuildingFacade.updatePregnantById(yunBookbuildingAddRequest.getId(), yunBookbuildingAddRequest,loginState.getId()); | |
| 96 | + | |
| 97 | + } | |
| 98 | + BaseObjectResponse p = bookbuildingFacade.createOrUpdateYunBuild(yunBookbuildingAddRequest,loginState.getId()); | |
| 99 | + return p; | |
| 100 | + } | |
| 79 | 101 | |
| 80 | 102 | |
| 81 | 103 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java
View file @
944c7af
| ... | ... | @@ -83,8 +83,9 @@ |
| 83 | 83 | |
| 84 | 84 | @Autowired |
| 85 | 85 | private QhdfyFmService qhdfyFmService; |
| 86 | -; | |
| 87 | 86 | |
| 87 | + @Autowired | |
| 88 | + private GenSequenceIdService genIdService; | |
| 88 | 89 | /** |
| 89 | 90 | * 获取科室 |
| 90 | 91 | */ |
| ... | ... | @@ -1027,6 +1028,12 @@ |
| 1027 | 1028 | } catch (Exception e) { |
| 1028 | 1029 | e.printStackTrace(); |
| 1029 | 1030 | } |
| 1031 | + } | |
| 1032 | + | |
| 1033 | + @RequestMapping("/poll") | |
| 1034 | + @ResponseBody | |
| 1035 | + public String poll() { | |
| 1036 | + return genIdService.poll("1234"); | |
| 1030 | 1037 | } |
| 1031 | 1038 | |
| 1032 | 1039 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java
View file @
944c7af
| ... | ... | @@ -117,6 +117,9 @@ |
| 117 | 117 | private PatientCheckTicketService patientCheckTicketService; |
| 118 | 118 | @Autowired |
| 119 | 119 | private AreaCodeService areaCodeService; |
| 120 | + | |
| 121 | + @Autowired | |
| 122 | + private GenSequenceIdService genSequenceIdService; | |
| 120 | 123 | |
| 121 | 124 | /** |
| 122 | 125 | * 根据患者的建档ID,查询还未使用的免费产检查券 |
| ... | ... | @@ -296,6 +299,190 @@ |
| 296 | 299 | ticket.setPatientId(p.getId()); |
| 297 | 300 | ticket.setCreated(new Date()); |
| 298 | 301 | ticket.setId(areaCode.getAreaCode() + ticketPid + i); |
| 302 | + ticket.setPid(p.getPid()); | |
| 303 | + patientCheckTicketService.addTicket(ticket); | |
| 304 | + } | |
| 305 | + } | |
| 306 | + } | |
| 307 | + } | |
| 308 | + } | |
| 309 | + } | |
| 310 | + | |
| 311 | + br.setErrorcode(ErrorCodeConstants.SUCCESS); | |
| 312 | + br.setErrormsg("成功"); | |
| 313 | + br.setData(p.getId()); | |
| 314 | + return br; | |
| 315 | + | |
| 316 | + } | |
| 317 | + | |
| 318 | + /** | |
| 319 | + * 添加孕妇建档 | |
| 320 | + * | |
| 321 | + * @param yunRequest | |
| 322 | + * @return | |
| 323 | + */ | |
| 324 | + public BaseObjectResponse createOrUpdateYunBuild( | |
| 325 | + YunBookbuildingAddRequest yunRequest, Integer userId) { | |
| 326 | + | |
| 327 | + BaseObjectResponse br = new BaseObjectResponse(); | |
| 328 | + PatientsQuery patientsQuery = new PatientsQuery(); | |
| 329 | + patientsQuery.setYn(YnEnums.YES.getId()); | |
| 330 | + patientsQuery.setType(1); | |
| 331 | + patientsQuery.setHospitalId(yunRequest.getHospitalId()); | |
| 332 | + patientsQuery.setBuildTypeEq(0); | |
| 333 | + patientsQuery.setDueStatus(0); | |
| 334 | + | |
| 335 | + if (yunRequest.getPregnantCertificateNum() != null) { | |
| 336 | + patientsQuery.setCardNo(yunRequest.getPregnantCertificateNum()); | |
| 337 | + //判断该身份证号码是否有孕妇建档 在该医院 | |
| 338 | + List<Patients> patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); | |
| 339 | + if (CollectionUtils.isNotEmpty(patients)) { | |
| 340 | + br.setErrorcode(ErrorCodeConstants.DATA_EXIST); | |
| 341 | + br.setErrormsg("该身份证在医院已经建档"); | |
| 342 | + return br; | |
| 343 | + } | |
| 344 | + } | |
| 345 | + if (yunRequest.getPregnantPhone() != null) { | |
| 346 | + patientsQuery.setCardNo(null); | |
| 347 | + patientsQuery.setPhone(yunRequest.getPregnantPhone()); | |
| 348 | + //判断该手机号码在 孕期内有没有建档 | |
| 349 | + List<Patients> patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); | |
| 350 | + if (CollectionUtils.isNotEmpty(patients)) { | |
| 351 | + br.setErrorcode(ErrorCodeConstants.DATA_EXIST); | |
| 352 | + br.setErrormsg("该手机号码已经建档"); | |
| 353 | + return br; | |
| 354 | + } | |
| 355 | + } | |
| 356 | + | |
| 357 | + //就诊卡号判断 | |
| 358 | + if (StringUtils.isNotEmpty(yunRequest.getVcCardNo())) { | |
| 359 | + patientsQuery.setCardNo(null); | |
| 360 | + patientsQuery.setPhone(null); | |
| 361 | + patientsQuery.setVcCardNo(yunRequest.getVcCardNo()); | |
| 362 | + patientsQuery.setHospitalId(yunRequest.getHospitalId()); | |
| 363 | + List<Patients> patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); | |
| 364 | + if (CollectionUtils.isNotEmpty(patients)) { | |
| 365 | + br.setErrorcode(ErrorCodeConstants.DATA_EXIST); | |
| 366 | + br.setErrormsg("该就诊卡号在该医院已经建档"); | |
| 367 | + return br; | |
| 368 | + } | |
| 369 | + } | |
| 370 | + | |
| 371 | + Integer type = 1; //1孕妇 2儿童 3产妇 | |
| 372 | + //建档类型 0 未分娩建档 1儿童建档时建档 2 自动分娩类型 3 转诊自动建档 | |
| 373 | + Integer buildType = 0; | |
| 374 | + Date date = null; | |
| 375 | + if (yunRequest.getLastMenstrualPeriod() != null) { | |
| 376 | + date = DateUtil.addWeek(DateUtil.parseYMD(yunRequest.getLastMenstrualPeriod()), 42); | |
| 377 | + Date currentDate = DateUtil.formatDate(new Date()); | |
| 378 | + if (date.getTime() <= currentDate.getTime()) { | |
| 379 | + type = 3; | |
| 380 | + buildType = 2; | |
| 381 | + } | |
| 382 | + } | |
| 383 | + | |
| 384 | + PersonModel resperson = null; | |
| 385 | + if (StringUtils.isNotEmpty(yunRequest.getPregnantCertificateNum())) { | |
| 386 | + | |
| 387 | + PersonModelQuery personModelQuery = new PersonModelQuery(); | |
| 388 | + personModelQuery.setCardNo(yunRequest.getPregnantCertificateNum()); | |
| 389 | + personModelQuery.setYn(YnEnums.YES.getId()); | |
| 390 | + personModelQuery.setTypes(new Integer[]{1, 3}); //孕妇或者产妇基本信息 | |
| 391 | + List<PersonModel> personModels = personService.queryPersons(personModelQuery); | |
| 392 | + | |
| 393 | + PersonModel pmodel = new PersonModel(); | |
| 394 | + pmodel.setName(yunRequest.getPregnantName()); | |
| 395 | + pmodel.setBirth(DateUtil.parseYMD(yunRequest.getBirthday())); | |
| 396 | + pmodel.setPhone(yunRequest.getPregnantPhone()); | |
| 397 | + pmodel.setCardNo(yunRequest.getPregnantCertificateNum()); | |
| 398 | + pmodel.setType(type); | |
| 399 | + pmodel.setModified(new Date()); | |
| 400 | + if (CollectionUtils.isNotEmpty(personModels) && personModels.get(0) != null) { | |
| 401 | + | |
| 402 | + resperson = personModels.get(0); | |
| 403 | + personService.updatePerson(pmodel, personModels.get(0).getId()); | |
| 404 | + } else { | |
| 405 | + pmodel.setYn(YnEnums.YES.getId()); | |
| 406 | + pmodel.setCreated(new Date()); | |
| 407 | + resperson = personService.addPerson(pmodel); | |
| 408 | + } | |
| 409 | + } | |
| 410 | + | |
| 411 | + Patients patient = getPatientsData(yunRequest); | |
| 412 | + patient.setDueStatus(0); | |
| 413 | + //1孕妇 3 产妇 | |
| 414 | + patient.setType(type); | |
| 415 | + if (type == 3) { | |
| 416 | + patient.setIsAutoFm(YnEnums.YES.getId()); | |
| 417 | + } | |
| 418 | + patient.setBuildType(buildType); | |
| 419 | + if (type == ServiceObjEnums.CHANOBJ.getId() && date != null) { | |
| 420 | + patient.setFmDate(date); | |
| 421 | + } | |
| 422 | + if (resperson != null) { | |
| 423 | + patient.setPid(resperson.getId()); | |
| 424 | + HighScoreResult highScoreResult = antenatalExaminationFacade.findLastRisk(resperson.getId(), true); | |
| 425 | + if (CollectionUtils.isNotEmpty(highScoreResult.getHighId())) { | |
| 426 | + patient.setRiskFactorId(highScoreResult.getHighId()); | |
| 427 | + } | |
| 428 | + patient.setRiskScore(highScoreResult.getScore()); | |
| 429 | + if (CollectionUtils.isNotEmpty(highScoreResult.getLevelId())) { | |
| 430 | + patient.setRiskLevelId(JsonUtil.array2JsonString(highScoreResult.getLevelId())); | |
| 431 | + } | |
| 432 | + } | |
| 433 | + | |
| 434 | + patient.setCreated(new Date()); | |
| 435 | + patient.setModified(new Date()); | |
| 436 | + patient.setOperator(userId); | |
| 437 | + Patients p = yunBookbuildingService.addPregnantBookbuilding(patient); | |
| 438 | + | |
| 439 | + if (p == null || p.getId() == null) { | |
| 440 | + br.setErrorcode(ErrorCodeConstants.SYSTEM_ERROR); | |
| 441 | + br.setErrormsg("建档失败,保存异常"); | |
| 442 | + return br; | |
| 443 | + | |
| 444 | + } | |
| 445 | + | |
| 446 | + //加入产筛 | |
| 447 | + patientsService.validata(p); | |
| 448 | + | |
| 449 | + if (type == ServiceObjEnums.YUNOBJ.getId()) { | |
| 450 | + //生成建档短信 | |
| 451 | + createBuildSms(p); | |
| 452 | + } | |
| 453 | + | |
| 454 | + | |
| 455 | + if (p.getType() != null && p.getType() == 1) { | |
| 456 | + | |
| 457 | + Organization organization = organizationService.getOrganization(Integer.valueOf(yunRequest.getHospitalId())); | |
| 458 | + if (null != organization) { | |
| 459 | + AreaCodeQuery areaCodeQuery = new AreaCodeQuery(); | |
| 460 | + areaCodeQuery.setAreaId(organization.getCityId()); | |
| 461 | + areaCodeQuery.setYn(YnEnums.YES.getId()); | |
| 462 | + List<AreaCodeModel> code = areaCodeService.queryList(areaCodeQuery); | |
| 463 | + AreaCodeModel areaCode = null; | |
| 464 | + | |
| 465 | + | |
| 466 | + String groupId= groupsFacade.findItemIdByCurrentUserId(autoMatchFacade.getHospitalId(userId)); | |
| 467 | + if(org.apache.commons.lang.StringUtils.isNotEmpty(groupId)){ | |
| 468 | + OrganizationGroupsItems groupsItems = groupsFacade.findById(groupId); | |
| 469 | + if(null!=groupsItems){ | |
| 470 | + if (CollectionUtils.isNotEmpty(code)) { | |
| 471 | + areaCode = code.get(0); | |
| 472 | + } | |
| 473 | + if (null != areaCode&&StringUtils.isNotEmpty(areaCode.getAreaCode())) { | |
| 474 | + // 建档成功后,给孕妇造五个条形码 | |
| 475 | + String ticketPid = autoIncermentService.nextPatientTicketId(areaCode.getAreaCode()); | |
| 476 | + | |
| 477 | + int start = TicketTypeEnums.TICKTE_ALL.getType().equals(groupsItems.getTicketType()) ?1:PatientCheckTicketFacade.complyCurrentDay(p.getLastMenses()); | |
| 478 | + for (Integer i =start; i <= 5; i++) { | |
| 479 | + PatientCheckTicket ticket = new PatientCheckTicket(); | |
| 480 | + ticket.setStatus(1); | |
| 481 | + ticket.setHospitalId(p.getHospitalId()); | |
| 482 | + ticket.setPatientId(p.getId()); | |
| 483 | + ticket.setCreated(new Date()); | |
| 484 | +// ticket.setId(areaCode.getAreaCode() + ticketPid + i); | |
| 485 | + ticket.setId(genSequenceIdService.poll(areaCode.getAreaCode())); | |
| 299 | 486 | ticket.setPid(p.getPid()); |
| 300 | 487 | patientCheckTicketService.addTicket(ticket); |
| 301 | 488 | } |
platform-operate-api/src/main/resources/database.properties
View file @
944c7af
| ... | ... | @@ -77,4 +77,10 @@ |
| 77 | 77 | mongo_sync_url=http://mms.api.stage.platform.healthbaby.com.cn/syncmongo |
| 78 | 78 | mongo_sync_token=68884AD1832AB397E2F85F87FE371C74 |
| 79 | 79 | mongo_crypto_key=Lymsh@2016 |
| 80 | + | |
| 81 | +# sequence id configs | |
| 82 | +sequence.create.size=3000 | |
| 83 | +sequence.index=20000000 | |
| 84 | +sequence.min.size=300 | |
| 85 | +sequence.schedule.expression=0 */1 * * * ? |
platform-operate-api/src/main/resources/spring/applicationContext-quartz.xml
View file @
944c7af
| ... | ... | @@ -9,7 +9,25 @@ |
| 9 | 9 | http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd |
| 10 | 10 | http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd"> |
| 11 | 11 | |
| 12 | + <bean id="genSequenceIdService" class="com.lyms.platform.biz.service.GenSequenceIdService"></bean> | |
| 13 | + <!-- 扫描生成的id库 数量不够时自动生成一批数据 --> | |
| 14 | + <bean id="autoInsertIdTask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> | |
| 15 | + <!-- 要调用的bean --> | |
| 16 | + <property name="targetObject" ref="genSequenceIdService"></property> | |
| 17 | + <!-- 要调用的Method --> | |
| 18 | + <property name="targetMethod" value="autoInsertId"></property> | |
| 19 | + <!-- 是否并发,false表示 如果发生错误也不影响下一次的调用 --> | |
| 20 | + <property name="concurrent" value="false"></property> | |
| 21 | + </bean> | |
| 22 | + <!-- 配置一个触发器 --> | |
| 23 | + <bean id="autoInsertIdTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> | |
| 24 | + <property name="jobDetail" ref="autoInsertIdTask"></property> | |
| 25 | + <property name="cronExpression" value="${sequence.schedule.expression}"></property> | |
| 26 | + </bean> | |
| 27 | + | |
| 12 | 28 | <bean id="patientsServiceLocal" class="com.lyms.platform.biz.service.PatientsService"></bean> |
| 29 | + | |
| 30 | + | |
| 13 | 31 | <!--自动分娩任务 --> |
| 14 | 32 | <bean id="autoMatDeliverTask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> |
| 15 | 33 | <!-- 要调用的bean --> |
| ... | ... | @@ -130,6 +148,7 @@ |
| 130 | 148 | <ref bean="delSieveTrigger"/> |
| 131 | 149 | <ref bean="addSieveJobTrigger"/> |
| 132 | 150 | <ref bean="correctSieveOrderTrigger"/> |
| 151 | + <ref bean="autoInsertIdTrigger"/> | |
| 133 | 152 | <!--<ref bean="qhdFmTrigger"/>--> |
| 134 | 153 | <!--<ref bean="crisisTrigger"/>--> |
| 135 | 154 | <!--<ref bean="qhdFmHistoryTrigger"/>--> |
platform-operate-api/src/main/resources/spring/applicationContext.xml
View file @
944c7af
| ... | ... | @@ -36,7 +36,7 @@ |
| 36 | 36 | <import resource="classpath:/spring/applicationContext-slave.xml"/>--> |
| 37 | 37 | |
| 38 | 38 | <!--医院单机版的时候需要打开--> |
| 39 | - <!--<import resource="classpath:/spring/applicationContext-quartz.xml"/>--> | |
| 39 | + <import resource="classpath:/spring/applicationContext-quartz.xml"/> | |
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | <task:annotation-driven/> |