Kaynağa Gözat

任务列表

tags/v1.0.0^2
chengwang 1 yıl önce
ebeveyn
işleme
5c1f9b7cd6
2 değiştirilmiş dosya ile 68 ekleme ve 5 silme
  1. +29
    -5
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryNewInspectionListService.java
  2. +39
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/InspectionListVo.java

+ 29
- 5
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryNewInspectionListService.java Dosyayı Görüntüle

@@ -12,15 +12,19 @@ import com.tuoheng.admin.mapper.InspectionFileMapper;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.mapper.UserMapper;
import com.tuoheng.admin.query.InspectionFileQuery;
import com.tuoheng.admin.vo.InspectionListVo;
import com.tuoheng.common.core.enums.ServiceExceptionEnum;
import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Stream;

/**
* @Author ChengWang
@@ -60,19 +64,27 @@ public class QueryNewInspectionListService {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
//若角色为超级管理员,查询任务表最新五条数据
if(UserTypeEnum.SUPER_ADMIN.getCode()==user.getType()){
if(UserTypeEnum.SUPER_ADMIN.getCode()==user.getType()) {
List<Inspection> inspectionList = inspectionMapper.selectList(Wrappers.<Inspection>lambdaQuery()
.eq(Inspection::getTenantId, tenantId)
.eq(Inspection::getMark, 1)
.orderByDesc(Inspection::getCreateTime)
.last("limit 5"));
if(inspectionList==null){
if (inspectionList == null) {
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
return JsonResult.success(inspectionList);
if (UserTypeEnum.SUPER_ADMIN.getCode() == user.getType() || UserTypeEnum.ORDINARY_USER.getCode() == user.getType()) {
Stream<InspectionListVo> inspections = this.getInspectionListVoStream(inspectionList);

return JsonResult.success(inspections);

}
}


//若角色为部门管理员或普通用户,查询最新五条数据
if(UserTypeEnum.SUPER_ADMIN.getCode()==user.getType() || UserTypeEnum.ORDINARY_USER.getCode()==user.getType()){
if(UserTypeEnum.ADMIN.getCode()==user.getType() || UserTypeEnum.ORDINARY_USER.getCode()==user.getType()){

if(StringUtils.isEmpty(deptId)){
JsonResult.error(QueryInspectionListServiceEnum.DEPT_ID_IS_NULL.getCode(),QueryInspectionListServiceEnum.DEPT_ID_IS_NULL.getMsg());
}
@@ -85,9 +97,21 @@ public class QueryNewInspectionListService {
if(inspectionList==null){
throw new ServiceException(ServiceExceptionEnum.PARAMETER_IS_NULL);
}
return JsonResult.success(inspectionList);
Stream<InspectionListVo> inspectionListVoStream = this.getInspectionListVoStream(inspectionList);

return JsonResult.success(inspectionListVoStream);

}

return JsonResult.error();
}

private Stream<InspectionListVo> getInspectionListVoStream(List<Inspection> inspectionList) {
return inspectionList.stream().map(x -> {
InspectionListVo vo = new InspectionListVo();
BeanUtils.copyProperties(x, vo);
return vo;
});

}
}

+ 39
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/InspectionListVo.java Dosyayı Görüntüle

@@ -0,0 +1,39 @@
package com.tuoheng.admin.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
* @Author ChengWang
* @Date 2022/12/5
*/
@Data
public class InspectionListVo {

/**
* 任务id
*/
private String id;

/**
* 任务名称
*/
private String name;

/**
* 执行时间
*/
@DateTimeFormat(pattern = "yyyy/MM/dd")
@JsonFormat(pattern = "yyyy/MM/dd", timezone = "GMT+8")
private Date executionStartTime;

/**
* 执行人
*/
private String createUser;


}

Yükleniyor…
İptal
Kaydet