提交 0b70a385 authored 作者: zhoushaopan's avatar zhoushaopan

feat(装备列装模块,装备管理模块,装备申请模块): 新增申请需求,新增数量接口

新增申请需求,新增数量接口
上级 ad153c2b
......@@ -735,8 +735,42 @@ public class DeviceApplyController {
@PostMapping("/removeSameSeq")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity removeSameSeq(@RequestBody RemoveSameSeqVo removeSameSeqVo) {
List<String> stringList = deviceApplyBillService.removeSameSeq(removeSameSeqVo);
return ResponseEntity.ok(stringList);
ApplyRemoveSeqVo applyRemoveSeqVo = deviceApplyBillService.removeSameSeq(removeSameSeqVo);
return ResponseEntity.ok(applyRemoveSeqVo);
}
@ApiOperation(value = "返回区间数量", notes = "返回区间数量")
@GetMapping("/returnSeqCount/{seqList}")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity returnSeqCount(@PathVariable("seqList") String seqList) {
String[] split = seqList.split(",");
int count = 0;
//判断里面有没有-
List<String> stringList = new ArrayList<>();
for (int i = 0; i < split.length; i++) {
if (split[i].contains("-")){
stringList.add(split[i]);
}
}
count = count+split.length-stringList.size();
//计算集合的长度
List<Integer> list = new ArrayList<>();
if (stringList.size()>0){
stringList.forEach(s -> {
List<String> stringList1 = DeviceSeqUtil.selectDeviceSeqs(s);
int size = stringList1.size();
list.add(size);
});
}
//集合中的元素想加
int j = 0;
for (int i = 0; i < list.size(); i++) {
j = list.get(i)+j;
}
count=count+j;
return ResponseEntity.ok(count);
}
......
......@@ -2,6 +2,7 @@ package com.tykj.dev.device.apply.service;
import com.tykj.dev.device.apply.subject.domin.DeviceApplyBill;
import com.tykj.dev.device.apply.subject.vo.ApplyRemoveSeqVo;
import com.tykj.dev.device.apply.subject.vo.ApplyTaskDeviceCheckVo;
import com.tykj.dev.device.apply.subject.vo.RemoveFromSeqListVo;
import com.tykj.dev.device.apply.subject.vo.RemoveSameSeqVo;
......@@ -39,6 +40,6 @@ public interface DeviceApplyBillService {
List<String> removeFromSeqList(RemoveFromSeqListVo removeFromSeqListVo);
List<String> removeSameSeq(RemoveSameSeqVo removeSameSeqVo);
ApplyRemoveSeqVo removeSameSeq(RemoveSameSeqVo removeSameSeqVo);
}
......@@ -7,10 +7,7 @@ import com.tykj.dev.config.TaskBeanConfig;
import com.tykj.dev.device.apply.repository.DeviceApplyBillDao;
import com.tykj.dev.device.apply.service.DeviceApplyBillService;
import com.tykj.dev.device.apply.subject.domin.DeviceApplyBill;
import com.tykj.dev.device.apply.subject.vo.ApplyTaskDeviceCheckVo;
import com.tykj.dev.device.apply.subject.vo.RemoveFromSeqListVo;
import com.tykj.dev.device.apply.subject.vo.RemoveSameSeqVo;
import com.tykj.dev.device.apply.subject.vo.ReplyVo;
import com.tykj.dev.device.apply.subject.vo.*;
import com.tykj.dev.device.library.service.DeviceLibraryCacheService;
import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.service.impl.CacheLibraryServiceImpl;
......@@ -267,16 +264,15 @@ public class DeviceApplyBillServiceImpl implements DeviceApplyBillService {
String seqNumberList = removeFromSeqListVo.getSeqNumberList();
//对序列号区间进行拆分
List<String> seqs = DeviceSeqUtil.selectDeviceSeqs(seqNumberList);
List<String> seq1 = DeviceSeqUtil.selectDeviceSeqs(removeFromSeqListVo.getSeqNumber());
seqs.removeAll(seq1);
seqs.removeAll(removeFromSeqListVo.getRemoveSeqNumberList());
//对原来的集合先进行排序
seqs.sort(Comparator.comparing(String::toString));
return DeviceSeqUtil.getContinuousSeqs(seqs);
}
@Override
public List<String> removeSameSeq(RemoveSameSeqVo removeSameSeqVo) {
public ApplyRemoveSeqVo removeSameSeq(RemoveSameSeqVo removeSameSeqVo) {
ApplyRemoveSeqVo applyRemoveSeqVo = new ApplyRemoveSeqVo();
String seqNumberList = removeSameSeqVo.getSeqNumberList();
List<String> selectDeviceSeqs = DeviceSeqUtil.selectDeviceSeqs(seqNumberList);
if (selectDeviceSeqs.size()>0){
......@@ -286,6 +282,8 @@ public class DeviceApplyBillServiceImpl implements DeviceApplyBillService {
}
}
List<String> continuousSeqs = DeviceSeqUtil.getContinuousSeqs(selectDeviceSeqs);
return continuousSeqs;
applyRemoveSeqVo.setSeqList(continuousSeqs);
applyRemoveSeqVo.setCount(selectDeviceSeqs.size());
return applyRemoveSeqVo;
}
}
package com.tykj.dev.device.apply.subject.vo;
import com.tykj.dev.device.apply.subject.domin.DeviceApplyBill;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.packing.subject.domin.PackingLibrary;
import com.tykj.dev.device.task.subject.vo.TaskLogUserVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author zsp
*/
@Data
@ApiModel("返回入库时候,如果试用装备的序列号在序列号区间,则进行去除vo")
public class ApplyRemoveSeqVo {
@ApiModelProperty(value = "序列号区间")
private List<String> seqList;
@ApiModelProperty(name = "区间数量")
private Integer count;
}
......@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author zsp
*/
......@@ -15,6 +17,6 @@ public class RemoveFromSeqListVo {
private String seqNumberList;
@ApiModelProperty(value = "要移除的序列号")
private String seqNumber;
private List<String> removeSeqNumberList;
}
......@@ -947,8 +947,8 @@ public class DeviceLibraryController {
@ApiOperation("入库修改试用装备的序列号")
@PostMapping("updateSeq")
public ResponseEntity updateSeq(@RequestBody DeviceForApplyVo deviceForApplyVo){
deviceLibraryService.updateSeqNumber(deviceForApplyVo);
public ResponseEntity updateSeq(@RequestBody List<DeviceForApplyVo> deviceForApplyVos){
deviceLibraryService.updateSeqNumber(deviceForApplyVos);
return ResponseEntity.ok("更新成功");
}
......
......@@ -496,7 +496,7 @@ public interface DeviceLibraryService {
/**
* 根据装备id更新装备
* @param deviceForApplyVo 更新试用装备序列号的vo
* @param deviceForApplyVos 更新试用装备序列号的vo
*/
void updateSeqNumber(DeviceForApplyVo deviceForApplyVo);
void updateSeqNumber(List<DeviceForApplyVo> deviceForApplyVos);
}
......@@ -26,6 +26,7 @@ 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.beans.factory.annotation.Qualifier;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
......@@ -40,6 +41,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -74,6 +76,10 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
@Autowired
private DeviceLibraryCacheService deviceLibraryCacheService;
@Autowired
@Qualifier("taskExecutor")
private Executor executor;
@Override
@UpdateCache
public DeviceLibrary addEntity(DeviceLibrary deviceLibraryEntity) {
......@@ -1090,16 +1096,43 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
@Override
@UpdateCache
public void updateSeqNumber(DeviceForApplyVo deviceForApplyVo) {
DeviceLibrary library = getOne(deviceForApplyVo.getDeviceId());
library.setSeqNumber(deviceForApplyVo.getSeqNumber().trim());
//先判断序列号存不存在
DeviceLibrary bySeqNumber = deviceLibraryDao.findBySeqNumber(deviceForApplyVo.getSeqNumber().trim());
if (bySeqNumber != null){
throw new ApiException("序列号已经存在,请更换序列号");
public void updateSeqNumber(List<DeviceForApplyVo> deviceForApplyVos) {
List<String> inputSeq = deviceForApplyVos.stream()
.filter(deviceForApplyVo -> deviceForApplyVo.getIsUpdate() == 0)
.map(DeviceForApplyVo::getSeqNumber)
.collect(Collectors.toList());
//数据库中的seq
List<String> existSeq = cacheLibraryService.getAllDeviceLibraryList().stream()
.map(DeviceLibrary::getSeqNumber)
.collect(Collectors.toList());
Integer userId = userUtils.getCurrentUserId();
List<DeviceLogDto> deviceLogDtos = new ArrayList<>();
//取交集
inputSeq.retainAll(existSeq);
if (inputSeq.size()>0){
String join = String.join(",", inputSeq);
throw new ApiException(join+"序列号已经存在");
}else {
deviceLibraryDao.save(library);
//进行更新装备
deviceForApplyVos.forEach(deviceForApplyVo -> {
Integer deviceId = deviceForApplyVo.getDeviceId();
String seqNumber = deviceForApplyVo.getSeqNumber();
DeviceLibrary one = getOne(deviceId);
one.setSeqNumber(seqNumber);
//添加装备日志
DeviceLogDto deviceLogDto = new DeviceLogDto();
deviceLogDto.setDeviceId(deviceId);
deviceLogDto.setRemark("将原来的序列号"+one.getSeqNumber()+"修改为"+seqNumber);
deviceLogDto.setCreateUserId(userId);
update(one);
deviceLogDtos.add(deviceLogDto);
});
}
executor.execute(()->{
deviceLogService.addAllLog(deviceLogDtos);
});
}
// @Override
......
......@@ -316,8 +316,7 @@ public class DeviceLibrary implements Serializable {
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<>());
// childs.clear();
}
return this;
}
......
......@@ -25,4 +25,7 @@ public class DeviceForApplyVo {
@ApiModelProperty(value = "装备的序列号", example = "12344")
private String seqNumber;
@ApiModelProperty(value = "是否修改 0 正式 1 试用", example = "0")
private Integer isUpdate;
}
......@@ -360,7 +360,8 @@ public class PackingController {
// Page<PackingLibrary> packingLibraries = PageUtil.getPerPage(selectPack.getPage(), selectPack.getSize(), resultList, selectPack.getPageable());
Page<PackingLibrary> packingLibraries = PageUtil.getPerPage(selectPack.getPage(), selectPack.getSize(), orderNumbers, selectPack.getPageable());
map.put("pages",packingLibraries);
List<String> models = new ArrayList<>(resultList.stream().filter(packingLibrary -> packingLibrary.getIsRoot() == 1).map(PackingLibrary::getModel).collect(Collectors.toList()));
List<String> models = new ArrayList<>(resultList.stream().filter(packingLibrary ->
packingLibrary.getIsRoot() == 1).map(PackingLibrary::getModel).collect(Collectors.toList()));
//去重
models = models.stream().distinct().collect(Collectors.toList());
map.put("models",models);
......@@ -368,6 +369,17 @@ public class PackingController {
return ResultUtil.success(map);
}
@ApiOperation(value = "查询所有型号")
@GetMapping("/findAllModel")
public ResponseEntity findAllModel(){
List<PackingLibrary> resultList = getAllPackingExceptNull(new SelectPack());
List<String> models = new ArrayList<>(resultList.stream().filter(packingLibrary ->
packingLibrary.getIsRoot() == 1).map(PackingLibrary::getModel).collect(Collectors.toList()));
//去重
models = models.stream().distinct().collect(Collectors.toList());
return ResultUtil.success(models);
}
// @ApiOperation(value = "查询父子结构列装")
// @PostMapping("/select")
// public ResponseEntity selectPack(@RequestBody SelectPack selectPack){
......@@ -1131,7 +1143,8 @@ public class PackingController {
resultList.add(packingLibrary);
}
});
resultList.sort(Comparator.comparing(PackingLibrary::getShowOrder,Comparator.nullsLast(Integer::compareTo)).thenComparing(Comparator.comparing(PackingLibrary::getModel)));
resultList.sort(Comparator.comparing(PackingLibrary::getShowOrder,Comparator.nullsLast(Integer::compareTo))
.thenComparing(Comparator.comparing(PackingLibrary::getModel)));
return resultList;
}
......
......@@ -965,7 +965,12 @@ public class PackingLibraryServiceImpl implements PackingLibraryService {
originPacking.setPartParentId(selectPacking.getId());
PackingLog packingLog = new PackingLog();
packingLog.setPackingId(originPacking.getId());
packingLog.setRemark("列装名称为"+originPacking.getName()+"与列装名称"+selectPacking.getName()+"进行绑定");
if (selectPacking.getIsRoot() == 0){
packingLog.setRemark("列装名称为"+originPacking.getName()+"与列装名称"+selectPacking.getName()+"进行绑定");
}else {
packingLog.setRemark("列装名称为"+originPacking.getName()+"与列装目录型号"+selectPacking.getModel()+"进行绑定");
}
packingLogService.add(packingLog);
update(originPacking);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论