Просмотр исходного кода

Merge branch 'test2' of jishutao/kede-server into prod

anderx 1 год назад
Родитель
Сommit
e8da832f95

+ 59 - 0
src/main/java/com/goafanti/admin/bo/CallDaysSumBo.java

@@ -0,0 +1,59 @@
+package com.goafanti.admin.bo;
+
+public class CallDaysSumBo {
+    private String aid;
+    private String dates;
+    private Integer callDurationSum;
+    private Integer callSum;
+    private Integer connectSum;
+    private Integer validSum;
+
+
+    public String getAid() {
+        return aid;
+    }
+
+    public void setAid(String aid) {
+        this.aid = aid;
+    }
+
+    public String getDates() {
+        return dates;
+    }
+
+    public void setDates(String dates) {
+        this.dates = dates;
+    }
+
+    public Integer getCallDurationSum() {
+        return callDurationSum;
+    }
+
+    public void setCallDurationSum(Integer callDurationSum) {
+        this.callDurationSum = callDurationSum;
+    }
+
+    public Integer getCallSum() {
+        return callSum;
+    }
+
+    public void setCallSum(Integer callSum) {
+        this.callSum = callSum;
+    }
+
+    public Integer getConnectSum() {
+        return connectSum;
+    }
+
+    public void setConnectSum(Integer connectSum) {
+        this.connectSum = connectSum;
+    }
+
+    public Integer getValidSum() {
+        return validSum;
+    }
+
+    public void setValidSum(Integer validSum) {
+        this.validSum = validSum;
+    }
+}

+ 7 - 0
src/main/java/com/goafanti/admin/service/impl/NewAdminServiceImpl.java

@@ -35,6 +35,8 @@ public class NewAdminServiceImpl extends BaseMybatisDao<AdminMapper> implements
 	private AsyncUtils asyncUtils;
 	@Resource
 	private AdminPublicReviewerMapper adminPublicReviewerMapper;
+	@Resource
+	private AdminCallDayMapper adminCallDayMapper;
 
 	@Override
 	public Pagination<AdminListBo> listAdmin(AdminListBo alb, String rid,String roleName,Integer pageNo, Integer pageSize) {
@@ -128,6 +130,11 @@ public class NewAdminServiceImpl extends BaseMybatisDao<AdminMapper> implements
 		if(publicReviewerIds!=null)updatePublicReviewer(ad.getId(),publicReviewerIds,0);
 		if(assistReviewerIds!=null)updatePublicReviewer(ad.getId(),assistReviewerIds,1);
 		pushAmbRole(ad);
+		//统计团队更换每天统计表
+		if (useAdmin.getTeamId()!=null&&!useAdmin.getTeamId().equals(ad.getTeamId())){
+			adminCallDayMapper.updateTeamId(ad.getId(),ad.getTeamId());
+		}
+
 		if (count>0&&ad.getAmbId()!=null){
 			//进行巴人数计算
 //			AmbSystem ambSystem = ambSystemMapper.selectByPrimaryKey(Long.valueOf(ad.getAmbId()));

+ 10 - 0
src/main/java/com/goafanti/common/controller/PublicController.java

@@ -991,6 +991,16 @@ public class PublicController extends CertifyApiController {
 		return new Result<>().data(userOutboundService.pushCallCompleted(in));
 	}
 
+	/**
+	 * 外呼数据统计处理
+	 *
+	 */
+	@PostMapping("/pullAllCall")
+	@ResponseBody
+	public Result pullAllCall() {
+		return new Result<>().data(userOutboundService.pushAllCall());
+	}
+
 
 //	/**
 //	 * OCR识别

+ 3 - 0
src/main/java/com/goafanti/common/dao/AdminCallDayMapper.java

@@ -91,5 +91,8 @@ public interface AdminCallDayMapper {
 
 
     AdminStatisticsBo selectByAidCount(@Param("aid") String aid, @Param("startTime") String startTime, @Param("endTime") String endTime);
+
+
+    void updateTeamId(@Param("id") String id, @Param("teamId") Integer teamId);
 }
 

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

@@ -1,6 +1,7 @@
 package com.goafanti.common.dao;
 
 import com.goafanti.admin.bo.AdminStatisticsBo;
+import com.goafanti.admin.bo.CallDaysSumBo;
 import com.goafanti.common.model.CallLog;
 import org.apache.ibatis.annotations.Param;
 
@@ -84,5 +85,7 @@ public interface CallLogMapper {
 
 
     AdminStatisticsBo selectAdminCallSum(@Param("aid") String aid, @Param("startTime") String startTime, @Param("endTime") String endTime);
+
+    List<CallDaysSumBo> selectAllCount();
 }
 

+ 7 - 0
src/main/java/com/goafanti/common/mapper/AdminCallDayMapper.xml

@@ -212,6 +212,7 @@
         set a.call_sum=b.callSum,a.connect_sum=b.connectSum,a.valid_sum=b.validSum,a.call_duration_sum=b.callDurationSum
         where a.aid=b.aid and a.day_date=b.dates
     </update>
+
     <select id="selectByAidCount" resultType="com.goafanti.admin.bo.AdminStatisticsBo">
         select  aid,sum(call_sum) callSum,
                 sum(connect_sum)connectSum,sum(valid_sum)validSum,sum(call_duration_sum) callDurationSum
@@ -220,6 +221,12 @@
           and day_date BETWEEN #{startTime} and  #{endTime}
         group by aid
     </select>
+    <update id="updateTeamId">
+        update admin_call_day a,sales_team b
+        set a.team_id=b.id,a.team_name=b.name
+        where a.aid= #{id} and b.id = #{teamId}
+
+    </update>
 
 </mapper>
 

+ 1 - 0
src/main/java/com/goafanti/common/mapper/AdminMapper.xml

@@ -35,6 +35,7 @@
         <result property="expenseSuperExamine" column="expense_super_examine" jdbcType="INTEGER"/>
         <result property="publicCarbonCopy" column="public_carbon_copy" jdbcType="VARCHAR"/>
         <result property="callNo" column="call_no" jdbcType="VARCHAR"/>
+        <result property="teamId" column="team_id" jdbcType="INTEGER"/>
     </resultMap>
 
     <sql id="AdminAllSql">

+ 43 - 10
src/main/java/com/goafanti/common/mapper/CallLogMapper.xml

@@ -13,10 +13,12 @@
         <result property="duration" column="duration" jdbcType="INTEGER"/>
         <result property="remarks" column="remarks" jdbcType="VARCHAR"/>
         <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+        <result property="mobile" column="mobile" jdbcType="VARCHAR"/>
+        <result property="callNo" column="call_no" jdbcType="VARCHAR"/>
     </resultMap>
 
     <sql id="CallLogAllSql">
-        id, uid, aid, admin_name, contacts, mobile_last_digits, status, duration, remarks, create_time
+        id, uid, aid, admin_name, contacts, mobile_last_digits, status, duration, remarks, create_time, mobile, call_no
     </sql>
 
     <!--查询单个-->
@@ -64,6 +66,12 @@
             <if test="createTime != null">
                 and create_time = #{createTime}
             </if>
+            <if test="mobile != null and mobile != ''">
+                and mobile = #{mobile}
+            </if>
+            <if test="callNo != null and callNo != ''">
+                and call_no = #{callNo}
+            </if>
         </where>
         <if test="page_sql != null">
             ${page_sql}
@@ -105,32 +113,42 @@
             <if test="createTime != null">
                 and create_time = #{createTime}
             </if>
+            <if test="mobile != null and mobile != ''">
+                and mobile = #{mobile}
+            </if>
+            <if test="callNo != null and callNo != ''">
+                and call_no = #{callNo}
+            </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)
+        insert into call_log(uid, aid, admin_name, contacts, mobile_last_digits, status, duration, remarks, create_time,
+                             mobile, call_no)
         values (#{uid}, #{aid}, #{adminName}, #{contacts}, #{mobileLastDigits}, #{status}, #{duration}, #{remarks},
-                #{createTime})
+                #{createTime}, #{mobile}, #{callNo})
     </insert>
 
     <insert id="insertBatch">
-        insert into call_log(uid, aid, admin_name, contacts, mobile_last_digits, status, duration, remarks, create_time)
+        insert into call_log(uid, aid, admin_name, contacts, mobile_last_digits, status, duration, remarks, create_time,
+        mobile, call_no)
         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})
+            #{entity.status}, #{entity.duration}, #{entity.remarks}, #{entity.createTime}, #{entity.mobile},
+            #{entity.callNo})
         </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)
+        insert into call_log(uid, aid, admin_name, contacts, mobile_last_digits, status, duration, remarks, create_time,
+        mobile, call_no)
         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})
+            #{entity.status}, #{entity.duration}, #{entity.remarks}, #{entity.createTime}, #{entity.mobile},
+            #{entity.callNo})
         </foreach>
         on duplicate key update
         uid = values(uid),
@@ -141,10 +159,11 @@
         status = values(status),
         duration = values(duration),
         remarks = values(remarks),
-        create_time = values(create_time)
+        create_time = values(create_time),
+        mobile = values(mobile),
+        call_no = values(call_no)
     </insert>
 
-
     <!--通过主键修改数据-->
     <update id="update">
         update call_log
@@ -176,6 +195,12 @@
             <if test="createTime != null">
                 create_time = #{createTime},
             </if>
+            <if test="mobile != null and mobile != ''">
+                mobile = #{mobile},
+            </if>
+            <if test="callNo != null and callNo != ''">
+                call_no = #{callNo},
+            </if>
         </set>
         where id = #{id}
     </update>
@@ -209,6 +234,14 @@
         </where>
         )x group by x.aid
     </select>
+    <select id="selectAllCount" resultType="com.goafanti.admin.bo.CallDaysSumBo">
+        SELECT x.aid,x.dates,sum(x.duration) callDurationSum,sum(x.counts) callSum,
+        sum(x.connectSum)connectSum,sum(x.validSum)validSum
+        from (SELECT b.aid,b.duration ,1 counts,if(b.duration>0 and b.duration &lt; 5,1,0)connectSum,
+        if(b.duration>=5,1,0)validSum,DATE_FORMAT(b.create_time,'%Y-%m-%d') dates
+        from  call_log b)x
+        group by x.aid,x.dates
+    </select>
 
 
 </mapper>

+ 26 - 2
src/main/java/com/goafanti/common/model/CallLog.java

@@ -10,10 +10,10 @@ import java.util.Date;
  * 呼叫记录(CallLog)实体类
  *
  * @author makejava
- * @since 2024-11-20 11:17:55
+ * @since 2024-12-19 11:28:39
  */
 public class CallLog implements Serializable {
-    private static final long serialVersionUID = 958322026904994164L;
+    private static final long serialVersionUID = 302427662635054975L;
     /**
      * id
      */
@@ -54,6 +54,14 @@ public class CallLog implements Serializable {
      * 创建时间
      */
     private Date createTime;
+    /**
+     * 联系方式(尾号)
+     */
+    private String mobile;
+    /**
+     * 外呼坐席号
+     */
+    private String callNo;
 
 
     public Integer getId() {
@@ -137,5 +145,21 @@ public class CallLog implements Serializable {
         this.createTime = createTime;
     }
 
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public String getCallNo() {
+        return callNo;
+    }
+
+    public void setCallNo(String callNo) {
+        this.callNo = callNo;
+    }
+
 }
 

+ 2 - 0
src/main/java/com/goafanti/customer/service/UserOutboundService.java

@@ -20,4 +20,6 @@ public interface UserOutboundService {
 
     Object userCallList(InputUserCallList in);
 
+
+    Object pushAllCall();
 }

+ 50 - 13
src/main/java/com/goafanti/customer/service/impl/UserClueServiceImpl.java

@@ -76,9 +76,13 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
         }
         return page;
     }
-
     @Override
     public Object add(InputUserClueBo in) throws BusinessException{
+        Admin admin = adminMapper.queryById(TokenManager.getAdminId());
+        return add(in,admin);
+    }
+
+    public Object add(InputUserClueBo in,Admin admin) throws BusinessException{
         User user = new User();
         Date now = new Date();
         String aid= TokenManager.getAdminId();
@@ -90,7 +94,7 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
         user.setNickname(in.getUserName());
         user.setUsername(in.getUserName());
         user.setStatus(AFTConstants.USER_STATUS_NORMAL);
-        user.setShareType(1);
+        user.setShareType(5);
         user.setAid(TokenManager.getAdminId());
         user.setClueAid(TokenManager.getAdminId());
 //		user.setAid("1");
@@ -113,7 +117,6 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
         user.setClueTime(now);
         user.setClueTransferTime(now);
         passwordUtil.encryptPassword(user);
-        String aname = adminMapper.queryById(TokenManager.getAdminId()).getName();
         UserMid um=new UserMid();
         um.setAid(user.getAid());
         um.setUid(uid);
@@ -137,7 +140,7 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
         un.setName(user.getNickname());
         userNamesMapper.insertSelective(un);
         // 新增企业联系人
-        iterContactBook(in,aname,uid);
+        iterContactBook(in,admin.getName(),uid);
         addUserTransferLog(user,22,null);
         return 1;
     }
@@ -151,6 +154,7 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
         cob.setName(in.getContacts());
         cob.setMobile(in.getContactMobile());
         cob.setMajor(AFTConstants.YES);
+        organizationContactBookMapper.updateSubContact(uid);
         organizationContactBookMapper.insert(cob);
         if (StringUtils.isNotBlank(in.getContactMobileMore())){
             String[] split = null;
@@ -183,20 +187,27 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
             try {
                 checkMobile(e.getContactMobile());
                 checkContacts(e.getContacts());
-                //判定客户名称
-                checkUserName(e.getNickname());
+                
             }catch (BusinessException ex){
                 size++;
                 msg.append("<br/>客户[").append(e.getNickname()).append("]导入失败,原因:").append(ex.getMessage()).append(" ");
                 continue;
             }
+            //判定客户名称
+            User user = checkUserName(e.getNickname());
+
             InputUserClueBo inUserClueBo = new InputUserClueBo();
             inUserClueBo.setUserName(e.getNickname());
             inUserClueBo.setContactMobile(e.getContactMobile());
             inUserClueBo.setContacts(e.getContacts());
             inUserClueBo.setContactMobileMore(e.getContactMobileMore());
             try {
-                add(inUserClueBo);
+                Admin admin = adminMapper.queryById(TokenManager.getAdminId());
+                if (user==null){
+                    add(inUserClueBo,admin);
+                }else {
+                    update(inUserClueBo,admin,user);
+                }
             }catch (Exception ex){
                 size++;
                 msg.append("<br/>客户[").append(e.getNickname()).append("]新增异常。 ");
@@ -212,6 +223,19 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
         return map;
     }
 
+    private void update(InputUserClueBo inUserClueBo,Admin admin,User user) {
+        Date now = new Date();
+        User newUser =new User();
+        newUser.setId(user.getId());
+        newUser.setClueProcess(0);
+        newUser.setClueStatus(1);
+        newUser.setClueTime(now);
+        newUser.setClueTransferTime(now);
+        userMapper.update(newUser);
+        // 新增企业联系人
+        iterContactBook(inUserClueBo,admin.getName(),user.getId());
+    }
+
     private void checkContacts(String contacts) throws BusinessException {
         String nameReg="[\\u4e00-\\u9fa5]+.*";
         Pattern  pattern =Pattern.compile(nameReg);
@@ -307,18 +331,31 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
     }
 
 
-    private void checkUserName(String name) throws BusinessException{
-        if (!userMapper.checkUser("", name, "", 1, null, null).isEmpty())
-            throw new BusinessException("客户已经存在");
+    private User checkUserName(String name) throws BusinessException{
+//        if (!userMapper.checkUser("", name, "", 1, null, null).isEmpty())
+//            throw new BusinessException("客户已经存在");
         String name2=null;
         if (name.contains("(")){
             name2=name.replace("(","(").replace(")",")");
         }else if (name.contains("(")){
             name2=name.replace("(","(").replace(")",")");
         }
-        if (name2!=null){
-            if (!userMapper.checkUser("", name2, "", 1, null, null).isEmpty())
-                throw new BusinessException("客户已经存在");
+//        if (name2!=null){
+//            if (!userMapper.checkUser("", name2, "", 1, null, null).isEmpty())
+//                throw new BusinessException("客户已经存在");
+//        }
+        User user = userMapper.selectByName(name);
+        if (user==null){
+            user = userMapper.selectByName(name2);
+        }
+        if (user!=null){
+            if (user.getShareType()==0){
+                throw new BusinessException("客户已经存在私有");
+            }else if (user.getShareType()==2){
+                throw new BusinessException("客户已经存在签单");
+            }
+            return user;
         }
+        return null;
     }
 }

+ 47 - 0
src/main/java/com/goafanti/customer/service/impl/UserOutboundServiceImpl.java

@@ -2,6 +2,7 @@ package com.goafanti.customer.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.goafanti.admin.bo.CallDaysSumBo;
 import com.goafanti.common.bo.Error;
 import com.goafanti.common.bo.InputCallCompleter;
 import com.goafanti.common.bo.Result;
@@ -25,6 +26,7 @@ import org.springframework.web.socket.TextMessage;
 
 import javax.annotation.Resource;
 import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -57,6 +59,8 @@ public class UserOutboundServiceImpl extends BaseMybatisDao<CallLogMapper> imple
     private CallLogMapper callLogMapper;
     @Resource
     private AdminCallDayMapper adminCallDayMapper;
+    @Resource
+    private SalesTeamMapper salesTeamMapper;
 
     @Override
     public Object checkUser(Integer type) {
@@ -197,6 +201,8 @@ public class UserOutboundServiceImpl extends BaseMybatisDao<CallLogMapper> imple
         callLog.setAdminName(name);
         callLog.setContacts(ContactName);
         callLog.setCreateTime(DateUtils.parseDate(startTime));
+        callLog.setMobile(callee);
+        callLog.setCallNo(staffNo);
         String substring = callee.substring(callee.length() - 4);
         callLog.setMobileLastDigits(substring);
         callLog.setDuration(Integer.parseInt(timeLength));
@@ -285,10 +291,51 @@ public class UserOutboundServiceImpl extends BaseMybatisDao<CallLogMapper> imple
             sumMap.put("name",user.getNickname());
         }
         Map<String,Object> res = new HashMap();
+        List<CallLog> list = (List<CallLog>) page.getList();
+        for (CallLog e : list) {
+            e.setCallNo(null);
+            e.setMobile(null);
+        }
         res.put("page",page);
         res.put("sum",sumMap);
         return res;
     }
 
+    @Override
+    public Object pushAllCall() {
+        List<CallDaysSumBo> callDaysSumBos = callLogMapper.selectAllCount();
+        DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE;
+        for (CallDaysSumBo e : callDaysSumBos) {
+            Admin admin = adminMapper.queryById(e.getAid());
+
+            AdminCallDay adminCallDay = new AdminCallDay();
+            adminCallDay.setAid(e.getAid());
+            adminCallDay.setName(admin.getName());
+            adminCallDay.setTeamId(admin.getTeamId());
+            if (admin.getTeamId()!=null){
+                SalesTeam salesTeam = salesTeamMapper.queryById(admin.getTeamId());
+                adminCallDay.setTeamName(salesTeam.getName());
+            }
+            adminCallDay.setCallSum(e.getCallSum());
+            adminCallDay.setDayDate(DateUtils.parseDate(e.getDates()));
+            adminCallDay.setCallDurationSum(e.getCallDurationSum());
+            adminCallDay.setValidSum(e.getValidSum());
+            adminCallDay.setConnectSum(e.getConnectSum());
+            LocalDate parse = LocalDate.parse(e.getDates(), formatter);
+            AdminCallDay adminCallDay1 = adminCallDayMapper.selectByAidAndDay(e.getAid(), parse);
+            if (adminCallDay1==null){
+                adminCallDayMapper.insert(adminCallDay);
+            }else {
+                adminCallDay.setId(adminCallDay1.getId());
+                adminCallDayMapper.update(adminCallDay);
+            }
+
+        }
+
+        return 1;
+    }
+
+
+
 
 }