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

更新

上级 48b0757a
......@@ -15,6 +15,7 @@ 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.DeviceLibrarySelectVo;
import com.tykj.dev.device.library.subject.vo.FileVo;
import com.tykj.dev.device.library.subject.vo.Script;
import com.tykj.dev.device.packing.controller.PackingController;
import com.tykj.dev.device.packing.service.PackingLibraryService;
import com.tykj.dev.device.packing.subject.domin.PackingLibrary;
......@@ -50,6 +51,8 @@ import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.groupingBy;
/**
* @author dengdiyi
*/
......@@ -488,26 +491,70 @@ public class DeviceApplyController {
Set<Integer> lifeStatus = deviceLibraries.stream().map(DeviceLibrary::getLifeStatus).collect(Collectors.toSet());
Set<Integer> integers = new HashSet<>();
integers.add(11);
final Integer status;
if (deviceApplyBill.getApplyType()==2) {
integers.add(15);
integers.add(12);
integers.add(16);
status=15;
}
if (deviceApplyBill.getApplyType()==3){
else if(deviceApplyBill.getApplyType()==3){
integers.add(17);
integers.add(5);
integers.add(18);
status=17;
}
if (deviceApplyBill.getApplyType()==4){
else if (deviceApplyBill.getApplyType()==4){
integers.add(19);
integers.add(10);
integers.add(20);
status=19;
}
else {
throw new ApiException("申请类型只能为2,3,4");
}
if (integers.containsAll(lifeStatus)){
return ResponseEntity.ok(true);
List<Script> scripts = new ArrayList<>();
List<DeviceLibrary> deviceLibraryList1 = deviceLibraries.stream().filter(deviceLibrary -> deviceLibrary.getLifeStatus().equals(status)).collect(Collectors.toList());
Map<Integer, List<DeviceLibrary>> map = deviceLibraryList1.stream().collect(groupingBy(DeviceLibrary::getPackingId));
for (Integer packingId:map.keySet()){
List<DeviceLibrary> deviceLibraryList = map.get(packingId);
PackingLibrary packingLibrary = packingLibraryService.getOne(packingId);
Script script = new Script();
script.setId(packingId);
script.setPartParentId(packingLibrary.getPartParentId());
script.setInvisibleRange(packingLibrary.getInvisibleRangeName());
script.setModel(packingLibrary.getModel());
script.setName(packingLibrary.getName());
script.setSecretLevel(packingLibrary.getSecretLevelName());
script.setType(packingLibrary.getTypeName());
script.setNum(deviceLibraryList.size());
script.setSeqNumber(StringSplitUtil.stringListToString(DeviceSeqUtil.getContinuousSeqs(deviceLibraryList.stream().map(DeviceLibrary::getSeqNumber).collect(Collectors.toList()))));
scripts.add(script);
}
Map<Integer, Script> nodeCollect =
scripts.stream().collect(Collectors.toMap(Script::getId, script -> script));
List<Script> scriptList = new ArrayList<>();
List<Script> conList = GetTreeUtils.parseTreeFromDown(
scripts,
Script::getId,
script -> Optional.ofNullable(nodeCollect.get(script.getPartParentId())),
Script::addChildNode
);
for (Script s:conList) {
addScript(scriptList,s);
}
return ResponseEntity.ok(scriptList);
}
else {
return ResponseEntity.ok(false);
}
}
private void addScript(List<Script> scripts,Script script){
scripts.add(script);
if (script.getChilds()!=null&&script.getChilds().size()>0){
script.getChilds().forEach(s -> addScript(scripts,s));
}
}
}
......@@ -194,6 +194,7 @@ public class DeviceLibraryController {
Set<String> ownUnits = new HashSet<>();
Set<String> locationUnits = new HashSet<>();
resultList.forEach(deviceVo -> {
deviceVo.setConfigName();
status.add(deviceVo.getLifeStatus());
models.add(deviceVo.getModel());
names.add(deviceVo.getName());
......@@ -264,29 +265,32 @@ public class DeviceLibraryController {
// }
// }
// }
List<DeviceVo> containList = GetTreeUtils.parseTreeFromDown(
List<DeviceLibrary> containList = GetTreeUtils.parseTreeFromDown(
resultList,
DeviceLibrary::getId,
deviceLibraryEntity -> Optional.ofNullable(nodeCollect.get(deviceLibraryEntity.getPartParentId())),
DeviceLibrary::addChildNode
).stream().map(DeviceLibrary::parseVo).collect(Collectors.toList());
// if (comparators.size()==1){
// containList = containList.stream().sorted(comparators.get(0)).collect(Collectors.toList());
// }
// else if(comparators.size()==2){
// containList = containList.stream().sorted(comparators.get(0).thenComparing(comparators.get(1))).collect(Collectors.toList());
// }
// else if(comparators.size()==3){
// containList = containList.stream().sorted(comparators.get(0).thenComparing(comparators.get(1)).thenComparing(comparators.get(2))).collect(Collectors.toList());
// }
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()));
Set<Integer> status = resultList.stream().map(DeviceLibrary::getLifeStatus).collect(Collectors.toSet());
);
Map<Integer,String> lifeStatusMap = configCache.getLifeStatusMap();
Set<Integer> status = new HashSet<>();
Set<String> models = new HashSet<>();
Set<String> names = new HashSet<>();
Set<String> ownUnits = new HashSet<>();
Set<String> locationUnits = new HashSet<>();
resultList.forEach(deviceVo -> {
deviceVo.setConfigName();
status.add(deviceVo.getLifeStatus());
models.add(deviceVo.getModel());
names.add(deviceVo.getName());
ownUnits.add(deviceVo.getOwnUnit());
locationUnits.add(deviceVo.getLocationUnit());
});
map.put("models",models);
map.put("names",names);
map.put("ownUnits",ownUnits);
map.put("locationUnits",locationUnits);
map.put("lifeStatus",status.stream().map(integer -> new LifeStatusVo(integer,lifeStatusMap.get(integer))).collect(Collectors.toList()));
Page<DeviceVo> deviceLibraryEntities = PageUtil.getPerPage(deviceLibrarySelectVo.getPage(), deviceLibrarySelectVo.getSize(), containList, deviceLibrarySelectVo.getPageable());
Page<DeviceLibrary> deviceLibraryEntities = PageUtil.getPerPage(deviceLibrarySelectVo.getPage(), deviceLibrarySelectVo.getSize(), containList, deviceLibrarySelectVo.getPageable());
map.put("pages",deviceLibraryEntities);
return ResultUtil.success(map);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论