zhongrj
2023-10-12 39b3d16e78a22e70e99341f366dcfa2c3e6519b9
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/intelligentCall/controller/CallController.java
@@ -2,18 +2,26 @@
import cn.gistack.sm.intelligentCall.entity.CallTaskResult;
import cn.gistack.sm.intelligentCall.entity.Scene;
import cn.gistack.sm.intelligentCall.excel.CallExcel;
import cn.gistack.sm.intelligentCall.listener.ExcelListener;
import cn.gistack.sm.intelligentCall.service.CallService;
import cn.gistack.sm.intelligentCall.service.ICallSmsNoticeTaskService;
import cn.gistack.sm.intelligentCall.vo.CallTaskResultVO;
import cn.gistack.sm.intelligentCall.vo.CallTaskStatistic;
import com.alibaba.excel.EasyExcel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
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.*;
/**
@@ -177,4 +185,35 @@
      // 返回
      return R.data(callService.getCallResultListTemp(Condition.getPage(query),callTaskResult));
   }
   /**
    * 导入表格发送智能外呼
    * @param file excel文件
    * @param time 呼叫时间(空的话默认选择当前时间)
    * @return
    */
   @PostMapping("/import-call")
   public R importCall(MultipartFile file,String time){
      ExcelListener<CallExcel> listener = new ExcelListener<>();
      //headRowNumber(1)从第2行开始读取,使用getDatas()方法取出数据
      try {
         EasyExcel.read(file.getInputStream(), CallExcel.class, listener).headRowNumber(1).sheet(0).doRead();
      } catch (IOException e) {
         e.printStackTrace();
      }
      List<CallExcel> list = listener.getDatas();
      // 导入并返回
      return R.data(callService.importCall(list,time));
   }
   /**
    * 导出模板
    */
   @GetMapping("/export-template")
   @ApiOperation(value = "导出模板")
   public void exportTemplate(HttpServletResponse response) {
      List<CallExcel> list = new ArrayList<>();
      ExcelUtil.export(response, "智能外呼数据模板", "智能外呼数据表", list, CallExcel.class);
   }
}