提交 00177b97 authored 作者: zhoushaopan's avatar zhoushaopan

[装备controller]新增更新序列号接口,新增装备序列号vo

上级 a76174c0
......@@ -21,6 +21,7 @@ import com.tykj.dev.misc.utils.GetTreeUtils;
import com.tykj.dev.misc.utils.PageUtil;
import com.tykj.dev.misc.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
......@@ -96,7 +97,10 @@ public class DeviceLibraryController {
public ResponseEntity selectByIds(@RequestBody DeviceSelectIdsVo deviceSelectIdsVo){
List<DeviceLibrary> deviceLibraries = new ArrayList<>();
deviceSelectIdsVo.getIds().forEach(integer -> deviceLibraries.add(deviceLibraryService.getOne(integer).setConfigName()));
return ResponseEntity.ok(PageUtil.getPerPage(deviceSelectIdsVo.getPage(),deviceSelectIdsVo.getSize(),deviceLibraries, PageRequest.of(deviceSelectIdsVo.getPage(),deviceSelectIdsVo.getSize())));
//进行排序
List<DeviceLibrary> libraryList = deviceLibraries.stream().sorted(Comparator.comparing(DeviceLibrary::getModel)
.thenComparing(DeviceLibrary::getName).thenComparing(DeviceLibrary::getSeqNumber)).collect(Collectors.toList());
return ResponseEntity.ok(PageUtil.getPerPage(deviceSelectIdsVo.getPage(),deviceSelectIdsVo.getSize(),libraryList, PageRequest.of(deviceSelectIdsVo.getPage(),deviceSelectIdsVo.getSize())));
}
@ApiOperation(value = "根据装备id查询装备详情", notes = "根据装备id查询装备详情")
......@@ -365,6 +369,7 @@ public class DeviceLibraryController {
Set<Integer> matchingRanges = new HashSet<>();
//添加装备形态
Set<Integer> types = new HashSet<>();
Set<String> storageLocation = new HashSet<>();
resultList.forEach(deviceVo -> {
deviceVo.setConfigName();
status.add(deviceVo.getLifeStatus());
......@@ -375,6 +380,7 @@ public class DeviceLibraryController {
matchingRanges.add(deviceVo.getMatchingRange());
//添加形态
types.add(deviceVo.getType());
storageLocation.add(deviceVo.getStorageLocation());
});
List<String> finalModels = models.stream().distinct().collect(Collectors.toList());
List<String> modelToSort = DeviceModelSort.modelToSort(finalModels);
......@@ -390,6 +396,7 @@ public class DeviceLibraryController {
Page<DeviceLibrary> deviceLibraryEntities = PageUtil.getPerPage(deviceLibrarySelectVo.getPage(), deviceLibrarySelectVo.getSize(), containList, deviceLibrarySelectVo.getPageable());
map.put("pages",deviceLibraryEntities);
map.put("types",types.stream().map(integer -> new TypeVo(integer,styleMap.get(integer))).collect(Collectors.toList()));
map.put("storageLocation",storageLocation);
return ResultUtil.success(map);
}
......@@ -715,4 +722,27 @@ public class DeviceLibraryController {
deviceLibraryService.update(deviceLibrary);
}
@ApiOperation("根据装备id修改装备的序列号")
@PostMapping("updateSeqByDeviceId")
public ResponseEntity updateSeqByDeviceId(@RequestBody DeviceSeqVo deviceSeqVo){
DeviceLibrary deviceLibrary = deviceLibraryService.getOne(deviceSeqVo.getId());
Map<String, Object> map = new HashMap<>();
//先判断序列号是否已经存在
DeviceLibrary bySeqNumber = deviceLibraryService.findBySeqNumber(deviceSeqVo.getSeqNumber());
if (bySeqNumber != null){
map.put("error","该序列号已经存在,请重新更换序列号");
}else {
//修改序列号
deviceLibrary.setSeqNumber(deviceSeqVo.getSeqNumber());
//添加日志
DeviceLogDto deviceLogDto = new DeviceLogDto(deviceSeqVo.getId(), "将装备序列号改为"+deviceSeqVo.getSeqNumber(), null,null,null);
deviceLogService.addLog(deviceLogDto);
deviceLibraryService.update(deviceLibrary);
map.put("deviceLibrary",deviceLibrary);
map.put("success","装备序列号信息更新成功");
}
return ResponseEntity.ok(map);
}
}
......@@ -157,5 +157,6 @@ public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>,
@Query("update DeviceLibrary o set o.lifeStatus = :lifeStatus where o.id in :ids")
int batchUpdate2(Integer lifeStatus,List<Integer> ids);
DeviceLibrary findBySeqNumber(String seqNumber);
}
......@@ -198,4 +198,9 @@ public interface DeviceLibraryService {
void updateLifeStatus2(Integer lifeStatus,List<Integer> ids);
List<DeviceLibrary> findByIds(List<Integer> ids);
/**
* @param seqNumber 序列号
*/
DeviceLibrary findBySeqNumber(String seqNumber);
}
......@@ -593,6 +593,11 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
return deviceLibraryDao.findAllByIdIn(ids);
}
@Override
public DeviceLibrary findBySeqNumber(String seqNumber) {
return deviceLibraryDao.findBySeqNumber(seqNumber);
}
@Override
public void isNotLoss(List<Integer> ids) {
......
package com.tykj.dev.device.library.subject.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* DATE:2021-7-27
* Author:zsp
*/
@Data
@ApiModel("装备序列号")
public class DeviceSeqVo {
@ApiModelProperty("装备id")
private Integer id;
@ApiModelProperty("装备序列号")
private String seqNumber;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论