Commit 63ec2006 张少辉

1.浩博料架出入库对接

1 个父辈 98add3e8
......@@ -823,6 +823,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
//仓位状态
barcodeDB.setCheckOutDate(new Date(), task.getOperator());
barcodeDB.setPosName("");
barcodeDB.setOnlySingleOut(false);
barcodeManager.save(barcodeDB);
task.setBatchInfo(barcodeDB.getBatch());
......
package com.neotel.smfcore.core.device.handler.impl;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.base.Strings;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.order.enums.ORDER_COLOR;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.bean.OrderSetting;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.security.TokenProvider;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@Api(tags = "SHELF: NLP感应料架(浩博)")
@RestController
@Slf4j
public class NLPHBShelfHandler extends BaseDeviceHandler {
@Autowired
private TokenProvider tokenProvider;
@Autowired
private DataCache dataCache;
ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(1);
@PostConstruct
private void init() {
scheduledThreadPool.scheduleWithFixedDelay(() -> {
OrderSetting orderSetting = dataCache.getOrderSetting();
boolean openZhiYin = orderSetting.getShelfLightType().equals(1);
Map<String, List<DataLog>> outMap = new HashMap<>();
for (Storage storage : dataCache.getAllStorage().values()) {
if (storage.isNLPHBShelf()) {
Collection<DataLog> queueTasks = taskService.getQueueTasks(storage.getCid());
if (queueTasks != null && !queueTasks.isEmpty()) {
for (DataLog queueTask : queueTasks) {
if (!openZhiYin || StringUtils.isBlank(queueTask.getSourceId())) {
if (queueTask.isWait() && queueTask.isCheckOutTask()) {
String rgb = queueTask.getLightColor();
ORDER_COLOR color = ORDER_COLOR.fromRgb(rgb);
if (color == null) {
color = ORDER_COLOR.BLUE;
}
queueTask.setLightColor(color.getRgb());
queueTask.setStatus(OP_STATUS.EXECUTING.name());
taskService.updateQueueTask(queueTask);
log.info("库位[" + queueTask.getPosName() + "][" + queueTask.getType() + "]+亮灯:" + color.name());
}
} else {
if (queueTask.isWait() || queueTask.isExecuting()) {
List<DataLog> dataLogList = outMap.get(queueTask.getSourceId());
if (dataLogList == null) {
dataLogList = new ArrayList<>();
}
dataLogList.add(queueTask);
outMap.put(queueTask.getSourceId(), dataLogList);
}
}
}
}
List<DataLog> dataLogs = getLightGuideTask(outMap, storage.getCid());
for (DataLog task : dataLogs) {
if (task.isWait()) {
if (StringUtils.isBlank(task.getLightColor())) {
task.setLightColor(ORDER_COLOR.BLUE.getRgb());
}
task.setStatus(OP_STATUS.EXECUTING.name());
taskService.updateQueueTask(task);
log.info("库位[" + task.getPosName() + "][" + task.getType() + "]+亮灯:" + task.getLightColor());
}
}
}
}
}, 30, 1, TimeUnit.SECONDS);
}
@ApiOperation("扫码入库")
@PostMapping("/api/nlpHBShelf/codeIn")
@PreAuthorize("@el.check('nlpHBShelf:putIn')")
public ResultBean codeIn(@RequestBody Map<String, String> mapValues, HttpServletRequest request) {
String code = mapValues.get("code");
String groupId = mapValues.get("group");
String storageId = mapValues.get("storageId");
String sourceId = mapValues.get("sourceId");
String token = tokenProvider.getToken(request);
String amountStr = mapValues.get("amount");
if (ObjectUtils.isEmpty(code)) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"code"});
}
code = replaceSpecial(code);
if (groupId == null && storageId == null) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"group"});
}
if (groupId == null && storageId != null) {
Storage storage = dataCache.getStorageById(storageId);
if (storage != null) {
groupId = storage.getGroupId();
}
}
if (groupId != null && groupId.equals("-1")) {
groupId = "";
}
// WebSocketServer.sendMsg("", new SocketMsg("{0}未找到库位:{1}"+code, MsgType.INFO,"smfclient.nlp.cannotFindPos",new String[]{"消息测试","库位号"}));
String loginUser = SecurityUtils.getLoginUsername();
Collection<DataLog> queueTasks = taskService.getQueueTasks();
for (DataLog queueTask : queueTasks) {
if (queueTask.isPutInTask() && (queueTask.isWait() || queueTask.isExecuting())) {
if (!Strings.isNullOrEmpty(groupId) && queueTask.getGroupId().equals(groupId)) {
log.info("codeIn [" + code + "][" + groupId + "]入库时取消条码[" + queueTask.getBarcode() + "]的未完成入库任务");
//return ResultBean.newErrorResult(-1,"smfcore.unfinished","the task of [{0}] is unfinished",new String[]{queueTask.getBarcode()});
taskService.cancelTask(queueTask.getId());
}
if (!Strings.isNullOrEmpty(storageId) && queueTask.getStorageId().equals(storageId)) {
log.info("codeIn [" + code + "][" + storageId + "]入库时取消料架[" + queueTask.getStorageId() + "]的未完成入库任务");
//return ResultBean.newErrorResult(-1,"smfcore.unfinished","the task of [{0}] is unfinished",new String[]{queueTask.getStorageName()});
taskService.cancelTask(queueTask.getId());
}
}
}
try {
CodeValidateParam params = new CodeValidateParam(loginUser, groupId, storageId, code, token);
Barcode barcodeSave = smfApi.canPutInBeforeResolve(params);
if (barcodeSave == null) {
barcodeSave = codeResolve.resolveOneValideBarcode("=1x1=" + code);
}
//从API验证
Barcode verResult = smfApi.canPutInAfterResolve(params, barcodeSave);
if (verResult != null) {
barcodeSave = verResult;
}
return putIn(loginUser, groupId, storageId, barcodeSave, token, amountStr);
} catch (ValidateException ve) {
return ResultBean.newErrorResult(-1, ve.getMsgKey(), ve.getDefaultMsg(), ve.getMsgParam());
}
}
protected ResultBean putIn(String loginUser, String groupId, String storageId, Barcode barcode, String token, String amountStr) {
if (barcode == null || barcode.getBarcode() == null) {
return ResultBean.newErrorResult(1, "smfcore.error.barcode.noValidCode", "无效的条码");
}
StoragePos pos = storagePosManager.getByBarcode(barcode.getBarcode());
if (pos != null) {
throw new ValidateException("smfcore.materialBox.inPos", "物料已在库位{0}中", new String[]{pos.getPosName()});
}
if (barcode.getAmount() <= 0) {
throw new ValidateException("smfcore.error.barcode.wrongQty", "条码[{0}]对应的数量<=0为: {1}", new String[]{barcode.getBarcode(), barcode.getAmount() + ""});
}
Date expireDate = barcode.getExpireDate();
if (expireDate != null) {
if (System.currentTimeMillis() > expireDate.getTime()) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库.");
}
}
if (dataCache.shelfConfirmPutIn()) {
if (barcode.isPutIn()) {
if (amountStr == null) {
ResultBean resultBean = ResultBean.newOkResult(barcode);
resultBean.setCode(99);
return resultBean;
} else {
int amount = 0;
try {
amount = Integer.parseInt(amountStr);
} catch (NumberFormatException e) {
e.printStackTrace();
}
if (amount <= 0) {
throw new ValidateException("smfcore.materialBox.qtyError", "请输入正确的数量");
}
barcode.setAmount(amount);
}
}
}
String pn = barcode.getPartNumber();
String reelId = barcode.getBarcode();
String num = barcode.getAmount() + "";
Integer qty = barcode.getAmount();
String msl = barcode.getMsl();
try {
//需要模拟一个库位
DataLog dataLog = new DataLog();
dataLog.setBarcode(reelId);
dataLog.setPartNumber(pn);
dataLog.setType(OP.PUT_IN);
barcode.setPutInTime(System.currentTimeMillis());
barcode.updateSluggishTime(dataCache.getPNsluggishDay(barcode.getPartNumber()));
barcodeManager.saveBarcode(barcode);
dataLog.setNum(barcode.getAmount());
dataLog.setStatus(OP_STATUS.WAIT.name());
dataLog.setGroupId(groupId);
dataLog.setStorageId(storageId);
dataLog.setMemo(barcode.getMemo());
dataLog.setOperator(loginUser);
if (ObjectUtil.isNotEmpty(storageId)) {
Storage storage = dataCache.getStorageById(storageId);
if (storage != null) {
dataLog.setCid(storage.getCid());
dataLog.setStorageName(storage.getName());
}
}
try {
taskService.addTaskToExecute(dataLog);
} catch (Exception e) {
return ResultBean.newErrorResult(-1, "smfclient.nlp.error", "入库失败:" + e.getMessage(), new String[]{e.getMessage()});
}
} catch (ValidateException e) {
log.error(e.toString());
return ResultBean.newErrorResult(1, e.getMsgKey(), e.getDefaultMsg());
}
return ResultBean.newOkResult("");
}
}
......@@ -820,7 +820,7 @@ public class DataCache {
public List<String> getAvailableStorageIds() {
List<String> availableStorageIds = new ArrayList<>();
for (Storage storage : getAllStorage().values()) {
if (!storage.isVirtual()) {
if (!storage.isVirtual() && !storage.isNLPHBShelf()) {
StatusBean bean = DevicesStatusUtil.getStatusBean(storage.getCid());
if (bean == null || bean.timeOut() || !bean.isAvailable()) {
continue;
......@@ -832,6 +832,7 @@ public class DataCache {
}
return availableStorageIds;
}
public List<String> getAvailableStorageIds(List<String> cidList) {
if (cidList == null || cidList.size() <= 0) {
return getAvailableStorageIds();
......@@ -841,7 +842,7 @@ public class DataCache {
if (!cidList.contains(storage.getCid())) {
continue;
}
if (!storage.isVirtual()) {
if (!storage.isVirtual() && !storage.isNLPHBShelf()) {
StatusBean bean = DevicesStatusUtil.getStatusBean(storage.getCid());
if (bean == null || bean.timeOut() || !bean.isAvailable()) {
continue;
......@@ -853,6 +854,7 @@ public class DataCache {
}
return availableStorageIds;
}
public List<String> getAvailableStorageIds(DeviceType deviceType) {
List<String> availableStorageIds = new ArrayList<>();
for (Storage storage : getAllStorage().values()) {
......
......@@ -455,7 +455,7 @@ public class BoxKanbanController {
boxDto.setOnLine(false);
//如果是虚拟仓,默认在线
if (storage.isVirtual()) {
if (storage.isVirtual() || storage.isNLPHBShelf()) {
boxDto.setOnLine(true);
boxDto.setStatus(1);
}
......
......@@ -33,16 +33,16 @@ public enum ORDER_COLOR {
//MAGENTA("FF00FF"),
CYAN("00FFFF"),
FIREBRICK("B22222"),
PURPLE("A020F0"),
//PURPLE("A020F0"),
//SKYBLUE("6CA6CD"),
//PINK("FF1493"),
FORESTGREEN("228B22"),
//LIGHTBLUE("8470FF"),
//INDIANRED("8B3A3A"),
DARKGREEN("556B2F"),
//DARKGREEN("556B2F"),
RED("FF0000"),
YELLOW("FFFF00"),
ORANGE("FFA500"),
//ORANGE("FFA500"),
WHITE("FFFFFF")
;
......
......@@ -207,6 +207,10 @@ public class Storage extends BasePo implements Serializable {
return DeviceType.SMD_XLC.name().equals(type);
}
public boolean isNLPHBShelf() {
return DeviceType.NLP_HB.name().equals(type);
}
public boolean isType(DeviceType[] types){
for (DeviceType str :
types) {
......
......@@ -157,7 +157,7 @@ public class SettingsController {
List<Storage> storages = new ArrayList<>(dataCache.getAllStorage().values());
for (Storage storage : storages
) {
if (storage.isType(new DeviceType[]{DeviceType.NLP,DeviceType.NL,DeviceType.NLS})) {
if (storage.isType(new DeviceType[]{DeviceType.NLP,DeviceType.NL,DeviceType.NLS,DeviceType.NLP_HB})) {
orderSetting.setShowLightType(true);
break;
}
......
package com.neotel.smfcore.custom.haobo;
import com.alibaba.fastjson.JSON;
import com.neotel.smfcore.common.exception.ApiException;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.core.api.listener.BaseSmfApiListener;
import com.neotel.smfcore.core.order.enums.ORDER_COLOR;
import com.neotel.smfcore.core.system.service.po.DataLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@Slf4j
@Service
public class HaoboApi extends BaseSmfApiListener {
@Override
public boolean isForThisApi(String apiName) {
return "haobo".equalsIgnoreCase(apiName);
}
@Override
public void inTaskStatusChange(String inNotifyUrl, DataLog task) {
if (task.isPutInTask() && task.isWait()){
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("labelId",task.getBarcode());
paramMap.put("shelfCode",task.getCid());
paramMap.put("operationTime", DateUtil.toDateString(task.getCreateDate(),"yyyy/MM/dd HH:mm:ss"));
paramMap.put("detailsJson","");
log.info(task.getBarcode()+":入库通知,请求浩博料架,地址为:"+inNotifyUrl+",参数为:"+ JSON.toJSONString(paramMap));
try {
String result = HttpHelper.postJson(inNotifyUrl, paramMap);
log.info(task.getBarcode()+":入库通知,浩博料架返回结果为:"+result);
} catch (ApiException e) {
log.info(task.getBarcode()+":入库通知,浩博料架返回异常,异常信息为:"+e.getMessage());
}
}
}
@Override
public void outTaskStatusChange(String outNotifyUrl, DataLog task) {
if (task.isCheckOutTask() && (task.isExecuting() || task.isCancel())) {
Map<String, Object> paramMap = new HashMap<>();
String labelIdListJson = "[" + "\'" + task.getBarcode() + "\'" + "]";
paramMap.put("labelIdListJson", labelIdListJson);
if (task.isExecuting()) {
paramMap.put("color", getHBColor(task.getLightColor()));
paramMap.put("outStockType", 2);
} else if (task.isCancel()) {
paramMap.put("color", 0);
paramMap.put("outStockType", 1);
}
paramMap.put("newShelfCode", "");
paramMap.put("detailsJson", "");
log.info(task.getBarcode() + ":出库通知,请求浩博料架,地址为:" + outNotifyUrl + ",参数为:" + JSON.toJSONString(paramMap));
try {
String result = HttpHelper.postJson(outNotifyUrl, paramMap);
log.info(task.getBarcode() + ":出库通知,浩博料架返回结果为:" + result);
} catch (ApiException e) {
log.info(task.getBarcode() + ":出库通知,浩博料架返回异常,异常信息为:" + e.getMessage());
}
}
}
private int getHBColor(String rgb) {
ORDER_COLOR color = ORDER_COLOR.fromRgb(rgb);
if (color == null) {
color = ORDER_COLOR.BLUE;
}
Map<String, Integer> hbColorMap = new HashMap<>();
hbColorMap.put(ORDER_COLOR.BLUE.name(), 3);
hbColorMap.put(ORDER_COLOR.CYAN.name(), 6);
hbColorMap.put(ORDER_COLOR.FIREBRICK.name(), 5);
hbColorMap.put(ORDER_COLOR.FIREBRICK.name(), 2);
hbColorMap.put(ORDER_COLOR.RED.name(), 1);
hbColorMap.put(ORDER_COLOR.YELLOW.name(), 4);
hbColorMap.put(ORDER_COLOR.WHITE.name(), 7);
/*hbColorMap.put(ORDER_COLOR.PURPLE.name(), );
hbColorMap.put(ORDER_COLOR.DARKGREEN.name(), );
hbColorMap.put(ORDER_COLOR.ORANGE.name(), );*/
return hbColorMap.get(color.name());
}
}
package com.neotel.smfcore.custom.haobo;
import com.alibaba.fastjson.JSON;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.enums.SOLDER_STATUS;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.handler.impl.BaseDeviceHandler;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.order.enums.ORDER_COLOR;
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.bean.OrderSetting;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.haobo.bean.request.InStockCallbackRequest;
import com.neotel.smfcore.custom.haobo.bean.request.OutStockCallbackRequest;
import com.neotel.smfcore.custom.haobo.bean.response.HaoBoApiResponse;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
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.RestController;
import javax.annotation.PostConstruct;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@Slf4j
@RestController
@RequestMapping("/hbNlp")
public class HaoboNlpController {
@Autowired
private TaskService taskService;
@Autowired
private DataCache dataCache;
@Autowired
private IStoragePosManager storagePosManager;
@Autowired
private IBarcodeManager barcodeManager;
@ApiOperation("入库完成回调")
@RequestMapping("/inStockCallback")
@AnonymousAccess
public HaoBoApiResponse inStockCallback(@RequestBody InStockCallbackRequest request) {
log.info("收到入库完成回调信息:" + JSON.toJSONString(request));
DataLog dataLog = null;
Collection<DataLog> queueTasks = taskService.getQueueTasks();
for (DataLog queueTask : queueTasks) {
if (queueTask.getBarcode().equals(request.getLabelId())) {
if (queueTask.isPutInTask() && queueTask.isWait()) {
dataLog = queueTask;
break;
}
}
}
if (dataLog == null) {
return new HaoBoApiResponse(false, "未找到对应的入库任务");
}
StoragePos pos = storagePosManager.getByPosName(request.getLocation());
if (pos == null) {
return new HaoBoApiResponse(false, "未找到对应的库位");
}
if (pos.getBarcode() != null) {
return new HaoBoApiResponse(false, "库位已被占用");
}
Storage storage = dataCache.getStorageById(pos.getStorageId());
dataLog.setCid(storage.getCid());
dataLog.setPosId(pos.getId());
dataLog.setPosName(pos.getPosName());
dataLog.setStorageId(storage.getId());
dataLog.setStorageName(storage.getName());
updatePutInData(dataLog);
return new HaoBoApiResponse(true, "入库完成");
}
@ApiOperation("出库完成回调")
@RequestMapping("/outStockCallback")
@AnonymousAccess
public HaoBoApiResponse outStockCallback(@RequestBody OutStockCallbackRequest request) {
log.info("收到出库完成回调信息:" + JSON.toJSONString(request));
DataLog dataLog = null;
Collection<DataLog> queueTasks = taskService.getQueueTasks();
for (DataLog queueTask : queueTasks) {
if (queueTask.getBarcode().equals(request.getLabelId())) {
if (queueTask.isCheckOutTask() && (queueTask.isWait() || queueTask.isExecuting())) {
dataLog = queueTask;
break;
}
}
}
if (dataLog != null) {
updateCheckoutData(dataLog, OP_STATUS.FINISHED);
return new HaoBoApiResponse(true, "出库完成");
} else {
//判断在不在库位中,如果不在库位中,则忽略
StoragePos pos = storagePosManager.getByBarcode(request.getLabelId());
if (pos == null) {
pos = storagePosManager.getByPosName(request.getLocation());
}
if (pos == null || pos.getBarcode() == null) {
log.info("根据库位名称和条码都未找到对应的库存信息,库位名称为:{},唯一码为:{}", request.getLocation(), request.getLabelId());
return new HaoBoApiResponse(true, "根据唯一码或者库位号都未找到对应的库存信息,默认已出库");
}
Storage storage = dataCache.getStorageById(pos.getStorageId());
DataLog createDataLog = new DataLog(storage, pos.getBarcode(), pos);
createDataLog.setType(OP.CHECKOUT);
createDataLog.setOperator("NLP");
createDataLog = taskService.updateQueueTask(createDataLog);
updateCheckoutData(createDataLog, OP_STATUS.FINISHED);
return new HaoBoApiResponse(true, "出库完成");
}
}
/**
* 入仓位完成
*/
protected void updatePutInData(DataLog task) throws ValidateException {
//从队列里面移除操作
taskService.removeQueueTask(task);
StoragePos storagePos = storagePosManager.get(task.getPosId());
//二维码状态
Barcode barcode = barcodeManager.findByBarcode(task.getBarcode());
if (barcode != null) {
barcode.setUsedCount(barcode.getUsedCount() + 1);
barcode.setPutInTime(System.currentTimeMillis());
barcode.updateSluggishTime(dataCache.getPNsluggishDay(barcode.getPartNumber()));
barcode.setInOpor(task.getOperator());
barcode.setCheckOutDate(null, "");
barcode.setPosName(task.getPosName());
if (barcode.isSolder()) {
if (storagePos.isWarmPos()) {
//回温仓位
barcode.setSolderStatus(SOLDER_STATUS.RETREAT_STORAGE.name());
} else {
barcode.setSolderStatus(SOLDER_STATUS.UNDER_REFRIGERATION.name());
}
barcode.setNeedOutDate(null);
}
barcodeManager.save(barcode);
}
storagePos.setBarcode(barcode);
storagePos.setUsed(true);
storagePos.setCanCheckOutTime(System.currentTimeMillis());
storagePosManager.save(storagePos);
if (barcode != null) {
dataCache.updateInventory(storagePos, barcode);
//记录日志,完成 task
task.setBatchInfo(barcode.getBatch());
task.setNum(barcode.getAmount());
task.setProviderNumber(barcode.getProviderNumber());
}
//更新缓存中的库存信息
task.setStatus(OP_STATUS.FINISHED.name());
taskService.updateFinishedTask(task);
}
/**
* 出仓位完成
*/
private void updateCheckoutData(DataLog task, OP_STATUS outBoxStatus) throws ValidateException {
//从队列里面移除操作
taskService.removeQueueTask(task);
StoragePos storagePos = storagePosManager.get(task.getPosId());
Barcode barcode = storagePos.getBarcode();
if (barcode == null) {
log.warn("任务:" + task.getId() + " 仓位:" + task.getPosId() + " 的 Barcode 为null, 之前可能处理过,结束任务后直接返回");
//记录日志
task.setStatus(outBoxStatus.name());
taskService.updateFinishedTask(task);
return;
}
Barcode barcodeDB = barcodeManager.get(barcode.getId());
if (barcodeDB != null) {
//二维码状态
barcodeDB.setUsed(true);
barcodeDB.setUsedDate(new Date());
//仓位状态
barcodeDB.setCheckOutDate(new Date(), task.getOperator());
barcodeDB.setPosName("");
barcodeManager.save(barcodeDB);
task.setBatchInfo(barcodeDB.getBatch());
//记录在库时长
task.setInStoreTime(barcodeDB.getInStoreMiniute());
}
storagePos.setBarcode(null);
storagePos.setUsed(false);
storagePosManager.save(storagePos);
log.info("出库完成,清空仓位: " + storagePos.getId() + "[" + storagePos.getPosName() + "]");
//更新缓存中的库存信息
dataCache.updateInventory(storagePos, barcode);
// 调用西门子接口
// SiemensApi.lotInOut(barcode.getBarcode(),2);
//记录日志
task.setStatus(outBoxStatus.name());
taskService.updateFinishedTask(task);
}
}
package com.neotel.smfcore.custom.haobo.bean.request;
import lombok.Data;
@Data
public class InStockCallbackRequest {
private String labelId;
private String location;
private String detailsJson;
}
package com.neotel.smfcore.custom.haobo.bean.request;
import lombok.Data;
@Data
public class OutStockCallbackRequest {
private String labelId;
private String location;
private String detailsJson;
}
package com.neotel.smfcore.custom.haobo.bean.response;
import lombok.Data;
@Data
public class HaoBoApiResponse {
private boolean success;
private String message;
private Object data;
public HaoBoApiResponse(boolean success,String message) {
this.message = message;
this.success = success;
this.data = null;
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!