统计导出

master
wjt 10 months ago
parent d681195c43
commit c097f6e9c6

@ -4,6 +4,7 @@ import com.baiye.modules.distribute.qo.HomePageQo;
import com.baiye.modules.distribute.service.HomepageService;
import com.baiye.result.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
@ -31,13 +32,13 @@ public class HomepageController {
@PostMapping("/enter")
@Operation(description = "渠道录入")
@Operation(description = "渠道录入--管理员")
public R<Object> channelEnterClue(@RequestBody HomePageQo homePageQo) {
return R.ok(homepageService.channelEnterClue(homePageQo));
}
@PostMapping("/assigned")
@Operation(description = "渠道分发")
@Operation(description = "渠道分发--管理员")
public R<Object> channelAssignedClue(@RequestBody HomePageQo homePageQo) {
return R.ok(homepageService.channelAssignedClue(homePageQo));
}
@ -47,4 +48,16 @@ public class HomepageController {
public void channelClueExport(HttpServletResponse response, @RequestBody HomePageQo homePageQo) {
homepageService.channelClueExport(response, homePageQo);
}
@PostMapping("/distributors")
@Operation(summary = "分发员")
public R<Object> distributorsEnterClue(@RequestBody HomePageQo homePageQo) {
return R.ok(homepageService.distributorsEnterClue(homePageQo));
}
@PostMapping("/salesman")
@Operation(summary = "业务员")
public R<Object> salesmanEnterClue(@RequestBody HomePageQo homePageQo) {
return R.ok(homepageService.salesmanEnterClue(homePageQo));
}
}

@ -18,4 +18,6 @@ public class HomePageDTO {
private Long createBy;
private String enterName;
private Integer num;
}

@ -14,9 +14,11 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface ClueMapper extends ExtendMapper<ClueEntity> {
@ -76,4 +78,7 @@ public interface ClueMapper extends ExtendMapper<ClueEntity> {
List<HomePageDTO> selectDetailByChannelAndAssigned(@Param("qo") HomePageQo homePageQo);
Integer addCount(@Param("date") String date, @Param("companyId") Long companyId);
List<HomePageDTO> distributorsAssignedClueByTime(@Param("qo") HomePageQo homePageQo);
}

@ -14,9 +14,11 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface CustomMapper extends ExtendMapper<CustomEntity> {
default PageResult<CustomVO> queryPage(PageParam pageParam, CustomQo qo) {
@ -33,12 +35,12 @@ public interface CustomMapper extends ExtendMapper<CustomEntity> {
/**
*
*/
String selectMaxBatchNoByCompanyId(@Param("code") String code,@Param("companyId") Long companyId);
String selectMaxBatchNoByCompanyId(@Param("code") String code, @Param("companyId") Long companyId);
/**
* qo wrapper
*
* @param qo
* @return LambdaQueryWrapperX
*/
@ -66,7 +68,7 @@ public interface CustomMapper extends ExtendMapper<CustomEntity> {
}
default List<CustomEntity> queryList(CustomQo customQo){
default List<CustomEntity> queryList(CustomQo customQo) {
Wrapper<CustomEntity> wrapperX = buildQueryWrapper(customQo);
return this.selectList(wrapperX);
}
@ -75,4 +77,6 @@ public interface CustomMapper extends ExtendMapper<CustomEntity> {
List<HomePageDTO> selectByCompanyIdAndTime(@Param("qo") HomePageQo homePageQo);
List<Integer> addCount(@Param("date") String date, @Param("companyId") Long companyId);
List<HomePageDTO> distributorsEnterClueByTime(@Param("qo") HomePageQo homePageQo);
}

@ -25,6 +25,9 @@ public class HomePageQo {
@Parameter(description = "添加的结束时间")
private String createEndTime;
@Parameter(description = "分配的客户id")
private Long assignedId;
@Parameter(description = "分配的客户id")
private List<Long> assignedIdList;
@ -36,4 +39,8 @@ public class HomePageQo {
@Parameter(description = "下载类型 1- 录入 2-分发")
private Integer type;
@Parameter(description = "分发员id")
private Long distributorId;
}

@ -42,4 +42,19 @@ public interface HomepageService {
*/
Map<String, Map<String, Integer>> channelAssignedClue(HomePageQo homePageQo);
/**
* 线
*
* @param homePageQo
* @return
*/
Object distributorsEnterClue(HomePageQo homePageQo);
/**
*
*
* @param homePageQo
* @return
*/
Object salesmanEnterClue(HomePageQo homePageQo);
}

@ -218,4 +218,47 @@ public class HomepageServiceImpl implements HomepageService {
}
return mapChannelType;
}
@Override
public Object distributorsEnterClue(HomePageQo homePageQo) {
homePageQo.setDistributorId(SecurityUtils.getCurrentUserId());
//分发员进线
List<HomePageDTO> enterList = customMapper.distributorsEnterClueByTime(homePageQo);
Map<String, Integer> enterMap = enterList.stream()
.collect(Collectors.toMap(HomePageDTO::getCreateTime, HomePageDTO::getNum));
//分发员分发数
List<HomePageDTO> assignedList = clueMapper.distributorsAssignedClueByTime(homePageQo);
Map<String, Integer> assignedMap = assignedList.stream()
.collect(Collectors.toMap(HomePageDTO::getCreateTime, HomePageDTO::getNum));
Map<String, Map<String, Integer>> map = new LinkedHashMap<>(8);
long betweenDay = DateUtil.between(DateUtil.parseDate(homePageQo.getCreateStartTime()), DateUtil.parseDate(homePageQo.getCreateEndTime()), DateUnit.DAY);
for (int i = 0; i <= betweenDay; i++) {
Map<String, Integer> mapNum = new LinkedHashMap<>(16);
String time = DateUtil.format(DateUtil.offsetDay(DateUtil.parseDate(homePageQo.getCreateStartTime()), i), "yyyy-MM-dd");
mapNum.put("enter", enterMap.getOrDefault(time, 0));
mapNum.put("assigned", assignedMap.getOrDefault(time, 0));
map.put(time, mapNum);
}
return map;
}
@Override
public Object salesmanEnterClue(HomePageQo homePageQo) {
homePageQo.setAssignedId(SecurityUtils.getCurrentUserId());
//业务员进线数
List<HomePageDTO> assignedList = clueMapper.distributorsAssignedClueByTime(homePageQo);
Map<String, Integer> assignedMap = assignedList.stream()
.collect(Collectors.toMap(HomePageDTO::getCreateTime, HomePageDTO::getNum));
Map<String, Integer> map = new LinkedHashMap<>(8);
long betweenDay = DateUtil.between(DateUtil.parseDate(homePageQo.getCreateStartTime()), DateUtil.parseDate(homePageQo.getCreateEndTime()), DateUnit.DAY);
//返回日期值 如{"2023-12-6":100}
for (int i = 0; i <= betweenDay; i++) {
String time = DateUtil.format(DateUtil.offsetDay(DateUtil.parseDate(homePageQo.getCreateStartTime()), i), "yyyy-MM-dd");
map.put(time, assignedMap.getOrDefault(time, 0));
}
return map;
}
}

@ -77,4 +77,18 @@
tb_clue ce
${ew.customSqlSegment}
</select>
<select id="distributorsAssignedClueByTime" resultType="com.baiye.modules.distribute.dto.HomePageDTO">
select DATE_FORMAT(create_time, '%Y-%m-%d') as createTime, count(1) as num
from tb_clue
where DATE_FORMAT(create_time, '%Y-%m-%d') &gt;= #{qo.createStartTime}
and DATE_FORMAT(create_time, '%Y-%m-%d') &lt;= #{qo.createEndTime}
and channel_type =#{qo.channelType}
<if test="qo.distributorId!=null">
and create_by = #{qo.distributorId}
</if>
<if test="qo.assignedId!=null">
and assigned_by = #{qo.assignedId}
</if>
GROUP BY createTime
</select>
</mapper>

@ -60,6 +60,16 @@
select type
from tb_custom
where DATE_FORMAT(create_time, '%Y-%m-%d') = #{date}
and company_id = #{companyId}
and company_id = #{companyId}
</select>
<select id="distributorsEnterClueByTime" resultType="com.baiye.modules.distribute.dto.HomePageDTO">
select DATE_FORMAT(create_time, '%Y-%m-%d') as createTime, count(1) as num
from tb_custom
where DATE_FORMAT(create_time, '%Y-%m-%d') &gt;= #{qo.createStartTime}
and DATE_FORMAT(create_time, '%Y-%m-%d') &lt;= #{qo.createEndTime}
and distributor_id = #{qo.distributorId}
and channel_type = #{qo.channelType}
GROUP BY createTime
</select>
</mapper>

Loading…
Cancel
Save