Commit ab8133df by 284718418@qq.com

跟进动态统计

parent 2a3f92a3
package cn.timer.api.bean.crm;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.util.Date;
/**
* Title: 客户跟进动态日志表
*
* @Description:
* @author wuqingjun
* @date 2023年7月31日
* @version 1.0
*/
@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "crm_client_log")
@ApiModel("客户跟进动态日志表")
public class CrmClientLog extends Model<CrmClientLog> {
private static final long serialVersionUID = -7362549097557018582L;
@Id
@GeneratedValue
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "编号")
private Integer id;
@ApiModelProperty(value = "客户数据id")
private Integer cid;
@ApiModelProperty(value = "变更前客户数据状态")
private Integer beforeClientStatus;
@ApiModelProperty(value = "变更后客户数据状态")
private Integer afterClientStatus;
@ApiModelProperty(value = "创建人")
private Integer createUser;
@ApiModelProperty(value = "企业id")
private Integer orgCode;
@ApiModelProperty(value = "创建人姓名")
private String createUserName;
@ApiModelProperty(value = "备注")
private String remark;
@TableField(fill = FieldFill.INSERT)
@ApiModelProperty(value = "创建时间")
private Date createTime;
}
......@@ -4,6 +4,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.net.URL;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
......@@ -15,8 +16,7 @@ import cn.timer.api.bean.crm.*;
import cn.timer.api.bean.insure.InsurePolicy;
import cn.timer.api.bean.insure.InsureProductPlan;
import cn.timer.api.controller.zpgl.sevice.ZpglService;
import cn.timer.api.dao.crm.CrmClientFollowMapper;
import cn.timer.api.dao.crm.CrmRemindRuleMapper;
import cn.timer.api.dao.crm.*;
import cn.timer.api.dto.clazz.CityClazzDto;
import cn.timer.api.dto.crm.*;
import cn.timer.api.dto.insure.PolicyDto;
......@@ -24,6 +24,7 @@ import cn.timer.api.dto.yggl.YgCityDto;
import cn.timer.api.utils.ExcelUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.DeleteMapping;
......@@ -59,8 +60,6 @@ import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.config.enums.SysRoleType;
import cn.timer.api.controller.kqgl.ClockInTool;
import cn.timer.api.dao.crm.CrmClientContactsMapper;
import cn.timer.api.dao.crm.CrmClientDataMapper;
import cn.timer.api.dao.qyzx.QyzxEmpEntAssoMapper;
import cn.timer.api.dto.kqmk.DailyDetailsDto;
import cn.timer.api.dto.xcgl.ImportDescriptionDto;
......@@ -103,6 +102,8 @@ public class CrmController {
private CrmRemindRuleMapper crmRemindRuleMapper;
@Autowired
private CrmClientFollowMapper crmClientFollowMapper;
@Autowired
private CrmClientLogMapper crmClientLogMapper;
private Integer getEmpNum(UserBean userBean) {
return userBean.getEmpNum();
......@@ -449,6 +450,14 @@ public class CrmController {
}
crmClientData.setContactsNum(contactsnum);
crmClientData.updateById();
/*** 客户跟进动态日志 ***/
CrmClientLog.builder().cid(crmClientData.getId())
.beforeClientStatus(0).afterClientStatus(crmClientData.getClientStatus())
.createUser(empNum)
.createUserName(userBean.getUserInfo().getName())
.orgCode(orgCode)
.remark("新增客户")
.build().insert();
return ResultUtil.success("新增成功");
}
......@@ -1023,6 +1032,14 @@ public class CrmController {
crmRemindRule.setCreateTime(new Date());
crmRemindRule.insert();
}
/*** 客户跟进动态日志 ***/
CrmClientLog.builder().cid(oldData.getId())
.beforeClientStatus(oldData.getClientStatus()).afterClientStatus(crmClientFollow.getClientStatus())
.createUser(empNum)
.createUserName(userBean.getUserInfo().getName())
.orgCode(orgCode)
.remark("新增跟进记录")
.build().insert();
return ResultUtil.success("新增成功");
}
return ResultUtil.error("新增失败");
......@@ -1070,10 +1087,26 @@ public class CrmController {
if (status != null && status != 5) {
crmClientData.setClientStatus(5);
crmClientData.updateById();
/*** 客户跟进动态日志 ***/
CrmClientLog.builder().cid(crmClientData.getId())
.beforeClientStatus(status).afterClientStatus(crmClientData.getClientStatus())
.createUser(empNum)
.createUserName(userBean.getUserInfo().getName())
.orgCode(userBean.getOrgCode())
.remark("封档成功")
.build().insert();
return ResultUtil.success("封档成功");
} else if (status == 5) {
crmClientData.setClientStatus(1); // 解封后默认潜在状态
crmClientData.updateById();
/*** 客户跟进动态日志 ***/
CrmClientLog.builder().cid(crmClientData.getId())
.beforeClientStatus(status).afterClientStatus(crmClientData.getClientStatus())
.createUser(empNum)
.createUserName(userBean.getUserInfo().getName())
.orgCode(userBean.getOrgCode())
.remark("解封成功")
.build().insert();
return ResultUtil.success("解封成功");
} else
return ResultUtil.error("失败");
......@@ -1105,6 +1138,14 @@ public class CrmController {
if (CrmClientData.builder().id(cid).belongUser(belongUser)
.belongUserName(getEmpName(getOrgCode(userBean), belongUser)).build().updateById())
return ResultUtil.success("指派成功");
/*** 客户跟进动态日志 ***/
CrmClientLog.builder().cid(oldData.getId())
.beforeClientStatus(oldData.getClientStatus()).afterClientStatus(oldData.getClientStatus())
.createUser(empNum)
.createUserName(userBean.getUserInfo().getName())
.orgCode(userBean.getOrgCode())
.remark("指派成功")
.build().insert();
return ResultUtil.error("指派失败");
}
......@@ -1131,8 +1172,17 @@ public class CrmController {
// 删除协作人列表
CrmClientAssociate.builder().build()
.delete(new QueryWrapper<CrmClientAssociate>().lambda().eq(CrmClientAssociate::getCid, cid));
if (oldData.updateById())
if (oldData.updateById()){
/*** 客户跟进动态日志 ***/
CrmClientLog.builder().cid(oldData.getId())
.beforeClientStatus(oldData.getClientStatus()).afterClientStatus(oldData.getClientStatus())
.createUser(empNum)
.createUserName(userBean.getUserInfo().getName())
.orgCode(userBean.getOrgCode())
.remark("释放到公海")
.build().insert();
return ResultUtil.success("释放成功");
}
return ResultUtil.error("释放失败");
}
......@@ -1152,8 +1202,17 @@ public class CrmController {
return ResultUtil.error("不是当前业务组成员");
oldData.setBelongUser(empNum);
oldData.setBelongUserName(getEmpName(orgCode, empNum));
if (oldData.updateById())
if (oldData.updateById()){
/*** 客户跟进动态日志 ***/
CrmClientLog.builder().cid(oldData.getId())
.beforeClientStatus(oldData.getClientStatus()).afterClientStatus(oldData.getClientStatus())
.createUser(empNum)
.createUserName(userBean.getUserInfo().getName())
.orgCode(orgCode)
.remark("接收客户")
.build().insert();
return ResultUtil.success("接收成功");
}
return ResultUtil.error("接收失败");
}
......@@ -1199,6 +1258,14 @@ public class CrmController {
crmClientData.setBelongUser(belonger);
crmClientData.setBelongUserName(getEmpName(getOrgCode(userBean), belonger));
crmClientData.updateById();
/*** 客户跟进动态日志 ***/
CrmClientLog.builder().cid(crmClientData.getId())
.beforeClientStatus(crmClientData.getClientStatus()).afterClientStatus(crmClientData.getClientStatus())
.createUser(userBean.getEmpNum())
.createUserName(userBean.getUserInfo().getName())
.orgCode(userBean.getOrgCode())
.remark("转移客户")
.build().insert();
}
return ResultUtil.success("转移成功");
......@@ -1235,6 +1302,14 @@ public class CrmController {
CrmClientData.builder().id(yid).hidingcustomers(0).build().updateById();
/*** 客户跟进动态日志 ***/
CrmClientLog.builder().cid(crda.getId())
.beforeClientStatus(crda.getClientStatus()).afterClientStatus(crda.getClientStatus())
.createUser(userBean.getEmpNum())
.createUserName(userBean.getUserInfo().getName())
.orgCode(userBean.getOrgCode())
.remark("隐藏客户")
.build().insert();
}
......@@ -1291,7 +1366,7 @@ public class CrmController {
listAll.add(cartogram6);
// 跟进图
listAll.add(cartogram(orgCode, groupId, 7, belonger, startCreateTime, endCreateTime));
// 新增潜在客户数量跟进的客户数量
// 新增潜在客户数量跟进的客户数量8
Calendar calendar= Calendar.getInstance();
SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM");
List<String> list = cn.timer.api.utils.DateUtil.getDayByMonth(dateFormat.format(calendar.getTime()));
......@@ -1306,14 +1381,54 @@ public class CrmController {
if(org.springframework.util.StringUtils.isEmpty(endCreateTime)){
param.setEndTime(list.get(list.size()-1)+" 23:59:59");
}
param.setOrgCode(orgCode);
//
List<CrmClientFollowCountDto> crm = crmClientFollowMapper.selectCrmClientFollowCount(param);
for (String day:list) {
List<CrmClientFollowCountDto> crmList = crmClientFollowMapper.selectCrmClientFollowList(param);
CrmClientFollowListDto source = new CrmClientFollowListDto();
source.setCreateStr(list);
List<CrmClientFollowCountDto> dtos = null;
CrmClientFollowCountParam countParam = null;
CrmClientFollowCountDto countDto = null;
dtos = new ArrayList<>();
for (CrmClientFollowCountDto dto : crmList) {
countDto = new CrmClientFollowCountDto();
BeanUtils.copyProperties(dto,countDto);
List<Integer> count = new ArrayList<>();
countParam = new CrmClientFollowCountParam();
for (String day : list) {
countParam.setStartTime(day);
countParam.setCreateUser(dto.getCreateUser());
count.add(crmClientFollowMapper.selectCountByParam(countParam));
countDto.setCreateTime(day);
}
countDto.setFollowCount(count);
dtos.add(countDto);
}
source.setDtos(dtos);
listAll.add(source);
//跟进动态
List<Map<String, Object>> cartogram9 = new ArrayList<Map<String, Object>>();// 图9
// 统计类型标记
List<ClientTypeClass> typeCount = new ArrayList<>();
typeCount.add(ClientTypeClass.builder().id(1).name("潜在客户转化为意向客户").build());
typeCount.add(ClientTypeClass.builder().id(2).name("意向客户转为合作的客户").build());
for (ClientTypeClass clientTypeClass : typeCount) {
Map<String, Object> map = new HashMap<>();
map.put("level", clientTypeClass.getId());
map.put("name", clientTypeClass.getName());
if(clientTypeClass.getId()==1){
map.put("num", CrmClientLog.builder().build().selectCount(new QueryWrapper<CrmClientLog>().lambda().eq(CrmClientLog::getBeforeClientStatus,1).eq(CrmClientLog::getAfterClientStatus,2)));
}else if(clientTypeClass.getId()==2){
map.put("num", CrmClientLog.builder().build().selectCount(new QueryWrapper<CrmClientLog>().lambda().eq(CrmClientLog::getAfterClientStatus,4)));
}
listAll.add(null);
if ((Integer) map.get("num") > 0) {
cartogram9.add(map);
}
}
listAll.add(cartogram9);
return ResultUtil.data(listAll, "获取成功");
}
......
......@@ -33,6 +33,19 @@ public interface CrmClientFollowMapper extends BaseMapper<CrmClientFollow> {
* @return
*/
List<CrmClientFollowCountDto> selectCrmClientFollowCount(@Param("param") CrmClientFollowCountParam param);
/**
* 根据条件查询 统计跟进数据 需要显示的人数
* @param param
* @return
*/
List<CrmClientFollowCountDto> selectCrmClientFollowList(@Param("param") CrmClientFollowCountParam param);
/**
* 根据条件查询 统计跟进数据
* @param param
* @return
*/
Integer selectCountByParam(@Param("param") CrmClientFollowCountParam param);
}
package cn.timer.api.dao.crm;
import cn.timer.api.bean.crm.CrmClientLog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* Title: 客户跟进动态日志表
*
* @Description:
* @author wuqingjun
* @date 2023年7月31日
* @version 1.0
*/
public interface CrmClientLogMapper extends BaseMapper<CrmClientLog> {
}
......@@ -8,8 +8,10 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.awt.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
*
......@@ -25,7 +27,7 @@ public class CrmClientFollowCountDto implements Serializable {
@ApiModelProperty(value = "跟进数")
private Integer followCount;
private List<Integer> followCount;
@ApiModelProperty(value = "创建人")
private Integer createUser;
......
......@@ -44,4 +44,9 @@ public class CrmClientFollowCountParam implements Serializable {
*/
@ApiModelProperty(value = "当前企业id")
private Integer orgCode;
/**
* 当前用户ID
*/
@ApiModelProperty(value = "当前用户ID")
private Integer createUser;
}
package cn.timer.api.dto.crm;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
/**
*
* @author wuqingjun
* @date 2023年7月28日
* @version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CrmClientFollowListDto implements Serializable {
@ApiModelProperty(value = "时间")
private List<String> createStr;
private List<CrmClientFollowCountDto> dtos;
}
......@@ -23,8 +23,47 @@
</if>
</where>
GROUP BY
create_user_name, DATE(create_time)
createUser, DATE(create_time)
ORDER BY
create_user_name, DATE(create_time);
createUser, DATE(create_time);
</select>
<select id="selectCrmClientFollowList" resultType="cn.timer.api.dto.crm.CrmClientFollowCountDto">
SELECT
create_user_name createUserName,
create_user createUser
FROM
crm_client_follow
<where>
<if test='null != param.startTime and param.startTime !=""'>
AND create_time <![CDATA[>=]]> #{param.startTime}
</if>
<if test='null != param.endTime and param.endTime !=""'>
AND create_time <![CDATA[<=]]> #{param.endTime}
</if>
<if test='null != param.orgCode and param.orgCode !=""'>
AND org_code = #{param.orgCode}
</if>
</where>
GROUP BY
createUser
ORDER BY
createUser
</select>
<select id="selectCountByParam" resultType="int">
SELECT
COUNT(*)
FROM
crm_client_follow
<where>
<if test='null != param.startTime and param.startTime !=""'>
AND DATE(create_time) = #{param.startTime}
</if>
<if test='null != param.createUser and param.createUser !=""'>
AND create_user = #{param.createUser}
</if>
<if test='null != param.orgCode and param.orgCode !=""'>
AND org_code = #{param.orgCode}
</if>
</where>
</select>
</mapper>
\ No newline at end of file
<?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="cn.timer.api.dao.crm.CrmClientLogMapper">
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment