Commit 2d5342eb sunke

改海拉料架为通用料架使用接口

1 个父辈 0adec304
......@@ -415,7 +415,7 @@ public class BarcodeRule {
String value = getStrValue(codeArr);
if(!Strings.isNullOrEmpty(value)){
try{
return Float.valueOf(value).intValue();
return Float.valueOf(value.trim()).intValue();
}catch (Exception ex){
log.warn(value + " is not a validate int");
}
......
......@@ -10,6 +10,14 @@ import com.neotel.smfcore.core.barcode.service.po.Barcode;
public interface IOpAuthApi {
/**
* 传入原始条码,API解析条码,注意条码中带有尺寸信息,此方法会在canPutIn方法之前调用,通常料架使用(其他设备会有尺寸信息且会有多个条码所以不适用此方法)
* @param code
* @return
* @throws ValidateException
*/
Barcode resolveBarcode(String code) throws ValidateException;
/**
* 是否可入库验证
*/
Barcode canPutIn(Barcode barcode) throws ValidateException;
......
......@@ -4,6 +4,7 @@ import com.google.common.base.Strings;
import com.google.common.collect.Lists;
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.StorageConstants;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
......@@ -24,12 +25,13 @@ import com.neotel.smfcore.core.system.websocket.SocketMsg;
import com.neotel.smfcore.core.system.websocket.WebSocketServer;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import com.neotel.smfcore.security.service.po.Group;
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.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
......@@ -47,6 +49,82 @@ public class SensorShelfHandler extends BaseDeviceHandler {
super(apiList);
}
/**
* 扫码
*/
@ApiOperation("扫码入库")
@PostMapping("/codeIn")
@PreAuthorize("@el.check('sensorShelf:putIn')")
public ResultBean codeIn( @RequestBody Map<String, String> mapValues) {
String code = mapValues.get("code");
String groupId = mapValues.get("group");
String storageId=mapValues.get("storageId");
if(ObjectUtils.isEmpty(code)){
throw new ValidateException("smfcode.valueCanotNull", "{0}不能为空", new String[]{"code"});
}
if(groupId==null&&storageId==null){
throw new ValidateException("smfcode.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="";
}
String loginUser = SecurityUtils.getLoginUsername();
Collection<DataLog> queueTasks = taskService.getQueueTasks();
ResultBean resultBean = null;
for (DataLog queueTask : queueTasks) {
if (queueTask.isPutInTask() && queueTask.isWait()) {
if (!Strings.isNullOrEmpty(groupId) && queueTask.getGroupId().equals(groupId)) {
log.info("codeIn [" + code + "][" + groupId + "]入库失败:条码[" + queueTask.getBarcode() + "]的任务还未结束 ");
throw new ValidateException("smfcore.unfinished", "the task of [{0}] is unfinished", new String[]{queueTask.getBarcode()});
}
if (!Strings.isNullOrEmpty(storageId) && queueTask.getStorageId().equals(storageId)) {
log.info("codeIn [" + code + "][" + storageId + "]入库失败:条码[" + queueTask.getBarcode() + "]的任务还未结束 ");
throw new ValidateException("smfcore.unfinished", "the task of [{0}] is unfinished", new String[]{queueTask.getBarcode()});
}
}
}
Barcode barcodeSave = resolveBarcodeFromApiForShelf(code);
if(barcodeSave == null){
barcodeSave = codeResolve.resolveOneValideBarcode(code);
}
Date expireDate = barcodeSave.getExpireDate();
if (expireDate != null) {
if (System.currentTimeMillis() > expireDate.getTime()) {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库.");
}
}
//从API验证
barcodeSave = verifyPutInFromApi(barcodeSave);
// resultBean = hellaServiceHandler.checkMaterial(loginUser, groupId, code);
return resultBean;
}
/**
* 从API接口解析条码,通常料架使用(其他设备会有尺寸信息且会有多个条码所以不适用此方法)
*/
protected Barcode resolveBarcodeFromApiForShelf(String code) throws ValidateException{
for (IOpAuthApi opAuthApi : opAuthApiList) {
Barcode responseBarcode = opAuthApi.resolveBarcode(code);
if(responseBarcode != null){
return responseBarcode;
}
}
return null;
}
@Override
public StatusBean handleClientRequest(StatusBean statusBean, HttpServletRequest request) {
handleMsg(statusBean);
......
......@@ -9,8 +9,8 @@ import java.util.Set;
*/
public enum ORDER_COLOR {
//magenta,cyan,firebrick,purple,skyblue,pink,forestgreen,lightblue,indianred,darkgreen
//洋红,青色,砖红色,紫色,天蓝色,粉色,森林绿,浅蓝色,印度红,深绿色
//cyan,firebrick,purple,skyblue,pink,forestgreen,lightblue,indianred,darkgreen
//青色,砖红色,紫色,天蓝色,粉色,森林绿,浅蓝色,印度红,深绿色
// 'red':[1,125,0,0],
// 'yellow':[2,125,125,0],
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!