| | |
| | | import cn.gistack.alerts.sms.entity.SmsRequest; |
| | | import cn.gistack.alerts.sms.entity.SmsResult; |
| | | import cn.gistack.alerts.sms.excel.SendRainSmsExcel; |
| | | import cn.gistack.alerts.sms.excel.SendSmsExcel; |
| | | import cn.gistack.alerts.sms.listener.ExcelListener; |
| | | import cn.gistack.alerts.sms.service.SmsService; |
| | | import cn.gistack.alerts.sms.util.SmsUtils; |
| | | import cn.gistack.alerts.sms.vo.SmsRequestTemplate; |
| | | import cn.gistack.alerts.sms.vo.SmsResponseVO; |
| | | import cn.gistack.sm.intelligentCall.excel.CallExcel; |
| | | import cn.gistack.system.user.entity.User; |
| | | import cn.gistack.system.user.feign.IUserClient; |
| | | import com.alibaba.excel.EasyExcel; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.excel.util.ExcelUtil; |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | // 导入并返回 |
| | | return R.data(smsService.batchSendSms(map)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导入表格发送预警短信 |
| | | * @param file excel文件 |
| | | * @param templateId 模板id |
| | | * @param param 通用参数 |
| | | * @param content 发送内容 |
| | | * @return |
| | | */ |
| | | @PostMapping("/import-send-sms") |
| | | public R importSendSms(MultipartFile file,String templateId,String param,String content){ |
| | | ExcelListener<SendSmsExcel> listener = new ExcelListener<>(); |
| | | //headRowNumber(1)从第2行开始读取,使用getDatas()方法取出数据 |
| | | try { |
| | | EasyExcel.read(file.getInputStream(), SendSmsExcel.class, listener).headRowNumber(1).sheet(0).doRead(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | List<SendSmsExcel> list = listener.getDatas(); |
| | | // 导入并返回 |
| | | return R.data(smsService.importSendSms(list,templateId,param,content)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导出模板 |
| | | */ |
| | | @GetMapping("/export-template") |
| | | @ApiOperation(value = "导出模板") |
| | | public void exportTemplate(HttpServletResponse response) { |
| | | List<SendSmsExcel> list = new ArrayList<>(); |
| | | ExcelUtil.export(response, "短信发送数据模板", "短信发送数据表", list, SendSmsExcel.class); |
| | | } |
| | | } |