Commit 6d400b608f0027ba4936fb41b28d4aca1cad7cc3
Exists in
master
and in
6 other branches
Merge remote-tracking branch 'origin/master'
Showing 3 changed files
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java
View file @
6d400b6
... | ... | @@ -116,18 +116,19 @@ |
116 | 116 | |
117 | 117 | @RequestMapping(value = "/synBuildToPatientService", method = RequestMethod.GET) |
118 | 118 | @ResponseBody |
119 | - public String synBuildToPatientService() { | |
119 | + public String synBuildToPatientService(@RequestParam(value = "isSkip") boolean isSkip) { | |
120 | 120 | PatientsQuery patientsQuery = new PatientsQuery(); |
121 | 121 | //排查本院隐藏建档 |
122 | 122 | patientsQuery.setExtEnable(false); |
123 | 123 | patientsQuery.setBuildTypeNot(1); |
124 | 124 | patientsQuery.setYn(YnEnums.YES.getId()); |
125 | 125 | patientsQuery.setNeed("need"); |
126 | - patientsQuery.setType(3); | |
126 | + patientsQuery.setType(1); | |
127 | 127 | |
128 | 128 | int patientCount = patientsService.queryPatientCount(patientsQuery); |
129 | 129 | |
130 | - int batchSize = 20000; | |
130 | + //预计开启10个线程处理,计算每个线程需要处理的数据量 | |
131 | + int batchSize = patientCount/10; | |
131 | 132 | int end = 0; |
132 | 133 | List<Future> listFuture = new ArrayList<>(); |
133 | 134 | for (int i = 0; i < patientCount; i += batchSize) { |
... | ... | @@ -135,7 +136,7 @@ |
135 | 136 | if (end > patientCount) { |
136 | 137 | end = batchSize; |
137 | 138 | } |
138 | - listFuture.add(commonThreadPool.submit(new BuildSerToPatientSerWorker(i, end,patientsService,patientServiceService))); | |
139 | + listFuture.add(commonThreadPool.submit(new BuildSerToPatientSerWorker(i, end,patientsService,patientServiceService,isSkip,batchSize))); | |
139 | 140 | } |
140 | 141 | |
141 | 142 | // for (Future f : listFuture) { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MatDeliverFacade.java
View file @
6d400b6
... | ... | @@ -1118,6 +1118,114 @@ |
1118 | 1118 | return list; |
1119 | 1119 | } |
1120 | 1120 | |
1121 | + /** | |
1122 | + * 分娩后随访列表数据 | |
1123 | + * @param postpartumFollowMakeRequest | |
1124 | + * @return | |
1125 | + */ | |
1126 | + public List<PostpartumFollowResult> postpartumDeliver(PostpartumFollowMakeRequest postpartumFollowMakeRequest) { | |
1127 | + List<PostpartumFollowResult> postpartumFollowResults = new ArrayList<>(); | |
1128 | + | |
1129 | + PatientsQuery patientsQuery = new PatientsQuery(); | |
1130 | + | |
1131 | + if (StringUtils.isNotEmpty(postpartumFollowMakeRequest.getBirthDate())) { | |
1132 | + patientsQuery.setFmDateStart(DateUtil.getSNDate(postpartumFollowMakeRequest.getBirthDate())[0]); | |
1133 | + patientsQuery.setFmDateEnd(DateUtil.getSNDate(postpartumFollowMakeRequest.getBirthDate())[1]); | |
1134 | + } | |
1135 | + patientsQuery.setYn(YnEnums.YES.getId()); | |
1136 | + patientsQuery.setIsAutoFm(YnEnums.NO.getId()); | |
1137 | + patientsQuery.setType(3); | |
1138 | + // 构造医院id集合 | |
1139 | + List<String> hospitalList = new ArrayList<>(); | |
1140 | + if (StringUtils.isEmpty(postpartumFollowMakeRequest.getIsArea())) { | |
1141 | + // 非区域 | |
1142 | + hospitalList.add(postpartumFollowMakeRequest.getHospitalId()); | |
1143 | + } else { | |
1144 | + // 未传入查询条件 | |
1145 | + if (StringUtils.isEmpty(postpartumFollowMakeRequest.getHospitalProvinceId()) && StringUtils.isEmpty(postpartumFollowMakeRequest.getHospitalProvinceId()) && StringUtils.isEmpty(postpartumFollowMakeRequest.getHospitalAreaId()) && StringUtils.isEmpty(postpartumFollowMakeRequest.getHospitalId())) { | |
1146 | + | |
1147 | + DataPermissionsModelQuery dataPermissionsModelQuery = new DataPermissionsModelQuery(); | |
1148 | + dataPermissionsModelQuery.setUserId(postpartumFollowMakeRequest.getOperatorId()); | |
1149 | + List<DataPermissionsModel> dataPermissionsModelList = dataPermissionService.queryPermission(dataPermissionsModelQuery); | |
1150 | + if (CollectionUtils.isNotEmpty(dataPermissionsModelList)) { | |
1151 | + Map data = dataPermissionsModelList.get(0).getData(); | |
1152 | + for (Object hospitalId : data.keySet()) { | |
1153 | + if (StringUtils.isNotEmpty(hospitalId.toString()) && !hospitalList.contains(hospitalId.toString())) { | |
1154 | + hospitalList.add(hospitalId.toString()); | |
1155 | + } | |
1156 | + } | |
1157 | + } | |
1158 | + } else { | |
1159 | + // 传入了查询条件 | |
1160 | + OrganizationQuery organizationQuery = new OrganizationQuery(); | |
1161 | + organizationQuery.setProvinceId(postpartumFollowMakeRequest.getHospitalProvinceId()); | |
1162 | + organizationQuery.setCityId(postpartumFollowMakeRequest.getHospitalCityId()); | |
1163 | + organizationQuery.setAreaId(postpartumFollowMakeRequest.getHospitalAreaId()); | |
1164 | + organizationQuery.setYn(YnEnums.YES.getId()); | |
1165 | + List<Organization> organizationList = organizationService.queryHospitals(organizationQuery); | |
1166 | + if (CollectionUtils.isNotEmpty(organizationList)) { | |
1167 | + for (Organization organization : organizationList) { | |
1168 | + hospitalList.add(organization.getId().toString()); | |
1169 | + } | |
1170 | + } | |
1171 | + } | |
1172 | + } | |
1173 | + patientsQuery.setFmHospitalQueryList(hospitalList); | |
1174 | + patientsQuery.setLimit(postpartumFollowMakeRequest.getLimit()); | |
1175 | + patientsQuery.setPage(postpartumFollowMakeRequest.getPage()); | |
1176 | + patientsQuery.setNeed("need"); | |
1177 | + patientsQuery.setDesc("fmDate"); | |
1178 | + patientsQuery.setSort("fmDate"); | |
1179 | + | |
1180 | + List<Patients> patientsList = patientsService.queryPatient(patientsQuery); | |
1181 | + List<String> parentIdList = new ArrayList<>(); | |
1182 | + if (CollectionUtils.isEmpty(patientsList)) { | |
1183 | + // 没有查到,直接抛出 | |
1184 | + return postpartumFollowResults; | |
1185 | + } | |
1186 | + Map<String,Patients> patientsMap = new HashMap<>(); | |
1187 | + for (Patients patients : patientsList) { | |
1188 | + parentIdList.add(patients.getId()); | |
1189 | + patientsMap.put(patients.getId(),patients); | |
1190 | + } | |
1191 | + | |
1192 | + MatDeliverQuery matDeliverQuery = new MatDeliverQuery(); | |
1193 | + matDeliverQuery.setParentIdList(parentIdList); | |
1194 | + matDeliverQuery.setYn(YnEnums.YES.getId()); | |
1195 | + List<MaternalDeliverModel> maternalDeliverModelList = matDeliverService.query(matDeliverQuery); | |
1196 | + | |
1197 | + for(MaternalDeliverModel deliverModel : maternalDeliverModelList){ | |
1198 | + PostpartumFollowResult postpartumFollowResult = new PostpartumFollowResult(); | |
1199 | + Patients patients = patientsMap.get(deliverModel.getParentId()); | |
1200 | + // 居住地 | |
1201 | + postpartumFollowResult.setAddress(CommonsHelper.getResidence(patients.getProvinceRegisterId(), patients.getCityRegisterId(), patients.getAreaRegisterId(), patients.getStreetRegisterId(), patients.getAddressRegister(), basicConfigService)); | |
1202 | + // 电话转换 | |
1203 | + postpartumFollowResult.setPhone(patients.getPhone()); | |
1204 | + //姓名 | |
1205 | + postpartumFollowResult.setName(patients.getUsername()); | |
1206 | + // 年龄 | |
1207 | + postpartumFollowResult.setAge(DateUtil.getAge(patients.getBirth())); | |
1208 | + //机构信息 | |
1209 | + Organization organization = organizationService.getOrganization(Integer.valueOf(deliverModel.getFmHospital())); | |
1210 | + // 市 | |
1211 | + BasicConfig cityName = basicConfigService.getOneBasicConfigById(organization.getCityId()); | |
1212 | + // 区 | |
1213 | + BasicConfig areaName = basicConfigService.getOneBasicConfigById(organization.getAreaId()); | |
1214 | + if (cityName != null) { | |
1215 | + postpartumFollowResult.setHospitalCityName(cityName.getName()); | |
1216 | + } | |
1217 | + if (areaName != null) { | |
1218 | + postpartumFollowResult.setHospitalAreaName(areaName.getName()); | |
1219 | + } | |
1220 | + //分娩医院 | |
1221 | + postpartumFollowResult.setFmHospital(organization.getName()); | |
1222 | + | |
1223 | + postpartumFollowResults.add(postpartumFollowResult); | |
1224 | + } | |
1225 | + | |
1226 | + return postpartumFollowResults; | |
1227 | + } | |
1228 | + | |
1121 | 1229 | |
1122 | 1230 | public ChildbirthManagerResult childbirthManager(ChildbirthManagerRequest childbirthManagerRequest) { |
1123 | 1231 | ChildbirthManagerResult childbirthManagerResult = new ChildbirthManagerResult(); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/BuildSerToPatientSerWorker.java
View file @
6d400b6
... | ... | @@ -5,7 +5,9 @@ |
5 | 5 | import com.lyms.platform.common.enums.ServiceStatusEnums; |
6 | 6 | import com.lyms.platform.common.enums.ServiceTypeEnums; |
7 | 7 | import com.lyms.platform.common.enums.YnEnums; |
8 | +import com.lyms.platform.operate.web.utils.CollectionUtils; | |
8 | 9 | import com.lyms.platform.permission.model.PatientService; |
10 | +import com.lyms.platform.permission.model.PatientServiceQuery; | |
9 | 11 | import com.lyms.platform.permission.service.PatientServiceService; |
10 | 12 | import com.lyms.platform.pojo.Patients; |
11 | 13 | import com.lyms.platform.query.PatientsQuery; |
12 | 14 | |
13 | 15 | |
14 | 16 | |
15 | 17 | |
16 | 18 | |
17 | 19 | |
18 | 20 | |
19 | 21 | |
20 | 22 | |
21 | 23 | |
22 | 24 | |
23 | 25 | |
24 | 26 | |
... | ... | @@ -22,91 +24,116 @@ |
22 | 24 | public class BuildSerToPatientSerWorker implements Callable { |
23 | 25 | private int startIndex; |
24 | 26 | private int endIndex; |
27 | + private int batchSize; | |
28 | + private boolean isSkip; | |
25 | 29 | private PatientsService patientsService; |
26 | 30 | private PatientServiceService patientServiceService; |
27 | 31 | |
28 | - public BuildSerToPatientSerWorker(int startIndex, int endIndex, PatientsService patientsService, PatientServiceService patientServiceService) { | |
32 | + public BuildSerToPatientSerWorker(int startIndex, int endIndex, PatientsService patientsService, PatientServiceService patientServiceService,boolean isSkip,int batchSize) { | |
29 | 33 | this.startIndex = startIndex; |
30 | 34 | this.endIndex = endIndex; |
31 | 35 | this.patientsService = patientsService; |
32 | 36 | this.patientServiceService = patientServiceService; |
37 | + this.isSkip = isSkip; | |
38 | + if(batchSize>=100){ | |
39 | + this.batchSize = 100; | |
40 | + } else{ | |
41 | + this.batchSize = batchSize; | |
42 | + } | |
33 | 43 | } |
34 | 44 | |
35 | 45 | /** |
36 | 46 | * Computes a result, or throws an exception if unable to do so. |
37 | 47 | * |
38 | 48 | * @return computed result |
39 | - * @throws Exception if unable to compute a result | |
40 | 49 | */ |
41 | 50 | @Override |
42 | - public Object call() throws Exception { | |
43 | - for (int i = startIndex; i <= endIndex; i += 1000) { | |
44 | - PatientsQuery patientsQuery = new PatientsQuery(); | |
45 | - patientsQuery.setLimit(1000); | |
46 | - patientsQuery.setPage((i+1000)/1000); | |
47 | - //排查本院隐藏建档 | |
48 | - patientsQuery.setExtEnable(false); | |
49 | - patientsQuery.setBuildTypeNot(1); | |
50 | - patientsQuery.setYn(YnEnums.YES.getId()); | |
51 | - patientsQuery.setNeed("need"); | |
52 | - patientsQuery.setType(1); | |
53 | - List<Patients> patients = patientsService.queryPatient(patientsQuery); | |
54 | - for (Patients pt : patients) { | |
55 | - System.out.println("正在处理:"+pt.getId()); | |
56 | - String patientId = pt.getId(); | |
51 | + public Object call() { | |
52 | + try { | |
53 | + for (int i = startIndex; i <= endIndex; i += batchSize) { | |
54 | + PatientsQuery patientsQuery = new PatientsQuery(); | |
55 | + patientsQuery.setLimit(batchSize); | |
56 | + patientsQuery.setPage((i+batchSize)/batchSize); | |
57 | + //排查本院隐藏建档 | |
58 | + patientsQuery.setExtEnable(false); | |
59 | + patientsQuery.setBuildTypeNot(1); | |
60 | + patientsQuery.setYn(YnEnums.YES.getId()); | |
61 | + patientsQuery.setNeed("need"); | |
62 | + patientsQuery.setType(1); | |
63 | + List<Patients> patients = patientsService.queryPatient(patientsQuery); | |
64 | + for (Patients pt : patients) { | |
57 | 65 | |
58 | - PatientService pser = new PatientService(); | |
59 | - pser.setCreateUser(pt.getBookbuildingDoctor()); | |
60 | - pser.setCreateDate(pt.getBookbuildingDate()); | |
61 | - pser.setParentid(patientId); | |
62 | - pser.setPid(pt.getPid()); | |
63 | - pser.setId(UUID.randomUUID().toString().replace("-", "")); | |
66 | + if(pt.getServiceType() == null){ | |
67 | + continue; | |
68 | + } | |
64 | 69 | |
65 | - pser.setHospitalId(pt.getHospitalId()); | |
70 | + System.out.println("正在处理:"+pt.getId()); | |
71 | + String patientId = pt.getId(); | |
66 | 72 | |
67 | - //服务类型 | |
68 | - if(pt.getServiceType() == ServiceTypeEnums.STANDARD_SERVICE.getId() ){//标准服务 | |
69 | - pser.setSerType(PatientSerEnums.SerTypeEnums.bzfw.getId()); | |
70 | - //默认开通状态 | |
71 | - if(pt.getServiceStatus() == ServiceStatusEnums.STANDARD_OPEN.getId()){ | |
72 | - pser.setSerStatus(PatientSerEnums.SerStatusEnums.kt.getId()); | |
73 | - }else if(pt.getServiceStatus() == ServiceStatusEnums.NO_OPEN.getId()){ | |
74 | - pser.setSerStatus(PatientSerEnums.SerStatusEnums.td.getId()); | |
75 | - }else if(pt.getServiceStatus() == ServiceStatusEnums.STANDARD_OVERDUE.getId()){ | |
76 | - pser.setSerStatus(PatientSerEnums.SerStatusEnums.gq.getId()); | |
77 | - } | |
73 | + PatientService pser = new PatientService(); | |
74 | + pser.setCreateUser(pt.getBookbuildingDoctor()); | |
75 | + pser.setCreateDate(pt.getBookbuildingDate()); | |
76 | + pser.setParentid(patientId); | |
77 | + pser.setPid(pt.getPid()); | |
78 | + pser.setId(UUID.randomUUID().toString().replace("-", "")); | |
78 | 79 | |
79 | - }else if(pt.getServiceType() ==ServiceTypeEnums.ADD_SERVICE.getId()){//增值服务 | |
80 | - pser.setSerType(PatientSerEnums.SerTypeEnums.yqjzzd.getId()); | |
81 | - //默认开通状态 | |
82 | - if(pt.getServiceStatus() == ServiceStatusEnums.ADD_OPEN.getId()){ | |
83 | - pser.setSerStatus(PatientSerEnums.SerStatusEnums.kt.getId()); | |
84 | - }else if(pt.getServiceStatus() == ServiceStatusEnums.UNSUBSCRIBE.getId()){ | |
85 | - pser.setSerStatus(PatientSerEnums.SerStatusEnums.td.getId()); | |
86 | - }else if(pt.getServiceStatus() == ServiceStatusEnums.ADD_OVERDUE.getId()){ | |
87 | - pser.setSerStatus(PatientSerEnums.SerStatusEnums.gq.getId()); | |
88 | - }else if(pt.getServiceStatus() == ServiceStatusEnums.SUSPEND.getId()){ | |
89 | - pser.setSerStatus(PatientSerEnums.SerStatusEnums.zt.getId()); | |
80 | + pser.setHospitalId(pt.getHospitalId()); | |
81 | + | |
82 | + | |
83 | + //服务类型 | |
84 | + if(pt.getServiceType() == ServiceTypeEnums.STANDARD_SERVICE.getId() ){//标准服务 | |
85 | + pser.setSerType(PatientSerEnums.SerTypeEnums.bzfw.getId()); | |
86 | + //默认开通状态 | |
87 | + if(pt.getServiceStatus() == ServiceStatusEnums.STANDARD_OPEN.getId()){ | |
88 | + pser.setSerStatus(PatientSerEnums.SerStatusEnums.kt.getId()); | |
89 | + }else if(pt.getServiceStatus() == ServiceStatusEnums.NO_OPEN.getId()){ | |
90 | + pser.setSerStatus(PatientSerEnums.SerStatusEnums.td.getId()); | |
91 | + }else if(pt.getServiceStatus() == ServiceStatusEnums.STANDARD_OVERDUE.getId()){ | |
92 | + pser.setSerStatus(PatientSerEnums.SerStatusEnums.gq.getId()); | |
93 | + } | |
94 | + | |
95 | + }else if(pt.getServiceType() ==ServiceTypeEnums.ADD_SERVICE.getId()){//增值服务 | |
96 | + pser.setSerType(PatientSerEnums.SerTypeEnums.yqjzzd.getId()); | |
97 | + //默认开通状态 | |
98 | + if(pt.getServiceStatus() == ServiceStatusEnums.ADD_OPEN.getId()){ | |
99 | + pser.setSerStatus(PatientSerEnums.SerStatusEnums.kt.getId()); | |
100 | + }else if(pt.getServiceStatus() == ServiceStatusEnums.UNSUBSCRIBE.getId()){ | |
101 | + pser.setSerStatus(PatientSerEnums.SerStatusEnums.td.getId()); | |
102 | + }else if(pt.getServiceStatus() == ServiceStatusEnums.ADD_OVERDUE.getId()){ | |
103 | + pser.setSerStatus(PatientSerEnums.SerStatusEnums.gq.getId()); | |
104 | + }else if(pt.getServiceStatus() == ServiceStatusEnums.SUSPEND.getId()){ | |
105 | + pser.setSerStatus(PatientSerEnums.SerStatusEnums.zt.getId()); | |
106 | + } | |
90 | 107 | } |
91 | - } | |
92 | 108 | |
109 | + if(isSkip){//是否是增量 | |
110 | + PatientServiceQuery patientQuery = new PatientServiceQuery(); | |
111 | + patientQuery.setParentid(pt.getId()); | |
112 | + patientQuery.setSerType(pser.getSerType()); | |
93 | 113 | |
94 | - //默认已经领取 | |
95 | - pser.setStatus(2); | |
96 | - //默认待同步 | |
97 | - pser.setSynStatus(1); | |
98 | - //领取时间 | |
99 | - // pser.setReceiveDate(new Date()); | |
100 | - //服务开通操作时间 | |
101 | - pser.setUpdateDate(pt.getBookbuildingDate()); | |
102 | - //服务开通操作人 | |
103 | - pser.setUpdateUser(String.valueOf(pt.getBookbuildingDoctor())); | |
104 | - patientServiceService.addPatientService(pser); | |
114 | + List<PatientService> patientServices = patientServiceService.queryPatientService(patientQuery); | |
115 | + if (CollectionUtils.isNotEmpty(patientServices)) { | |
116 | + continue; | |
117 | + } | |
118 | + } | |
119 | + | |
120 | + //默认已经领取 | |
121 | + pser.setStatus(2); | |
122 | + //默认待同步 | |
123 | + pser.setSynStatus(1); | |
124 | + //领取时间 | |
125 | + // pser.setReceiveDate(new Date()); | |
126 | + //服务开通操作时间 | |
127 | + pser.setUpdateDate(pt.getBookbuildingDate()); | |
128 | + //服务开通操作人 | |
129 | + pser.setUpdateUser(pt.getBookbuildingDoctor()); | |
130 | + patientServiceService.addPatientService(pser); | |
131 | + } | |
132 | + // System.out.println("endIndex:" + endIndex + "," + i + ":" + patients.size()); | |
105 | 133 | } |
106 | - // System.out.println("endIndex:" + endIndex + "," + i + ":" + patients.size()); | |
134 | + }catch (Exception e){ | |
135 | + e.printStackTrace(); | |
107 | 136 | } |
108 | - | |
109 | - | |
110 | 137 | return null; |
111 | 138 | } |
112 | 139 |