sinake
20 小时以前 371603a0eb9f3a279cf77073734e991b5851b792
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/BaseSmsaccountController.java
@@ -1,5 +1,8 @@
package com.ruoyi.web.controller.smartor.tools;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
@@ -7,6 +10,7 @@
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.utils.sms.smsUtils;
import com.smartor.domain.BaseSmsRequest;
import com.smartor.domain.BaseSmsaccount;
import com.smartor.domain.BatchBaseSmsRequest;
@@ -16,6 +20,7 @@
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -34,6 +39,18 @@
public class BaseSmsaccountController extends BaseController {
    @Autowired
    private IBaseSmsaccountService baseSmsaccountService;
    @Value("${visitHosp}")
    private Integer visitHosp;
    @Value("${xhsmsPath}")
    private String xhsmsPath;
    @Value("${xhsmsAccount}")
    private String xhsmsAccount;
    @Value("${xhsmsPwd}")
    private String xhsmsPwd;
    /**
     * 查询短信账号列表
@@ -105,10 +122,22 @@
    @PostMapping("/sendMsg")
    @RepeatSubmit
    public AjaxResult sendMsg(@RequestBody BaseSmsRequest baseSmsRequest) {
        if (baseSmsaccountService.sendMsg(baseSmsRequest) == null) {
            return error();
        String sendMsg="";
        if(visitHosp.equals("3")) {
            try{
                JSONObject jsTemp = JSON.parseObject(baseSmsRequest.getTemplateParam());
                String content=jsTemp.getString("name");
                sendMsg= smsUtils.sendSms(xhsmsPath,xhsmsAccount,xhsmsPwd,baseSmsRequest.getPhoneNumber(),content);
            } catch (Exception ex) {
                return AjaxResult.error(ex.getMessage()) ;
            }
            return AjaxResult.success(sendMsg);
        }else {
            if (baseSmsaccountService.sendMsg(baseSmsRequest) == null) {
                return error();
            }
            return success(baseSmsaccountService.sendMsg(baseSmsRequest));
        }
        return success(baseSmsaccountService.sendMsg(baseSmsRequest));
    }
    /**