sinake
3 天以前 b542bb002d9dc8e12cf4bd8bb54dc4aa0b4bb67d
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
package com.ruoyi.project.service.impl;
 
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SmsUtils;
import com.ruoyi.project.domain.GiLink;
import com.ruoyi.project.mapper.ApiMapper;
import com.ruoyi.project.mapper.GiLinkMapper;
import com.ruoyi.project.service.IGiLinkService;
import com.ruoyi.system.service.ISysUserService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
 
import java.util.Random;
 
@Service
public class GiLinkService  extends ServiceImpl<GiLinkMapper, GiLink> implements IGiLinkService {
    @Autowired
    GiLinkMapper mapper;
    @Autowired
    private ISysUserService userService;
    @Autowired
    private IGiLinkService linkService;
    @Value("${link.report_url}")
    private String reportUrl;
    @Value("${link.expert_url}")
    private String expertUrl;
    public String Add(GiLink model) {
        Integer maxid = mapper.getMaxID();
        Random rand = new Random();
        String code = maxid + String.format("%x", rand.nextInt(100));
        model.setCode(code);
        Integer res = mapper.insert(model);
        if (res == 1)
            return code;
        else
            return "";
    }
    /**
     * 上报发送短信
     * @param id 上报id
     * @param coordinatorNo 协调员编号
     * @param toHospital 上报医院
     */
    public String SendReport(Long id,String coordinatorNo,String toHospital){
        String res="";
        SysUser user= userService.selectUserByUserName(coordinatorNo);
        if(user!=null&& ObjectUtils.isNotEmpty(user.getPhonenumber())) {
            GiLink link=new GiLink();
            link.setUserName(user.getUserName());
            link.setUserPhone(user.getPhonenumber());
            link.setExtContent("{\"id\":\""+id+"\"}");
            String code=linkService.Add(link);
            reportUrl += "?code=" + code;
            String content = "案例上报通知:【青岛大学附属医院】" + toHospital
                    + "上报潜在捐献案例,请登录OPO系统查看详细信息,及时进行对接。登录链接:" + reportUrl + " 。";
            SmsUtils sms=new SmsUtils();
            res=sms.send(user.getPhonenumber(),content);
        }
        return res;
    }
 
    /**
     * 专家发送短信
     * @param id 专家意见id
     * @param expertNo 专家编号
     * @param infoId 案例id
     */
    public String SendExpert(String id,String expertNo,String infoId){
        String res="";
        SysUser user= userService.selectUserByUserName(expertNo);
        if(user!=null&& ObjectUtils.isNotEmpty(user.getPhonenumber())) {
            GiLink link=new GiLink();
            link.setUserName(user.getUserName());
            link.setUserPhone(user.getPhonenumber());
            link.setExtContent("{\"id\":\""+id+"\",\"type\": \"review\",\"status\": \"1\",\"infoId\": \""+infoId+"\"}");
            String code=linkService.Add(link);
            expertUrl += "?code=" + code;
            String content = "伦理专家审查通知:【青岛大学附属医院】尊敬的专家您好!您有紧急人体器官移植伦理审查申请待处理," +
                    "请务必于1小时内登录医院OPO系统进行审批。登录链接: " + expertUrl + "。谢谢 。";
            SmsUtils sms=new SmsUtils();
            res=sms.send(user.getPhonenumber(),content);
        }
        return res;
    }
}