提交 99f3b55e authored 作者: 邓砥奕's avatar 邓砥奕

更新业务查询

上级 89a22fd8
...@@ -16,14 +16,32 @@ ...@@ -16,14 +16,32 @@
<dependency> <dependency>
<groupId>com.tykj.dev</groupId> <groupId>com.tykj.dev</groupId>
<artifactId>device-user</artifactId> <artifactId>device-user</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-allot</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tykj.dev</groupId> <groupId>com.tykj.dev</groupId>
<artifactId>device-library</artifactId> <artifactId>device-library</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-allot</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tykj.dev</groupId> <groupId>com.tykj.dev</groupId>
<artifactId>device-task</artifactId> <artifactId>device-task</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-allot</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
...@@ -14,18 +14,42 @@ ...@@ -14,18 +14,42 @@
<dependency> <dependency>
<groupId>com.tykj.dev</groupId> <groupId>com.tykj.dev</groupId>
<artifactId>device-user</artifactId> <artifactId>device-user</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-apply</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tykj.dev</groupId> <groupId>com.tykj.dev</groupId>
<artifactId>device-task</artifactId> <artifactId>device-task</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-apply</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tykj.dev</groupId> <groupId>com.tykj.dev</groupId>
<artifactId>device-allot</artifactId> <artifactId>device-allot</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-apply</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tykj.dev</groupId> <groupId>com.tykj.dev</groupId>
<artifactId>device-library</artifactId> <artifactId>device-library</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-apply</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -12,6 +12,12 @@ ...@@ -12,6 +12,12 @@
<dependency> <dependency>
<groupId>com.tykj.dev</groupId> <groupId>com.tykj.dev</groupId>
<artifactId>device-user</artifactId> <artifactId>device-user</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-library</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
</dependencies> </dependencies>
<artifactId>device-library</artifactId> <artifactId>device-library</artifactId>
......
...@@ -2,6 +2,7 @@ package com.tykj.dev.device.library.service; ...@@ -2,6 +2,7 @@ package com.tykj.dev.device.library.service;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary; import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo; import com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo;
import com.tykj.dev.device.library.subject.vo.DeviceStatisticsVo;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
...@@ -11,9 +12,8 @@ import java.util.List; ...@@ -11,9 +12,8 @@ import java.util.List;
* @author dengdiyi * @author dengdiyi
*/ */
public interface DeviceLibraryService { public interface DeviceLibraryService {
DeviceLibrary addEntity(DeviceLibrary deviceLibraryEntity);
List<DeviceLibrary> addEntityList(List<DeviceLibrary> list); DeviceLibrary addEntity(DeviceLibrary deviceLibraryEntity);
Page<DeviceLibrary> getPage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable); Page<DeviceLibrary> getPage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable);
...@@ -23,7 +23,7 @@ public interface DeviceLibraryService { ...@@ -23,7 +23,7 @@ public interface DeviceLibraryService {
Page<DeviceLibrary> getCoreDevicePage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable); Page<DeviceLibrary> getCoreDevicePage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable);
// Page<DeviceLibrary> getDeviceStatisticsPage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable); Page<DeviceStatisticsVo> getDeviceStatisticsPage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable);
List<String> getAllName(); List<String> getAllName();
......
package com.tykj.dev.device.library.subject.Dto; package com.tykj.dev.device.library.subject.Dto;
import com.tykj.dev.device.library.subject.domin.DeviceLog; import com.tykj.dev.device.library.subject.domin.DeviceLog;
import com.tykj.dev.device.library.subject.vo.DeviceLogUserVo;
import com.tykj.dev.device.library.subject.vo.FileVo; import com.tykj.dev.device.library.subject.vo.FileVo;
import com.tykj.dev.device.user.subject.service.UserPublicService;
import com.tykj.dev.misc.base.BeanHelper;
import com.tykj.dev.misc.utils.SpringUtils;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.modelmapper.ModelMapper;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -75,4 +80,20 @@ public class DeviceLogDto { ...@@ -75,4 +80,20 @@ public class DeviceLogDto {
this.remark = remark; this.remark = remark;
this.fileVoList = fileVoList; this.fileVoList = fileVoList;
} }
/**
* dto类转化为vo类
*/
public DeviceLogUserVo toVo(){
UserPublicService userPublicService = SpringUtils.getBean("userPublicServiceImpl");
//复制相同属性
ModelMapper modelMapper = BeanHelper.getUserMapper();
DeviceLogUserVo deviceLogUserVo = modelMapper.map(this,DeviceLogUserVo.class);
//set vo字段
if (userPublicService!=null){
deviceLogUserVo.setUser(userPublicService.getOne(this.createUserId).getName());
deviceLogUserVo.setUnit(userPublicService.findUnitsNameByUserId(this.createUserId));
}
return deviceLogUserVo;
}
} }
...@@ -89,18 +89,6 @@ public class DeviceLog { ...@@ -89,18 +89,6 @@ public class DeviceLog {
@ApiModelProperty(value = "删除标记(0:未删除,1:已删除)") @ApiModelProperty(value = "删除标记(0:未删除,1:已删除)")
private Integer deleteTag = 0; private Integer deleteTag = 0;
@ApiModelProperty(value = "操作用户")
@Transient
private String user;
@ApiModelProperty(value = "操作单位")
@Transient
private String unit;
@ApiModelProperty(value = "附件信息")
@Transient
private List<FileVo> fileVoList;
/** /**
* do类转化为dto类 * do类转化为dto类
*/ */
......
...@@ -18,7 +18,7 @@ public class DeviceDetailVo { ...@@ -18,7 +18,7 @@ public class DeviceDetailVo {
private List<DeviceLibrary> deviceList; private List<DeviceLibrary> deviceList;
private List<DeviceLog> deviceLogEntityList; private List<DeviceLogUserVo> deviceLogEntityList;
private String imageName; private String imageName;
......
package com.tykj.dev.device.library.subject.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DeviceLogUserVo {
@ApiModelProperty(name = "主键id")
private Integer id;
@ApiModelProperty(value = "业务id")
private Integer taskId;
@ApiModelProperty(value = "操作描述")
private String remark;
@ApiModelProperty(value = "附件信息")
private List<FileVo> fileVoList;
@ApiModelProperty(value = "操作用户")
private String user;
@ApiModelProperty(value = "操作单位")
private String unit;
@ApiModelProperty(value = "操作时间")
private Date createTime;
}
...@@ -14,7 +14,14 @@ ...@@ -14,7 +14,14 @@
<dependency> <dependency>
<groupId>com.tykj.dev</groupId> <groupId>com.tykj.dev</groupId>
<artifactId>device-task</artifactId> <artifactId>device-task</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-packing</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
...@@ -55,7 +55,6 @@ public class PackingLibraryServiceImpl implements PackingLibraryService { ...@@ -55,7 +55,6 @@ public class PackingLibraryServiceImpl implements PackingLibraryService {
packingLibraryEntity -> Optional.ofNullable(nodeCollect.get(packingLibraryEntity.getPartParentId())), packingLibraryEntity -> Optional.ofNullable(nodeCollect.get(packingLibraryEntity.getPartParentId())),
PackingLibrary::addChildNode PackingLibrary::addChildNode
); );
return packingLibraryEntityList; return packingLibraryEntityList;
} }
......
...@@ -14,10 +14,22 @@ ...@@ -14,10 +14,22 @@
<dependency> <dependency>
<groupId>com.tykj.dev</groupId> <groupId>com.tykj.dev</groupId>
<artifactId>device-library</artifactId> <artifactId>device-library</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-selfcheck</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tykj.dev</groupId> <groupId>com.tykj.dev</groupId>
<artifactId>device-task</artifactId> <artifactId>device-task</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-selfcheck</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -15,14 +15,32 @@ ...@@ -15,14 +15,32 @@
<dependency> <dependency>
<groupId>com.tykj.dev</groupId> <groupId>com.tykj.dev</groupId>
<artifactId>device-library</artifactId> <artifactId>device-library</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-storage</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tykj.dev</groupId> <groupId>com.tykj.dev</groupId>
<artifactId>device-packing</artifactId> <artifactId>device-packing</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-storage</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tykj.dev</groupId> <groupId>com.tykj.dev</groupId>
<artifactId>device-task</artifactId> <artifactId>device-task</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-storage</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
...@@ -20,10 +20,22 @@ ...@@ -20,10 +20,22 @@
<dependency> <dependency>
<groupId>com.tykj.dev</groupId> <groupId>com.tykj.dev</groupId>
<artifactId>device-user</artifactId> <artifactId>device-user</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-task</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tykj.dev</groupId> <groupId>com.tykj.dev</groupId>
<artifactId>device-library</artifactId> <artifactId>device-library</artifactId>
<exclusions>
<exclusion>
<groupId>com.tykj.dev</groupId>
<artifactId>device-task</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -97,4 +97,10 @@ public interface TaskService { ...@@ -97,4 +97,10 @@ public interface TaskService {
* 获取跟踪和待办业务列表 * 获取跟踪和待办业务列表
*/ */
List<TaskUserVo> getList(TaskSelectVo taskSelectVo); List<TaskUserVo> getList(TaskSelectVo taskSelectVo);
/**
* @param taskSelectVo
* 获取业务管理中的业务列表
*/
List<TaskUserVo> getManageList(TaskSelectVo taskSelectVo);
} }
package com.tykj.dev.device.task.service.impl; package com.tykj.dev.device.task.service.impl;
import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications; import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.device.task.repository.TaskDao; import com.tykj.dev.device.task.repository.TaskDao;
import com.tykj.dev.device.task.repository.TaskLogDao; import com.tykj.dev.device.task.repository.TaskLogDao;
...@@ -17,12 +18,14 @@ import com.tykj.dev.device.user.util.UserUtils; ...@@ -17,12 +18,14 @@ import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.exception.ApiException; import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.utils.ResultUtil; import com.tykj.dev.misc.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import javax.persistence.Transient;
import java.lang.reflect.Field;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* @author dengdiyi * @author dengdiyi
...@@ -280,6 +283,97 @@ public class TaskServiceImpl implements TaskService { ...@@ -280,6 +283,97 @@ public class TaskServiceImpl implements TaskService {
return taskEntities; return taskEntities;
} }
/**
* @param taskSelectVo 获取业务管理中的业务列表
*/
@Override
public List<TaskUserVo> getManageList(TaskSelectVo taskSelectVo) {
Integer num = taskSelectVo.getSelectNum();
Integer userId = userUtils.getCurrentUserId();
//业务管理中的待办和跟踪
if (num==2||num==3){
//查询出符合筛选条件的所有task
List<TaskUserVo> list = taskDao.findAll(getSelectSpecification(taskSelectVo)).stream()
.map(Task::parse2Bto)
.map(TaskBto::toVo)
.collect(Collectors.toList());
//查询当前用户的跟踪和待办并和list按id取交集
List<TaskUserVo> taskUserVos = getList(taskSelectVo).stream()
.filter(taskUserVo -> find(taskUserVo.getId(),list)>-1)
.collect(Collectors.toList());
//判断是否需要按发起时间排序
if (taskSelectVo.getOrders()!=null) {
if ("createTime".equals(taskSelectVo.getOrders().get(0).getCoulmn())) {
if ("ASC".equals(taskSelectVo.getOrders().get(0).getDirection().toString())) {
return taskUtils.orderByCreateTimeAsc2(taskUserVos);
}
if ("DESC".equals(taskSelectVo.getOrders().get(0).getDirection().toString())) {
return taskUtils.orderByCreateTimeDesc2(taskUserVos);
}
}
}
return taskUserVos;
}
if (num==4||num==5||num==1||num==0) {
//获取单位等级
Integer level = userUtils.getCurrentUnitLevel();
//获取该单位以及下属单位所有用户Id
List<Integer> idLists = userPublicService.findAllUserIdByUnitsName(userUtils.getCurrentUserUnitName());
List<TaskUserVo> taskUserVos = new ArrayList<>();
//省能看到所有业务
if (level==1) {
taskUserVos = taskDao.findAll(getSelectSpecification(taskSelectVo)).stream()
.map(Task::parse2Bto)
.map(TaskBto::toVo)
.collect(Collectors.toList());
}
//市或县只能看到涉及人员和idLists有交集的
if (level==2||level==3){
taskUserVos = taskDao.findAll(getSelectSpecification(taskSelectVo)).stream()
.map(Task::parse2Bto)
.map(TaskBto::toVo)
.filter(taskUserVo -> !Collections.disjoint(idLists, taskUserVo.getInvolveUserIdList()))
.collect(Collectors.toList());
}
//set经办人,置顶以及阅读情况
for (TaskUserVo taskUserVo:taskUserVos) {
List<Integer> idList = taskUserVo.getUserReadDetailList();
List<Integer> idList2 = taskUserVo.getTopFlagDetailList();
if (taskUserVo.getInvolveUserIdList() != null && taskUserVo.getInvolveUserIdList().size() > 0) {
//筛选出userId大于0的
List<Integer> userIds = taskUserVo.getInvolveUserIdList().stream().filter(integer -> integer > 0).collect(Collectors.toList());
if (userIds.size() > 0) {
//List最后一个id即为最新经办人
taskUserVo.setProcessingUser(userPublicService.getOne(userIds.get(userIds.size() - 1)).getName());
}
}
//判断当前用户是否已读
if (idList.contains(userId)) {
taskUserVo.setIsRead(1);
}
//判断当前用户是否置顶
if (idList2.contains(userId)) {
taskUserVo.setIsTop(1);
}
}
//判断是否需要按发起时间排序
if (taskSelectVo.getOrders()!=null) {
if ("createTime".equals(taskSelectVo.getOrders().get(0).getCoulmn())) {
if ("ASC".equals(taskSelectVo.getOrders().get(0).getDirection().toString())) {
return taskUtils.orderByCreateTimeAsc2(taskUserVos);
}
if ("DESC".equals(taskSelectVo.getOrders().get(0).getDirection().toString())) {
return taskUtils.orderByCreateTimeDesc2(taskUserVos);
}
}
}
return taskUserVos;
}
else {
throw new ApiException(ResultUtil.failed("selectNum只能为0,1,2,3,4,5"));
}
}
/** /**
* @param taskSelectVo 查询vo * @param taskSelectVo 查询vo
* 查询跟踪和待办列表 * 查询跟踪和待办列表
...@@ -423,4 +517,58 @@ public class TaskServiceImpl implements TaskService { ...@@ -423,4 +517,58 @@ public class TaskServiceImpl implements TaskService {
return null; return null;
} }
} }
/**
* @param taskSelectVo
* task查询器
*/
private Specification<Task> getSelectSpecification(TaskSelectVo taskSelectVo){
PredicateBuilder<Task> predicateBuilder = Specifications.and();
if (taskSelectVo.getBussinessType()!=null){
predicateBuilder.eq("bussinessType", taskSelectVo.getBussinessType());
}
if (taskSelectVo.getContent()!=null){
Class<Task> taskEntityClass = Task.class;
Field[] declaredFields = taskEntityClass.getDeclaredFields();
PredicateBuilder<Task> p = Specifications.or();
for (Field field : declaredFields) {
if (field.getType().equals(String.class)&&field.getAnnotation(Transient.class)==null) {
p.like(field.getName(), "%" + taskSelectVo.getContent() + "%");
}
}
predicateBuilder.predicate(p.build());
}
if (taskSelectVo.getStartTime()!=null){
predicateBuilder.gt("createTime", taskSelectVo.getStartTime());
}
if (taskSelectVo.getEndTime()!=null){
predicateBuilder.lt("createTime", taskSelectVo.getEndTime());
}
if (taskSelectVo.getSelectNum()==4){
predicateBuilder.eq("billStatus",13);
}
if (taskSelectVo.getSelectNum()==5){
predicateBuilder.eq("billStatus",14);
}
if (taskSelectVo.getSelectNum()==1){
predicateBuilder.eq("createUserId",userUtils.getCurrentUnitId());
}
return predicateBuilder.build();
}
/**
* 判断list中是否包含某个id的taskUserVo,若不存在返回-1,存在则返回第一次出现的索引值
*/
int find(Integer id,List<TaskUserVo> list){
int index = -1;
if (list!=null&&list.size()>0){
for (int i=0;i<list.size();i++){
if (list.get(i).getId().equals(id)){
index = i;
break;
}
}
}
return index;
}
} }
...@@ -5,6 +5,7 @@ import com.tykj.dev.device.task.subject.domin.Task; ...@@ -5,6 +5,7 @@ import com.tykj.dev.device.task.subject.domin.Task;
import com.tykj.dev.device.task.subject.vo.TaskUserVo; import com.tykj.dev.device.task.subject.vo.TaskUserVo;
import com.tykj.dev.device.user.subject.service.UserPublicService; import com.tykj.dev.device.user.subject.service.UserPublicService;
import com.tykj.dev.misc.base.BeanHelper; import com.tykj.dev.misc.base.BeanHelper;
import com.tykj.dev.misc.utils.SpringUtils;
import com.tykj.dev.misc.utils.StringSplitUtil; import com.tykj.dev.misc.utils.StringSplitUtil;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
...@@ -13,6 +14,7 @@ import lombok.NoArgsConstructor; ...@@ -13,6 +14,7 @@ import lombok.NoArgsConstructor;
import org.modelmapper.ModelMapper; import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -23,12 +25,8 @@ import java.util.List; ...@@ -23,12 +25,8 @@ import java.util.List;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@Repository
public class TaskBto { public class TaskBto {
@Autowired
private UserPublicService userPublicService;
@ApiModelProperty(value = "主键id") @ApiModelProperty(value = "主键id")
private Integer id; private Integer id;
...@@ -97,11 +95,14 @@ public class TaskBto { ...@@ -97,11 +95,14 @@ public class TaskBto {
* bto类转化为vo类 * bto类转化为vo类
*/ */
public TaskUserVo toVo(){ public TaskUserVo toVo(){
UserPublicService userPublicService = SpringUtils.getBean("userPublicServiceImpl");
//复制相同属性 //复制相同属性
ModelMapper modelMapper = BeanHelper.getUserMapper(); ModelMapper modelMapper = BeanHelper.getUserMapper();
TaskUserVo taskUserVo = modelMapper.map(this,TaskUserVo.class); TaskUserVo taskUserVo = modelMapper.map(this,TaskUserVo.class);
//set vo字段 //set vo字段
taskUserVo.setStartUnit(userPublicService.findUnitsNameByUserId(this.createUserId)); if (userPublicService != null) {
taskUserVo.setStartUnit(userPublicService.findUnitsNameByUserId(this.createUserId));
}
taskUserVo.setStatus(GlobalMap.getStatusEnumMap().get(this.billStatus).name); taskUserVo.setStatus(GlobalMap.getStatusEnumMap().get(this.billStatus).name);
return taskUserVo; return taskUserVo;
} }
......
...@@ -2,10 +2,15 @@ package com.tykj.dev.device.task.subject.bto; ...@@ -2,10 +2,15 @@ package com.tykj.dev.device.task.subject.bto;
import com.tykj.dev.device.task.subject.domin.TaskLog; import com.tykj.dev.device.task.subject.domin.TaskLog;
import com.tykj.dev.device.library.subject.vo.FileVo; import com.tykj.dev.device.library.subject.vo.FileVo;
import com.tykj.dev.device.task.subject.vo.TaskLogUserVo;
import com.tykj.dev.device.user.subject.service.UserPublicService;
import com.tykj.dev.misc.base.BeanHelper;
import com.tykj.dev.misc.utils.SpringUtils;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.modelmapper.ModelMapper;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -64,4 +69,20 @@ public class TaskLogBto { ...@@ -64,4 +69,20 @@ public class TaskLogBto {
this.remark = remark; this.remark = remark;
this.fileVoList = fileVoList; this.fileVoList = fileVoList;
} }
/**
* bto类转化为vo类
*/
public TaskLogUserVo toVo(){
UserPublicService userPublicService = SpringUtils.getBean("userPublicServiceImpl");
//复制相同属性
ModelMapper modelMapper = BeanHelper.getUserMapper();
TaskLogUserVo taskLogUserVo = modelMapper.map(this,TaskLogUserVo.class);
//set vo字段
if (userPublicService!=null){
taskLogUserVo.setUser(userPublicService.getOne(this.createUserId).getName());
taskLogUserVo.setUnit(userPublicService.findUnitsNameByUserId(this.createUserId));
}
return taskLogUserVo;
}
} }
...@@ -84,18 +84,6 @@ public class TaskLog { ...@@ -84,18 +84,6 @@ public class TaskLog {
@ApiModelProperty(value = "删除标记(0:未删除,1:已删除)") @ApiModelProperty(value = "删除标记(0:未删除,1:已删除)")
private Integer deleteTag = 0; private Integer deleteTag = 0;
@ApiModelProperty(value = "操作用户")
@Transient
private String user;
@ApiModelProperty(value = "操作单位")
@Transient
private String unit;
@ApiModelProperty(value = "附件信息")
@Transient
private List<FileVo> fileVoList;
/** /**
* do类转化为bto类 * do类转化为bto类
*/ */
......
package com.tykj.dev.device.task.subject.vo;
import com.tykj.dev.device.library.subject.vo.FileVo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TaskLogUserVo {
@ApiModelProperty(name = "主键id")
private Integer id;
@ApiModelProperty(value = "业务id")
private Integer taskId;
@ApiModelProperty(value = "操作描述")
private String remark;
@ApiModelProperty(value = "附件信息")
private List<FileVo> fileVoList;
@ApiModelProperty(value = "操作用户")
private String user;
@ApiModelProperty(value = "操作单位")
private String unit;
@ApiModelProperty(value = "操作时间")
private Date createTime;
}
...@@ -4,6 +4,7 @@ import com.tykj.dev.device.task.subject.domin.TaskLog; ...@@ -4,6 +4,7 @@ import com.tykj.dev.device.task.subject.domin.TaskLog;
import com.tykj.dev.device.task.subject.vo.TaskUserVo; import com.tykj.dev.device.task.subject.vo.TaskUserVo;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
...@@ -26,6 +27,18 @@ public class TaskUtils { ...@@ -26,6 +27,18 @@ public class TaskUtils {
return list; return list;
} }
/**
* @param list 业务日志list
* 按照日志创建时间增序排列
*/
public List<TaskLog> orderByCreateTimeAsc(List<TaskLog> list){
Collections.sort(list, (o1, o2) -> {
int flag = o1.getCreateTime().compareTo(o2.getCreateTime());
return flag;
});
return list;
}
/** /**
* @param list taskUserVo list * @param list taskUserVo list
* 按照跟踪时间增序排列 * 按照跟踪时间增序排列
...@@ -73,4 +86,75 @@ public class TaskUtils { ...@@ -73,4 +86,75 @@ public class TaskUtils {
}); });
return list; return list;
} }
/**
* @param list taskUserVo list
* 按照发起时间降序排列
*/
public List<TaskUserVo> orderByCreateTimeDesc2(List<TaskUserVo> list){
Collections.sort(list, (o1, o2) -> {
int flag = o2.getCreateTime().compareTo(o1.getCreateTime());
return flag;
});
return list;
}
/**
* @param list taskUserVo list
* 按照发起时间升序排列
*/
public List<TaskUserVo> orderByCreateTimeAsc2(List<TaskUserVo> list){
Collections.sort(list, (o1, o2) -> {
int flag = o1.getCreateTime().compareTo(o2.getCreateTime());
return flag;
});
return list;
}
/**
* @param taskUserVos
* 按置顶第一顺序,未读第二顺序排序输出
*/
public List<TaskUserVo> orderByTopDescAndReadAsc(List<TaskUserVo> taskUserVos){
List<TaskUserVo> list = new ArrayList<>();
List<TaskUserVo> list1 = new ArrayList<>();
List<TaskUserVo> list2 = new ArrayList<>();
//将置顶筛选到list1
for (TaskUserVo t:taskUserVos) {
if (t.getIsTop()==1){
list1.add(t);
}
}
//list1中将未读的放在list最前面
for (TaskUserVo t:list1) {
if (t.getIsRead()==0){
list.add(t);
}
}
//list1中将已读的放在list最后面
for (TaskUserVo t:list1) {
if (t.getIsRead()==1){
list.add(t);
}
}
//将未置顶的放入list2中
for (TaskUserVo t:taskUserVos) {
if (t.getIsTop()==0){
list2.add(t);
}
}
//将未读的优先放入list中
for (TaskUserVo t:list2) {
if (t.getIsRead()==0){
list.add(t);
}
}
//将已读的放入list
for (TaskUserVo t:list2) {
if (t.getIsRead()==1){
list.add(t);
}
}
return list;
}
} }
...@@ -2,6 +2,7 @@ package com.tykj.dev.device.user.util; ...@@ -2,6 +2,7 @@ package com.tykj.dev.device.user.util;
import com.tykj.dev.device.user.subject.entity.SecurityUser; import com.tykj.dev.device.user.subject.entity.SecurityUser;
import com.tykj.dev.device.user.subject.service.UnitsService; import com.tykj.dev.device.user.subject.service.UnitsService;
import com.tykj.dev.misc.utils.SpringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -12,8 +13,7 @@ import org.springframework.stereotype.Component; ...@@ -12,8 +13,7 @@ import org.springframework.stereotype.Component;
@Component @Component
public class UserUtils { public class UserUtils {
@Autowired private UnitsService unitsService = SpringUtils.getBean("unitsServiceImpl");
private UnitsService unitsService;
public Integer getCurrentUserId(){ public Integer getCurrentUserId(){
SecurityUser authentication = AuthenticationUtils.getAuthentication(); SecurityUser authentication = AuthenticationUtils.getAuthentication();
......
package com.tykj.dev.misc.utils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import java.util.List;
/**
* @author dengdiyi
* 分页工具类
*/
public class PageUtil {
/**
* @param page 当前页数,默认0为第一页
* @param size 分页大小
* 获取分页后每一页的分页信息
*/
public static <T> Page<T> getPerPage(Integer page, Integer size, List<T> list, Pageable pageable){
//若List的size小于分页大小(只有一页)
if (list.size()<=size) {
return new PageImpl<>(list, pageable, list.size());
}
else {
//计算分了几页
double d = Math.ceil(list.size()/size.doubleValue());
int value = new Double(d).intValue();
//当前页数超出了最大页数
if (page>=value){
return null;
}
else {
//当前页的第一条记录的索引值
int index = page*size;
//当前页为最后一页
if (page==value-1){
return new PageImpl<>(list.subList(index,list.size()), pageable, list.size());
}
return new PageImpl<>(list.subList(index,index+size), pageable, list.size());
}
}
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论