Commit a5760305 LN

1

1 个父辈 e54d5eac
...@@ -95,13 +95,13 @@ public class ShelfInfo { ...@@ -95,13 +95,13 @@ public class ShelfInfo {
/** /**
* 根据条码获取库位信息 * 根据条码获取库位信息
*/ */
public int getBarcodeLoc(String barcode) { public ShelfLoc getBarcodeLoc(String barcode) {
for (ShelfLoc shelfLoc : locMap.values()) { for (ShelfLoc shelfLoc : locMap.values()) {
if (shelfLoc.isLock() && shelfLoc.getBarcode().equals(barcode)) { if (shelfLoc.isLock() && shelfLoc.getBarcode().equals(barcode)) {
return shelfLoc.getLoc(); return shelfLoc;
} }
} }
return -1; return null;
} }
/** /**
......
...@@ -51,6 +51,8 @@ public class ShelfLoc { ...@@ -51,6 +51,8 @@ public class ShelfLoc {
*/ */
private boolean isLock = false; private boolean isLock = false;
private String shelfLocation=null;
/** /**
* 判断该架位锁定的条码是否与给定的条码一样 * 判断该架位锁定的条码是否与给定的条码一样
* *
......
...@@ -370,25 +370,26 @@ public class TaskShelfController { ...@@ -370,25 +370,26 @@ public class TaskShelfController {
} }
@ApiOperation("产线扫码亮灯,返回条码放到料架的位置:1-31") // @ApiOperation("产线扫码亮灯,返回条码放到料架的位置:1-31")
@PostMapping(value = "/codeLed") // @PostMapping(value = "/codeLed")
@ResponseBody // @ResponseBody
@AnonymousAccess // @AnonymousAccess
public ResultBean codeLed(HttpServletRequest request) { // public ResultBean codeLed(HttpServletRequest request) {
//
//扫码后,解析条码,从料架列表中查找对应位置 // //扫码后,解析条码,从料架列表中查找对应位置
//
String barcodeStr = request.getParameter("code"); // String barcodeStr = request.getParameter("code");
//
Barcode barcode = codeResolve.resolveOneValideBarcode(barcodeStr); // Barcode barcode = codeResolve.resolveOneValideBarcode(barcodeStr);
//
if (barcode == null) { // if (barcode == null) {
log.info("codeLed 未找到有效条码[" + barcodeStr + "]"); // log.info("codeLed 未找到有效条码[" + barcodeStr + "]");
return ResultBean.newErrorResult(99, "smfcore.error.barcode.invalid", "未找到有效条码"); // return ResultBean.newErrorResult(99, "smfcore.error.barcode.invalid", "未找到有效条码");
} // }
int loc = TaskShelfUtil.getLastLoc(barcode.getBarcode()); // int loc = TaskShelfUtil.getLastLoc(barcode.getBarcode());
return ResultBean.newOkResult(loc); //
} // return ResultBean.newOkResult(loc);
// }
} }
...@@ -386,7 +386,11 @@ public class TaskShelfUtil { ...@@ -386,7 +386,11 @@ public class TaskShelfUtil {
ShelfInfo minShelf = null; ShelfInfo minShelf = null;
for (ShelfInfo shelfInfo : shelfMap.values()) { for (ShelfInfo shelfInfo : shelfMap.values()) {
int limitLoc = shelfInfo.getBarcodeLoc(barcode); ShelfLoc shelfLoc = shelfInfo.getBarcodeLoc(barcode);
int limitLoc=-1;
if(shelfLoc!=null){
limitLoc=shelfLoc.getLoc();
}
if (limitLoc > 0) { if (limitLoc > 0) {
//已经锁定过 //已经锁定过
boolean result = shelfInfo.cancelLimitLoc(barcode); boolean result = shelfInfo.cancelLimitLoc(barcode);
...@@ -482,20 +486,37 @@ public class TaskShelfUtil { ...@@ -482,20 +486,37 @@ public class TaskShelfUtil {
public static void updateShelfLoc(String rfid,String loc){ public static void updateShelfLoc(String rfid,String loc){
lineShelfLocMap.put(rfid,loc); lineShelfLocMap.put(rfid,loc);
saveLineShelfLocMap(lineShelfLocMap); saveLineShelfLocMap(lineShelfLocMap);
}
public static String getShelfLoc(String rfid) {
//获取料架所在的产线位置
String line = lineShelfLocMap.get(rfid);
if (line == null) {
line = "";
}
return line;
} }
public static int getLastLoc(String barcode){
public static ShelfLoc getLastLoc(String barcode){
for (Map<String, ShelfInfo> shelfInfoMap : taskShelfMap.values()) { for (Map<String, ShelfInfo> shelfInfoMap : taskShelfMap.values()) {
for (ShelfInfo shelf : shelfInfoMap.values()) { for (ShelfInfo shelf : shelfInfoMap.values()) {
int loc=shelf.getBarcodeLoc(barcode);
return loc;
ShelfLoc shelfLoc=shelf.getBarcodeLoc(barcode);
if(shelfLoc!=null&&(!shelfLoc.isEmpty())){
//获取料架位置
String line=getShelfLoc(shelfLoc.getRealRfid());
shelfLoc.setShelfLocation(line);
return shelfLoc;
}
} }
} }
return -1; return null;
} }
} }
package com.neotel.smfcore.custom.gree20242;
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.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.shelf.bean.ShelfLoc;
import com.neotel.smfcore.core.shelf.util.TaskShelfUtil;
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.DevicesStatusUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
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.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.awt.*;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@Slf4j
@RestController
@Api(tags = "20242:扫码亮灯灭灯")
@RequestMapping("/rest/gree/light")
public class CodeLightController {
@Autowired
private CodeResolve codeResolve;
@Autowired
private DataCache dataCache;
@Autowired
private IStoragePosManager storagePosManager;
@ApiOperation("扫码亮灯")
@PostMapping(value = "/lightOn")
@ResponseBody
@AnonymousAccess
public ResultBean lightOn(@RequestBody Map<String, String> mapValues) {
String code = mapValues.get("code");
//扫码后,解析条码,从料架列表中查找对应位置
Barcode barcode = codeResolve.resolveOneValideBarcode(code);
if (barcode == null) {
log.info("codeLed 未找到有效条码[" + code + "]");
return ResultBean.newErrorResult(99, "smfcore.error.barcode.invalid", "未找到有效条码");
}
ShelfLoc loc = TaskShelfUtil.getLastLoc(barcode.getBarcode());
if (loc == null) {
return ResultBean.newErrorResult(99, "smfcore.light.error.noloc", "未找到亮灯位置");
}
//找到对应的库位,给亮灯料架发送亮灯指令
String cid = loc.getShelfLocation();
String posname = loc.getShelfLocation() + "_" + loc.getLoc();
Storage storage = dataCache.getStorage(cid);
if (storage == null) {
return ResultBean.newErrorResult(99, "smfcore.light.error.noStorage", "未找到料架[" + cid + "]", new String[]{cid});
}
StoragePos pos = storagePosManager.getByPosName(posname);
if (pos == null) {
return ResultBean.newErrorResult(99, "smfcore.light.error.noStoragePos", "未找到料架库位[" + posname + "]", new String[]{posname});
}
opPosLight("open", pos, Color.GREEN.toString());
return ResultBean.newOkResult(loc);
}
/**
* 操作库位灯(开灯,或关灯)
*
* @param opKey
* @param pos
* @param colorStr
*/
private void opPosLight(String opKey, StoragePos pos, String colorStr) {
String opStr = pos.getPosName();
if (!Strings.isNullOrEmpty(colorStr)) {
opStr = opStr + "=" + colorStr;
}
Storage storage = dataCache.getStorageById(pos.getStorageId());
DevicesStatusUtil.appendOp(storage.getCid(), opKey, opStr);
log.info("操作库位[" + pos.getPosName() + "]" + opKey + " : " + opStr);
}
@ApiOperation("扫码灭灯")
@PostMapping(value = "/lightOff")
@ResponseBody
@AnonymousAccess
public ResultBean lightOff(@RequestBody Map<String, String> mapValues, HttpServletRequest request) {
String code = mapValues.get("code");
//扫码后,解析条码,从料架列表中查找对应位置
Barcode barcode = codeResolve.resolveOneValideBarcode(code);
if (barcode == null) {
log.info("codeLed 未找到有效条码[" + code + "]");
return ResultBean.newErrorResult(99, "smfcore.error.barcode.invalid", "未找到有效条码");
}
ShelfLoc loc = TaskShelfUtil.getLastLoc(barcode.getBarcode());
if (loc == null) {
return ResultBean.newErrorResult(99, "smfcore.light.error.noloc", "未找到亮灯位置");
}
String cid = loc.getShelfLocation();
String posname = loc.getShelfLocation() + "_" + loc.getLoc();
Storage storage = dataCache.getStorage(cid);
if (storage == null) {
return ResultBean.newErrorResult(99, "smfcore.light.error.noStorage", "未找到料架[" + cid + "]", new String[]{cid});
}
StoragePos pos = storagePosManager.getByPosName(posname);
if (pos == null) {
return ResultBean.newErrorResult(99, "smfcore.light.error.noStoragePos", "未找到料架库位[" + posname + "]", new String[]{posname});
}
//找到对应的库位,给亮灯料架发送灭灯指令
DevicesStatusUtil.appendOp(storage.getCid(), "closeAll", "true");
return ResultBean.newOkResult(loc);
}
}
package com.neotel.smfcore.custom.gree20242;
import com.neotel.smfcore.common.init.MenuInit;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.security.service.po.Menu;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@Component
public class Gree20242Menu {
@Autowired
MenuInit menuInit;
@Autowired
SmfApi smfApi;
@PostConstruct
public void init(){
String menuLabel = "20242";
//Report菜单
//物料管理下加一个 扫码亮灯 出库 菜单
Menu poutOut = Menu.CreatePMenu("物料管理", 1, "order", "workOrder", null);
MenuInit.addMenu(menuLabel,poutOut, 120, "扫码亮灯", "codeLight", "neolight/codeLight/index","findOut");
String apiName = smfApi.getApiName();
if(Strings.isNotBlank(apiName) && apiName.equals(menuLabel)){
menuInit.showMenu(apiName);
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!