Commit 8f064138 zshaohui

1.呼叫料箱放到料盒操作里

1 个父辈 d512443b
......@@ -22,15 +22,20 @@ 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.po.Storage;
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.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
......@@ -542,6 +547,76 @@ public class MaterialBoxController {
return ResultBean.newOkResult("");
}
/**
* 1:出库未满同物料最少料箱
* 2:出库未满物料最少料箱
*/
@RequestMapping("/callBox")
@AnonymousAccess
public ResultBean callBox(@RequestBody Map<String, String> paramMap) {
String barcode = paramMap.get("barcode");
String type = paramMap.get("type");
log.info("出库请求--barcode:{},type:{}", barcode, type);
if (StringUtils.isBlank(type)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "请选择出库方式", new String[]{"type"});
}
StoragePos pos = null;
if ("1".equals(type)) {
if (StringUtils.isBlank(barcode)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{}出库同规格物料最少料箱时,{}不能为空", new String[]{"barcode"});
}
//解析barcode条码
CodeBean codeBean = codeResolve.resolveSingleCode("=1x1=" + barcode);
if (!codeBean.isValid()) {
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.invalid", "{}条码无效", new String[]{"barcode"});
}
pos = getAvailableBox(codeBean.getBarcode().getPartNumber());
} else if ("2".equals(type)) {
pos = getAvailableBox(null);
}
if (pos == null) {
return ResultBean.newErrorResult(-1, "", "未找到可用料箱", new String[]{});
}
Storage storage = dataCache.getStorageById(pos.getStorageId());
DataLog task = new DataLog(storage, pos.getBarcode(), pos);
task.setType(OP.CHECKOUT);
taskService.updateQueueTask(task);
return ResultBean.newOkResult("出库的料箱为" + pos.getBarcode().getBarcode());
}
private StoragePos getAvailableBox(String partNumber) {
String storageId = "";
Map<String, Storage> allStorage = dataCache.getAllStorage();
for (Storage storage : allStorage.values()) {
if (storage.isXLC()) {
storageId = storage.getId();
break;
}
}
Criteria c = Criteria.where("barcode").exists(true)
.and("enabled").is(true) //可用
.and("barcode.fillUp").is(false); //未装满
if (StringUtils.isNotBlank(partNumber)) {
c.and("barcode.subCodeList.partNumber").is(partNumber);
}
//排除掉正在执行的仓位
Collection<String> excludePosIds = taskService.excludePosIds();
if (excludePosIds != null && !excludePosIds.isEmpty()) {
c.and("id").nin(excludePosIds);
}
//xlc类型的
if (StringUtils.isNotBlank(storageId)) {
c.and("storageId").is(storageId);
}
Query query = new Query(c).with(Sort.by(Sort.Direction.ASC, "barcode.amount")).limit(1);
List<StoragePos> storagePoss = storagePosManager.findByQuery(query);
if (storagePoss != null && !storagePoss.isEmpty()) {
return storagePoss.get(0);
}
return null;
}
private Component autoGetComponent(String pnStr,int opQty){
Component component = componentManager.findOneByPN(pnStr);
......
package com.neotel.smfcore.core.storage.rest;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.bean.CodeBean;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@Slf4j
@Api(tags = "物料管理:料箱出库")
@RestController
@RequestMapping("/api/materialCall")
public class MaterialCallBoxController {
@Autowired
private IStoragePosManager storagePosManager;
@Autowired
private DataCache dataCache;
@Autowired
private TaskService taskService;
@Autowired
private CodeResolve codeResolve;
/**
* 1:出库未满同规格物料最少料箱
* 2:出库未满物料最少料箱
*/
@RequestMapping("/callBox")
@AnonymousAccess
public ResultBean callBox(@RequestBody Map<String, String> paramMap) {
String barcode = paramMap.get("barcode");
String type = paramMap.get("type");
log.info("出库请求--barcode:{},type:{}", barcode, type);
if (StringUtils.isBlank(type)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "请选择出库方式", new String[]{"type"});
}
StoragePos pos = null;
if ("1".equals(type)) {
if (StringUtils.isBlank(barcode)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{}出库同规格物料最少料箱时,{}不能为空", new String[]{"barcode"});
}
//解析barcode条码
CodeBean codeBean = codeResolve.resolveSingleCode("=1x1=" + barcode);
if (!codeBean.isValid()) {
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.invalid", "{}条码无效", new String[]{"barcode"});
}
pos = getAvailableBox(codeBean.getBarcode().getPartNumber());
} else if ("2".equals(type)) {
pos = getAvailableBox(null);
}
if (pos == null) {
return ResultBean.newErrorResult(-1, "", "未找到可用料箱", new String[]{});
}
Storage storage = dataCache.getStorageById(pos.getStorageId());
DataLog task = new DataLog(storage, pos.getBarcode(), pos);
task.setType(OP.CHECKOUT);
taskService.updateQueueTask(task);
return ResultBean.newOkResult("出库的料箱为" + pos.getBarcode().getBarcode());
}
private StoragePos getAvailableBox(String partNumber) {
String storageId = "";
Map<String, Storage> allStorage = dataCache.getAllStorage();
for (Storage storage : allStorage.values()) {
if (storage.isXLC()) {
storageId = storage.getId();
break;
}
}
Criteria c = Criteria.where("barcode").exists(true)
.and("enabled").is(true) //可用
.and("barcode.fillUp").is(false); //未装满
if (StringUtils.isNotBlank(partNumber)) {
c.and("barcode.subCodeList.partNumber").is(partNumber);
}
//排除掉正在执行的仓位
Collection<String> excludePosIds = taskService.excludePosIds();
if (excludePosIds != null && !excludePosIds.isEmpty()) {
c.and("id").nin(excludePosIds);
}
//xlc类型的
if (StringUtils.isNotBlank(storageId)) {
c.and("storageId").is(storageId);
}
Query query = new Query(c).with(Sort.by(Sort.Direction.ASC, "barcode.amount")).limit(1);
List<StoragePos> storagePoss = storagePosManager.findByQuery(query);
if (storagePoss != null && !storagePoss.isEmpty()) {
return storagePoss.get(0);
}
return null;
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!