parent
ae278bf5e8
commit
e6a8fdc489
@ -0,0 +1,206 @@
|
||||
package org.jeecg.modules.ai.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.ai.entity.PreExaminationMattersField;
|
||||
import org.jeecg.modules.ai.qo.PreExaminationMattersFieldQuery;
|
||||
import org.jeecg.modules.ai.service.IPreExaminationMattersFieldService;
|
||||
import org.jeecg.modules.ai.vo.PreExaminationMattersFieldVo;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
|
||||
/**
|
||||
* @Description: 事项表单回显字段与材料对应关系表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2023-11-29
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="事项表单回显字段与材料对应关系表")
|
||||
@RestController
|
||||
@RequestMapping("/ai/preExaminationMattersField")
|
||||
@Slf4j
|
||||
public class PreExaminationMattersFieldController extends JeecgController<PreExaminationMattersField, IPreExaminationMattersFieldService> {
|
||||
@Autowired
|
||||
private IPreExaminationMattersFieldService preExaminationMattersFieldService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param preExaminationMattersField
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "事项表单回显字段与材料对应关系表-分页列表查询")
|
||||
@ApiOperation(value="事项表单回显字段与材料对应关系表-分页列表查询", notes="事项表单回显字段与材料对应关系表-分页列表查询")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<?> queryPageList(PreExaminationMattersField preExaminationMattersField,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<PreExaminationMattersField> queryWrapper = QueryGenerator.initQueryWrapper(preExaminationMattersField, req.getParameterMap());
|
||||
Page<PreExaminationMattersField> page = new Page<PreExaminationMattersField>(pageNo, pageSize);
|
||||
IPage<PreExaminationMattersField> pageList = preExaminationMattersFieldService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param preExaminationMattersField
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "事项表单回显字段与材料对应关系表")
|
||||
@ApiOperation(value="事项表单回显字段与材料对应关系表", notes="事项表单回显字段与材料对应关系表")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<?> queryList(PreExaminationMattersFieldQuery query,
|
||||
HttpServletRequest req) {
|
||||
List<PreExaminationMattersFieldVo> list = preExaminationMattersFieldService.getPreExaminationMattersFieldListByEvent(query);
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param preExaminationMattersField
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "事项表单回显字段与材料对应关系表-添加")
|
||||
@ApiOperation(value="事项表单回显字段与材料对应关系表-添加", notes="事项表单回显字段与材料对应关系表-添加")
|
||||
@PostMapping(value = "/saveInfo")
|
||||
public Result<?> saveInfo(@RequestBody String reviewInfo) {
|
||||
preExaminationMattersFieldService.saveInfo(reviewInfo);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param preExaminationMattersField
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "事项表单回显字段与材料对应关系表-添加")
|
||||
@ApiOperation(value="事项表单回显字段与材料对应关系表-添加", notes="事项表单回显字段与材料对应关系表-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<?> add(@RequestBody PreExaminationMattersField preExaminationMattersField) {
|
||||
preExaminationMattersFieldService.save(preExaminationMattersField);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param preExaminationMattersField
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "事项表单回显字段与材料对应关系表-编辑")
|
||||
@ApiOperation(value="事项表单回显字段与材料对应关系表-编辑", notes="事项表单回显字段与材料对应关系表-编辑")
|
||||
@PostMapping(value = "/edit")
|
||||
public Result<?> edit(@RequestBody PreExaminationMattersField preExaminationMattersField) {
|
||||
preExaminationMattersFieldService.updateById(preExaminationMattersField);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "事项表单回显字段与材料对应关系表-通过id删除")
|
||||
@ApiOperation(value="事项表单回显字段与材料对应关系表-通过id删除", notes="事项表单回显字段与材料对应关系表-通过id删除")
|
||||
@PostMapping(value = "/delete")
|
||||
public Result<?> delete(@RequestBody PreExaminationMattersField preExaminationMattersField) {
|
||||
preExaminationMattersFieldService.removeById(preExaminationMattersField.getId());
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "事项表单回显字段与材料对应关系表-批量删除")
|
||||
@ApiOperation(value="事项表单回显字段与材料对应关系表-批量删除", notes="事项表单回显字段与材料对应关系表-批量删除")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.preExaminationMattersFieldService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "事项表单回显字段与材料对应关系表-通过id查询")
|
||||
@ApiOperation(value="事项表单回显字段与材料对应关系表-通过id查询", notes="事项表单回显字段与材料对应关系表-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
PreExaminationMattersField preExaminationMattersField = preExaminationMattersFieldService.getById(id);
|
||||
if(preExaminationMattersField==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(preExaminationMattersField);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param preExaminationMattersField
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, PreExaminationMattersField preExaminationMattersField) {
|
||||
return super.exportXls(request, preExaminationMattersField, PreExaminationMattersField.class, "事项表单回显字段与材料对应关系表");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, PreExaminationMattersField.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package org.jeecg.modules.ai.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Description: 事项表单回显字段与材料对应关系表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2023-11-29
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("pre_examination_matters_field")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="pre_examination_matters_field对象", description="事项表单回显字段与材料对应关系表")
|
||||
public class PreExaminationMattersField implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键")
|
||||
private java.lang.String id;
|
||||
/**预审事项编码*/
|
||||
@Excel(name = "预审事项编码", width = 15)
|
||||
@ApiModelProperty(value = "预审事项编码")
|
||||
private java.lang.String eventCode;
|
||||
/**回显字段名称*/
|
||||
@Excel(name = "回显字段名称", width = 15)
|
||||
@ApiModelProperty(value = "回显字段名称")
|
||||
private java.lang.String fieldName;
|
||||
/**回显字段编码*/
|
||||
@Excel(name = "回显字段编码", width = 15)
|
||||
@ApiModelProperty(value = "回显字段编码")
|
||||
private java.lang.String fieldCode;
|
||||
/**材料编码*/
|
||||
@Excel(name = "材料编码", width = 15)
|
||||
@ApiModelProperty(value = "材料编码")
|
||||
private java.lang.String materialCode;
|
||||
/**状态 1 可用 0 禁用*/
|
||||
@Excel(name = "状态 1 可用 0 禁用", width = 15)
|
||||
@ApiModelProperty(value = "状态 1 可用 0 禁用")
|
||||
private java.lang.Integer status;
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package org.jeecg.modules.ai.job;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jeecg.modules.ai.entity.PreReviewRecords;
|
||||
import org.jeecg.modules.ai.service.IPreReviewRecordsService;
|
||||
import org.jeecg.modules.system.util.SendSmsUtil;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class SendSmsJob implements Job{
|
||||
|
||||
@Autowired
|
||||
private IPreReviewRecordsService preReviewRecordsService;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
log.info("-------------->开始发送统计数量");
|
||||
List<PreReviewRecords> list = preReviewRecordsService.getSendMsgRecordsCount();
|
||||
String msg = "";
|
||||
for(PreReviewRecords record:list) {
|
||||
|
||||
}
|
||||
String result = new SendSmsUtil().sendSms("", "", "", "");
|
||||
|
||||
log.info("--------短信发送内容---------->"+msg);
|
||||
log.info("--------短信发送结果---------->"+result);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package org.jeecg.modules.ai.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.ai.entity.PreExaminationMattersField;
|
||||
import org.jeecg.modules.ai.qo.PreExaminationMattersFieldQuery;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 事项表单回显字段与材料对应关系表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2023-11-29
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface PreExaminationMattersFieldMapper extends BaseMapper<PreExaminationMattersField> {
|
||||
|
||||
/**
|
||||
* 查询数据列表
|
||||
* @param queryWrapper
|
||||
* @return
|
||||
*/
|
||||
List<PreExaminationMattersField> selectByEventCode(String eventCode);
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.ai.mapper.PreExaminationMattersFieldMapper">
|
||||
|
||||
<select id="selectByEventCode" resultType="org.jeecg.modules.ai.entity.PreExaminationMattersField">
|
||||
|
||||
select * from pre_examination_matters_field where event_code = #{query.eventCode,jdbcType=VARCHAR}
|
||||
|
||||
and status = 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,11 @@
|
||||
package org.jeecg.modules.ai.qo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PreExaminationMattersFieldQuery {
|
||||
|
||||
private String eventCode;
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package org.jeecg.modules.ai.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jeecg.modules.ai.entity.PreExaminationMattersField;
|
||||
import org.jeecg.modules.ai.qo.PreExaminationMattersFieldQuery;
|
||||
import org.jeecg.modules.ai.vo.PreExaminationMattersFieldVo;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: 事项表单回显字段与材料对应关系表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2023-11-29
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface IPreExaminationMattersFieldService extends IService<PreExaminationMattersField> {
|
||||
|
||||
/**
|
||||
* 获取已经配置的表单字段
|
||||
* @param preExaminationMattersField
|
||||
* @return
|
||||
*/
|
||||
public List<PreExaminationMattersFieldVo> getPreExaminationMattersFieldListByEvent(PreExaminationMattersFieldQuery query);
|
||||
|
||||
/**
|
||||
* 保存表单数据
|
||||
* @param reviewInfo
|
||||
* @return
|
||||
*/
|
||||
public boolean saveInfo(String reviewInfo) ;
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
package org.jeecg.modules.ai.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.jeecg.modules.ai.entity.PreExaminationMattersField;
|
||||
import org.jeecg.modules.ai.entity.PreReviewMaterial;
|
||||
import org.jeecg.modules.ai.mapper.PreExaminationMattersFieldMapper;
|
||||
import org.jeecg.modules.ai.mapper.PreReviewMaterialMapper;
|
||||
import org.jeecg.modules.ai.qo.PreExaminationMattersFieldQuery;
|
||||
import org.jeecg.modules.ai.service.IPreExaminationMattersFieldService;
|
||||
import org.jeecg.modules.ai.vo.PreExaminationMattersFieldVo;
|
||||
import org.jeecg.modules.ai.vo.PreReviewMaterialVo;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import ch.qos.logback.core.joran.util.beans.BeanUtil;
|
||||
|
||||
/**
|
||||
* @Description: 事项表单回显字段与材料对应关系表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2023-11-29
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class PreExaminationMattersFieldServiceImpl extends ServiceImpl<PreExaminationMattersFieldMapper, PreExaminationMattersField> implements IPreExaminationMattersFieldService {
|
||||
|
||||
@Resource
|
||||
private PreExaminationMattersFieldMapper preExaminationMattersFieldMapper;
|
||||
@Resource
|
||||
private PreReviewMaterialMapper preReviewMaterialMapper;
|
||||
|
||||
/**
|
||||
* 获取已经配置的表单字段
|
||||
* @param preExaminationMattersField
|
||||
* @return
|
||||
*/
|
||||
public List<PreExaminationMattersFieldVo> getPreExaminationMattersFieldListByEvent(PreExaminationMattersFieldQuery query){
|
||||
|
||||
List<PreExaminationMattersField> list = preExaminationMattersFieldMapper.selectByEventCode(query.getEventCode());
|
||||
List<PreExaminationMattersFieldVo> listPreExaminationMattersFieldVo = new ArrayList<PreExaminationMattersFieldVo>();
|
||||
for(PreExaminationMattersField field:list) {
|
||||
PreExaminationMattersFieldVo vo = new PreExaminationMattersFieldVo();
|
||||
BeanUtils.copyProperties(field, vo);
|
||||
PreReviewMaterialVo material = preReviewMaterialMapper.getPreReviewMaterialByCode(field.getMaterialCode());
|
||||
vo.setMaterialName(material.getMaterialName());
|
||||
listPreExaminationMattersFieldVo.add(vo);
|
||||
}
|
||||
return listPreExaminationMattersFieldVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存表单数据
|
||||
*/
|
||||
@Override
|
||||
public boolean saveInfo(String reviewInfo) {
|
||||
JSONObject json = JSONObject.parseObject(reviewInfo);
|
||||
String eventCode = json.getString("eventCode");
|
||||
JSONArray listMaterial = json.getJSONArray("listMaterial");
|
||||
if(listMaterial.size()>0) {
|
||||
//删除旧数据
|
||||
LambdaQueryWrapper<PreExaminationMattersField> queryWrapper = new LambdaQueryWrapper<PreExaminationMattersField>();
|
||||
queryWrapper.eq(PreExaminationMattersField::getEventCode, eventCode);
|
||||
preExaminationMattersFieldMapper.delete(queryWrapper);
|
||||
}
|
||||
for(int i=0;i<listMaterial.size();i++) {
|
||||
JSONObject jsonMaterial = listMaterial.getJSONObject(i);
|
||||
PreExaminationMattersField preExaminationMattersField = new PreExaminationMattersField();
|
||||
preExaminationMattersField.setEventCode(eventCode);
|
||||
preExaminationMattersField.setFieldCode(jsonMaterial.getString("fieldCode"));
|
||||
preExaminationMattersField.setFieldName(jsonMaterial.getString("fieldName"));
|
||||
preExaminationMattersField.setMaterialCode(jsonMaterial.getString("materialCode"));
|
||||
preExaminationMattersFieldMapper.insert(preExaminationMattersField);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package org.jeecg.modules.ai.vo;
|
||||
|
||||
import org.jeecg.modules.ai.entity.PreExaminationMattersField;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PreExaminationMattersFieldVo extends PreExaminationMattersField{
|
||||
|
||||
private String materialName;
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package org.jeecg.modules.system.util;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import com.aliyun.auth.credentials.Credential;
|
||||
import com.aliyun.auth.credentials.provider.StaticCredentialProvider;
|
||||
import com.aliyun.sdk.service.dysmsapi20170525.AsyncClient;
|
||||
import com.aliyun.sdk.service.dysmsapi20170525.models.SendSmsRequest;
|
||||
import com.aliyun.sdk.service.dysmsapi20170525.models.SendSmsResponse;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import darabonba.core.client.ClientOverrideConfiguration;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class SendSmsUtil {
|
||||
|
||||
@Value(value = "${aliyun.accessKey}")
|
||||
private static String ALIBABA_CLOUD_ACCESS_KEY_ID;
|
||||
@Value(value = "${aliyun.accessKeySecret}")
|
||||
private static String ALIBABA_CLOUD_ACCESS_KEY_SECRET;
|
||||
|
||||
private static AsyncClient client;
|
||||
|
||||
static {
|
||||
StaticCredentialProvider provider = StaticCredentialProvider
|
||||
.create(Credential.builder().accessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
|
||||
.accessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")).build());
|
||||
client = AsyncClient.builder().region("cn-hangzhou").credentialsProvider(provider).overrideConfiguration(
|
||||
ClientOverrideConfiguration.create().setEndpointOverride("dysmsapi.aliyuncs.com")).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送短信
|
||||
* @param signName
|
||||
* @param phone
|
||||
* @param templateCode
|
||||
* @param templateParam
|
||||
*/
|
||||
public String sendSms(String signName, String phone, String templateCode, String templateParam) {
|
||||
SendSmsRequest sendSmsRequest = SendSmsRequest.builder().signName(signName).templateCode(templateCode)
|
||||
.phoneNumbers(phone).templateParam(templateParam).build();
|
||||
CompletableFuture<SendSmsResponse> response = client.sendSms(sendSmsRequest);
|
||||
SendSmsResponse resp;
|
||||
try {
|
||||
resp = response.get();
|
||||
log.info(phone+"--------短信发送结果----------->"+new Gson().toJson(resp));
|
||||
return new Gson().toJson(resp);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue