医院废弃物信息化管理平台
“mitao”
2025-12-24 3763145f34d7706923d55edc32f5cfbc8bc08b92
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
package cn.besteam.modules.api.controller;
 
import cn.besteam.common.api.vo.Result;
import cn.besteam.common.aspect.annotation.LogApi;
import cn.besteam.common.aspect.annotation.OpenApi;
import cn.besteam.common.constant.CommonConstant;
import cn.besteam.common.constant.ErrorCode;
import cn.besteam.common.exception.BusinessException;
import cn.besteam.modules.medical.entity.MwDeviceAgentDevice;
import cn.besteam.modules.medical.service.IMwDeviceAgentDeviceService;
import cn.besteam.modules.medical.service.IMwTransitConfigService;
import cn.besteam.modules.shiro.authc.util.EnvUtils;
import cn.besteam.modules.system.biz.SysDepartmentBiz;
import cn.besteam.modules.system.dto.*;
import cn.besteam.modules.system.entity.SysDepartment;
import cn.besteam.modules.system.entity.SysUser;
import cn.besteam.modules.system.service.ISysDepartmentService;
import cn.besteam.modules.system.service.ISysRolePermissionService;
import cn.besteam.modules.system.service.ISysUserService;
import cn.besteam.modules.system.vo.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.Map;
 
@RestController
@RequestMapping("/api/user")
@Api(value = "用户相关")
public class ApiUserController {
 
    @Autowired
    private ISysUserService sysUserService;
 
    @Autowired
    private SysDepartmentBiz sysDepartmentBiz;
 
    @Autowired
    private IMwDeviceAgentDeviceService mwDeviceAgentDeviceService;
 
    @Autowired
    private ISysRolePermissionService sysRolePermissionService;
 
    @Autowired
    private IMwTransitConfigService mwTransitConfigService;
 
    @Autowired
    private ISysDepartmentService departmentService;
 
 
 
    @ApiOperation(value = "APP登录")
    @OpenApi
    @PostMapping("/login")
    @LogApi(value = "APP登录")
    public Result<AppSysUserVO> login(@Validated @RequestBody SysUserLoginDTO dto) {
        if(null != dto.getSn()){
            MwDeviceAgentDevice device = mwDeviceAgentDeviceService.getOne(new QueryWrapper<MwDeviceAgentDevice>().lambda().eq(MwDeviceAgentDevice::getSn, dto.getSn()).eq(MwDeviceAgentDevice::getStatus, CommonConstant.STATUS_NORMAL));
            if (device == null) {
                Integer deviceValidateStatus = mwDeviceAgentDeviceService.getDeviceValidateStatus();
                if (deviceValidateStatus.equals(1)) {
                    throw new BusinessException(ErrorCode.ERR_500, "未授权设备");
                }
            }
        }
        AppSysUserVO current = sysUserService.appLogin(dto);
        fillAppSysUserVO(current, dto.getAccount());
        return Result.ok(current);
    }
 
    private void fillAppSysUserVO(AppSysUserVO current, String account) {
 
        current.setOfficeList(sysDepartmentBiz.getMyOfficeListByApp(current.getId()));
        current.setOfficeUserList(sysUserService.getUserListByApp(current.getId()));
        current.setPermissionList(sysRolePermissionService.getAppPermissionList(current.getRoleId()));
        current.setTransitConfigList(mwTransitConfigService.listAppSelect(current.getDepartmentId()));
        if(null == account){
            return;
        }
        SysUser one = sysUserService.getOne(new QueryWrapper<SysUser>().lambda().eq(SysUser::getAccount, account).eq(SysUser::getDelFlag, 0));
        SysDepartment myDepartment = departmentService.getMyDepartment(one.getId());
        if(null != myDepartment){
            SysDepartment hospital = departmentService.getHospital(myDepartment.getParentId());
            if(null != hospital){
                SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                current.setExpireDate(null == hospital.getExpireDate() ? "" : sdf.format(hospital.getExpireDate()));
                current.setHospitalId(hospital.getId());
                current.setReminderDays(hospital.getReminderDays());
            }
        }
    }
 
    @ApiOperation(value = "APP扫码登录")
    @OpenApi
    @PostMapping("/loginByCode")
    @LogApi(value = "APP扫码登录")
    public Result<SysUserVO> loginByCode(@Validated @RequestBody SysUserLoginByCodeDTO dto) {
 
        MwDeviceAgentDevice device = mwDeviceAgentDeviceService.getOne(new QueryWrapper<MwDeviceAgentDevice>().lambda().eq(MwDeviceAgentDevice::getSn, dto.getSn()).eq(MwDeviceAgentDevice::getStatus, CommonConstant.STATUS_NORMAL));
        if (device == null) {
            Integer deviceValidateStatus = mwDeviceAgentDeviceService.getDeviceValidateStatus();
            if (deviceValidateStatus.equals(1)) {
                throw new BusinessException(ErrorCode.ERR_500, "未授权设备");
            }
        }
        AppSysUserVO current = sysUserService.appLoginByCode(dto.getCode(), dto.getSn());
        fillAppSysUserVO(current, null);
        return Result.ok(current);
    }
 
    @GetMapping("/current")
    @ApiOperation("获取当前用户信息")
    @LogApi(value = "获取当前用户信息")
    public Result<SysUserVO> current() {
 
        SysUserVO loginUser = sysUserService.current();
        AppSysUserVO current = new AppSysUserVO();
        BeanUtils.copyProperties(loginUser, current);
        fillAppSysUserVO(current, null);
        return Result.ok(current);
    }
 
    @OpenApi
    @GetMapping("/getValidateCode")
    @ApiOperation("发送验证码")
    @LogApi(value = "发送验证码")
    public Result<Boolean> getValidateCode(@RequestParam("account") String account, @RequestParam("phone") String phone) {
 
        return Result.ok(sysUserService.getValidateCode(account, phone, true));
    }
 
    @OpenApi
    @PostMapping("/checkValidateCode")
    @ApiOperation("检查验证码")
    @LogApi(value = "检查验证码")
    public Result<Boolean> checkValidateCode(@Validated @RequestBody SysUserForgotPwdDTO dto) {
 
        return Result.ok(sysUserService.checkValidateCode(dto.getAccount(), dto.getPhone(), dto.getValidateCode()));
    }
 
    @OpenApi
    @PostMapping("/resetPassword")
    @ApiOperation("重置密码")
    @LogApi(value = "重置密码")
    public Result<Boolean> resetPassword(@Validated @RequestBody SysUserPwdDTO dto) {
 
        return Result.ok(sysUserService.resetPassword(dto.getAccount(), dto.getPhone(), dto.getValidateCode(), dto.getPassword()));
    }
 
    @PostMapping("/updatePassword")
    @ApiOperation("修改密码")
    @LogApi(value = "修改密码")
    public Result<Boolean> updatePassword(@Validated @RequestBody SysUserUpdatePwdDTO dto) {
 
        return Result.ok(sysUserService.updatePassword(dto.getOriginPassword(), dto.getPassword()));
    }
 
    @GetMapping(value = "/getMyHospitalList")
    @ApiOperation(value = "获取我的医院列表", notes = "获取我的医院列表", produces = "application/json")
    @LogApi(value = "获取我的医院列表")
    public Result<?> getMyHospitalList() {
 
        return Result.ok(sysDepartmentBiz.getMyHospitalList());
    }
 
    @GetMapping(value = "/getMyOfficeList")
    @ApiOperation(value = "获取我的科室列表", notes = "获取我的科室列表", produces = "application/json")
    @LogApi(value = "获取我的科室列表")
    public Result<?> getMyOfficeList() {
 
        return Result.ok(sysDepartmentBiz.getMyOfficeListByApp(EnvUtils.getUser().getId()));
    }
 
    @GetMapping(value = "/getOfficeUserList")
    @ApiOperation(value = "获取科室人员列表", notes = "获取科室人员列表", produces = "application/json")
    @LogApi(value = "获取科室人员列表")
    public Result<?> getMyOfficeUserList() {
 
        return Result.ok(sysUserService.getUserListByApp(EnvUtils.getUser().getId()));
    }
 
    @GetMapping(value = "/getMyWarehouseOfficeList")
    @ApiOperation(value = "获取我的暂存间列表", notes = "获取我的暂存间列表", produces = "application/json")
    @LogApi(value = "获取我的暂存间列表")
    public Result<?> getMyWarehouseOfficeList() {
 
        return Result.ok(sysDepartmentBiz.getMyWarehouseOfficeList(null));
    }
 
 
    @OpenApi
    @PostMapping(value = "/getPayUrl")
    @ApiOperation(value = "获取支付连接", notes = "获取支付连接", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "医院id", required = true, dataType = "int", format = "query")
    })
    @LogApi(value = "获取支付连接")
    public Result<?> getPayUrl(@Validated @RequestParam Integer id){
        return Result.ok(sysUserService.getPayUrl(id));
    }
 
 
 
    @OpenApi
    @PostMapping(value = "/NouNouPayCallback")
    @LogApi(value = "支付成功回调")
    public void NouNouPayCallback(@RequestBody Map<String,Object> map, HttpServletResponse response){
        sysUserService.NouNouPayCallback(map, response);
    }
 
    @OpenApi
    @PostMapping(value = "/getPayStatus")
    @ApiOperation(value = "查询支付结果", notes = "查询支付结果", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "订单号", required = true, dataType = "string", format = "query")
    })
    public Result<?> getPayStatus(@Validated @RequestParam String code){
        return Result.ok(sysUserService.getPayStatus(code));
    }
 
 
}