提交 f567c483 authored 作者: 邓砥奕's avatar 邓砥奕

修改入库

上级 024f55eb
...@@ -23,17 +23,22 @@ public class DeviceSeqUtil { ...@@ -23,17 +23,22 @@ public class DeviceSeqUtil {
//按,分隔多个区间 //按,分隔多个区间
String[] strings = s.split(","); String[] strings = s.split(",");
if (strings.length==1){ if (strings.length==1){
String num1 = strings[0].replaceAll(".*[^\\d](?=(\\d+))", ""); if (isSingle(strings[0])) {
int minSeq = Integer.parseInt(num1); String num1 = strings[0].replaceAll(".*[^\\d](?=(\\d+))", "");
for (int i =0;i<num;i++){ int minSeq = Integer.parseInt(num1);
StringBuffer stringBuffer = new StringBuffer(); for (int i = 0; i < num; i++) {
//拼接数字之前的字符串 StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(s, 0, s.length()-num1.length()); //拼接数字之前的字符串
//将数字按长度格式化,缺位补0 stringBuffer.append(s, 0, s.length() - num1.length());
String codeFormat = "%0"+ num1.length() +"d"; //将数字按长度格式化,缺位补0
stringBuffer.append(String.format(codeFormat,minSeq)); String codeFormat = "%0" + num1.length() + "d";
seqs.add(stringBuffer.toString()); stringBuffer.append(String.format(codeFormat, minSeq));
minSeq++; seqs.add(stringBuffer.toString());
minSeq++;
}
}
else {
seqs.addAll(getIntervalSeqs(strings[0]));
} }
} }
else { else {
......
...@@ -93,24 +93,43 @@ public class StorageBillController { ...@@ -93,24 +93,43 @@ public class StorageBillController {
@PostMapping(value = "/addStorageDetail") @PostMapping(value = "/addStorageDetail")
public ResponseEntity addStorageDetail(@RequestBody List<StorageBillDetailVo> list) { public ResponseEntity addStorageDetail(@RequestBody List<StorageBillDetailVo> list) {
List<PackingLibrary> libraryEntities = new ArrayList<>(); List<PackingLibrary> libraryEntities = new ArrayList<>();
Map<Integer, Integer> map = new HashMap<>(); Map<Integer, List<PackingLibrary>> map = new HashMap<>();
for (StorageBillDetailVo s : list) { for (StorageBillDetailVo s : list) {
List<String> strings = DeviceSeqUtil.createDeviceSeqs(s.getSeqInterval(),s.getStorageCount());
List<List<String>> sons = new ArrayList<>();
int count = 1; int count = 1;
Integer deviceNum = s.getStorageCount(); Integer deviceNum = s.getStorageCount();
while (deviceNum >= count) { while (deviceNum >= count) {
PackingLibrary packingLibraryEntity = new PackingLibrary(); PackingLibrary packingLibraryEntity = new PackingLibrary();
BeanUtils.copyProperties(packingLibraryService.getOne(s.getPackingId()), packingLibraryEntity); BeanUtils.copyProperties(packingLibraryService.getOne(s.getPackingId()), packingLibraryEntity);
packingLibraryEntity.setCorresponding(count); packingLibraryEntity.setCorresponding(count);
packingLibraryEntity.setSeq(strings.get(0));
strings.remove(0);
libraryEntities.add(packingLibraryEntity); libraryEntities.add(packingLibraryEntity);
if (s.getList() != null && s.getList().size() != 0) { if (s.getList() != null && s.getList().size() != 0) {
for (StorageBillDetailVo s2 : s.getList()) { for (int j = 0;j<s.getList().size();j++) {
StorageBillDetailVo s2 = s.getList().get(j);
if (j>=sons.size()){
sons.add(DeviceSeqUtil.createDeviceSeqs(s2.getSeqInterval(),s2.getStorageCount()));
}
packingLibraryEntity = packingLibraryService.getOne(s2.getPackingId()); packingLibraryEntity = packingLibraryService.getOne(s2.getPackingId());
List<String> strings2 = sons.get(j);
if (s2.getStorageCount() >= count) { if (s2.getStorageCount() >= count) {
packingLibraryEntity.setCorresponding(count); packingLibraryEntity.setCorresponding(count);
packingLibraryEntity.setSeq(strings2.get(0));
strings2.remove(0);
libraryEntities.add(packingLibraryEntity); libraryEntities.add(packingLibraryEntity);
} }
if (s2.getStorageCount() > deviceNum) { if (s2.getStorageCount()-strings2.size()==deviceNum) {
map.put(s2.getPackingId(), s2.getStorageCount() - deviceNum); List<PackingLibrary> packingLibraries = new ArrayList<>();
for (int i = 0;i<s2.getStorageCount()-deviceNum;i++){
packingLibraryEntity = packingLibraryService.getOne(s2.getPackingId());
packingLibraryEntity.setCorresponding(0);
packingLibraryEntity.setSeq(strings2.get(0));
strings2.remove(0);
packingLibraries.add(packingLibraryEntity);
}
map.put(s2.getPackingId(), packingLibraries);
} }
} }
...@@ -119,11 +138,7 @@ public class StorageBillController { ...@@ -119,11 +138,7 @@ public class StorageBillController {
} }
} }
for (Integer i : map.keySet()) { for (Integer i : map.keySet()) {
for (int j = 1; j <= map.get(i); j++) { libraryEntities.addAll(map.get(i));
PackingLibrary packingLibraryEntity = packingLibraryService.getOne(i);
packingLibraryEntity.setCorresponding(0);
libraryEntities.add(packingLibraryEntity);
}
} }
return ResultUtil.success(libraryEntities); return ResultUtil.success(libraryEntities);
} }
......
...@@ -19,4 +19,6 @@ public class StorageBillDetailVo { ...@@ -19,4 +19,6 @@ public class StorageBillDetailVo {
private Integer packingId; private Integer packingId;
@ApiModelProperty(value = "入库数量") @ApiModelProperty(value = "入库数量")
private Integer storageCount; private Integer storageCount;
@ApiModelProperty(value = "序列号区间")
private String seqInterval;
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论