医院废弃物信息化管理平台
“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
package cn.besteam.modules.medical.service.impl;
 
import cn.besteam.modules.medical.dto.MwWarningRecordDealDTO;
import cn.besteam.modules.medical.entity.MwMessage;
import cn.besteam.modules.medical.entity.MwWarningRecord;
import cn.besteam.modules.medical.entity.MwWarningRecordDeal;
import cn.besteam.modules.medical.mapper.MwWarningRecordDealMapper;
import cn.besteam.modules.medical.service.IMwMessageService;
import cn.besteam.modules.medical.service.IMwWarningRecordDealService;
import cn.besteam.modules.medical.service.IMwWarningRecordService;
import cn.besteam.modules.medical.vo.MwNoticeVO;
import cn.besteam.modules.medical.vo.MwWarningRecordDealVO;
import cn.besteam.modules.shiro.authc.util.EnvUtils;
import cn.besteam.modules.system.biz.AliSmsService;
import cn.besteam.modules.system.entity.SysDepartment;
import cn.besteam.modules.system.service.ISysDepartmentService;
import cn.besteam.modules.system.service.ISysUserRoleService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
import java.util.HashMap;
import java.util.Map;
 
/**
 * @Description: 预警消息处理
 * @author: besteam
 * @date:   2022-02-15
 * @version: V1.0
 */
@Service
public class MwWarningRecordDealServiceImpl extends ServiceImpl<MwWarningRecordDealMapper, MwWarningRecordDeal> implements IMwWarningRecordDealService {
    @Autowired
    private IMwMessageService mwMessageService;
    @Autowired
    private IMwWarningRecordService mwWarningRecordService;
    @Autowired
    private ISysUserRoleService sysUserRoleService;
    @Autowired
    private AliSmsService aliSmsService;
    @Autowired
    private ISysDepartmentService sysDepartmentService;
 
 
 
    @Override
    public IPage<MwWarningRecordDealVO> queryPageList(Integer pageNo, Integer pageSize, MwWarningRecordDealDTO mwWarningRecordDealDTO) {
        Page<MwWarningRecordDealVO> page = new Page<>(pageNo, pageSize);
        IPage<MwWarningRecordDealVO> result = baseMapper.queryPageList(page, mwWarningRecordDealDTO);
        return result;
    }
 
    @Override
    public Boolean add(MwWarningRecordDeal mwWarningRecordDeal) {
        if(mwWarningRecordDeal.getWarningRecordId()!=null) {
            String[] warningRecordIds=mwWarningRecordDeal.getWarningRecordId().split(",");
            for(String warningRecordId_:warningRecordIds) {
                Integer warningRecordId = Integer.valueOf(warningRecordId_.trim());
                MwWarningRecord mwWarningRecord = mwWarningRecordService.getById(warningRecordId);
                if (mwWarningRecordDeal.getType() == 1) {//提醒
                    String content = "";
                    String userIds = "";
                    String userPhones = "";
                    Integer hospitalId = 0;
                    Integer count = mwWarningRecordService.count(new QueryWrapper<MwWarningRecord>()
                            .eq("hospital_id", mwWarningRecord.getHospitalId())
                            .eq("status", 1));
                    hospitalId = mwWarningRecord.getHospitalId();
                    SysDepartment sysDepartment = sysDepartmentService.getById(hospitalId);
                    if(sysDepartment!=null){
                        content = sysDepartment.getDepartName()+",温馨提醒,您有" + count + "条预警未处理,请及时处理!";
                    }else {
                        content = "温馨提醒,您有" + count + "条预警未处理,请及时处理!";
                    }
 
                    if (mwWarningRecord != null) {
                        hospitalId = mwWarningRecord.getHospitalId();
                        //温馨提醒,您有X条预警未处理,请及时处理!
                        if (mwWarningRecordDeal.getRemindWay() != null
                                && mwWarningRecordDeal.getRemindWay().contains("1")) {//短信
                            if (mwWarningRecord.getLevel() == 2) {//2等级预警通知一级预警人员
                                userPhones = sysUserRoleService.getUserPhoneList("23", hospitalId);//一级预警人员
                            } else if (mwWarningRecord.getLevel() == 3) {//3等级预警通知一二级预警人员
                                userPhones = sysUserRoleService.getUserPhoneList("23,24", hospitalId);//一,二级预警人员
                            }
                            Map<String, String> param = new HashMap<>();
                            //todo 短信发送通知消息
                            //aliSmsService.sendMessage(userPhones, param);
 
                        } else if (mwWarningRecordDeal.getRemindWay() != null
                                && mwWarningRecordDeal.getRemindWay().contains("2")) {//通知消息
                            MwMessage mwMessage = new MwMessage();
                            mwMessage.setTitle("预警提醒");
                            mwMessage.setPromulgator(EnvUtils.getUser().getName());
                            if (mwWarningRecord != null && mwWarningRecord.getLevel() == 2) {//2等级预警通知一级预警人员
                                userIds = sysUserRoleService.getUserIdList("23", hospitalId);//一级预警人员
                            } else if (mwWarningRecord != null && mwWarningRecord.getLevel() == 3) {//3等级预警通知一二级预警人员
                                userIds = sysUserRoleService.getUserIdList("23,24", hospitalId);//一,二级预警人员
                            }
                            mwMessage.setUserId(userIds);
                            mwMessage.setContent(content);
                            mwMessage.setWarningRecordId(warningRecordId);
                            mwMessage.setStatus(0);
                            mwMessageService.save(mwMessage);
                        }
 
                    }
                    mwWarningRecord.setSuperviseCount(mwWarningRecord.getSuperviseCount() + 1);
                    mwWarningRecordService.updateById(mwWarningRecord);
                } else {
                    mwWarningRecord.setMessageCount(mwWarningRecord.getMessageCount() + 1);
                    mwWarningRecordService.updateById(mwWarningRecord);
                }
                mwWarningRecordDeal.setWarningRecordId(warningRecordId+"");
                this.baseMapper.insert(mwWarningRecordDeal);
            }
        }
 
        return true ;
    }
}