Commit 6ac7d684ab4cddce27d7f24590ba5b1034c4a229
1 parent
ef47537217
Exists in
master
and in
8 other branches
座机号 替换的问题
Showing 4 changed files with 232 additions and 2 deletions
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UpdateController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/CorrectDataFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/CorrectDataWorker.java
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UpdateController.java
View file @
6ac7d68
| 1 | +package com.lyms.platform.operate.web.controller; | |
| 2 | + | |
| 3 | +import com.lyms.platform.common.base.BaseController; | |
| 4 | +import com.lyms.platform.common.constants.ErrorCodeConstants; | |
| 5 | +import com.lyms.platform.common.utils.ExceptionUtils; | |
| 6 | +import com.lyms.platform.common.utils.StringUtils; | |
| 7 | +import com.lyms.platform.operate.web.facade.CorrectDataFacade; | |
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | +import org.springframework.stereotype.Controller; | |
| 10 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 11 | +import org.springframework.web.bind.annotation.RequestMethod; | |
| 12 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 13 | +import org.springframework.web.bind.annotation.ResponseBody; | |
| 14 | + | |
| 15 | +import javax.servlet.http.HttpServletResponse; | |
| 16 | +import java.util.HashMap; | |
| 17 | +import java.util.Map; | |
| 18 | + | |
| 19 | +/** | |
| 20 | + * 数据处理接口 | |
| 21 | + * <p/> | |
| 22 | + * Created by Administrator on 2016/10/25 0025. | |
| 23 | + */ | |
| 24 | +@Controller | |
| 25 | +public class UpdateController extends BaseController { | |
| 26 | + | |
| 27 | + @Autowired | |
| 28 | + private CorrectDataFacade correctDataFacade; | |
| 29 | + | |
| 30 | + @RequestMapping(value = "/updateData", method = RequestMethod.GET) | |
| 31 | + @ResponseBody | |
| 32 | + private Map<String, String> updateCorrectData(@RequestParam("hId") String hId) { | |
| 33 | + Map result = new HashMap<>(); | |
| 34 | + try { | |
| 35 | + if (StringUtils.isNotEmpty(hId)) { | |
| 36 | + correctDataFacade.correctPatient(hId); | |
| 37 | + result.put("msg", "成功."); | |
| 38 | + result.put("code", ErrorCodeConstants.SUCCESS); | |
| 39 | + } else { | |
| 40 | + result.put("msg", "参数不能为空."); | |
| 41 | + result.put("code", ErrorCodeConstants.PARAMETER_ERROR); | |
| 42 | + } | |
| 43 | + } catch (Exception e) { | |
| 44 | + ExceptionUtils.catchException(e, "updateCorrectData Error. hospitalId:" + hId); | |
| 45 | + } | |
| 46 | + return result; | |
| 47 | + } | |
| 48 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java
View file @
6ac7d68
| ... | ... | @@ -340,7 +340,7 @@ |
| 340 | 340 | * @param parentId |
| 341 | 341 | * @param hospitalId |
| 342 | 342 | */ |
| 343 | - private void updateLastRhTime(String parentId, String hospitalId) { | |
| 343 | + public void updateLastRhTime(String parentId, String hospitalId) { | |
| 344 | 344 | |
| 345 | 345 | AntExQuery antExQuery = new AntExQuery(); |
| 346 | 346 | antExQuery.setYn(YnEnums.YES.getId()); |
| ... | ... | @@ -1426,7 +1426,7 @@ |
| 1426 | 1426 | * |
| 1427 | 1427 | * @param parentId |
| 1428 | 1428 | */ |
| 1429 | - private void updateLastRisk(String parentId) { | |
| 1429 | + public void updateLastRisk(String parentId) { | |
| 1430 | 1430 | Patients patients = patientsService.findOnePatientById(parentId); |
| 1431 | 1431 | |
| 1432 | 1432 | PatientsQuery patientsQuery1 = new PatientsQuery(); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/CorrectDataFacade.java
View file @
6ac7d68
| 1 | +package com.lyms.platform.operate.web.facade; | |
| 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.operate.web.worker.CorrectDataWorker; | |
| 8 | +import com.lyms.platform.operate.web.worker.WorkHR; | |
| 9 | +import com.lyms.platform.pojo.Patients; | |
| 10 | +import com.lyms.platform.query.PatientsQuery; | |
| 11 | +import org.apache.commons.collections.CollectionUtils; | |
| 12 | +import org.slf4j.Logger; | |
| 13 | +import org.slf4j.LoggerFactory; | |
| 14 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 15 | +import org.springframework.stereotype.Component; | |
| 16 | + | |
| 17 | +import java.util.ArrayList; | |
| 18 | +import java.util.List; | |
| 19 | +import java.util.concurrent.*; | |
| 20 | +import java.util.concurrent.atomic.AtomicLong; | |
| 21 | + | |
| 22 | +/** | |
| 23 | + * 纠正数据门面 | |
| 24 | + * | |
| 25 | + * Created by Administrator on 2016/10/25 0025. | |
| 26 | + */ | |
| 27 | +@Component | |
| 28 | +public class CorrectDataFacade { | |
| 29 | + | |
| 30 | + private Logger logger = LoggerFactory.getLogger(CorrectDataFacade.class); | |
| 31 | + @Autowired | |
| 32 | + private PatientsService patientsService; | |
| 33 | + @Autowired | |
| 34 | + private PostReviewService postReviewService; | |
| 35 | + @Autowired | |
| 36 | + private AntenatalExaminationFacade antExFacade; | |
| 37 | + @Autowired | |
| 38 | + private AntenatalExaminationService anExService; | |
| 39 | + | |
| 40 | + private ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(5, 10, 1, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>(5000)); | |
| 41 | + | |
| 42 | + /** | |
| 43 | + * | |
| 44 | + * 纠正数据 | |
| 45 | + * | |
| 46 | + * @param hospitalId | |
| 47 | + */ | |
| 48 | + public void correctPatient(String hospitalId) throws InterruptedException { | |
| 49 | + PatientsQuery patientsQuery1=new PatientsQuery(); | |
| 50 | + patientsQuery1.setYn(YnEnums.YES.getId()); | |
| 51 | + patientsQuery1.setHospitalId(hospitalId); | |
| 52 | + List<Patients> patientses = patientsService.queryPatient(patientsQuery1); | |
| 53 | + | |
| 54 | + if(CollectionUtils.isNotEmpty(patientses)){ | |
| 55 | + int batchSize = 150; | |
| 56 | + int end = 0; | |
| 57 | + CountDownLatch countDownLatch=new CountDownLatch(patientses.size()); | |
| 58 | + java.util.concurrent.atomic.AtomicLong counter=new AtomicLong(); | |
| 59 | + for (int i = 0; i < patientses.size(); i += batchSize) { | |
| 60 | + end = (end + batchSize); | |
| 61 | + if (end > patientses.size()) { | |
| 62 | + end = patientses.size(); | |
| 63 | + } | |
| 64 | + threadPoolExecutor.submit(new CorrectDataWorker(patientses.subList(i, end),postReviewService,patientsService,anExService,antExFacade,countDownLatch,counter)); | |
| 65 | + } | |
| 66 | + countDownLatch.await(); | |
| 67 | + logger.info("hand hospitalId :" +hospitalId+", update count "+counter.get()); | |
| 68 | + } | |
| 69 | + } | |
| 70 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/CorrectDataWorker.java
View file @
6ac7d68
| 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.utils.ExceptionUtils; | |
| 8 | +import com.lyms.platform.operate.web.facade.AntenatalExaminationFacade; | |
| 9 | +import com.lyms.platform.pojo.AntExChuModel; | |
| 10 | +import com.lyms.platform.pojo.AntenatalExaminationModel; | |
| 11 | +import com.lyms.platform.pojo.Patients; | |
| 12 | +import com.lyms.platform.query.AntExChuQuery; | |
| 13 | +import com.lyms.platform.query.AntExQuery; | |
| 14 | +import com.lyms.platform.query.PostReviewQuery; | |
| 15 | +import org.apache.commons.collections.CollectionUtils; | |
| 16 | +import org.springframework.data.domain.Sort; | |
| 17 | + | |
| 18 | +import java.util.Date; | |
| 19 | +import java.util.List; | |
| 20 | +import java.util.concurrent.CountDownLatch; | |
| 21 | +import java.util.concurrent.atomic.AtomicLong; | |
| 22 | + | |
| 23 | +/** | |
| 24 | + * 纠正数据线程 | |
| 25 | + * <p/> | |
| 26 | + * Created by Administrator on 2016/10/25 0025. | |
| 27 | + */ | |
| 28 | +public class CorrectDataWorker extends Thread { | |
| 29 | + | |
| 30 | + private PostReviewService postReviewService; | |
| 31 | + | |
| 32 | + private PatientsService patientsService; | |
| 33 | + | |
| 34 | + private AntenatalExaminationService antExService; | |
| 35 | + | |
| 36 | + private AntenatalExaminationFacade antExFacade; | |
| 37 | + | |
| 38 | + private List<Patients> patientses; | |
| 39 | + | |
| 40 | + private CountDownLatch countDownLatch; | |
| 41 | + | |
| 42 | + private java.util.concurrent.atomic.AtomicLong counter; | |
| 43 | + | |
| 44 | + public CorrectDataWorker(List<Patients> patientses, | |
| 45 | + PostReviewService postReviewService, | |
| 46 | + PatientsService patientsService, | |
| 47 | + AntenatalExaminationService antExService, | |
| 48 | + AntenatalExaminationFacade antExFacade, | |
| 49 | + CountDownLatch countDownLatch, | |
| 50 | + java.util.concurrent.atomic.AtomicLong counter) { | |
| 51 | + this.patientses = patientses; | |
| 52 | + this.patientsService = patientsService; | |
| 53 | + this.postReviewService = postReviewService; | |
| 54 | + this.antExService=antExService; | |
| 55 | + this.antExFacade=antExFacade; | |
| 56 | + this.countDownLatch=countDownLatch; | |
| 57 | + this.counter=counter; | |
| 58 | + } | |
| 59 | + | |
| 60 | + @Override | |
| 61 | + public void run() { | |
| 62 | + //最后一次高危时间 | |
| 63 | + // Date lastRhTime; | |
| 64 | + //本院最后一次产检时间 | |
| 65 | + //Date lastCTime; | |
| 66 | + //本院产后复查次数 | |
| 67 | + //Integer postViewTimes; | |
| 68 | + try { | |
| 69 | + for(Patients patients:patientses){ | |
| 70 | + Patients patients1=new Patients(); | |
| 71 | + patients1.setId(patients.getId()); | |
| 72 | + //产后复查次数 | |
| 73 | + PostReviewQuery postReviewQuery=new PostReviewQuery(); | |
| 74 | + postReviewQuery.setHospitalId(patients.getHospitalId()); | |
| 75 | + postReviewQuery.setYn(YnEnums.YES.getId()); | |
| 76 | + //产后复查次数 | |
| 77 | + patients1.setPostViewTimes(postReviewService.count(postReviewQuery)); | |
| 78 | + //最后产检时间 | |
| 79 | + patients1.setLastCTime(findLastCTime(patients.getId())); | |
| 80 | + //修改最后一次定义高危时间 | |
| 81 | + antExFacade.updateLastRhTime(patients.getId(),patients.getHospitalId()); | |
| 82 | + //修改高危 | |
| 83 | + antExFacade.updateLastRisk(patients.getId()); | |
| 84 | + counter.incrementAndGet(); | |
| 85 | + } | |
| 86 | + }catch (Exception e){ | |
| 87 | + ExceptionUtils.catchException(e,"CorrectDataWorker Error."); | |
| 88 | + }finally { | |
| 89 | + countDownLatch.countDown(); | |
| 90 | + } | |
| 91 | + } | |
| 92 | + | |
| 93 | + | |
| 94 | + private Date findLastCTime(String id){ | |
| 95 | + AntExQuery antExQuery=new AntExQuery(); | |
| 96 | + antExQuery.setParentId(id); | |
| 97 | + antExQuery.setYn(YnEnums.YES.getId()); | |
| 98 | + List<AntenatalExaminationModel> antEx= antExService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "checkDate")); | |
| 99 | + if(CollectionUtils.isNotEmpty(antEx)){ | |
| 100 | + return antEx.get(0).getCheckDate(); | |
| 101 | + }else{ | |
| 102 | + AntExChuQuery antExChuQuery=new AntExChuQuery(); | |
| 103 | + antExChuQuery.setParentId(id); | |
| 104 | + antExChuQuery.setYn(YnEnums.YES.getId()); | |
| 105 | + List<AntExChuModel> antExChu= antExService.queryAntExChu(antExChuQuery); | |
| 106 | + if(CollectionUtils.isNotEmpty(antExChu)){ | |
| 107 | + return antExChu.get(0).getCheckTime(); | |
| 108 | + } | |
| 109 | + } | |
| 110 | + return null; | |
| 111 | + } | |
| 112 | +} |