临时提交

This commit is contained in:
磷叶 2025-02-19 18:10:42 +08:00
parent 3d7b91bc03
commit 6a43d7d7a7
51 changed files with 780 additions and 160 deletions

View File

@ -1,14 +1,14 @@
package com.ruoyi.common.core.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
/**
* Entity基类
*
@ -40,7 +40,7 @@ public class BaseEntity implements Serializable
private String remark;
/** 是否需要数据隔离 */
private Boolean needScope;
private Boolean scope;
/** 删除标志 */
private Boolean deleted;
@ -57,12 +57,12 @@ public class BaseEntity implements Serializable
this.deleted = deleted;
}
public Boolean getNeedScope() {
return needScope;
public Boolean getScope() {
return scope;
}
public void setNeedScope(Boolean needScope) {
this.needScope = needScope;
public void setScope(Boolean scope) {
this.scope = scope;
}
public String getSearchValue()

View File

@ -1,12 +1,22 @@
package com.ruoyi.common.utils.collection;
import com.ruoyi.common.utils.DateUtils;
import java.time.LocalDate;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.ruoyi.common.utils.DateUtils;
/**
* @author wjh
* 2024/4/29
@ -134,6 +144,29 @@ public class CollectionUtils extends org.springframework.util.CollectionUtils {
return true;
}
/**
* 判断两个列表的元素是否一致无关顺序
*/
public static boolean equalsIgnoreOrder(List<?> list1, List<?> list2) {
if (list1 == null || list2 == null) {
return false;
}
if (list1.size() != list2.size()) {
return false;
}
Map<Object, Integer> countMap = new HashMap<>();
for (Object obj : list1) {
countMap.put(obj, countMap.getOrDefault(obj, 0) + 1);
}
for (Object obj : list2) {
Integer count = countMap.get(obj);
if (count == null || count == 0) {
return false;
}
countMap.put(obj, count - 1);
}
return true;
}
/**
* 填充空值

View File

@ -69,7 +69,7 @@ public class DataScopeUtil {
* @param needScope
* @return
*/
public static String dataScope(String deptAlias, String userAlias, boolean needScope) {
public static String dataScope(String deptAlias, String userAlias, String deptSetAlias, String userSetAlias, boolean needScope) {
if (needScope) {
// 获取当前的用户
LoginUser loginUser = SecurityUtils.getLoginUser();
@ -79,7 +79,7 @@ public class DataScopeUtil {
// 如果是超级管理员则不过滤数据
if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin())
{
StringBuilder sqlString = getSqlString(currentUser, deptAlias, userAlias, null, null, PermissionContextHolder.getContext());
StringBuilder sqlString = getSqlString(currentUser, deptAlias, userAlias, deptSetAlias, userSetAlias, PermissionContextHolder.getContext());
if (StringUtils.isNotBlank(sqlString.toString())) {
return getJoinSqlString(sqlString, "");
}

View File

@ -84,6 +84,11 @@ public class Customer extends BaseEntity
@ApiModelProperty("最近跟进时间")
private LocalDateTime lastFollowTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "下次跟进时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("下次跟进时间")
private LocalDateTime nextFollowTime;
@Excel(name = "创建人ID")
@ApiModelProperty("创建人ID")
private Long createId;

View File

@ -26,4 +26,11 @@ public class CustomerQuery extends CustomerVO{
@ApiModelProperty("创建日期")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate createDate;
@ApiModelProperty("参与人ID")
private Long joinUserId;
@ApiModelProperty("创建日期范围")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private List<LocalDate> createDateRange;
}

View File

@ -0,0 +1,20 @@
package com.ruoyi.bst.customer.domain.dto;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import com.ruoyi.bst.customer.domain.Customer;
import com.ruoyi.bst.customerFollow.domain.CustomerFollow;
import com.ruoyi.common.core.validate.ValidGroup;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class CustomerAddDTO extends Customer {
@ApiModelProperty("跟进记录")
@Valid
@NotNull(message = "跟进记录不能为空", groups = {ValidGroup.Create.class})
private CustomerFollow follow;
}

View File

@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Param;
import com.ruoyi.bst.customer.domain.Customer;
import com.ruoyi.bst.customer.domain.CustomerQuery;
import com.ruoyi.bst.customer.domain.CustomerVO;
import com.ruoyi.common.vo.LocalDateIntegerVO;
import com.ruoyi.common.vo.StringIntegerVO;
/**
@ -65,12 +66,12 @@ public interface CustomerMapper
List<StringIntegerVO> selectCountGroupByStatus(@Param("query") CustomerQuery query);
/**
* 更新客户最近跟进时间
* @param customerId
* @param lastFollowTime
* @return
* 更新客户跟进时间
*/
int updateLastFollowTime(@Param("customerId") Long customerId, @Param("lastFollowTime") LocalDateTime lastFollowTime);
int updateFollowTime(@Param("customerId") Long customerId,
@Param("lastFollowTime") LocalDateTime lastFollowTime,
@Param("nextFollowTime") LocalDateTime nextFollowTime
);
/**
* 逻辑删除
@ -78,4 +79,11 @@ public interface CustomerMapper
* @return
*/
int logicDel(@Param("ids") List<Long> ids);
/**
* 查询每日创建客户统计
* @param query
* @return
*/
List<LocalDateIntegerVO> selectDailyCreateCount(@Param("query") CustomerQuery query);
}

View File

@ -21,6 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bc.intents,
bc.follow_id,
bc.last_follow_time,
bc.next_follow_time,
bc.remark,
bc.create_time,
bc.update_time,
@ -52,6 +53,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.followName != null and query.followName != ''"> and suf.nick_name like concat('%', #{query.followName}, '%')</if>
<if test="query.createName != null and query.createName != ''"> and su.nick_name like concat('%', #{query.createName}, '%')</if>
<if test="query.createId != null "> and su.user_id = #{query.createId}</if>
<if test="query.createDateRange != null and query.createDateRange.size() > 1">
and date(bc.create_time) >= #{query.createDateRange[0]}
and date(bc.create_time) &lt;= #{query.createDateRange[1]}
</if>
<if test="query.joinUserId != null ">
and (
bc.create_id = #{query.joinUserId}
or bc.follow_id = #{query.joinUserId}
)
</if>
<if test="query.ids != null and query.ids.size() > 0">
and bc.id in
<foreach collection="query.ids" item="item" open="(" separator="," close=")">
@ -91,6 +102,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">update_time,</if>
<if test="deleted != null">deleted,</if>
<if test="createId != null">create_id,</if>
<if test="nextFollowTime != null">next_follow_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="code != null and code != ''">#{code},</if>
@ -108,6 +120,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">#{updateTime},</if>
<if test="deleted != null">#{deleted},</if>
<if test="createId != null">#{createId},</if>
<if test="nextFollowTime != null">#{nextFollowTime},</if>
</trim>
</insert>
@ -135,6 +148,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="data.updateTime != null">update_time = #{data.updateTime},</if>
<if test="data.deleted != null">deleted = #{data.deleted},</if>
<if test="data.createId != null">create_id = #{data.createId},</if>
<if test="data.nextFollowTime != null">next_follow_time = #{data.nextFollowTime},</if>
</sql>
@ -147,12 +161,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<!-- selectCountGroupByStatus -->
<!-- selectCountGroupByStatus -->
<select id="selectCountGroupByStatus" parameterType="CustomerQuery" resultMap="com.ruoyi.common.mapper.CommonMapper.StringIntegerVO">
select
bc.status as `key`,
count(bc.id) as `value`
bc.status as `key`,
count(bc.id) as `value`
from bst_customer bc
<where>
<include refid="searchCondition"/>
@ -160,14 +174,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
group by `key`
</select>
<update id="updateLastFollowTime">
<update id="updateFollowTime">
update bst_customer
set last_follow_time = #{lastFollowTime}
<trim prefix="SET" suffixOverrides=",">
<if test="lastFollowTime != null">
last_follow_time = if (last_follow_time is null or (#{lastFollowTime} >= last_follow_time),
#{lastFollowTime},
last_follow_time),
</if>
<if test="nextFollowTime != null">
next_follow_time = if (next_follow_time is null or (#{nextFollowTime} &lt; next_follow_time and #{nextFollowTime} > now()),
#{nextFollowTime},
next_follow_time),
</if>
</trim>
where id = #{customerId}
and last_follow_time &lt; #{lastFollowTime}
</update>
<!-- logicDel -->
<!-- logicDel -->
<update id="logicDel">
update bst_customer
@ -177,5 +201,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
and deleted = false
</update>
</update>
<!-- selectDailyCreateCount -->
<select id="selectDailyCreateCount" parameterType="CustomerQuery" resultMap="com.ruoyi.common.mapper.CommonMapper.LocalDateIntegerVO">
select
date(bc.create_time) as `key`,
count(bc.id) as `value`
from bst_customer bc
<where>
<include refid="searchCondition"/>
</where>
group by `key`
</select>
</mapper>

View File

@ -1,6 +1,7 @@
package com.ruoyi.bst.customer.service;
import com.ruoyi.bst.customer.domain.Customer;
import com.ruoyi.bst.customer.domain.dto.CustomerAddDTO;
import com.ruoyi.bst.customerFollow.domain.CustomerFollow;
public interface CustomerConverter {
@ -10,7 +11,7 @@ public interface CustomerConverter {
* @param customer
* @return
*/
Customer toPoByCreate(Customer customer);
CustomerAddDTO toDTOByCreate(CustomerAddDTO customer);
/**
* 修改客户

View File

@ -6,7 +6,9 @@ import java.util.List;
import com.ruoyi.bst.customer.domain.Customer;
import com.ruoyi.bst.customer.domain.CustomerQuery;
import com.ruoyi.bst.customer.domain.CustomerVO;
import com.ruoyi.bst.customer.domain.dto.CustomerAddDTO;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.vo.LocalDateIntegerVO;
import com.ruoyi.common.vo.StringIntegerVO;
/**
@ -39,7 +41,7 @@ public interface CustomerService
* @param customer 客户
* @return 结果
*/
public int insertCustomer(Customer customer);
public int insertCustomer(CustomerAddDTO customer);
/**
* 修改客户
@ -71,12 +73,16 @@ public interface CustomerService
List<StringIntegerVO> selectCountGroupByStatus(CustomerQuery customerQuery);
/**
* 更新客户最近跟进时间需要新的跟进时间大于当前跟进时间
* @param customerId 客户ID
* 更新客户跟进时间
* 新的最近跟进时间大于当前跟进时间
* 新的下次跟进时间需要大于当前时间并且小于客户当前的下次跟进时间
*
* @param customerId 客户ID
* @param lastFollowTime 新的跟进时间
* @param nextFollowTime 新的下次跟进时间
* @return
*/
int updateLastFollowTime(Long customerId, LocalDateTime lastFollowTime);
int updateFollowTime(Long customerId, LocalDateTime lastFollowTime, LocalDateTime nextFollowTime);
/**
* 查询客户列表并根据数据权限过滤
@ -94,4 +100,11 @@ public interface CustomerService
* @return
*/
int logicDel(List<Long> ids);
/**
* 查询每日创建客户统计
* @param query
* @return
*/
List<LocalDateIntegerVO> selectDailyCreateCount(CustomerQuery query);
}

View File

@ -3,18 +3,20 @@ package com.ruoyi.bst.customer.service.impl;
import org.springframework.stereotype.Service;
import com.ruoyi.bst.customer.domain.Customer;
import com.ruoyi.bst.customer.domain.dto.CustomerAddDTO;
import com.ruoyi.bst.customer.service.CustomerConverter;
import com.ruoyi.bst.customerFollow.domain.CustomerFollow;
@Service
public class CustomerConverterImpl implements CustomerConverter {
@Override
public Customer toPoByCreate(Customer customer) {
public CustomerAddDTO toDTOByCreate(CustomerAddDTO customer) {
if (customer == null) {
return null;
}
Customer po = new Customer();
CustomerAddDTO po = new CustomerAddDTO();
po.setName(customer.getName());
po.setStatus(customer.getStatus());
po.setIntentLevel(customer.getIntentLevel());
@ -24,6 +26,7 @@ public class CustomerConverterImpl implements CustomerConverter {
po.setIntents(customer.getIntents());
po.setFollowId(customer.getFollowId());
po.setRemark(customer.getRemark());
po.setFollow(customer.getFollow());
return po;
}

View File

@ -11,13 +11,17 @@ import org.springframework.transaction.support.TransactionTemplate;
import com.ruoyi.bst.customer.domain.Customer;
import com.ruoyi.bst.customer.domain.CustomerQuery;
import com.ruoyi.bst.customer.domain.CustomerVO;
import com.ruoyi.bst.customer.domain.dto.CustomerAddDTO;
import com.ruoyi.bst.customer.mapper.CustomerMapper;
import com.ruoyi.bst.customer.service.CustomerService;
import com.ruoyi.bst.customer.service.CustomerValidator;
import com.ruoyi.bst.customerFollow.service.CustomerFollowService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.common.utils.SnowFlakeUtil;
import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.common.vo.LocalDateIntegerVO;
import com.ruoyi.common.vo.StringIntegerVO;
/**
@ -38,6 +42,9 @@ public class CustomerServiceImpl implements CustomerService
@Autowired
private CustomerValidator customerValidator;
@Autowired
private CustomerFollowService customerFollowService;
/**
* 查询客户
*
@ -69,7 +76,7 @@ public class CustomerServiceImpl implements CustomerService
* @return 结果
*/
@Override
public int insertCustomer(Customer customer)
public int insertCustomer(CustomerAddDTO customer)
{
customer.setCode(String.valueOf(SnowFlakeUtil.newId()));
customer.setCreateTime(DateUtils.getNowDate());
@ -78,6 +85,14 @@ public class CustomerServiceImpl implements CustomerService
Integer result = transactionTemplate.execute(status -> {
int insert = customerMapper.insertCustomer(customer);
if (insert > 0) {
// 若跟进记录不为空则插入跟进记录
if (customer.getFollow() != null) {
customer.getFollow().setCustomerId(customer.getId());
int insertFollow = customerFollowService.insertCustomerFollow(customer.getFollow());
ServiceUtil.assertion(insertFollow != 1, "新增跟进记录失败");
}
CustomerVO vo = selectCustomerById(customer.getId());
customerValidator.validate(vo);
}
@ -109,7 +124,7 @@ public class CustomerServiceImpl implements CustomerService
return result;
}
@Override
public int selectCount(CustomerQuery query) {
return customerMapper.selectCount(query);
@ -131,11 +146,11 @@ public class CustomerServiceImpl implements CustomerService
}
@Override
public int updateLastFollowTime(Long customerId, LocalDateTime lastFollowTime) {
if (customerId == null || lastFollowTime == null) {
public int updateFollowTime(Long customerId, LocalDateTime lastFollowTime, LocalDateTime nextFollowTime) {
if (customerId == null) {
return 0;
}
return customerMapper.updateLastFollowTime(customerId, lastFollowTime);
return customerMapper.updateFollowTime(customerId, lastFollowTime, nextFollowTime);
}
@Override
@ -145,4 +160,9 @@ public class CustomerServiceImpl implements CustomerService
}
return customerMapper.logicDel(ids);
}
@Override
public List<LocalDateIntegerVO> selectDailyCreateCount(CustomerQuery query) {
return customerMapper.selectDailyCreateCount(query);
}
}

View File

@ -4,7 +4,6 @@ import java.time.LocalDateTime;
import javax.validation.constraints.Future;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import javax.validation.constraints.Size;
@ -34,7 +33,6 @@ public class CustomerFollow extends BaseEntity
@Excel(name = "客户ID")
@ApiModelProperty("客户ID")
@NotNull(message = "客户ID不能为空", groups = {ValidGroup.Create.class})
private Long customerId;
@Excel(name = "跟进方式", readConverterExp = "1=电话,2=微信,3=见面,4=其他")

View File

@ -0,0 +1,6 @@
package com.ruoyi.bst.customerFollow.service;
public interface CustomerFollowConverter {
}

View File

@ -0,0 +1,10 @@
package com.ruoyi.bst.customerFollow.service.impl;
import org.springframework.stereotype.Service;
import com.ruoyi.bst.customerFollow.service.CustomerFollowConverter;
@Service
public class CustomerFollowConverterImpl implements CustomerFollowConverter {
}

View File

@ -14,6 +14,8 @@ import com.ruoyi.bst.customerFollow.domain.CustomerFollowVO;
import com.ruoyi.bst.customerFollow.mapper.CustomerFollowMapper;
import com.ruoyi.bst.customerFollow.service.CustomerFollowService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServiceUtil;
/**
* 客户跟进记录Service业务层处理
@ -67,17 +69,20 @@ public class CustomerFollowServiceImpl implements CustomerFollowService
* @return 结果
*/
@Override
public int insertCustomerFollow(CustomerFollow customerFollow)
public int insertCustomerFollow(CustomerFollow data)
{
customerFollow.setCreateTime(DateUtils.getNowDate());
ServiceUtil.assertion(data.getCustomerId() == null, "客户ID不能为空");
data.setUserId(SecurityUtils.getUserId());
data.setCreateTime(DateUtils.getNowDate());
Integer result = transactionTemplate.execute(status -> {
// 新增客户跟进记录
int insert = customerFollowMapper.insertCustomerFollow(customerFollow);
int insert = customerFollowMapper.insertCustomerFollow(data);
if (insert > 0) {
// 更新客户最近跟进时间
customerService.updateLastFollowTime(customerFollow.getCustomerId(), customerFollow.getFollowTime());
customerService.updateFollowTime(data.getCustomerId(), data.getFollowTime(), data.getNextFollowTime());
}
return insert;
@ -89,17 +94,17 @@ public class CustomerFollowServiceImpl implements CustomerFollowService
/**
* 修改客户跟进记录
*
* @param customerFollow 客户跟进记录
* @param data 客户跟进记录
* @return 结果
*/
@Override
public int updateCustomerFollow(CustomerFollow customerFollow) {
public int updateCustomerFollow(CustomerFollow data) {
Integer result = transactionTemplate.execute(status -> {
int update = customerFollowMapper.updateCustomerFollow(customerFollow);
int update = customerFollowMapper.updateCustomerFollow(data);
if (update > 0) {
// 更新客户最近跟进时间
customerService.updateLastFollowTime(customerFollow.getCustomerId(), customerFollow.getFollowTime());
customerService.updateFollowTime(data.getCustomerId(), data.getFollowTime(), data.getNextFollowTime());
}
return update;

View File

@ -42,4 +42,7 @@ public class ProjectQuery extends ProjectVO {
@ApiModelProperty("维护到期日期结束")
private LocalDate maintenanceEndDateEnd;
@ApiModelProperty("参与人ID")
private Long joinUserId;
}

View File

@ -56,7 +56,7 @@ public enum ProjectStatus {
}
/**
* 完成的项目状态
* 开发完成的项目状态
* @return
*/
public static List<String> completedList() {

View File

@ -69,12 +69,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.expectedCompleteDateEnd != null "> and date(bp.expected_complete_date) &lt;= #{query.expectedCompleteDateEnd}</if>
<if test="query.maintenanceEndDateStart != null "> and date(bp.maintenance_end_date) >= #{query.maintenanceEndDateStart}</if>
<if test="query.maintenanceEndDateEnd != null "> and date(bp.maintenance_end_date) &lt;= #{query.maintenanceEndDateEnd}</if>
<if test="query.joinUserId != null ">
and (
bp.owner_id = #{query.joinUserId}
or bp.follow_id = #{query.joinUserId}
or find_in_set(#{query.joinUserId}, bp.member_ids)
)
</if>
<if test="query.statusList != null and query.statusList.size() > 0">
and bp.status in
<foreach item="item" collection="query.statusList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
${@com.ruoyi.framework.util.DataScopeUtil@dataScope(
null,
"bp.owner_id,bp.follow_id,bp.create_id",
null,
"bp.member_ids",
query.scope
)}
${query.params.dataScope}
</sql>

View File

@ -8,7 +8,6 @@ import com.ruoyi.bst.project.domain.ProjectVO;
import com.ruoyi.bst.project.domain.dto.ProjectMaintenanceDTO;
import com.ruoyi.bst.project.domain.dto.ProjectStartDTO;
import com.ruoyi.bst.project.domain.vo.ProjectNameVO;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.vo.IntegerIntegerVO;
import com.ruoyi.common.vo.StringIntegerVO;
@ -139,13 +138,4 @@ public interface ProjectService
*/
int handleMaintenanceOverdueProject(ProjectQuery query);
/**
* 查询项目列表并按照数据隔离
* @param query
* @return
*/
@DataScope(userAlias = "bp.owner_id,bp.follow_id,bp.create_id", userSetAlias = "bp.member_ids")
default List<ProjectVO> selectProjectListScope(ProjectQuery query) {
return this.selectProjectList(query);
}
}

View File

@ -81,6 +81,7 @@ public class ProjectAssemblerImpl implements ProjectAssembler {
*/
private Map<Long, Integer> selectTaskCountByProjects(List<ProjectVO> list, String status) {
TaskQuery query = new TaskQuery();
query.setScope(true);
query.setStatus(status);
query.setProjectIds(CollectionUtils.map(list, ProjectVO::getId));
return taskService.selectCountGroupByProject(query)

View File

@ -31,4 +31,7 @@ public class TaskVO extends Task{
@ApiModelProperty("通过数量")
private Integer passCount;
@ApiModelProperty("是否逾期")
private Boolean overdue;
}

View File

@ -49,4 +49,18 @@ public enum TaskStatus {
public static List<String> canStart() {
return CollectionUtils.map(TaskStatus::getStatus, PASS, CANCEL);
}
/**
* 获取未完成任务状态
*/
public static List<String> unComplete() {
return CollectionUtils.map(TaskStatus::getStatus, PROCESSING);
}
/**
* 获取已完成任务状态
*/
public static List<String> complete() {
return CollectionUtils.map(TaskStatus::getStatus, PASS);
}
}

View File

@ -0,0 +1,17 @@
package com.ruoyi.bst.task.domain.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum TaskType {
FUNCTION("1", "新功能"),
OPTIMIZATION("2", "优化"),
BUG("3", "BUG");
private final String type;
private final String name;
}

View File

@ -86,4 +86,11 @@ public interface TaskMapper
* @return
*/
int updateByQuery(@Param("data") Task data, @Param("query") TaskQuery query);
/**
* 查询任务类型数量
* @param query
* @return
*/
List<StringIntegerVO> selectCountGroupByType(@Param("query") TaskQuery query);
}

View File

@ -8,6 +8,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="ownerIds" column="owner_ids" typeHandler="com.ruoyi.common.mybatis.typehandler.LongSplitListTypeHandler"/>
</resultMap>
<!-- 是否逾期 -->
<sql id="overdue">
if(bt.pass_time is null, now() > bt.expire_time, bt.pass_time > bt.expire_time)
</sql>
<sql id="selectTaskVo">
select
bt.id,
@ -27,6 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bt.cancel_time,
bt.cancel_user_id,
bt.cancel_remark,
<include refid="overdue"/> as overdue,
bp.name as project_name,
su.nick_name as create_name,
cu.nick_name as cancel_user_name
@ -54,12 +60,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.cancelUserId != null"> and bt.cancel_user_id = #{query.cancelUserId}</if>
<if test="query.cancelRemark != null and query.cancelRemark != ''"> and bt.cancel_remark like concat('%', #{query.cancelRemark}, '%')</if>
<if test="query.cancelUserName != null and query.cancelUserName != ''"> and cu.nick_name like concat('%', #{query.cancelUserName}, '%')</if>
<if test="query.overdue != null">
and <include refid="overdue"/> = #{query.overdue}
</if>
<if test="query.statusList != null and query.statusList.size() > 0">
and bt.status in
<foreach item="item" collection="query.statusList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
${@com.ruoyi.framework.util.DataScopeUtil@dataScope(
null,
"bt.cancel_user_id,bt.create_id",
null,
"bt.owner_ids",
query.scope
)}
${query.params.dataScope}
</sql>
@ -199,4 +215,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="searchCondition"/>
</where>
</update>
<!-- selectCountGroupByType -->
<select id="selectCountGroupByType" parameterType="TaskQuery" resultMap="com.ruoyi.common.mapper.CommonMapper.StringIntegerVO">
select
bt.type as `key`,
count(bt.id) as `value`
from bst_task bt
<where>
<include refid="searchCondition"/>
</where>
group by `key`
</select>
</mapper>

View File

@ -7,7 +7,6 @@ import com.ruoyi.bst.task.domain.TaskQuery;
import com.ruoyi.bst.task.domain.TaskVO;
import com.ruoyi.bst.task.domain.dto.TaskCancelDTO;
import com.ruoyi.bst.task.domain.dto.TaskSubmitDTO;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.vo.LongIntegerVO;
import com.ruoyi.common.vo.StringIntegerVO;
@ -115,8 +114,12 @@ public interface TaskService
*/
int startTask(Long taskId);
@DataScope(userAlias = "bt.create_id,bt.cancel_user_id", userSetAlias = "bt.owner_ids")
default List<TaskVO> selectTaskListScope(TaskQuery query) {
return this.selectTaskList(query);
}
/**
* 查询任务类型数量
* @param query
* @return
*/
List<StringIntegerVO> selectCountGroupByType(TaskQuery query);
}

View File

@ -194,7 +194,7 @@ public class TaskServiceImpl implements TaskService
submitQuery.setStatus(TaskSubmitStatus.PASS.getCode());
List<TaskSubmitVO> submitList = taskSubmitService.selectTaskSubmitList(submitQuery);
List<Long> passedOwnerIds = CollectionUtils.map(submitList, TaskSubmitVO::getUserId);
ServiceUtil.assertion(!CollectionUtils.equals(old.getOwnerIds(), passedOwnerIds),
ServiceUtil.assertion(!CollectionUtils.equalsIgnoreOrder(old.getOwnerIds(), passedOwnerIds),
"ID为%s的任务当前状态不允许完成,还有%s个负责人未提交", id, old.getOwnerIds().size() - passedOwnerIds.size());
}
@ -247,4 +247,9 @@ public class TaskServiceImpl implements TaskService
query.setStatusList(TaskStatus.canStart());
return this.updateByQuery(data, query);
}
@Override
public List<StringIntegerVO> selectCountGroupByType(TaskQuery query) {
return taskMapper.selectCountGroupByType(query);
}
}

View File

@ -0,0 +1,16 @@
package com.ruoyi.common.constants;
/**
* 数据隔离常量
*/
public class ScopeConstants {
// 项目
public static final String PROJECT_USER_ALIAS = "bp.owner_id,bp.follow_id,bp.create_id";
public static final String PROJECT_USER_SET_ALIAS = "bp.member_ids";
// 任务
public static final String TASK_USER_ALIAS = "bt.create_id,bt.cancel_user_id";
public static final String TASK_USER_SET_ALIAS = "bt.member_ids";
}

View File

@ -18,4 +18,9 @@
<result property="value" column="value" typeHandler="com.ruoyi.common.mybatis.typehandler.NonNullIntegerTyperHandler"/>
</resultMap>
<resultMap id="LocalDateIntegerVO" type="com.ruoyi.common.vo.LocalDateIntegerVO">
<result property="key" column="key"/>
<result property="value" column="value" typeHandler="com.ruoyi.common.mybatis.typehandler.NonNullIntegerTyperHandler"/>
</resultMap>
</mapper>

View File

@ -0,0 +1,17 @@
package com.ruoyi.common.vo;
import java.time.LocalDate;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class LocalDateIntegerVO {
@ApiModelProperty("日期")
private LocalDate key;
@ApiModelProperty("数量")
private Integer value;
}

View File

@ -0,0 +1,8 @@
package com.ruoyi.dashboard.customer.mapper;
/**
* @author wjh
* 2024/12/20
*/
public interface DashboardCustomerMapper {
}

View File

@ -0,0 +1,7 @@
<?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="com.ruoyi.dashboard.customer.mapper.DashboardCustomerMapper">
</mapper>

View File

@ -3,13 +3,14 @@ package com.ruoyi.dashboard.customer.service;
import java.time.LocalDate;
import java.util.List;
import com.ruoyi.dashboard.index.domain.brief.CustomerBriefVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.bst.customer.domain.CustomerQuery;
import com.ruoyi.bst.customer.service.CustomerService;
import com.ruoyi.common.vo.StringIntegerVO;
import com.ruoyi.dashboard.customer.mapper.DashboardCustomerMapper;
import com.ruoyi.dashboard.index.domain.brief.CustomerBriefVO;
@Service
public class DashboardCustomerService {
@ -17,12 +18,14 @@ public class DashboardCustomerService {
@Autowired
private CustomerService customerService;
public CustomerBriefVO selectCustomerBrief() {
@Autowired
private DashboardCustomerMapper dashboardCustomerMapper;
List<StringIntegerVO> customerMap = customerService.selectCountGroupByStatus(new CustomerQuery());
public CustomerBriefVO selectCustomerBrief(CustomerQuery query) {
List<StringIntegerVO> customerMap = customerService.selectCountGroupByStatus(query);
CustomerBriefVO customerBriefVO = new CustomerBriefVO(customerMap);
// 今日新增客户
customerBriefVO.setToday(this.selectTodayCustomerCount());
customerBriefVO.setToday(this.selectTodayCustomerCount(query));
return customerBriefVO;
}
@ -31,8 +34,7 @@ public class DashboardCustomerService {
* 查询今日新增客户数
* @return
*/
private int selectTodayCustomerCount() {
CustomerQuery query = new CustomerQuery();
private int selectTodayCustomerCount(CustomerQuery query) {
query.setCreateDate(LocalDate.now());
return customerService.selectCount(query);
}

View File

@ -0,0 +1,40 @@
package com.ruoyi.dashboard.index.domain.brief;
import com.ruoyi.bst.customer.domain.CustomerQuery;
import com.ruoyi.bst.project.domain.ProjectQuery;
import com.ruoyi.bst.task.domain.TaskQuery;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class BriefQuery {
@ApiModelProperty("参与人ID")
private Long joinUserId;
@ApiModelProperty("数据隔离")
private Boolean scope;
public ProjectQuery toProjectQuery() {
ProjectQuery projectQuery = new ProjectQuery();
projectQuery.setJoinUserId(joinUserId);
projectQuery.setScope(scope);
return projectQuery;
}
public TaskQuery toTaskQuery() {
TaskQuery taskQuery = new TaskQuery();
taskQuery.setOwnerId(joinUserId);
taskQuery.setScope(scope);
return taskQuery;
}
public CustomerQuery toCustomerQuery() {
CustomerQuery customerQuery = new CustomerQuery();
customerQuery.setJoinUserId(joinUserId);
customerQuery.setScope(scope);
return customerQuery;
}
}

View File

@ -7,31 +7,36 @@ import com.ruoyi.common.vo.StringIntegerVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
public class ProjectBriefVO {
@ApiModelProperty("项目总数")
private Integer total;
@ApiModelProperty("已完成")
// 状态
@ApiModelProperty("开发完成")
private Integer completed;
@ApiModelProperty("进行中")
private Integer inProgress;
@ApiModelProperty("维护中")
private Integer maintenance;
@ApiModelProperty("开发超期")
private Integer developmentOverdue;
@ApiModelProperty("维护超期")
private Integer maintenanceOverdue;
public ProjectBriefVO(List<StringIntegerVO> statusMap) {
@ApiModelProperty("开发已完成")
private Integer devCompleted;
@ApiModelProperty("开发逾期未完成")
private Integer devOverdueUncompleted;
@ApiModelProperty("开发逾期完成")
private Integer devOverdueCompleted;
public void setStatusGroup(List<StringIntegerVO> statusMap) {
this.completed = statusMap.stream()
.filter(vo -> ProjectStatus.COMPLETED.getStatus().equals(vo.getKey()))
.findFirst().map(StringIntegerVO::getValue).orElse(0);

View File

@ -2,37 +2,47 @@ package com.ruoyi.dashboard.index.domain.brief;
import java.util.List;
import com.ruoyi.bst.task.domain.enums.TaskStatus;
import com.ruoyi.bst.task.domain.enums.TaskType;
import com.ruoyi.common.vo.StringIntegerVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
public class TaskBriefVO {
@ApiModelProperty("任务总数")
private Integer total;
// 状态分组
@ApiModelProperty("待完成")
private Integer waitCompleted;
@ApiModelProperty("进行中")
private Integer inProgress;
@ApiModelProperty("待确认")
private Integer waitConfirm;
@ApiModelProperty("已完成")
private Integer completed;
@ApiModelProperty("驳回")
private Integer reject;
public TaskBriefVO(List<StringIntegerVO> statusMap) {
this.waitCompleted = statusMap.stream()
// 类型分组
@ApiModelProperty("BUG数")
private Integer bug;
@ApiModelProperty("新功能")
private Integer newFunction;
@ApiModelProperty("优化")
private Integer optimization;
@ApiModelProperty("逾期未完成")
private Integer overdueUncompleted;
@ApiModelProperty("逾期完成")
private Integer overdueCompleted;
// 设置状态分组数据
public void setStatusGroup(List<StringIntegerVO> statusMap) {
this.waitCompleted = statusMap.stream()
.filter(vo -> TaskStatus.WAIT_COMPLETED.getStatus().equals(vo.getKey()))
.findFirst().map(StringIntegerVO::getValue).orElse(0);
@ -53,6 +63,23 @@ public class TaskBriefVO {
.findFirst().map(StringIntegerVO::getValue).orElse(0);
this.total = statusMap.stream().map(StringIntegerVO::getValue).reduce(0, Integer::sum);
}
// 设置类型分组数据
public void setTypeGroup(List<StringIntegerVO> typeMap) {
this.bug = typeMap.stream()
.filter(vo -> TaskType.BUG.getType().equals(vo.getKey()))
.findFirst().map(StringIntegerVO::getValue).orElse(0);
this.newFunction = typeMap.stream()
.filter(vo -> TaskType.FUNCTION.getType().equals(vo.getKey()))
.findFirst().map(StringIntegerVO::getValue).orElse(0);
this.optimization = typeMap.stream()
.filter(vo -> TaskType.OPTIMIZATION.getType().equals(vo.getKey()))
.findFirst().map(StringIntegerVO::getValue).orElse(0);
this.total = typeMap.stream().map(StringIntegerVO::getValue).reduce(0, Integer::sum);
}
}

View File

@ -1,40 +1,13 @@
package com.ruoyi.dashboard.index.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.dashboard.customer.service.DashboardCustomerService;
import com.ruoyi.dashboard.index.domain.brief.BriefQuery;
import com.ruoyi.dashboard.index.domain.brief.BriefVO;
import com.ruoyi.dashboard.project.service.DashboardProjectService;
import com.ruoyi.dashboard.task.domain.DashboardTaskService;
@Service
public class DashboardService {
@Autowired
private DashboardProjectService dashboardProjectService;
@Autowired
private DashboardTaskService dashboardTaskService;
@Autowired
private DashboardCustomerService dashboardCustomerService;
public BriefVO selectBrief() {
BriefVO result = new BriefVO();
// 项目概览
result.setProject(dashboardProjectService.selectProjectBrief());
// 任务概览
result.setTask(dashboardTaskService.selectTaskBrief());
// 客户概览
result.setCustomer(dashboardCustomerService.selectCustomerBrief());
return result;
}

View File

@ -0,0 +1,19 @@
package com.ruoyi.dashboard.project.domain.brief;
public class ProjectBriefKeys {
// 项目状态
public static final String STATUS = "status";
// 项目开发完成
public static final String DEV_COMPLETED = "devCompleted";
// 项目逾期开发未完成
public static final String OVERDUE_DEV_UNCOMPLETED = "overdueDevUncompleted";
// 项目逾期开发完成
public static final String OVERDUE_DEV_COMPLETED = "overdueDevCompleted";
}

View File

@ -8,5 +8,4 @@ public class MonthProjectQuery {
@ApiModelProperty("年份")
private Integer year;
}

View File

@ -1,6 +1,7 @@
package com.ruoyi.dashboard.project.service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
@ -10,9 +11,11 @@ import org.springframework.stereotype.Service;
import com.ruoyi.bst.project.domain.ProjectQuery;
import com.ruoyi.bst.project.domain.enums.ProjectStatus;
import com.ruoyi.bst.project.service.ProjectService;
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.ProjectBriefVO;
import com.ruoyi.dashboard.project.domain.brief.ProjectBriefKeys;
import com.ruoyi.dashboard.project.domain.monthProject.MonthProjectQuery;
import com.ruoyi.dashboard.project.domain.monthProject.MonthProjectVO;
import com.ruoyi.dashboard.project.domain.projectRate.ProjectRateVO;
@ -22,7 +25,7 @@ public class DashboardProjectService {
@Autowired
private ProjectService projectService;
public List<MonthProjectVO> selectMonthProject(MonthProjectQuery query) {
List<MonthProjectVO> result = new ArrayList<>();
@ -58,12 +61,35 @@ public class DashboardProjectService {
}
return result;
}
}
// 查询项目概览
public ProjectBriefVO selectProjectBrief() {
List<StringIntegerVO> projectMap = projectService.selectCountGroupByStatus(new ProjectQuery());
return new ProjectBriefVO(projectMap);
public ProjectBriefVO selectProjectBrief(ProjectQuery query, String ...keys) {
ProjectBriefVO vo = new ProjectBriefVO();
if (keys != null) {
List<String> keyList = Arrays.asList(keys);
if (keyList.contains(ProjectBriefKeys.STATUS)) {
List<StringIntegerVO> projectMap = projectService.selectCountGroupByStatus(query);
vo.setStatusGroup(projectMap);
}
if (keyList.contains(ProjectBriefKeys.DEV_COMPLETED)) {
int devCompleted = this.selectDevCompletedCount(query);
vo.setDevCompleted(devCompleted);
}
if (keyList.contains(ProjectBriefKeys.OVERDUE_DEV_UNCOMPLETED)) {
int devOverdueUncompleted = this.selectDevOverdueUncompletedCount(query);
vo.setDevOverdueUncompleted(devOverdueUncompleted);
}
if (keyList.contains(ProjectBriefKeys.OVERDUE_DEV_COMPLETED)) {
int devOverdueCompleted = this.selectDevOverdueCompletedCount(query);
vo.setDevOverdueCompleted(devOverdueCompleted);
}
}
return vo;
}
// 按月查询新增项目数
@ -92,14 +118,16 @@ public class DashboardProjectService {
ProjectRateVO result = new ProjectRateVO();
// 查询总数
int total = projectService.selectCount(new ProjectQuery());
ProjectQuery query = new ProjectQuery();
query.setScope(true);
int total = projectService.selectCount(query);
result.setTotal(total);
// 查询完成数
result.setCompleted(this.selectCompletedCount());
// 查询超期数
result.setDevOverdue(this.selectDevOverdueCount());
result.setDevOverdue(this.selectDevOverdueCount());
return result;
}
@ -108,6 +136,7 @@ public class DashboardProjectService {
private int selectCompletedCount() {
ProjectQuery query = new ProjectQuery();
query.setStatusList(ProjectStatus.completedList());
query.setScope(true);
return projectService.selectCount(query);
}
@ -115,6 +144,35 @@ public class DashboardProjectService {
private int selectDevOverdueCount() {
ProjectQuery query = new ProjectQuery();
query.setDevOverdue(true);
query.setScope(true);
return projectService.selectCount(query);
}
// 查询正常开发完成数
private int selectDevCompletedCount(ProjectQuery projectQuery) {
ProjectQuery query = new ProjectQuery();
BeanUtils.copyBeanProp(query, projectQuery);
query.setStatusList(ProjectStatus.completedList());
query.setDevOverdue(false);
return projectService.selectCount(query);
}
// 开发逾期未完成
private int selectDevOverdueUncompletedCount(ProjectQuery projectQuery) {
ProjectQuery query = new ProjectQuery();
BeanUtils.copyBeanProp(query, projectQuery);
query.setDevOverdue(true);
query.setStatusList(ProjectStatus.devNotFinish());
return projectService.selectCount(query);
}
// 开发逾期完成
private int selectDevOverdueCompletedCount(ProjectQuery projectQuery) {
ProjectQuery query = new ProjectQuery();
BeanUtils.copyBeanProp(query, projectQuery);
query.setDevOverdue(true);
query.setStatusList(ProjectStatus.completedList());
return projectService.selectCount(query);
}
}

View File

@ -1,24 +0,0 @@
package com.ruoyi.dashboard.task.domain;
import java.util.List;
import com.ruoyi.dashboard.index.domain.brief.TaskBriefVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.bst.task.domain.TaskQuery;
import com.ruoyi.bst.task.service.TaskService;
import com.ruoyi.common.vo.StringIntegerVO;
@Service
public class DashboardTaskService {
@Autowired
private TaskService taskService;
public TaskBriefVO selectTaskBrief() {
List<StringIntegerVO> taskMap = taskService.selectCountGroupByStatus(new TaskQuery());
return new TaskBriefVO(taskMap);
}
}

View File

@ -0,0 +1,17 @@
package com.ruoyi.dashboard.task.domain.brief;
public class TaskBriefKeys {
// 状态数据
public static final String STATUS = "status";
// 类型分组数据
public static final String TYPE = "type";
// 逾期未完成
public static final String OVERDUE_UNCOMPLETED = "overdueUncompleted";
// 逾期完成
public static final String OVERDUE_COMPLETED = "overdueCompleted";
}

View File

@ -0,0 +1,71 @@
package com.ruoyi.dashboard.task.service;
import java.util.Arrays;
import java.util.List;
import com.ruoyi.common.utils.bean.BeanUtils;
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.service.TaskService;
import com.ruoyi.common.vo.StringIntegerVO;
import com.ruoyi.dashboard.index.domain.brief.TaskBriefVO;
import com.ruoyi.dashboard.task.domain.brief.TaskBriefKeys;
@Service
public class DashboardTaskService {
@Autowired
private TaskService taskService;
public TaskBriefVO selectTaskBrief(TaskQuery query, String ...keys) {
TaskBriefVO vo = new TaskBriefVO();
if (keys != null) {
List<String> keyList = Arrays.asList(keys);
if (keyList.contains(TaskBriefKeys.STATUS)) {
List<StringIntegerVO> statusMap = taskService.selectCountGroupByStatus(query);
vo.setStatusGroup(statusMap);
}
if (keyList.contains(TaskBriefKeys.TYPE)) {
List<StringIntegerVO> typeMap = taskService.selectCountGroupByType(query);
vo.setTypeGroup(typeMap);
}
if (keyList.contains(TaskBriefKeys.OVERDUE_UNCOMPLETED)) {
vo.setOverdueUncompleted(this.selectCountOverdueUncompleted(query));
}
if (keyList.contains(TaskBriefKeys.OVERDUE_COMPLETED)) {
vo.setOverdueCompleted(this.selectCountOverdueCompleted(query));
}
}
return vo;
}
/**
* 查询逾期未完成任务数
* @param taskQuery
* @return
*/
private int selectCountOverdueUncompleted(TaskQuery taskQuery) {
TaskQuery query = new TaskQuery();
BeanUtils.copyBeanProp(query, taskQuery);
query.setStatusList(TaskStatus.unComplete());
query.setOverdue(true);
return taskService.selectCount(query);
}
/**
* 查询逾期完成任务数
* @param taskQuery
* @return
*/
private int selectCountOverdueCompleted(TaskQuery taskQuery) {
TaskQuery query = new TaskQuery();
BeanUtils.copyBeanProp(query, taskQuery);
query.setStatusList(TaskStatus.complete());
query.setOverdue(true);
return taskService.selectCount(query);
}
}

View File

@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.bst.customer.domain.Customer;
import com.ruoyi.bst.customer.domain.CustomerQuery;
import com.ruoyi.bst.customer.domain.CustomerVO;
import com.ruoyi.bst.customer.domain.dto.CustomerAddDTO;
import com.ruoyi.bst.customer.service.CustomerConverter;
import com.ruoyi.bst.customer.service.CustomerService;
import com.ruoyi.common.annotation.Log;
@ -98,9 +99,9 @@ public class CustomerController extends BaseController
@PreAuthorize("@ss.hasPermi('bst:customer:add')")
@Log(title = "客户", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) Customer customer)
public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) CustomerAddDTO customer)
{
customer = customerConverter.toPoByCreate(customer);
customer = customerConverter.toDTOByCreate(customer);
return toAjax(customerService.insertCustomer(customer));
}

View File

@ -85,7 +85,6 @@ public class CustomerFollowController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) CustomerFollow customerFollow)
{
customerFollow.setUserId(getUserId());
return toAjax(customerFollowService.insertCustomerFollow(customerFollow));
}

View File

@ -61,7 +61,8 @@ public class ProjectController extends BaseController
{
startPage();
startOrderBy();
List<ProjectVO> list = projectService.selectProjectListScope(query);
query.setScope(true);
List<ProjectVO> list = projectService.selectProjectList(query);
projectAssembler.assembleTaskCount(list);
projectAssembler.assembleTaskPassCount(list);
projectAssembler.assembleTaskWaitConfirmCount(list);

View File

@ -65,7 +65,8 @@ public class TaskController extends BaseController
{
startPage();
startOrderBy();
List<TaskVO> list = taskService.selectTaskListScope(query);
query.setScope(true);
List<TaskVO> list = taskService.selectTaskList(query);
taskAssembler.assembleOwnerList(list);
return getDataTable(list);
}

View File

@ -5,9 +5,19 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.bst.customer.domain.CustomerQuery;
import com.ruoyi.bst.project.domain.ProjectQuery;
import com.ruoyi.bst.task.domain.TaskQuery;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.dashboard.customer.service.DashboardCustomerService;
import com.ruoyi.dashboard.index.domain.brief.BriefQuery;
import com.ruoyi.dashboard.index.domain.brief.BriefVO;
import com.ruoyi.dashboard.index.service.DashboardService;
import com.ruoyi.dashboard.project.domain.brief.ProjectBriefKeys;
import com.ruoyi.dashboard.project.service.DashboardProjectService;
import com.ruoyi.dashboard.task.domain.brief.TaskBriefKeys;
import com.ruoyi.dashboard.task.service.DashboardTaskService;
@RestController
@RequestMapping("/dashboard")
@ -16,12 +26,63 @@ public class DashboardController extends BaseController {
@Autowired
private DashboardService dashboardService;
// 获取首页统计数据
@Autowired
private DashboardProjectService dashboardProjectService;
@Autowired
private DashboardTaskService dashboardTaskService;
@Autowired
private DashboardCustomerService dashboardCustomerService;
// 获取本人的统计数据
@GetMapping("/mineBrief")
public AjaxResult mineBrief(BriefQuery query) {
query.setJoinUserId(getUserId());
query.setScope(true);
BriefVO result = new BriefVO();
// 项目概览
ProjectQuery projectQuery = query.toProjectQuery();
result.setProject(dashboardProjectService.selectProjectBrief(projectQuery, ProjectBriefKeys.STATUS));
// 任务概览
TaskQuery taskQuery = query.toTaskQuery();
result.setTask(dashboardTaskService.selectTaskBrief(taskQuery, TaskBriefKeys.STATUS));
// 客户概览
CustomerQuery customerQuery = query.toCustomerQuery();
result.setCustomer(dashboardCustomerService.selectCustomerBrief(customerQuery));
return AjaxResult.success(result);
}
// 获取统计数据
@GetMapping("/brief")
public AjaxResult brief() {
return AjaxResult.success(dashboardService.selectBrief());
public AjaxResult brief(BriefQuery query) {
BriefVO result = new BriefVO();
// 项目概览
ProjectQuery projectQuery = query.toProjectQuery();
result.setProject(dashboardProjectService.selectProjectBrief(projectQuery,
ProjectBriefKeys.STATUS,
ProjectBriefKeys.DEV_COMPLETED,
ProjectBriefKeys.OVERDUE_DEV_UNCOMPLETED,
ProjectBriefKeys.OVERDUE_DEV_COMPLETED
));
// 任务概览
TaskQuery taskQuery = query.toTaskQuery();
result.setTask(dashboardTaskService.selectTaskBrief(taskQuery,
TaskBriefKeys.STATUS,
TaskBriefKeys.TYPE,
TaskBriefKeys.OVERDUE_UNCOMPLETED,
TaskBriefKeys.OVERDUE_COMPLETED
));
return AjaxResult.success(result);
}
}

View File

@ -0,0 +1,45 @@
package com.ruoyi.web.dashboard;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.bst.customer.domain.CustomerQuery;
import com.ruoyi.bst.customer.service.CustomerService;
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.service.DashboardCustomerService;
@RestController
@RequestMapping("/dashboard/customer")
public class DashboardCustomerController extends BaseController {
@Autowired
private DashboardCustomerService dashboardCustomerService;
@Autowired
private CustomerService customerService;
// 查询每日创建客户统计
@GetMapping("/dailyCreateCount")
public AjaxResult dailyCreateCount(CustomerQuery query) {
List<LocalDateIntegerVO> list = customerService.selectDailyCreateCount(query);
if (query.getCreateDateRange() != null && query.getCreateDateRange().size() > 1) {
list = CollectionUtils.fillVoids(list, LocalDateIntegerVO::getKey, (date) -> {
LocalDateIntegerVO vo = new LocalDateIntegerVO();
vo.setKey(date);
vo.setValue(0);
return vo;
}, query.getCreateDateRange().get(0), query.getCreateDateRange().get(1));
}
return success(list);
}
}

View File

@ -0,0 +1,18 @@
package com.ruoyi.web.dashboard;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.dashboard.task.service.DashboardTaskService;
@RestController
@RequestMapping("/dashboard/task")
public class DashboardTaskController extends BaseController {
@Autowired
private DashboardTaskService dashboardTaskService;
}