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 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; } }