Commit d29fe1e181cc54f7cfd1204ae84eec856d31b142
1 parent
ecfe3b825f
Exists in
master
and in
6 other branches
产检统计
Showing 2 changed files with 175 additions and 11 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PremaritalCheckupController.java
View file @
d29fe1e
| ... | ... | @@ -94,6 +94,23 @@ |
| 94 | 94 | return premaritalCheckupFacade.queryPremaritalCheckup(queryRequest, loginState.getId()); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | + | |
| 98 | + /** | |
| 99 | + * 婚检统计 | |
| 100 | + * @param provinceId | |
| 101 | + * @param cityId | |
| 102 | + * @param areaId | |
| 103 | + * @param streetId | |
| 104 | + * @param time | |
| 105 | + * @param request | |
| 106 | + * @return | |
| 107 | + */ | |
| 108 | + public BaseResponse queryPremaritalReport(String provinceId,String cityId,String areaId,String streetId,String time,HttpServletRequest request){ | |
| 109 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
| 110 | + return premaritalCheckupFacade.queryPremaritalReport(provinceId,cityId,areaId,streetId,time,loginState.getId()); | |
| 111 | + } | |
| 112 | + | |
| 113 | + | |
| 97 | 114 | @RequestMapping(value = "/premaritalCheckupExport", method = RequestMethod.GET) |
| 98 | 115 | @ResponseBody |
| 99 | 116 | @TokenRequired |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PremaritalCheckupFacade.java
View file @
d29fe1e
| 1 | 1 | package com.lyms.platform.operate.web.facade; |
| 2 | 2 | |
| 3 | -import com.lyms.platform.biz.service.BasicConfigService; | |
| 4 | -import com.lyms.platform.biz.service.PremaritalCheckupService; | |
| 5 | -import com.lyms.platform.biz.service.ResidentsArchiveService; | |
| 6 | -import com.lyms.platform.biz.service.TrackDownRecordService; | |
| 3 | +import com.lyms.platform.beans.AddressBean; | |
| 4 | +import com.lyms.platform.biz.service.*; | |
| 7 | 5 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
| 8 | 6 | import com.lyms.platform.common.enums.MedicalAdviceEnum; |
| 9 | 7 | import com.lyms.platform.common.enums.PhysiologyStatusEnum; |
| ... | ... | @@ -14,6 +12,7 @@ |
| 14 | 12 | import com.lyms.platform.common.result.BaseResponse; |
| 15 | 13 | import com.lyms.platform.common.utils.DateUtil; |
| 16 | 14 | import com.lyms.platform.common.utils.ExcelUtil; |
| 15 | +import com.lyms.platform.common.utils.JsonUtil; | |
| 17 | 16 | import com.lyms.platform.common.utils.SystemConfig; |
| 18 | 17 | import com.lyms.platform.operate.web.request.PremaritalCheckupAddRequest; |
| 19 | 18 | import com.lyms.platform.operate.web.request.PremaritalCheckupQueryRequest; |
| 20 | 19 | |
| ... | ... | @@ -25,16 +24,12 @@ |
| 25 | 24 | import com.lyms.platform.operate.web.utils.FunvCommonUtil; |
| 26 | 25 | import com.lyms.platform.operate.web.utils.UnitConstants; |
| 27 | 26 | import com.lyms.platform.permission.model.Organization; |
| 27 | +import com.lyms.platform.permission.model.OrganizationQuery; | |
| 28 | 28 | import com.lyms.platform.permission.model.Users; |
| 29 | 29 | import com.lyms.platform.permission.service.OrganizationService; |
| 30 | 30 | import com.lyms.platform.permission.service.UsersService; |
| 31 | -import com.lyms.platform.pojo.BasicConfig; | |
| 32 | -import com.lyms.platform.pojo.PremaritalCheckup; | |
| 33 | -import com.lyms.platform.pojo.ResidentsArchiveModel; | |
| 34 | -import com.lyms.platform.pojo.TrackDownRecord; | |
| 35 | -import com.lyms.platform.query.PremaritalCheckupQuery; | |
| 36 | -import com.lyms.platform.query.ResidentsArchiveQuery; | |
| 37 | -import com.lyms.platform.query.TrackDownRecordQuery; | |
| 31 | +import com.lyms.platform.pojo.*; | |
| 32 | +import com.lyms.platform.query.*; | |
| 38 | 33 | import org.apache.commons.collections.CollectionUtils; |
| 39 | 34 | import org.apache.commons.lang.StringUtils; |
| 40 | 35 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -68,6 +63,10 @@ |
| 68 | 63 | private ITrackDownService trackDownService; |
| 69 | 64 | @Autowired |
| 70 | 65 | private TrackDownRecordService trackDownRecordService; |
| 66 | + @Autowired | |
| 67 | + private AreaCountFacade areaCountFacade; | |
| 68 | + @Autowired | |
| 69 | + private DataPermissionService dataPermissionService; | |
| 71 | 70 | |
| 72 | 71 | /** |
| 73 | 72 | * 查询单个(男/女)婚前检查 |
| ... | ... | @@ -2190,6 +2189,144 @@ |
| 2190 | 2189 | return checkupResult; |
| 2191 | 2190 | } |
| 2192 | 2191 | |
| 2192 | + | |
| 2193 | + //婚检统计 | |
| 2194 | + public BaseResponse queryPremaritalReport(String provinceId,String cityId,String areaId,String streetId,String time,Integer userId){ | |
| 2195 | + //获取用户权限医院和筛选条件的交集 | |
| 2196 | + List<String> currentUserHospPermissions = areaCountFacade.getCurrentUserHospPermissions2(userId, provinceId, | |
| 2197 | + cityId, areaId); | |
| 2198 | + String[] dates = null; | |
| 2199 | + if (StringUtils.isNotEmpty(time)) { | |
| 2200 | + dates = time.split(" - "); | |
| 2201 | + } | |
| 2202 | + BasicConfigQuery basicQuery = new BasicConfigQuery(); | |
| 2203 | + basicQuery.setYn(YnEnums.YES.getId()); | |
| 2204 | + basicQuery.setTypeId("b7ea005c-dfac-4c2a-bdae-25239b3f44fd"); | |
| 2205 | + //用来存放省、市、县的ID的集合 | |
| 2206 | + List<String> ids = new ArrayList<>(); | |
| 2207 | + //查询当前登录用户管辖的所有医院 | |
| 2208 | + DataPermissionsModelQuery dataPermissionsModelQuery = new DataPermissionsModelQuery(); | |
| 2209 | + dataPermissionsModelQuery.setUserId(userId); | |
| 2210 | + List<DataPermissionsModel> permissionsModels = dataPermissionService.queryPermission(dataPermissionsModelQuery); | |
| 2211 | + | |
| 2212 | + int addrType = 0; | |
| 2213 | + if (StringUtils.isNotEmpty(provinceId)) { | |
| 2214 | + ids = new ArrayList<>(); | |
| 2215 | + if (CollectionUtils.isNotEmpty(permissionsModels)) { | |
| 2216 | + List<AddressBean> addressBeanList = JsonUtil.toList(permissionsModels.get(0).getAreaPermission(), AddressBean.class); | |
| 2217 | + if (CollectionUtils.isNotEmpty(addressBeanList)) | |
| 2218 | + { | |
| 2219 | + for (AddressBean bean : addressBeanList) | |
| 2220 | + { | |
| 2221 | + if (bean != null && bean.getP() != null && bean.getP().equals(provinceId) && StringUtils.isNotEmpty(bean.getC())) | |
| 2222 | + { | |
| 2223 | + //省不为空,赋值所有市的id | |
| 2224 | + ids.add(bean.getC()); | |
| 2225 | + } | |
| 2226 | + } | |
| 2227 | + } | |
| 2228 | + } | |
| 2229 | + basicQuery.setIds(ids); | |
| 2230 | + addrType = 1; | |
| 2231 | + } | |
| 2232 | + if (StringUtils.isNotEmpty(cityId)) { | |
| 2233 | + ids = new ArrayList<>(); | |
| 2234 | + if (CollectionUtils.isNotEmpty(permissionsModels)) { | |
| 2235 | + List<AddressBean> addressBeanList = JsonUtil.toList(permissionsModels.get(0).getAreaPermission(), AddressBean.class); | |
| 2236 | + if (CollectionUtils.isNotEmpty(addressBeanList)) | |
| 2237 | + { | |
| 2238 | + for (AddressBean bean : addressBeanList) | |
| 2239 | + { | |
| 2240 | + if (bean != null && bean.getC() != null && bean.getC().equals(cityId) && StringUtils.isNotEmpty(bean.getA())) | |
| 2241 | + { | |
| 2242 | + //市不为空,赋值所有县的id | |
| 2243 | + ids.add(bean.getA()); | |
| 2244 | + } | |
| 2245 | + } | |
| 2246 | + } | |
| 2247 | + } | |
| 2248 | + basicQuery.setIds(ids); | |
| 2249 | + addrType = 2; | |
| 2250 | + } | |
| 2251 | + //x轴标题数据 | |
| 2252 | + List<String> xAxis = new ArrayList<>(); | |
| 2253 | + //获取地址列表 | |
| 2254 | + List<BasicConfig> configList = new ArrayList<>(); | |
| 2255 | + if (CollectionUtils.isNotEmpty(ids)) | |
| 2256 | + { | |
| 2257 | + configList = basicConfigService.queryBasicConfig(basicQuery); | |
| 2258 | + } | |
| 2259 | + if (CollectionUtils.isNotEmpty(configList)) { | |
| 2260 | + for (BasicConfig addr : configList) { | |
| 2261 | + xAxis.add(addr.getName()); | |
| 2262 | + } | |
| 2263 | + } | |
| 2264 | + //标题名称 | |
| 2265 | + List<String> titleItems = new LinkedList<>(); | |
| 2266 | + titleItems.add("男婚检人数"); | |
| 2267 | + titleItems.add("女婚检人数"); | |
| 2268 | + | |
| 2269 | + //图标数据 | |
| 2270 | + List<Map<String, Object>> series = new LinkedList<>(); | |
| 2271 | + if (CollectionUtils.isNotEmpty(configList)) { | |
| 2272 | + | |
| 2273 | + | |
| 2274 | + for (BasicConfig c : configList) { | |
| 2275 | + Map<String,Object> map = new HashMap<String,Object>(); | |
| 2276 | + OrganizationQuery idQuery = new OrganizationQuery(); | |
| 2277 | + idQuery.setYn(YnEnums.YES.getId()); | |
| 2278 | + | |
| 2279 | + //查询机构数 | |
| 2280 | + if (addrType == 1) { | |
| 2281 | + idQuery.setCityId(c.getId()); | |
| 2282 | + } else if (addrType == 2) { | |
| 2283 | + idQuery.setAreaId(c.getId()); | |
| 2284 | + } | |
| 2285 | + List<Organization> orgs = organizationService.queryOrganization(idQuery); | |
| 2286 | + List<String> hids = getConditionHospitalIds(currentUserHospPermissions, orgs); | |
| 2287 | + | |
| 2288 | + if (CollectionUtils.isNotEmpty(hids)) | |
| 2289 | + { | |
| 2290 | + | |
| 2291 | + PremaritalCheckupQuery query = new PremaritalCheckupQuery(); | |
| 2292 | + if(dates != null){ | |
| 2293 | + query.setPremaritalUpTimeStart(DateUtil.parseYMD(dates[0])); | |
| 2294 | + if (dates.length == 2) { | |
| 2295 | + query.setPremaritalUpTimeEnd(DateUtil.parseYMD(dates[1])); | |
| 2296 | + } | |
| 2297 | + } | |
| 2298 | + query.setHospitalIds(hids); | |
| 2299 | + query.setSexType(1);//女性 | |
| 2300 | + List<PremaritalCheckup> dataNv = premaritalCheckupService.queryPremaritalCheckup(query); | |
| 2301 | + if(dataNv != null && dataNv.size() > 0){ | |
| 2302 | + map.put("woman",dataNv.size()); | |
| 2303 | + }else{ | |
| 2304 | + map.put("woman",0); | |
| 2305 | + } | |
| 2306 | + | |
| 2307 | + query.setSexType(2);//男性 | |
| 2308 | + List<PremaritalCheckup> dataNan = premaritalCheckupService.queryPremaritalCheckup(query); | |
| 2309 | + if(dataNv != null && dataNv.size() > 0){ | |
| 2310 | + map.put("man",dataNan.size()); | |
| 2311 | + }else{ | |
| 2312 | + map.put("man",0); | |
| 2313 | + } | |
| 2314 | + } | |
| 2315 | + series.add(map); | |
| 2316 | + } | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + } | |
| 2320 | + | |
| 2321 | + Map<String, Object> datas = new HashMap<>(); | |
| 2322 | + datas.put("series", series); | |
| 2323 | + datas.put("xAxis", xAxis); | |
| 2324 | + return new BaseObjectResponse().setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS).setData(datas); | |
| 2325 | + | |
| 2326 | + } | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2193 | 2330 | private String strPj(String dstStr,String str) |
| 2194 | 2331 | { |
| 2195 | 2332 | String result = ""; |
| ... | ... | @@ -2264,6 +2401,16 @@ |
| 2264 | 2401 | return str.substring(0,str.length()-1); |
| 2265 | 2402 | } |
| 2266 | 2403 | return ""; |
| 2404 | + } | |
| 2405 | + | |
| 2406 | + private List<String> getConditionHospitalIds(List<String> currentUserHospPermissions, List<Organization> conditionHospitals) { | |
| 2407 | + List<String> hids = new ArrayList<>(); | |
| 2408 | + for (Organization org : conditionHospitals) { | |
| 2409 | + hids.add(String.valueOf(org.getId())); | |
| 2410 | + } | |
| 2411 | + hids.retainAll(currentUserHospPermissions); | |
| 2412 | + | |
| 2413 | + return hids; | |
| 2267 | 2414 | } |
| 2268 | 2415 | |
| 2269 | 2416 | } |