Commit 4310e7fa hc

fix:手动入库,手动出库优化

1 个父辈 45350f13
......@@ -31,4 +31,5 @@ public interface IBarcodeManager extends IBaseManager<Barcode> {
int countByQuery(Query query);
boolean partNumberIsAlreadyInThisOrNever(String bin, String partNumber);
}
package com.neotel.smfcore.core.barcode.service.manager.impl;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.base.Strings;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.exception.ValidateException;
......@@ -20,12 +19,13 @@ import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
import com.neotel.smfcore.custom.luxsan_sp.util.SpBoxUtil;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@Slf4j
@Service
......@@ -214,6 +214,19 @@ public class BarcodeManagerImpl implements IBarcodeManager {
return barcodeDao.countByQuery(query);
}
@Override
public boolean partNumberIsAlreadyInThisOrNever(String bin, String partNumber) {
Query query = new Query(Criteria.where("subCodeList.partNumber").is(partNumber));
List<String> barcodes = new ArrayList<>();
for (Barcode barcode : (List<Barcode>) barcodeDao.findByQuery(query)) {
barcodes.addAll(barcode.getSubCodeList().stream()
.map(Barcode::getBarcode).collect(Collectors.toList()));
}
for (String barcode : barcodes) {
return barcode.equals(bin);
}
return true;
}
protected boolean validateComponent(Barcode barcode) {
return componentManager.findOneByPN(barcode.getPartNumber()) != null;
......
......@@ -35,8 +35,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
@Api(tags = "备件仓 料箱入库")
......@@ -139,6 +137,24 @@ public class SpBoxPutInController {
return ResultBean.newErrorResult(-1, "", binCodeStr + "不是有效的条码");
}
//2.解析条码信息
CodeBarcode codeBarcode = CodeUtil.getCodeBarcode(codeStr);
if (codeBarcode == null) {
return ResultBean.newErrorResult(-1, "", codeStr + "不是有效的条码");
}
// 判断物料是否在其他格口
boolean isAlreadyInThisOrNever = barcodeManager.partNumberIsAlreadyInThisOrNever(binCodeStr, codeBarcode.getPartNumber());
if (!isAlreadyInThisOrNever) {
return ResultBean.newErrorResult(-1, "", codeBarcode.getPartNumber() + "已经存在其他料格");
}
if (boxBarcode.getPartNumber().equals(binBarcode.getPartNumber())) {
binBarcode.setPartNumber(null);
}
//1.判断料格信息与料箱信息是否匹配
if (!binBarcode.getBarcode().startsWith(boxBarcode.getBarcode())) {
return ResultBean.newErrorResult(-1, "", binCodeStr + "不是当前料箱:" + boxStr + "的隔口");
......@@ -160,11 +176,6 @@ public class SpBoxPutInController {
}
//2.解析条码信息
CodeBarcode codeBarcode = CodeUtil.getCodeBarcode(codeStr);
if (codeBarcode == null) {
return ResultBean.newErrorResult(-1, "", codeStr + "不是有效的条码");
}
//判断有没有正在执行入库单
SpareNo spareNo = spareNoCache.getExecutIngSpareNo();
......@@ -201,6 +212,7 @@ public class SpBoxPutInController {
if (isOrderPutIn) {
}else {
isMatch = true;
barcode.setPartNumber(codePartNumber);
}
}
......
......@@ -137,10 +137,13 @@ public class SpBoxUtil {
String partNumber = getPartNumber(subCodeList, materialBarcode);
SpareNoDetail activeDetail = null;
if (ObjectUtil.isNotNull(activeDetails)) {
activeDetail = activeDetails.stream()
List<SpareNoDetail> spareNoDetails = activeDetails.stream()
.filter(spareNoDetail -> spareNoDetail.getPartno().equals(partNumber))
.limit(1)
.collect(Collectors.toList()).get(0);
.collect(Collectors.toList());
if (!spareNoDetails.isEmpty()) {
activeDetail = spareNoDetails.get(0);
}
}
if (ObjectUtil.isNull(activeDetail)) {
par.add(0);
......@@ -201,7 +204,8 @@ public class SpBoxUtil {
public static int getAmount(List<Barcode> subCodeList,String reelId){
if (subCodeList != null && !subCodeList.isEmpty()){
for (Barcode barcode : subCodeList) {
if (reelId.equals(barcode.getBarcode())){
if (reelId.replace("0", "")
.equals(barcode.getBarcode().replace("0", ""))){
return barcode.getAmount();
}
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!