跟进日志处理

This commit is contained in:
zhangchenbiao
2023-08-15 16:32:35 +08:00
parent 6fa6b3cf8d
commit 6bdc773aa5
10 changed files with 179 additions and 4 deletions

View File

@@ -43,6 +43,18 @@ public class HyFollowTaskDAO {
return hyFollowTaskMapper.getFollowTask(followTaskId);
}
/**
* 批量获取根据任务
* @param followTaskIds
* @return
*/
public List<HyFollowTaskDO> getFollowTaskList(List<Long> followTaskIds){
if(Objects.isNull(followTaskIds)){
return null;
}
return hyFollowTaskMapper.getFollowTaskList(followTaskIds);
}
/**
* 新增跟进任务

View File

@@ -5,10 +5,14 @@ import com.cool.store.dto.log.LineLogInfo;
import com.cool.store.entity.HyPartnerTaskInfoLogDO;
import com.cool.store.enums.OperateTypeEnum;
import com.cool.store.mapper.HyPartnerTaskInfoLogMapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
@@ -53,4 +57,16 @@ public class HyPartnerTaskInfoLogDAO {
return hyPartnerTaskInfoLogMapper.updateLineId(newPartnerId,newLineId, oldLineId);
}
public Page<HyPartnerTaskInfoLogDO> getFollowTaskLogPage(Integer pageNum, Integer pageSize, Long partnerLineId){
if(Objects.isNull(partnerLineId)){
return new Page<>();
}
PageHelper.startPage(pageNum, pageSize);
List<String> operateTypes = new ArrayList<>();
operateTypes.add(OperateTypeEnum.ADD_FOLLOW_TASK.getCode());
operateTypes.add(OperateTypeEnum.ADD_FOLLOW_LOG.getCode());
operateTypes.add(OperateTypeEnum.ADD_TAGS.getCode());
return hyPartnerTaskInfoLogMapper.getLogPageByLineId(partnerLineId, operateTypes);
}
}

View File

@@ -93,4 +93,11 @@ public interface HyFollowTaskMapper {
* @return
*/
Integer updateUndoTaskStatusToOverdue();
/**
* 批量获取跟进任务
* @param followTaskIds
* @return
*/
List<HyFollowTaskDO> getFollowTaskList(@Param("followTaskIds") List<Long> followTaskIds);
}

View File

@@ -1,6 +1,7 @@
package com.cool.store.mapper;
import com.cool.store.entity.HyPartnerTaskInfoLogDO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -29,4 +30,13 @@ public interface HyPartnerTaskInfoLogMapper {
int updateLineId(@Param("newPartnerId") String newPartnerId, @Param("newLineId") Long newLineId, @Param("oldLineId") Long oldLineId);
/**
* 跟进线索id以及操作类型分页获取日志
* @param partnerLineId
* @param operateTypes
* @return
*/
Page<HyPartnerTaskInfoLogDO> getLogPageByLineId(@Param("partnerLineId")Long partnerLineId, @Param("operateTypes")List<String> operateTypes);
}

View File

@@ -199,5 +199,14 @@
<update id="updateUndoTaskStatusToOverdue">
<![CDATA[ update hy_follow_task set task_status = '2' where task_status = '0' and deadline < now() ]]]>
</update>
<select id="getFollowTaskList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
hy_follow_task
where
deleted = '0' and id in <foreach collection="followTaskIds" item="followTaskId" separator="," open="(" close=")">#{followTaskId}</foreach>
</select>
</mapper>

View File

@@ -18,7 +18,7 @@
<result column="field_copy" jdbcType="LONGVARCHAR" property="fieldCopy"/>
</resultMap>
<sql id="Base_Column_List">
id, partner_line_id, operate_user_id, operate_username, workflow_stage, workflow_status,
id, partner_line_id, operate_user_id, operate_username, operate_type, workflow_stage, workflow_status,
message, create_time, update_time, partner_id
</sql>
<sql id="Blob_Column_List">
@@ -148,5 +148,16 @@
set partner_line_id = #{newLineId} , partner_id = #{newPartnerId}
where partner_line_id = #{oldLineId}
</update>
<select id="getLogPageByLineId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>,
<include refid="Blob_Column_List"/>
from
hy_partner_task_info_log
where
partner_line_id= #{partnerLineId} and operate_type in <foreach collection="operateTypes" open="(" close=")" separator="," item="operateType">#{operateType}</foreach>
order by create_time desc
</select>
</mapper>

View File

@@ -18,7 +18,8 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
@AllArgsConstructor
public class HyFollowTaskDO implements Serializable {
@ApiModelProperty("")
@ApiModelProperty("跟进任务id")
private Long id;
@ApiModelProperty("hy_partner_line_info.id")

View File

@@ -1,9 +1,24 @@
package com.cool.store.vo.follow;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.dto.log.LogFieldDTO;
import com.cool.store.entity.HyFollowTaskDO;
import com.cool.store.entity.HyPartnerTaskInfoLogDO;
import com.cool.store.enums.OperateLogFieldValueEnum;
import com.cool.store.enums.OperateTypeEnum;
import com.cool.store.vo.log.LogFieldVO;
import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author zhangchenbiao
@@ -33,6 +48,33 @@ public class FollowTaskLogVO {
private String operateType;
@ApiModelProperty("操作内容")
private String operateContent;
private List<LogFieldVO> operateContent;
public static List<FollowTaskLogVO> convertVO(List<HyPartnerTaskInfoLogDO> list, List<HyFollowTaskDO> followTaskList){
if(CollectionUtils.isEmpty(list)){
return Lists.newArrayList();
}
Map<Long, HyFollowTaskDO> taskMap = ListUtils.emptyIfNull(followTaskList).stream().collect(Collectors.toMap(k -> k.getId(), Function.identity(), (k1, k2) -> k1));
List<FollowTaskLogVO> resultList = new ArrayList<>();
for (HyPartnerTaskInfoLogDO log : list) {
FollowTaskLogVO result = new FollowTaskLogVO();
result.setFollowLogId(log.getId());
result.setPartnerLineId(log.getPartnerLineId());
result.setOperateTime(log.getCreateTime());
result.setOperateUserId(log.getOperateUserId());
result.setOperateUsername(log.getOperateUsername());
result.setOperateType(log.getOperateType());
List<LogFieldVO> logFieldList = JSONObject.parseArray(log.getFieldCopy(), LogFieldVO.class);
if(OperateTypeEnum.ADD_FOLLOW_TASK.getCode().equals(log.getOperateType())){
Long taskId = Long.valueOf(logFieldList.stream().filter(o -> OperateLogFieldValueEnum.FOLLOW_TASK_ID.getCode().equals(o.getCode())).map(LogFieldVO::getValue).findFirst().get().toString());
HyFollowTaskDO hyFollowTask = taskMap.get(taskId);
logFieldList.addAll(LogFieldVO.convertLogField(hyFollowTask));
}
result.setOperateContent(logFieldList);
resultList.add(result);
}
return resultList;
}
}

View File

@@ -0,0 +1,48 @@
package com.cool.store.vo.log;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* @Author: young.yu
* @Date: 2023-06-28 15:32
* @Description:
*/
@Data
public class LogFieldVO {
@ApiModelProperty("字段名称")
private String code;
@ApiModelProperty("字段定义")
private String name;
@ApiModelProperty("字段值")
private Object value;
public static List<LogFieldVO> convertLogField(Object object){
Field[] declaredFields = object.getClass().getDeclaredFields();
List<LogFieldVO> resultList = new ArrayList<>();
for (Field declaredField : declaredFields) {
try {
declaredField.setAccessible(true);
LogFieldVO field = new LogFieldVO();
ApiModelProperty annotation = declaredField.getAnnotation(ApiModelProperty.class);
if(Objects.nonNull(annotation)){
field.setName(annotation.value());
}
field.setCode(declaredField.getName());
field.setValue(declaredField.get(object));
resultList.add(field);
} catch (IllegalAccessException e) {
continue;
}
}
return resultList;
}
}

View File

@@ -10,10 +10,12 @@ import com.cool.store.dao.HyPartnerLineInfoDAO;
import com.cool.store.dao.HyPartnerTaskInfoLogDAO;
import com.cool.store.dto.follow.FollowTaskNumDTO;
import com.cool.store.dto.log.LineLogInfo;
import com.cool.store.dto.log.LogFieldDTO;
import com.cool.store.dto.message.SendCardMessageDTO;
import com.cool.store.dto.partner.PartnerSimpleInfoDTO;
import com.cool.store.entity.HyFollowTaskDO;
import com.cool.store.entity.HyPartnerLineInfoDO;
import com.cool.store.entity.HyPartnerTaskInfoLogDO;
import com.cool.store.enums.*;
import com.cool.store.exception.ApiException;
import com.cool.store.exception.ServiceException;
@@ -87,7 +89,24 @@ public class FollowTaskServiceImpl implements FollowTaskService {
@Override
public PageInfo<FollowTaskLogVO> getFollowLogPage(Integer pageNum, Integer pageSize, Long partnerLineId) {
return null;
Page<HyPartnerTaskInfoLogDO> logPage = hyPartnerTaskInfoLogDAO.getFollowTaskLogPage(pageNum, pageSize, partnerLineId);
List<FollowTaskLogVO> resultList = new ArrayList<>();
if(CollectionUtils.isNotEmpty(logPage)){
List<Long> taskIds = logPage.stream().filter(o->OperateTypeEnum.ADD_FOLLOW_TASK.getCode().equals(o.getOperateType())).map(o->{
List<LogFieldDTO> logField = JSONObject.parseArray(o.getFieldCopy(), LogFieldDTO.class);
String value = logField.stream().filter(f -> f.getCode().equals(OperateLogFieldValueEnum.FOLLOW_TASK_ID.getCode())).findFirst().get().getValue();
return Long.valueOf(value);
}).collect(Collectors.toList());
List<HyFollowTaskDO> followTaskList = hyFollowTaskDAO.getFollowTaskList(taskIds);
List<String> callIds = logPage.stream().filter(o->OperateTypeEnum.ADD_FOLLOW_TASK.getCode().equals(o.getOperateType())).map(o->{
List<LogFieldDTO> logField = JSONObject.parseArray(o.getFieldCopy(), LogFieldDTO.class);
return logField.stream().filter(f -> f.getCode().equals(OperateLogFieldValueEnum.FOLLOW_TASK_ID.getCode())).findFirst().get().getValue();
}).collect(Collectors.toList());
resultList = FollowTaskLogVO.convertVO(logPage, followTaskList);
}
PageInfo resultPage = new PageInfo(logPage);
resultPage.setList(resultList);
return resultPage;
}
@Override