提交 7fefc582 authored 作者: zhoushaopan's avatar zhoushaopan

[已报废,已销毁,已退役]改成数量以及修改批量配发

上级 9ad2a97d
......@@ -158,5 +158,9 @@ public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>,
int batchUpdate2(Integer lifeStatus,List<Integer> ids);
DeviceLibrary findBySeqNumber(String seqNumber);
List<DeviceLibrary> findAllByPackingId(Integer packingIds);
List<DeviceLibrary> findAllByPackingIdIn(List<Integer> packingIds);
}
......@@ -213,4 +213,17 @@ public interface DeviceLibraryService {
* 得到所有的装备
*/
List<DeviceLibrary> getAllDeviceList(DeviceLibrarySelectVo deviceLibrarySelectVo);
/**
* 通过列装id查询所有装备
*/
List<DeviceLibrary> findAllByPackingId(Integer packingId);
/**
* 通过列装id查询所有装备
*/
// List<DeviceLibrary> findAllByPackingId2(List<Integer> packingIds);
Map<Integer,List<DeviceLibrary>> findAllByPackingId3();
}
......@@ -6,6 +6,7 @@ import com.tykj.dev.blockcha.subject.entity.BcHash;
import com.tykj.dev.blockcha.subject.service.BlockChainUtil;
import com.tykj.dev.config.TaskBeanConfig;
import com.tykj.dev.config.base.DeviceLifeStatus;
import com.tykj.dev.device.library.controller.CacheLibraryController;
import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.library.service.DeviceLibraryCacheService;
import com.tykj.dev.device.library.service.DeviceLibraryService;
......@@ -58,6 +59,9 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
@Autowired
private DeviceLibraryCacheService cacheLibraryService;
@Autowired
private CacheLibraryController cacheLibraryController;
@Override
public DeviceLibrary addEntity(DeviceLibrary deviceLibraryEntity) {
DeviceLibrary deviceLibrary = deviceLibraryDao.save(deviceLibraryEntity);
......@@ -622,6 +626,48 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
return all;
}
@Override
public List<DeviceLibrary> findAllByPackingId(Integer packingId) {
return deviceLibraryDao.findAllByPackingId(packingId);
}
// @Override
// public List<DeviceLibrary> findAllByPackingId2(List<Integer> packingIds) {
// //查询可以使用并且在库 是所在或者所属是自己的
//// List<DeviceLibrary> deviceLibraries = deviceLibraryDao.findAllByPackingIdIn(packingIds).stream().filter(
//// deviceLibrary -> deviceLibrary.getLifeStatus() == 2
//// ).filter(deviceLibrary -> deviceLibrary.getOwnUnit().equals(userUtils.getCurrentUserUnitName()))
//// .filter(deviceLibrary -> deviceLibrary.getLocationUnit().equals(userUtils.getCurrentUserUnitName()))
//// .collect(Collectors.toList());
// //筛选出当前单位在库的装备
// DeviceLibrarySelectVo deviceLibrarySelectVo = new DeviceLibrarySelectVo();
// deviceLibrarySelectVo.setLifeStatus(Collections.singletonList(2));
// long l = System.currentTimeMillis();
// List<DeviceLibrary> deviceLibraries = getList(deviceLibrarySelectVo);
// System.out.println("查询在库时间"+(System.currentTimeMillis()-l));
// //转为列装id的map
// Map<Integer,List<DeviceLibrary>> map = deviceLibraries.stream().collect(groupingBy(DeviceLibrary::getPackingId));
//
// return deviceLibraries;
// }
@Override
public Map<Integer,List<DeviceLibrary>> findAllByPackingId3() {
//筛选出当前单位在库的装备
long l = System.currentTimeMillis();
List<DeviceLibrary> deviceLibraryList = cacheLibraryController.getAll();
// List<DeviceLibrary> deviceLibraryList = cacheLibraryService.getAllDeviceLibraryList();
System.out.println("查询在库时间ggg"+(System.currentTimeMillis()-l));
List<DeviceLibrary> deviceLibraries = deviceLibraryList.stream().filter(deviceLibrary -> deviceLibrary.getLifeStatus() == 2)
// .filter(deviceLibrary -> deviceLibrary.getLocationUnit().equals(userUtils.getCurrentUserUnitName())
// || deviceLibrary.getOwnUnit().equals(userUtils.getCurrentUserUnitName()))
.collect(Collectors.toList());
//转为列装id的map
Map<Integer,List<DeviceLibrary>> map = deviceLibraries.stream().collect(groupingBy(DeviceLibrary::getPackingId));
return map;
}
@Override
public void isNotLoss(List<Integer> ids) {
ids.forEach(integer -> {
......
......@@ -128,4 +128,7 @@ public class DeviceLibrarySelectVo extends CustomPage {
//
@ApiModelProperty(value = "装备形态模糊查询字段")
private String typeDim;
@ApiModelProperty(value = "作为已报废,已销毁,已退役的标志位",notes = "0 代表查询 1代表查询其他")
private Integer isScraped =1;
}
package com.tykj.dev.device.library.subject.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("已退役,已报废,已销毁")
public class ScrappedVos {
@ApiModelProperty(value = "型号", example = "bmxx")
public String model;
@ApiModelProperty(value = "名称", example = "BM-1")
public String name;
@ApiModelProperty(value = "序列号")
public String seqNumber;
@ApiModelProperty(value = "更新时间")
private Date updateTime;
}
......@@ -374,7 +374,9 @@ public class PackingController {
//筛选出当前单位在库的装备
DeviceLibrarySelectVo deviceLibrarySelectVo = new DeviceLibrarySelectVo();
deviceLibrarySelectVo.setLifeStatus(Collections.singletonList(2));
long l = System.currentTimeMillis();
List<DeviceLibrary> deviceLibraries = deviceLibraryService.getList(deviceLibrarySelectVo);
System.out.println("查询在库时间"+(System.currentTimeMillis()-l));
//转为列装id的map
Map<Integer,List<DeviceLibrary>> map = deviceLibraries.stream().collect(groupingBy(DeviceLibrary::getPackingId));
ids.forEach(integer -> {
......@@ -382,8 +384,7 @@ public class PackingController {
AllotMaxNum allotMaxNum = new AllotMaxNum();
allotMaxNum.setId(integer);
//map里value的集合大小为最大可配发数量
if (!map.keySet().contains(integer)){
if (!map.containsKey(integer)){
//设置最大配发数量为0
allotMaxNum.setMaxNum(0);
}else {
......
......@@ -5,10 +5,12 @@ import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo;
import com.tykj.dev.device.packing.repository.PackingLibraryDao;
import com.tykj.dev.device.packing.service.PackingLibraryService;
import com.tykj.dev.device.packing.subject.domin.PackingLibrary;
import com.tykj.dev.device.packing.subject.vo.*;
import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.utils.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -22,8 +24,12 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.Min;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.toMap;
/**
* @author dengdiyi
*/
......@@ -49,6 +55,9 @@ public class PackingLibraryController {
@Autowired
private ConfigCache configCache;
@Autowired
private UserUtils userUtils;
@ApiOperation(value = "申请后入库获取父子结构列装(去除已入库序列号)", notes = "获取父子结构列装")
@PostMapping("/merge")
public ResponseEntity merge(@RequestBody List<PackingLibrary> packingLibraries){
......@@ -197,6 +206,9 @@ public class PackingLibraryController {
packingLibraryEntity -> Optional.ofNullable(nodeCollect.get(packingLibraryEntity.getPartParentId())),
PackingLibrary::addChildNode
).stream().sorted(Comparator.comparing(PackingLibrary::getModel)).collect(Collectors.toList());
if (packingLibrarySelectVo.getIsAllot()!=null){
packingLibraryList = filterDevices(packingLibraryList);
}
Map<String,Object> map = new HashMap<>();
map.put("pages",packingLibraryList);
List<String> models = new ArrayList<>();
......@@ -411,7 +423,7 @@ public class PackingLibraryController {
}
public PackingLibrary getContext2(List<PackingLibrary> packingLibraries){
public PackingLibrary getContext2(List<PackingLibrary> packingLibraries) {
//判断集合的长度 801 802 803 804 只操作804 或者803
//取出目录
PackingLibrary packingLibrary = packingLibraries.get(0);
......@@ -484,4 +496,34 @@ public class PackingLibraryController {
// }
// return list;
// }
/**
* 通过列装id查询装备是否存在 过滤出装备为0的
*/
public List<PackingLibrary> filterDevices(List<PackingLibrary> packingLibraryList){
//获取列装id
List<Integer> packingIds = packingLibraryList.stream().map(PackingLibrary::getId).collect(Collectors.toList());
//通过列装id 查询装备数量
// long l = System.currentTimeMillis();
// List<DeviceLibrary> allByPackingId2 = deviceLibraryService.findAllByPackingId2(packingIds);
// System.out.println("查询时间"+(System.currentTimeMillis()-l));
// Map<Integer, List<DeviceLibrary>> map = allByPackingId2.stream().collect(groupingBy(DeviceLibrary::getPackingId));
Map<Integer, List<DeviceLibrary>> map = deviceLibraryService.findAllByPackingId3();
if (map.size()>0){
map.forEach(
(k,v)->{
if (v.size()==0){
Optional<PackingLibrary> byId = packingLibraryDao.findById(k);
PackingLibrary packingLibrary = new PackingLibrary();
if (byId.isPresent()){
packingLibrary = byId.get();
}
packingLibraryList.remove(packingLibrary);
}
}
);
}
return packingLibraryList;
}
}
......@@ -274,6 +274,11 @@ public class PackingLibrary {
@ApiModelProperty(value = "是不是单独的配件,0-不是,1-是")
private Integer isSinglePart;
@Transient
@ApiModelProperty(value = "装备的数量")
private Integer deviceNum;
public void addChildNode(PackingLibrary packingLibraryEntity) {
childs.add(packingLibraryEntity);
}
......
......@@ -43,4 +43,6 @@ public class PackingLibrarySelectVo extends CustomPage {
private Integer invisibleRange;
private Integer packingStatus;
private Integer isAllot;
}
......@@ -1623,7 +1623,7 @@ public class RepairController {
integerList.add(9);
integerList.add(0);
//筛选维修状态为1,9的
List<RepairDetail> repairDetails = repairDetailDao.findAllByRepairStatusIn(integerList, repairTaskSelectVo.getPageable().getSort());
List<RepairDetail> repairDetails = repairDetailDao.findAllByRepairStatusIn(integerList, repairTaskSelectVo.getPageable().getSort());
repairDetails.forEach(repairDetail -> {
repairDetail.setConfigName();
});
......
......@@ -11,7 +11,7 @@ package com.tykj.dev.statistical.controller;
import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.library.service.DeviceLibraryService;
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.*;
import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.utils.DeviceModelSort;
import com.tykj.dev.misc.utils.PageUtil;
......@@ -19,8 +19,10 @@ import com.tykj.dev.misc.utils.ResultUtil;
import com.tykj.dev.statistical.cache.StatisticalCache;
import com.tykj.dev.statistical.service.StatisticalService;
import com.tykj.dev.statistical.vo.DeviceStatistics;
import com.tykj.dev.statistical.vo.ScrappedDestroyedRetiredVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.ResponseEntity;
......@@ -29,6 +31,7 @@ import org.springframework.web.bind.annotation.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.groupingBy;
......@@ -220,6 +223,11 @@ public class StatisticalController {
}
List<DeviceLibrary> deviceLibraryEntities = resultList;
deviceLibraryEntities.forEach(DeviceLibrary::setConfigName);
//新增 已退役 已报废 已退役
if (deviceLibrarySelectVo.getIsScraped()==0){
return ScrappedDestroyedRetiredMethod(deviceLibraryEntities,deviceLibrarySelectVo);
}
//进行注释
Page<DeviceLibrary> deviceLibraries = PageUtil.getPerPage(deviceLibrarySelectVo.getPage(),deviceLibrarySelectVo.getSize(),deviceLibraryEntities,deviceLibrarySelectVo.getPageable());
Map<String,Object> map = new HashMap<>();
// Map<Integer,String> lifeStatusMap = configCache.getLifeStatusMap();
......@@ -238,6 +246,24 @@ public class StatisticalController {
return ResultUtil.success(map);
}
@ApiOperation(value = "根据装备id查询装备详情", notes = "根据装备id查询装备详情")
@PostMapping("/selectByIds2")
public List<DeviceLibrary> selectByIds2(@RequestBody DeviceSelectIdsVo deviceSelectIdsVo){
List<DeviceLibrary> byIds = deviceLibraryService.findByIds(deviceSelectIdsVo.getIds());
byIds.forEach(DeviceLibrary::setConfigName);
// List<ScrappedVos> scrappedVosArrayList = new ArrayList<>();
ScrappedVos scrappedVos = new ScrappedVos();
// byIds.forEach(
// deviceLibrary -> {
// BeanUtils.copyProperties(deviceLibrary,scrappedVos);
// scrappedVosArrayList.add(scrappedVos);
// }
// );
return byIds;
}
/**
* 按型号,名称,类型组合
*/
......@@ -266,4 +292,50 @@ public class StatisticalController {
}
return deviceStatisticsList;
}
//已退役 已报废 已退役
public ResponseEntity ScrappedDestroyedRetiredMethod(List<DeviceLibrary> libraryList,DeviceLibrarySelectVo deviceLibrarySelectVo){
//已销毁 10 已报废 5 已退役 12
List<Integer> lifeStatus = new ArrayList<>(Arrays.asList(5, 10, 12));
List<ScrappedDestroyedRetiredVo> destroyedRetiredVoList = new ArrayList<>();
if (lifeStatus.containsAll(deviceLibrarySelectVo.getLifeStatus())){
//进行组合
Map<String, List<DeviceLibrary>> map = libraryList.stream().collect(groupingBy(deviceLibrary -> deviceLibrary.getModel() + "Ǵ" + deviceLibrary.getName() + "Ǵ" + deviceLibrary.getMatchingRangeName()));
if (map.size()>0){
for (String s : map.keySet()) {
String[] strings = s.split("Ǵ");
//型号 名称 配用范围
ScrappedDestroyedRetiredVo scrappedDestroyedRetiredVo = new ScrappedDestroyedRetiredVo();
scrappedDestroyedRetiredVo.setModel(strings[0]);
scrappedDestroyedRetiredVo.setName(strings[1]);
scrappedDestroyedRetiredVo.setMatchingRangeName(strings[2]);
scrappedDestroyedRetiredVo.setNum(map.get(s).size());
List<Integer> ids = new ArrayList<>();
List<DeviceLibrary> deviceLibraries = map.get(s);
ids = deviceLibraries.stream().map(DeviceLibrary::getId).collect(Collectors.toList());
// for (List<DeviceLibrary> deviceLibraryList : map.values()) {
// deviceLibraryList.forEach(
// deviceLibrary -> {
// ids.add(x.getId());
// }
// );
// }
scrappedDestroyedRetiredVo.setDevicesId(ids);
destroyedRetiredVoList.add(scrappedDestroyedRetiredVo);
}
}
}
Map<String,Object> map = new HashMap<>();
Page<ScrappedDestroyedRetiredVo> page = PageUtil.getPerPage(deviceLibrarySelectVo.getPage(), deviceLibrarySelectVo.getSize(), destroyedRetiredVoList, deviceLibrarySelectVo.getPageable());
map.put("pages",page);
//排序加上去重
List<String> names = destroyedRetiredVoList.stream().map(ScrappedDestroyedRetiredVo::getName).distinct()
.sorted(Comparator.comparing(String::toString)).collect(Collectors.toList());
map.put("names",names);
List<String> models = destroyedRetiredVoList.stream().map(ScrappedDestroyedRetiredVo::getModel).distinct().collect(Collectors.toList());
List<String> modelToSort = DeviceModelSort.modelToSort(models);
map.put("modelToSort",modelToSort);
return ResponseEntity.ok(map);
}
}
package com.tykj.dev.statistical.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* DATE:2021-8-13
* Author:zsp
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("已退役,报废,销毁")
public class ScrappedDestroyedRetiredVo {
@ApiModelProperty(value = "型号", example = "bmxx")
public String model;
@ApiModelProperty(value = "名称", example = "BM-1")
public String name;
@ApiModelProperty(value = "配用范围")
public String matchingRangeName;
@ApiModelProperty(value = "数量")
public Integer num;
@ApiModelProperty(value = "所属单位", example = "省机要局")
private String ownUnit;
@ApiModelProperty("组织架构级别")
private Integer level;
@ApiModelProperty(value = "装备id")
private List<Integer> devicesId;
}
......@@ -22,10 +22,7 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
//import com.tykj.dev.device.read.service.MessageService;
......@@ -63,6 +60,7 @@ public class MessageController {
Boolean hasContentDim = messageSelectVo.getContentDim()!=null;
Boolean hasOperatorDim = messageSelectVo.getOperatorDim()!=null;
List<MessageUserVo> messageUserVos = messageService.getAllList(messageSelectVo);
messageUserVos.sort(Comparator.comparing(MessageUserVo::getIsTop).reversed().thenComparing(MessageUserVo::getCreateTime).reversed());
//模糊查询筛选
if (hasContentDim||hasOperatorDim) {
messageUserVos = messageUserVos.stream().filter(messageUserVo -> {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论