Commit 0cb689b537e6a3dd115dc7ae59d22270ddaa450f

Authored by gengxiaokai
1 parent b4ce6fe8e5

婚检统计

Showing 1 changed file with 215 additions and 106 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PremaritalCheckupFacade.java View file @ 0cb689b
... ... @@ -2195,149 +2195,258 @@
2195 2195 //获取用户权限医院和筛选条件的交集
2196 2196 List<String> currentUserHospPermissions = areaCountFacade.getCurrentUserHospPermissions2(userId, provinceId,
2197 2197 cityId, areaId);
  2198 + //图标数据
  2199 + List<Map<String, Object>> series = new LinkedList<>();
  2200 + Map<String,Object> hjMap = new HashMap<String,Object>();
  2201 + hjMap.put("name","婚前检查");
  2202 + hjMap.put("type","bar");
  2203 + Map<String,Object> hqwsMap = new HashMap<String,Object>();
  2204 + hqwsMap.put("name","婚前卫生咨询情况");
  2205 + hqwsMap.put("type","bar");
  2206 + List<String> hjList = new ArrayList<String>();
  2207 + List<String> hqwsList = new ArrayList<String>();
  2208 + //标题名称
  2209 + List<String> titleItems = new LinkedList<>();
  2210 + titleItems.add("男婚检人数");
  2211 + titleItems.add("女婚检人数");
  2212 + //x轴标题数据
  2213 + List<String> xAxis = new ArrayList<>();
2198 2214 String[] dates = null;
2199 2215 if (StringUtils.isNotEmpty(time)) {
2200 2216 dates = time.split(" - ");
2201 2217 }
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);
  2218 + if(StringUtils.isNotEmpty(areaId)){//按照医院统计
2211 2219  
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 + for(String hospitalId : currentUserHospPermissions){
  2221 + List<String> shu = new ArrayList<String>();
  2222 + Map<String, Object> map = new HashMap<String, Object>();
  2223 + //查询X轴标题数据
  2224 + OrganizationQuery idQuery = new OrganizationQuery();
  2225 + idQuery.setYn(YnEnums.YES.getId());
  2226 + idQuery.setId(Integer.parseInt(hospitalId));
  2227 + List<Organization> orgs = organizationService.queryOrganization(idQuery);
  2228 +
  2229 + PremaritalCheckupQuery query = new PremaritalCheckupQuery();
  2230 + if (dates != null) {
  2231 + query.setPremaritalUpTimeStart(DateUtil.parseYMD(dates[0]));
  2232 + if (dates.length == 2) {
  2233 + query.setPremaritalUpTimeEnd(DateUtil.parseYMD(dates[1]));
  2234 + }
  2235 + }
  2236 + query.setHospitalId(hospitalId);
  2237 + query.setSexType(2);//男性
  2238 + List<PremaritalCheckup> dataNan = premaritalCheckupService.queryPremaritalCheckup(query);
  2239 + int hunqianHealthMan = 0;
  2240 + int hunqianHealthWoman = 0;
  2241 + int man = 0;
  2242 + int woman = 0;
  2243 + if (dataNan != null && dataNan.size() > 0) {
  2244 + for (PremaritalCheckup data : dataNan) {
  2245 + if (StringUtils.isNotEmpty(data.getHunqianHealth())) {
  2246 + hunqianHealthMan++;
  2247 + }
  2248 + }
  2249 +
  2250 + } else {
  2251 + man = 1;
  2252 + }
  2253 +
  2254 + query.setSexType(1);//女性
  2255 + List<PremaritalCheckup> dataNv = premaritalCheckupService.queryPremaritalCheckup(query);
  2256 + if (dataNv != null && dataNv.size() > 0) {
  2257 + for (PremaritalCheckup data : dataNv) {
  2258 + if (StringUtils.isNotEmpty(data.getHunqianHealth())) {
  2259 + hunqianHealthWoman++;
  2260 + }
  2261 + }
  2262 + } else {
  2263 + woman = 1;
  2264 + }
  2265 + xAxis.add(orgs.get(0).getName());
  2266 + if(man == 1){
  2267 + hjList.add("0");
  2268 + if(woman == 1){
  2269 + hjList.add("0");
  2270 + hqwsList.add("0");
  2271 + hqwsList.add("0");
  2272 + }else{
  2273 + hjList.add(String.valueOf(dataNv.size()));
  2274 + hqwsList.add("0");
  2275 + hqwsList.add(String.valueOf(hunqianHealthWoman));
  2276 + }
  2277 + }else{
  2278 + hjList.add(String.valueOf(dataNan.size()));
  2279 + if(woman == 1){
  2280 + hjList.add("0");
  2281 + hqwsList.add(String.valueOf(hunqianHealthMan));
  2282 + hqwsList.add("0");
  2283 + }else{
  2284 + hjList.add(String.valueOf(dataNv.size()));
  2285 + hqwsList.add(String.valueOf(hunqianHealthMan));
  2286 + hqwsList.add(String.valueOf(hunqianHealthWoman));
  2287 + }
  2288 + }
  2289 + }
  2290 + hjMap.put("data",hjList);
  2291 + hqwsMap.put("data",hqwsList);
  2292 + series.add(hjMap);
  2293 + series.add(hqwsMap);
  2294 + }else{
  2295 + BasicConfigQuery basicQuery = new BasicConfigQuery();
  2296 + basicQuery.setYn(YnEnums.YES.getId());
  2297 + basicQuery.setTypeId("b7ea005c-dfac-4c2a-bdae-25239b3f44fd");
  2298 + //用来存放省、市、县的ID的集合
  2299 + List<String> ids = new ArrayList<>();
  2300 + //查询当前登录用户管辖的所有医院
  2301 + DataPermissionsModelQuery dataPermissionsModelQuery = new DataPermissionsModelQuery();
  2302 + dataPermissionsModelQuery.setUserId(userId);
  2303 + List<DataPermissionsModel> permissionsModels = dataPermissionService.queryPermission(dataPermissionsModelQuery);
  2304 +
  2305 + int addrType = 0;
  2306 + if (StringUtils.isNotEmpty(provinceId)) {
  2307 + ids = new ArrayList<>();
  2308 + if (CollectionUtils.isNotEmpty(permissionsModels)) {
  2309 + List<AddressBean> addressBeanList = JsonUtil.toList(permissionsModels.get(0).getAreaPermission(), AddressBean.class);
  2310 + if (CollectionUtils.isNotEmpty(addressBeanList))
2220 2311 {
2221   - if (bean != null && bean.getP() != null && bean.getP().equals(provinceId) && StringUtils.isNotEmpty(bean.getC()))
  2312 + for (AddressBean bean : addressBeanList)
2222 2313 {
2223   - //省不为空,赋值所有市的id
2224   - ids.add(bean.getC());
  2314 + if (bean != null && bean.getP() != null && bean.getP().equals(provinceId) && StringUtils.isNotEmpty(bean.getC()))
  2315 + {
  2316 + //省不为空,赋值所有市的id
  2317 + ids.add(bean.getC());
  2318 + }
2225 2319 }
2226 2320 }
2227 2321 }
  2322 + basicQuery.setIds(ids);
  2323 + addrType = 1;
2228 2324 }
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)
  2325 + if (StringUtils.isNotEmpty(cityId)) {
  2326 + ids = new ArrayList<>();
  2327 + if (CollectionUtils.isNotEmpty(permissionsModels)) {
  2328 + List<AddressBean> addressBeanList = JsonUtil.toList(permissionsModels.get(0).getAreaPermission(), AddressBean.class);
  2329 + if (CollectionUtils.isNotEmpty(addressBeanList))
2239 2330 {
2240   - if (bean != null && bean.getC() != null && bean.getC().equals(cityId) && StringUtils.isNotEmpty(bean.getA()))
  2331 + for (AddressBean bean : addressBeanList)
2241 2332 {
2242   - //市不为空,赋值所有县的id
2243   - ids.add(bean.getA());
  2333 + if (bean != null && bean.getC() != null && bean.getC().equals(cityId) && StringUtils.isNotEmpty(bean.getA()))
  2334 + {
  2335 + //市不为空,赋值所有县的id
  2336 + ids.add(bean.getA());
  2337 + }
2244 2338 }
2245 2339 }
2246 2340 }
  2341 + basicQuery.setIds(ids);
  2342 + addrType = 2;
2247 2343 }
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());
  2344 +
  2345 + //获取地址列表
  2346 + List<BasicConfig> configList = new ArrayList<>();
  2347 + if (CollectionUtils.isNotEmpty(ids))
  2348 + {
  2349 + configList = basicConfigService.queryBasicConfig(basicQuery);
2262 2350 }
2263   - }
2264   - //标题名称
2265   - List<String> titleItems = new LinkedList<>();
2266   - titleItems.add("男婚检人数");
2267   - titleItems.add("女婚检人数");
  2351 + if (CollectionUtils.isNotEmpty(configList)) {
  2352 + for (BasicConfig addr : configList) {
  2353 + xAxis.add(addr.getName());
  2354 + }
  2355 + }
2268 2356  
2269   - //图标数据
2270   - List<Map<String, Object>> series = new LinkedList<>();
2271   - if (CollectionUtils.isNotEmpty(configList)) {
  2357 + if (CollectionUtils.isNotEmpty(configList)) {
2272 2358  
2273 2359  
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());
  2360 + for (BasicConfig c : configList) {
  2361 + Map<String, Object> map = new HashMap<String, Object>();
  2362 + OrganizationQuery idQuery = new OrganizationQuery();
  2363 + idQuery.setYn(YnEnums.YES.getId());
2278 2364  
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);
  2365 + //查询机构数
  2366 + if (addrType == 1) {
  2367 + idQuery.setCityId(c.getId());
  2368 + } else if (addrType == 2) {
  2369 + idQuery.setAreaId(c.getId());
  2370 + }
  2371 + List<Organization> orgs = organizationService.queryOrganization(idQuery);
  2372 + List<String> hids = getConditionHospitalIds(currentUserHospPermissions, orgs);
2287 2373  
2288   - if (CollectionUtils.isNotEmpty(hids))
2289   - {
  2374 + if (CollectionUtils.isNotEmpty(hids)) {
2290 2375  
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]));
  2376 + PremaritalCheckupQuery query = new PremaritalCheckupQuery();
  2377 + if (dates != null) {
  2378 + query.setPremaritalUpTimeStart(DateUtil.parseYMD(dates[0]));
  2379 + if (dates.length == 2) {
  2380 + query.setPremaritalUpTimeEnd(DateUtil.parseYMD(dates[1]));
  2381 + }
2296 2382 }
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());
  2383 + query.setHospitalIds(hids);
  2384 + query.setSexType(2);//男性
  2385 + List<PremaritalCheckup> dataNan = premaritalCheckupService.queryPremaritalCheckup(query);
  2386 + int hunqianHealthMan = 0;
2303 2387 int hunqianHealthWoman = 0;
2304   - for(PremaritalCheckup data : dataNv){
2305   - if(StringUtils.isNotEmpty(data.getHunqianHealth())){
2306   - hunqianHealthWoman++;
  2388 + int man = 0;
  2389 + int woman = 0;
  2390 + if (dataNan != null && dataNan.size() > 0) {
  2391 + for (PremaritalCheckup data : dataNan) {
  2392 + if (StringUtils.isNotEmpty(data.getHunqianHealth())) {
  2393 + hunqianHealthMan++;
  2394 + }
2307 2395 }
  2396 +
  2397 + } else {
  2398 + man = 1;
2308 2399 }
2309   - map.put("hunqianHealthWoman",hunqianHealthWoman);
2310   - }else{
2311   - map.put("woman", 0);
2312   - map.put("hunqianHealthWoman",0);
2313   - }
2314 2400  
2315   - query.setSexType(2);//男性
2316   - List<PremaritalCheckup> dataNan = premaritalCheckupService.queryPremaritalCheckup(query);
2317   - if(dataNv != null && dataNv.size() > 0){
2318   - map.put("man",dataNan.size());
2319   - int hunqianHealthMan = 0;
2320   - for(PremaritalCheckup data : dataNan){
2321   - if(StringUtils.isNotEmpty(data.getHunqianHealth())){
2322   - hunqianHealthMan++;
  2401 + query.setSexType(1);//女性
  2402 + List<PremaritalCheckup> dataNv = premaritalCheckupService.queryPremaritalCheckup(query);
  2403 + if (dataNv != null && dataNv.size() > 0) {
  2404 + for (PremaritalCheckup data : dataNv) {
  2405 + if (StringUtils.isNotEmpty(data.getHunqianHealth())) {
  2406 + hunqianHealthWoman++;
  2407 + }
2323 2408 }
  2409 + } else {
  2410 + woman = 1;
2324 2411 }
2325   - map.put("hunqianHealthMan",hunqianHealthMan);
2326   - }else{
2327   - map.put("man",0);
2328   - map.put("hunqianHealthMan",0);
  2412 + xAxis.add(orgs.get(0).getName());
  2413 + if(man == 1){
  2414 + hjList.add("0");
  2415 + if(woman == 1){
  2416 + hjList.add("0");
  2417 + hqwsList.add("0");
  2418 + hqwsList.add("0");
  2419 + }else{
  2420 + hjList.add(String.valueOf(dataNv.size()));
  2421 + hqwsList.add("0");
  2422 + hqwsList.add(String.valueOf(hunqianHealthWoman));
  2423 + }
  2424 + }else{
  2425 + hjList.add(String.valueOf(dataNan.size()));
  2426 + if(woman == 1){
  2427 + hjList.add("0");
  2428 + hqwsList.add(String.valueOf(hunqianHealthMan));
  2429 + hqwsList.add("0");
  2430 + }else{
  2431 + hjList.add(String.valueOf(dataNv.size()));
  2432 + hqwsList.add(String.valueOf(hunqianHealthMan));
  2433 + hqwsList.add(String.valueOf(hunqianHealthWoman));
  2434 + }
  2435 + }
2329 2436 }
  2437 +
2330 2438 }
2331   - series.add(map);
  2439 + hjMap.put("data",hjList);
  2440 + hqwsMap.put("data",hqwsList);
  2441 + series.add(hjMap);
  2442 + series.add(hqwsMap);
2332 2443 }
2333   -
2334   -
2335 2444 }
2336 2445  
2337 2446 Map<String, Object> datas = new HashMap<>();
2338 2447 datas.put("series", series);
2339 2448 datas.put("xAxis", xAxis);
2340   - datas.put("titleItems",titleItems);
  2449 + datas.put("legend",titleItems);
2341 2450 return new BaseObjectResponse().setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS).setData(datas);
2342 2451  
2343 2452 }