From 304abf411eb0f74aa52c58faa3017dcffaaf39fa Mon Sep 17 00:00:00 2001 From: Lenovo Date: Fri, 5 Jul 2024 18:08:38 +0800 Subject: [PATCH] =?UTF-8?q?ai=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/controller/AiController.java | 115 ++++++++++++ .../framework/config/SecurityConfig.java | 8 +- .../com/ruoyi/business/domain/BusAiInfo.java | 164 ++++++++++++++++++ .../business/mapper/BusAiInfoMapper.java | 61 +++++++ .../business/service/IBusAiInfoService.java | 61 +++++++ .../service/impl/BusAiInfoServiceImpl.java | 95 ++++++++++ .../mapper/business/BusAiInfoMapper.xml | 100 +++++++++++ 7 files changed, 600 insertions(+), 4 deletions(-) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/business/controller/AiController.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/business/domain/BusAiInfo.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/business/mapper/BusAiInfoMapper.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/business/service/IBusAiInfoService.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/business/service/impl/BusAiInfoServiceImpl.java create mode 100644 ruoyi-system/src/main/resources/mapper/business/BusAiInfoMapper.xml diff --git a/ruoyi-admin/src/main/java/com/ruoyi/business/controller/AiController.java b/ruoyi-admin/src/main/java/com/ruoyi/business/controller/AiController.java new file mode 100644 index 0000000..bb0659e --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/business/controller/AiController.java @@ -0,0 +1,115 @@ +package com.ruoyi.business.controller; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import com.ruoyi.business.domain.BusAiInfo; +import com.ruoyi.business.domain.SysCookie; +import com.ruoyi.business.service.IBusAiInfoService; +import com.ruoyi.business.service.IMeituanService; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.utils.HttpClientUtilT; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.Map; + + +/** + * 采集美团接口 + */ +@RestController +@RequestMapping("/ai") +public class AiController { + + @Autowired + private IBusAiInfoService aiInfoService; + + @GetMapping(value = "/login") + public void login() + { + String url = "https://ai002.ciopaas.com/api/login"; + String userName = "zw982210"; + Map header = new HashMap<>(); + header.put("Accept", "application/json"); + header.put("Content-Type", "application/json;charset=utf-8"); + String loginJson = "{\"username\":\""+userName+"\",\"password\":\""+userName+"\",\"from\":\"2\",\"url\":\"83710973\"}"; + String loginResult = HttpClientUtilT.doPostJson(url,header, loginJson); + JSONObject jsonObject = JSONObject.parseObject(loginResult); + if ("0".equals(jsonObject.getString("code"))){ + JSONObject data = jsonObject.getJSONObject("data"); + String apiKey = data.getString("api_key"); + String userSn = data.getString("user_sn"); + String projectSn = data.getString("project_sn"); + System.out.println("login 返回:===========apikey,userSn,projectSn============="+apiKey+","+userSn+","+projectSn); + + String projectSn1 = projectSn.split(",")[0]; + + String requestJson = "{\"api_key\": \""+apiKey+"\",\"user_sn\": \""+userSn+"\",\"source\": \"测试任务\",\"project_sn\": \""+projectSn1+"\",\"ai_user_sn\": \"SYSUSER|2665bcca63a2b5c724095fa01dce0470\",\"is_zidong\": \"on\",\"client_info_json\": {\"data\": [{\"姓名\": \"ws测试\",\"电话\": \"1761240322\",\"备注\": \"门店新客\",\"虚拟分机号\": \"9292\"}]},\"is_open_second_dialing\": \"1\",\n" + + "\"is_open_remove_duplication\": \"0\",\"dial_task_main_sn\": \"20240621203741220560000000000034\",\"is_append\": \"0\"}"; + String requestUrl = "https://ai002.ciopaas.com/api/addJsonOfAsync"; + String requestResult = HttpClientUtilT.doPostJson(requestUrl,header,requestJson); + JSONObject jo = JSONObject.parseObject(requestResult); + if ("0".equals(jo.getString("code"))){ + JSONObject data1 = jo.getJSONObject("data"); + String taskMainId = data1.getString("dial_task_main_id"); + String taskMainSn = data1.getString("dial_task_main_sn"); + +// JSONArray jsonArray = jsonObject.getJSONArray("list"); +// JSONObject joo = jsonArray.getJSONObject(0); +// String taskMainSn1 = joo.getString("dial_task_main_sn"); +// System.out.println(taskMainSn1); + + System.out.println("建立任务返回: ============taskMainId,taskMainSn==========="+taskMainId+","+taskMainSn); + + String url1 = "https://ai002.ciopaas.com/api/crmList"; + String json1 = "{\"api_key\":\""+apiKey+"\",\"user_sn\":\""+userSn+"\",\"pageIndex\":\"0\",\"pageSize\":\"20\"}"; + String result1 = HttpClientUtilT.doPostJson(url1,header,json1); + JSONObject jsonObject1 = JSONObject.parseObject(result1); + if ("0".equals(jsonObject1.getString("code"))){ + JSONArray jsonArray = jsonObject1.getJSONObject("data").getJSONArray("list"); + for (Object o : jsonArray) { + JSONObject oj = JSONObject.parseObject(JSON.toJSONString(o)); + String id = oj.getString("id"); + String dial_task_main_sn = oj.getString("dial_task_main_sn"); + String phone = oj.getString("phone"); + String virtual_extension_number = oj.getString("virtual_extension_number"); + String connected_at = oj.getString("connected_at"); + String disconnected_at = oj.getString("disconnected_at"); + String talktimes = oj.getString("talktimes"); + String mark = oj.getString("mark"); + String source = oj.getString("source"); + System.out.println(id); + System.out.println(dial_task_main_sn); + System.out.println(phone); + System.out.println(virtual_extension_number); + System.out.println(connected_at); + System.out.println(disconnected_at); + System.out.println(talktimes); + System.out.println(mark); + System.out.println(source); + BusAiInfo aiInfo = new BusAiInfo(); + aiInfo.setSerialId(id); + aiInfo.setDialTaskMainSn(dial_task_main_sn); + aiInfo.setPhone(phone); + aiInfo.setVirtualExtensionNumber(virtual_extension_number); + aiInfo.setConnectedAt(connected_at); + aiInfo.setDisconnectedAt(disconnected_at); + aiInfo.setTalktimes(talktimes); + aiInfo.setMark(mark); + aiInfo.setSource(source); + aiInfoService.insertBusAiInfo(aiInfo); + } + } else { + System.out.println("crmList接口返回错误: " + jsonObject1.toString()); + } + } else { + System.out.println("建立任务接口返回错误: " + jo.toString()); + } + } else { + System.out.println("login接口返回错误: " + jsonObject.toString()); + } + } + +} diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index 11fb7ba..c9d162e 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -23,7 +23,7 @@ import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl; /** * spring security配置 - * + * * @author ruoyi */ @EnableMethodSecurity(prePostEnabled = true, securedEnabled = true) @@ -35,7 +35,7 @@ public class SecurityConfig */ @Autowired private UserDetailsService userDetailsService; - + /** * 认证失败处理类 */ @@ -53,7 +53,7 @@ public class SecurityConfig */ @Autowired private JwtAuthenticationTokenFilter authenticationTokenFilter; - + /** * 跨域过滤器 */ @@ -115,7 +115,7 @@ public class SecurityConfig // 静态资源,可匿名访问 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() - .antMatchers("/mt/**").permitAll() + .antMatchers("/mt/**","/ai/**").permitAll() // 除上面外的所有请求全部需要鉴权认证 .anyRequest().authenticated(); diff --git a/ruoyi-system/src/main/java/com/ruoyi/business/domain/BusAiInfo.java b/ruoyi-system/src/main/java/com/ruoyi/business/domain/BusAiInfo.java new file mode 100644 index 0000000..817553b --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/business/domain/BusAiInfo.java @@ -0,0 +1,164 @@ +package com.ruoyi.business.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * ai对象 bus_ai_info + * + * @author ruoyi + * @date 2024-07-05 + */ +public class BusAiInfo extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** $column.columnComment */ + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") + private String serialId; + + /** $column.columnComment */ + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") + private String dialTaskMainSn; + + /** $column.columnComment */ + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") + private String phone; + + /** $column.columnComment */ + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") + private String virtualExtensionNumber; + + /** $column.columnComment */ + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") + private String connectedAt; + + /** $column.columnComment */ + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") + private String disconnectedAt; + + /** $column.columnComment */ + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") + private String talktimes; + + /** $column.columnComment */ + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") + private String mark; + + /** $column.columnComment */ + @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") + private String source; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setSerialId(String serialId) + { + this.serialId = serialId; + } + + public String getSerialId() + { + return serialId; + } + public void setDialTaskMainSn(String dialTaskMainSn) + { + this.dialTaskMainSn = dialTaskMainSn; + } + + public String getDialTaskMainSn() + { + return dialTaskMainSn; + } + public void setPhone(String phone) + { + this.phone = phone; + } + + public String getPhone() + { + return phone; + } + public void setVirtualExtensionNumber(String virtualExtensionNumber) + { + this.virtualExtensionNumber = virtualExtensionNumber; + } + + public String getVirtualExtensionNumber() + { + return virtualExtensionNumber; + } + public void setConnectedAt(String connectedAt) + { + this.connectedAt = connectedAt; + } + + public String getConnectedAt() + { + return connectedAt; + } + public void setDisconnectedAt(String disconnectedAt) + { + this.disconnectedAt = disconnectedAt; + } + + public String getDisconnectedAt() + { + return disconnectedAt; + } + public void setTalktimes(String talktimes) + { + this.talktimes = talktimes; + } + + public String getTalktimes() + { + return talktimes; + } + public void setMark(String mark) + { + this.mark = mark; + } + + public String getMark() + { + return mark; + } + public void setSource(String source) + { + this.source = source; + } + + public String getSource() + { + return source; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("serialId", getSerialId()) + .append("dialTaskMainSn", getDialTaskMainSn()) + .append("phone", getPhone()) + .append("virtualExtensionNumber", getVirtualExtensionNumber()) + .append("connectedAt", getConnectedAt()) + .append("disconnectedAt", getDisconnectedAt()) + .append("talktimes", getTalktimes()) + .append("mark", getMark()) + .append("source", getSource()) + .append("createTime", getCreateTime()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/business/mapper/BusAiInfoMapper.java b/ruoyi-system/src/main/java/com/ruoyi/business/mapper/BusAiInfoMapper.java new file mode 100644 index 0000000..44c67fa --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/business/mapper/BusAiInfoMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.business.mapper; + +import java.util.List; +import com.ruoyi.business.domain.BusAiInfo; + +/** + * aiMapper接口 + * + * @author ruoyi + * @date 2024-07-05 + */ +public interface BusAiInfoMapper +{ + /** + * 查询ai + * + * @param id ai主键 + * @return ai + */ + public BusAiInfo selectBusAiInfoById(Long id); + + /** + * 查询ai列表 + * + * @param busAiInfo ai + * @return ai集合 + */ + public List selectBusAiInfoList(BusAiInfo busAiInfo); + + /** + * 新增ai + * + * @param busAiInfo ai + * @return 结果 + */ + public int insertBusAiInfo(BusAiInfo busAiInfo); + + /** + * 修改ai + * + * @param busAiInfo ai + * @return 结果 + */ + public int updateBusAiInfo(BusAiInfo busAiInfo); + + /** + * 删除ai + * + * @param id ai主键 + * @return 结果 + */ + public int deleteBusAiInfoById(Long id); + + /** + * 批量删除ai + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteBusAiInfoByIds(Long[] ids); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/business/service/IBusAiInfoService.java b/ruoyi-system/src/main/java/com/ruoyi/business/service/IBusAiInfoService.java new file mode 100644 index 0000000..32ed976 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/business/service/IBusAiInfoService.java @@ -0,0 +1,61 @@ +package com.ruoyi.business.service; + +import java.util.List; +import com.ruoyi.business.domain.BusAiInfo; + +/** + * aiService接口 + * + * @author ruoyi + * @date 2024-07-05 + */ +public interface IBusAiInfoService +{ + /** + * 查询ai + * + * @param id ai主键 + * @return ai + */ + public BusAiInfo selectBusAiInfoById(Long id); + + /** + * 查询ai列表 + * + * @param busAiInfo ai + * @return ai集合 + */ + public List selectBusAiInfoList(BusAiInfo busAiInfo); + + /** + * 新增ai + * + * @param busAiInfo ai + * @return 结果 + */ + public int insertBusAiInfo(BusAiInfo busAiInfo); + + /** + * 修改ai + * + * @param busAiInfo ai + * @return 结果 + */ + public int updateBusAiInfo(BusAiInfo busAiInfo); + + /** + * 批量删除ai + * + * @param ids 需要删除的ai主键集合 + * @return 结果 + */ + public int deleteBusAiInfoByIds(Long[] ids); + + /** + * 删除ai信息 + * + * @param id ai主键 + * @return 结果 + */ + public int deleteBusAiInfoById(Long id); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/business/service/impl/BusAiInfoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/business/service/impl/BusAiInfoServiceImpl.java new file mode 100644 index 0000000..d0c3b78 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/business/service/impl/BusAiInfoServiceImpl.java @@ -0,0 +1,95 @@ +package com.ruoyi.business.service.impl; + +import java.util.List; +import com.ruoyi.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.business.mapper.BusAiInfoMapper; +import com.ruoyi.business.domain.BusAiInfo; +import com.ruoyi.business.service.IBusAiInfoService; + +/** + * aiService业务层处理 + * + * @author ruoyi + * @date 2024-07-05 + */ +@Service +public class BusAiInfoServiceImpl implements IBusAiInfoService +{ + @Autowired + private BusAiInfoMapper busAiInfoMapper; + + /** + * 查询ai + * + * @param id ai主键 + * @return ai + */ + @Override + public BusAiInfo selectBusAiInfoById(Long id) + { + return busAiInfoMapper.selectBusAiInfoById(id); + } + + /** + * 查询ai列表 + * + * @param busAiInfo ai + * @return ai + */ + @Override + public List selectBusAiInfoList(BusAiInfo busAiInfo) + { + return busAiInfoMapper.selectBusAiInfoList(busAiInfo); + } + + /** + * 新增ai + * + * @param busAiInfo ai + * @return 结果 + */ + @Override + public int insertBusAiInfo(BusAiInfo busAiInfo) + { + busAiInfo.setCreateTime(DateUtils.getNowDate()); + return busAiInfoMapper.insertBusAiInfo(busAiInfo); + } + + /** + * 修改ai + * + * @param busAiInfo ai + * @return 结果 + */ + @Override + public int updateBusAiInfo(BusAiInfo busAiInfo) + { + return busAiInfoMapper.updateBusAiInfo(busAiInfo); + } + + /** + * 批量删除ai + * + * @param ids 需要删除的ai主键 + * @return 结果 + */ + @Override + public int deleteBusAiInfoByIds(Long[] ids) + { + return busAiInfoMapper.deleteBusAiInfoByIds(ids); + } + + /** + * 删除ai信息 + * + * @param id ai主键 + * @return 结果 + */ + @Override + public int deleteBusAiInfoById(Long id) + { + return busAiInfoMapper.deleteBusAiInfoById(id); + } +} diff --git a/ruoyi-system/src/main/resources/mapper/business/BusAiInfoMapper.xml b/ruoyi-system/src/main/resources/mapper/business/BusAiInfoMapper.xml new file mode 100644 index 0000000..9dea073 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/business/BusAiInfoMapper.xml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + select id, serial_id, dial_task_main_sn, phone, virtual_extension_number, connected_at, disconnected_at, talktimes, mark, source, create_time from bus_ai_info + + + + + + + + insert into bus_ai_info + + serial_id, + dial_task_main_sn, + phone, + virtual_extension_number, + connected_at, + disconnected_at, + talktimes, + mark, + source, + create_time, + + + #{serialId}, + #{dialTaskMainSn}, + #{phone}, + #{virtualExtensionNumber}, + #{connectedAt}, + #{disconnectedAt}, + #{talktimes}, + #{mark}, + #{source}, + #{createTime}, + + + + + update bus_ai_info + + serial_id = #{serialId}, + dial_task_main_sn = #{dialTaskMainSn}, + phone = #{phone}, + virtual_extension_number = #{virtualExtensionNumber}, + connected_at = #{connectedAt}, + disconnected_at = #{disconnectedAt}, + talktimes = #{talktimes}, + mark = #{mark}, + source = #{source}, + create_time = #{createTime}, + + where id = #{id} + + + + delete from bus_ai_info where id = #{id} + + + + delete from bus_ai_info where id in + + #{id} + + +