|
|
@@ -0,0 +1,734 @@
|
|
|
+package com.zhou.controller;
|
|
|
+import com.zhou.tools.PostHttp;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import com.zhou.mapper.CloudOutboundMapper;
|
|
|
+import com.zhou.mapper.HttpInterfaceMapper;
|
|
|
+import com.zhou.mapper.SsoLogMapper;
|
|
|
+import com.zhou.pojo.*;
|
|
|
+import com.zhou.tools.CusAccessObjectUtil;
|
|
|
+import com.zhou.tools.FileURL;
|
|
|
+import com.zhou.tools.HttpClientUtil;
|
|
|
+import com.zhou.tools.tokens.IFToken;
|
|
|
+import com.zhou.tools.tokens.Token;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.servlet.http.HttpSession;
|
|
|
+import java.io.BufferedReader;
|
|
|
+import java.io.InputStreamReader;
|
|
|
+import java.text.DateFormat;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+import java.util.Date;
|
|
|
+import com.zhou.mapper.UsersMapper;
|
|
|
+
|
|
|
+//import org.slf4j.Logger;
|
|
|
+//import org.slf4j.LoggerFactory;
|
|
|
+
|
|
|
+@CrossOrigin
|
|
|
+@RestController
|
|
|
+/**
|
|
|
+ * 该功能现在未启用,代码处于保存状态
|
|
|
+ */
|
|
|
+public class CloudOutboundController {
|
|
|
+ /*//Logger logger = LoggerFactory.getLogger("SSOinfo");
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(CloudOutboundController.class);
|
|
|
+ @Value("${EXPIRE_TIME}")
|
|
|
+ private String EXPIRE_TIME;
|
|
|
+ @Value("${appId}")
|
|
|
+ private String appId;
|
|
|
+ @Value("${appSecret}")
|
|
|
+ private String appSecret;
|
|
|
+ @Value("${apiKey}")
|
|
|
+ private String apiKey;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private CloudOutboundMapper cloudOutboundMapper;
|
|
|
+ @Resource
|
|
|
+ private UsersMapper usersMapper;
|
|
|
+ @Resource
|
|
|
+ private SsoLogMapper ssoLogMapper;
|
|
|
+ @Resource
|
|
|
+ private HttpInterfaceMapper httpInterfaceMapper;
|
|
|
+ @Value("/sso")
|
|
|
+ //@Value("/CloudOutbound")
|
|
|
+ private String contextpath;
|
|
|
+
|
|
|
+ //用户管理,模型训练平台,机器人后台,外呼机器人,技术支撑,云呼叫使用,云呼叫导入
|
|
|
+ //查找云外呼导入人
|
|
|
+ @RequestMapping("getAccountList")
|
|
|
+ public ResponseEntity<Object> getAccountList(HttpServletRequest request) throws Exception {
|
|
|
+ request.setCharacterEncoding("UTF-8");
|
|
|
+ String username = (String) request.getSession().getAttribute("username");
|
|
|
+ List<String> list=new ArrayList<String>();
|
|
|
+ int jurisdiction=0;
|
|
|
+ String message="当前用户没有权限";
|
|
|
+ String token = (String) request.getSession().getAttribute("token");
|
|
|
+ Map<String,Object >tokenMap = IFToken.typeTokne(username,token);
|
|
|
+ int tokenTYPE =(int)tokenMap.get("jurisdiction");
|
|
|
+ if(tokenTYPE==0){
|
|
|
+ jurisdiction=3;
|
|
|
+ message =(String)tokenMap.get("message");
|
|
|
+ }else {
|
|
|
+ Date expiresDate = new Date(System.currentTimeMillis() + Integer.valueOf(EXPIRE_TIME) * 60 * 1000);
|
|
|
+ List<Users> users = usersMapper.getUsersListByAccount(username);
|
|
|
+ String key = Token.getToken(users.get(0), expiresDate);
|
|
|
+ request.getSession().setAttribute("token", key);
|
|
|
+ try{
|
|
|
+ String userType =usersMapper.getPermissionList(username);
|
|
|
+ if(userType!=null&&userType.length()!=0){
|
|
|
+ String[] type = userType.split(",");
|
|
|
+ for(int i=0 ;userType.length()>i ; i++){
|
|
|
+ if(type[i].equals("云呼叫使用")||type[i].equals("云呼叫导入")){
|
|
|
+ list = usersMapper.getAccountList();
|
|
|
+ jurisdiction=1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ message="系统异常:"+e.getMessage();
|
|
|
+ e.printStackTrace();
|
|
|
+ jurisdiction=2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String,Object> maps = new HashMap<>();
|
|
|
+ maps.put("Type", jurisdiction);
|
|
|
+ if(jurisdiction==1){
|
|
|
+ maps.put("Data", list);
|
|
|
+ return new ResponseEntity<>(maps, HttpStatus.OK);
|
|
|
+ }else {
|
|
|
+ maps.put("Data", message);
|
|
|
+ return new ResponseEntity<>(maps, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //查找云外呼数据集合
|
|
|
+ @RequestMapping("getCloudOutboundList")
|
|
|
+ public ResponseEntity<Object> getCloudOutboundList(HttpServletRequest request) throws Exception {
|
|
|
+ request.setCharacterEncoding("UTF-8");
|
|
|
+ String username = (String) request.getSession().getAttribute("username");
|
|
|
+ //List<String> list=new ArrayList<String>();
|
|
|
+ int jurisdiction=0;
|
|
|
+ String message="当前用户没有权限";
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ String token = (String) request.getSession().getAttribute("token");
|
|
|
+ Map<String,Object >tokenMap = IFToken.typeTokne(username,token);
|
|
|
+ int tokenTYPE =(int)tokenMap.get("jurisdiction");
|
|
|
+ if(tokenTYPE==0){
|
|
|
+ jurisdiction=3;
|
|
|
+ message =(String)tokenMap.get("message");
|
|
|
+ }else {
|
|
|
+ Date expiresDate = new Date(System.currentTimeMillis() + Integer.valueOf(EXPIRE_TIME) * 60 * 1000);
|
|
|
+ List<Users> users = usersMapper.getUsersListByAccount(username);
|
|
|
+ String key = Token.getToken(users.get(0), expiresDate);
|
|
|
+ request.getSession().setAttribute("token", key);
|
|
|
+ try{
|
|
|
+ String userType =usersMapper.getPermissionList(username);
|
|
|
+ if(userType!=null&&userType.length()!=0){
|
|
|
+ String[] type = userType.split(",");
|
|
|
+ for(int i=0 ;userType.length()>i ; i++){
|
|
|
+ if(type[i].equals("云呼叫使用")||type[i].equals("云呼叫导入")){
|
|
|
+ JSONObject jsonParam = this.getJSONParam(request);
|
|
|
+ UsersDTO dto = new UsersDTO();
|
|
|
+ if(jsonParam!=null){
|
|
|
+ dto = JSON.parseObject(jsonParam.toJSONString(),UsersDTO.class);
|
|
|
+ }
|
|
|
+ CloudOutboundDTO co = new CloudOutboundDTO();
|
|
|
+ PageHelper.startPage(dto.getStart(), dto.getSize(), "C_ID asc");
|
|
|
+ List<CloudOutbound> CloudOutboundList = cloudOutboundMapper.getCloudOutboundList();
|
|
|
+ List<CloudOutboundVo> voList = new ArrayList<>();
|
|
|
+ for (CloudOutbound cobd:CloudOutboundList) {
|
|
|
+ CloudOutboundVo vo = cloudOutboundPoToVo(cobd);
|
|
|
+ voList.add(vo);
|
|
|
+ }
|
|
|
+ PageInfo page = new PageInfo(CloudOutboundList);
|
|
|
+ page.setList(voList);
|
|
|
+ map.put("pages", page);
|
|
|
+ map.put("account", dto.getAccount());
|
|
|
+ map.put("userName", dto.getUserName());
|
|
|
+ jurisdiction=1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ message="系统异常:"+e.getMessage();
|
|
|
+ e.printStackTrace();
|
|
|
+ jurisdiction=2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String,Object> maps = new HashMap<>();
|
|
|
+ maps.put("Type", jurisdiction);
|
|
|
+ if(jurisdiction==1){
|
|
|
+ maps.put("Data", map);
|
|
|
+ return new ResponseEntity<>(maps, HttpStatus.OK);
|
|
|
+ }else {
|
|
|
+ maps.put("Data", message);
|
|
|
+ return new ResponseEntity<>(maps, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //查找云外呼数据集合条件查询
|
|
|
+ @RequestMapping("getCloudOutboundListS")
|
|
|
+ public ResponseEntity<Object> getCloudOutboundListS(HttpServletRequest request,String beginTime ,String endTime,String C_CREATOR) throws Exception {//,String beginTime ,String endTime
|
|
|
+ request.setCharacterEncoding("UTF-8");
|
|
|
+ SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-ddHH:mm:ss");
|
|
|
+ Date dbt =sd.parse(beginTime);
|
|
|
+ Date det =sd.parse(endTime);
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ beginTime=sdf.format(dbt);
|
|
|
+ endTime=sdf.format(det);
|
|
|
+ String username = (String) request.getSession().getAttribute("username");
|
|
|
+ int jurisdiction=0;
|
|
|
+ String message="当前用户没有权限";
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ String token = (String) request.getSession().getAttribute("token");
|
|
|
+ Map<String,Object >tokenMap = IFToken.typeTokne(username,token);
|
|
|
+ int tokenTYPE =(int)tokenMap.get("jurisdiction");
|
|
|
+ if(tokenTYPE==0){
|
|
|
+ jurisdiction=3;
|
|
|
+ message =(String)tokenMap.get("message");
|
|
|
+ }else {
|
|
|
+ Date expiresDate = new Date(System.currentTimeMillis() + Integer.valueOf(EXPIRE_TIME) * 60 * 1000);
|
|
|
+ List<Users> users = usersMapper.getUsersListByAccount(username);
|
|
|
+ String key = Token.getToken(users.get(0), expiresDate);
|
|
|
+ request.getSession().setAttribute("token", key);
|
|
|
+ try{
|
|
|
+ String userType =usersMapper.getPermissionList(username);
|
|
|
+ if(userType!=null&&userType.length()!=0){
|
|
|
+ String[] type = userType.split(",");
|
|
|
+ for(int i=0 ;userType.length()>i ; i++){
|
|
|
+ if(type[i].equals("云呼叫使用")||type[i].equals("云呼叫导入")){
|
|
|
+ JSONObject jsonParam = this.getJSONParam(request);
|
|
|
+ UsersDTO dto = new UsersDTO();
|
|
|
+ if(jsonParam!=null){
|
|
|
+ dto = JSON.parseObject(jsonParam.toJSONString(),UsersDTO.class);
|
|
|
+ }
|
|
|
+ CloudOutboundDTO co = new CloudOutboundDTO();
|
|
|
+ List<CloudOutbound> CloudOutboundList =new ArrayList<CloudOutbound>();
|
|
|
+ PageHelper.startPage(dto.getStart(), dto.getSize(), "C_ID asc");
|
|
|
+ if (C_CREATOR.length()>=1){
|
|
|
+ CloudOutboundList = cloudOutboundMapper.getCloudOutboundListS( beginTime, endTime , C_CREATOR);
|
|
|
+
|
|
|
+ }else {
|
|
|
+ CloudOutboundList = cloudOutboundMapper.getCloudOutboundListStwo( beginTime, endTime );
|
|
|
+ }
|
|
|
+ PageHelper.startPage(co.getStart(), co.getSize(), "C_ID asc");
|
|
|
+ List<CloudOutboundVo> voList = new ArrayList<>();
|
|
|
+ for (CloudOutbound cobd:CloudOutboundList) {
|
|
|
+ CloudOutboundVo vo = cloudOutboundPoToVo(cobd);
|
|
|
+ voList.add(vo);
|
|
|
+ }
|
|
|
+ PageInfo page = new PageInfo(CloudOutboundList);
|
|
|
+ page.setList(voList);
|
|
|
+ map.put("pages", page);
|
|
|
+ map.put("account", dto.getAccount());
|
|
|
+ map.put("userName", dto.getUserName());
|
|
|
+ jurisdiction=1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ message="系统异常:"+e.getMessage();
|
|
|
+ e.printStackTrace();
|
|
|
+ jurisdiction=2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String,Object> maps = new HashMap<>();
|
|
|
+ maps.put("Type", jurisdiction);
|
|
|
+ if(jurisdiction==1){
|
|
|
+ maps.put("Data", map);
|
|
|
+ return new ResponseEntity<>(maps, HttpStatus.OK);
|
|
|
+ }else {
|
|
|
+ maps.put("Data", message);
|
|
|
+ return new ResponseEntity<>(maps, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //添加新的云外呼数据
|
|
|
+ @RequestMapping("addCloudOutbound")
|
|
|
+ public ResponseEntity<Object> addCloudOutbound(@RequestParam("file") MultipartFile file,HttpServletRequest request){
|
|
|
+ String username = (String) request.getSession().getAttribute("username");
|
|
|
+ int jurisdiction=0;
|
|
|
+ String message="当前用户没有权限";
|
|
|
+ try{
|
|
|
+ String userType =usersMapper.getPermissionList(username);
|
|
|
+ if(userType!=null&&userType.length()!=0){
|
|
|
+ String[] type = userType.split(",");
|
|
|
+ for(int i=0 ;userType.length()>i ; i++){
|
|
|
+ if(type[i].equals("云呼叫导入")){
|
|
|
+ // 获取文件的名称
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
+ //System.out.println(fileName);
|
|
|
+ // 获取文件的后缀名
|
|
|
+ String pattern = fileName.substring(fileName.lastIndexOf(".") + 1);
|
|
|
+ //System.out.println(pattern);
|
|
|
+ List<List<String>> listContent = new ArrayList<>();
|
|
|
+ message = "导入失败";
|
|
|
+ if (file != null) {
|
|
|
+ //文件类型判断
|
|
|
+ if (!FileURL.isEXCEL(file)) {
|
|
|
+ message = "该文件不是Excel文件";
|
|
|
+ } else {
|
|
|
+ listContent = FileURL.readExcelContents(file, pattern);
|
|
|
+ //文件内容判断
|
|
|
+ if (listContent.isEmpty()) {
|
|
|
+ message = "表格内容为空";
|
|
|
+ } else {
|
|
|
+ // 循环遍历
|
|
|
+ for (int y = 0; y < listContent.size(); y++) {
|
|
|
+ CloudOutbound cod = new CloudOutbound();
|
|
|
+ //读取excel表格中的数据
|
|
|
+ Date d = new Date();
|
|
|
+ cod.setC_ID(getTimestamp(d)+"");
|
|
|
+ //赋值
|
|
|
+ cod.setC_CUSTOMER_NAME(listContent.get(y).get(0));
|
|
|
+ cod.setC_CUSTOMER_PHONE(listContent.get(y).get(1));
|
|
|
+ cod.setC_AGENT_NAME(listContent.get(y).get(2));
|
|
|
+ cod.setC_DEVICE_ID(listContent.get(y).get(3));
|
|
|
+ cod.setC_BIND_PHONE(listContent.get(y).get(4));
|
|
|
+ cod.setC_DISPLAY_ORIGIN(listContent.get(y).get(5));
|
|
|
+ cod.setC_CREATOR(username);
|
|
|
+ cod.setN_CONTACT(0);
|
|
|
+ cod.setN_CONNECT(0);
|
|
|
+ // 插入数据
|
|
|
+ cloudOutboundMapper.addCloudOutbound(cod);
|
|
|
+ }
|
|
|
+ message="云外呼清单导入成功";
|
|
|
+ SetSsoLog(request,"云外呼管理","导入云外呼清单");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ message = "未选择文件";
|
|
|
+ }
|
|
|
+ jurisdiction=1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ message="系统异常:"+e.getMessage();
|
|
|
+ e.printStackTrace();
|
|
|
+ jurisdiction=2;
|
|
|
+ }
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put("Type", jurisdiction);
|
|
|
+ map.put("Data", message);
|
|
|
+ return new ResponseEntity<>(map, HttpStatus.OK);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ *//**
|
|
|
+ 获取精确到毫秒的时间戳
|
|
|
+ * @param date
|
|
|
+ * @return
|
|
|
+ **//*
|
|
|
+ public static Long getTimestamp(Date date){
|
|
|
+ if (null == date) {
|
|
|
+ return (long) 0;
|
|
|
+ }
|
|
|
+ String timestamp = String.valueOf(date.getTime());
|
|
|
+ return Long.valueOf(timestamp);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //删除云外呼数据
|
|
|
+ @RequestMapping("delCloudOutbound")
|
|
|
+ public ResponseEntity<Object> delCloudOutbound(HttpServletRequest request,String C_ID) throws Exception {
|
|
|
+ request.setCharacterEncoding("UTF-8");
|
|
|
+ String username = (String) request.getSession().getAttribute("username");
|
|
|
+ int jurisdiction=0;
|
|
|
+ String message="当前用户没有权限";
|
|
|
+ String token = (String) request.getSession().getAttribute("token");
|
|
|
+ Map<String,Object >tokenMap = IFToken.typeTokne(username,token);
|
|
|
+ int tokenTYPE =(int)tokenMap.get("jurisdiction");
|
|
|
+ if(tokenTYPE==0){
|
|
|
+ jurisdiction=3;
|
|
|
+ message =(String)tokenMap.get("message");
|
|
|
+ }else {
|
|
|
+ Date expiresDate = new Date(System.currentTimeMillis() + Integer.valueOf(EXPIRE_TIME) * 60 * 1000);
|
|
|
+ List<Users> users = usersMapper.getUsersListByAccount(username);
|
|
|
+ String key = Token.getToken(users.get(0), expiresDate);
|
|
|
+ request.getSession().setAttribute("token", key);
|
|
|
+ try{
|
|
|
+ String userType =usersMapper.getPermissionList(username);
|
|
|
+ if(userType!=null&&userType.length()!=0){
|
|
|
+ String[] type = userType.split(",");
|
|
|
+ for(int i=0 ;userType.length()>i ; i++){
|
|
|
+ if(type[i].equals("云呼叫导入")){
|
|
|
+ String[] id = C_ID.split(",");
|
|
|
+ for (int y =0 ; id.length>y;y++ ){
|
|
|
+ cloudOutboundMapper.delCloudOutbound(id[y]);
|
|
|
+ message="删除成功";
|
|
|
+ }
|
|
|
+ SetSsoLog(request,"云外呼管理","删除云外呼清单");
|
|
|
+ jurisdiction=1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ message="系统异常:"+e.getMessage();
|
|
|
+ e.printStackTrace();
|
|
|
+ jurisdiction=2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put("Type", jurisdiction);
|
|
|
+ map.put("Data", message);
|
|
|
+ return new ResponseEntity<>(map, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据云外呼ID修改该条数据是否联系状态:0否,1是
|
|
|
+ @RequestMapping("updateCloudOutboundContact")
|
|
|
+ public ResponseEntity<Object> updateCloudOutboundContact(HttpServletRequest request,String C_ID,String C_CUSTOMER_PHONE_S) throws Exception {
|
|
|
+ request.setCharacterEncoding("UTF-8");
|
|
|
+ String username = (String) request.getSession().getAttribute("username");
|
|
|
+ int jurisdiction=0;
|
|
|
+ String message="当前用户没有权限";
|
|
|
+ String token = (String) request.getSession().getAttribute("token");
|
|
|
+ Map<String,Object >tokenMap = IFToken.typeTokne(username,token);
|
|
|
+ int tokenTYPE =(int)tokenMap.get("jurisdiction");
|
|
|
+ if(tokenTYPE==0){
|
|
|
+ jurisdiction=3;
|
|
|
+ message =(String)tokenMap.get("message");
|
|
|
+ }else {
|
|
|
+ Date expiresDate = new Date(System.currentTimeMillis() + Integer.valueOf(EXPIRE_TIME) * 60 * 1000);
|
|
|
+ List<Users> users = usersMapper.getUsersListByAccount(username);
|
|
|
+ String key = Token.getToken(users.get(0), expiresDate);
|
|
|
+ request.getSession().setAttribute("token", key);
|
|
|
+ try{
|
|
|
+ String userType =usersMapper.getPermissionList(username);
|
|
|
+ if(userType!=null&&userType.length()!=0){
|
|
|
+ String[] type = userType.split(",");
|
|
|
+ for(int i=0 ;userType.length()>i ; i++){
|
|
|
+ if(type[i].equals("云呼叫使用")||type[i].equals("云呼叫导入")){
|
|
|
+ String cid = (String) request.getSession().getAttribute("C_ID");
|
|
|
+ cid=C_ID;
|
|
|
+ boolean flag = cloudOutboundMapper.updateCloudOutboundContact(cid) > 0;
|
|
|
+ if(flag){
|
|
|
+ SetSsoLog(request,"云外呼管理","已拨打:"+C_CUSTOMER_PHONE_S);
|
|
|
+ message="云外呼是否联系状态修改成功";
|
|
|
+ }else{
|
|
|
+ message="云外呼是否联系状态修改失败,请联系技术人员处理";
|
|
|
+ }
|
|
|
+ jurisdiction=1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ message="系统异常:"+e.getMessage();
|
|
|
+ e.printStackTrace();
|
|
|
+ jurisdiction=2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put("Type", jurisdiction);
|
|
|
+ map.put("Data", message);
|
|
|
+ return new ResponseEntity<>(map, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ ////根据云外呼ID修改该条数据是否接通状态:0否,1是
|
|
|
+ @RequestMapping("updateCloudOutboundConnect")
|
|
|
+ public ResponseEntity<Object> updateCloudOutboundConnect(HttpServletRequest request,String C_ID) throws Exception {
|
|
|
+ request.setCharacterEncoding("UTF-8");
|
|
|
+ String username = (String) request.getSession().getAttribute("username");
|
|
|
+ int jurisdiction=0;
|
|
|
+ String message="当前用户没有权限";
|
|
|
+ String token = (String) request.getSession().getAttribute("token");
|
|
|
+ Map<String,Object >tokenMap = IFToken.typeTokne(username,token);
|
|
|
+ int tokenTYPE =(int)tokenMap.get("jurisdiction");
|
|
|
+ if(tokenTYPE==0){
|
|
|
+ jurisdiction=3;
|
|
|
+ message =(String)tokenMap.get("message");
|
|
|
+ }else {
|
|
|
+ Date expiresDate = new Date(System.currentTimeMillis() + Integer.valueOf(EXPIRE_TIME) * 60 * 1000);
|
|
|
+ List<Users> users = usersMapper.getUsersListByAccount(username);
|
|
|
+ String key = Token.getToken(users.get(0), expiresDate);
|
|
|
+ request.getSession().setAttribute("token", key);
|
|
|
+ try{
|
|
|
+ String userType =usersMapper.getPermissionList(username);
|
|
|
+ if(userType!=null&&userType.length()!=0){
|
|
|
+ String[] type = userType.split(",");
|
|
|
+ for(int i=0 ;userType.length()>i ; i++){
|
|
|
+ if(type[i].equals("云呼叫使用")||type[i].equals("云呼叫导入")){
|
|
|
+ String cid = (String) request.getSession().getAttribute("C_ID");
|
|
|
+ cid=C_ID;
|
|
|
+ boolean flag = cloudOutboundMapper.updateCloudOutboundConnect(cid) > 0;
|
|
|
+ if(flag){
|
|
|
+ message="云外呼是否接通状态修改成功";
|
|
|
+ }else{
|
|
|
+ message="云外呼是否接通状态修改失败,请联系技术人员处理";
|
|
|
+ }
|
|
|
+ jurisdiction=1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ message="系统异常:"+e.getMessage();
|
|
|
+ e.printStackTrace();
|
|
|
+ jurisdiction=2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put("Type", jurisdiction);
|
|
|
+ map.put("Data", message);
|
|
|
+ return new ResponseEntity<>(map, HttpStatus.OK);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据云外呼ID修改该条数据是否联系状态:0否,1是
|
|
|
+ @RequestMapping("CloudOut")
|
|
|
+ public ResponseEntity<Object> CloudOut(HttpServletRequest request,String CloudOutValue) throws Exception {
|
|
|
+ request.setCharacterEncoding("UTF-8");
|
|
|
+ String username = (String) request.getSession().getAttribute("username");
|
|
|
+ int jurisdiction=0;
|
|
|
+ String message="当前用户没有权限";
|
|
|
+ String token = (String) request.getSession().getAttribute("token");
|
|
|
+ Map<String,Object >tokenMap = IFToken.typeTokne(username,token);
|
|
|
+ int tokenTYPE =(int)tokenMap.get("jurisdiction");
|
|
|
+ String post=null;
|
|
|
+ if(tokenTYPE==0){
|
|
|
+ jurisdiction=3;
|
|
|
+ message =(String)tokenMap.get("message");
|
|
|
+ }else {
|
|
|
+ Date expiresDate = new Date(System.currentTimeMillis() + Integer.valueOf(EXPIRE_TIME) * 60 * 1000);
|
|
|
+ List<Users> users = usersMapper.getUsersListByAccount(username);
|
|
|
+ String key = Token.getToken(users.get(0), expiresDate);
|
|
|
+ request.getSession().setAttribute("token", key);
|
|
|
+
|
|
|
+ try{
|
|
|
+ String userType =usersMapper.getPermissionList(username);
|
|
|
+ if(userType!=null&&userType.length()!=0){
|
|
|
+ String[] type = userType.split(",");
|
|
|
+ for(int i=0 ;userType.length()>i ; i++){
|
|
|
+ if(type[i].equals("云呼叫使用")||type[i].equals("云呼叫导入")){
|
|
|
+ String cid = (String) request.getSession().getAttribute("C_ID");
|
|
|
+ org.codehaus.jettison.json.JSONObject jsonObject1 = new org.codehaus.jettison.json.JSONObject();
|
|
|
+ *//*String appId = "41b79a8f-fce8-43e0-9809-e0d1848aad01";
|
|
|
+ String appSecret = "2D06BFE5-10B2-40BC-89A6-5C47AAD08472";
|
|
|
+ String apiKey = "kENe0S6cyYnqcHTtqLDwD3lwRFNVTyfd";*//*
|
|
|
+ jsonObject1.put("appId", appId);
|
|
|
+ jsonObject1.put("appSecret", appSecret);
|
|
|
+ jsonObject1.put("apiKey", apiKey);
|
|
|
+
|
|
|
+ List<HttpInterface> list = httpInterfaceMapper.getIpHttpInterface("云呼叫使用","Webpagetoken");
|
|
|
+ if(list.size()>0) {
|
|
|
+ HttpInterface hife =list.get(0);
|
|
|
+ String HTTPSTokenUrl=hife.getURL();
|
|
|
+ String[] split = HTTPSTokenUrl.split("https://");
|
|
|
+ String[] split2 = HTTPSTokenUrl.split("HTTPS://");
|
|
|
+ int utlSZ =split.length +split2.length;
|
|
|
+
|
|
|
+ if(utlSZ>=3){
|
|
|
+ System.out.println("---------------"+"https接口"+"---------------");
|
|
|
+ post= HttpClientUtil.doPost(HTTPSTokenUrl, jsonObject1, "utf-8");
|
|
|
+
|
|
|
+ }else {
|
|
|
+ System.out.println("---------------"+"http接口"+"---------------");
|
|
|
+ PostHttp postHttp =new PostHttp();
|
|
|
+ post =postHttp.send(HTTPSTokenUrl,jsonObject1);
|
|
|
+ }
|
|
|
+ if(post!=null&&!post.isEmpty()){
|
|
|
+ System.out.println("云外呼获取Token返回参数:"+post);
|
|
|
+ org.codehaus.jettison.json.JSONObject jsonToken = new org.codehaus.jettison.json.JSONObject(post);
|
|
|
+ String access_token = (String) jsonToken.get("access_token");
|
|
|
+ if(access_token!=null && !access_token.isEmpty()){
|
|
|
+ List<HttpInterface> list2 = httpInterfaceMapper.getIpHttpInterface("云呼叫使用","Webpagecall");
|
|
|
+ if(list2.size()>0){
|
|
|
+ HttpInterface hife2 =list2.get(0);
|
|
|
+ String HTTPSCallUrl=hife2.getURL();
|
|
|
+ System.out.println(CloudOutValue);
|
|
|
+ org.codehaus.jettison.json.JSONObject jsonCloudOutValue = new org.codehaus.jettison.json.JSONObject(CloudOutValue);
|
|
|
+ cid=(String)jsonCloudOutValue.get("C_ID");
|
|
|
+ System.out.println("cid:"+cid);
|
|
|
+ Object COValue = jsonCloudOutValue.get("data");
|
|
|
+ System.out.println("COValue:"+COValue.toString());
|
|
|
+ org.codehaus.jettison.json.JSONObject jsonCOV = new org.codehaus.jettison.json.JSONObject(COValue.toString());
|
|
|
+ System.out.println("外呼CALL传参的Json:"+jsonCOV);
|
|
|
+
|
|
|
+ String[] split3 = HTTPSCallUrl.split("https://");
|
|
|
+ String[] split4 = HTTPSCallUrl.split("HTTPS://");
|
|
|
+ int utlSZs =split3.length +split4.length;
|
|
|
+
|
|
|
+ if(utlSZs>=3){
|
|
|
+ System.out.println("---------------"+"https接口"+"---------------");
|
|
|
+ //post= HttpClientUtil.doPost(HTTPSTokenUrl, jsonObject1, "utf-8");
|
|
|
+ //post = HttpClientUtil.doHeaderPost(HTTPSCallUrl,access_token,jsonCOV,"utf-8");
|
|
|
+ post=HttpClientUtil.doPost(hife.getURL(), jsonObject1, "utf-8");
|
|
|
+
|
|
|
+ }else {
|
|
|
+ System.out.println("---------------"+"http接口"+"---------------");
|
|
|
+ PostHttp postHttp =new PostHttp();
|
|
|
+ //post =postHttp.sendHeader(HTTPSTokenUrl,access_token,jsonObject1);
|
|
|
+ post =postHttp.send(hife.getURL(),jsonObject1);
|
|
|
+ }
|
|
|
+ //post = HttpClientUtil.doHeaderPost(HTTPSCallUrl,access_token,jsonCOV,"utf-8");
|
|
|
+ System.out.println("请求外呼call返回参数:"+post);
|
|
|
+ org.codehaus.jettison.json.JSONObject jsonGetV = new org.codehaus.jettison.json.JSONObject(post);
|
|
|
+ message =(String)jsonGetV.get("callId");
|
|
|
+ String customerPhone = (String) jsonCOV.get("customerPhone");
|
|
|
+ StringBuilder sb = new StringBuilder(customerPhone);
|
|
|
+ sb.replace(4,7,"****");
|
|
|
+
|
|
|
+ System.out.println("加密手机号码:"+sb.toString());
|
|
|
+ if(!cid.equals("*")){
|
|
|
+ boolean flag = cloudOutboundMapper.updateCloudOutboundContact(cid) > 0;
|
|
|
+ if(flag){
|
|
|
+ System.out.println("云外呼是否联系状态修改成功");
|
|
|
+ //message="云外呼是否联系状态修改成功";
|
|
|
+ }else{
|
|
|
+ System.out.println("云外呼是否联系状态修改失败,请联系技术人员处理");
|
|
|
+ //message="云外呼是否联系状态修改失败,请联系技术人员处理";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ SetSsoLog(request,"云外呼管理","已拨打:"+sb.toString());
|
|
|
+ jurisdiction=1;
|
|
|
+ break;
|
|
|
+ }else {
|
|
|
+ message="云外呼callIP地址数据库未获取到";
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ message="云外呼token值未获取到返回值access_token";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ message="云外呼tokenIP地址数据库未获取到";
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ message="系统异常:"+e.getMessage();
|
|
|
+ e.printStackTrace();
|
|
|
+ jurisdiction=2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put("Type", jurisdiction);
|
|
|
+ map.put("Data", message);
|
|
|
+ return new ResponseEntity<>(map, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ public CloudOutboundVo cloudOutboundPoToVo(CloudOutbound po){
|
|
|
+ CloudOutboundVo vo = new CloudOutboundVo();
|
|
|
+ vo.setC_ID(po.getC_ID());
|
|
|
+ vo.setC_CUSTOMER_NAME(po.getC_CUSTOMER_NAME());
|
|
|
+ vo.setC_CUSTOMER_PHONE(po.getC_CUSTOMER_PHONE());
|
|
|
+ vo.setC_AGENT_NAME(po.getC_AGENT_NAME());
|
|
|
+ vo.setC_DEVICE_ID(po.getC_DEVICE_ID());
|
|
|
+ vo.setC_BIND_PHONE(po.getC_BIND_PHONE());
|
|
|
+ vo.setC_DISPLAY_ORIGIN(po.getC_DISPLAY_ORIGIN());
|
|
|
+ vo.setT_CRT_TIME(po.getT_CRT_TIME());
|
|
|
+ vo.setC_CREATOR(po.getC_CREATOR());
|
|
|
+ vo.setN_CONTACT(po.getN_CONTACT());
|
|
|
+ vo.setN_CONNECT(po.getN_CONNECT());
|
|
|
+ vo.setC_CUSTOMER_PHONE_S(po.getC_CUSTOMER_PHONE_S());
|
|
|
+ String time =po.getT_CRT_TIME();
|
|
|
+ //System.out.println(time);
|
|
|
+ if(time.length()>19){
|
|
|
+ time=dealDateFormat(time);
|
|
|
+ vo.setT_CRT_TIME(time);
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+ public JSONObject getJSONParam(HttpServletRequest request){
|
|
|
+ JSONObject jsonParam = null;
|
|
|
+ try {
|
|
|
+ // 获取输入流
|
|
|
+ BufferedReader streamReader = new BufferedReader(new InputStreamReader(request.getInputStream(), "UTF-8"));
|
|
|
+
|
|
|
+ // 写入数据到Stringbuilder
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ String line = null;
|
|
|
+ while ((line = streamReader.readLine()) != null) {
|
|
|
+ sb.append(line);
|
|
|
+ }
|
|
|
+ jsonParam = JSONObject.parseObject(sb.toString());
|
|
|
+ // 直接将json信息打印出来
|
|
|
+ if(jsonParam!=null){
|
|
|
+ //logger.info(jsonParam.toJSONString());
|
|
|
+ }else{
|
|
|
+ //logger.info("请求JSON为空");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return jsonParam;
|
|
|
+ }
|
|
|
+ public static String dealDateFormat(String oldDate) {
|
|
|
+ Date date1 = null;
|
|
|
+ DateFormat df2 = null;
|
|
|
+ try {
|
|
|
+ DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
|
|
+ Date date = df.parse(oldDate);
|
|
|
+ SimpleDateFormat df1 = new SimpleDateFormat ("EEE MMM dd HH:mm:ss Z yyyy", Locale.UK);
|
|
|
+ date1 = df1.parse(date.toString());
|
|
|
+ df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return df2.format(date1);
|
|
|
+ }
|
|
|
+ public void SetSsoLog(HttpServletRequest request,String C_OPERATE_MODULE,String C_OPERATE_CONTENT){
|
|
|
+ String username = (String) request.getSession().getAttribute("username");
|
|
|
+ SsoLog ssoLog = new SsoLog();
|
|
|
+ //获取id号码
|
|
|
+ Date dp = new Date();
|
|
|
+ ssoLog.setC_LOG_ID(getTimestamp(dp)+"");
|
|
|
+ //获取用户姓名
|
|
|
+ String uName = usersMapper.getUserName(username);
|
|
|
+ ssoLog.setC_OPERATE_USER(uName);
|
|
|
+ CusAccessObjectUtil caou =new CusAccessObjectUtil();
|
|
|
+ //获取客户端IP
|
|
|
+ String ip = caou.getIpAddr(request);
|
|
|
+ ssoLog.setC_IP(ip);
|
|
|
+ //获取用户操作模块
|
|
|
+ ssoLog.setC_OPERATE_MODULE(C_OPERATE_MODULE);
|
|
|
+ //获取用户操作内容
|
|
|
+ ssoLog.setC_OPERATE_CONTENT(C_OPERATE_CONTENT);
|
|
|
+ //插入数据库中
|
|
|
+ ssoLogMapper.addSsoLog(ssoLog);
|
|
|
+ }*/
|
|
|
+}
|