浏览代码

更新中考录取结果下发

Administrator 1 年之前
父节点
当前提交
efd368f4fd

+ 14 - 0
boman-web-core/src/main/java/com/boman/web/core/controller/SendSmsController.java

@@ -7,8 +7,11 @@ import com.boman.common.core.utils.SecurityUtils;
 import com.boman.common.core.utils.StringUtils;
 import com.boman.common.core.utils.poi.ExcelUtil;
 import com.boman.common.core.web.controller.BaseController;
+import com.boman.domain.SysFile;
 import com.boman.domain.TableDataInfo;
 import com.boman.domain.dto.AjaxResult;
+import com.boman.domain.dto.R;
+import com.boman.system.api.RemoteFileService;
 import com.boman.web.core.service.sendSms.ISendSmsService;
 import com.boman.web.core.utils.SendSmsUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -37,6 +40,10 @@ public class SendSmsController extends BaseController
     @Autowired
     private ISendSmsService sendSmsService;
 
+
+    @Autowired
+    private RemoteFileService remoteFileService;
+
     /**
      * 查询中考下发短信日志列表
      */
@@ -115,6 +122,13 @@ public class SendSmsController extends BaseController
     @PostMapping("/importData")
     public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
     {
+        R<SysFile> fileResult = remoteFileService.upload(file);
+        if (StringUtils.isNull(fileResult) || StringUtils.isNull(fileResult.getData()))
+        {
+            return AjaxResult.error("文件服务异常,请联系管理员");
+        }
+        String url = fileResult.getData().getUrl();
+        System.out.println("中考录取数据文件地址"+url);
         long startTimeSql = System.currentTimeMillis();
         ExcelUtil<SendSms> util = new ExcelUtil<SendSms>(SendSms.class);
         List<SendSms> userList = util.importExcel(file.getInputStream());

+ 4 - 2
boman-web-core/src/main/java/com/boman/web/core/service/sendSms/Impl/SendSmsServiceImpl.java

@@ -116,6 +116,7 @@ public class SendSmsServiceImpl implements ISendSmsService {
         if (StringUtils.isNull(smsList) || smsList.size() == 0) {
             throw new CustomException("导入数据不能为空!");
         }
+        String templateCode = smsList.get(0).getTemplateCode();
         int maxNums = 100; //每次最多发送100条,我们一次批量发100条
         int times = 0;// 循环几个100  用List的长度 除 100
         int size = 0; //
@@ -153,7 +154,7 @@ public class SendSmsServiceImpl implements ISendSmsService {
                     }
                     phoneNumberJson.append("\"" + smsList.get(k).getPhone() + "\",");
                     signNameJson.append("\"潜山市数据资源局\",");
-                    templateParamJson.append("{\"ticketId\":\"" + smsList.get(k).getTicketId() + "\",\"name\":\"" + smsList.get(k).getName() + "\",\"result\":\"" + smsList.get(k).getResult() + "\"},");
+                    templateParamJson.append("{\"year\":\"" + smsList.get(k).getYear() + "\",\"admission\":\"" + smsList.get(k).getTicketId() + "\",\"name\":\"" + smsList.get(k).getName() + "\",\"result\":\"" + smsList.get(k).getResult() + "\"},");
                 }
                 phoneNumberJson.deleteCharAt(phoneNumberJson.length() - 1);//移除最后一个逗号字符,
                 templateParamJson.deleteCharAt(templateParamJson.length() - 1);//移除最后一个逗号字符
@@ -167,6 +168,7 @@ public class SendSmsServiceImpl implements ISendSmsService {
             }
             //组装请求对象
             if (times == phoneList.size()) {
+
                 for (int i = 0; i < times; i++) {
                     long startTimeSql = System.currentTimeMillis();
                     SendBatchSmsRequest sendBatchSmsRequest = new SendBatchSmsRequest();
@@ -177,7 +179,7 @@ public class SendSmsServiceImpl implements ISendSmsService {
                     //替换参数
                     sendBatchSmsRequest.setTemplateParamJson(templateList.get(i));
                     //固定的模板名称
-                    sendBatchSmsRequest.setTemplateCode(TEMPLATE_CODE);
+                    sendBatchSmsRequest.setTemplateCode(templateCode);
                     long endTimeSql = System.currentTimeMillis() - startTimeSql;
                     System.out.println("执行批量下发短信计算:"+i+"次,时间" + endTimeSql + "ms");
                     long startTimeSend = System.currentTimeMillis();