医院废弃物信息化管理平台
“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
package cn.besteam.modules.medical.controller;
 
import cn.besteam.common.api.vo.Result;
import cn.besteam.common.aspect.annotation.AutoLog;
import cn.besteam.common.constant.DepartmentEnum;
import cn.besteam.common.constant.ErrorCode;
import cn.besteam.common.constant.MedicalWasteEnum;
import cn.besteam.common.dto.IdDTO;
import cn.besteam.common.exception.BusinessException;
import cn.besteam.modules.medical.entity.MwWarningConfigItemPlatform;
import cn.besteam.modules.medical.service.IMwWarningConfigItemPlatformService;
import cn.besteam.modules.system.entity.SysDepartment;
import cn.besteam.modules.system.service.ISysDepartmentService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
 
/**
 * @Title: Controller
 * @Description: 预警-自定义配置-平台
 * @author: besteam
 * @date: 2020-07-17
 * @version: V1.0
 */
@RestController
@RequestMapping("/medical/mwWarningConfigItemPlatform")
@Slf4j
@Api(description = "预警-自定义配置-平台")
public class MwWarningConfigItemPlatformController {
 
    @Autowired
    private IMwWarningConfigItemPlatformService mwWarningConfigItemService;
 
    @Autowired
    private ISysDepartmentService sysDepartmentService;
 
    /**
     * @param type
     * @return
     */
    @GetMapping(value = "/listByType")
    @ApiOperation(value = "获取预警平台-自定义配置数据列表(新)", notes = "获取所有预警-自定义配置数据列表", produces = "application/json")
    public Object listByType(@RequestParam Integer type, Integer departmentId,  Integer pageNo,  Integer pageSize) {
        if(pageNo==null || pageSize==null){
            return Result.ok(mwWarningConfigItemService.listByType(type, departmentId));
        }else {
            return Result.ok(mwWarningConfigItemService.listByType(type, departmentId, pageNo, pageSize));
        }
    }
 
    /**
     * 添加
     *
     * @param mwWarningConfigItem
     * @return
     */
    @PostMapping(value = "/add")
    @AutoLog(value = "添加预警平台-自定义配置(新)")
    @ApiOperation(value = "添加预警平台-自定义配置(新)", notes = "添加预警-自定义配置", produces = "application/json")
    public Result<Boolean> add(@RequestBody MwWarningConfigItemPlatform mwWarningConfigItem) {
 
        if (mwWarningConfigItem.getType() == null) {
            throw new BusinessException(ErrorCode.ERR_500, "类型不能为空");
        }
        //
        QueryWrapper<MwWarningConfigItemPlatform> queryWrapper = new QueryWrapper<>();
        SysDepartment department = sysDepartmentService.getById(mwWarningConfigItem.getCustomDepartmentId());
        if (mwWarningConfigItem.getType().equals(MedicalWasteEnum.WarningConfigTypeEnum.NON_COLLECT.getType())) {
            if (department == null || !department.getOrgType().equals(DepartmentEnum.OrgTypeEnum.AREA.getType())) {
                throw new BusinessException(ErrorCode.ERR_500, "区域不存在");
            }
            queryWrapper.lambda().eq(MwWarningConfigItemPlatform::getCustomDepartmentId, mwWarningConfigItem.getCustomDepartmentId()).eq(MwWarningConfigItemPlatform::getCustomDepartmentId, mwWarningConfigItem.getCustomDepartmentId())
                    .eq(MwWarningConfigItemPlatform::getApplyType,1);
        } else if (mwWarningConfigItem.getType().equals(MedicalWasteEnum.WarningConfigTypeEnum.CHECKOUT_OVER_TIME.getType())) {
            if (department == null || !department.getOrgType().equals(DepartmentEnum.OrgTypeEnum.HOSPITAL.getType())) {
                throw new BusinessException(ErrorCode.ERR_500, "区域不存在");
            }
            queryWrapper.lambda().eq(MwWarningConfigItemPlatform::getCustomDepartmentId, mwWarningConfigItem.getCustomDepartmentId()).eq(MwWarningConfigItemPlatform::getWasteType, mwWarningConfigItem.getWasteType())
            .eq(MwWarningConfigItemPlatform::getApplyType,1);
        }
        mwWarningConfigItem.setStatus(1);
        Boolean result=mwWarningConfigItemService.save(mwWarningConfigItem);
        return Result.ok(result);
    }
 
    /**
     * 编辑
     *
     * @param mwWarningConfigItem
     * @return
     */
    @PostMapping(value = "/edit")
    @AutoLog(value = "编辑预警平台-自定义配置(新)")
    @ApiOperation(value = "编辑预警平台-自定义配置(新)", notes = "编辑预警-自定义配置", produces = "application/json")
    public Result<Boolean> edit(@RequestBody MwWarningConfigItemPlatform mwWarningConfigItem) {
 
        MwWarningConfigItemPlatform mwWarningConfigItemEntity = mwWarningConfigItemService.getById(mwWarningConfigItem.getId());
        if (mwWarningConfigItemEntity == null) {
            throw new BusinessException(ErrorCode.ERR_500, "自定义配置不存在");
        }
        int count = 0;
        QueryWrapper<MwWarningConfigItemPlatform> queryWrapper = new QueryWrapper<>();
        SysDepartment department = sysDepartmentService.getById(mwWarningConfigItem.getCustomDepartmentId());
        if (mwWarningConfigItem.getType().equals(MedicalWasteEnum.WarningConfigTypeEnum.NON_COLLECT.getType())) {
            if (department == null || !department.getOrgType().equals(DepartmentEnum.OrgTypeEnum.AREA.getType())) {
                throw new BusinessException(ErrorCode.ERR_500, "区域不存在");
            }
            queryWrapper.lambda().ne(MwWarningConfigItemPlatform::getId,mwWarningConfigItem.getId()).eq(MwWarningConfigItemPlatform::getCustomDepartmentId, mwWarningConfigItem.getCustomDepartmentId()).eq(MwWarningConfigItemPlatform::getCustomDepartmentId, mwWarningConfigItem.getCustomDepartmentId())
                    .eq(MwWarningConfigItemPlatform::getApplyType,1);
            count = mwWarningConfigItemService.count(queryWrapper);
        } else if (mwWarningConfigItem.getType().equals(MedicalWasteEnum.WarningConfigTypeEnum.CHECKOUT_OVER_TIME.getType())) {
            if (department == null || !department.getOrgType().equals(DepartmentEnum.OrgTypeEnum.HOSPITAL.getType())) {
                throw new BusinessException(ErrorCode.ERR_500, "区域不存在");
            }
            queryWrapper.lambda().ne(MwWarningConfigItemPlatform::getId,mwWarningConfigItem.getId()).eq(MwWarningConfigItemPlatform::getCustomDepartmentId, mwWarningConfigItem.getCustomDepartmentId()).eq(MwWarningConfigItemPlatform::getWasteType, mwWarningConfigItem.getWasteType())
                    .eq(MwWarningConfigItemPlatform::getApplyType,1);
            count = mwWarningConfigItemService.count(queryWrapper);
        }
        if (count > 0) {
            throw new BusinessException(ErrorCode.ERR_500, "自定义设置已存在");
        }
        return Result.ok(mwWarningConfigItemService.updateById(mwWarningConfigItem));
    }
 
    /**
     * 通过id删除
     *
     * @param idDTO
     * @return
     */
    @PostMapping(value = "/delete")
    @AutoLog(value = "删除预警平台-自定义配置(新)")
    @ApiOperation(value = "删除预警平台-自定义配置(新)", notes = "删除预警-自定义配置", produces = "application/json")
    public Result<Boolean> delete(@RequestBody IdDTO idDTO) {
 
        MwWarningConfigItemPlatform mwWarningConfigItem = mwWarningConfigItemService.getById(idDTO.getId());
        if (mwWarningConfigItem == null) {
            throw new BusinessException(ErrorCode.ERR_500, "自定义配置不存在");
        }
        return Result.ok(mwWarningConfigItemService.removeById(idDTO.getId()));
    }
 
}