Browse Source

外呼系统开发

anderx 1 year ago
parent
commit
84660cce09

+ 85 - 0
src/main/java/com/goafanti/common/dao/CallLogMapper.java

@@ -0,0 +1,85 @@
+package com.goafanti.common.dao;
+
+import com.goafanti.common.model.CallLog;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.data.domain.Pageable;
+
+import java.util.List;
+
+/**
+ * 呼叫记录(CallLog)表数据库访问层
+ *
+ * @author makejava
+ * @since 2024-11-20 11:17:55
+ */
+public interface CallLogMapper {
+
+    /**
+     * 通过ID查询单条数据
+     *
+     * @param id 主键
+     * @return 实例对象
+     */
+    CallLog queryById(Integer id);
+
+
+    /**
+     * 查询指定行数据
+     *
+     * @param callLog  查询条件
+     * @param pageable 分页对象
+     * @return 对象列表
+     */
+    List<CallLog> findCallLogList(CallLog callLog, @Param("pageable") Pageable pageable);
+
+    /**
+     * 统计总行数
+     *
+     * @param callLog 查询条件
+     * @return 总行数
+     */
+    int findCallLogCount(CallLog callLog);
+
+    /**
+     * 新增数据
+     *
+     * @param callLog 实例对象
+     * @return 影响行数
+     */
+    int insert(CallLog callLog);
+
+    /**
+     * 批量新增数据(MyBatis原生foreach方法)
+     *
+     * @param entities List<CallLog> 实例对象列表
+     * @return 影响行数
+     */
+    int insertBatch(@Param("entities") List<CallLog> entities);
+
+    /**
+     * 批量新增或按主键更新数据(MyBatis原生foreach方法)
+     *
+     * @param entities List<CallLog> 实例对象列表
+     * @return 影响行数
+     * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
+     */
+    int insertOrUpdateBatch(@Param("entities") List<CallLog> entities);
+
+    /**
+     * 修改数据
+     *
+     * @param callLog 实例对象
+     * @return 影响行数
+     */
+    int update(CallLog callLog);
+
+    /**
+     * 通过主键删除数据
+     *
+     * @param id 主键
+     * @return 影响行数
+     */
+    int deleteById(Integer id);
+
+}
+

+ 2 - 0
src/main/java/com/goafanti/common/dao/OrganizationContactBookMapper.java

@@ -92,4 +92,6 @@ public interface OrganizationContactBookMapper {
 	void updateByUids(@Param("list")List<String> list, @Param("aid")String aid);
 
 	OrganizationContactBook getMajor(@Param("uid")String uid, @Param("aid")String aid);
+
+	List<OrganizationContactBook>  selectUserByContact(@Param("mobile") String mobile);
 }

+ 189 - 0
src/main/java/com/goafanti/common/mapper/CallLogMapper.xml

@@ -0,0 +1,189 @@
+<?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="com.goafanti.common.dao.CallLogMapper">
+
+    <resultMap type="com.goafanti.common.model.CallLog" id="CallLogMap">
+        <result property="id" column="id" jdbcType="INTEGER"/>
+        <result property="uid" column="uid" jdbcType="VARCHAR"/>
+        <result property="aid" column="aid" jdbcType="VARCHAR"/>
+        <result property="adminName" column="admin_name" jdbcType="VARCHAR"/>
+        <result property="contacts" column="contacts" jdbcType="VARCHAR"/>
+        <result property="mobileLastDigits" column="mobile_last_digits" jdbcType="VARCHAR"/>
+        <result property="status" column="status" jdbcType="INTEGER"/>
+        <result property="duration" column="duration" jdbcType="INTEGER"/>
+        <result property="remarks" column="remarks" jdbcType="VARCHAR"/>
+        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <sql id="CallLogAllSql">
+        id, uid, aid, admin_name, contacts, mobile_last_digits, status, duration, remarks, create_time
+    </sql>
+
+    <!--查询单个-->
+    <select id="queryById" resultMap="CallLogMap">
+        select
+        <include refid="CallLogAllSql"/>
+        from call_log
+        where id = #{id}
+    </select>
+
+    <!--查询指定行数据-->
+    <select id="findCallLogList" resultMap="CallLogMap">
+        select
+        <include refid="CallLogAllSql"/>
+
+        from call_log
+        <where>
+            <if test="id != null">
+                and id = #{id}
+            </if>
+            <if test="uid != null and uid != ''">
+                and uid = #{uid}
+            </if>
+            <if test="aid != null and aid != ''">
+                and aid = #{aid}
+            </if>
+            <if test="adminName != null and adminName != ''">
+                and admin_name = #{adminName}
+            </if>
+            <if test="contacts != null and contacts != ''">
+                and contacts = #{contacts}
+            </if>
+            <if test="mobileLastDigits != null and mobileLastDigits != ''">
+                and mobile_last_digits = #{mobileLastDigits}
+            </if>
+            <if test="status != null">
+                and status = #{status}
+            </if>
+            <if test="duration != null">
+                and duration = #{duration}
+            </if>
+            <if test="remarks != null and remarks != ''">
+                and remarks = #{remarks}
+            </if>
+            <if test="createTime != null">
+                and create_time = #{createTime}
+            </if>
+        </where>
+        <if test="page_sql != null">
+            ${page_sql}
+        </if>
+    </select>
+
+    <!--统计总行数-->
+    <select id="findCallLogCount" resultType="java.lang.Integer">
+        select count(1)
+        from call_log
+        <where>
+            <if test="id != null">
+                and id = #{id}
+            </if>
+            <if test="uid != null and uid != ''">
+                and uid = #{uid}
+            </if>
+            <if test="aid != null and aid != ''">
+                and aid = #{aid}
+            </if>
+            <if test="adminName != null and adminName != ''">
+                and admin_name = #{adminName}
+            </if>
+            <if test="contacts != null and contacts != ''">
+                and contacts = #{contacts}
+            </if>
+            <if test="mobileLastDigits != null and mobileLastDigits != ''">
+                and mobile_last_digits = #{mobileLastDigits}
+            </if>
+            <if test="status != null">
+                and status = #{status}
+            </if>
+            <if test="duration != null">
+                and duration = #{duration}
+            </if>
+            <if test="remarks != null and remarks != ''">
+                and remarks = #{remarks}
+            </if>
+            <if test="createTime != null">
+                and create_time = #{createTime}
+            </if>
+        </where>
+    </select>
+
+    <!--新增所有列-->
+    <insert id="insert" keyProperty="id" useGeneratedKeys="true">
+        insert into call_log(uid, aid, admin_name, contacts, mobile_last_digits, status, duration, remarks, create_time)
+        values (#{uid}, #{aid}, #{adminName}, #{contacts}, #{mobileLastDigits}, #{status}, #{duration}, #{remarks},
+                #{createTime})
+    </insert>
+
+    <insert id="insertBatch">
+        insert into call_log(uid, aid, admin_name, contacts, mobile_last_digits, status, duration, remarks, create_time)
+        values
+        <foreach collection="entities" item="entity" separator=",">
+            (#{entity.uid}, #{entity.aid}, #{entity.adminName}, #{entity.contacts}, #{entity.mobileLastDigits},
+            #{entity.status}, #{entity.duration}, #{entity.remarks}, #{entity.createTime})
+        </foreach>
+    </insert>
+
+    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
+        insert into call_log(uid, aid, admin_name, contacts, mobile_last_digits, status, duration, remarks, create_time)
+        values
+        <foreach collection="entities" item="entity" separator=",">
+            (#{entity.uid}, #{entity.aid}, #{entity.adminName}, #{entity.contacts}, #{entity.mobileLastDigits},
+            #{entity.status}, #{entity.duration}, #{entity.remarks}, #{entity.createTime})
+        </foreach>
+        on duplicate key update
+        uid = values(uid),
+        aid = values(aid),
+        admin_name = values(admin_name),
+        contacts = values(contacts),
+        mobile_last_digits = values(mobile_last_digits),
+        status = values(status),
+        duration = values(duration),
+        remarks = values(remarks),
+        create_time = values(create_time)
+    </insert>
+
+    <!--通过主键修改数据-->
+    <update id="update">
+        update call_log
+        <set>
+            <if test="uid != null and uid != ''">
+                uid = #{uid},
+            </if>
+            <if test="aid != null and aid != ''">
+                aid = #{aid},
+            </if>
+            <if test="adminName != null and adminName != ''">
+                admin_name = #{adminName},
+            </if>
+            <if test="contacts != null and contacts != ''">
+                contacts = #{contacts},
+            </if>
+            <if test="mobileLastDigits != null and mobileLastDigits != ''">
+                mobile_last_digits = #{mobileLastDigits},
+            </if>
+            <if test="status != null">
+                status = #{status},
+            </if>
+            <if test="duration != null">
+                duration = #{duration},
+            </if>
+            <if test="remarks != null and remarks != ''">
+                remarks = #{remarks},
+            </if>
+            <if test="createTime != null">
+                create_time = #{createTime},
+            </if>
+        </set>
+        where id = #{id}
+    </update>
+
+    <!--通过主键删除-->
+    <delete id="deleteById">
+        delete
+        from call_log
+        where id = #{id}
+    </delete>
+
+</mapper>
+

+ 6 - 0
src/main/java/com/goafanti/common/mapper/OrganizationContactBookMapper.xml

@@ -497,4 +497,10 @@
         and aid= #{aid}
     </if>
   </select>
+    <select id="selectUserByContact" resultMap="BaseResultMap">
+      select
+          <include refid="Base_Column_List"/>
+      from organization_contact_book
+      where mobile=#{mobile}
+    </select>
 </mapper>

+ 138 - 0
src/main/java/com/goafanti/common/model/CallLog.java

@@ -0,0 +1,138 @@
+package com.goafanti.common.model;
+
+import java.io.Serializable;
+import java.util.Date;
+
+
+/**
+ * 呼叫记录(CallLog)实体类
+ *
+ * @author makejava
+ * @since 2024-11-20 11:17:55
+ */
+public class CallLog implements Serializable {
+    private static final long serialVersionUID = 958322026904994164L;
+    /**
+     * id
+     */
+    private Integer id;
+    /**
+     * 公司编号
+     */
+    private String uid;
+    /**
+     * 通话人编号
+     */
+    private String aid;
+    /**
+     * 通话人名称
+     */
+    private String adminName;
+    /**
+     * 联系人
+     */
+    private String contacts;
+    /**
+     * 联系方式(尾号)
+     */
+    private String mobileLastDigits;
+    /**
+     * 状态 0=正常,1=转移
+     */
+    private Integer status;
+    /**
+     * 时长
+     */
+    private Integer duration;
+    /**
+     * 备注
+     */
+    private String remarks;
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getUid() {
+        return uid;
+    }
+
+    public void setUid(String uid) {
+        this.uid = uid;
+    }
+
+    public String getAid() {
+        return aid;
+    }
+
+    public void setAid(String aid) {
+        this.aid = aid;
+    }
+
+    public String getAdminName() {
+        return adminName;
+    }
+
+    public void setAdminName(String adminName) {
+        this.adminName = adminName;
+    }
+
+    public String getContacts() {
+        return contacts;
+    }
+
+    public void setContacts(String contacts) {
+        this.contacts = contacts;
+    }
+
+    public String getMobileLastDigits() {
+        return mobileLastDigits;
+    }
+
+    public void setMobileLastDigits(String mobileLastDigits) {
+        this.mobileLastDigits = mobileLastDigits;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Integer getDuration() {
+        return duration;
+    }
+
+    public void setDuration(Integer duration) {
+        this.duration = duration;
+    }
+
+    public String getRemarks() {
+        return remarks;
+    }
+
+    public void setRemarks(String remarks) {
+        this.remarks = remarks;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+}
+

+ 43 - 6
src/main/java/com/goafanti/customer/service/impl/UserOutboundServiceImpl.java

@@ -5,22 +5,26 @@ import com.alibaba.fastjson.JSONObject;
 import com.goafanti.common.bo.Error;
 import com.goafanti.common.bo.InputCallCompleter;
 import com.goafanti.common.bo.Result;
-import com.goafanti.common.dao.AdminMapper;
-import com.goafanti.common.dao.OrganizationContactBookMapper;
-import com.goafanti.common.dao.UserArchivesMapper;
-import com.goafanti.common.dao.UserMapper;
+import com.goafanti.common.dao.*;
+import com.goafanti.common.model.Admin;
+import com.goafanti.common.model.CallLog;
+import com.goafanti.common.model.OrganizationContactBook;
 import com.goafanti.common.model.User;
+import com.goafanti.common.utils.DateUtils;
 import com.goafanti.common.utils.HttpUtils;
 import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.mybatis.BaseMybatisDao;
+import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.core.websocket.SystemWebSocketHandler;
 import com.goafanti.customer.bo.InputCallNumber;
 import com.goafanti.customer.service.UserOutboundService;
 import org.apache.shiro.crypto.hash.SimpleHash;
 import org.springframework.stereotype.Service;
+import org.springframework.web.socket.TextMessage;
 
 import javax.annotation.Resource;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 @Service("userOutboundService")
@@ -39,6 +43,8 @@ public class UserOutboundServiceImpl extends BaseMybatisDao<UserArchivesMapper>
     private AdminMapper adminMapper;
     @Resource
     private OrganizationContactBookMapper organizationContactBookMapper;
+    @Resource
+    private CallLogMapper callLogMapper;
 
     @Override
     public Object checkUser(Integer type) {
@@ -130,10 +136,41 @@ public class UserOutboundServiceImpl extends BaseMybatisDao<UserArchivesMapper>
 
     @Override
     public Object callCompleted(InputCallCompleter in) {
+        //{authentication=authenticationBo{customer='C322', timestamp='1732070407', seq='68197723', digest='c310ec894cee31765baa1b4f97426014'},
+        // notify={type=billing, startTime=2024-11-20 10:39:37, ringTime=2024-11-20 10:39:39, answerTime=2024-11-20 10:39:53,
+        // byeTime=2024-11-20 10:40:05, staffNo=1863336, group1=默认班组, group2=, callee=13297312076, caller=15574937814,
+        // keyPress=, taskID=0, taskName=, recordFile=/data/voicerecord/322/20241120/1863336-20241120-103953-13297312076-15574937814.mp3,
+        // service=1, session=1732070377-5753-414072, seq=1085, userData=, result=801, releaseCause=1, timeLength=12, callResult=801,
+        // typeResult=success, callResultMsg=呼叫成功客户挂断, releasePart=0}}
+        String adminId = TokenManager.getAdminId();
+        Admin admin = adminMapper.queryById(adminId);
         Map<String, Object> notify = in.getNotify();
-
+        String  startTime = (String) notify.get("startTime");
+        String callee=(String) notify.get("callee");
+        String caller=(String) notify.get("caller");
+        String typeResult=(String) notify.get("typeResult");
+        String timeLength=(String) notify.get("timeLength");
+        String name=admin.getName();
+        String ContactName=null;
+        String uid=null;
+        List<OrganizationContactBook> books = organizationContactBookMapper.selectUserByContact(callee);
+        if (books!=null){
+            OrganizationContactBook book1 = books.get(0);
+            ContactName=book1.getName();
+            uid=book1.getUid();
+        }
+        CallLog callLog=new CallLog();
+        callLog.setUid(uid);
+        callLog.setAid(adminId);
+        callLog.setAdminName(name);
+        callLog.setContacts(ContactName);
+        callLog.setCreateTime(DateUtils.parseDate(startTime));
+        String substring = callee.substring(callee.length() - 4);
+        callLog.setMobileLastDigits(substring);
+        callLog.setDuration(Integer.parseInt(timeLength));
+        callLogMapper.insert(callLog);
         //需要关闭客户呼叫中
-//        systemWebSocketHandler.sendMessageToUser(TokenManager.getAdminId(), new TextMessage("callCompleted"));
+        systemWebSocketHandler.sendMessageToUser(adminId, new TextMessage("callCompleted"));
         return 1;
     }
 

+ 5 - 5
src/main/resources/props/config_test.properties

@@ -1,5 +1,5 @@
 dev.name=test
-static.host=//static.jishutao.com/1.3.28
+static.host=//uat.jishutao.com/1.3.28
 #Driver
 jdbc.driverClassName=com.mysql.jdbc.Driver
 jdbc.url=jdbc:mysql://127.0.0.1:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
@@ -51,11 +51,11 @@ yxjl_max=100
 amb.maxLvl=6
 
 
-portal.host=//static.jishutao.com/portal/2.0.6
-avatar.host=//static.jishutao.com
+portal.host=//uat.jishutao.com/portal/2.0.6
+avatar.host=//uat.jishutao.com
 
-rd.static.host=//static.jishutao.com/RD/1.0.04
-avatar.upload.host=//static.jishutao.com/upload
+rd.static.host=//uat.jishutao.com/RD/1.0.04
+avatar.upload.host=//uat.jishutao.com/upload
 
 wx.appId=wxff2f5720ed7d7f63
 wx.appSecret=081744369d42405be58fe37f892631f7