Commit 5a91a66b 孙克

手动绑定料串到BG/CG

去除料格已放满验证
1 个父辈 a85b7e8f
......@@ -238,6 +238,8 @@ public class DataInitManager {
//手动出库
addNewFunctionMenu(6, raw, "outVir", "手动出库", "outVir", "outVir/index", "docOut", functionMenuMap);
//料串绑定
addNewFunctionMenu(7, raw, "manualBindStacker", "料串绑定", "manualBindStacker", "manualBindStacker/index", "docOut", functionMenuMap);
......
......@@ -671,7 +671,7 @@ public class CDeviceController {
barcodeManager.saveBarcode(barcode);
//更新料串缓存信息
MaterialLocUtil.updateMaterialLoc(materialStr,"",null);
MaterialLocUtil.updateStackerLoc(materialStr,"",null);
Map<String,String> resultMap = new HashMap<>();
resultMap.put("binCode",boxStr);
......
......@@ -187,19 +187,4 @@ public class ManualLineController {
return ResultBean.newOkResult("");
}
@ApiOperation("获取料串目的地接口")
@RequestMapping("/material/api/getDestination")
@AnonymousAccess
public ResultBean getDestination(@RequestBody Map<String, String> paramMap) {
String materialStr = paramMap.get("materialStr");
String loc = paramMap.get("loc");
log.info("获取料串目的地,料串为:" + materialStr + ",位置为:" + loc);
Map<String, String> resultMap = new HashMap<>();
resultMap.put("destination", "C2-3F-BG");
resultMap.put("materialStr", materialStr);
return ResultBean.newOkResult(resultMap);
}
}
......@@ -437,11 +437,11 @@ public class BinCacheUtil {
*/
public static String canMaterialPutInBin(Barcode reelBarcode, Barcode boxBarcode, String binId) {
String isBinFull = boxBarcode.getExtraData(binId);
if (isBinFull != null) {
//该料格已放满, 不可以再放料
log.info("料格[" + binId + "]已满,不可放入物料[" + reelBarcode.getBarcode() + "]");
return "料格[" + binId + "]已满,不可放入物料[" + reelBarcode.getBarcode() + "]";
}
// if (isBinFull != null) {
// //该料格已放满, 不可以再放料
// log.info("料格[" + binId + "]已满,不可放入物料[" + reelBarcode.getBarcode() + "]");
// return "料格[" + binId + "]已满,不可放入物料[" + reelBarcode.getBarcode() + "]";
// }
if (!BinCacheUtil.canPutInBinCode(binId, reelBarcode.getWarehouseCode())) {
return "库别[" + reelBarcode.getWarehouseCode() + "]不可放入料格[" + binId + "]";
}
......
......@@ -8,6 +8,7 @@ import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -29,7 +30,7 @@ public class MaterialRestController {
String materialStr = paramMap.get("materialStr");
String loc = paramMap.get("loc");
log.info("收到料串位置更新,料串为:"+materialStr+",位置为:"+loc);
MaterialLocUtil.updateMaterialLoc(materialStr,loc,null);
MaterialLocUtil.updateStackerLoc(materialStr,loc,null);
return ResultBean.newOkResult("");
}
......@@ -39,6 +40,35 @@ public class MaterialRestController {
@RequestMapping("/getMaterialLoc")
@AnonymousAccess
public ResultBean getMaterialLoc() {
return ResultBean.newOkResult(MaterialLocUtil.getMaterialLoc());
return ResultBean.newOkResult(MaterialLocUtil.getAllStackerLoc());
}
@ApiOperation("获取料串目的地接口")
@RequestMapping("/getDestination")
@AnonymousAccess
public ResultBean getDestination(@RequestBody Map<String, String> paramMap) {
String stackerCode = paramMap.get("materialStr");
String loc = paramMap.get("loc");
log.info("获取料串目的地,料串为:" + stackerCode + ",位置为:" + loc);
String stackerDestination = MaterialLocUtil.getStackerDestination(stackerCode);
if(Strings.isBlank(stackerDestination)){
stackerDestination = "W2-1F";
}
Map<String, String> resultMap = new HashMap<>();
resultMap.put("destination", stackerDestination);
resultMap.put("materialStr", stackerCode);
return ResultBean.newOkResult(resultMap);
}
@ApiOperation("手动修改料串目的地接口")
@RequestMapping("/manualBindStacker")
@AnonymousAccess
public ResultBean manualBindStack(@RequestBody Map<String, String> paramMap) {
String stackerCode = paramMap.get("stackerCode");
String destination = paramMap.get("destination");
log.info("手动绑定料串["+stackerCode+"]目的地:" + stackerCode);
MaterialLocUtil.updateStackerLoc(stackerCode,"", destination);
return ResultBean.newOkResult("绑定成功");
}
}
......@@ -10,13 +10,25 @@ import java.util.List;
@Data
public class MaterialLoc {
private String material;
/**
* 料串条码
*/
private String stackerCode;
/**
* 位置编号
*/
private String loc;
private int amount = 0;
/**
* 位置名称
*/
private String locName;
private List<Barcode> barcodeList = new ArrayList<>();
/**
* 目的地: C2-3F-BG或C2-3F-CG
*/
private String destination;
private Date createDate = new Date();
......
package com.neotel.smfcore.custom.luxsan.factory_c.third.util;
import com.google.common.collect.Maps;
import com.neotel.smfcore.common.bean.ReelLockPosInfo;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.custom.luxsan.factory_c.third.bean.MaterialLoc;
import com.neotel.smfcore.custom.luxsan.factory_c.third.enums.MaterialLocEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.*;
@Component
@Slf4j
public class MaterialLocUtil {
public static final String CACHE_MATERIAL_LOC = "CACHE_MATERIAL_LOC";
public static final String CACHE_STACKER_LOC = "CACHE_STACKER_LOC";
private static Map<String, MaterialLoc> stackerLocMap = Maps.newConcurrentMap();
private static DataCache dataCache;
@PostConstruct
public void init() {
Map<String, MaterialLoc> cacheMap = dataCache.getCache(CACHE_STACKER_LOC);
if (cacheMap != null) {
stackerLocMap.putAll(cacheMap);
}
}
@Autowired
public void setDataCache(DataCache cache) {
MaterialLocUtil.dataCache = cache;
}
public static void updateMaterialLoc(String materialStr, String loc, Barcode barcode) {
Map<String, MaterialLoc> cacheMap = dataCache.getCache(CACHE_MATERIAL_LOC);
if (cacheMap == null) {
cacheMap = new HashMap<>();
}
MaterialLoc materialLoc = cacheMap.get(materialStr);
/**
* 更新料串位置或目的地
*/
public static synchronized void updateStackerLoc(String stackerCode, String loc, String destination){
log.info("更新料串["+stackerCode+"]位置为["+loc+"] 目的地为:["+destination+"]");
MaterialLoc materialLoc = stackerLocMap.get(stackerCode);
if (materialLoc == null) {
materialLoc = new MaterialLoc();
materialLoc.setStackerCode(stackerCode);
}
if (StringUtils.isNotEmpty(loc)) {
String name = MaterialLocEnum.findNameById(loc);
materialLoc.setLoc(name);
}
materialLoc.setMaterial(materialStr);
materialLoc.setUpdateDate(new Date());
List<Barcode> barcodeList = materialLoc.getBarcodeList();
materialLoc.setLoc(loc);
materialLoc.setLocName(name);
if (barcode != null) {
if (barcodeList != null && !barcodeList.isEmpty()) {
barcodeList.removeIf(t -> t.getBarcode().equals(barcode.getBarcode()));
}
barcode.setUpdateDate(new Date());
barcodeList.add(barcode);
}
int amount = barcodeList.stream().mapToInt(Barcode::getAmount).sum();
materialLoc.setAmount(amount);
if (StringUtils.isNotEmpty(destination)) {
materialLoc.setDestination(destination);
}
materialLoc.setBarcodeList(barcodeList);
materialLoc.setUpdateDate(new Date());
cacheMap.put(materialStr, materialLoc);
dataCache.updateCache(CACHE_MATERIAL_LOC, cacheMap);
stackerLocMap.put(stackerCode, materialLoc);
//dataCache.updateCache(CACHE_STACKER_LOC, stackerLocMap);
}
public static void removeMaterialLoc(String materialStr){
Map<String, MaterialLoc> cacheMap = dataCache.getCache(CACHE_MATERIAL_LOC);
if (cacheMap == null) {
cacheMap = new HashMap<>();
public static String getStackerDestination(String stackerCode){
MaterialLoc materialLoc = stackerLocMap.get(stackerCode);
if(materialLoc != null){
return materialLoc.getDestination();
}
cacheMap.remove(materialStr);
dataCache.updateCache(CACHE_MATERIAL_LOC, cacheMap);
return "";
}
public static Collection<MaterialLoc> getMaterialLoc() {
Map<String, MaterialLoc> cacheMap = dataCache.getCache(CACHE_MATERIAL_LOC);
if (cacheMap == null) {
cacheMap = new HashMap<>();
}
return cacheMap.values();
public static Collection<MaterialLoc> getAllStackerLoc() {
return stackerLocMap.values();
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!