提交 0fed092a authored 作者: zjm's avatar zjm

Merge branch 'dev' of git.yfzx.zjtys.com.cn:matrix/device-back

...@@ -735,8 +735,42 @@ public class DeviceApplyController { ...@@ -735,8 +735,42 @@ public class DeviceApplyController {
@PostMapping("/removeSameSeq") @PostMapping("/removeSameSeq")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity removeSameSeq(@RequestBody RemoveSameSeqVo removeSameSeqVo) { public ResponseEntity removeSameSeq(@RequestBody RemoveSameSeqVo removeSameSeqVo) {
List<String> stringList = deviceApplyBillService.removeSameSeq(removeSameSeqVo); ApplyRemoveSeqVo applyRemoveSeqVo = deviceApplyBillService.removeSameSeq(removeSameSeqVo);
return ResponseEntity.ok(stringList); 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; ...@@ -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.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.ApplyTaskDeviceCheckVo;
import com.tykj.dev.device.apply.subject.vo.RemoveFromSeqListVo; 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.RemoveSameSeqVo;
...@@ -39,6 +40,6 @@ public interface DeviceApplyBillService { ...@@ -39,6 +40,6 @@ public interface DeviceApplyBillService {
List<String> removeFromSeqList(RemoveFromSeqListVo removeFromSeqListVo); List<String> removeFromSeqList(RemoveFromSeqListVo removeFromSeqListVo);
List<String> removeSameSeq(RemoveSameSeqVo removeSameSeqVo); ApplyRemoveSeqVo removeSameSeq(RemoveSameSeqVo removeSameSeqVo);
} }
...@@ -7,10 +7,7 @@ import com.tykj.dev.config.TaskBeanConfig; ...@@ -7,10 +7,7 @@ import com.tykj.dev.config.TaskBeanConfig;
import com.tykj.dev.device.apply.repository.DeviceApplyBillDao; import com.tykj.dev.device.apply.repository.DeviceApplyBillDao;
import com.tykj.dev.device.apply.service.DeviceApplyBillService; import com.tykj.dev.device.apply.service.DeviceApplyBillService;
import com.tykj.dev.device.apply.subject.domin.DeviceApplyBill; 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.*;
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.library.service.DeviceLibraryCacheService; import com.tykj.dev.device.library.service.DeviceLibraryCacheService;
import com.tykj.dev.device.library.service.DeviceLibraryService; import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.service.impl.CacheLibraryServiceImpl; import com.tykj.dev.device.library.service.impl.CacheLibraryServiceImpl;
...@@ -267,16 +264,15 @@ public class DeviceApplyBillServiceImpl implements DeviceApplyBillService { ...@@ -267,16 +264,15 @@ public class DeviceApplyBillServiceImpl implements DeviceApplyBillService {
String seqNumberList = removeFromSeqListVo.getSeqNumberList(); String seqNumberList = removeFromSeqListVo.getSeqNumberList();
//对序列号区间进行拆分 //对序列号区间进行拆分
List<String> seqs = DeviceSeqUtil.selectDeviceSeqs(seqNumberList); List<String> seqs = DeviceSeqUtil.selectDeviceSeqs(seqNumberList);
seqs.removeAll(removeFromSeqListVo.getRemoveSeqNumberList());
List<String> seq1 = DeviceSeqUtil.selectDeviceSeqs(removeFromSeqListVo.getSeqNumber());
seqs.removeAll(seq1);
//对原来的集合先进行排序 //对原来的集合先进行排序
seqs.sort(Comparator.comparing(String::toString)); seqs.sort(Comparator.comparing(String::toString));
return DeviceSeqUtil.getContinuousSeqs(seqs); return DeviceSeqUtil.getContinuousSeqs(seqs);
} }
@Override @Override
public List<String> removeSameSeq(RemoveSameSeqVo removeSameSeqVo) { public ApplyRemoveSeqVo removeSameSeq(RemoveSameSeqVo removeSameSeqVo) {
ApplyRemoveSeqVo applyRemoveSeqVo = new ApplyRemoveSeqVo();
String seqNumberList = removeSameSeqVo.getSeqNumberList(); String seqNumberList = removeSameSeqVo.getSeqNumberList();
List<String> selectDeviceSeqs = DeviceSeqUtil.selectDeviceSeqs(seqNumberList); List<String> selectDeviceSeqs = DeviceSeqUtil.selectDeviceSeqs(seqNumberList);
if (selectDeviceSeqs.size()>0){ if (selectDeviceSeqs.size()>0){
...@@ -286,6 +282,8 @@ public class DeviceApplyBillServiceImpl implements DeviceApplyBillService { ...@@ -286,6 +282,8 @@ public class DeviceApplyBillServiceImpl implements DeviceApplyBillService {
} }
} }
List<String> continuousSeqs = DeviceSeqUtil.getContinuousSeqs(selectDeviceSeqs); 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; ...@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* @author zsp * @author zsp
*/ */
...@@ -15,6 +17,6 @@ public class RemoveFromSeqListVo { ...@@ -15,6 +17,6 @@ public class RemoveFromSeqListVo {
private String seqNumberList; private String seqNumberList;
@ApiModelProperty(value = "要移除的序列号") @ApiModelProperty(value = "要移除的序列号")
private String seqNumber; private List<String> removeSeqNumberList;
} }
...@@ -393,7 +393,6 @@ public class DeviceLibraryController { ...@@ -393,7 +393,6 @@ public class DeviceLibraryController {
//形态 //形态
List<Integer> types = new ArrayList<>(); List<Integer> types = new ArrayList<>();
resultList.forEach(deviceVo -> { resultList.forEach(deviceVo -> {
deviceVo.setConfigName();
status.add(deviceVo.getLifeStatus()); status.add(deviceVo.getLifeStatus());
models.add(deviceVo.getModel()); models.add(deviceVo.getModel());
names.add(deviceVo.getName()); names.add(deviceVo.getName());
...@@ -948,8 +947,8 @@ public class DeviceLibraryController { ...@@ -948,8 +947,8 @@ public class DeviceLibraryController {
@ApiOperation("入库修改试用装备的序列号") @ApiOperation("入库修改试用装备的序列号")
@PostMapping("updateSeq") @PostMapping("updateSeq")
public ResponseEntity updateSeq(@RequestBody DeviceForApplyVo deviceForApplyVo){ public ResponseEntity updateSeq(@RequestBody List<DeviceForApplyVo> deviceForApplyVos){
deviceLibraryService.updateSeqNumber(deviceForApplyVo); deviceLibraryService.updateSeqNumber(deviceForApplyVos);
return ResponseEntity.ok("更新成功"); return ResponseEntity.ok("更新成功");
} }
......
...@@ -496,7 +496,7 @@ public interface DeviceLibraryService { ...@@ -496,7 +496,7 @@ public interface DeviceLibraryService {
/** /**
* 根据装备id更新装备 * 根据装备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.*; ...@@ -26,6 +26,7 @@ import com.tykj.dev.misc.utils.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
...@@ -40,6 +41,7 @@ import java.lang.reflect.Field; ...@@ -40,6 +41,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -74,6 +76,10 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService { ...@@ -74,6 +76,10 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
@Autowired @Autowired
private DeviceLibraryCacheService deviceLibraryCacheService; private DeviceLibraryCacheService deviceLibraryCacheService;
@Autowired
@Qualifier("taskExecutor")
private Executor executor;
@Override @Override
@UpdateCache @UpdateCache
public DeviceLibrary addEntity(DeviceLibrary deviceLibraryEntity) { public DeviceLibrary addEntity(DeviceLibrary deviceLibraryEntity) {
...@@ -1090,16 +1096,43 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService { ...@@ -1090,16 +1096,43 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
@Override @Override
@UpdateCache @UpdateCache
public void updateSeqNumber(DeviceForApplyVo deviceForApplyVo) { public void updateSeqNumber(List<DeviceForApplyVo> deviceForApplyVos) {
DeviceLibrary library = getOne(deviceForApplyVo.getDeviceId()); List<String> inputSeq = deviceForApplyVos.stream()
library.setSeqNumber(deviceForApplyVo.getSeqNumber().trim()); .filter(deviceForApplyVo -> deviceForApplyVo.getIsUpdate() == 0)
//先判断序列号存不存在 .map(DeviceForApplyVo::getSeqNumber)
DeviceLibrary bySeqNumber = deviceLibraryDao.findBySeqNumber(deviceForApplyVo.getSeqNumber().trim()); .collect(Collectors.toList());
if (bySeqNumber != null){ //数据库中的seq
throw new ApiException("序列号已经存在,请更换序列号"); 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 { }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 // @Override
......
...@@ -316,8 +316,7 @@ public class DeviceLibrary implements Serializable { ...@@ -316,8 +316,7 @@ public class DeviceLibrary implements Serializable {
setTypeName(configCache.getStyleMap().get(this.type)==null?"-":configCache.getStyleMap().get(this.type)); setTypeName(configCache.getStyleMap().get(this.type)==null?"-":configCache.getStyleMap().get(this.type));
setStorageTypeName(configCache.getStorageTypeMap().get(this.storageType)==null?"-":configCache.getStorageTypeMap().get(this.storageType)); setStorageTypeName(configCache.getStorageTypeMap().get(this.storageType)==null?"-":configCache.getStorageTypeMap().get(this.storageType));
setAllotTypeName(configCache.getAllotTypeMap().get(this.allotType)==null?"-":configCache.getAllotTypeMap().get(this.allotType)); setAllotTypeName(configCache.getAllotTypeMap().get(this.allotType)==null?"-":configCache.getAllotTypeMap().get(this.allotType));
childs.clear(); // childs.clear();
// setChilds(new ArrayList<>());
} }
return this; return this;
} }
......
...@@ -25,4 +25,7 @@ public class DeviceForApplyVo { ...@@ -25,4 +25,7 @@ public class DeviceForApplyVo {
@ApiModelProperty(value = "装备的序列号", example = "12344") @ApiModelProperty(value = "装备的序列号", example = "12344")
private String seqNumber; private String seqNumber;
@ApiModelProperty(value = "是否修改 0 正式 1 试用", example = "0")
private Integer isUpdate;
} }
...@@ -360,7 +360,8 @@ public class PackingController { ...@@ -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(), resultList, selectPack.getPageable());
Page<PackingLibrary> packingLibraries = PageUtil.getPerPage(selectPack.getPage(), selectPack.getSize(), orderNumbers, selectPack.getPageable()); Page<PackingLibrary> packingLibraries = PageUtil.getPerPage(selectPack.getPage(), selectPack.getSize(), orderNumbers, selectPack.getPageable());
map.put("pages",packingLibraries); 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()); models = models.stream().distinct().collect(Collectors.toList());
map.put("models",models); map.put("models",models);
...@@ -368,6 +369,17 @@ public class PackingController { ...@@ -368,6 +369,17 @@ public class PackingController {
return ResultUtil.success(map); 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 = "查询父子结构列装") // @ApiOperation(value = "查询父子结构列装")
// @PostMapping("/select") // @PostMapping("/select")
// public ResponseEntity selectPack(@RequestBody SelectPack selectPack){ // public ResponseEntity selectPack(@RequestBody SelectPack selectPack){
...@@ -1131,7 +1143,8 @@ public class PackingController { ...@@ -1131,7 +1143,8 @@ public class PackingController {
resultList.add(packingLibrary); 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; return resultList;
} }
......
...@@ -965,7 +965,12 @@ public class PackingLibraryServiceImpl implements PackingLibraryService { ...@@ -965,7 +965,12 @@ public class PackingLibraryServiceImpl implements PackingLibraryService {
originPacking.setPartParentId(selectPacking.getId()); originPacking.setPartParentId(selectPacking.getId());
PackingLog packingLog = new PackingLog(); PackingLog packingLog = new PackingLog();
packingLog.setPackingId(originPacking.getId()); 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); packingLogService.add(packingLog);
update(originPacking); update(originPacking);
} }
...@@ -977,23 +982,25 @@ public class PackingLibraryServiceImpl implements PackingLibraryService { ...@@ -977,23 +982,25 @@ public class PackingLibraryServiceImpl implements PackingLibraryService {
if (packingLibrary.getIsPart() == 1) { if (packingLibrary.getIsPart() == 1) {
//说明是附件目录 //说明是附件目录
List<DeviceLibrary> deviceLibraries = deviceLibraryService.findAllByPackingId(packingLibrary.getId()); List<DeviceLibrary> deviceLibraries = deviceLibraryService.findAllByPackingId(packingLibrary.getId());
List<Integer> deviceIds = deviceLibraries.stream().map(DeviceLibrary::getId).collect(Collectors.toList()); if (deviceLibraries.size()>0){
//将装备的父id全部置空 List<Integer> deviceIds = deviceLibraries.stream().map(DeviceLibrary::getId).collect(Collectors.toList());
Integer userId = userUtils.getCurrentUserId(); //将装备的父id全部置空
List<DeviceLogDto> deviceLogDtos = new ArrayList<>(); Integer userId = userUtils.getCurrentUserId();
long l = System.currentTimeMillis(); List<DeviceLogDto> deviceLogDtos = new ArrayList<>();
deviceLibraryService.updatePartParentId(deviceIds); long l = System.currentTimeMillis();
log.info("更新父id时间为:{}",System.currentTimeMillis()-l); deviceLibraryService.updatePartParentId(deviceIds);
deviceLibraries.forEach(deviceLibrary -> { log.info("更新父id时间为:{}",System.currentTimeMillis()-l);
DeviceLogDto deviceLogDto = new DeviceLogDto(); deviceLibraries.forEach(deviceLibrary -> {
deviceLogDto.setDeviceId(deviceLibrary.getId()); DeviceLogDto deviceLogDto = new DeviceLogDto();
deviceLogDto.setRemark("由于列装进行了解绑,装备也需要进行解绑"); deviceLogDto.setDeviceId(deviceLibrary.getId());
deviceLogDto.setCreateUserId(userId); deviceLogDto.setRemark("由于列装进行了解绑,装备也需要进行解绑");
deviceLogDtos.add(deviceLogDto); deviceLogDto.setCreateUserId(userId);
}); deviceLogDtos.add(deviceLogDto);
executor.execute(()->{ });
deviceLogService.addAllLog(deviceLogDtos); executor.execute(()->{
}); deviceLogService.addAllLog(deviceLogDtos);
});
}
} }
//修改列装 //修改列装
packingLibrary.setPartParentId(null); packingLibrary.setPartParentId(null);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论