提交
This commit is contained in:
parent
0abdb3fe32
commit
99834c633a
|
@ -17,6 +17,13 @@
|
|||
|
||||
<dependencies>
|
||||
|
||||
<!-- 七牛云上传 -->
|
||||
<dependency>
|
||||
<groupId>com.qiniu</groupId>
|
||||
<artifactId>qiniu-java-sdk</artifactId>
|
||||
<version>[7.13.0, 7.13.99]</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 微信小程序 -->
|
||||
<dependency>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
package com.ruoyi.common.utils.qiniu;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.qiniu.http.Response;
|
||||
import com.qiniu.storage.Configuration;
|
||||
import com.qiniu.storage.Region;
|
||||
import com.qiniu.storage.UploadManager;
|
||||
import com.qiniu.storage.model.DefaultPutRet;
|
||||
import com.qiniu.util.Auth;
|
||||
import com.qiniu.util.StringMap;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import org.springframework.util.Base64Utils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 七牛云工具类
|
||||
* @author wjh
|
||||
* 2024/3/26
|
||||
*/
|
||||
public class QiNiuUtils {
|
||||
public static final String ACCESS_KEY = SpringUtils.getRequiredProperty("qiniu.accessKey");
|
||||
public static final String SECRET_KEY = SpringUtils.getRequiredProperty("qiniu.secretKey");
|
||||
public static final String BUCKET = SpringUtils.getRequiredProperty("qiniu.bucket");
|
||||
public static final Long EXPIRE_SECONDS = Long.parseLong(SpringUtils.getRequiredProperty("qiniu.expireSeconds")); // 过期时间(秒)
|
||||
public static final String DOMAIN = SpringUtils.getRequiredProperty("qiniu.domain"); // 外链域名
|
||||
private static final String CACHE_KEY = SpringUtils.getRequiredProperty("qiniu.cacheKey"); // 缓存key
|
||||
private static final Configuration CFG;
|
||||
private static final UploadManager UPLOAD_MANAGER;
|
||||
private static final RedisCache REDIS_CACHE = SpringUtils.getBean(RedisCache.class);
|
||||
|
||||
static {
|
||||
// zone0华东区域,zone1是华北区域,zone2是华南区域
|
||||
CFG = new Configuration(Region.region2());
|
||||
UPLOAD_MANAGER = new UploadManager(CFG);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件上传的token
|
||||
* @return token
|
||||
*/
|
||||
public static String getToken() {
|
||||
String tokenCache = REDIS_CACHE.getCacheObject(CACHE_KEY);
|
||||
if (tokenCache == null) {
|
||||
StringMap putPolicy = new StringMap();
|
||||
Auth auth = Auth.create(ACCESS_KEY, SECRET_KEY);
|
||||
tokenCache = auth.uploadToken(BUCKET,null, EXPIRE_SECONDS, putPolicy);
|
||||
REDIS_CACHE.setCacheObject(CACHE_KEY, tokenCache, EXPIRE_SECONDS.intValue(), TimeUnit.SECONDS);
|
||||
}
|
||||
return tokenCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将文件上传到七牛云
|
||||
*/
|
||||
public static String upload(FileInputStream fileStream) throws Exception {
|
||||
// 生成上传凭证,然后准备上传
|
||||
Response response = UPLOAD_MANAGER.put(fileStream, null, getToken(), null, null);
|
||||
// 解析上传成功的结果
|
||||
DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
|
||||
return putRet.key;
|
||||
}
|
||||
|
||||
public static String upload(MultipartFile file) throws Exception {
|
||||
File tempFile = File.createTempFile("temp-", "." + FileUploadUtils.getExtension(file));
|
||||
file.transferTo(tempFile);
|
||||
try (FileInputStream fis = new FileInputStream(tempFile)){
|
||||
return upload(fis);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64上传到七牛云
|
||||
* @param base64
|
||||
* @return
|
||||
*/
|
||||
public static String uploadBase64(String base64) throws Exception{
|
||||
byte[] bytes = base64.getBytes();
|
||||
byte[] decode = Base64Utils.decode(bytes);
|
||||
Response response = UPLOAD_MANAGER.put(decode, null, getToken());
|
||||
// 解析上传成功的结果
|
||||
DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
|
||||
return putRet.key;
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package com.ruoyi.bst.dashboard.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BriefVO {
|
||||
|
||||
@ApiModelProperty("项目概览")
|
||||
ProjectBriefVO project;
|
||||
|
||||
@ApiModelProperty("任务概览")
|
||||
TaskBriefVO task;
|
||||
|
||||
@ApiModelProperty("客户概览")
|
||||
CustomerBriefVO customer;
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
package com.ruoyi.bst.dashboard.domain.vo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.bst.customer.domain.enums.CustomerStatus;
|
||||
import com.ruoyi.common.vo.StringIntegerVO;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class CustomerBriefVO {
|
||||
|
||||
@ApiModelProperty("客户总数")
|
||||
private Integer total;
|
||||
|
||||
@ApiModelProperty("今日新增客户数")
|
||||
private Integer today;
|
||||
|
||||
@ApiModelProperty("潜在客户")
|
||||
private Integer potential;
|
||||
|
||||
@ApiModelProperty("意向客户")
|
||||
private Integer intention;
|
||||
|
||||
@ApiModelProperty("已成交")
|
||||
private Integer transaction;
|
||||
|
||||
@ApiModelProperty("失效客户")
|
||||
private Integer invalid;
|
||||
|
||||
public CustomerBriefVO(List<StringIntegerVO> statusMap) {
|
||||
this.potential = statusMap.stream()
|
||||
.filter(vo -> CustomerStatus.POTENTIAL.getStatus().equals(vo.getKey()))
|
||||
.findFirst().map(StringIntegerVO::getValue).orElse(0);
|
||||
|
||||
this.intention = statusMap.stream()
|
||||
.filter(vo -> CustomerStatus.INTENTION.getStatus().equals(vo.getKey()))
|
||||
.findFirst().map(StringIntegerVO::getValue).orElse(0);
|
||||
|
||||
this.transaction = statusMap.stream()
|
||||
.filter(vo -> CustomerStatus.TRANSACTION.getStatus().equals(vo.getKey()))
|
||||
.findFirst().map(StringIntegerVO::getValue).orElse(0);
|
||||
|
||||
this.invalid = statusMap.stream()
|
||||
.filter(vo -> CustomerStatus.INVALID.getStatus().equals(vo.getKey()))
|
||||
.findFirst().map(StringIntegerVO::getValue).orElse(0);
|
||||
|
||||
this.total = statusMap.stream().map(map -> map.getValue()).reduce(0, Integer::sum);
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package com.ruoyi.bst.dashboard.domain.vo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.bst.project.domain.enums.ProjectStatus;
|
||||
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("已完成")
|
||||
private Integer completed;
|
||||
|
||||
@ApiModelProperty("进行中")
|
||||
private Integer inProgress;
|
||||
|
||||
@ApiModelProperty("维护中")
|
||||
private Integer maintenance;
|
||||
|
||||
@ApiModelProperty("开发超期")
|
||||
private Integer developmentOverdue;
|
||||
|
||||
@ApiModelProperty("维护超期")
|
||||
private Integer maintenanceOverdue;
|
||||
|
||||
public ProjectBriefVO(List<StringIntegerVO> statusMap) {
|
||||
this.completed = statusMap.stream()
|
||||
.filter(vo -> ProjectStatus.COMPLETED.getStatus().equals(vo.getKey()))
|
||||
.findFirst().map(StringIntegerVO::getValue).orElse(0);
|
||||
|
||||
this.inProgress = statusMap.stream()
|
||||
.filter(vo -> ProjectStatus.IN_PROGRESS.getStatus().equals(vo.getKey()))
|
||||
.findFirst().map(StringIntegerVO::getValue).orElse(0);
|
||||
|
||||
this.maintenance = statusMap.stream()
|
||||
.filter(vo -> ProjectStatus.MAINTENANCE.getStatus().equals(vo.getKey()))
|
||||
.findFirst().map(StringIntegerVO::getValue).orElse(0);
|
||||
|
||||
this.developmentOverdue = statusMap.stream()
|
||||
.filter(vo -> ProjectStatus.DEVELOPMENT_OVERDUE.getStatus().equals(vo.getKey()))
|
||||
.findFirst().map(StringIntegerVO::getValue).orElse(0);
|
||||
|
||||
this.maintenanceOverdue = statusMap.stream()
|
||||
.filter(vo -> ProjectStatus.MAINTENANCE_OVERDUE.getStatus().equals(vo.getKey()))
|
||||
.findFirst().map(StringIntegerVO::getValue).orElse(0);
|
||||
|
||||
this.total = statusMap.stream().map(StringIntegerVO::getValue).reduce(0, Integer::sum);
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package com.ruoyi.bst.dashboard.domain.vo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.bst.task.domain.enums.TaskStatus;
|
||||
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;
|
||||
|
||||
public TaskBriefVO(List<StringIntegerVO> statusMap) {
|
||||
this.waitCompleted = statusMap.stream()
|
||||
.filter(vo -> TaskStatus.WAIT_COMPLETED.getStatus().equals(vo.getKey()))
|
||||
.findFirst().map(StringIntegerVO::getValue).orElse(0);
|
||||
|
||||
this.inProgress = statusMap.stream()
|
||||
.filter(vo -> TaskStatus.PROCESSING.getStatus().equals(vo.getKey()))
|
||||
.findFirst().map(StringIntegerVO::getValue).orElse(0);
|
||||
|
||||
this.waitConfirm = statusMap.stream()
|
||||
.filter(vo -> TaskStatus.WAIT_CONFIRM.getStatus().equals(vo.getKey()))
|
||||
.findFirst().map(StringIntegerVO::getValue).orElse(0);
|
||||
|
||||
this.completed = statusMap.stream()
|
||||
.filter(vo -> TaskStatus.PASS.getStatus().equals(vo.getKey()))
|
||||
.findFirst().map(StringIntegerVO::getValue).orElse(0);
|
||||
|
||||
this.total = statusMap.stream().map(StringIntegerVO::getValue).reduce(0, Integer::sum);
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
package com.ruoyi.bst.dashboard.mapper;
|
||||
|
||||
import com.ruoyi.bst.dashboard.domain.vo.ProjectBriefVO;
|
||||
|
||||
public interface DashboardMapper {
|
||||
|
||||
ProjectBriefVO selectProjectBrief();
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
<?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.bst.dashboard.mapper.DashboardMapper">
|
||||
|
||||
<resultMap id="ProjectBriefVO" type="ProjectBriefVO">
|
||||
<result column="total_count" property="totalCount" typeHandler="com.ruoyi.common.mybatis.typehandler.NonNullIntegerTyperHandler"/>
|
||||
<result column="finished_count" property="finishedCount" typeHandler="com.ruoyi.common.mybatis.typehandler.NonNullIntegerTyperHandler"/>
|
||||
<result column="processing_count" property="processingCount" typeHandler="com.ruoyi.common.mybatis.typehandler.NonNullIntegerTyperHandler"/>
|
||||
<result column="overdue_count" property="overdueCount" typeHandler="com.ruoyi.common.mybatis.typehandler.NonNullIntegerTyperHandler"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectProjectBrief" resultMap="ProjectBriefVO">
|
||||
select
|
||||
count(*) as total_count,
|
||||
sum(case when bp.status = '2' then 1 else 0 end) as finished_count,
|
||||
sum(case when bp.status = '1' then 1 else 0 end) as processing_count,
|
||||
sum(case when bp.status = '4' then 1 else 0 end) as overdue_count
|
||||
from bst_project bp
|
||||
<where>
|
||||
<include refid="com.ruoyi.bst.project.mapper.ProjectMapper.searchCondition"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -1,63 +0,0 @@
|
|||
package com.ruoyi.bst.dashboard.service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
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.bst.dashboard.domain.vo.BriefVO;
|
||||
import com.ruoyi.bst.dashboard.domain.vo.CustomerBriefVO;
|
||||
import com.ruoyi.bst.dashboard.domain.vo.ProjectBriefVO;
|
||||
import com.ruoyi.bst.dashboard.domain.vo.TaskBriefVO;
|
||||
import com.ruoyi.bst.project.domain.ProjectQuery;
|
||||
import com.ruoyi.bst.project.service.ProjectService;
|
||||
import com.ruoyi.bst.task.domain.TaskQuery;
|
||||
import com.ruoyi.bst.task.service.TaskService;
|
||||
import com.ruoyi.common.vo.StringIntegerVO;
|
||||
|
||||
@Service
|
||||
public class DashboardService {
|
||||
@Autowired
|
||||
private ProjectService projectService;
|
||||
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
|
||||
@Autowired
|
||||
private CustomerService customerService;
|
||||
|
||||
|
||||
public BriefVO selectBrief() {
|
||||
BriefVO result = new BriefVO();
|
||||
|
||||
// 项目概览
|
||||
List<StringIntegerVO> projectMap = projectService.selectCountGroupByStatus(new ProjectQuery());
|
||||
ProjectBriefVO projectBriefVO = new ProjectBriefVO(projectMap);
|
||||
result.setProject(projectBriefVO);
|
||||
|
||||
// 任务概览
|
||||
List<StringIntegerVO> taskMap = taskService.selectCountGroupByStatus(new TaskQuery());
|
||||
TaskBriefVO taskBriefVO = new TaskBriefVO(taskMap);
|
||||
result.setTask(taskBriefVO);
|
||||
|
||||
// 客户概览
|
||||
List<StringIntegerVO> customerMap = customerService.selectCountGroupByStatus(new CustomerQuery());
|
||||
CustomerBriefVO customerBriefVO = new CustomerBriefVO(customerMap);
|
||||
// 今日新增客户
|
||||
customerBriefVO.setToday(this.selectTodayCustomerCount());
|
||||
result.setCustomer(customerBriefVO);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private int selectTodayCustomerCount() {
|
||||
CustomerQuery query = new CustomerQuery();
|
||||
query.setCreateDate(LocalDate.now());
|
||||
return customerService.selectCount(query);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -99,4 +99,8 @@ public class Project extends BaseEntity
|
|||
@Excel(name = "维护到期日期", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
@ApiModelProperty("维护到期日期")
|
||||
private LocalDate maintenanceEndDate;
|
||||
|
||||
@Excel(name = "开发是否超期")
|
||||
@ApiModelProperty("开发是否超期")
|
||||
private Boolean devOverdue;
|
||||
}
|
||||
|
|
|
@ -20,4 +20,13 @@ public class ProjectQuery extends ProjectVO {
|
|||
|
||||
@ApiModelProperty("状态列表")
|
||||
private List<String> statusList;
|
||||
|
||||
@ApiModelProperty("创建年份")
|
||||
private Integer createYear;
|
||||
|
||||
@ApiModelProperty("完成年份")
|
||||
private Integer completeYear;
|
||||
|
||||
@ApiModelProperty("开始年份")
|
||||
private Integer startYear;
|
||||
}
|
||||
|
|
|
@ -21,4 +21,13 @@ public class ProjectVO extends Project{
|
|||
|
||||
@ApiModelProperty("客户名称")
|
||||
private String customerName;
|
||||
|
||||
@ApiModelProperty("任务总数量(需组装)")
|
||||
private Integer taskCount;
|
||||
|
||||
@ApiModelProperty("任务通过数量(需组装)")
|
||||
private Integer taskPassCount;
|
||||
|
||||
@ApiModelProperty("任务待确认数量(需组装)")
|
||||
private Integer taskWaitConfirmCount;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.ruoyi.bst.project.domain.enums;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
|
@ -52,4 +54,18 @@ public enum ProjectStatus {
|
|||
public static List<String> canMaintenance() {
|
||||
return Arrays.asList(ACCEPTED.getStatus(), MAINTENANCE_OVERDUE.getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成的项目状态
|
||||
* @return
|
||||
*/
|
||||
public static List<String> completedList() {
|
||||
return CollectionUtils.map(ProjectStatus::getStatus,
|
||||
COMPLETED,
|
||||
ACCEPTED,
|
||||
MAINTENANCE,
|
||||
MAINTENANCE_OVERDUE
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.ruoyi.bst.project.domain.Project;
|
|||
import com.ruoyi.bst.project.domain.ProjectQuery;
|
||||
import com.ruoyi.bst.project.domain.ProjectVO;
|
||||
import com.ruoyi.bst.project.domain.vo.ProjectNameVO;
|
||||
import com.ruoyi.common.vo.IntegerIntegerVO;
|
||||
import com.ruoyi.common.vo.StringIntegerVO;
|
||||
|
||||
/**
|
||||
|
@ -86,4 +87,25 @@ public interface ProjectMapper
|
|||
* @return 结果
|
||||
*/
|
||||
int updateByQuery(@Param("data") Project data, @Param("query") ProjectQuery query);
|
||||
|
||||
/**
|
||||
* 按创建月份分组查询数量
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
List<IntegerIntegerVO> selectCountGroupByCreateMonth(@Param("query") ProjectQuery query);
|
||||
|
||||
/**
|
||||
* 按完成月份分组查询数量
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
List<IntegerIntegerVO> selectCountGroupByCompleteMonth(@Param("query") ProjectQuery query);
|
||||
|
||||
/**
|
||||
* 按开始月份分组查询数量
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
List<IntegerIntegerVO> selectCountGroupByStartMonth(@Param("query") ProjectQuery query);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bp.expected_complete_date,
|
||||
bp.start_time,
|
||||
bp.accept_time,
|
||||
bp.dev_overdue,
|
||||
su.nick_name as owner_name,
|
||||
sf.nick_name as follow_name,
|
||||
sc.nick_name as create_name,
|
||||
|
@ -56,6 +57,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="query.customerName != null and query.customerName != ''"> and bc.name like concat('%', #{query.customerName}, '%')</if>
|
||||
<if test="query.excludeId != null "> and bp.id != #{query.excludeId}</if>
|
||||
<if test="query.eqNo != null and query.eqNo != ''"> and bp.no = #{query.eqNo}</if>
|
||||
<if test="query.createYear != null "> and year(bp.create_time) = #{query.createYear}</if>
|
||||
<if test="query.completeYear != null "> and year(bp.complete_time) = #{query.completeYear}</if>
|
||||
<if test="query.startYear != null "> and year(bp.start_time) = #{query.startYear}</if>
|
||||
<if test="query.devOverdue != null "> and bp.dev_overdue = #{query.devOverdue}</if>
|
||||
<if test="query.statusList != null and query.statusList.size() > 0">
|
||||
and bp.status in
|
||||
<foreach item="item" collection="query.statusList" open="(" separator="," close=")">
|
||||
|
@ -100,6 +105,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="expectedCompleteDate != null">expected_complete_date,</if>
|
||||
<if test="startTime != null">start_time,</if>
|
||||
<if test="acceptTime != null">accept_time,</if>
|
||||
<if test="devOverdue != null">dev_overdue,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="no != null and no != ''">#{no},</if>
|
||||
|
@ -122,6 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="expectedCompleteDate != null">#{expectedCompleteDate},</if>
|
||||
<if test="startTime != null">#{startTime},</if>
|
||||
<if test="acceptTime != null">#{acceptTime},</if>
|
||||
<if test="devOverdue != null">#{devOverdue},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
@ -154,6 +161,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="data.expectedCompleteDate != null">expected_complete_date = #{data.expectedCompleteDate},</if>
|
||||
<if test="data.startTime != null">start_time = #{data.startTime},</if>
|
||||
<if test="data.acceptTime != null">accept_time = #{data.acceptTime},</if>
|
||||
<if test="data.devOverdue != null">dev_overdue = #{data.devOverdue},</if>
|
||||
</sql>
|
||||
|
||||
<update id="logicDel" parameterType="String">
|
||||
|
@ -205,4 +213,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
</update>
|
||||
|
||||
<!-- selectCountGroupByCreateMonth -->
|
||||
|
||||
<select id="selectCountGroupByCreateMonth">
|
||||
select
|
||||
month(bp.create_time) as `key`,
|
||||
count(bp.id) as `value`
|
||||
from bst_project bp
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
group by `key`
|
||||
</select>
|
||||
|
||||
<!-- selectCountGroupByCompleteMonth -->
|
||||
|
||||
<select id="selectCountGroupByCompleteMonth">
|
||||
select
|
||||
month(bp.complete_time) as `key`,
|
||||
count(bp.id) as `value`
|
||||
from bst_project bp
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
group by `key`
|
||||
</select>
|
||||
|
||||
<!-- selectCountGroupByStartMonth -->
|
||||
|
||||
<select id="selectCountGroupByStartMonth">
|
||||
select
|
||||
month(bp.start_time) as `key`,
|
||||
count(bp.id) as `value`
|
||||
from bst_project bp
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
group by `key`
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -8,6 +8,7 @@ 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.vo.IntegerIntegerVO;
|
||||
import com.ruoyi.common.vo.StringIntegerVO;
|
||||
|
||||
/**
|
||||
|
@ -106,4 +107,24 @@ public interface ProjectService
|
|||
* @return
|
||||
*/
|
||||
int maintenance(ProjectMaintenanceDTO dto);
|
||||
|
||||
/**
|
||||
* 按创建月份分组查询数量
|
||||
* @param query
|
||||
*/
|
||||
List<IntegerIntegerVO> selectCountGroupByCreateMonth(ProjectQuery query);
|
||||
|
||||
/**
|
||||
* 按完成月份分组查询数量
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
List<IntegerIntegerVO> selectCountGroupByCompleteMonth(ProjectQuery query);
|
||||
|
||||
/**
|
||||
* 按开始月份分组查询数量
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
List<IntegerIntegerVO> selectCountGroupByStartMonth(ProjectQuery query);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.ruoyi.common.utils.DateUtils;
|
|||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.SnowFlakeUtil;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.common.vo.IntegerIntegerVO;
|
||||
import com.ruoyi.common.vo.StringIntegerVO;
|
||||
|
||||
/**
|
||||
|
@ -234,4 +235,19 @@ public class ProjectServiceImpl implements ProjectService
|
|||
query.setStatusList(ProjectStatus.canMaintenance());
|
||||
return this.updateByQuery(data, query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IntegerIntegerVO> selectCountGroupByCreateMonth(ProjectQuery query) {
|
||||
return projectMapper.selectCountGroupByCreateMonth(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IntegerIntegerVO> selectCountGroupByCompleteMonth(ProjectQuery query) {
|
||||
return projectMapper.selectCountGroupByCompleteMonth(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IntegerIntegerVO> selectCountGroupByStartMonth(ProjectQuery query) {
|
||||
return projectMapper.selectCountGroupByStartMonth(query);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,4 +78,32 @@ public class Task extends BaseEntity
|
|||
@ApiModelProperty("描述")
|
||||
@Size(max = 1000, message = "描述长度不能超过1000个字符")
|
||||
private String description;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "预计完成时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("预计完成时间")
|
||||
private LocalDateTime expectFinishTime;
|
||||
|
||||
|
||||
@Excel(name = "最后一次审核记录ID")
|
||||
@ApiModelProperty("最后一次审核记录ID")
|
||||
private Long verifyId;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "通过时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("通过时间")
|
||||
private LocalDateTime passTime;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "取消时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("取消时间")
|
||||
private LocalDateTime cancelTime;
|
||||
|
||||
@Excel(name = "取消操作人ID")
|
||||
@ApiModelProperty("取消操作人ID")
|
||||
private Long cancelUserId;
|
||||
|
||||
@Excel(name = "取消备注")
|
||||
@ApiModelProperty("取消备注")
|
||||
private String cancelRemark;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,17 @@
|
|||
package com.ruoyi.bst.task.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TaskQuery extends TaskVO{
|
||||
|
||||
@ApiModelProperty("项目id列表")
|
||||
private List<Long> projectIds;
|
||||
|
||||
@ApiModelProperty("状态列表")
|
||||
private List<String> statusList;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package com.ruoyi.bst.task.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.bst.taskSubmit.domain.TaskSubmitVO;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
|
@ -15,4 +19,9 @@ public class TaskVO extends Task{
|
|||
@ApiModelProperty(value = "负责人名称")
|
||||
private String ownerName;
|
||||
|
||||
@ApiModelProperty(value = "取消人名称")
|
||||
private String cancelUserName;
|
||||
|
||||
@ApiModelProperty(value = "提交列表")
|
||||
private List<TaskSubmitVO> submitList;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package com.ruoyi.bst.task.domain.enums;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
|
@ -11,8 +15,38 @@ public enum TaskStatus {
|
|||
PROCESSING("2", "进行中"),
|
||||
WAIT_CONFIRM("3", "待确认"),
|
||||
PASS("4", "通过"),
|
||||
REJECT("5", "驳回");
|
||||
REJECT("5", "驳回"),
|
||||
CANCEL("6", "取消");
|
||||
|
||||
private final String status;
|
||||
private final String name;
|
||||
|
||||
|
||||
/**
|
||||
* 获取可以提交的任务状态
|
||||
*/
|
||||
public static List<String> canSubmit() {
|
||||
return CollectionUtils.map(TaskStatus::getStatus, PROCESSING, REJECT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取可以开始任务的状态
|
||||
*/
|
||||
public static List<String> canStart() {
|
||||
return CollectionUtils.map(TaskStatus::getStatus, WAIT_COMPLETED, CANCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取可以审核的任务状态
|
||||
*/
|
||||
public static List<String> canVerify() {
|
||||
return CollectionUtils.map(TaskStatus::getStatus, WAIT_CONFIRM);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取可以取消的任务状态
|
||||
*/
|
||||
public static List<String> canCancel() {
|
||||
return CollectionUtils.map(TaskStatus::getStatus, WAIT_COMPLETED, PROCESSING, REJECT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.LongIntegerVO;
|
||||
import com.ruoyi.common.vo.StringIntegerVO;
|
||||
|
||||
/**
|
||||
|
@ -63,4 +64,26 @@ public interface TaskMapper
|
|||
* @return
|
||||
*/
|
||||
List<StringIntegerVO> selectCountGroupByStatus(@Param("query") TaskQuery query);
|
||||
|
||||
/**
|
||||
* 查询任务数量
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
int selectCount(@Param("query") TaskQuery query);
|
||||
|
||||
/**
|
||||
* 查询任务数量
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
List<LongIntegerVO> selectCountGroupByProject(@Param("query") TaskQuery query);
|
||||
|
||||
/**
|
||||
* 根据条件更新任务
|
||||
* @param data
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
int updateByQuery(@Param("data") Task data, @Param("query") TaskQuery query);
|
||||
}
|
||||
|
|
|
@ -21,13 +21,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
bt.owner_id,
|
||||
bt.deleted,
|
||||
bt.description,
|
||||
bt.expect_finish_time,
|
||||
bt.pass_time,
|
||||
bt.verify_id,
|
||||
bt.cancel_time,
|
||||
bt.cancel_user_id,
|
||||
bt.cancel_remark,
|
||||
bp.name as project_name,
|
||||
su.nick_name as create_name,
|
||||
ou.nick_name as owner_name
|
||||
ou.nick_name as owner_name,
|
||||
cu.nick_name as cancel_user_name
|
||||
from bst_task bt
|
||||
left join bst_project bp on bt.project_id = bp.id
|
||||
left join sys_user su on bt.create_id = su.user_id
|
||||
left join sys_user ou on bt.owner_id = ou.user_id
|
||||
left join sys_user cu on bt.cancel_user_id = cu.user_id
|
||||
</sql>
|
||||
|
||||
<sql id="searchCondition">
|
||||
|
@ -44,7 +52,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="query.projectName != null and query.projectName != ''"> and bp.name like concat('%', #{query.projectName}, '%')</if>
|
||||
<if test="query.createName != null and query.createName != ''"> and su.nick_name like concat('%', #{query.createName}, '%')</if>
|
||||
<if test="query.ownerName != null and query.ownerName != ''"> and ou.nick_name like concat('%', #{query.ownerName}, '%')</if>
|
||||
<if test="query.description != null and query.description != ''"> and bt.description like concat('%', #{query.description}, '%')</if>
|
||||
<if test="query.description != null and query.description != ''"> and bt.description like concat('%', #{query.description}, '%')</if> <if test="query.verifyId != null"> and bt.verify_id = #{query.verifyId}</if>
|
||||
<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.statusList != null and query.statusList.size() > 0">
|
||||
and bt.status in
|
||||
<foreach item="item" collection="query.statusList" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
${query.params.dataScope}
|
||||
</sql>
|
||||
|
||||
|
@ -75,6 +92,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="ownerId != null">owner_id,</if>
|
||||
<if test="description != null and description != ''">`description`,</if>
|
||||
<if test="deleted != null">deleted,</if>
|
||||
<if test="expectFinishTime != null">expect_finish_time,</if>
|
||||
<if test="passTime != null">pass_time,</if>
|
||||
<if test="verifyId != null">verify_id,</if>
|
||||
<if test="cancelTime != null">cancel_time,</if>
|
||||
<if test="cancelUserId != null">cancel_user_id,</if>
|
||||
<if test="cancelRemark != null and cancelRemark != ''">cancel_remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="projectId != null">#{projectId},</if>
|
||||
|
@ -89,6 +112,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="ownerId != null">#{ownerId},</if>
|
||||
<if test="description != null and description != ''">#{description},</if>
|
||||
<if test="deleted != null">#{deleted},</if>
|
||||
<if test="expectFinishTime != null">#{expectFinishTime},</if>
|
||||
<if test="passTime != null">#{passTime},</if>
|
||||
<if test="verifyId != null">#{verifyId},</if>
|
||||
<if test="cancelTime != null">#{cancelTime},</if>
|
||||
<if test="cancelUserId != null">#{cancelUserId},</if>
|
||||
<if test="cancelRemark != null and cancelRemark != ''">#{cancelRemark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
@ -113,22 +142,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="data.ownerId != null">owner_id = #{data.ownerId},</if>
|
||||
<if test="data.deleted != null">deleted = #{data.deleted},</if>
|
||||
<if test="data.description != null and data.description != ''">description = #{data.description},</if>
|
||||
<if test="data.expectFinishTime != null">expect_finish_time = #{data.expectFinishTime},</if>
|
||||
<if test="data.passTime != null">pass_time = #{data.passTime},</if>
|
||||
<if test="data.verifyId != null">verify_id = #{data.verifyId},</if>
|
||||
<if test="data.cancelTime != null">cancel_time = #{data.cancelTime},</if>
|
||||
<if test="data.cancelUserId != null">cancel_user_id = #{data.cancelUserId},</if>
|
||||
<if test="data.cancelRemark != null and data.cancelRemark != ''">cancel_remark = #{data.cancelRemark},</if>
|
||||
</sql>
|
||||
|
||||
<delete id="logicDel" parameterType="String">
|
||||
update bst_task
|
||||
set deleted = true
|
||||
where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
and deleted = false
|
||||
</delete>
|
||||
|
||||
<!-- selectCountGroupByStatus -->
|
||||
<!-- selectCountGroupByStatus -->
|
||||
|
||||
<select id="selectCountGroupByStatus" parameterType="TaskQuery" resultMap="com.ruoyi.common.mapper.CommonMapper.StringIntegerVO">
|
||||
select
|
||||
select
|
||||
bt.status as `key`,
|
||||
count(bt.id) as `value`
|
||||
from bst_task bt
|
||||
|
@ -137,5 +172,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</where>
|
||||
group by `key`
|
||||
</select>
|
||||
|
||||
|
||||
<!-- selectCount -->
|
||||
|
||||
<select id="selectCount" parameterType="TaskQuery" resultType="Integer">
|
||||
select count(bt.id)
|
||||
from bst_task bt
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- selectCountGroupByProject -->
|
||||
|
||||
<select id="selectCountGroupByProject" parameterType="TaskQuery" resultMap="com.ruoyi.common.mapper.CommonMapper.LongIntegerVO">
|
||||
select
|
||||
bt.project_id as `key`,
|
||||
count(bt.id) as `value`
|
||||
from bst_task bt
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
group by `key`
|
||||
</select>
|
||||
|
||||
<!-- updateByQuery -->
|
||||
|
||||
<update id="updateByQuery">
|
||||
update bst_task bt
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<include refid="updateColumns"/>
|
||||
</trim>
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
|
@ -5,6 +5,11 @@ import java.util.List;
|
|||
import com.ruoyi.bst.task.domain.Task;
|
||||
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.TaskStartDTO;
|
||||
import com.ruoyi.bst.task.domain.dto.TaskSubmitDTO;
|
||||
import com.ruoyi.bst.task.domain.dto.TaskVerifyDTO;
|
||||
import com.ruoyi.common.vo.LongIntegerVO;
|
||||
import com.ruoyi.common.vo.StringIntegerVO;
|
||||
|
||||
/**
|
||||
|
@ -61,4 +66,46 @@ public interface TaskService
|
|||
* @return
|
||||
*/
|
||||
List<StringIntegerVO> selectCountGroupByStatus(TaskQuery query);
|
||||
|
||||
/**
|
||||
* 查询任务数量
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
public int selectCount(TaskQuery query);
|
||||
|
||||
/**
|
||||
* 查询任务数量
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
List<LongIntegerVO> selectCountGroupByProject(TaskQuery query);
|
||||
|
||||
/**
|
||||
* 提交任务
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
int submitTask(TaskSubmitDTO dto);
|
||||
|
||||
/**
|
||||
* 开始任务
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
int startTask(TaskStartDTO dto);
|
||||
|
||||
/**
|
||||
* 审核任务
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
int verifyTask(TaskVerifyDTO dto);
|
||||
|
||||
/**
|
||||
* 取消任务
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
int cancelTask(TaskCancelDTO dto);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ public class TaskConverterImpl implements TaskConverter {
|
|||
po.setCreateId(SecurityUtils.getUserId());
|
||||
po.setExpireTime(data.getExpireTime());
|
||||
po.setOwnerId(data.getOwnerId());
|
||||
po.setDescription(data.getDescription());
|
||||
return po;
|
||||
}
|
||||
|
||||
|
@ -46,6 +47,7 @@ public class TaskConverterImpl implements TaskConverter {
|
|||
po.setPicture(data.getPicture());
|
||||
po.setExpireTime(data.getExpireTime());
|
||||
po.setOwnerId(data.getOwnerId());
|
||||
po.setDescription(data.getDescription());
|
||||
|
||||
return po;
|
||||
}
|
||||
|
|
|
@ -1,16 +1,32 @@
|
|||
package com.ruoyi.bst.task.service.impl;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import com.ruoyi.bst.task.domain.Task;
|
||||
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.TaskStartDTO;
|
||||
import com.ruoyi.bst.task.domain.dto.TaskSubmitDTO;
|
||||
import com.ruoyi.bst.task.domain.dto.TaskVerifyDTO;
|
||||
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.bst.taskSubmit.domain.TaskSubmit;
|
||||
import com.ruoyi.bst.taskSubmit.service.TaskSubmitConverter;
|
||||
import com.ruoyi.bst.taskSubmit.service.TaskSubmitService;
|
||||
import com.ruoyi.bst.verify.domain.Verify;
|
||||
import com.ruoyi.bst.verify.service.VerifyConverter;
|
||||
import com.ruoyi.bst.verify.service.VerifyService;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.vo.LongIntegerVO;
|
||||
import com.ruoyi.common.vo.StringIntegerVO;
|
||||
|
||||
/**
|
||||
|
@ -25,6 +41,21 @@ public class TaskServiceImpl implements TaskService
|
|||
@Autowired
|
||||
private TaskMapper taskMapper;
|
||||
|
||||
@Autowired
|
||||
private TransactionTemplate transactionTemplate;
|
||||
|
||||
@Autowired
|
||||
private VerifyService verifyService;
|
||||
|
||||
@Autowired
|
||||
private VerifyConverter verifyConverter;
|
||||
|
||||
@Autowired
|
||||
private TaskSubmitConverter taskSubmitConverter;
|
||||
|
||||
@Autowired
|
||||
private TaskSubmitService taskSubmitService;
|
||||
|
||||
/**
|
||||
* 查询任务
|
||||
*
|
||||
|
@ -34,6 +65,9 @@ public class TaskServiceImpl implements TaskService
|
|||
@Override
|
||||
public TaskVO selectTaskById(Long id)
|
||||
{
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
return taskMapper.selectTaskById(id);
|
||||
}
|
||||
|
||||
|
@ -90,4 +124,143 @@ public class TaskServiceImpl implements TaskService
|
|||
public List<StringIntegerVO> selectCountGroupByStatus(TaskQuery query) {
|
||||
return taskMapper.selectCountGroupByStatus(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int selectCount(TaskQuery query) {
|
||||
return taskMapper.selectCount(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LongIntegerVO> selectCountGroupByProject(TaskQuery query) {
|
||||
return taskMapper.selectCountGroupByProject(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int submitTask(TaskSubmitDTO dto) {
|
||||
// 校验
|
||||
ServiceUtil.assertion(dto == null, "参数不允许为空");
|
||||
ServiceUtil.assertion(dto.getId() == null, "任务ID不允许为空");
|
||||
|
||||
TaskVO old = this.selectTaskById(dto.getId());
|
||||
ServiceUtil.assertion(old == null, "ID为%s的任务不存在", dto.getId());
|
||||
ServiceUtil.assertion(!TaskStatus.canSubmit().contains(old.getStatus()), "ID为%s的任务当前状态不允许提交", dto.getId());
|
||||
|
||||
// 更新任务状态
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
// 更新状态
|
||||
Task data = new Task();
|
||||
data.setStatus(TaskStatus.WAIT_CONFIRM.getStatus());
|
||||
TaskQuery query = new TaskQuery();
|
||||
query.setId(dto.getId());
|
||||
query.setStatusList(TaskStatus.canSubmit());
|
||||
int update = this.updateByQuery(data, query);
|
||||
ServiceUtil.assertion(update != 1, "更新ID为%s的任务状态失败", dto.getId());
|
||||
|
||||
// 新增提交记录
|
||||
TaskSubmit submit = taskSubmitConverter.toPo(dto);
|
||||
int insertSubmit = taskSubmitService.insertTaskSubmit(submit);
|
||||
ServiceUtil.assertion(insertSubmit != 1, "新增提交记录失败");
|
||||
|
||||
return update;
|
||||
});
|
||||
|
||||
return result == null ? 0 : result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int startTask(TaskStartDTO dto) {
|
||||
// 校验
|
||||
ServiceUtil.assertion(dto == null, "参数不允许为空");
|
||||
ServiceUtil.assertion(dto.getId() == null, "任务ID不允许为空");
|
||||
|
||||
TaskVO old = this.selectTaskById(dto.getId());
|
||||
ServiceUtil.assertion(old == null, "ID为%s的任务不存在", dto.getId());
|
||||
ServiceUtil.assertion(!TaskStatus.canStart().contains(old.getStatus()), "ID为%s的任务当前状态不允许开始", dto.getId());
|
||||
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
Task data = new Task();
|
||||
data.setStatus(TaskStatus.PROCESSING.getStatus());
|
||||
data.setExpectFinishTime(dto.getExpectFinishTime());
|
||||
TaskQuery query = new TaskQuery();
|
||||
query.setId(dto.getId());
|
||||
query.setStatusList(TaskStatus.canStart());
|
||||
int update = this.updateByQuery(data, query);
|
||||
ServiceUtil.assertion(update != 1, "更新ID为%s的任务状态失败", dto.getId());
|
||||
|
||||
return update;
|
||||
});
|
||||
|
||||
return result == null ? 0 : result;
|
||||
}
|
||||
|
||||
private int updateByQuery(Task data, TaskQuery query) {
|
||||
return taskMapper.updateByQuery(data, query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int verifyTask(TaskVerifyDTO dto) {
|
||||
// 校验
|
||||
ServiceUtil.assertion(dto == null, "参数不允许为空");
|
||||
ServiceUtil.assertion(dto.getId() == null, "任务ID不允许为空");
|
||||
|
||||
TaskVO old = this.selectTaskById(dto.getId());
|
||||
ServiceUtil.assertion(old == null, "ID为%s的任务不存在", dto.getId());
|
||||
ServiceUtil.assertion(!TaskStatus.canVerify().contains(old.getStatus()), "ID为%s的任务当前状态不允许审核", dto.getId());
|
||||
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
// 新增审核记录
|
||||
Verify verify = verifyConverter.toPo(dto);
|
||||
int insertVerify = verifyService.insertVerify(verify);
|
||||
ServiceUtil.assertion(insertVerify != 1, "新增审核记录失败");
|
||||
|
||||
// 更新任务状态
|
||||
Task data = new Task();
|
||||
if (dto.getPass() != null && dto.getPass()) {
|
||||
data.setStatus(TaskStatus.PASS.getStatus());
|
||||
data.setPassTime(LocalDateTime.now());
|
||||
} else {
|
||||
data.setStatus(TaskStatus.REJECT.getStatus());
|
||||
}
|
||||
data.setVerifyId(verify.getId());
|
||||
TaskQuery query = new TaskQuery();
|
||||
query.setId(dto.getId());
|
||||
query.setStatusList(TaskStatus.canVerify());
|
||||
int update = this.updateByQuery(data, query);
|
||||
ServiceUtil.assertion(update != 1, "更新ID为%s的任务状态失败", dto.getId());
|
||||
|
||||
return update;
|
||||
});
|
||||
|
||||
return result == null ? 0 : result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cancelTask(TaskCancelDTO dto) {
|
||||
|
||||
// 校验
|
||||
ServiceUtil.assertion(dto == null, "参数不允许为空");
|
||||
ServiceUtil.assertion(dto.getId() == null, "任务ID不允许为空");
|
||||
|
||||
TaskVO old = this.selectTaskById(dto.getId());
|
||||
ServiceUtil.assertion(old == null, "ID为%s的任务不存在", dto.getId());
|
||||
ServiceUtil.assertion(!TaskStatus.canCancel().contains(old.getStatus()), "ID为%s的任务当前状态不允许取消", dto.getId());
|
||||
|
||||
// 更新任务状态
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
Task data = new Task();
|
||||
data.setStatus(TaskStatus.CANCEL.getStatus());
|
||||
data.setCancelTime(LocalDateTime.now());
|
||||
data.setCancelRemark(dto.getCancelRemark());
|
||||
data.setCancelUserId(SecurityUtils.getUserId());
|
||||
TaskQuery query = new TaskQuery();
|
||||
query.setId(dto.getId());
|
||||
query.setStatusList(TaskStatus.canCancel());
|
||||
int update = this.updateByQuery(data, query);
|
||||
ServiceUtil.assertion(update != 1, "更新ID为%s的任务状态失败", dto.getId());
|
||||
|
||||
return update;
|
||||
});
|
||||
|
||||
return result == null ? 0 : result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,4 +13,9 @@
|
|||
<result property="value" column="value" typeHandler="com.ruoyi.common.mybatis.typehandler.NonNullIntegerTyperHandler"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="LongIntegerVO" type="com.ruoyi.common.vo.LongIntegerVO">
|
||||
<result property="key" column="key"/>
|
||||
<result property="value" column="value" typeHandler="com.ruoyi.common.mybatis.typehandler.NonNullIntegerTyperHandler"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package com.ruoyi.common.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2025/2/7
|
||||
*/
|
||||
@Data
|
||||
public class IntegerIntegerVO {
|
||||
private Integer key;
|
||||
private Integer value;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.ruoyi.dashboard.index.mapper;
|
||||
|
||||
import com.ruoyi.dashboard.index.domain.brief.ProjectBriefVO;
|
||||
|
||||
public interface DashboardMapper {
|
||||
|
||||
}
|
|
@ -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.index.mapper.DashboardMapper">
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,41 @@
|
|||
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.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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.ruoyi.dashboard.project.mapper;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2025/2/7
|
||||
*/
|
||||
public interface DashboardProjectMapper {
|
||||
}
|
|
@ -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.project.mapper.DashboardProjectMapper">
|
||||
|
||||
</mapper>
|
|
@ -21,6 +21,7 @@ import com.ruoyi.bst.project.domain.ProjectQuery;
|
|||
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.service.ProjectAssembler;
|
||||
import com.ruoyi.bst.project.service.ProjectConverter;
|
||||
import com.ruoyi.bst.project.service.ProjectService;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
|
@ -47,6 +48,9 @@ public class ProjectController extends BaseController
|
|||
@Autowired
|
||||
private ProjectConverter projectConverter;
|
||||
|
||||
@Autowired
|
||||
private ProjectAssembler projectAssembler;
|
||||
|
||||
/**
|
||||
* 查询项目列表
|
||||
*/
|
||||
|
@ -57,6 +61,9 @@ public class ProjectController extends BaseController
|
|||
startPage();
|
||||
startOrderBy();
|
||||
List<ProjectVO> list = projectService.selectProjectList(query);
|
||||
projectAssembler.assembleTaskCount(list);
|
||||
projectAssembler.assembleTaskPassCount(list);
|
||||
projectAssembler.assembleTaskWaitConfirmCount(list);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.web.bst;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -19,8 +20,14 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import com.ruoyi.bst.task.domain.Task;
|
||||
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.TaskStartDTO;
|
||||
import com.ruoyi.bst.task.domain.dto.TaskSubmitDTO;
|
||||
import com.ruoyi.bst.task.domain.dto.TaskVerifyDTO;
|
||||
import com.ruoyi.bst.task.service.TaskAssembler;
|
||||
import com.ruoyi.bst.task.service.TaskConverter;
|
||||
import com.ruoyi.bst.task.service.TaskService;
|
||||
import com.ruoyi.bst.task.service.TaskValidator;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
|
@ -45,6 +52,12 @@ public class TaskController extends BaseController
|
|||
@Autowired
|
||||
private TaskConverter taskConverter;
|
||||
|
||||
@Autowired
|
||||
private TaskValidator taskValidator;
|
||||
|
||||
@Autowired
|
||||
private TaskAssembler taskAssembler;
|
||||
|
||||
/**
|
||||
* 查询任务列表
|
||||
*/
|
||||
|
@ -78,7 +91,10 @@ public class TaskController extends BaseController
|
|||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(taskService.selectTaskById(id));
|
||||
TaskVO task = taskService.selectTaskById(id);
|
||||
List<TaskVO> list = Collections.singletonList(task);
|
||||
taskAssembler.assembleSubmitList(list);
|
||||
return success(task);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,4 +131,56 @@ public class TaskController extends BaseController
|
|||
{
|
||||
return toAjax(taskService.logicDel(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始任务
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bst:task:start')")
|
||||
@Log(title = "任务", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/start")
|
||||
public AjaxResult start(@RequestBody @Validated TaskStartDTO dto) {
|
||||
// 校验当前用户能否开始任务
|
||||
if (!taskValidator.allowStart(dto.getId(), getUserId())) {
|
||||
return error("您不是任务的负责人,不能开始任务");
|
||||
}
|
||||
return toAjax(taskService.startTask(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交任务
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bst:task:submit')")
|
||||
@Log(title = "任务", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/submit")
|
||||
public AjaxResult submit(@RequestBody @Validated TaskSubmitDTO dto) {
|
||||
// 校验当前用户能否提交任务
|
||||
if (!taskValidator.allowSubmit(dto.getId(), getUserId())) {
|
||||
return error("您不是任务的负责人,不能提交任务");
|
||||
}
|
||||
|
||||
return toAjax(taskService.submitTask(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME 审核任务
|
||||
* TODO 需要移动到taskSubmit模块
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bst:task:verify')")
|
||||
@Log(title = "任务", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/verify")
|
||||
public AjaxResult verify(@RequestBody @Validated TaskVerifyDTO dto) {
|
||||
return toAjax(taskService.verifyTask(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消任务
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bst:task:cancel')")
|
||||
@Log(title = "任务", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/cancel")
|
||||
public AjaxResult cancel(@RequestBody @Validated TaskCancelDTO dto) {
|
||||
return toAjax(taskService.cancelTask(dto));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package com.ruoyi.web.common;
|
||||
|
||||
import com.ruoyi.common.config.RuoYiConfig;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||
import com.ruoyi.common.utils.file.FileUtils;
|
||||
import com.ruoyi.framework.config.ServerConfig;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -17,10 +16,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.config.RuoYiConfig;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||
import com.ruoyi.common.utils.file.FileUtils;
|
||||
import com.ruoyi.common.utils.qiniu.QiNiuUtils;
|
||||
import com.ruoyi.framework.config.ServerConfig;
|
||||
|
||||
/**
|
||||
* 通用请求处理
|
||||
|
@ -161,4 +164,12 @@ public class CommonController
|
|||
log.error("下载文件失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取七牛云token
|
||||
*/
|
||||
@GetMapping("/qiniuToken")
|
||||
public AjaxResult getQiniuToken() {
|
||||
return AjaxResult.success("操作成功", QiNiuUtils.getToken());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,27 @@
|
|||
package com.ruoyi.web.bst;
|
||||
package com.ruoyi.web.dashboard;
|
||||
|
||||
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.dashboard.service.DashboardService;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.dashboard.index.service.DashboardService;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/bst/dashboard")
|
||||
@RequestMapping("/dashboard")
|
||||
public class DashboardController extends BaseController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private DashboardService dashboardService;
|
||||
|
||||
// 获取首页统计数据
|
||||
@GetMapping("/brief")
|
||||
public AjaxResult brief() {
|
||||
return AjaxResult.success(dashboardService.selectBrief());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -101,3 +101,18 @@ lock:
|
|||
timeout: 60
|
||||
# 重试次数
|
||||
retry: 3
|
||||
|
||||
# 七牛云配置
|
||||
qiniu:
|
||||
# 七牛云key
|
||||
accessKey: MI4PDg9LYWXJyahzx5ec6-Ih0YNwQhew_BQUhttS
|
||||
# 七牛云密钥
|
||||
secretKey: Lk3fHHEnJuf0jD_Zte1xhtv7BTvjvmaWVCKd7O0J
|
||||
# 七牛云命名空间
|
||||
bucket: smartmeter
|
||||
# 过期时间(秒)
|
||||
expireSeconds: 600
|
||||
# 七牛云GET请求域名
|
||||
domain: https://api.ccttiot.com
|
||||
# 七牛云token缓存
|
||||
cacheKey: qiniu-token
|
||||
|
|
Loading…
Reference in New Issue
Block a user