Commit 5a91a66b 孙克

手动绑定料串到BG/CG

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