wlzboy
2025-11-09 fa5ea853099e88be253fca4fb2b0c2b7af5f396e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package com.ruoyi.web.controller.system;
 
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.HospData;
import com.ruoyi.system.mapper.HospDataMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
 
/**
 * 医院数据Controller
 * 
 * @author ruoyi
 * @date 2024-01-16
 */
@RestController
@RequestMapping("/system/hospital")
public class HospDataController extends BaseController {
    
    @Autowired
    private HospDataMapper hospDataMapper;
    
    /**
     * 搜索医院
     * 支持根据医院名称、地址、地域进行模糊搜索
     * @param keyword 搜索关键词(医院名称、地址、简称、省市区)
     * @param region 地域关键词(用于过滤省市区)
     */
    @GetMapping("/search")
    public AjaxResult searchHospitals(
            @RequestParam(value = "keyword", required = false) String keyword,
            @RequestParam(value = "region", required = false) String region) {
        List<HospData> list = hospDataMapper.searchHospitals(keyword, region);
        Integer homeHospId=hospDataMapper.getHomeHospId();
        if(homeHospId>0 && list.stream().count()>0 && list.stream().filter(hospData -> hospData.getHospId().equals(homeHospId)).count()<=0) {
            HospData hospData=   hospDataMapper.selectHospDataById(homeHospId);
            list.add(0,hospData);
        }
        return success(list);
    }
    
    /**
     * 根据ID获取医院详情
     */
    @GetMapping("/detail")
    public AjaxResult getHospitalDetail(@RequestParam("hospId") Integer hospId) {
        HospData hospital = hospDataMapper.selectHospDataById(hospId);
        return success(hospital);
    }
    
    /**
     * 获取常用转出医院列表
     * @param serviceOrdClass 分公司编码(service_order_class)
     * @param region 地域关键词(可选)
     */
    @GetMapping("/frequent/out")
    public AjaxResult getFrequentOutHospitals(
            @RequestParam("serviceOrdClass") String serviceOrdClass,
            @RequestParam(value = "region", required = false) String region) {
        // 查询常用转出医院ID列表
        List<Integer> hospIds = hospDataMapper.selectFrequentOutHospitalIds(serviceOrdClass);
        if (hospIds == null || hospIds.isEmpty()) {
            return success();
        }
 
        // 根据ID列表查询医院详情
        List<HospData> hospitals = hospDataMapper.selectHospDataByIds(hospIds, region);
 
        return success(hospitals);
    }
    
    /**
     * 获取常用转入医院列表
     * @param serviceOrdClass 分公司编码(service_order_class)
     * @param region 地域关键词(可选)
     */
    @GetMapping("/frequent/in")
    public AjaxResult getFrequentInHospitals(
            @RequestParam("serviceOrdClass") String serviceOrdClass,
            @RequestParam(value = "region", required = false) String region) {
        // 查询常用转入医院ID列表
        List<Integer> hospIds = hospDataMapper.selectFrequentInHospitalIds(serviceOrdClass);
        if (hospIds == null || hospIds.isEmpty()) {
            return success();
        }
        Integer homeHospId=hospDataMapper.getHomeHospId();
 
        // 根据ID列表查询医院详情
        List<HospData> hospitals = hospDataMapper.selectHospDataByIds(hospIds, region);
        if(homeHospId>0) {
 
         HospData hospData=   hospDataMapper.selectHospDataById(homeHospId);
         hospitals.add(0,hospData);
        }
        return success(hospitals);
    }
}