提交 74f70dc9 authored 作者: zhoushaopan's avatar zhoushaopan

fix(装备模块,配套设备模块,自查模块,列装模块): 解决了配套设备库的入库数量和序列号区间的验证,装备新增根据存放位置查询,自查根据库房位置查询装备,列装修改阅知

解决了配套设备库的入库数量和序列号区间的验证,装备新增根据存放位置查询,自查根据库房位置查询装备,列装修改阅知
上级 c6f20d5e
...@@ -183,11 +183,12 @@ public class DeviceLibraryController { ...@@ -183,11 +183,12 @@ public class DeviceLibraryController {
} }
@ApiOperation(value = "查询检查装备列表", notes = "可以通过这个接口查询装备列表") @ApiOperation(value = "查询检查装备列表", notes = "可以通过这个接口查询装备列表")
@GetMapping("/selectCheckDeviceList") @PostMapping("/selectCheckDeviceList")
public ResponseEntity selectDeviceList() { public ResponseEntity selectDeviceList(@RequestBody SelfCheckVo selfCheckVo) {
String unit = userUtils.getCurrentUserUnitName(); String unit = userUtils.getCurrentUserUnitName();
PredicateBuilder<DeviceLibrary> predicateBuilder = Specifications.and(); PredicateBuilder<DeviceLibrary> predicateBuilder = Specifications.and();
predicateBuilder.eq("ownUnit", unit); predicateBuilder.eq("ownUnit", unit);
predicateBuilder.eq(selfCheckVo.getStorageLocationId()!=null,"storageLocationId",selfCheckVo.getStorageLocationId());
List<DeviceLibrary> deviceLibraries = deviceLibraryDao.findAll(predicateBuilder.build()); List<DeviceLibrary> deviceLibraries = deviceLibraryDao.findAll(predicateBuilder.build());
deviceLibraries.forEach(DeviceLibrary::setConfigName); deviceLibraries.forEach(DeviceLibrary::setConfigName);
List<DeviceLibrary> deviceLibraryEntities = deviceLibraries.stream() List<DeviceLibrary> deviceLibraryEntities = deviceLibraries.stream()
...@@ -456,6 +457,7 @@ public class DeviceLibraryController { ...@@ -456,6 +457,7 @@ public class DeviceLibraryController {
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
List<DeviceLibrary> resultList = deviceLibraryService.getList(deviceLibrarySelectVo); List<DeviceLibrary> resultList = deviceLibraryService.getList(deviceLibrarySelectVo);
map.put("resultList",resultList);
// List<DeviceLibrary> resultList = new ArrayList<>(); // List<DeviceLibrary> resultList = new ArrayList<>();
// resultList = deviceLibraryService.getAlldevList(deviceLibrarySelectVo); // resultList = deviceLibraryService.getAlldevList(deviceLibrarySelectVo);
// List<DeviceLibrary> resultList = deviceLibraryService.getList(deviceLibrarySelectVo); // List<DeviceLibrary> resultList = deviceLibraryService.getList(deviceLibrarySelectVo);
......
package com.tykj.dev.device.library.subject.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author zsp
* @create 2021/11/23 14:37
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("自查装备的vo")
public class SelfCheckVo {
@ApiModelProperty(value = "库存位置的id")
private Integer storageLocationId;
}
...@@ -122,7 +122,9 @@ public class MatchingDeviceController { ...@@ -122,7 +122,9 @@ public class MatchingDeviceController {
//当手动输入序列号的时候 需要进行遍历成集合 //当手动输入序列号的时候 需要进行遍历成集合
matchingDeviceSaveVos.forEach(matchingDeviceSaveVo -> { matchingDeviceSaveVos.forEach(matchingDeviceSaveVo -> {
// List<String> deviceSeqs = DeviceSeqUtil.createDeviceSeqs(matchingDeviceSaveVo.getSeqNumber(), matchingDeviceSaveVo.getStorageCount()); // List<String> deviceSeqs = DeviceSeqUtil.createDeviceSeqs(matchingDeviceSaveVo.getSeqNumber(), matchingDeviceSaveVo.getStorageCount());
List<String> deviceSeqs = DeviceSeqUtil.getIntervalSeqsForMatchingDevice(matchingDeviceSaveVo.getSeqNumber()); // List<String> deviceSeqs = DeviceSeqUtil.getIntervalSeqsForMatchingDevice(matchingDeviceSaveVo.getSeqNumber());
List<String> deviceSeqs = DeviceSeqUtil.selectDeviceSeqsForMatchingDevice( matchingDeviceSaveVo.getSeqNumber());
// List<String> deviceSeqs = DeviceSeqUtil.selectDeviceSeqs(matchingDeviceSaveVo.getSeqNumber());
matchingDeviceSaveVo.setSeqList(deviceSeqs); matchingDeviceSaveVo.setSeqList(deviceSeqs);
}); });
//做校验 数量跟序列号 //做校验 数量跟序列号
......
...@@ -221,6 +221,49 @@ public class DeviceSeqUtil { ...@@ -221,6 +221,49 @@ public class DeviceSeqUtil {
return seqs; return seqs;
} }
public static List<String> selectDeviceSeqsForMatchingDevice(String s){
List<String> seqs = new ArrayList<>();
if (s!=null&&s.length()>0) {
//按,分隔多个区间
String[] strings = s.split(",");
if (strings.length==1){
if (isSingle(strings[0])) {
String num1 = strings[0].replaceAll(".*[^\\d](?=(\\d+))", "");
if (num1.equals(strings[0])){
seqs.add(num1);
return seqs;
}
BigInteger minSeq = new BigInteger(num1);
for (int i = 0; i < 1; i++) {
StringBuffer stringBuffer = new StringBuffer();
//拼接数字之前的字符串
stringBuffer.append(s, 0, s.length() - num1.length());
//将数字按长度格式化,缺位补0
String codeFormat = "%0" + num1.length() + "d";
stringBuffer.append(String.format(codeFormat, minSeq));
seqs.add(stringBuffer.toString());
minSeq = minSeq.add(new BigInteger("1"));
}
}
else {
seqs.addAll(getIntervalSeqsForMatchingDevice(strings[0]));
}
}
else {
for (String str : strings) {
if (str.length() > 0) {
if (isSingle(str)) {
seqs.add(str);
} else {
seqs.addAll(getIntervalSeqsForMatchingDevice(str));
}
}
}
}
}
return seqs;
}
/** /**
* @param s 区间字符串 * @param s 区间字符串
* 判断是单个序列号还是序列号区间,若是单个序列号返回true,否则返回false * 判断是单个序列号还是序列号区间,若是单个序列号返回true,否则返回false
...@@ -292,6 +335,12 @@ public class DeviceSeqUtil { ...@@ -292,6 +335,12 @@ public class DeviceSeqUtil {
List<String> stringList = new ArrayList<>(); List<String> stringList = new ArrayList<>();
//根据-分隔 //根据-分隔
String[] strings = s.split("-"); String[] strings = s.split("-");
//先判断是不是区间
//1.是否有多个-
int count = getCount(s);
if (count>1){
throw new ApiException("序列号区间包含多个-,或者输入不是序列号区间");
}
if(strings.length==2){ if(strings.length==2){
//左区间字符串 //左区间字符串
String s1 = strings[0]; String s1 = strings[0];
...@@ -302,9 +351,18 @@ public class DeviceSeqUtil { ...@@ -302,9 +351,18 @@ public class DeviceSeqUtil {
// } // }
// else { // else {
//获得左区间最后几位的数字 //获得左区间最后几位的数字
//2.区间如果含有字母 判断区间前后字母是否一样
String num1 = s1.replaceAll(".*[^\\d](?=(\\d+))", ""); String num1 = s1.replaceAll(".*[^\\d](?=(\\d+))", "");
//获取索引 然后截取
int i = s1.indexOf(num1);
String substring1 = s1.substring(0, i);
//获得右区间最后几位的数字 //获得右区间最后几位的数字
String num2 = s2.replaceAll(".*[^\\d](?=(\\d+))", ""); String num2 = s2.replaceAll(".*[^\\d](?=(\\d+))", "");
int i2 = s2.indexOf(num2);
String substring2 = s2.substring(0, i2);
if (!substring1.equals(substring2)){
throw new ApiException("输入的序列号区间有误");
}
// if (num1.length() != num2.length()){ // if (num1.length() != num2.length()){
//// throw new ApiException("序列号区间后面数字位数不相同"); //// throw new ApiException("序列号区间后面数字位数不相同");
// } // }
...@@ -334,7 +392,9 @@ public class DeviceSeqUtil { ...@@ -334,7 +392,9 @@ public class DeviceSeqUtil {
} }
// } // }
else { else {
throw new ApiException("序列号区间包含多个-,或者输入不是序列号区间"); // throw new ApiException("序列号区间包含多个-,或者输入不是序列号区间");
stringList.add(s);
return stringList;
} }
return stringList; return stringList;
} }
...@@ -488,4 +548,16 @@ public class DeviceSeqUtil { ...@@ -488,4 +548,16 @@ public class DeviceSeqUtil {
return s.substring(0, s.length()-s1.length()); return s.substring(0, s.length()-s1.length());
} }
private static int getCount(String s){
char searchChar = '-';
int count = 0;
char[] charArray = s.toCharArray();
for (char item : charArray) {
if (item == searchChar) {
count++;
}
}
return count;
}
} }
...@@ -320,7 +320,9 @@ public class PackingController { ...@@ -320,7 +320,9 @@ public class PackingController {
@PostMapping("/clean") @PostMapping("/clean")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity clean(@RequestBody List<Integer> ids){ public ResponseEntity clean(@RequestBody List<Integer> ids){
if (!ids.isEmpty()){
packingLibraryService.cleanAll(ids); packingLibraryService.cleanAll(ids);
}
return ResponseEntity.ok("删除成功"); return ResponseEntity.ok("删除成功");
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论