Commit 74ca021b hc

fix:gr手动入库缓存gr过账信息新增缓存的查找接口

1 个父辈 cf06998d
......@@ -7,6 +7,8 @@ import lombok.Data;
@AllArgsConstructor
public class GrUdNum {
private String code;
private String grCode;
private String grItem;
......
......@@ -100,9 +100,17 @@ public class ManualGrPutInController {
@ApiOperation("缓存已过帐缓存信息")
@RequestMapping("/bindGrUdQty")
@AnonymousAccess
public ResultBean bindGrUdQty(@RequestBody GrUdNum grUdNum) {
GrUtil.updateGrUdQty(grUdNum.getGrCode(), grUdNum.getGrItem(), grUdNum.getUdQty(), grUdNum.getLotQty());
return ResultBean.newOkResult("");
public ResultBean bindGrUdQty(@RequestBody GrUdNum grUdNum) throws Exception {
GrUtil.updateGrUdQty(grUdNum.getCode(), grUdNum.getGrCode(), grUdNum.getGrItem(), grUdNum.getUdQty(), grUdNum.getLotQty());
return ResultBean.newOkResult(GrUtil.getGrUdQty(grUdNum.getGrCode(), grUdNum.getGrItem()));
}
@ApiOperation("缓存已过帐缓存信息")
@RequestMapping("/grUdNum")
@AnonymousAccess
public ResultBean getGrUdNum(String grCode, String grItem) throws Exception {
return ResultBean.newOkResult(
GrUtil.getGrUdQty(grCode, grItem));
}
@ApiOperation("获取料箱信息")
......@@ -129,8 +137,6 @@ public class ManualGrPutInController {
String grCode = paramMap.get("grCode"); //GrItem
String grItem = paramMap.get("grItem"); //GrCode
String boxStr = paramMap.get("boxStr"); //料箱信息
Integer udQty = Double.valueOf(paramMap.get("udQty")).intValue();
Integer lotQty = Double.valueOf(paramMap.get("lotQty")).intValue();
log.info("人工GR入库,料格信息为:" + binCode + ",过账编码为:" + udCode + "条码信息为:" + codeStr);
......@@ -161,7 +167,6 @@ public class ManualGrPutInController {
int w = 7;
int h = 8;
Component component = componentManager.findByPartNumberAndProvider(noDbBarcode.getPartNumber(), noDbBarcode.getProvider());
if (component == null) {
BrandQtyResult result = LuxsanApi.brandQtyUrl(new BrandQtyRequest(noDbBarcode.getPartNumber(), noDbBarcode.getProvider()));
......@@ -183,6 +188,7 @@ public class ManualGrPutInController {
//判断条码是否正常
Barcode barcode = null;
try {
barcode = codeResolve.resolveOneValideBarcode("="+w+"x"+h+"="+codeStr);
} catch (ValidateException ve) {
......@@ -239,7 +245,8 @@ public class ManualGrPutInController {
inPos.setBarcode(boxBarcode);
storagePosManager.save(inPos);
}
GrUtil.updateGrUdQty(grCode, grItem, udQty, lotQty);
int amount = barcode.getAmount();
GrUtil.addQty(grCode, grItem, amount);
return ResultBean.newOkResult(BoxHandleUtil.getBoxInfo(boxStr));
}
}
......
package com.neotel.smfcore.custom.luxsan.factory_c.rawstor.util;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Maps;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.StringUtils;
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.custom.luxsan.api.LuxsanApi;
import com.neotel.smfcore.custom.luxsan.api.bean.request.QueryGrStatusRequest;
import com.neotel.smfcore.custom.luxsan.api.bean.result.QueryGrStatusResult;
import com.neotel.smfcore.custom.luxsan.factory_c.common.util.CommonUtil;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.GrUdNum;
import com.neotel.smfcore.custom.luxsan.factory_c.rawstor.bean.dto.QueryGrStatusDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.List;
import java.util.Map;
@Service
public class GrUtil {
private static CodeResolve codeResolve;
@Autowired
public void setCodeResolve(CodeResolve codeResolve) {
this.codeResolve = codeResolve;
}
private static DataCache dataCache;
public static final String CACHE_GR_UDQTY = "CACHE_GR_UDQTY";
......@@ -21,23 +40,64 @@ public class GrUtil {
GrUtil.dataCache = cache;
}
public synchronized static void updateGrUdQty(String grCode, String grItem, int udQty, int lotQty) {
public synchronized static void updateGrUdQty(String code, String grCode, String grItem, int udQty, int lotQty) {
Map<String, GrUdNum> cacheMap = dataCache.getCache(CACHE_GR_UDQTY);
if (cacheMap == null) {
cacheMap = Maps.newConcurrentMap();
}
String key = grCode + "_" + grItem;
cacheMap.put(key, new GrUdNum(grCode, grItem, udQty, lotQty));
cacheMap.put(key, new GrUdNum(code, grCode, grItem, udQty, lotQty));
dataCache.updateCache(CACHE_GR_UDQTY, cacheMap);
}
public static GrUdNum getGrUdQty(String grCode, String grItem){
public static GrUdNum getGrUdQty(String grCode, String grItem) throws Exception {
Map<String, GrUdNum> cacheMap = dataCache.getCache(CACHE_GR_UDQTY);
if (cacheMap == null) {
cacheMap = Maps.newConcurrentMap();
}
String key = grCode + "_" + grItem;
GrUdNum grUdNum = cacheMap.get(key);
// 服务器端刷新条件
if (grUdNum.getLotQty() <= grUdNum.getUdQty()) {
return refreshGrNumFromAPI(grCode, grItem);
}
return grUdNum;
}
private static GrUdNum refreshGrNumFromAPI(String grCode, String grItem) throws Exception {
Map<String, GrUdNum> cacheMap = dataCache.getCache(CACHE_GR_UDQTY);
if (cacheMap == null) {
cacheMap = Maps.newConcurrentMap();
}
String key = grCode + "_" + grItem;
GrUdNum grUdNum = cacheMap.get(key);
//解析条码为barcode
Barcode barcode = codeResolve.resolveCode(grUdNum.getCode());
if (barcode == null) {
throw new Exception("条码无效");
}
QueryGrStatusRequest request = new QueryGrStatusRequest(CommonUtil.plantCode, barcode.getProvider(), barcode.getPartNumber(), "", "");
List<QueryGrStatusDto> queryGrStatusDtos = QueryGrStatusDto.convertQueryGrStatusResultDto(
LuxsanApi.queryGrStatus(request));
if (ObjectUtil.isNotEmpty(queryGrStatusDtos)) {
QueryGrStatusDto queryGrStatusDto = queryGrStatusDtos.get(0);
grUdNum.setLotQty(Double.valueOf(queryGrStatusDto.getLotQty()).intValue());
grUdNum.setUdQty(Double.valueOf(queryGrStatusDto.getUdQty()).intValue());
cacheMap.put(key, grUdNum);
dataCache.updateCache(CACHE_GR_UDQTY, cacheMap);
}
return grUdNum;
}
public static synchronized void addQty(String grCode, String grItem, int count) {
Map<String, GrUdNum> cacheMap = dataCache.getCache(CACHE_GR_UDQTY);
if (cacheMap == null) {
cacheMap = Maps.newConcurrentMap();
}
String key = grCode + "_" + grItem;
return cacheMap.get(key);
GrUdNum grUdNum = cacheMap.get(key);
grUdNum.setUdQty(grUdNum.getUdQty()+count);
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!