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

修改返回值

上级 21dceed7
......@@ -13,6 +13,7 @@ import com.tykj.dev.device.library.subject.domin.DeviceLog;
import com.tykj.dev.device.library.subject.vo.*;
import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.utils.PageUtil;
import com.tykj.dev.misc.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -24,10 +25,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.Min;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -126,8 +124,15 @@ public class DeviceLibraryController {
@ApiOperation(value = "模糊查询核心装备分页", notes = "可以通过这个接口查询装备列表")
@PostMapping("/core/feature/summary")
public ResponseEntity selectCoreDevicePage(@RequestBody DeviceLibrarySelectVo deviceLibrarySelectVo) {
Page<DeviceVo> deviceLibraryEntities = deviceLibraryService.getCoreDevicePage(deviceLibrarySelectVo, deviceLibrarySelectVo.getPageable()).map(DeviceLibrary::parseVo);
return ResultUtil.success(deviceLibraryEntities);
List<DeviceLibrary> resultList = deviceLibraryService.getCoreDevicePage(deviceLibrarySelectVo, deviceLibrarySelectVo.getPageable());
Page<DeviceVo> deviceLibraryEntities = PageUtil.getPerPage(deviceLibrarySelectVo.getPage(), deviceLibrarySelectVo.getSize(), resultList, deviceLibrarySelectVo.getPageable()).map(DeviceLibrary::parseVo);
Map<String,Object> map = new HashMap<>();
map.put("pages",deviceLibraryEntities);
map.put("models",resultList.stream().map(DeviceLibrary::getModel).collect(Collectors.toSet()));
map.put("names",resultList.stream().map(DeviceLibrary::getName).collect(Collectors.toSet()));
map.put("ownUnits",resultList.stream().map(DeviceLibrary::getOwnUnit).collect(Collectors.toSet()));
map.put("locationUnits",resultList.stream().map(DeviceLibrary::getLocationUnit).collect(Collectors.toSet()));
return ResultUtil.success(map);
}
@ApiOperation(value = "查询存在的装备名称", notes = "可以通过这个接口查询存在的装备名称")
......@@ -152,8 +157,13 @@ public class DeviceLibraryController {
@ApiOperation(value = "模糊查询核心装备统计分页", notes = "可以通过这个接口查询装备列表")
@PostMapping("/core/stat/summary")
public ResponseEntity getDeviceStatisticsPage(@RequestBody DeviceLibrarySelectVo deviceLibrarySelectVo) {
Page<DeviceStatisticsVo> deviceStatisticsVos = deviceLibraryService.getDeviceStatisticsPage(deviceLibrarySelectVo, deviceLibrarySelectVo.getPageable());
return ResultUtil.success(deviceStatisticsVos);
List<DeviceStatisticsVo> deviceStatisticsVoList = deviceLibraryService.getDeviceStatisticsPage(deviceLibrarySelectVo, deviceLibrarySelectVo.getPageable());
Page<DeviceStatisticsVo> deviceStatisticsVos = PageUtil.getPerPage(deviceLibrarySelectVo.getPage(), deviceLibrarySelectVo.getSize(), deviceStatisticsVoList, deviceLibrarySelectVo.getPageable());
Map<String,Object> map = new HashMap<>();
map.put("pages",deviceStatisticsVos);
map.put("models",deviceStatisticsVoList.stream().map(DeviceStatisticsVo::getModel).collect(Collectors.toSet()));
map.put("names",deviceStatisticsVoList.stream().map(DeviceStatisticsVo::getName).collect(Collectors.toSet()));
return ResultUtil.success(map);
}
@ApiOperation(value = "查询核心装备详情的详情", notes = "可以通过这个接口查询核心装备详情的详情")
......
......@@ -39,13 +39,13 @@ public interface DeviceLibraryService {
* @param deviceLibrarySelectVo 装备查询vo
* @param pageable 获取核心装备分页
*/
Page<DeviceLibrary> getCoreDevicePage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable);
List<DeviceLibrary> getCoreDevicePage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable);
/**
* @param deviceLibrarySelectVo 装备查询vo
* @param pageable 获取装备统计分页
*/
Page<DeviceStatisticsVo> getDeviceStatisticsPage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable);
List<DeviceStatisticsVo> getDeviceStatisticsPage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable);
/**
* 获取所有存在的装备名称
......
......@@ -15,11 +15,9 @@ import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.utils.GetTreeUtils;
import com.tykj.dev.misc.utils.JacksonUtil;
import com.tykj.dev.misc.utils.PageUtil;
import com.tykj.dev.misc.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.ResponseEntity;
......@@ -89,7 +87,7 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
}
@Override
public Page<DeviceLibrary> getCoreDevicePage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable) {
public List<DeviceLibrary> getCoreDevicePage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable) {
Integer selectUnitId = deviceLibrarySelectVo.getUnitId();
Integer selectAreaId = deviceLibrarySelectVo.getAreaId();
//areaId为null
......@@ -112,7 +110,10 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
resultList.addAll(d.getChilds());
}
}
return PageUtil.getPerPage(deviceLibrarySelectVo.getPage(), deviceLibrarySelectVo.getSize(), resultList, pageable);
if (deviceLibrarySelectVo.getContent()!=null){
resultList = resultList.stream().filter(deviceLibrary -> deviceLibrary.getKeyWords().contains(deviceLibrarySelectVo.getContent())).collect(Collectors.toList());
}
return resultList;
}
//areId不为空,查询某个区域下的所有单位的所有装备
else {
......@@ -133,7 +134,10 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
resultList.addAll(d.getChilds());
}
}
return PageUtil.getPerPage(deviceLibrarySelectVo.getPage(), deviceLibrarySelectVo.getSize(), resultList, pageable);
if (deviceLibrarySelectVo.getContent()!=null){
resultList = resultList.stream().filter(deviceLibrary -> deviceLibrary.getKeyWords().contains(deviceLibrarySelectVo.getContent())).collect(Collectors.toList());
}
return resultList;
}
//省能看到所有装备
if (selectLevel == 1) {
......@@ -145,7 +149,10 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
resultList.addAll(d.getChilds());
}
}
return PageUtil.getPerPage(deviceLibrarySelectVo.getPage(), deviceLibrarySelectVo.getSize(), resultList, pageable);
if (deviceLibrarySelectVo.getContent()!=null){
resultList = resultList.stream().filter(deviceLibrary -> deviceLibrary.getKeyWords().contains(deviceLibrarySelectVo.getContent())).collect(Collectors.toList());
}
return resultList;
} else {
throw new ApiException(ResultUtil.failed("区域等级只能为1,2,3"));
}
......@@ -153,7 +160,7 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
}
@Override
public Page<DeviceStatisticsVo> getDeviceStatisticsPage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable) {
public List<DeviceStatisticsVo> getDeviceStatisticsPage(DeviceLibrarySelectVo deviceLibrarySelectVo, Pageable pageable) {
//获取存在的所有装备型号
// List<String> list = new ArrayList<>();
// if (deviceLibrarySelectVo.getModel() != null) {
......@@ -173,7 +180,7 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
d.setName(deviceLibrarySelectVo.getName());
d.setContent(deviceLibrarySelectVo.getContent());
//获取所有的核心装备
List<DeviceLibrary> libraryEntities = getCoreDevicePage(d, d.getPageable()).getContent();
List<DeviceLibrary> libraryEntities = getCoreDevicePage(d, d.getPageable());
if (libraryEntities.size() > 0) {
Map<String, List<DeviceLibrary>> map = libraryEntities.stream().collect(groupingBy(deviceLibrary -> deviceLibrary.getModel()+"Ǵ"+deviceLibrary.getName()));
//按型号遍历统计各种状态的装备数量
......@@ -277,9 +284,9 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
if (deviceLibrarySelectVo.getName() != null) {
deviceStatisticsVos = selectByName(deviceLibrarySelectVo.getName(), deviceStatisticsVos);
}
return PageUtil.getPerPage(deviceLibrarySelectVo.getPage(), deviceLibrarySelectVo.getSize(), deviceStatisticsVos, pageable);
return deviceStatisticsVos;
}
return new PageImpl<>(deviceStatisticsVos, pageable, deviceStatisticsVos.size());
return deviceStatisticsVos;
}
@Override
......@@ -583,7 +590,7 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
if (deviceLibrarySelectVo.getManageStatus() != null) {
predicateBuilder.eq("manageStatus", deviceLibrarySelectVo.getManageStatus());
}
if (deviceLibrarySelectVo.getLifeStatus() != null) {
if (lifeStatus != null && lifeStatus.size()>0) {
predicateBuilder.in("lifeStatus", lifeStatus.toArray(new Integer[]{}));
}
if (deviceLibrarySelectVo.getType() != null) {
......
package com.tykj.dev.device.library.subject.domin;
import com.tykj.dev.config.GlobalMap;
import com.tykj.dev.device.library.subject.vo.DeviceVo;
import com.tykj.dev.misc.base.BeanHelper;
import io.swagger.annotations.ApiModel;
......@@ -233,4 +234,24 @@ public class DeviceLibrary {
ModelMapper mapper = BeanHelper.getUserMapper();
return mapper.map(this, DeviceVo.class);
}
public String getKeyWords(){
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(this.model);
stringBuffer.append("Ǒ");
stringBuffer.append(this.name);
stringBuffer.append("Ǒ");
stringBuffer.append(this.seqNumber);
stringBuffer.append("Ǒ");
stringBuffer.append(this.rfidSurfaceId);
stringBuffer.append("Ǒ");
stringBuffer.append(this.locationUnit);
stringBuffer.append("Ǒ");
stringBuffer.append(this.ownUnit);
stringBuffer.append("Ǒ");
stringBuffer.append(GlobalMap.getDeviceLifeStatusMap().get(this.lifeStatus).name);
stringBuffer.append("Ǒ");
stringBuffer.append(this.record);
return stringBuffer.toString();
}
}
......@@ -59,4 +59,5 @@ public class DeviceVo {
@ApiModelProperty(value = "备注")
private String record;
}
......@@ -24,7 +24,7 @@ public enum DeviceLifeStatus {
/**
* 配发中
*/
IN_TRANSIT(3, "配发"),
IN_TRANSIT(3, "配发"),
/**
* 维修中
*/
......@@ -32,7 +32,7 @@ public enum DeviceLifeStatus {
/**
* 报废在省库
*/
SCRAP_I(5, "报废在省库"),
SCRAP_I(5, "已报废"),
/**
* 清退
*/
......@@ -64,7 +64,7 @@ public enum DeviceLifeStatus {
/**
* 报废不在省库
*/
SCRAP_II(13, "报废不在省库"),
SCRAP_II(13, "已报废"),
/**
* 使用
*/
......
......@@ -611,7 +611,7 @@ public class TaskServiceImpl implements TaskService {
*/
private List<TaskUserVo> getTaskUserVoList(TaskSelectVo taskSelectVo) {
Integer userId = userUtils.getCurrentUserId();
Integer bussinessType = taskSelectVo.getBusinessType();
List<Integer> bussinessType = taskSelectVo.getBusinessType();
Integer unitId = userUtils.getCurrentUnitId();
//筛选出未完结和未封存业务,映射成bto
List<TaskBto> taskBtos = taskDao.findAll().stream()
......@@ -632,12 +632,12 @@ public class TaskServiceImpl implements TaskService {
})
.collect(Collectors.toList());
//查询所有的业务
if (bussinessType == null) {
if (bussinessType == null ||bussinessType.isEmpty()) {
List<TaskUserVo> taskUserVos = taskBtoList.stream().map(TaskBto::toVo).collect(Collectors.toList());
return setTaskUserVo(taskUserVos, 0);
} else {
//查询工作台其它业务
if (bussinessType == 0) {
if (bussinessType.contains(0)) {
List<TaskUserVo> taskUserVos = taskBtoList.stream()
.filter(taskBto -> !new ArrayList<>(Arrays.asList(3, 4, 5, 6)).contains(taskBto.getBusinessType()))
.map(TaskBto::toVo)
......@@ -647,7 +647,7 @@ public class TaskServiceImpl implements TaskService {
//查询某一业务
else {
List<TaskUserVo> taskUserVos = taskBtoList.stream()
.filter(taskBto -> taskBto.getBusinessType().equals(bussinessType))
.filter(taskBto -> bussinessType.contains(taskBto.getBusinessType()))
.map(TaskBto::toVo)
.collect(Collectors.toList());
return setTaskUserVo(taskUserVos, 0);
......@@ -686,7 +686,7 @@ public class TaskServiceImpl implements TaskService {
return setTaskUserVo(taskUserVos, 1);
} else {
//查询工作台其它业务
if (bussinessType == 0) {
if (bussinessType.contains(0)) {
List<TaskUserVo> taskUserVos = taskBtoList.stream()
.filter(taskBto -> !new ArrayList<>(Arrays.asList(3, 4, 5, 6)).contains(taskBto.getBusinessType()))
.map(TaskBto::toVo)
......@@ -696,7 +696,7 @@ public class TaskServiceImpl implements TaskService {
//查询某一业务
else {
List<TaskUserVo> taskUserVos = taskBtoList.stream()
.filter(taskBto -> taskBto.getBusinessType().equals(bussinessType))
.filter(taskBto -> bussinessType.contains(taskBto.getBusinessType()))
.map(TaskBto::toVo)
.collect(Collectors.toList());
return setTaskUserVo(taskUserVos, 1);
......@@ -799,8 +799,8 @@ public class TaskServiceImpl implements TaskService {
*/
private Specification<Task> getSelectSpecification(TaskSelectVo taskSelectVo) {
PredicateBuilder<Task> predicateBuilder = Specifications.and();
if (taskSelectVo.getBusinessType() != null) {
predicateBuilder.eq("businessType", taskSelectVo.getBusinessType());
if (taskSelectVo.getBusinessType() != null && taskSelectVo.getBusinessType().size()>0) {
predicateBuilder.in("businessType", taskSelectVo.getBusinessType().toArray(new Integer[]{}));
}
if (taskSelectVo.getContent() != null) {
Class<Task> taskEntityClass = Task.class;
......
......@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @author dengdiyi
......@@ -23,6 +24,6 @@ public class TaskSelectVo extends CustomPage {
@ApiModelProperty(value = "查询方式(0:全部业务,1:我的发起,2:待办业务,3:业务跟踪,4:办结任务,5:封存业务)", example = "0")
private Integer selectNum;
@ApiModelProperty(value = "业务类型id", example = "1")
private Integer businessType;
private List<Integer> businessType;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论