Commit 74fe500a LN

增加麦康尼库位同步接口updateMInventory

1 个父辈 05c8a767
...@@ -117,6 +117,12 @@ public class StoragePos extends BasePo implements Serializable { ...@@ -117,6 +117,12 @@ public class StoragePos extends BasePo implements Serializable {
private List<String> mergePosList; private List<String> mergePosList;
/**
* 库位备注,麦康尼料仓报错麦康尼库位号
*/
private String remark;
public String getLabelStr(){ public String getLabelStr(){
String posNameLabel = posName; String posNameLabel = posName;
int index = posNameLabel.lastIndexOf(":"); int index = posNameLabel.lastIndexOf(":");
......
package com.neotel.smfcore.custom.micron1053.bean;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import java.io.Serializable;
@Data
@Slf4j
@AllArgsConstructor
@NoArgsConstructor
public class MInventory implements Serializable {
/**
* 条码,唯一码
*/
private String carrier;
/**
* 麦康尼库位号
*/
private String depot;
/**
* 条码
*/
private String partNumber;
/**
* 直径
*/
private Integer diameter;
/**
* 高度
*/
private Integer height;
/**
* 正确匹配的数据,不需要处理
*/
private boolean rightData=false;
public String getDepotCid(){
// 缺少库存,自动增加库存
String[] arrays = depot.split(",");
if (arrays.length < 2) {
return "";
}
String cid = arrays[0].substring(1);
return cid;
}
}
package com.neotel.smfcore.custom.micron1053.controller; package com.neotel.smfcore.custom.micron1053.controller;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.bean.ResultBean; import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.JsonUtil; import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.util.DataCache;
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.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService; import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.micron1053.bean.MInventory;
import com.neotel.smfcore.custom.micron1053.bean.ML5NgReelInfo; import com.neotel.smfcore.custom.micron1053.bean.ML5NgReelInfo;
import com.neotel.smfcore.custom.micron1053.bean.MicronEquipStatus; import com.neotel.smfcore.custom.micron1053.bean.MicronEquipStatus;
import com.neotel.smfcore.custom.micron1053.util.MicronDataCache; import com.neotel.smfcore.custom.micron1053.util.MicronDataCache;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import com.neotel.smfcore.security.bean.FileProperties;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.Collections; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j @Slf4j
@RestController @RestController
@Api(tags = "1053:设备端接口") @Api(tags = "1053:设备端接口")
@RequestMapping("/rest/micron/device") @RequestMapping("/rest/micron/device")
@RequiredArgsConstructor
public class MicronDeviceController { public class MicronDeviceController {
@Autowired @Autowired
private final FileProperties properties;
@Autowired
private TaskService taskService; private TaskService taskService;
@Autowired
private DataCache dataCache;
@Autowired
private IStoragePosManager storagePosManager;
@Autowired
private IBarcodeManager barcodeManager;
@ApiOperation("单个设备状态更新,可传集合,也可只传一个设备状态 (ML5,CI,R1,R2,R3) (1=正常运行,2=报警) ") @ApiOperation("单个设备状态更新,可传集合,也可只传一个设备状态 (ML5,CI,R1,R2,R3) (1=正常运行,2=报警) ")
@PostMapping(value = "/updateStatus") @PostMapping(value = "/updateStatus")
@ResponseBody @ResponseBody
...@@ -123,6 +144,163 @@ public class MicronDeviceController { ...@@ -123,6 +144,163 @@ public class MicronDeviceController {
MicronDataCache.clearNgPos(ngPos); MicronDataCache.clearNgPos(ngPos);
return ResultBean.newOkResult("clearNgPos " + ngPos + " ok"); return ResultBean.newOkResult("clearNgPos " + ngPos + " ok");
} }
@ApiOperation("更新麦康尼料仓库存")
@PostMapping(value = "/updateMInventory")
@ResponseBody
@AnonymousAccess
public ResultBean updateMInventory(@RequestBody Object param) throws Exception {
if (param instanceof List) {
List<Object> list = (List<Object>) param;
if(list.size()<=0){
log.info("updateMInventory: 未解析到有效数据,返回格式错误");
return ResultBean.newErrorResult(99, "smfcore.device.formatError", "格式错误");
}
//获取麦康尼料仓
Map<String, StoragePos> allUsedStoragePosMap = getMUsedMPosMap();
int okCount=0;
Map<String, String> barcodeInventory = new HashMap<>();
List<MInventory> mInventoryList=new ArrayList<>();
for (Object object : list
) {
MInventory obj = JsonUtil.toObj(object.toString(), MInventory.class);
if (obj == null || ObjectUtil.isEmpty(obj.getCarrier()) || ObjectUtil.isEmpty(obj.getDepot())) {
continue;
}
barcodeInventory.put(obj.getCarrier(), obj.getDepot());
String cid = obj.getDepotCid();
//在库存中且料仓相同
if (ObjectUtil.isNotEmpty(cid)) {
//判断是否已在库位中
StoragePos inPos = allUsedStoragePosMap.get(obj.getCarrier());
if (inPos != null) {
Storage storage = dataCache.getStorage(cid);
if (storage != null) {
if(inPos.getStorageId().equals(storage.getId())){
obj.setRightData(true);
okCount++;
}
}
}
}
mInventoryList.add(obj);
}
int pipeidu;
if(allUsedStoragePosMap.size()==0){
pipeidu=(okCount*100)/10;
}
else {
pipeidu = (okCount * 100) / allUsedStoragePosMap.size();
}
if(pipeidu<80){
log.info("updateMInventory : 库存数据:[" + allUsedStoragePosMap.size() + "]条,上传数据:[" + mInventoryList.size() + "]条,匹配正确数据["+okCount+"]条,匹配度="+pipeidu+"%,匹配度过低,不处理数据" );
return ResultBean.newErrorResult(99, "smfcore.device.formatError", "格式错误");
}
log.info("updateMInventory : 库存数据:[" + allUsedStoragePosMap.size() + "]条,上传数据:[" + mInventoryList.size() + "]条,匹配正确数据["+okCount+"]条,匹配度="+pipeidu+"%");
for (MInventory obj : mInventoryList
) {
if (obj.isRightData()) {
continue;
}
String mCid = obj.getDepotCid();
//判断是否已在库位中
StoragePos inPos = allUsedStoragePosMap.get(obj.getCarrier());
if (inPos == null) {
//不在缓存库位中,查询数据库,是否再其他库位
inPos = storagePosManager.getByBarcode(obj.getCarrier());
}
Storage inStorage = null;
if (inPos != null) {
//在同一个料仓
inStorage = dataCache.getStorageById(inPos.getStorageId());
if (inStorage != null && inStorage.getCid().equals(mCid)) {
continue;
}
}
Barcode barcode = barcodeManager.findByBarcode(obj.getCarrier());
if (barcode == null) {
log.info("updateMInventory : barcode[" + obj.getCarrier() + "]MPos[" + obj.getDepot() + "]未在库存中,未找到条码信息,跳过此数据");
continue;
}
Storage SStorage = dataCache.getStorage(mCid);
if (inPos != null) {
log.info("updateMInventory : barcode[" + obj.getCarrier() + "]MPos[" + obj.getDepot() + "]在库位[" + inPos.getPosName() + "-" + inPos.getStorageId() + "-" + inStorage.getCid() + "]中," +
"清空此库位,重新入库到料仓[" + SStorage.getName() + "-" + SStorage.getCid() + "-" + SStorage.getId() + "]");
//不在一个库位中,需要 清空原来的库位,重新 入库。
log.info("updateMInventory: 清理库位[" + inPos.getPosName() + "]中的库存:" + barcode);
taskService.addTaskToFinished(inPos, null, "MInventory" + "-clear");
}
try {
Collection<String> excludePos = taskService.excludePosIds();
StoragePos newPos = storagePosManager.getEmptyPosByStorage(SStorage, barcode, excludePos);
log.info("updateMInventory : barcode[" + obj.getCarrier() + "]MPos[" + obj.getDepot() + "] 自动增加库存:[" + newPos.getPosName() + "]料仓[" + SStorage.getName() + "-" + SStorage.getCid() + "-" + SStorage.getId() + "]]");
taskService.addTaskToFinished(newPos, barcode, "MInventory" + "-add");
} catch (Exception ex) {
log.error("updateMInventory : barcode[" + obj.getCarrier() + "]MPos[" + obj.getDepot() + "] 自动增加库存出错,跳过此数据,错误信息:" + ex.toString());
continue;
}
}
for (StoragePos pos :
allUsedStoragePosMap.values()) {
String barcode = pos.getBarcode().getBarcode();
//判断是否已在库位中
if (barcodeInventory.containsKey(barcode)) {
continue;
}
StoragePos inPos = storagePosManager.getByBarcode(barcode);
if (inPos == null) {
log.info("updateMInventory: barcode[" + barcode + "]在缓存中在库位[" + pos.getPosName() + "-" + pos.getStorageId() + "]中,数据库中未找到inPos,跳过此数据");
continue;
}
//需要清空库位信息,自动出库
log.info("updateMInventory: 清理库位[" + pos.getPosName() + "]中的库存:" + barcode);
taskService.addTaskToFinished(pos, null, "MInventory" + "-clear");
}
} else {
return ResultBean.newErrorResult(99, "smfcore.device.formatError", "格式错误");
}
return ResultBean.newOkResult("ok");
}
private Map<String, StoragePos> getMUsedMPosMap(){
//获取麦康尼料仓
Map<String, StoragePos> allUsedStoragePosMap = new HashMap<>();
List<String> mCids = new ArrayList<>();
//获取当前库存所有数据
Map<String, Storage> allStorageMap = dataCache.getAllStorage();
for (Storage storage :
allStorageMap.values()) {
if (storage.isTHIRDBox()) {
mCids.add(storage.getCid());
//获取当前麦康尼的所有库存信息
Map<String, StoragePos> usedMap = dataCache.getUsedPosList(storage.getCid());
for (StoragePos pos :
usedMap.values()) {
allUsedStoragePosMap.put(pos.getBarcode().getBarcode(), pos);
}
}
}
return allUsedStoragePosMap;
}
// @ApiOperation("ML5设备状态更新") // @ApiOperation("ML5设备状态更新")
// @PostMapping(value = "ml5/updateStatus") // @PostMapping(value = "ml5/updateStatus")
......
...@@ -345,6 +345,7 @@ smfcore.saveOk=\u4FDD\u5B58\u6210\u529F ...@@ -345,6 +345,7 @@ smfcore.saveOk=\u4FDD\u5B58\u6210\u529F
smfcore.lockMaterials=\u9501\u5B9A\u7269\u6599 smfcore.lockMaterials=\u9501\u5B9A\u7269\u6599
smfcore.emptyOut.fail=\u4EFB\u52A1[{0}]\u7A7A\u51FA\u5904\u7406\u5931\u8D25:{1} smfcore.emptyOut.fail=\u4EFB\u52A1[{0}]\u7A7A\u51FA\u5904\u7406\u5931\u8D25:{1}
smfcore.storage.error.posNameExist=\u5E93\u4F4D\u53F7\u5DF2\u5728\u5176\u4ED6\u6599\u4ED3\u5B58\u5728\uFF1A{0} smfcore.storage.error.posNameExist=\u5E93\u4F4D\u53F7\u5DF2\u5728\u5176\u4ED6\u6599\u4ED3\u5B58\u5728\uFF1A{0}
smfcore.device.formatError= \u683C\u5F0F\u9519\u8BEF
#smfclient.nlp.onlyOneTray=\u4E0D\u53EF\u540C\u65F6\u653E\u5165\u591A\u76D8\u7269\u6599:{0} #smfclient.nlp.onlyOneTray=\u4E0D\u53EF\u540C\u65F6\u653E\u5165\u591A\u76D8\u7269\u6599:{0}
#smfclient.nlp.cannotFindPos={0}\u672A\u627E\u5230\u5E93\u4F4D:{1} #smfclient.nlp.cannotFindPos={0}\u672A\u627E\u5230\u5E93\u4F4D:{1}
#smfclient.nlp.inputOk={0}\u5165\u5E93\u5230{1}\u6210\u529F #smfclient.nlp.inputOk={0}\u5165\u5E93\u5230{1}\u6210\u529F
......
...@@ -345,3 +345,4 @@ smfcore.saveOk=save successfully ...@@ -345,3 +345,4 @@ smfcore.saveOk=save successfully
smfcore.lockMaterials=Locking Materials smfcore.lockMaterials=Locking Materials
smfcore.emptyOut.fail=Task [{0}] empty processing failure:{1} smfcore.emptyOut.fail=Task [{0}] empty processing failure:{1}
smfcore.storage.error.posNameExist=Bin number already exists in other bins\uFF1A{0} smfcore.storage.error.posNameExist=Bin number already exists in other bins\uFF1A{0}
smfcore.device.formatError= Format error
\ No newline at end of file \ No newline at end of file
...@@ -342,3 +342,4 @@ smfcore.saveOk=\u4FDD\u5B58\u6210\u529F ...@@ -342,3 +342,4 @@ smfcore.saveOk=\u4FDD\u5B58\u6210\u529F
smfcore.lockMaterials=\u9501\u5B9A\u7269\u6599 smfcore.lockMaterials=\u9501\u5B9A\u7269\u6599
smfcore.emptyOut.fail=\u4EFB\u52A1[{0}]\u7A7A\u51FA\u5904\u7406\u5931\u8D25:{1} smfcore.emptyOut.fail=\u4EFB\u52A1[{0}]\u7A7A\u51FA\u5904\u7406\u5931\u8D25:{1}
smfcore.storage.error.posNameExist=\u5E93\u4F4D\u53F7\u5DF2\u5728\u5176\u4ED6\u6599\u4ED3\u5B58\u5728\uFF1A{0} smfcore.storage.error.posNameExist=\u5E93\u4F4D\u53F7\u5DF2\u5728\u5176\u4ED6\u6599\u4ED3\u5B58\u5728\uFF1A{0}
smfcore.device.formatError= \u683C\u5F0F\u9519\u8BEF
\ No newline at end of file \ No newline at end of file
...@@ -342,3 +342,4 @@ smfcore.saveOk=\u4FDD\u5B58\u6210\u529F ...@@ -342,3 +342,4 @@ smfcore.saveOk=\u4FDD\u5B58\u6210\u529F
smfcore.lockMaterials=\u9501\u5B9A\u7269\u6599 smfcore.lockMaterials=\u9501\u5B9A\u7269\u6599
smfcore.emptyOut.fail=\u4EFB\u52A1[{0}]\u7A7A\u51FA\u5904\u7406\u5931\u8D25:{1} smfcore.emptyOut.fail=\u4EFB\u52A1[{0}]\u7A7A\u51FA\u5904\u7406\u5931\u8D25:{1}
smfcore.storage.error.posNameExist=\u5E93\u4F4D\u53F7\u5DF2\u5728\u5176\u4ED6\u6599\u4ED3\u5B58\u5728\uFF1A{0} smfcore.storage.error.posNameExist=\u5E93\u4F4D\u53F7\u5DF2\u5728\u5176\u4ED6\u6599\u4ED3\u5B58\u5728\uFF1A{0}
smfcore.device.formatError= \u683C\u5F0F\u9519\u8BEF
\ No newline at end of file \ No newline at end of file
...@@ -343,3 +343,4 @@ smfcore.saveOk=\u4FDD\u5B58\u6210\u529F ...@@ -343,3 +343,4 @@ smfcore.saveOk=\u4FDD\u5B58\u6210\u529F
smfcore.lockMaterials=\u9396\u5B9A\u7269\u6599 smfcore.lockMaterials=\u9396\u5B9A\u7269\u6599
smfcore.emptyOut.fail=\u4EFB\u52D9[{0}]\u7A7A\u51FA\u8655\u7406\u5931\u6557:{1} smfcore.emptyOut.fail=\u4EFB\u52D9[{0}]\u7A7A\u51FA\u8655\u7406\u5931\u6557:{1}
smfcore.storage.error.posNameExist=\u5EAB\u4F4D\u865F\u5DF2\u5728\u5176\u4ED6\u6599\u5009\u5B58\u5728\uFF1A{0} smfcore.storage.error.posNameExist=\u5EAB\u4F4D\u865F\u5DF2\u5728\u5176\u4ED6\u6599\u5009\u5B58\u5728\uFF1A{0}
smfcore.device.formatError= \u683C\u5F0F\u932F\u8AA4
\ No newline at end of file \ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!