Commit 0b074730 zshaohui

sorting扫描料盘出库

1 个父辈 2205f05b
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.controller; package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.controller;
import com.neotel.smfcore.common.bean.ResultBean; import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils; import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.enums.BARCODE_STATUS; import com.neotel.smfcore.core.barcode.enums.BARCODE_STATUS;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager; import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve; import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderItemManager;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderManager;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.order.service.po.LiteOrderItem;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager; import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.StoragePos; import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.BoxHandleUtil; import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util.BoxHandleUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import javafx.concurrent.Task;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -33,6 +45,15 @@ public class TicketSortingController { ...@@ -33,6 +45,15 @@ public class TicketSortingController {
@Autowired @Autowired
private IBarcodeManager barcodeManager; private IBarcodeManager barcodeManager;
@Autowired
private ILiteOrderItemManager liteOrderItemManager;
@Autowired
private TaskService taskService;
@Autowired
private IDataLogManager dataLogManager;
@ApiOperation("获取料箱信息") @ApiOperation("获取料箱信息")
@RequestMapping("/boxInfo") @RequestMapping("/boxInfo")
...@@ -103,44 +124,224 @@ public class TicketSortingController { ...@@ -103,44 +124,224 @@ public class TicketSortingController {
boxInfoList.add(list); boxInfoList.add(list);
} }
List<List<Object>> resultList = new ArrayList<>();
if (boxStr.startsWith("C07")) { if (boxStr.startsWith("C07")) {
if (boxStr.endsWith("A")) { if (boxStr.endsWith("A")) {
boxInfoList.add(boxInfoList.get(1)); resultList.add(boxInfoList.get(1));
boxInfoList.add(boxInfoList.get(3)); resultList.add(boxInfoList.get(3));
boxInfoList.add(boxInfoList.get(5)); resultList.add(boxInfoList.get(5));
boxInfoList.add(boxInfoList.get(0)); resultList.add(boxInfoList.get(0));
boxInfoList.add(boxInfoList.get(2)); resultList.add(boxInfoList.get(2));
boxInfoList.add(boxInfoList.get(4)); resultList.add(boxInfoList.get(4));
} else { } else {
boxInfoList.add(boxInfoList.get(4)); resultList.add(boxInfoList.get(4));
boxInfoList.add(boxInfoList.get(2)); resultList.add(boxInfoList.get(2));
boxInfoList.add(boxInfoList.get(0)); resultList.add(boxInfoList.get(0));
boxInfoList.add(boxInfoList.get(5)); resultList.add(boxInfoList.get(5));
boxInfoList.add(boxInfoList.get(3)); resultList.add(boxInfoList.get(3));
boxInfoList.add(boxInfoList.get(1)); resultList.add(boxInfoList.get(1));
} }
} else if (boxStr.startsWith("C13")) { } else if (boxStr.startsWith("C13")) {
if (boxStr.endsWith("A")) { if (boxStr.endsWith("A")) {
boxInfoList.add(boxInfoList.get(0)); resultList.add(boxInfoList.get(0));
boxInfoList.add(boxInfoList.get(1)); resultList.add(boxInfoList.get(1));
boxInfoList.add(boxInfoList.get(2)); resultList.add(boxInfoList.get(2));
} else { } else {
boxInfoList.add(boxInfoList.get(2)); resultList.add(boxInfoList.get(2));
boxInfoList.add(boxInfoList.get(1)); resultList.add(boxInfoList.get(1));
boxInfoList.add(boxInfoList.get(0)); resultList.add(boxInfoList.get(0));
} }
} else if (boxStr.startsWith("C15")) { } else if (boxStr.startsWith("C15")) {
if (boxStr.endsWith("A")) { if (boxStr.endsWith("A")) {
boxInfoList.add(boxInfoList.get(0)); resultList.add(boxInfoList.get(0));
boxInfoList.add(boxInfoList.get(1)); resultList.add(boxInfoList.get(1));
boxInfoList.add(boxInfoList.get(2)); resultList.add(boxInfoList.get(2));
} else { } else {
boxInfoList.add(boxInfoList.get(2)); resultList.add(boxInfoList.get(2));
boxInfoList.add(boxInfoList.get(1)); resultList.add(boxInfoList.get(1));
boxInfoList.add(boxInfoList.get(0)); resultList.add(boxInfoList.get(0));
} }
} }
return ResultBean.newOkResult(boxInfoList); return ResultBean.newOkResult(boxInfoList);
} }
@ApiOperation("扫描隔扣码")
@RequestMapping("/scanPar")
@AnonymousAccess
public ResultBean scanPar(String boxStr, String parStr) {
if (StringUtils.isEmpty(parStr)) {
return ResultBean.newErrorResult(-1, "", "料格条码不能为空");
}
if (!parStr.startsWith("C07") && !parStr.startsWith("C15") && !parStr.startsWith("C15")) {
return ResultBean.newErrorResult(-1, "", parStr + "料格条码不正确");
}
Barcode barcode = codeResolve.resolveOneValideBarcode(boxStr);
if (barcode == null) {
return ResultBean.newErrorResult(-1, "", boxStr + "料箱条码不正确");
}
StoragePos pos = BoxHandleUtil.locOnePos(barcode);
if (pos != null) {
if (pos.getBarcode() != null) {
barcode = pos.getBarcode();
}
}
if (!parStr.startsWith(barcode.getBarcode())) {
return ResultBean.newErrorResult(-1, "", parStr + "与不是料箱:" + boxStr + "的料格");
}
int outBarcodeCount = 0;
List<Barcode> needOutBarcodeList = new ArrayList<>();
List<Barcode> subCodeList = barcode.getSubCodeList();
for (Barcode subCode : subCodeList) {
if (parStr.equals(subCode.getPosName())) {
needOutBarcodeList.add(subCode);
if (subCode.isOut()) {
outBarcodeCount = outBarcodeCount + 1;
}
}
}
//判断有没有出库的物料
if (outBarcodeCount == 0) {
return ResultBean.newErrorResult(-1, "", parStr + "没有sorting的物料");
}
if (needOutBarcodeList == null || needOutBarcodeList.isEmpty()) {
return ResultBean.newErrorResult(-1, "", parStr + "没有sorting的物料");
}
for (Barcode needOutBarcode : needOutBarcodeList) {
needOutBarcode.updateExtraData("status", "1");
barcodeManager.save(needOutBarcode);
barcode.updateSubCodes(needOutBarcode);
}
barcode = barcodeManager.save(barcode);
if (pos != null) {
pos.setBarcode(barcode);
storagePosManager.save(pos);
}
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("all", needOutBarcodeList.size());
resultMap.put("ng", outBarcodeCount);
return ResultBean.newOkResult(resultMap);
}
@ApiOperation("扫描物料条码")
@RequestMapping("/scanReel")
@AnonymousAccess
public ResultBean scanReel(@RequestBody Map<String, String> paramMap) {
String codeStr = paramMap.get("codeStr");
String parStr = paramMap.get("parStr");
String boxStr = paramMap.get("boxStr");
if (StringUtils.isEmpty(codeStr)) {
return ResultBean.newErrorResult(-1, "", "料盘条码不能为空");
}
Barcode boxBarcode = codeResolve.resolveOneValideBarcode(boxStr);
if (boxBarcode == null) {
return ResultBean.newErrorResult(-1, "", boxStr + "料箱条码不正确");
}
StoragePos pos = BoxHandleUtil.locOnePos(boxBarcode);
if (pos != null){
if (pos.getBarcode() != null){
boxBarcode = pos.getBarcode();
}
}
Barcode barcode = codeResolve.resolveOneValideBarcode(codeStr);
if (barcode == null) {
return ResultBean.newErrorResult(-1, "", codeStr + "料箱条码不正确");
}
if (!barcode.getPosName().equals(parStr)) {
return ResultBean.newErrorResult(-1, "", barcode.getBarcode() + "不在料格:" + parStr + "中");
}
Map<String,Integer> resultMap = new HashMap<>();
resultMap.put("ng",0);
//判断是不是要出库的物料
if (barcode.isOut()) {
barcode.setOut(false);
barcode.setOrderItemId("");
barcode.setPosName("");
barcode = barcodeManager.save(barcode);
boxBarcode.removeFromSubCodes(barcode);
boxBarcode = barcodeManager.save(boxBarcode);
if (pos != null){
pos.setBarcode(boxBarcode);
storagePosManager.save(pos);
}
DataLog task = new DataLog();
task.setBarcode(barcode.getBarcode());
task.setPartNumber(barcode.getPartNumber());
task.setNum(barcode.getAmount());
task.setType(OP.CHECKOUT);
task.setStatus(OP_STATUS.FINISHED.name());
task.setOperator(SecurityUtils.getLoginUsername()+"Sorting出库");
//生成出库任务
String itemId = barcode.getOrderItemId();
if (StringUtils.isNotEmpty(itemId)){
LiteOrderItem item = liteOrderItemManager.get(itemId);
if (item != null){
task.setSourceId(item.getOrderId());
task.setSourceName(item.getOrderNo());
task.setSubSourceId(item.getId());
}
}
dataLogManager.save(task);
taskService.moveTaskToFinished(task);
resultMap.put("ng",1);
} else {
barcode.setSeq(getSeq(boxBarcode,barcode.getPosName()));
barcode.updateExtraData("status",null);
barcodeManager.save(barcode);
boxBarcode.updateSubCodes(barcode);
boxBarcode = barcodeManager.save(boxBarcode);
if (pos != null){
pos.setBarcode(boxBarcode);
storagePosManager.save(pos);
}
}
return ResultBean.newOkResult(resultMap);
}
public int getSeq(Barcode boxBarcode, String posName) {
int seq = 0;
List<Barcode> subCodeList = boxBarcode.getSubCodeList();
if (subCodeList != null && !subCodeList.isEmpty()) {
for (Barcode subCode : subCodeList) {
if (subCode.getPosName().equals(posName)) {
String status = subCode.getExtraData("status");
if (StringUtils.isEmpty(status)) {
if (seq < subCode.getSeq()) {
seq = subCode.getSeq();
}
}
}
}
}
seq = seq + 1;
return seq;
}
} }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!