Commit dae3e29e hc

fix:代码优化

1 个父辈 a86ccf55
...@@ -62,7 +62,6 @@ public class SpBoxPutInManagerImpl implements SpBoxPutInManager { ...@@ -62,7 +62,6 @@ public class SpBoxPutInManagerImpl implements SpBoxPutInManager {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public synchronized Map<String, String> reelToBox(Map<String, String> paramMap) throws Exception { public synchronized Map<String, String> reelToBox(Map<String, String> paramMap) throws Exception {
try {
String boxStr = paramMap.get("boxStr").trim(); String boxStr = paramMap.get("boxStr").trim();
String rellCodeStr = paramMap.get("codeStr").trim(); String rellCodeStr = paramMap.get("codeStr").trim();
String gekouCodeStr = paramMap.get("binCodeStr").trim(); String gekouCodeStr = paramMap.get("binCodeStr").trim();
...@@ -76,14 +75,12 @@ public class SpBoxPutInManagerImpl implements SpBoxPutInManager { ...@@ -76,14 +75,12 @@ public class SpBoxPutInManagerImpl implements SpBoxPutInManager {
if (boxBarcode == null) { if (boxBarcode == null) {
throw new Exception("不是有效的料箱条码"); throw new Exception("不是有效的料箱条码");
} }
addBackupObj(boxBarcode);
//解析料格信息 //解析料格信息
Barcode gekouBarcode = codeResolve.resolveOneValideBarcode("=2x2=" + gekouCodeStr); Barcode gekouBarcode = codeResolve.resolveOneValideBarcode("=2x2=" + gekouCodeStr);
if (gekouBarcode == null) { if (gekouBarcode == null) {
throw new Exception("不是有效的料格条码"); throw new Exception("不是有效的料格条码");
} }
addBackupObj(gekouBarcode);
//2.解析条码信息 //2.解析条码信息
CodeBarcode codeBarcode = CodeUtil.getCodeBarcode(rellCodeStr); CodeBarcode codeBarcode = CodeUtil.getCodeBarcode(rellCodeStr);
...@@ -132,7 +129,6 @@ public class SpBoxPutInManagerImpl implements SpBoxPutInManager { ...@@ -132,7 +129,6 @@ public class SpBoxPutInManagerImpl implements SpBoxPutInManager {
// return ResultBean.newErrorResult(-1,"","没有找到正在执行的入库单或者退库单"); // return ResultBean.newErrorResult(-1,"","没有找到正在执行的入库单或者退库单");
} else { } else {
baseNo = ObjectUtil.isEmpty(spareNo) ? returnInventoryNo : spareNo; baseNo = ObjectUtil.isEmpty(spareNo) ? returnInventoryNo : spareNo;
addBackupObj(baseNo);
//判断此料箱有没有待执行的出入库任务 //判断此料箱有没有待执行的出入库任务
List<String> needInPn = new ArrayList<>(); List<String> needInPn = new ArrayList<>();
...@@ -194,7 +190,6 @@ public class SpBoxPutInManagerImpl implements SpBoxPutInManager { ...@@ -194,7 +190,6 @@ public class SpBoxPutInManagerImpl implements SpBoxPutInManager {
// 寻找空库位 // 寻找空库位
StoragePos pos = SpBoxUtil.locOnePos(boxBarcode); StoragePos pos = SpBoxUtil.locOnePos(boxBarcode);
addBackupObj(pos);
// 将给pos赋值延迟到深拷贝库位对象之后 // 将给pos赋值延迟到深拷贝库位对象之后
// 开始放入料箱 // 开始放入料箱
...@@ -264,11 +259,6 @@ public class SpBoxPutInManagerImpl implements SpBoxPutInManager { ...@@ -264,11 +259,6 @@ public class SpBoxPutInManagerImpl implements SpBoxPutInManager {
} }
} }
return res; return res;
}catch (Exception e) {
// 回滚
rollBack();
throw new Exception(e.getMessage());
}
} }
// 入料接口使用了对象锁,可以 // 入料接口使用了对象锁,可以
...@@ -276,6 +266,7 @@ public class SpBoxPutInManagerImpl implements SpBoxPutInManager { ...@@ -276,6 +266,7 @@ public class SpBoxPutInManagerImpl implements SpBoxPutInManager {
private BaseNo backupSpareNo; private BaseNo backupSpareNo;
private StoragePos backupPos; private StoragePos backupPos;
@Deprecated
public void addBackupObj(Object o) { public void addBackupObj(Object o) {
if (o instanceof Barcode) { if (o instanceof Barcode) {
backupBarcodes.add(DeepCopyUtil.deepCopy((Barcode) o)); backupBarcodes.add(DeepCopyUtil.deepCopy((Barcode) o));
...@@ -286,6 +277,7 @@ public class SpBoxPutInManagerImpl implements SpBoxPutInManager { ...@@ -286,6 +277,7 @@ public class SpBoxPutInManagerImpl implements SpBoxPutInManager {
} }
} }
@Deprecated
public void rollBack() throws Exception { public void rollBack() throws Exception {
try { try {
log.info("开始回滚"); log.info("开始回滚");
...@@ -311,10 +303,11 @@ public class SpBoxPutInManagerImpl implements SpBoxPutInManager { ...@@ -311,10 +303,11 @@ public class SpBoxPutInManagerImpl implements SpBoxPutInManager {
log.info(String.format("库位[%s]回滚为"+backupPos, backupPos.getPosName())); log.info(String.format("库位[%s]回滚为"+backupPos, backupPos.getPosName()));
} }
}catch (Exception e) { }catch (Exception e) {
throw new Exception("回滚失败,失败原因:"+e.getMessage());
}finally {
backupBarcodes = new ArrayList<>(); backupBarcodes = new ArrayList<>();
backupPos = null; backupPos = null;
backupSpareNo = null; backupSpareNo = null;
throw new Exception("回滚失败,失败原因:"+e.getMessage());
} }
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!