提交 c163be52 authored 作者: zhoushaopan's avatar zhoushaopan

fix(装备管理模块): 解决了从其他目录进来装备的子都会增加1

解决了从其他目录进来装备的子都会增加1
上级 2d1f7be8
......@@ -439,8 +439,11 @@ public class DeviceLibraryController {
Map<String,Object> map = new HashMap<>();
// List<DeviceLibrary> resultList = deviceLibraryService.getList(deviceLibrarySelectVo);
List<DeviceLibrary> resultList = deviceLibraryService.getAlldevList(deviceLibrarySelectVo);
List<DeviceLibrary> resultList = new ArrayList<>();
resultList = deviceLibraryService.getAlldevList(deviceLibrarySelectVo);
resultList.forEach(DeviceLibrary::setConfigName);
if (hasModelDim||hasLifeStatusDim||hasLocationUnitDim||hasNameDim||hasOwnUnitDim||hasSeqDim) {
resultList = resultList.stream().filter(deviceLibrary -> {
Boolean containModelDim = !hasModelDim||deviceLibrary.getModel().contains(deviceLibrarySelectVo.getModelDim());
......@@ -454,7 +457,7 @@ public class DeviceLibraryController {
return containModelDim&&containNameDim&&containSeqDim&&containLocationUnitDim&&containOwnUnitDim&&containLifeStatusDim&&containStorageLocationDim;
}).collect(Collectors.toList());
}
Map<Integer, DeviceLibrary> nodeCollect =
Map<Integer, DeviceLibrary> nodeCollect =
resultList.stream().collect(Collectors.toMap(DeviceLibrary::getId, deviceLibraryEntity -> deviceLibraryEntity));
// List<Comparator<DeviceVo>> comparators = new ArrayList<>();
// if (deviceLibrarySelectVo.getOrders().size() > 0) {
......@@ -510,7 +513,7 @@ public class DeviceLibraryController {
Set<Integer> types = new HashSet<>();
Set<String> storageLocation = new HashSet<>();
resultList.forEach(deviceVo -> {
deviceVo.setConfigName();
// deviceVo.setConfigName();
status.add(deviceVo.getLifeStatus());
models.add(deviceVo.getModel());
names.add(deviceVo.getName());
......
package com.tykj.dev.device.library.service;
import com.tykj.dev.config.UpdateCache;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.vo.BindingDeviceVo;
import com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo;
......
......@@ -16,6 +16,7 @@ import com.tykj.dev.device.library.service.DeviceLogService;
import com.tykj.dev.device.library.subject.Dto.DeviceLogDto;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.vo.BindingDeviceVo;
import com.tykj.dev.device.library.subject.vo.DeviceLibraryCacheSelectVo;
import com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo;
import com.tykj.dev.device.library.subject.vo.DeviceStatisticsVo;
import com.tykj.dev.device.library.utils.DeviceNumberUtils;
......@@ -26,6 +27,7 @@ import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.utils.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
......@@ -1054,15 +1056,29 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
List<DeviceLibrary> deviceLibraryList = cacheLibraryService.getAllDeviceLibraryList();
List<Integer> status = new ArrayList<>(Arrays.asList(2, 11, 14));
String currentUserUnitName = userUtils.getCurrentUserUnitName();
deviceLibraryList = deviceLibraryList.stream().filter(deviceLibrary -> deviceLibrary.getOwnUnit().equals(currentUserUnitName)
&&deviceLibrary.getLocationUnit().equals(currentUserUnitName))
.filter(deviceLibrary -> status.contains(deviceLibrary.getLifeStatus()) )
.collect(Collectors.toList());
List list = null;
if (deviceLibrarySelectVo.getLifeStatus().size()>0){
List<Integer> lifeStatus = deviceLibrarySelectVo.getLifeStatus();
deviceLibraryList = deviceLibraryList.stream().filter(deviceLibrary ->
deviceLibrary.getOwnUnit().equals(currentUserUnitName) &&
deviceLibrary.getLocationUnit().equals(currentUserUnitName) &&
lifeStatus.contains(deviceLibrary.getLifeStatus()))
.collect(Collectors.toList());
}else {
deviceLibraryList = deviceLibraryList.stream().filter(deviceLibrary ->
deviceLibrary.getOwnUnit().equals(currentUserUnitName) &&
deviceLibrary.getLocationUnit().equals(currentUserUnitName) &&
status.contains(deviceLibrary.getLifeStatus()))
.collect(Collectors.toList());
}
// DeviceLibraryCacheSelectVo deviceLibraryCacheSelectVo = new DeviceLibraryCacheSelectVo();
// BeanUtils.copyProperties(deviceLibrarySelectVo,deviceLibraryCacheSelectVo);
List<DeviceLibrary> list = null;
try {
long l = System.currentTimeMillis();
list = filterFields(deviceLibraryList, deviceLibrarySelectVo);
log.info("过滤时间为:{}"+(System.currentTimeMillis()-l));
// list = filterFields2(deviceLibraryList, deviceLibraryCacheSelectVo);
log.info("过滤时间为:{}",(System.currentTimeMillis()-l));
} catch (Exception e) {
e.printStackTrace();
}
......@@ -1299,4 +1315,41 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
return list;
}
public List<DeviceLibrary> filterFields2(List<DeviceLibrary> list,DeviceLibraryCacheSelectVo params) throws Exception {
Method[] methods = params.getClass().getMethods();
// getUserName getPassWord
List<Method> useMethods = Arrays.stream(methods).filter(method -> !method.getName().equals("getClass")
&& method.getName().startsWith("get")).collect(Collectors.toList());
// Map<String,Object> filterFields = new HashMap<>();
//获取参数不为空的集合 如 username = "张三",password = "123456" age = "null"
Set<String> nameMethods = new HashSet<>();
for (DeviceLibrary deviceLibrary : list) {
for (Method declaredField : deviceLibrary.getClass().getDeclaredMethods()) {
nameMethods.add(declaredField.getName());
}
}
for (Method useMethod : useMethods) {
Object invoke = params.getClass().getMethod(useMethod.getName()).invoke(params);
//判断是否为空
if (ObjectUtil.isNotNull(invoke)) {
if (nameMethods.contains(useMethod.getName())) {
list = list.stream().filter(deviceLibrary1 -> {
try {
Object invoke1 = deviceLibrary1.getClass().getMethod(useMethod.getName())
.invoke(deviceLibrary1);
//判断是不是同一个
if (ObjectUtil.equal(invoke, invoke1) || ObjectUtil.contains(invoke1, invoke)) {
return true;
}
} catch (Exception e) {
}
return false;
}).collect(Collectors.toList());
}
}
}
return list;
}
}
......@@ -19,6 +19,7 @@ import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -33,7 +34,7 @@ import java.util.List;
@SQLDelete(sql = "update device_library set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@ApiModel("装备库")
public class DeviceLibrary {
public class DeviceLibrary implements Serializable {
/**
* 主键id
......@@ -315,6 +316,8 @@ public class DeviceLibrary {
setTypeName(configCache.getStyleMap().get(this.type)==null?"-":configCache.getStyleMap().get(this.type));
setStorageTypeName(configCache.getStorageTypeMap().get(this.storageType)==null?"-":configCache.getStorageTypeMap().get(this.storageType));
setAllotTypeName(configCache.getAllotTypeMap().get(this.allotType)==null?"-":configCache.getAllotTypeMap().get(this.allotType));
childs.clear();
// setChilds(new ArrayList<>());
}
return this;
}
......
package com.tykj.dev.device.library.subject.vo;
import com.tykj.dev.misc.base.CustomPage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @author zsp
*/
@Data
@ApiModel("装备查询类")
public class DeviceLibraryCacheSelectVo extends CustomPage {
@ApiModelProperty(value = "装备id", example = "1")
public Integer deviceId;
@ApiModelProperty(value = "操作人", example = "1")
public Integer UserAId;
@ApiModelProperty(value = "审核人", example = "1")
public Integer UserBId;
@ApiModelProperty(value = "型号", example = "bmxx")
public String model;
@ApiModelProperty(value = "类型", example = "1")
public Integer type;
@ApiModelProperty(value = "密级", example = "1")
public Integer secretLevel;
@ApiModelProperty(value = "可见范围(应用领域)", example = "1")
public Integer invisibleRange;
@ApiModelProperty(value = "名称", example = "BM-1")
public String name;
@ApiModelProperty(value = "配用范围", example = "1")
public Integer matchingRange;
@ApiModelProperty(value = "入库类型", example = "1")
public Integer storageType;
@ApiModelProperty(value = "管理状态", example = "1")
public Integer manageStatus;
@ApiModelProperty(value = "单位id", example = "1")
public Integer unitId;
@ApiModelProperty(value = "区域id", example = "1")
public Integer areaId;
@ApiModelProperty(value = "模糊查询内容", example = "测试")
public String content;
@ApiModelProperty(value = "发起时间", example = "2020-10-10 01:10:10")
public Date startTime;
@ApiModelProperty(value = "确认时间", example = "2020-10-10 01:10:10")
public Date endTime;
@ApiModelProperty(value = "列装id")
private Integer packingId;
@ApiModelProperty(value = "所在单位")
private String locationUnit;
@ApiModelProperty(value = "所属单位")
private String ownUnit;
@ApiModelProperty(value = "rfid卡号")
private String rfidCardId;
@ApiModelProperty(value = "是不是配件(0:不是,1:是)")
private Integer isPart;
@ApiModelProperty(value = "序列号区间")
private String seqInterval;
@ApiModelProperty(value = "型号模糊查询字段")
private String modelDim;
@ApiModelProperty(value = "名称模糊查询字段")
private String nameDim;
@ApiModelProperty(value = "序列号模糊查询字段")
private String seqDim;
@ApiModelProperty(value = "表面号模糊查询字段")
private String surfaceDim;
@ApiModelProperty(value = "标签编码模糊查询字段")
private String rfidCardDim;
@ApiModelProperty(value = "所在单位模糊查询字段")
private String locationUnitDim;
@ApiModelProperty(value = "所属单位模糊查询字段")
private String ownUnitDim;
@ApiModelProperty(value = "生命状态模糊查询字段")
private String lifeStatusDim;
@ApiModelProperty(value = "更新时间模糊查询字段")
private String updateTimeDim;
@ApiModelProperty(value = "创建时间模糊查询字段")
private String createTimeDim;
@ApiModelProperty(value = "更新时间年份")
private Integer year;
@ApiModelProperty(value = "查询是否打印标签(有没有表面号)装备")
private Integer isPrint;
@ApiModelProperty(value = "存储位置")
private String storageLocation;
@ApiModelProperty(value = "存储位置的模糊查询字段")
private String storageLocationDim;
@ApiModelProperty(value = "装备形态模糊查询字段")
private String typeDim;
@ApiModelProperty(value = "作为已报废,已销毁,已退役的标志位",notes = "0 代表查询 1代表查询其他")
private Integer isScraped =1;
}
......@@ -1030,11 +1030,7 @@ public class PackingLibraryServiceImpl implements PackingLibraryService {
packingLibraryEntities = packingLibraryEntities.stream().filter(packingLibrary -> packingLibrary.getIsRoot() == 1).collect(Collectors.toList());
return packingLibraryEntities;
}else {
//附件 显示装备
// packingLibraryEntities = packingLibraryEntities.stream()
// .filter(packingLibrary -> packingLibrary.getIsRoot() == 1)
// .filter(packingLibrary -> packingLibrary.getIsPart() == 0)
// .collect(Collectors.toList());
//附件 显示装备和目录
packingLibraryEntities = packingLibraryEntities.stream()
.filter(packingLibrary -> packingLibrary.getIsRoot() == 1 || packingLibrary.getIsPart() == 0)
.collect(Collectors.toList());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论