| | |
| | | package cn.gistack.sm.intelligentCall.controller; |
| | | |
| | | import cn.gistack.sm.intelligentCall.constant.CallConstant; |
| | | import cn.gistack.sm.intelligentCall.entity.User; |
| | | import cn.gistack.sm.intelligentCall.util.HttpClientUtils; |
| | | import com.alibaba.fastjson.JSON; |
| | | import cn.gistack.sm.intelligentCall.entity.CallTaskResult; |
| | | import cn.gistack.sm.intelligentCall.service.CallService; |
| | | import cn.gistack.sm.intelligentCall.vo.CallTaskResultVO; |
| | | import cn.gistack.sm.intelligentCall.vo.CallTaskStatistic; |
| | | import io.swagger.annotations.Api; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import java.security.MessageDigest; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import static cn.gistack.sm.intelligentCall.util.CallUtil.getRandom; |
| | | import static cn.gistack.sm.intelligentCall.util.CallUtil.getToken; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 智能呼叫控制层 |
| | |
| | | @AllArgsConstructor |
| | | public class CallController { |
| | | |
| | | /** |
| | | * 创建任务 |
| | | * @return |
| | | */ |
| | | @GetMapping("/createCall") |
| | | public R createCall(){ |
| | | // 请求 |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("p1",createCallUtil()); |
| | | // 返回 |
| | | return R.data(map); |
| | | } |
| | | private final CallService callService; |
| | | |
| | | /** |
| | | * 创建任务 |
| | | * @return |
| | | */ |
| | | public String createCallUtil(){ |
| | | Date date = new Date(); |
| | | String dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date); |
| | | String timestamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS").format(date); |
| | | String transId = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(date) + getRandom(); |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("taskName","测试"); |
| | | map.put("sceneId",230); |
| | | map.put("callingNumbers", Arrays.asList("00862787222298")); |
| | | map.put("taskScheduleTime",dateFormat); |
| | | List<Map<String,Object>> list = new ArrayList<>(); |
| | | Map<String,Object> maps = new HashMap<>(); |
| | | maps.put("被叫号码","15170720695"); |
| | | maps.put("水库名称","测试水库"); |
| | | maps.put("超汛限多少米","0"); |
| | | maps.put("水库编码","1241241122"); |
| | | maps.put("用户名","zrj"); |
| | | maps.put("用户id","123456"); |
| | | list.add(maps); |
| | | map.put("calleeData",list); |
| | | |
| | | String token = getToken(timestamp, transId, map); |
| | | String url = CallConstant.HOST + CallConstant.createTaskUrl1; |
| | | String httpPost = HttpClientUtils.httpPost(url, CallConstant.AppKey, timestamp, transId, token, map); |
| | | @PostMapping("/createCall") |
| | | public R createCall(@RequestBody Map<String,Object> map){ |
| | | // 返回 |
| | | return httpPost; |
| | | return R.data(callService.createTask(map)); |
| | | } |
| | | |
| | | /** |
| | | * 获取通话详情 |
| | | * @return |
| | | */ |
| | | @GetMapping("/getCallDetail") |
| | | public R getCallDetail(String taskId,String calleeNumber){ |
| | | // 返回 |
| | | return R.data(callService.getCallDetail(taskId,calleeNumber)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询呼叫列表信息 |
| | | * @param callTask |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @GetMapping("/getCallListPage") |
| | | public R getCallListPage(CallTaskStatistic callTask, Query query){ |
| | | // 返回 |
| | | return R.data(callService.getCallListPage(Condition.getPage(query),callTask)); |
| | | } |
| | | |
| | | // /** |
| | | // * 测试 |
| | | // * @param args |
| | | // */ |
| | | // public static void main(String[] args) { |
| | | // Date date = new Date(); |
| | | // String dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date); |
| | | // String timestamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS").format(date); |
| | | // String transId = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(date) + getRandom(); |
| | | // |
| | | // Map<String, Object> map = new HashMap<>(); |
| | | // map.put("taskName","测试"); |
| | | // map.put("sceneId",230); |
| | | // map.put("callingNumbers", Arrays.asList("00862787222298")); |
| | | // map.put("taskScheduleTime",dateFormat); |
| | | // List<Map<String,Object>> list = new ArrayList<>(); |
| | | // Map<String,Object> maps = new HashMap<>(); |
| | | // maps.put("被叫号码","15170720695"); |
| | | // maps.put("水库名称","测试水库"); |
| | | // maps.put("超汛限多少米","0"); |
| | | // maps.put("水库编码","1241241122"); |
| | | // maps.put("用户名","zrj"); |
| | | // maps.put("用户id","123456"); |
| | | // list.add(maps); |
| | | // map.put("calleeData",list); |
| | | // |
| | | // String token = getToken(timestamp, transId, map); |
| | | // String url = CallConstant.HOST + CallConstant.createTaskUrl1; |
| | | // String httpPost = HttpClientUtils.httpPost(url, CallConstant.AppKey, timestamp, transId, token, map); |
| | | // System.out.println("httpPost = " + httpPost); |
| | | // } |
| | | |
| | | /** |
| | | * 查询呼叫详情列表信息 |
| | | * @param callTaskResult |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @GetMapping("/getCallTaskResultListPage") |
| | | public R getCallTaskResultListPage(CallTaskResultVO callTaskResult, Query query){ |
| | | // 返回 |
| | | return R.data(callService.getCallTaskResultListPage(Condition.getPage(query),callTaskResult)); |
| | | } |
| | | |
| | | /** |
| | | * 导出呼叫详情列表信息 |
| | | * @param callTaskResult |
| | | * @return |
| | | */ |
| | | @GetMapping("/getCallTaskResultList") |
| | | public R getCallTaskResultList(CallTaskResultVO callTaskResult){ |
| | | // 返回 |
| | | return R.data(callService.getCallTaskResultList(callTaskResult)); |
| | | } |
| | | |
| | | } |