tudc 3 gadi atpakaļ
vecāks
revīzija
6857fd1090

+ 8 - 3
sc-service/src/main/java/com/huyi/service/common/ShortMessageController.java

@@ -5,11 +5,14 @@ import com.huyi.service.util.impl.MessageUtilsServiceImpl;
 import com.tianhu.common.core.web.domain.AjaxResult;
 import com.tianhu.common.log.annotation.Log;
 import com.tianhu.common.log.enums.BusinessType;
+import com.tianhu.common.redis.common.RedisUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
-import javax.servlet.http.HttpServletRequest;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -30,7 +33,9 @@ public class ShortMessageController {
         String random = messageUtilsService.genRandomNum(6);
         Map<String, String> param = new HashMap<>();
         param.put("code", random);
-        messageUtilsService.sendMessageCode(requestBody.get("phone"), requestBody.get("verificationCode"), param,  random);
+        // 获取注册模板ID
+        String templateCode = RedisUtils.getDictValue("aliyun_message_code", "zhuce");
+        messageUtilsService.sendMessageCode(requestBody.get("phone"), templateCode, param,  random);
         return AjaxResult.success();
     }
 }

+ 40 - 0
sc-service/src/main/java/com/huyi/service/common/flowable/controller/ApprovalController.java

@@ -0,0 +1,40 @@
+package com.huyi.service.common.flowable.controller;
+
+import com.huyi.service.util.ApprovalService;
+import com.tianhu.common.core.web.controller.BaseController;
+import com.tianhu.common.security.service.TokenService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 审批流程
+ */
+@RestController
+@RequestMapping("/approval")
+public class ApprovalController extends BaseController
+{
+
+    /**
+     *  发起审批
+     */
+    @Autowired
+    private ApprovalService approvalService;
+    //token
+    @Autowired
+    private TokenService tokenService;
+
+    /**
+     * 发起合同审批
+     * @param map
+     * @return
+     * @throws Exception
+     */
+    /*@RequestMapping("/contractStart")
+    public AjaxResult contractStart(@RequestBody Map map) throws Exception {
+        approvalService.addContractApproval(map);
+        return AjaxResult.success();
+    }*/
+
+
+}

+ 260 - 0
sc-service/src/main/java/com/huyi/service/common/flowable/controller/FlowableController.java

@@ -0,0 +1,260 @@
+package com.huyi.service.common.flowable.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.huyi.service.base.entity.PubApprovalProcess;
+import com.huyi.service.base.service.IPubApprovalProcessService;
+import com.keao.tianhu.starter.mybatis.plus.entity.QueryRequest;
+import com.tianhu.common.core.utils.CommonUtil;
+import com.tianhu.common.core.utils.DateUtils;
+import com.tianhu.common.core.utils.IdUtils;
+import com.tianhu.common.core.web.controller.BaseController;
+import com.tianhu.common.core.web.domain.AjaxResult;
+import com.tianhu.common.log.annotation.Log;
+import com.tianhu.common.log.enums.BusinessType;
+import com.tianhu.common.security.annotation.PreAuthorize;
+import com.tianhu.common.security.service.TokenService;
+import com.tianhu.system.api.model.LoginUser;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.lang.reflect.InvocationTargetException;
+import java.text.ParseException;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 审批流程
+ */
+@RestController
+@RequestMapping("/flowable")
+public class  FlowableController extends BaseController
+{
+
+    /**
+     *  自动生成的流程审批服务类
+     */
+    @Autowired
+    private IPubApprovalProcessService approvalProcessService;
+    /**
+     * token
+     */
+    @Autowired
+    private TokenService tokenService;
+
+    //自动生成的合同服务类
+//    @Autowired
+//    private IWcContractInfService wcContractInfService;
+
+
+
+
+
+    /**
+     * 查询需要审批的流程
+     * @return
+     */
+    @RequestMapping("/list")
+    public AjaxResult getFlowAbleInfo(QueryRequest request)
+    {
+        //获取用户信息
+        LoginUser userInfo = tokenService.getLoginUser();
+        //企业id
+        String companyId = userInfo.getSysUser().getCompanyId();
+        LambdaQueryWrapper<PubApprovalProcess> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        IPage<PubApprovalProcess>  list  = approvalProcessService.findPubApprovalProcesss(request,lambdaQueryWrapper);
+        List<PubApprovalProcess> approvalProcessList = list.getRecords();
+        for ( int i = 0 ; i < approvalProcessList.size() ;i++){
+            PubApprovalProcess p = approvalProcessList.get(i);
+            Map<String,Object> map  = CommonUtil. entityToMap(p);
+            map.put("companyId",companyId);
+        }
+        return AjaxResult.success(list);
+    }
+
+
+    /**
+     * 审批通过
+     * @return
+     */
+    @RequestMapping("/agreeApproval")
+    public AjaxResult agreeApproval(
+            @RequestParam("id") String id,
+            @RequestParam("menuId") String menuId,
+            @RequestParam("companyId") String companyId) throws Exception {
+        //合同审批通过
+        /*if("1000000000".equals(menuId)){
+            LambdaQueryWrapper<WcContractInf> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+            String [] arr = id.split("\\|");
+            lambdaQueryWrapper.eq(WcContractInf::getCifId,arr[0]);
+            lambdaQueryWrapper.eq(WcContractInf::getCifCompanyId,arr[1]);
+            WcContractInf wcContractInf = new WcContractInf();
+            //审批通过
+            wcContractInf.setCifState("02");
+            wcContractInfService.update(wcContractInf,lambdaQueryWrapper);
+        }*/
+        return AjaxResult.success();
+    }
+
+
+
+    /**
+     * 审批拒绝
+     * @return
+     */
+    @RequestMapping("/rejectApproval")
+    public AjaxResult rejectApproval(
+                                     @RequestParam("id") String id,
+                                     @RequestParam("menuId") String menuId,
+                                     @RequestParam("companyId") String companyId,
+                                     @RequestParam("state") String state) throws Exception {
+        //合同
+        /*if("1000000000".equals(menuId)){
+            LambdaQueryWrapper<WcContractInf> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+            String [] arr = id.split("\\|");
+            lambdaQueryWrapper.eq(WcContractInf::getCifId,arr[0]);
+            lambdaQueryWrapper.eq(WcContractInf::getCifCompanyId,arr[1]);
+            WcContractInf wcContractInf = new WcContractInf();
+            //审批拒绝
+            if("delete".equals(state)){
+                wcContractInf.setCifState("01");
+            }else if("recall".equals(state)){
+                //撤回
+                //更改为保存状态
+                wcContractInf.setCifState("03");
+            }
+            wcContractInfService.update(wcContractInf,lambdaQueryWrapper);
+        }*/
+
+        return AjaxResult.success();
+    }
+
+    /**
+     * 审批设置
+     * @param approvalProcess
+     * @return
+     * @throws ParseException
+     */
+    @PreAuthorize(hasPermi = "approval:approval:add")
+    @Log(title = "审批管理", businessType = BusinessType.INSERT)
+    @Transactional(rollbackFor=Exception.class)
+    @PostMapping
+    public AjaxResult add(@Validated @RequestBody  PubApprovalProcess approvalProcess) throws ParseException {
+        //获取用户信息
+        LoginUser userInfo = tokenService.getLoginUser();
+        //用户id
+        String userId = CommonUtil.objToString(userInfo.getUserid());
+        if(CommonUtil.isEmpty(approvalProcess.getPapBusinessName())){
+            return AjaxResult.error("请输入业务名称");
+        }
+        if(CommonUtil.isEmpty(approvalProcess.getPapTableName())){
+            return AjaxResult.error("请输入表名称");
+        }
+        if(CommonUtil.isEmpty(approvalProcess.getPapType())){
+            return AjaxResult.error("请选择类型");
+        }
+        //先查询业务名称是否存在
+        LambdaQueryWrapper<PubApprovalProcess> approvalProcessLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        approvalProcessLambdaQueryWrapper.eq(PubApprovalProcess::getPapBusinessName,approvalProcess.getPapBusinessName());
+        List<PubApprovalProcess>   processesList =  approvalProcessService.findPubApprovalProcesss(approvalProcessLambdaQueryWrapper);
+        if(processesList.size() > 0 ){
+            return AjaxResult.error("业务名称已经存在");
+        }
+        LambdaQueryWrapper<PubApprovalProcess> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(PubApprovalProcess::getPapTableName,approvalProcess.getPapTableName());
+        List<PubApprovalProcess>   list =  approvalProcessService.findPubApprovalProcesss(lambdaQueryWrapper);
+        if(list.size() > 0 ){
+            return AjaxResult.error("表名称已经存在");
+        }
+        //获取主键
+        String id = IdUtils.fastSimpleUUID();
+        approvalProcess.setPapId(id);
+        approvalProcess.setCreateBy(userId);
+        approvalProcess.setCreateTime(DateUtils.getNowDate());
+        approvalProcessService.createPubApprovalProcess(approvalProcess);
+        return AjaxResult.success();
+    }
+
+    /**
+     * 查询审批列表
+     * @param approvalProcess
+     * @param request
+     * @return
+     */
+    @PreAuthorize(hasPermi = "approval:approval:list")
+    @RequestMapping("/approvalList")
+    public AjaxResult getFlowAbleList(PubApprovalProcess approvalProcess,QueryRequest request)
+    {
+        LambdaQueryWrapper<PubApprovalProcess> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        if(!CommonUtil.isEmpty(approvalProcess.getPapBusinessName())){
+            lambdaQueryWrapper.like(PubApprovalProcess::getPapBusinessName,approvalProcess.getPapBusinessName());
+        }
+        IPage<PubApprovalProcess>  list  = approvalProcessService.findPubApprovalProcesss(request,lambdaQueryWrapper);
+        return AjaxResult.success(list);
+    }
+
+
+    /**
+     * 修改审批设置
+     * @param approvalProcess
+     * @return
+     * @throws ParseException
+     */
+    @PreAuthorize(hasPermi = "approval:approval:edit")
+    @Log(title = "审批管理", businessType = BusinessType.UPDATE)
+    @Transactional(rollbackFor=Exception.class)
+    @PutMapping
+    public AjaxResult edit(@RequestBody PubApprovalProcess approvalProcess) throws ParseException {
+        //获取用户信息
+        LoginUser userInfo = tokenService.getLoginUser();
+        //用户id
+        String userId = CommonUtil.objToString(userInfo.getUserid());
+        if(CommonUtil.isEmpty(approvalProcess.getPapBusinessName())){
+            return AjaxResult.error("请输入业务名称");
+        }
+        if(CommonUtil.isEmpty(approvalProcess.getPapTableName())){
+            return AjaxResult.error("请输入表名称");
+        }
+        if(CommonUtil.isEmpty(approvalProcess.getPapType())){
+            return AjaxResult.error("请选择类型");
+        }
+        //先查询业务名称是否存在
+        LambdaQueryWrapper<PubApprovalProcess> approvalProcessLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        approvalProcessLambdaQueryWrapper.eq(PubApprovalProcess::getPapBusinessName,approvalProcess.getPapBusinessName());
+        approvalProcessLambdaQueryWrapper.ne(PubApprovalProcess::getPapId,approvalProcess.getPapId());
+        List<PubApprovalProcess>   processesList =  approvalProcessService.findPubApprovalProcesss(approvalProcessLambdaQueryWrapper);
+        if(processesList.size() > 0 ){
+            return AjaxResult.error("业务名称已经存在");
+        }
+        LambdaQueryWrapper<PubApprovalProcess> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(PubApprovalProcess::getPapTableName,approvalProcess.getPapTableName());
+        lambdaQueryWrapper.ne(PubApprovalProcess::getPapId,approvalProcess.getPapId());
+        List<PubApprovalProcess>   list =  approvalProcessService.findPubApprovalProcesss(lambdaQueryWrapper);
+        if(list.size() > 0 ){
+            return AjaxResult.error("表名称已经存在");
+        }
+        approvalProcess.setUpdateBy(userId);
+        approvalProcess.setUpdateTime(DateUtils.getNowDate());
+        approvalProcessService.updateById(approvalProcess);
+        return AjaxResult.success();
+    }
+
+
+    /**
+     * 查询详情
+     * @param papId
+     * @param request
+     * @return
+     * @throws NoSuchMethodException
+     * @throws IllegalAccessException
+     * @throws InvocationTargetException
+     */
+    @GetMapping(value = "/{papId}")
+    public AjaxResult getContractInfo(@PathVariable("papId") String papId, QueryRequest request){
+        //获取用户信息
+        PubApprovalProcess approvalProcesses = approvalProcessService.getById(papId);
+        return AjaxResult.success(approvalProcesses);
+    }
+}

+ 62 - 0
sc-service/src/main/java/com/huyi/service/util/ApprovalService.java

@@ -0,0 +1,62 @@
+package com.huyi.service.util;
+
+import com.tianhu.common.security.service.TokenService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ApprovalService {
+
+	@Autowired
+	private FlowableService flowableService;
+	// 开始流程
+	public final static String STRART_FLOW = "flow/strartFlow";
+	//token
+	@Autowired
+	private TokenService tokenService;
+	//合同生成的服务类
+//    @Autowired
+//    private IWcContractInfService contractInfService;
+	/**
+	 * 发起合同审批
+	 *
+	 * @param map
+	 */
+	/*public void addContractApproval(@RequestBody Map map) throws Exception {
+		Map<String, Object> flowParam = new HashMap<String, Object>();
+		//查询当前操作员
+		LoginUser user = tokenService.getLoginUser();
+		flowParam.put("menuId", "1000000000");
+		flowParam.put("companyId", user.getSysUser().getCompanyId());
+		//双主键
+		flowParam.put("businessKey", CommonUtil.objToString(map.get("cifId")) +"|" +  CommonUtil.objToString(map.get("cifCompanyId")));
+		//员工编号
+		flowParam.put("sessionUserId", user.getSysUser().getStaffCode());
+		if (!CommonUtil.isEmpty(CommonUtil.objToString(map.get("cifName")))){
+			flowParam.put("name",CommonUtil.objToString(map.get("cifName")));
+		} else if (!CommonUtil.isEmpty(CommonUtil.objToString(map.get("cifNo")))) {
+			flowParam.put("name", CommonUtil.objToString(map.get("cifNo")));
+		} else {
+			flowParam.put("name", CommonUtil.objToString(map.get("cifId")));
+		}
+		JSONObject jsonObj=new JSONObject(map);
+		flowParam.put("paras", jsonObj.toString());
+		Map<String, Object> resMap = flowableService.apiPost(STRART_FLOW, flowParam);
+		//未开启流程实例
+		if("300".equals(resMap.get("code"))){
+		    //修改合同状态为通过
+            WcContractInf contract = new WcContractInf();
+            //合同编号
+            contract.setCifId(CommonUtil.objToString(map.get("cifId")));
+            //公司编号
+            contract.setCifCompanyId( CommonUtil.objToString(map.get("cifCompanyId")));
+            //审核通过
+            contract.setCifState("02");
+            contractInfService.updateById(contract);
+			throw new Exception("300");
+        }else if (!"200".equals(resMap.get("code"))) {
+			throw new Exception(resMap.get("message").toString());
+		}
+	}*/
+
+}

+ 6 - 0
sc-service/src/main/java/com/huyi/service/util/Constant.java

@@ -0,0 +1,6 @@
+package com.huyi.service.util;
+
+public class Constant {
+    //审批
+    public  static   final  String FLOWABLE_URL = "http://127.0.0.1:7001/api/";
+}

+ 84 - 0
sc-service/src/main/java/com/huyi/service/util/FlowableService.java

@@ -0,0 +1,84 @@
+package com.huyi.service.util;
+
+import com.alibaba.fastjson.JSON;
+import com.tianhu.common.core.utils.CommonUtil;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.Map;
+
+@Component
+public class FlowableService {
+	//private final static String FLOWABLE_URL = "http://127.0.0.1:7001/api/";
+
+	public Map<String, Object> apiPost(String url, Map<String, Object> param) {
+		return apiPost(url, param, null);
+	}
+	public Map<String, Object> apiPost(String url, Map<String, Object> param, HttpServletRequest request) {
+		Map<String, Object> resMap = null;
+		try {
+			resMap = invokeCapp(Constant.FLOWABLE_URL + url, param, request);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return resMap;
+	}
+
+	public static Map<String, Object> invokeCapp(String urlStr, Map<String, Object> params, HttpServletRequest request) throws Exception {
+		Map map = new HashMap();
+		// post参数
+		StringBuilder postData = new StringBuilder();
+		for (Map.Entry<String,Object> param : params.entrySet()) {
+			if (postData.length() != 0) {
+				postData.append('&');
+			}
+			postData.append(URLEncoder.encode(param.getKey(), "UTF-8"));
+			postData.append('=');
+			postData.append(URLEncoder.encode(String.valueOf(param.getValue()), "UTF-8"));
+		}
+		byte[] postDataBytes = postData.toString().getBytes("UTF-8");
+
+		//开始访问
+		HttpURLConnection conn = (HttpURLConnection)(new URL(urlStr)).openConnection();
+		conn.setRequestMethod("POST");
+		conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+		conn.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
+		if (request != null) {
+			if (request.getHeader("Authorization") != null) {
+				conn.setRequestProperty("Authorization", request.getHeader("Authorization").replace("Bearer ", ""));
+			}
+		}
+		conn.setDoOutput(true);
+		conn.getOutputStream().write(postDataBytes);
+
+
+		Reader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
+
+		StringBuilder sb = new StringBuilder();
+		for (int c; (c = in.read()) >= 0;) {
+			sb.append((char)c);
+		}
+		in.close();
+		conn.disconnect();
+
+		String responseStr = sb.toString();
+		if (CommonUtil.isEmpty(responseStr)) {
+			responseStr = "{}";
+		}
+		int statusCode = conn.getResponseCode();
+		if (HttpServletResponse.SC_OK == statusCode) {
+			// JSONObject dataJson = JSONObject.fromObject(responseStr);
+			// map = new HashMap(dataJson);
+			map = JSON.parseObject(responseStr, HashMap.class);
+		}
+		return map;
+	}
+}

+ 51 - 39
sc-service/src/main/java/com/huyi/service/util/impl/MessageUtilsServiceImpl.java

@@ -4,12 +4,14 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.huyi.service.base.entity.PubVerifyCode;
 import com.huyi.service.base.service.IPubVerifyCodeService;
+import com.huyi.service.base.service.ISysConfigService;
 import com.huyi.service.util.IMessageUtilsService;
 import com.tianhu.common.core.aliyun.SendSms;
 import com.tianhu.common.core.exception.BaseException;
 import com.tianhu.common.core.utils.CommonUtil;
 import com.tianhu.common.core.utils.DateUtils;
 import com.tianhu.common.core.utils.IdUtils;
+import com.tianhu.common.core.utils.StringUtils;
 import com.tianhu.common.redis.common.RedisUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -29,14 +31,16 @@ public class MessageUtilsServiceImpl implements IMessageUtilsService
 {
     @Autowired
     private IPubVerifyCodeService iPubVerifyCodeService;
+    @Autowired
+    private ISysConfigService configService;
     //手机号格式校验
     public static String MOBILE = "^1\\d{10}$";
     //验证码状态(未校验)
     static final String  NO_CHECK = "00";
 
-    private static final String accessKeyId = "";
-    private static final String accessKeySecret = "";
-    private static final String signName = "";
+    private static final String ACCESSKEY_ID = "aliyun.message.accessKeyId";
+    private static final String ACCESSKEY_SECRET = "aliyun.message.accessKeySecret";
+    private static final String SIGN_NAME = "aliyun.message.signName";
     /**
      * 发送短信验证码
      * @param mobileNo         手机号
@@ -47,54 +51,62 @@ public class MessageUtilsServiceImpl implements IMessageUtilsService
     @Override
     public void sendMessageCode(String mobileNo, String templateCode, Map<String, String> param, String random)
     {
-        if (CommonUtil.isEmpty(mobileNo)) {
-            throw new BaseException("手机号不能为空!");
-        } else {
-            // 校验手机号
-            Pattern pattern = Pattern.compile(MOBILE);
-            Matcher matcher = pattern.matcher(mobileNo);
-            boolean rs = matcher.matches();
-            if (!rs) {
-                throw new BaseException("手机号格式错误");
+        // 发送短信验证码
+        if (StringUtils.isNotEmpty(random)) {
+            if (CommonUtil.isEmpty(mobileNo)) {
+                throw new BaseException("手机号不能为空!");
+            } else {
+                // 校验手机号
+                Pattern pattern = Pattern.compile(MOBILE);
+                Matcher matcher = pattern.matcher(mobileNo);
+                boolean rs = matcher.matches();
+                if (!rs) {
+                    throw new BaseException("手机号格式错误");
+                }
             }
-        }
-        //查询验证码
-        LambdaQueryWrapper<PubVerifyCode> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(PubVerifyCode::getPvcPhone,mobileNo);
-        queryWrapper.eq(PubVerifyCode::getPvcState,NO_CHECK);
-        queryWrapper.orderByDesc(PubVerifyCode::getPvcLastTime);
-        List<PubVerifyCode> staffInfList = iPubVerifyCodeService.findPubVerifyCodes(queryWrapper);
-        // 如果已经发送过短`信验证码,并且在60S以内,稍后再发送
-        if(staffInfList.size()>0){
-            //取得指定时间间隔后的系统时间
-            GregorianCalendar calendar = (GregorianCalendar) Calendar.getInstance();
-            calendar.add( Calendar.MINUTE, -1);
-            SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
-            System.out.println("比较时间"+formatter.format(calendar.getTime()));
-            System.out.println("最后时间"+formatter.format(staffInfList.get(0).getPvcLastTime()));
-            if(formatter.format(calendar.getTime()).compareTo(formatter.format(staffInfList.get(0).getPvcLastTime()))<0){
-                System.out.println("请勿频繁发送验证码");
-                throw new BaseException("请勿频繁发送验证码!");
+            //查询验证码
+            LambdaQueryWrapper<PubVerifyCode> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(PubVerifyCode::getPvcPhone,mobileNo);
+            queryWrapper.eq(PubVerifyCode::getPvcState,NO_CHECK);
+            queryWrapper.orderByDesc(PubVerifyCode::getPvcLastTime);
+            List<PubVerifyCode> staffInfList = iPubVerifyCodeService.findPubVerifyCodes(queryWrapper);
+            // 如果已经发送过短`信验证码,并且在60S以内,稍后再发送
+            if(staffInfList.size()>0){
+                //取得指定时间间隔后的系统时间
+                GregorianCalendar calendar = (GregorianCalendar) Calendar.getInstance();
+                calendar.add( Calendar.MINUTE, -1);
+                SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
+                System.out.println("比较时间"+formatter.format(calendar.getTime()));
+                System.out.println("最后时间"+formatter.format(staffInfList.get(0).getPvcLastTime()));
+                if(formatter.format(calendar.getTime()).compareTo(formatter.format(staffInfList.get(0).getPvcLastTime()))<0){
+                    System.out.println("请勿频繁发送验证码");
+                    throw new BaseException("请勿频繁发送验证码!");
+                }
             }
+
+            PubVerifyCode pubVerifyCode = new PubVerifyCode();
+            pubVerifyCode.setPvcId(IdUtils.fastSimpleUUID());
+            pubVerifyCode.setPvcCode(random);
+            pubVerifyCode.setPvcPhone(mobileNo);
+            pubVerifyCode.setPvcLastTime(DateUtils.getNowDate());
+            pubVerifyCode.setPvcState("00");
+            iPubVerifyCodeService.createPubVerifyCode(pubVerifyCode);
         }
 
         //调试模式
         boolean isTest = true;
         String regVal = RedisUtils.getDictValue("pub_verification_code", templateCode);
 
-        PubVerifyCode pubVerifyCode = new PubVerifyCode();
-        pubVerifyCode.setPvcId(IdUtils.fastSimpleUUID());
-        pubVerifyCode.setPvcCode(random);
-        pubVerifyCode.setPvcPhone(mobileNo);
-        pubVerifyCode.setPvcLastTime(DateUtils.getNowDate());
-        pubVerifyCode.setPvcState("00");
-        iPubVerifyCodeService.createPubVerifyCode(pubVerifyCode);
 		if(!isTest) {
 			try {
+                String accessKeyId = configService.selectConfigByKey(ACCESSKEY_ID);
+                String accessKeySecret = configService.selectConfigByKey(ACCESSKEY_SECRET);
+                String signName = configService.selectConfigByKey(SIGN_NAME);
                 SendSms.sendMessage(accessKeyId, accessKeySecret, mobileNo, signName, regVal, JSONObject.toJSONString(param));
 			} catch (Exception ex) {
-                System.out.println("获取短信验证码失败");
-				throw new BaseException("获取短信验证码失败");
+                System.out.println("发送短信验证码失败");
+			    ex.printStackTrace();
+				throw new BaseException("发送短信验证码失败");
 			}
 		}
     }