diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/customer/domain/Customer.java b/ruoyi-service/src/main/java/com/ruoyi/bst/customer/domain/Customer.java index 286e93a..f24fd78 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/customer/domain/Customer.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/customer/domain/Customer.java @@ -43,13 +43,11 @@ public class Customer extends BaseEntity @Excel(name = "状态", readConverterExp = "1=潜在,2=意向,3=成交,4=失效") @ApiModelProperty("状态") - @NotBlank(message = "状态不能为空", groups = {ValidGroup.Create.class}) @DictValid(type = DictType.CUSTOMER_STATUS, message = "非法的状态值") private String status; @Excel(name = "意向强度", readConverterExp = "1=高,2=中,3=低") @ApiModelProperty("意向强度") - @NotBlank(message = "意向强度不能为空", groups = {ValidGroup.Create.class}) @DictValid(type = DictType.CUSTOMER_INTENT_LEVEL, message = "非法的意向强度值") private String intentLevel; diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/customer/domain/CustomerQuery.java b/ruoyi-service/src/main/java/com/ruoyi/bst/customer/domain/CustomerQuery.java index 5716064..4bad6e9 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/customer/domain/CustomerQuery.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/customer/domain/CustomerQuery.java @@ -39,6 +39,14 @@ public class CustomerQuery extends CustomerVO{ @DateTimeFormat(pattern = "yyyy-MM-dd") private LocalDate nextFollowDate; + @ApiModelProperty("下次跟进日期开始") + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate nextFollowDateStart; + + @ApiModelProperty("下次跟进日期结束") + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate nextFollowDateEnd; + @ApiModelProperty("创建日期范围") @DateTimeFormat(pattern = "yyyy-MM-dd") private List createDateRange; @@ -50,4 +58,7 @@ public class CustomerQuery extends CustomerVO{ @ApiModelProperty("下次跟进时间结束") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime nextFollowTimeEnd; + + @ApiModelProperty("客户状态列表") + private List statusList; } diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/customer/domain/dto/CustomerAddDTO.java b/ruoyi-service/src/main/java/com/ruoyi/bst/customer/domain/dto/CustomerAddDTO.java index 735a842..3505725 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/customer/domain/dto/CustomerAddDTO.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/customer/domain/dto/CustomerAddDTO.java @@ -12,7 +12,7 @@ import lombok.Data; @Data public class CustomerAddDTO extends Customer { - + @ApiModelProperty("跟进记录") @Valid @NotNull(message = "跟进记录不能为空", groups = {ValidGroup.Create.class}) diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/customer/domain/enums/CustomerStatus.java b/ruoyi-service/src/main/java/com/ruoyi/bst/customer/domain/enums/CustomerStatus.java index d5021e7..ee875b6 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/customer/domain/enums/CustomerStatus.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/customer/domain/enums/CustomerStatus.java @@ -1,5 +1,9 @@ package com.ruoyi.bst.customer.domain.enums; +import java.util.List; + +import com.ruoyi.common.utils.collection.CollectionUtils; + import lombok.AllArgsConstructor; import lombok.Getter; @@ -15,4 +19,12 @@ public enum CustomerStatus { private final String status; private final String name; + /** + * 跟进中的客户状态 + * @return + */ + public static List following() { + return CollectionUtils.map(CustomerStatus::getStatus, POTENTIAL, INTENTION, TRANSACTION); + } + } diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/customer/mapper/CustomerMapper.xml b/ruoyi-service/src/main/java/com/ruoyi/bst/customer/mapper/CustomerMapper.xml index 4b08260..42b1171 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/customer/mapper/CustomerMapper.xml +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/customer/mapper/CustomerMapper.xml @@ -32,6 +32,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bc.demand, suf.nick_name as follow_name, su.nick_name as create_name + + + + from bst_customer bc left join sys_user suf on suf.user_id = bc.follow_id left join sys_user su on su.user_id = bc.create_id @@ -65,6 +69,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and date(bc.next_follow_time) = #{query.nextFollowDate} and bc.next_follow_time >= #{query.nextFollowTimeStart} and bc.next_follow_time <= #{query.nextFollowTimeEnd} + and date(bc.next_follow_time) >= #{query.nextFollowDateStart} + and date(bc.next_follow_time) <= #{query.nextFollowDateEnd} + + and bc.status in + + #{item} + + and date(bc.create_time) >= #{query.createDateRange[0]} and date(bc.create_time) <= #{query.createDateRange[1]} @@ -186,7 +198,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/task/domain/TaskQuery.java b/ruoyi-service/src/main/java/com/ruoyi/bst/task/domain/TaskQuery.java index 86f35b8..54f80c8 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/task/domain/TaskQuery.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/task/domain/TaskQuery.java @@ -15,6 +15,9 @@ public class TaskQuery extends TaskVO{ @ApiModelProperty("负责人ID") private Long ownerId; + @ApiModelProperty("负责人ID列表") + private List ownerIds; + @ApiModelProperty("项目id列表") private List projectIds; diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/task/mapper/TaskMapper.java b/ruoyi-service/src/main/java/com/ruoyi/bst/task/mapper/TaskMapper.java index 58e0461..13f07ee 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/task/mapper/TaskMapper.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/task/mapper/TaskMapper.java @@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Param; import com.ruoyi.bst.task.domain.Task; import com.ruoyi.bst.task.domain.TaskQuery; import com.ruoyi.bst.task.domain.TaskVO; +import com.ruoyi.common.vo.IntegerIntegerVO; import com.ruoyi.common.vo.LongIntegerVO; import com.ruoyi.common.vo.StringIntegerVO; @@ -93,4 +94,11 @@ public interface TaskMapper * @return */ List selectCountGroupByType(@Param("query") TaskQuery query); + + /** + * 查询参与人任务数,并按参与人ID分组 + * @param query + * @return + */ + List selectCountGroupByMemberUserId(@Param("query") TaskQuery query); } diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/task/mapper/TaskMapper.xml b/ruoyi-service/src/main/java/com/ruoyi/bst/task/mapper/TaskMapper.xml index e873166..d0b332b 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/task/mapper/TaskMapper.xml +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/task/mapper/TaskMapper.xml @@ -187,7 +187,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + diff --git a/ruoyi-service/src/main/java/com/ruoyi/common/mapper/CommonMapper.xml b/ruoyi-service/src/main/java/com/ruoyi/common/mapper/CommonMapper.xml index 458b8ef..713bbed 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/common/mapper/CommonMapper.xml +++ b/ruoyi-service/src/main/java/com/ruoyi/common/mapper/CommonMapper.xml @@ -18,6 +18,11 @@ + + + + + diff --git a/ruoyi-service/src/main/java/com/ruoyi/dashboard/customer/domain/brief/CustomerBriefQuery.java b/ruoyi-service/src/main/java/com/ruoyi/dashboard/customer/domain/brief/CustomerBriefQuery.java new file mode 100644 index 0000000..f8af28b --- /dev/null +++ b/ruoyi-service/src/main/java/com/ruoyi/dashboard/customer/domain/brief/CustomerBriefQuery.java @@ -0,0 +1,14 @@ +package com.ruoyi.dashboard.customer.domain.brief; + +import java.util.List; + +import com.ruoyi.bst.customer.domain.CustomerQuery; + +import lombok.Data; + +@Data +public class CustomerBriefQuery extends CustomerQuery { + + + private List keys; +} diff --git a/ruoyi-service/src/main/java/com/ruoyi/dashboard/project/service/DashboardProjectService.java b/ruoyi-service/src/main/java/com/ruoyi/dashboard/project/service/DashboardProjectService.java index cc98ee4..7a77ec2 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/dashboard/project/service/DashboardProjectService.java +++ b/ruoyi-service/src/main/java/com/ruoyi/dashboard/project/service/DashboardProjectService.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; +import com.ruoyi.common.vo.LongIntegerVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -130,7 +131,7 @@ public class DashboardProjectService { query.setDevOverdue(true); return this.selectCount(query); } - + // 查询完成数 private int selectDevCompletedCount(ProjectQuery projectQuery) { @@ -167,4 +168,9 @@ public class DashboardProjectService { return this.selectCount(query); } + // 查询参与人项目数,并按参与人ID分组 + public List selectCountGroupByMemberUserId(ProjectQuery query) { + return projectMapper.selectCountGroupByMemberUserId(query); + } + } diff --git a/ruoyi-service/src/main/java/com/ruoyi/dashboard/task/domain/brief/TaskBriefQuery.java b/ruoyi-service/src/main/java/com/ruoyi/dashboard/task/domain/brief/TaskBriefQuery.java new file mode 100644 index 0000000..4d76d73 --- /dev/null +++ b/ruoyi-service/src/main/java/com/ruoyi/dashboard/task/domain/brief/TaskBriefQuery.java @@ -0,0 +1,14 @@ +package com.ruoyi.dashboard.task.domain.brief; + +import java.util.List; + +import com.ruoyi.bst.task.domain.TaskQuery; + +import lombok.Data; + +@Data +public class TaskBriefQuery extends TaskQuery { + + private List keys; + +} diff --git a/ruoyi-service/src/main/java/com/ruoyi/dashboard/task/service/DashboardTaskService.java b/ruoyi-service/src/main/java/com/ruoyi/dashboard/task/service/DashboardTaskService.java index ba2bccd..dc5dbd5 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/dashboard/task/service/DashboardTaskService.java +++ b/ruoyi-service/src/main/java/com/ruoyi/dashboard/task/service/DashboardTaskService.java @@ -4,13 +4,16 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; +import com.ruoyi.common.vo.LongIntegerVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.bst.task.domain.TaskQuery; import com.ruoyi.bst.task.domain.enums.TaskStatus; +import com.ruoyi.bst.task.mapper.TaskMapper; import com.ruoyi.bst.task.service.TaskService; import com.ruoyi.common.utils.bean.BeanUtils; +import com.ruoyi.common.vo.IntegerIntegerVO; import com.ruoyi.common.vo.StringIntegerVO; import com.ruoyi.dashboard.index.domain.brief.BriefKeys; import com.ruoyi.dashboard.index.domain.brief.TaskBriefVO; @@ -20,6 +23,9 @@ public class DashboardTaskService { @Autowired private TaskService taskService; + @Autowired + private TaskMapper taskMapper; + public TaskBriefVO selectTaskBrief(TaskQuery query, List keyList) { TaskBriefVO vo = new TaskBriefVO(); if (keyList != null) { @@ -99,4 +105,9 @@ public class DashboardTaskService { query.setOverdue(true); return taskService.selectCount(query); } + + // 查询参与人任务数,并按参与人ID分组 + public List selectCountGroupByMemberUserId(TaskQuery query) { + return taskMapper.selectCountGroupByMemberUserId(query); + } } diff --git a/ruoyi-service/src/main/java/com/ruoyi/system/user/service/impl/UserAssemblerImpl.java b/ruoyi-service/src/main/java/com/ruoyi/system/user/service/impl/UserAssemblerImpl.java index 5845e32..2ed16bf 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/system/user/service/impl/UserAssemblerImpl.java +++ b/ruoyi-service/src/main/java/com/ruoyi/system/user/service/impl/UserAssemblerImpl.java @@ -1,11 +1,17 @@ package com.ruoyi.system.user.service.impl; import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; +import com.ruoyi.common.vo.LongIntegerVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.ruoyi.bst.project.domain.ProjectQuery; +import com.ruoyi.bst.task.domain.TaskQuery; import com.ruoyi.common.utils.collection.CollectionUtils; +import com.ruoyi.common.vo.IntegerIntegerVO; import com.ruoyi.dashboard.project.service.DashboardProjectService; import com.ruoyi.dashboard.task.service.DashboardTaskService; import com.ruoyi.system.user.domain.SysUserVO; @@ -25,16 +31,42 @@ public class UserAssemblerImpl implements UserAssembler{ if (CollectionUtils.isEmptyElement(list)) { return; } - // ProjectQuery query = new ProjectQuery(); - // query.setUserIds(list.stream().map(SysUserVO::getUserId).collect(Collectors.toList())); - // dashboardProjectService.selectCountGroupByUserId(query); - + ProjectQuery query = new ProjectQuery(); + query.setJoinUserIds(list.stream().map(SysUserVO::getUserId).collect(Collectors.toList())); + List result = dashboardProjectService.selectCountGroupByMemberUserId(query); + for (SysUserVO user : list) { + LongIntegerVO vo = result.stream() + .filter(item -> Objects.equals(item.getKey(), user.getUserId())) + .findFirst() + .orElse(null); + if (vo != null) { + user.setProjectCount(vo.getValue()); + } else { + user.setProjectCount(0); + } + } } @Override public void assembleTaskCount(List list) { - // TODO Auto-generated method stub -// throw new UnsupportedOperationException("Unimplemented method 'assembleTaskCount'"); + if (CollectionUtils.isEmptyElement(list)) { + return; + } + TaskQuery query = new TaskQuery(); + query.setOwnerIds(list.stream().map(SysUserVO::getUserId).collect(Collectors.toList())); + List result = dashboardTaskService.selectCountGroupByMemberUserId(query); + + for (SysUserVO user : list) { + LongIntegerVO vo = result.stream() + .filter(item -> Objects.equals(item.getKey(), user.getUserId())) + .findFirst() + .orElse(null); + if (vo != null) { + user.setTaskCount(vo.getValue()); + } else { + user.setTaskCount(0); + } + } } } diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/bst/CustomerController.java b/ruoyi-web/src/main/java/com/ruoyi/web/bst/CustomerController.java index af01c9c..91763bc 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/bst/CustomerController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/bst/CustomerController.java @@ -141,4 +141,5 @@ public class CustomerController extends BaseController { return toAjax(customerService.logicDel(ids)); } + } diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/bst/CustomerFollowController.java b/ruoyi-web/src/main/java/com/ruoyi/web/bst/CustomerFollowController.java index b73ed6b..e89a810 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/bst/CustomerFollowController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/bst/CustomerFollowController.java @@ -4,6 +4,7 @@ import java.util.List; import javax.servlet.http.HttpServletResponse; +import com.ruoyi.bst.customerFollow.domain.CustomerFollow; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; @@ -16,7 +17,6 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.ruoyi.bst.customerFollow.domain.CustomerFollow; import com.ruoyi.bst.customerFollow.domain.CustomerFollowQuery; import com.ruoyi.bst.customerFollow.domain.CustomerFollowVO; import com.ruoyi.bst.customerFollow.service.CustomerFollowService; @@ -84,9 +84,9 @@ public class CustomerFollowController extends BaseController @PreAuthorize("@ss.hasPermi('bst:customerFollow:add')") @Log(title = "客户跟进记录", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) CustomerFollow customerFollow) + public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) CustomerFollow dto) { - return toAjax(customerFollowService.insertCustomerFollow(customerFollow)); + return toAjax(customerFollowService.insertCustomerFollow(dto)); } /** @@ -95,9 +95,9 @@ public class CustomerFollowController extends BaseController @PreAuthorize("@ss.hasPermi('bst:customerFollow:edit')") @Log(title = "客户跟进记录", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody @Validated(ValidGroup.Update.class) CustomerFollow customerFollow) + public AjaxResult edit(@RequestBody @Validated(ValidGroup.Update.class) CustomerFollow dto) { - return toAjax(customerFollowService.updateCustomerFollow(customerFollow)); + return toAjax(customerFollowService.updateCustomerFollow(dto)); } /** diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/dashboard/DashboardCustomerController.java b/ruoyi-web/src/main/java/com/ruoyi/web/dashboard/DashboardCustomerController.java index dec5f86..27bfc86 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/dashboard/DashboardCustomerController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/dashboard/DashboardCustomerController.java @@ -3,6 +3,7 @@ package com.ruoyi.web.dashboard; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -13,12 +14,13 @@ import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.collection.CollectionUtils; import com.ruoyi.common.vo.LocalDateIntegerVO; +import com.ruoyi.dashboard.customer.domain.brief.CustomerBriefQuery; import com.ruoyi.dashboard.customer.service.DashboardCustomerService; @RestController @RequestMapping("/dashboard/customer") public class DashboardCustomerController extends BaseController { - + @Autowired private DashboardCustomerService dashboardCustomerService; @@ -42,4 +44,12 @@ public class DashboardCustomerController extends BaseController { return success(list); } + // 客户概览 + @GetMapping("/brief") + @PreAuthorize("@ss.hasPermi('dashboard:brief')") + public AjaxResult brief(CustomerBriefQuery query) { + query.setScope(true); + return success(dashboardCustomerService.selectCustomerBrief(query, query.getKeys())); + } + } diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/dashboard/DashboardTaskController.java b/ruoyi-web/src/main/java/com/ruoyi/web/dashboard/DashboardTaskController.java index a9b4d61..84a6caa 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/dashboard/DashboardTaskController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/dashboard/DashboardTaskController.java @@ -1,10 +1,14 @@ package com.ruoyi.web.dashboard; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.dashboard.task.domain.brief.TaskBriefQuery; import com.ruoyi.dashboard.task.service.DashboardTaskService; @@ -14,5 +18,12 @@ public class DashboardTaskController extends BaseController { @Autowired private DashboardTaskService dashboardTaskService; - + + @GetMapping("/brief") + @PreAuthorize("@ss.hasPermi('dashboard:brief')") + public AjaxResult brief(TaskBriefQuery query) { + query.setScope(true); + return success(dashboardTaskService.selectTaskBrief(query, query.getKeys())); + } + }