Commit 437a3c12 zshaohui

立臻项目功能提交

1 个父辈 4a9001b6
正在显示 24 个修改的文件 包含 1123 行增加291 行删除
...@@ -8,8 +8,10 @@ import lombok.val; ...@@ -8,8 +8,10 @@ import lombok.val;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair; import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder; import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
...@@ -141,4 +143,41 @@ public class HttpHelper { ...@@ -141,4 +143,41 @@ public class HttpHelper {
} }
/**
* 发送HttpGet请求
*
* @param url
* @return
*/
public static String sendGet(String url) {
HttpGet httpget = new HttpGet(url);
RequestConfig build = RequestConfig.custom().setSocketTimeout(5000)
.setConnectTimeout(5000)
.setConnectionRequestTimeout(5000).build();
httpget.setConfig(build);
CloseableHttpResponse response = null;
try {
CloseableHttpClient httpClient = HttpClients.createDefault();
response = httpClient.execute(httpget);
} catch (IOException e1) {
e1.printStackTrace();
}
String result = null;
try {
HttpEntity entity = response.getEntity();
if (entity != null) {
result = EntityUtils.toString(entity);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
response.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
} }
...@@ -55,6 +55,9 @@ public class SmfApi { ...@@ -55,6 +55,9 @@ public class SmfApi {
@Value("${api.fetchOrderUrl:}") @Value("${api.fetchOrderUrl:}")
protected String fetchOrderUrl = ""; protected String fetchOrderUrl = "";
@Value("${api.barcodeInfoUrl:}")
protected String barcodeInfoUrl = "";
@PostConstruct @PostConstruct
public void init(){ public void init(){
apiName = dataCache.getConfigCache("api.name",apiName); apiName = dataCache.getConfigCache("api.name",apiName);
...@@ -65,6 +68,7 @@ public class SmfApi { ...@@ -65,6 +68,7 @@ public class SmfApi {
orderNotifyUrl = dataCache.getConfigCache("api.orderNotifyUrl",orderNotifyUrl); orderNotifyUrl = dataCache.getConfigCache("api.orderNotifyUrl",orderNotifyUrl);
fetchInListUrl = dataCache.getConfigCache("api.fetchInListUrl",fetchInListUrl); fetchInListUrl = dataCache.getConfigCache("api.fetchInListUrl",fetchInListUrl);
fetchOrderUrl = dataCache.getConfigCache("api.fetchOrderUrl",fetchOrderUrl); fetchOrderUrl = dataCache.getConfigCache("api.fetchOrderUrl",fetchOrderUrl);
barcodeInfoUrl = dataCache.getConfigCache("api.barcodeInfoUrl",barcodeInfoUrl);
} }
/** /**
...@@ -145,9 +149,6 @@ public class SmfApi { ...@@ -145,9 +149,6 @@ public class SmfApi {
} }
public LiteOrder fetchOrder(String orderNumber, String username){ public LiteOrder fetchOrder(String orderNumber, String username){
if(orderNumber == null){
throw new ValidateException("smfcore.fetchOrder.orderNumber.empty","工单号不能为空");
}
if(isUrlExist(fetchOrderUrl)){ if(isUrlExist(fetchOrderUrl)){
for (ISmfApiListener apiListener : apiListenerList) { for (ISmfApiListener apiListener : apiListenerList) {
if(apiListener.isForThisApi(apiName)){ if(apiListener.isForThisApi(apiName)){
...@@ -174,4 +175,17 @@ public class SmfApi { ...@@ -174,4 +175,17 @@ public class SmfApi {
return false; return false;
} }
public Barcode barcodeInfo(Barcode barcode) {
if (isUrlExist(barcodeInfoUrl)) {
for (ISmfApiListener apiListener : apiListenerList) {
if (apiListener.isForThisApi(apiName)) {
Barcode responseBarcode = apiListener.barcodeInfo(barcodeInfoUrl,barcode);
if (responseBarcode != null) {
return responseBarcode;
}
}
}
}
return null;
}
} }
...@@ -246,4 +246,9 @@ public class DefaultSmfApiListener extends BaseSmfApiListener { ...@@ -246,4 +246,9 @@ public class DefaultSmfApiListener extends BaseSmfApiListener {
public LiteOrder fetchOrder(String fetchOrderUrl, String orderNumber, String username){ public LiteOrder fetchOrder(String fetchOrderUrl, String orderNumber, String username){
return null; return null;
} }
@Override
public Barcode barcodeInfo(String barcodeInfoUrl,Barcode barcode) {
return null;
}
} }
...@@ -48,4 +48,6 @@ public interface ISmfApiListener { ...@@ -48,4 +48,6 @@ public interface ISmfApiListener {
* @return * @return
*/ */
LiteOrder fetchOrder(String url, String orderNumber, String username); LiteOrder fetchOrder(String url, String orderNumber, String username);
Barcode barcodeInfo(String barcodeInfoUrl,Barcode barcode);
} }
...@@ -200,6 +200,19 @@ public class BarcodeRule { ...@@ -200,6 +200,19 @@ public class BarcodeRule {
log.info("expireDay: 为" + newRule.expireDay_item.toString()); log.info("expireDay: 为" + newRule.expireDay_item.toString());
} }
} }
if(!newRule.dateCode_item.hasThisField()){
if(newRule.dateCode_item.matchRule(fieldValue,i)){
log.info("dateCode: 为" + newRule.dateCode_item.toString());
}
}
if(!newRule.providerNumber_item.hasThisField()){
if(newRule.providerNumber_item.matchRule(fieldValue,i)){
log.info("providerNumber: 为" + newRule.providerNumber_item.toString());
}
}
} }
boolean validRule = false; boolean validRule = false;
if(newRule.partNumber_item.hasThisField()){ if(newRule.partNumber_item.hasThisField()){
...@@ -234,6 +247,8 @@ public class BarcodeRule { ...@@ -234,6 +247,8 @@ public class BarcodeRule {
private RuleItem batch_item = new RuleItem("BATCH"); private RuleItem batch_item = new RuleItem("BATCH");
private RuleItem msl_item = new RuleItem("MSL"); private RuleItem msl_item = new RuleItem("MSL");
private RuleItem memo_item = new RuleItem("MEMO"); private RuleItem memo_item = new RuleItem("MEMO");
private RuleItem dateCode_item = new RuleItem("DATECODE");
private RuleItem providerNumber_item = new RuleItem("PROVIDERNUMBER");
private class RuleItem{ private class RuleItem{
private RuleItem(String ruleName) { private RuleItem(String ruleName) {
...@@ -541,6 +556,9 @@ public class BarcodeRule { ...@@ -541,6 +556,9 @@ public class BarcodeRule {
} }
if(batch_item.hasThisField()){ if(batch_item.hasThisField()){
String batch = batch_item.getStrValue(codeArr); String batch = batch_item.getStrValue(codeArr);
if (batch.indexOf("-") != -1){
batch = batch.substring(0,batch.indexOf("-"));
}
b.setBatch(batch); b.setBatch(batch);
} }
int quantity = 1; int quantity = 1;
...@@ -590,8 +608,28 @@ public class BarcodeRule { ...@@ -590,8 +608,28 @@ public class BarcodeRule {
b.setMemo(memo); b.setMemo(memo);
} }
if (dateCode_item.hasThisField()){
String dateCode = dateCode_item.getStrValue(codeArr);
if (dateCode.indexOf("-") != -1){
dateCode = dateCode.substring(dateCode.indexOf("-")+1,dateCode.length());
}
b.setDateCode(dateCode);
}
if (providerNumber_item.hasThisField()){
String providerNumber = providerNumber_item.getStrValue(codeArr);
if (providerNumber.indexOf("-") != -1){
providerNumber = providerNumber.substring(providerNumber.indexOf("-")+1,providerNumber.length());
}
b.setProviderNumber(providerNumber);
}
b.setBarcode(reelId); b.setBarcode(reelId);
codeBean.setCodeStr(reelId); codeBean.setCodeStr(reelId);
//如果是立臻的,则取-前面的
if (partNumber.indexOf("-") != -1){
partNumber = partNumber.substring(0,partNumber.indexOf("-"));
}
b.setPartNumber(partNumber); b.setPartNumber(partNumber);
b.setAmount(quantity); b.setAmount(quantity);
b.setProduceDate(produceDate); b.setProduceDate(produceDate);
...@@ -727,6 +765,18 @@ public class BarcodeRule { ...@@ -727,6 +765,18 @@ public class BarcodeRule {
codeStr = "CS0001-1"; codeStr = "CS0001-1";
rule = "RI[-1:6:-1]PN[-1:2:-1]"; rule = "RI[-1:6:-1]PN[-1:2:-1]";
codeStr = "107S0257-017425|YB1N27N06-2216|20000|M1001742524EA09EUT|MURATA";
rule = "PN[-1:20:-1]PROVIDERNUMBER[-1:20:-1]|BATCH[-1:20:-1]DATECODE[-1:20:-1]|QTY|RI|SP";
codeStr = "103S00421-797001|TPA221300067-20220320|20000|A1079700122220C406|CYNTEC|TPA2213000670000C406";
rule = "PN[-1:20:-1]PROVIDERNUMBER[-1:20:-1]|BATCH[-1:20:-1]DATECODE[-1:20:-1]|QTY|4|SP|RI";
codeStr = "138S00138-012207|2022-1015|41625|L130122074222008AL|KYOCERA|";
rule = "PN[-1:20:-1]PROVIDERNUMBER[-1:20:-1]|BATCH[-1:20:-1]DATECODE[-1:20:-1]|QTY|RI|SP|6";
BarcodeRule br = BarcodeRule.newRule(rule); BarcodeRule br = BarcodeRule.newRule(rule);
Barcode b = br.toCodeBean(codeStr).getBarcode(); Barcode b = br.toCodeBean(codeStr).getBarcode();
if(b != null){ if(b != null){
...@@ -739,6 +789,9 @@ public class BarcodeRule { ...@@ -739,6 +789,9 @@ public class BarcodeRule {
System.out.println("EXPDATE:"+b.getExpireDate()); System.out.println("EXPDATE:"+b.getExpireDate());
System.out.println("Supllier:"+b.getProvider()); System.out.println("Supllier:"+b.getProvider());
System.out.println("Memo:"+b.getMemo()); System.out.println("Memo:"+b.getMemo());
System.out.println("DataCode:"+b.getDateCode());
System.out.println("ProviderNumber:"+b.getProviderNumber());
//System.out.println("Provider:"+b.getProvider());
}else{ }else{
log.info("解析失败"); log.info("解析失败");
} }
......
...@@ -241,12 +241,13 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -241,12 +241,13 @@ public class BaseDeviceHandler implements IDeviceHandler {
} }
//本地难条码是否可以入库 //本地难条码是否可以入库
verifyBarcodePutIn(Lists.<Storage>newArrayList(storage), barcodeSave); verifyBarcodePutIn(Lists.<Storage>newArrayList(storage), barcodeSave);
//从API验证 //从API验证
Barcode barcodeFromApi = smfApi.canPutInAfterResolve(barcodeSave); /*Barcode barcodeFromApi = smfApi.canPutInAfterResolve(barcodeSave);
if (barcodeFromApi != null) { if (barcodeFromApi != null) {
barcodeSave = barcodeFromApi; barcodeSave = barcodeFromApi;
} }*/
// //西门子接口验证 // //西门子接口验证
// boolean result=SiemensApi.getMaterialLot(1, storage.getId(),storage.getName(),barcodeSave.getBarcode()); // boolean result=SiemensApi.getMaterialLot(1, storage.getId(),storage.getName(),barcodeSave.getBarcode());
......
...@@ -10,6 +10,8 @@ import com.neotel.smfcore.common.bean.ResultBean; ...@@ -10,6 +10,8 @@ import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException; import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants; import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.ReelLockPosUtil; import com.neotel.smfcore.common.utils.ReelLockPosUtil;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.api.listener.ISmfApiListener;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve; import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.bean.PosInfo; import com.neotel.smfcore.core.device.bean.PosInfo;
...@@ -57,6 +59,9 @@ public class DeviceController { ...@@ -57,6 +59,9 @@ public class DeviceController {
@Autowired @Autowired
private IStoragePosManager storagePosManager; private IStoragePosManager storagePosManager;
@Autowired
private SmfApi smfApi;
private Map<String, IDeviceHandler> handlerMap = new HashMap<>(); private Map<String, IDeviceHandler> handlerMap = new HashMap<>();
public DeviceController(List<IDeviceHandler> deviceHandlerList) { public DeviceController(List<IDeviceHandler> deviceHandlerList) {
...@@ -155,10 +160,21 @@ public class DeviceController { ...@@ -155,10 +160,21 @@ public class DeviceController {
try { try {
Barcode barcode = codeResolve.resolveOneValideBarcode(code); Barcode barcode = codeResolve.resolveOneValideBarcode(code);
if(barcode==null) { if(barcode==null) {
throw new ValidateException("smfcore.error.barcode.invalid", "{0}不是有效的条码", new String[]{code}); throw new ValidateException("smfcore.error.barcode.invalid", "{0}不是有效的条码", new String[]{code});
} }
Barcode barcodeCanPutIn = smfApi.canPutInAfterResolve(barcode);
if (barcodeCanPutIn != null){
barcode = barcodeCanPutIn;
}
Barcode barcodeApi = smfApi.barcodeInfo(barcode);
if (barcodeApi != null){
barcode = barcodeApi;
}
for (DataLog dataLog : taskService.getQueueTasks()) { for (DataLog dataLog : taskService.getQueueTasks()) {
// if(!dataLog.isPackageReel()){ // if(!dataLog.isPackageReel()){
//已经在任务当中,返回对应的信息 //已经在任务当中,返回对应的信息
......
...@@ -8,6 +8,7 @@ import com.neotel.smfcore.common.exception.ValidateException; ...@@ -8,6 +8,7 @@ import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants; import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.SecurityUtils; import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.core.api.SmfApi; import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.enums.OP; import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS; import com.neotel.smfcore.core.device.enums.OP_STATUS;
...@@ -27,6 +28,8 @@ import com.neotel.smfcore.core.system.service.po.DataLog; ...@@ -27,6 +28,8 @@ 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 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.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
...@@ -53,9 +56,13 @@ public class LiteOrderCache { ...@@ -53,9 +56,13 @@ public class LiteOrderCache {
@Autowired @Autowired
private IStoragePosManager storagePosManager; private IStoragePosManager storagePosManager;
@Autowired @Autowired
private SmfApi smfApi; private SmfApi smfApi;
@Autowired
private IBarcodeManager barcodeManager;
/** /**
* 正在执行的liteOrderMap, key 为orderNo,value 为order * 正在执行的liteOrderMap, key 为orderNo,value 为order
*/ */
...@@ -218,7 +225,7 @@ public class LiteOrderCache { ...@@ -218,7 +225,7 @@ public class LiteOrderCache {
}else if(liteOrder.isOutTails()){ }else if(liteOrder.isOutTails()){
// setStatus(LITEORDER_STATUS.TAILS_FINISHED); // setStatus(LITEORDER_STATUS.TAILS_FINISHED);
liteOrder.setClosed(true); liteOrder.setClosed(true);
}else if (liteOrder.isOutTails()){ }else if (liteOrder.isNew()){
liteOrder.setClosed(true); liteOrder.setClosed(true);
} }
...@@ -398,10 +405,12 @@ public class LiteOrderCache { ...@@ -398,10 +405,12 @@ public class LiteOrderCache {
if(cacheOrder.getType()==2){ if(cacheOrder.getType()==2){
//RI //RI
pos=storagePosManager.getByBarcode(orderItem.getRi()); pos=storagePosManager.getByBarcode(orderItem.getRi());
if(excludePosIds.contains(pos.getId())) { if (pos != null) {
if (excludePosIds.contains(pos.getId())) {
log.info("工单[" + orderNo + "]RI出库,任务数[" + taskReelCount + "]出库位置仓位【" + pos.getPosName() + "】RI=[" + pos.getBarcode().getBarcode() + "]已在操作队列中,跳过不处理"); log.info("工单[" + orderNo + "]RI出库,任务数[" + taskReelCount + "]出库位置仓位【" + pos.getPosName() + "】RI=[" + pos.getBarcode().getBarcode() + "]已在操作队列中,跳过不处理");
break; break;
} }
}
}else{ }else{
//PN //PN
pos=storagePosManager.findPartNumberInStorages(availableStorageIds, partNumber, excludePosIds, checkoutType); pos=storagePosManager.findPartNumberInStorages(availableStorageIds, partNumber, excludePosIds, checkoutType);
...@@ -416,13 +425,19 @@ public class LiteOrderCache { ...@@ -416,13 +425,19 @@ public class LiteOrderCache {
DataLog task = newTask(pos) ; DataLog task = newTask(pos) ;
task.setSourceId(cacheOrder.getId()); task.setSourceId(cacheOrder.getId());
if (pos.getBarcode().getBarcode().startsWith("CS") ||
pos.getBarcode().getBarcode().startsWith("CM") ||
pos.getBarcode().getBarcode().startsWith("CB")){
taskReelCount = cacheOrder.getOrderItems().size();
} else {
task.setSourceName(cacheOrder.getOrderNo()); task.setSourceName(cacheOrder.getOrderNo());
}
task.setSubSourceId(orderItem.getId()); task.setSubSourceId(orderItem.getId());
task.setSubSourceInfo(orderItem.getFeederInfo()); task.setSubSourceInfo(orderItem.getFeederInfo());
task.setType(OP.CHECKOUT); task.setType(OP.CHECKOUT);
task.setLightColor(nextColor.getRgb()); task.setLightColor(nextColor.getRgb());
task.setStatus(OP_STATUS.WAIT.name()); task.setStatus(OP_STATUS.WAIT.name());
task.setPartNumber(orderItem.getPn()); task.setPartNumber(pos.getBarcode().getPartNumber());
// task = dataLogDao.save(task); // task = dataLogDao.save(task);
taskService.addTaskToExecute(task); taskService.addTaskToExecute(task);
} }
...@@ -432,9 +447,7 @@ public class LiteOrderCache { ...@@ -432,9 +447,7 @@ public class LiteOrderCache {
} }
} }
} }
} }
cacheOrder.setTaskReelCount(taskReelCount); cacheOrder.setTaskReelCount(taskReelCount);
cacheOrder.setTotalTaskReelCount(cacheOrder.getTotalTaskReelCount()+taskReelCount); cacheOrder.setTotalTaskReelCount(cacheOrder.getTotalTaskReelCount()+taskReelCount);
log.info("工单[" + orderNo + "]任务分配结束,任务数[" + taskReelCount + "]"); log.info("工单[" + orderNo + "]任务分配结束,任务数[" + taskReelCount + "]");
...@@ -603,12 +616,59 @@ public class LiteOrderCache { ...@@ -603,12 +616,59 @@ public class LiteOrderCache {
public Collection<String> excludeBarcodeIds() { public Collection<String> excludeBarcodeIds() {
Collection<String> barcodeIds = new ArrayList<>(); Collection<String> barcodeIds = new ArrayList<>();
Collection<LiteOrder> liteOrders = liteOrderMap.values();
if (liteOrders != null && !liteOrders.isEmpty()) {
for (LiteOrder liteOrder : liteOrderMap.values()) { for (LiteOrder liteOrder : liteOrderMap.values()) {
List<LiteOrderItem> orderItems = liteOrder.getOrderItems(); List<LiteOrderItem> orderItems = liteOrder.getOrderItems();
for (LiteOrderItem orderItem : orderItems) { for (LiteOrderItem orderItem : orderItems) {
barcodeIds.add(orderItem.getRi()); barcodeIds.add(orderItem.getRi());
} }
} }
}
return barcodeIds; return barcodeIds;
} }
public String executeOrderByBarcode(String barcode){
Collection<LiteOrder> liteOrders = liteOrderMap.values();
if (liteOrders != null && !liteOrders.isEmpty()) {
for (LiteOrder liteOrder : liteOrderMap.values()) {
for (LiteOrderItem orderItem : liteOrder.getOrderItems()) {
if (orderItem.getRi().equals(barcode)) {
return liteOrder.getOrderNo();
}
}
}
}
return null;
}
public Collection<LiteOrderItem> executeItems() {
Collection<LiteOrderItem> items = new ArrayList<>();
Collection<LiteOrder> liteOrders = liteOrderMap.values();
if (liteOrders != null && !liteOrders.isEmpty()) {
for (LiteOrder liteOrder : liteOrderMap.values()) {
List<LiteOrderItem> orderItems = liteOrder.getOrderItems();
for (LiteOrderItem orderItem : orderItems) {
items.add(orderItem);
}
}
}
return items;
}
public Collection<String> executePartNumber(){
Collection<String> partNumbers = new ArrayList<>();
Collection<LiteOrder> liteOrders = liteOrderMap.values();
if (liteOrders != null && !liteOrders.isEmpty()) {
for (LiteOrder liteOrder : liteOrderMap.values()) {
List<LiteOrderItem> orderItems = liteOrder.getOrderItems();
for (LiteOrderItem orderItem : orderItems) {
partNumbers.add(orderItem.getPn());
}
}
}
return partNumbers;
}
} }
...@@ -80,6 +80,12 @@ public class LiteOrderItem extends BasePo implements Serializable ,Comparable<Li ...@@ -80,6 +80,12 @@ public class LiteOrderItem extends BasePo implements Serializable ,Comparable<Li
*/ */
private String side = ""; private String side = "";
/**
* 库位
*/
private String posName;
/** /**
* 出库是否满足要求,已出库数量大于需求数量 * 出库是否满足要求,已出库数量大于需求数量
*/ */
......
...@@ -66,4 +66,6 @@ public interface IStoragePosManager extends IBaseManager<StoragePos> { ...@@ -66,4 +66,6 @@ public interface IStoragePosManager extends IBaseManager<StoragePos> {
List<StoragePos> findPosList(String storageId, List<String> posNames); List<StoragePos> findPosList(String storageId, List<String> posNames);
List<StoragePos> getSameSizeContinuityEmptyPosList(Storage storage, Barcode barcode) throws ValidateException; List<StoragePos> getSameSizeContinuityEmptyPosList(Storage storage, Barcode barcode) throws ValidateException;
StoragePos findByQueryOne(Query query);
} }
...@@ -30,7 +30,6 @@ import org.springframework.stereotype.Service; ...@@ -30,7 +30,6 @@ import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
@Service @Service
@Slf4j @Slf4j
...@@ -562,6 +561,11 @@ public class StoragePosManagerImpl implements IStoragePosManager { ...@@ -562,6 +561,11 @@ public class StoragePosManagerImpl implements IStoragePosManager {
return new ArrayList<>(); return new ArrayList<>();
} }
@Override
public StoragePos findByQueryOne(Query query) {
return storagePosDao.findOne(query);
}
/** /**
* 获取下一库位的库位名(后缀数字+1) * 获取下一库位的库位名(后缀数字+1)
*/ */
......
...@@ -302,9 +302,9 @@ public class DataLog extends BasePo implements Serializable { ...@@ -302,9 +302,9 @@ public class DataLog extends BasePo implements Serializable {
*/ */
public boolean needRemoveFromCache(){ public boolean needRemoveFromCache(){
if(isFinished() || isCancel()){ if(isFinished() || isCancel()){
//if(System.currentTimeMillis() - super.getUpdateDate().getTime() > 5 * 60 * 1000){ if(System.currentTimeMillis() - super.getUpdateDate().getTime() > 5 * 60 * 1000){
return true; return true;
//} }
} }
return false; return false;
} }
......
...@@ -392,6 +392,11 @@ public class AdvantechApi extends BaseSmfApiListener { ...@@ -392,6 +392,11 @@ public class AdvantechApi extends BaseSmfApiListener {
} }
@Override @Override
public Barcode barcodeInfo(String barcodeInfoUrl, Barcode barcode) {
return null;
}
@Override
public boolean isForThisApi(String apiName) { public boolean isForThisApi(String apiName) {
return apiName != null && apiName.equalsIgnoreCase("Advantech"); return apiName != null && apiName.equalsIgnoreCase("Advantech");
} }
......
...@@ -26,6 +26,11 @@ public class HellaApiHandler extends BaseSmfApiListener { ...@@ -26,6 +26,11 @@ public class HellaApiHandler extends BaseSmfApiListener {
} }
@Override @Override
public Barcode barcodeInfo(String barcodeInfoUrl, Barcode barcode) {
return null;
}
@Override
public boolean isForThisApi(String apiName) { public boolean isForThisApi(String apiName) {
return apiName != null && apiName.equalsIgnoreCase("Hella"); return apiName != null && apiName.equalsIgnoreCase("Hella");
} }
......
...@@ -577,6 +577,11 @@ public class HellaServiceHandler extends BaseSmfApiListener implements IoHandler ...@@ -577,6 +577,11 @@ public class HellaServiceHandler extends BaseSmfApiListener implements IoHandler
} }
} }
@Override
public Barcode barcodeInfo(String barcodeInfoUrl, Barcode barcode) {
return null;
}
@Override @Override
public void exceptionCaught(IoSession session, Throwable cause) throws Exception { public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
......
package com.neotel.smfcore.custom.lizhen; package com.neotel.smfcore.custom.lizhen;
import com.alibaba.fastjson.JSONObject;
import com.neotel.smfcore.common.exception.ApiException; import com.neotel.smfcore.common.exception.ApiException;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.HttpHelper; import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.common.utils.JsonUtil; import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.listener.BaseSmfApiListener; import com.neotel.smfcore.core.api.listener.BaseSmfApiListener;
import com.neotel.smfcore.core.api.listener.DefaultSmfApiListener;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.order.LiteOrderCache; import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.po.LiteOrder; import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.system.service.po.DataLog; import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.custom.lizhen.innerBox.bean.PreWarningItem;
import com.neotel.smfcore.custom.lizhen.innerBox.util.PreWarningItemCache;
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.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
@Slf4j @Slf4j
public class LizhenApi extends BaseSmfApiListener { @Service
public class LizhenApi extends DefaultSmfApiListener {
@Autowired @Autowired
private LiteOrderCache liteOrderCache; private LiteOrderCache liteOrderCache;
@Value("${api.fetchGRUrl}")
private String fetchGRUrl;
//7.获取MES物料数量 @Value("${api.plant}")
public Barcode getReelNum(String reelNumUrl,String reelId){ private String plant;
log.info("获取MES物料数量入参为:" + reelId);
/**
* 获取gr标签的料卷数
* @param barcode
* @return
*/
public int fetchGR(Barcode barcode) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("plant", plant);
paramMap.put("gr_code", barcode.getBarcode());
paramMap.put("gr_item", barcode.getMemo());
paramMap.put("partNumber", barcode.getPartNumber());
log.info("gr标签入参为:" + JsonUtil.toJsonStr(paramMap));
try {
String result = HttpHelper.postJson(fetchGRUrl, paramMap);
log.info("gr标签出参为:" + result);
} catch (ApiException e) {
e.printStackTrace();
}
return 0;
}
@Override
public Barcode barcodeInfo(String barcodeInfoUrl, Barcode barcode) {
log.info("获取MES物料数量入参为:" + barcode.getBarcode());
try { try {
String result = HttpHelper.postJson(reelNumUrl, reelId); String result = HttpHelper.postJson(barcodeInfoUrl, barcode.getBarcode());
log.info("获取MES物料数量出参为:" + result); log.info("获取MES物料数量出参为:" + result);
Map<String, Object> resultMap = JsonUtil.toMap(result); JSONObject resultJson = JsonUtil.toObj(result, JSONObject.class);
Object status = resultMap.get("status"); Integer status = resultJson.getInteger("status");
if (status != null){ if (status != null) {
if (status.equals(200)){ if (status == 200) {
Map<String, Object> dataMap = JsonUtil.toMap(resultMap.get("data").toString()); JSONObject dataJson = resultJson.getJSONObject("data");
String reelID = dataMap.get("reelID") == null ? "" : dataMap.get("reelID").toString(); String reelID = dataJson.get("reelID") == null ? "" : dataJson.get("reelID").toString();
String partNum = dataMap.get("partNum") == null ? "" : dataMap.get("partNum").toString(); String partNum = dataJson.get("partNum") == null ? "" : dataJson.get("partNum").toString();
String partSpec = dataMap.get("partSpec") == null ? "" : dataMap.get("partSpec").toString(); String partSpec = dataJson.get("partSpec") == null ? "" : dataJson.get("partSpec").toString();
int qty = dataMap.get("qty") == null ? 0 : Integer.valueOf(dataMap.get("qty").toString()); int qty = dataJson.get("qty") == null ? 0 : Integer.valueOf(dataJson.get("qty").toString());
String vendor = dataMap.get("vendor") == null ? "" : dataMap.get("vendor").toString(); String vendor = dataJson.get("vendor") == null ? "" : dataJson.get("vendor").toString();
String vendorNum = dataMap.get("vendorNum") == null ? "" : dataMap.get("vendorNum").toString(); String vendorNum = dataJson.get("vendorNum") == null ? "" : dataJson.get("vendorNum").toString();
String dataCode = dataMap.get("dataCode") == null ? "" : dataMap.get("dataCode").toString(); String dataCode = dataJson.get("dataCode") == null ? "" : dataJson.get("dataCode").toString();
String lotCode = dataMap.get("lotCode") == null ? "" : dataMap.get("lotCode").toString(); String lotCode = dataJson.get("lotCode") == null ? "" : dataJson.get("lotCode").toString();
Barcode barcode = new Barcode(); if (StringUtils.isBlank(reelID)){
return null;
}
barcode.setBarcode(reelID); barcode.setBarcode(reelID);
barcode.setPartNumber(partNum); barcode.setPartNumber(partNum);
barcode.setAmount(qty); barcode.setAmount(qty);
...@@ -57,68 +96,169 @@ public class LizhenApi extends BaseSmfApiListener { ...@@ -57,68 +96,169 @@ public class LizhenApi extends BaseSmfApiListener {
return null; return null;
} }
/**
* 入库验证
* @param inCheckUrl
* @param barcode
* @return
* @throws ValidateException
*/
@Override
public Barcode canPutIn(String inCheckUrl, Barcode barcode) throws ValidateException {
String resultStr = "false";
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("ipn", barcode.getPartNumber());
paramMap.put("reelId", barcode.getBarcode());
paramMap.put("wo", "");
paramMap.put("datecode", barcode.getDateCode());
paramMap.put("lot", barcode.getBatch());
paramMap.put("vendor", barcode.getProvider());
String param = JsonUtil.toJsonStr(paramMap);
log.info("禁用料接口wmsCheckReelfob入参为:" + param);
try {
String result = HttpHelper.postJson(inCheckUrl, paramMap);
log.info(barcode.getBarcode() + "禁用料接口wmsCheckReelfob出参为:" + result);
JSONObject resultJson = JsonUtil.toObj(result,JSONObject.class);
if (resultJson != null) {
if (resultJson.getString("data") != null) {
JSONObject dataJson = resultJson.getJSONObject("data");
if (dataJson.get("result") != null && dataJson.getBoolean("result") == true) {
resultStr = "";
} else {
resultStr = dataJson.get("message").toString();
}
}
}
//log.info("禁用料接口wmsCheckReelfob出参为:" + result);
} catch (ApiException e) {
e.printStackTrace();
}
if (StringUtils.isNotBlank(resultStr)) {
throw new ValidateException("smfcore.mesApi.inCheck.ng", "MES验证失败:" + barcode.getBarcode() + "验证失败:"+resultStr);
}
return barcode;
}
//3.IMES提供接收发料明细接口
public void saveReelInfo(String outNotifyUrl, DataLog task){
Map<String,Object> paramMap = new HashMap<>();
Map<String,Object> dataMap = new HashMap<>(); /**
* 保存物料接口
* @param inNotifyUrl
* @param task
*/
@Override
public void inTaskStatusChange(String inNotifyUrl, DataLog task) {
Map<String, Object> paramMap = new HashMap<>();
Map<String, Object> dataMap = new HashMap<>();
String sourceId = task.getSourceId(); String sourceId = task.getSourceId();
dataMap.put("pickingid", "");
LiteOrder liteOrder = liteOrderCache.getOrderSortItems(sourceId); LiteOrder liteOrder = liteOrderCache.getOrderSortItems(sourceId);
if (liteOrder != null){ if (liteOrder != null) {
dataMap.put("pickingid",liteOrder.getOrderNo()); dataMap.put("pickingid", liteOrder.getOrderNo());
} }
dataMap.put("wo",""); //dataMap.put("pickingid", "20220214162216");
dataMap.put("reelno",task.getBarcode()); dataMap.put("wo", "");
dataMap.put("ipn",task.getPartNumber()); dataMap.put("reelno", task.getBarcode());
dataMap.put("qty",task.getNum()); dataMap.put("ipn", task.getPartNumber());
dataMap.put("datecode",new SimpleDateFormat("yyyyMMdd").format(new Date()));
dataMap.put("lot",task.getPosName());
dataMap.put("vendor",task.getPosName());
dataMap.put("batch",task.getBatchId());
Barcode barcode = barcodeManager.findByBarcode(task.getBarcode());
if (barcode != null) {
dataMap.put("qty", barcode.getAmount());
dataMap.put("datecode", barcode.getDateCode());
dataMap.put("lot", barcode.getBatch());
dataMap.put("vendor", barcode.getProvider());
dataMap.put("batch", "");
}
paramMap.put("data", Arrays.asList(dataMap)); paramMap.put("data", Arrays.asList(dataMap));
String param = JsonUtil.toJsonStr(paramMap); String param = JsonUtil.toJsonStr(paramMap);
log.info("IMES提供接收发料明细接口入参为:" + param); log.info("IMES提供接收发料明细接口入参为:" + param);
try { try {
String result = HttpHelper.postJson(outNotifyUrl, paramMap); String result = HttpHelper.postJson(inNotifyUrl, paramMap);
log.info("IMES提供接收发料明细接口出参为:" + result); log.info("IMES提供接收发料明细接口出参为:" + result);
} catch (ApiException e) { } catch (ApiException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
/**
//2.禁用料接口MES提供外围系统调用 * 保存物料接口
public static String wmsCheckReelfob(String checkReelfobUrl, Barcode barcode) { * @param outNotifyUrl
String resultStr = "false"; * @param task
*/
@Override
public void outTaskStatusChange(String outNotifyUrl, DataLog task) {
Map<String, Object> paramMap = new HashMap<>(); Map<String, Object> paramMap = new HashMap<>();
paramMap.put("ipn", barcode.getPartNumber());
paramMap.put("reelId", barcode.getBarcode()); Map<String, Object> dataMap = new HashMap<>();
paramMap.put("wo", ""); String sourceId = task.getSourceId();
paramMap.put("datecode", barcode.getDateCode()); dataMap.put("pickingid", "");
paramMap.put("lot", barcode.getPosName()); LiteOrder liteOrder = liteOrderCache.getOrderSortItems(sourceId);
paramMap.put("vendor", barcode.getProviderNumber()); if (liteOrder != null) {
dataMap.put("pickingid", liteOrder.getSo());
}
dataMap.put("wo", "");
dataMap.put("reelno", task.getBarcode());
dataMap.put("ipn", task.getPartNumber());
Barcode barcode = barcodeManager.findByBarcode(task.getBarcode());
if (barcode != null) {
dataMap.put("qty", barcode.getAmount());
dataMap.put("datecode", barcode.getDateCode());
dataMap.put("lot", barcode.getBatch());
dataMap.put("vendor", barcode.getProvider());
dataMap.put("batch", "");
}
paramMap.put("data", Arrays.asList(dataMap));
String param = JsonUtil.toJsonStr(paramMap); String param = JsonUtil.toJsonStr(paramMap);
log.info("禁用料接口wmsCheckReelfob入参为:" + param); log.info("IMES提供接收发料明细接口入参为:" + param);
try { try {
String result = HttpHelper.postJson(checkReelfobUrl, paramMap); String result = HttpHelper.postJson(outNotifyUrl, paramMap);
Map<String, Object> resultMap = JsonUtil.toMap(result); log.info("IMES提供接收发料明细接口出参为:" + result);
if (resultMap != null) { } catch (ApiException e) {
e.printStackTrace();
}
}
/**
* 获取到需求单数据
* @param fetchOrderUrl
* @param orderNumber
* @param username
* @return
*/
@Override
public LiteOrder fetchOrder(String fetchOrderUrl, String orderNumber, String username) {
log.info("收到需求单号--" + orderNumber);
String result = HttpHelper.sendGet(fetchOrderUrl + "workorder=" + orderNumber);
log.info(orderNumber + "返回数据为--" + result);
if (StringUtils.isNotBlank(result)) {
List<PreWarningItem> items = new ArrayList<>();
Map resultMap = JsonUtil.toObj(result, Map.class);
if (resultMap.get("data") != null) { if (resultMap.get("data") != null) {
Map<String, Object> dataMap = JsonUtil.toMap(resultMap.get("data").toString()); List<Map> datas = JsonUtil.toList(resultMap.get("data").toString(), Map.class);
if (dataMap.get("result") != null && dataMap.get("result").equals(true)) { for (Map data : datas) {
resultStr = ""; String line = data.get("LINE").toString();
} else { String face = data.get("FACE").toString();
resultStr = dataMap.get("message").toString(); String machine = data.get("MACHINE").toString();
String slot = data.get("SLOT").toString();
String module = data.get("MODULE").toString();
String partNumber = data.get("ITEM_PART_NUMBER").toString();
PreWarningItem item = new PreWarningItem();
item.setLine(line);
item.setPartnumber(partNumber);
item.setSubslot("");
item.setSlot(slot);
item.setSide(face);
item.setMachinename(machine);
item.setStation(module);
items.add(item);
} }
} }
if (items != null && !items.isEmpty()) {
return PreWarningItemCache.createAndExecuteLiteOrder(items);
} }
log.info("禁用料接口wmsCheckReelfob出参为:" + result);
} catch (ApiException e) {
e.printStackTrace();
} }
return resultStr; return null;
} }
@Override @Override
......
...@@ -3,25 +3,30 @@ package com.neotel.smfcore.custom.lizhen; ...@@ -3,25 +3,30 @@ package com.neotel.smfcore.custom.lizhen;
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.common.utils.StringUtils; import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.order.LiteOrderCache; import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderManager; import com.neotel.smfcore.core.order.service.manager.ILiteOrderManager;
import com.neotel.smfcore.core.order.service.po.LiteOrder; import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.order.service.po.LiteOrderItem; import com.neotel.smfcore.core.order.service.po.LiteOrderItem;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.custom.lizhen.innerBox.bean.PreWarningItem; import com.neotel.smfcore.custom.lizhen.innerBox.bean.PreWarningItem;
import com.neotel.smfcore.custom.lizhen.innerBox.util.PreWarningItemCache; import com.neotel.smfcore.custom.lizhen.innerBox.util.PreWarningItemCache;
import com.neotel.smfcore.custom.lizhen.innerBox.util.service.PreWarningItemManager;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
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.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
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;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@Slf4j @Slf4j
@RestController @RestController
...@@ -34,78 +39,78 @@ public class LizhenController { ...@@ -34,78 +39,78 @@ public class LizhenController {
@Autowired @Autowired
private LiteOrderCache liteOrderCache; private LiteOrderCache liteOrderCache;
//1.发料明细 @Autowired
private IStoragePosManager storagePosManager;
@Autowired
private PreWarningItemManager preWarningItemManager;
/**
* 发料明细
*
* @param params
* @return
*/
@PostMapping("/EPickingList") @PostMapping("/EPickingList")
@AnonymousAccess
public ResultBean EPickingList(@RequestBody List<Map<String, Object>> params) { public ResultBean EPickingList(@RequestBody List<Map<String, Object>> params) {
if (params == null || params.isEmpty()) { log.info("发料明细数据--" + JsonUtil.toJsonStr(params));
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "参数不能为空");
}
for (Map<String, Object> param : params) { for (Map<String, Object> param : params) {
String pickingId = param.get("picking_id") == null ? "" : param.get("picking_id").toString(); //工单号 //任务单号
if (StringUtils.isBlank(pickingId)) { String orderNo = param.get("picking_id") == null ? "" : param.get("picking_id").toString();
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{}不能为空", new String[]{"picking_id"}); if (StringUtils.isBlank(orderNo)) {
} return ResultBean.newErrorResult(-1, "", "picking_id不能为空");
String plantCode = param.get("plant_code") == null ? "" : param.get("plant_code").toString(); //需求单号
if (StringUtils.isBlank(plantCode)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{}不能为空", new String[]{"plant_code"});
} }
String line = param.get("line") == null ? "" : param.get("line").toString(); //线别 //线别
String line = param.get("line") == null ? "" : param.get("line").toString();
if (StringUtils.isBlank(line)) { if (StringUtils.isBlank(line)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{}不能为空", new String[]{"line"}); return ResultBean.newErrorResult(-1, "", "line不能为空");
} }
//设置工单信息
LiteOrder liteOrder = new LiteOrder(); LiteOrder liteOrder = new LiteOrder();
liteOrder.setOrderNo(pickingId); liteOrder.setOrderNo(preWarningItemManager.getNextId("L" + PreWarningItemCache.class.getName()));
liteOrder.setSo(orderNo);
liteOrder.setLine(line); liteOrder.setLine(line);
//开始处理工单详情信息 liteOrder.setType(2);
List<LiteOrderItem> liteOrderItems = new ArrayList<>();
String item = param.get("ITEM") == null ? "" : param.get("ITEM").toString(); //liteOrderItem
if (StringUtils.isBlank(item)) { List<LiteOrderItem> orderItems = new ArrayList<>();
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{}不能为空", new String[]{"item"}); String itemStr = param.get("ITEM") == null ? "" : param.get("ITEM").toString();
} if (StringUtils.isBlank(itemStr)) {
List<Map> itemMaps = JsonUtil.toList(item, Map.class); return ResultBean.newErrorResult(-1, "", "ITEM不能为空");
for (Map itemMap : itemMaps) { }
String face = itemMap.get("face") == null ? "" : itemMap.get("face").toString(); //面别 List<Map> items = JsonUtil.toList(itemStr, Map.class);
if (StringUtils.isBlank(face)) { for (Map item : items) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{}不能为空", new String[]{"face"}); String face = item.get("face") == null ? "" : item.get("face").toString();
} String mo = item.get("mo") == null ? "" : item.get("mo").toString();
String mo = itemMap.get("mo") == null ? "" : itemMap.get("mo").toString(); String materialCode = item.get("material_code") == null ? "" : item.get("material_code").toString();
if (StringUtils.isBlank(mo)) { String brand = item.get("brand") == null ? "" : item.get("brand").toString();
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{}不能为空", new String[]{"mo"}); String batchCode = item.get("batch_code") == null ? "" : item.get("batch_code").toString();
} int reqQty = item.get("req_qty") == null ? 0 : Integer.valueOf(item.get("req_qty").toString());
String materialCode = itemMap.get("material_code") == null ? "" : itemMap.get("material_code").toString(); //物料编号 int reqReel = item.get("req_reel") == null ? 0 : Integer.valueOf(item.get("req_reel").toString());
if (StringUtils.isBlank(materialCode)) { String warehouse = item.get("warehouse") == null ? "" : item.get("warehouse").toString();
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{}不能为空", new String[]{"material_code"});
} List<Barcode> barcodes = getBarcodesBypn(materialCode, reqQty);
String brand = itemMap.get("brand") == null ? "" : itemMap.get("brand").toString(); //品牌 if (barcodes != null && !barcodes.isEmpty()){
String batchCode = itemMap.get("batch_code") == null ? "" : itemMap.get("batch_code").toString(); //批次号 for (Barcode barcode : barcodes) {
Integer reqQty = itemMap.get("req_qty") == null ? null : Integer.valueOf(itemMap.get("req_qty").toString()); //数量 LiteOrderItem orderItem = new LiteOrderItem();
Integer reqReel = itemMap.get("req_reel") == null ? null : Integer.valueOf(itemMap.get("req_reel").toString()); //盘数 orderItem.setSide(face);
String warehouse = itemMap.get("warehouse") == null ? "" : itemMap.get("material_code").toString(); //位置 orderItem.setPn(materialCode);
if (StringUtils.isBlank(warehouse)) { orderItem.setRi(barcode.getBarcode());
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{}不能为空", new String[]{"material_code"}); orderItem.setNeedNum(barcode.getAmount());
} orderItem.setPosName(barcode.getPosName());
//工单详情进行赋值操作 orderItems.add(orderItem);
LiteOrderItem liteOrderItem = new LiteOrderItem(); }
liteOrderItem.setPn(materialCode); }
liteOrderItem.setSide(face); }
liteOrderItem.setNeedNum(reqQty); if (orderItems != null && !orderItems.isEmpty()) {
liteOrderItem.setNeedReelCount(reqReel); liteOrder.setTaskReelCount(orderItems.size());
liteOrderItem.setFeederInfo(warehouse); liteOrder.setTotalTaskReelCount(orderItems.size());
if (itemMap.get("SLOT") != null){ liteOrder.setOrderItems(orderItems);
String slot = JsonUtil.toJsonStr(itemMap.get("SLOT"));
List<Map> slotMaps = JsonUtil.toList(slot, Map.class);
for (Map slotMap : slotMaps) {
String machine = slotMap.get("machine") == null ? null : slotMap.get("machine").toString();//机器编号
String zone = slotMap.get("zone") == null ? null : slotMap.get("zone").toString();//区域
}
}
liteOrderItems.add(liteOrderItem);
}
liteOrder.setOrderItems(liteOrderItems);
liteOrder = liteOrderManager.createWithItems(liteOrder); liteOrder = liteOrderManager.createWithItems(liteOrder);
log.info("新增加订单:" + liteOrder.getOrderNo() + "[" + liteOrder.getId() + "],共" + orderItems.size() + "条工单详情");
liteOrderCache.addOrderToMap(liteOrder); liteOrderCache.addOrderToMap(liteOrder);
} }
}
return ResultBean.newOkResult(""); return ResultBean.newOkResult("");
} }
...@@ -113,21 +118,20 @@ public class LizhenController { ...@@ -113,21 +118,20 @@ public class LizhenController {
@ApiOperation("5.缺料预警") @ApiOperation("5.缺料预警")
@PostMapping("/mPickingList") @PostMapping("/mPickingList")
@AnonymousAccess @AnonymousAccess
public ResultBean mPickingList(@RequestBody Map<String, List<Map<String, String>>> paramMap) { public ResultBean mPickingList(@RequestBody List<Map<String, String>> params) {
List<Map<String, String>> datas = paramMap.get("data"); if (params == null || params.isEmpty()) {
if (datas == null || datas.isEmpty()) { return ResultBean.newErrorResult(-1, "", "数据不能为空");
return ResultBean.newErrorResult(-1, "", "data不能为空");
} }
List<PreWarningItem> items = new ArrayList<>(); List<PreWarningItem> items = new ArrayList<>();
for (Map<String, String> data : datas) { for (Map<String, String> data : params) {
PreWarningItem item = new PreWarningItem(); PreWarningItem item = new PreWarningItem();
item.setMachinename(data.get("machinename")); item.setMachinename(data.get("MACHINENAME"));
item.setStation(data.get("station")); item.setStation(data.get("STATION"));
item.setSide(data.get("side")); item.setSide(data.get("SIDE"));
item.setSlot(data.get("slot")); item.setSlot(data.get("SLOT"));
item.setSubslot(data.get("subslot")); item.setSubslot(data.get("SUBSLOT"));
item.setPartnumber(data.get("partnumber")); item.setPartnumber(data.get("PARTNUMBER"));
item.setLine(data.get("line")); item.setLine(data.get("LINE"));
items.add(item); items.add(item);
} }
if (items != null && !items.isEmpty()) { if (items != null && !items.isEmpty()) {
...@@ -137,4 +141,34 @@ public class LizhenController { ...@@ -137,4 +141,34 @@ public class LizhenController {
} }
private List<Barcode> getBarcodesBypn(String partNumber, int reqQty) {
Query q = new Query();
Criteria c = Criteria.where("barcode.subCodeList.partNumber").is(partNumber); //料箱中parnumber的物料
c.and("barcode").exists(true).and("enabled").is(true);
Collection<String> barcodeIds = liteOrderCache.excludeBarcodeIds();
Sort sort = Sort.by(Sort.Direction.ASC, "canCheckOutTime", "barcode.usedCount");
List<StoragePos> storagePoss = storagePosManager.findByQuery(q.addCriteria(c).with(sort));
List<Barcode> barcodes = new ArrayList<>();
int amount = 0;
if (storagePoss != null && !storagePoss.isEmpty()) {
for (StoragePos pos : storagePoss) {
List<Barcode> subCodeList = pos.getBarcode().getSubCodeList();
for (Barcode barcode : subCodeList) {
if (barcode.getPartNumber().equals(partNumber)) {
if (barcodeIds != null && !barcodeIds.isEmpty()){
if (barcodeIds.contains(barcode.getBarcode())){
continue;
}
}
barcodes.add(barcode);
amount = amount + barcode.getAmount();
if (amount >= reqQty) {
break;
}
}
}
}
}
return barcodes;
}
} }
...@@ -8,6 +8,7 @@ import com.neotel.smfcore.common.utils.JsonUtil; ...@@ -8,6 +8,7 @@ import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.common.utils.ReelLockPosUtil; import com.neotel.smfcore.common.utils.ReelLockPosUtil;
import com.neotel.smfcore.common.utils.SecurityUtils; import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils; import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.barcode.bean.CodeBean; import com.neotel.smfcore.core.barcode.bean.CodeBean;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager; import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
...@@ -15,6 +16,11 @@ import com.neotel.smfcore.core.barcode.utils.CodeResolve; ...@@ -15,6 +16,11 @@ import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.enums.OP; import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS; import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderItemManager;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderManager;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.order.service.po.LiteOrderItem;
import com.neotel.smfcore.core.storage.enums.DeviceType; import com.neotel.smfcore.core.storage.enums.DeviceType;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager; 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.Storage;
...@@ -22,9 +28,11 @@ import com.neotel.smfcore.core.storage.service.po.StoragePos; ...@@ -22,9 +28,11 @@ import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager; import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
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.lizhen.LizhenApi;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.Station; import com.neotel.smfcore.custom.lizhen.agvBox.bean.Station;
import com.neotel.smfcore.custom.lizhen.agvBox.util.StationCacheUtil; import com.neotel.smfcore.custom.lizhen.agvBox.util.StationCacheUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import com.sun.org.apache.regexp.internal.RE;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings; import org.apache.logging.log4j.util.Strings;
...@@ -37,6 +45,9 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -37,6 +45,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -51,7 +62,6 @@ public class WarehouseController { ...@@ -51,7 +62,6 @@ public class WarehouseController {
@Autowired @Autowired
private IBarcodeManager barcodeManager; private IBarcodeManager barcodeManager;
@Autowired @Autowired
private CodeResolve codeResolve; private CodeResolve codeResolve;
...@@ -67,6 +77,25 @@ public class WarehouseController { ...@@ -67,6 +77,25 @@ public class WarehouseController {
@Autowired @Autowired
private DataCache dataCache; private DataCache dataCache;
@Autowired
private LizhenApi lizhenApi;
@Autowired
private SmfApi smfApi;
@Autowired
private LiteOrderCache liteOrderCache;
@Autowired
private ILiteOrderManager liteOrderManager;
@Autowired
private ILiteOrderItemManager liteOrderItemManager;
private static Map<String,Map<String,Integer>> boxALlCountMap = new ConcurrentHashMap<>();
private static Map<String,Integer> boxCount = new ConcurrentHashMap<>();
@ApiOperation("选择物料") @ApiOperation("选择物料")
@RequestMapping("/chooseReel") @RequestMapping("/chooseReel")
...@@ -80,6 +109,13 @@ public class WarehouseController { ...@@ -80,6 +109,13 @@ public class WarehouseController {
return ResultBean.newErrorResult(-1, "", "请核实尺寸,数量,工位名称是否为空", new String[]{}); return ResultBean.newErrorResult(-1, "", "请核实尺寸,数量,工位名称是否为空", new String[]{});
} }
String grLabel = paramMap.get("grLabel"); //GR标签 String grLabel = paramMap.get("grLabel"); //GR标签
if (StringUtils.isNotBlank(grLabel)) {
CodeBean codeBean = codeResolve.resolveSingleCode(grLabel);
if (codeBean.isValid()) {
int grNum = lizhenApi.fetchGR(codeBean.getBarcode());
}
}
int platsize = getPlatsizeOrHeight(size, 0); int platsize = getPlatsizeOrHeight(size, 0);
int height = getPlatsizeOrHeight(size, 1); int height = getPlatsizeOrHeight(size, 1);
...@@ -94,6 +130,7 @@ public class WarehouseController { ...@@ -94,6 +130,7 @@ public class WarehouseController {
station.setReelNum(Integer.valueOf(num)); station.setReelNum(Integer.valueOf(num));
station.setReelCurrentNum(0); station.setReelCurrentNum(0);
station.setLastScanBoxCode(null); station.setLastScanBoxCode(null);
station.setBoxCurrentNum(0);
StationCacheUtil.updateStation(station); StationCacheUtil.updateStation(station);
return ResultBean.newOkResult(""); return ResultBean.newOkResult("");
} }
...@@ -109,57 +146,13 @@ public class WarehouseController { ...@@ -109,57 +146,13 @@ public class WarehouseController {
return ResultBean.newErrorResult(-1, "", "尺寸不能为空", new String[]{}); return ResultBean.newErrorResult(-1, "", "尺寸不能为空", new String[]{});
} }
StoragePos pos = getEmptyBoxPos(platsize); StoragePos pos = getEmptyBoxPos(platsize);
if (pos == null){ if (pos == null) {
return ResultBean.newErrorResult(-1,"","未找到可用料箱",new String[]{}); return ResultBean.newErrorResult(-1, "", "未找到可用料箱", new String[]{});
} }
generateTask(dataCache.getStorageById(pos.getStorageId()),pos.getBarcode(),pos,OP.CHECKOUT,OP_STATUS.WAIT.name(), name); generateTask(dataCache.getStorageById(pos.getStorageId()), pos.getBarcode(), pos, OP.CHECKOUT, OP_STATUS.WAIT.name(), name);
return ResultBean.newOkResult(""); return ResultBean.newOkResult("");
} }
private StoragePos getEmptyBoxPos(String platsize) {
//得到料盒类型
String boxCode = "";
if ("7".equals(platsize)) {
boxCode = "CS";
} else if ("13".equals(platsize)) {
boxCode = "CM";
} else if ("15".equals(platsize)) {
boxCode = "CB";
}
//料仓类型是agv的
String storageId = "";
Collection<Storage> storages = dataCache.getAllStorage().values();
for (Storage storage : storages) {
if (storage.isType(new DeviceType[]{DeviceType.AGV_BOX})) {
storageId = storage.getId();
}
}
Criteria c = Criteria.where("barcode").exists(true)
.and("enabled").is(true);//可用
//排除掉正在执行的仓位
Collection<String> excludePosIds = taskService.excludePosIds();
log.info("excludePosIds--"+JsonUtil.toJsonStr(excludePosIds));
if (excludePosIds != null && !excludePosIds.isEmpty()) {
c.and("id").nin(excludePosIds);
}
if (StringUtils.isNotBlank(storageId)) {
c.and("storageId").is(storageId);
}
if (StringUtils.isNotBlank(boxCode)) {
Pattern pattern = Pattern.compile("^.*" + boxCode + ".*$", Pattern.CASE_INSENSITIVE);
c.and("barcode.barcode").regex(pattern);
}
Query q = new Query(c).with(Sort.by(Sort.Direction.ASC, "barcode.amount")).limit(1);
List<StoragePos> storagePoss = storagePosManager.findByQuery(q);
if (storagePoss != null && !storagePoss.isEmpty()) {
return storagePoss.get(0);
}
return null;
}
@ApiOperation("获取工位详情") @ApiOperation("获取工位详情")
@RequestMapping("/getStation") @RequestMapping("/getStation")
...@@ -174,59 +167,95 @@ public class WarehouseController { ...@@ -174,59 +167,95 @@ public class WarehouseController {
} }
@ApiOperation("操作料盒内的物料信息") @ApiOperation("扫码入库")
@RequestMapping(value = "/operatePos") @RequestMapping(value = "/operatePos")
@AnonymousAccess @AnonymousAccess
//先扫条码 再扫料箱 //先扫条码 再扫料箱
public ResultBean operatePos(@RequestBody Map<String, String> paramMap) { public ResultBean operatePos(@RequestBody Map<String, String> paramMap) {
String code = paramMap.get("code"); //条码
String name = paramMap.get("name"); //工位名称 String name = paramMap.get("name"); //工位名称
log.info("收到物料信息,条码为:{},工位为:{}", code, name); String code = paramMap.get("code"); //条码
Station station = StationCacheUtil.getStation(name);
if (station == null) {
return ResultBean.newErrorResult(-1, "", name + "工位不存在", new String[]{});
}
//条码信息
String barcodeStr = ""; String barcodeStr = "";
if (code.startsWith("C") && code.indexOf("-") != -1) { if (code.startsWith("C") && code.indexOf("-") != -1) {
station.setLastScanBoxCode(code); //设置扫描的隔口信息
barcodeStr = code.substring(0, code.indexOf("-")); barcodeStr = code.substring(0, code.indexOf("-"));
} else { } else {
barcodeStr = code; barcodeStr = code;
} }
Station station = StationCacheUtil.getStation(name); log.info("收到物料信息,条码为:{},工位为:{}", code, name);
String currentRfid = station.getCurrentRfid();
if (station == null) { String currentRfid = station.getCurrentRfid(); //当前料箱的信息
return ResultBean.newErrorResult(-1, "", name + "工位不存在", new String[]{}); if (StringUtils.isBlank(currentRfid)) {
return ResultBean.newErrorResult(-1, "", "料箱不存在", new String[]{});
} }
//先判断是否料盒 //先判断是否料盒
String newCodeStr = "=" + station.getPlatsize() + "x" + station.getHeight() + "=" + barcodeStr; String newCodeStr = "=" + station.getPlatsize() + "x" + station.getHeight() + "=" + barcodeStr;
CodeBean codeBean = codeResolve.resolveSingleCode(newCodeStr); CodeBean codeBean = codeResolve.resolveSingleCode(newCodeStr);
if (!codeBean.isValid()) { if (!codeBean.isValid()) {
return ResultBean.newErrorResult(-1, "", code + "解析条码失败", new String[]{}); return ResultBean.newErrorResult(-1, "", code + "解析条码失败", new String[]{});
} }
if (codeBean.isValid()) {
Barcode barcode = codeBean.getBarcode(); Barcode barcode = codeBean.getBarcode();
String partNumber = barcode.getPartNumber(); String partNumber = barcode.getPartNumber();
//如果是箱子的话 则取下边的 //如果是箱子的话 则取下边的
if (partNumber.equals("CS") || partNumber.equals("CM") || partNumber.equals("CB") || partNumber.equals("CN")) { if (partNumber.equals("CS") || partNumber.equals("CM") || partNumber.equals("CB")) {
if (StringUtils.isBlank(currentRfid)) { if (!currentRfid.startsWith(barcode.getBarcode())) {
return ResultBean.newErrorResult(-1, "", "RFID不存在", new String[]{}); return ResultBean.newErrorResult(-1, "", "料箱" + currentRfid + "与料箱隔口码" + barcode.getBarcode() + "不一致", new String[]{});
} else if (!currentRfid.startsWith(barcode.getBarcode())) { }
return ResultBean.newErrorResult(-1, "", "RFID" + currentRfid + "与" + barcode.getBarcode() + "不一致", new String[]{}); //判断当前是否有正在执行的任务
DataLog dataLog = getExecuteTask(barcode.getBarcode());
if (dataLog != null) {
if (dataLog.isPutInTask()) {
//已有入库任务
return ResultBean.newErrorResult(-1, "", "物料[" + dataLog.getBarcode() + "]已有入库任务,需继续执行入库动作", new String[]{});
} else if (dataLog.isCheckOutTask()) {
//已有出库任务
return ResultBean.newErrorResult(-1, "", "物料[" + dataLog.getBarcode() + "]已有出库任务,需继续执行出库动作", new String[]{});
}
}
//判断料箱是否在库位中
StoragePos pos = storagePosManager.getByBarcode(barcode.getBarcode());
if (pos != null) {
return ResultBean.newErrorResult(-1, "", "料箱" + barcode.getBarcode() + "已存在库位" + pos.getPosName());
} }
station.setLastScanBoxCode(code);
StationCacheUtil.updateStation(station);
barcodeManager.save(barcode); barcodeManager.save(barcode);
} else { } else {
String lastScanBoxCode = station.getLastScanBoxCode(); String lastScanBoxCode = station.getLastScanBoxCode();
//再加个rfid判断
if (Strings.isBlank(lastScanBoxCode)) { if (Strings.isBlank(lastScanBoxCode)) {
//提示要先扫料箱 //提示要先扫料箱
return ResultBean.newErrorResult(-1, "", "请先扫描料箱,再扫描条码"); return ResultBean.newErrorResult(-1, "", "请先扫描料箱,再扫描条码");
} }
StationCacheUtil.saveReelToBoxCode(station);
Barcode barcodeApi = smfApi.barcodeInfo(barcode);
if (barcodeApi != null) {
barcode = barcodeApi;
}
//判断是否已经在其他料箱中
Query q = new Query();
q.addCriteria(Criteria.where("subCodeList.barcode").is(barcode.getBarcode()));
List<Barcode> barcodes = barcodeManager.findByQuery(q);
if (barcodes != null && !barcodes.isEmpty()) {
return ResultBean.newErrorResult(-1, "", "物料" + barcode.getBarcode() + "已存在料箱:" + barcodes.get(0).getBarcode());
}
int reelCurrentNum = station.getReelCurrentNum();
station.setReelCurrentNum(reelCurrentNum + 1);
String boxBarcode = lastScanBoxCode.substring(0, lastScanBoxCode.indexOf("-")); //获取到料箱条码 String boxBarcode = lastScanBoxCode.substring(0, lastScanBoxCode.indexOf("-")); //获取到料箱条码
Barcode pidBarcode = barcodeManager.findByBarcode(boxBarcode); Barcode pidBarcode = barcodeManager.findByBarcode(boxBarcode);
barcode.setHostBarcodeId(pidBarcode.getId()); barcode.setHostBarcodeId(pidBarcode.getId());
barcode.setPosName(lastScanBoxCode); barcode.setPosName(lastScanBoxCode);
barcodeManager.save(barcode);
finishTask(pidBarcode, 1, null, barcode, 1); finishTask(pidBarcode, 1, null, barcode, 1);
} }
} StationCacheUtil.updateStation(station);
return ResultBean.newOkResult(StationCacheUtil.getStation(name)); return ResultBean.newOkResult(StationCacheUtil.getStation(name));
} }
...@@ -239,10 +268,9 @@ public class WarehouseController { ...@@ -239,10 +268,9 @@ public class WarehouseController {
String code = paramMap.get("barcode"); //料箱条码 String code = paramMap.get("barcode"); //料箱条码
String name = paramMap.get("name"); //工位名称 String name = paramMap.get("name"); //工位名称
String cids = paramMap.get("cids"); //料仓cid String cids = paramMap.get("cids"); //料仓cid
cids = "so1131"; cids = "so1131";
log.info("完成装箱并入库,条码为:{},工位为:{}",code,name); log.info("完成装箱并入库,条码为:{},工位为:{}", code, name);
//校验是否存在 //校验是否存在
code = code.replace("A", "").replace("B", ""); code = code.replace("A", "").replace("B", "");
...@@ -250,6 +278,7 @@ public class WarehouseController { ...@@ -250,6 +278,7 @@ public class WarehouseController {
if (barcode == null) { if (barcode == null) {
return ResultBean.newErrorResult(-1, "", code + "料箱不存在", null); return ResultBean.newErrorResult(-1, "", code + "料箱不存在", null);
} }
Station station = StationCacheUtil.getStation(name); Station station = StationCacheUtil.getStation(name);
if (station == null) { if (station == null) {
return ResultBean.newErrorResult(-1, "", name + "工位不存在", new String[]{}); return ResultBean.newErrorResult(-1, "", name + "工位不存在", new String[]{});
...@@ -257,9 +286,9 @@ public class WarehouseController { ...@@ -257,9 +286,9 @@ public class WarehouseController {
//校验rfid是否一致 //校验rfid是否一致
String currentRfid = station.getCurrentRfid(); String currentRfid = station.getCurrentRfid();
if (StringUtils.isBlank(currentRfid)) { if (StringUtils.isBlank(currentRfid)) {
return ResultBean.newErrorResult(-1, "", "RFID不存在", new String[]{}); return ResultBean.newErrorResult(-1, "", "料箱不存在", new String[]{});
} else if (!currentRfid.startsWith(barcode.getBarcode())) { } else if (!currentRfid.startsWith(barcode.getBarcode())) {
return ResultBean.newErrorResult(-1, "", "RFID" + currentRfid + "与" + barcode.getBarcode() + "不一致", new String[]{}); return ResultBean.newErrorResult(-1, "", "料箱" + currentRfid + "与" + barcode.getBarcode() + "不一致", new String[]{});
} }
//先找可用料仓 //先找可用料仓
...@@ -285,22 +314,20 @@ public class WarehouseController { ...@@ -285,22 +314,20 @@ public class WarehouseController {
if (storageList.isEmpty()) { if (storageList.isEmpty()) {
return ResultBean.newErrorResult(-1, "", "料仓不存在", new String[]{}); return ResultBean.newErrorResult(-1, "", "料仓不存在", new String[]{});
} }
//判断是否有出入库任务
for (DataLog dataLog : taskService.getQueueTasks()) { DataLog dataLog = getExecuteTask(barcode.getBarcode());
// if(!dataLog.isPackageReel()){ if (dataLog != null) {
//已经在任务当中,返回对应的信息
if (dataLog.getBarcode().equals(barcode.getBarcode())) {
if (dataLog.isPutInTask()) { if (dataLog.isPutInTask()) {
//已有入库任务 //已有入库任务
return ResultBean.newErrorResult(-1, "", "物料[" + dataLog.getBarcode() + "]已有入库任务,需继续执行入库动作", new String[]{}); return ResultBean.newErrorResult(-1, "", "物料[" + dataLog.getBarcode() + "]已有入库任务,需继续执行入库动作", new String[]{});
} else { } else if (dataLog.isCheckOutTask()) {
//已有出库任务 //已有出库任务
return ResultBean.newErrorResult(-1, "", "物料[" + dataLog.getBarcode() + "]已有出库任务,需继续执行出库动作", new String[]{}); return ResultBean.newErrorResult(-1, "", "物料[" + dataLog.getBarcode() + "]已有出库任务,需继续执行出库动作", new String[]{});
} }
} }
}
//开始寻找空箱 //开始寻找空箱
StoragePos pos = taskService.findEmptyPosForPutIn(storageList, barcode, "", ""); StoragePos pos = taskService.findEmptyPosForPutIn(storageList, barcode, "", "");
if (pos == null) { if (pos == null) {
throw new ValidateException("", "[" + barcode.getBarcode() + "]未找到可用的[" + barcode.getPlateSize() + "x" + barcode.getHeight() + "]仓位", null); throw new ValidateException("", "[" + barcode.getBarcode() + "]未找到可用的[" + barcode.getPlateSize() + "x" + barcode.getHeight() + "]仓位", null);
} }
...@@ -330,48 +357,336 @@ public class WarehouseController { ...@@ -330,48 +357,336 @@ public class WarehouseController {
//同时清空lastScanBoxCode //同时清空lastScanBoxCode
station.setLastScanBoxCode(null); station.setLastScanBoxCode(null);
StationCacheUtil.saveBoxToBoxCode(station); StationCacheUtil.saveBoxToBoxCode(station);
String boxStr = currentRfid.replaceAll("A","").replaceAll("B","");
if (boxALlCountMap.get(boxStr) != null){
boxALlCountMap.remove(boxStr);
}
if (boxCount.get(boxStr) != null){
boxCount.remove(boxStr);
}
return ResultBean.newOkResult(station); return ResultBean.newOkResult(station);
} }
@ApiOperation("扫码出库")
@RequestMapping("/finishBoxOut") @ApiOperation("出库页面展示")
@RequestMapping("/outIndex")
@AnonymousAccess @AnonymousAccess
public ResultBean finishBoxOut(@RequestBody Map<String, String> paramMap) { public ResultBean outIndex(@RequestBody Map<String, String> paramMap) {
String code = paramMap.get("barcode"); String name = paramMap.get("name"); //工位名称
Barcode barcode = barcodeManager.findByBarcode(code); String barcodeStr = paramMap.get("barcode"); //隔扣码
Station station = StationCacheUtil.getStation(name);
if (station == null) {
return ResultBean.newErrorResult(-1, "", name + "工位不存在", new String[]{});
}
//判断当前工位是否有料箱
String currentRfid = station.getCurrentRfid();
if (StringUtils.isBlank(currentRfid)) {
return ResultBean.newErrorResult(-1, "", "料箱不存在", new String[]{});
}
String boxStr = currentRfid.replaceAll("A","").replaceAll("B","");
//处理要出库的物料
if (StringUtils.isNotBlank(barcodeStr)) {
CodeBean codeBean = codeResolve.resolveSingleCode(barcodeStr);
if (!codeBean.isValid()) {
return ResultBean.newErrorResult(-1, "", barcodeStr + "解析条码失败", new String[]{});
}
String code = codeBean.getBarcode().getBarcode();
if (code.startsWith("CS") || code.startsWith("CM") || code.startsWith("CB")) {
return ResultBean.newErrorResult(-1, "", "请扫描物料条码");
}
Barcode barcode = barcodeManager.findByBarcode(codeBean.getBarcode().getBarcode());
if (barcode == null) { if (barcode == null) {
return ResultBean.newErrorResult(-1, "", code + "物料不存在", new String[]{}); return ResultBean.newErrorResult(-1, "", barcodeStr + "未找到对应得物料");
}
Barcode barcodeApi = smfApi.canPutInAfterResolve(barcode);
if (barcodeApi != null) {
barcode = barcodeApi;
} }
int amount = barcode.getAmount();
barcode.setAmount(amount - 1); //判断扫描的料号与正在执行的是否一致
Barcode pidBarcode = barcodeManager.get(barcode.getHostBarcodeId()); Collection<String> executePartNumbers = liteOrderCache.executePartNumber();
if (executePartNumbers != null && !executePartNumbers.isEmpty()) {
if (!executePartNumbers.contains(barcode.getPartNumber())) {
return ResultBean.newErrorResult(-1, "", "当前物料不在允许出库");
}
}
String posName = barcode.getPosName();
Map<String, Integer> boxCountMap = boxALlCountMap.get(boxStr);
if (boxCountMap == null) {
return ResultBean.newErrorResult(-1, "", "当前料箱没有要出库的物料");
}
if (StringUtils.isBlank(posName) || !posName.startsWith(boxStr)){
return ResultBean.newErrorResult(-1,"",barcode.getBarcode()+"不在料箱"+boxStr);
}
int count = boxCountMap.get(posName);
if (count == 0) {
return ResultBean.newErrorResult(-1, "", posName + "没有出库任务");
}
//得到正在执行的工单
String orderId = null;
Collection<LiteOrderItem> items = liteOrderCache.executeItems();
for (LiteOrderItem item : items) {
String pn = item.getPn();
if (pn.equals(barcode.getPartNumber()) && posName.equals(item.getPosName())) {
DataLog executeTask = getExecuteTask(item.getRi());
if (executeTask == null) {
if (item.getTotalOutNum() != item.getNeedNum()) {
item.setRi(barcode.getBarcode());
orderId = item.getOrderId();
liteOrderItemManager.save(item);
break;
}
}
}
}
if (StringUtils.isNotBlank(orderId)){
LiteOrder liteOrder = liteOrderManager.get(orderId);
List<LiteOrderItem> orderItems = liteOrderItemManager.findOrderItems(orderId);
liteOrder.setOrderItems(orderItems);
liteOrder = liteOrderManager.createWithItems(liteOrder);
liteOrderCache.addOrderToMap(liteOrder);
}
//生成出库任务
Barcode pidBarcode = barcodeManager.findByBarcode(boxStr);
finishTask(pidBarcode, OP.CHECKOUT, null, barcode, 1); finishTask(pidBarcode, OP.CHECKOUT, null, barcode, 1);
return ResultBean.newOkResult("");
} }
@ApiOperation("出库页面展示") //获取料箱中的物料信息
@RequestMapping("/outIndex") Barcode pidBarcode = barcodeManager.findByBarcode(boxStr);
public ResultBean outIndex(@RequestBody Map<String, String> paramMap) { if (pidBarcode == null){
String barcode = paramMap.get("barcode"); //料箱barcode return ResultBean.newErrorResult(-1,"",boxStr+"未找到物料信息");
Query query = new Query(); }
Pattern pattern = Pattern.compile("^.*" + barcode + ".*$", Pattern.CASE_INSENSITIVE); List<Barcode> subCodeList = pidBarcode.getSubCodeList();
Criteria criteria = Criteria.where("posName").regex(pattern);
List<Barcode> barcodes = barcodeManager.findByQuery(query.addCriteria(criteria)); //需要出库的数量
List<Map<String, String>> results = new ArrayList<>(); Map<String,Integer> boxCountMap = new HashMap<>();
if (barcodes != null && !barcodes.isEmpty()) { boxCountMap.put(boxStr+"-1",0);
boxCountMap.put(boxStr+"-2",0);
boxCountMap.put(boxStr+"-3",0);
boxCountMap.put(boxStr+"-4",0);
boxCountMap.put(boxStr+"-5",0);
boxCountMap.put(boxStr+"-6",0);
boxCountMap.put(boxStr+"-7",0);
boxCountMap.put(boxStr+"-8",0);
//得到正在执行的工单数据
List<LiteOrderItem> orderItems = new ArrayList<>();
Collection<LiteOrderItem> liteOrderItems = liteOrderCache.executeItems();
for (LiteOrderItem liteOrderItem : liteOrderItems) {
if (liteOrderItem.getNeedNum() != liteOrderItem.getTotalOutNum()){
orderItems.add(liteOrderItem);
}
}
if (orderItems != null && !orderItems.isEmpty()){
Map<String, Long> boxCount = orderItems.stream().collect(Collectors.groupingBy(LiteOrderItem::getPosName, Collectors.counting()));
for (Map.Entry<String, Long> countEntry : boxCount.entrySet()) {
if (countEntry.getValue() != null) {
boxCountMap.put(countEntry.getKey(),countEntry.getValue().intValue());
}
}
}
if (boxALlCountMap.get(boxStr) != null){
boxALlCountMap.remove(boxStr);
}
boxALlCountMap.put(boxStr,boxCountMap);
//料箱总数量
if (boxCount.get(boxStr) == null) {
boxCount.put(boxStr, subCodeList.size());
}
//判断是否全部出库
Map<String, Long> subCountMap = subCodeList.stream().collect(Collectors.groupingBy(Barcode::getPosName, Collectors.counting()));
for (Map.Entry<String, Long> countMap : subCountMap.entrySet()) {
String posName = countMap.getKey();
int count = boxCountMap.get(posName);
if (count != 0 && count == countMap.getValue()) {
boxCountMap.put(posName, -1);
}
}
List<Integer> boxPartitionCounts = new ArrayList<>();
if (currentRfid.endsWith("A")) {
boxPartitionCounts.add(boxCountMap.get(boxStr + "-8"));
boxPartitionCounts.add(boxCountMap.get(boxStr + "-7"));
boxPartitionCounts.add(boxCountMap.get(boxStr + "-6"));
boxPartitionCounts.add(boxCountMap.get(boxStr + "-5"));
boxPartitionCounts.add(boxCountMap.get(boxStr + "-1"));
boxPartitionCounts.add(boxCountMap.get(boxStr + "-2"));
boxPartitionCounts.add(boxCountMap.get(boxStr + "-3"));
boxPartitionCounts.add(boxCountMap.get(boxStr + "-4"));
} else if (currentRfid.endsWith("B")) {
boxPartitionCounts.add(boxCountMap.get(boxStr + "-4"));
boxPartitionCounts.add(boxCountMap.get(boxStr + "-3"));
boxPartitionCounts.add(boxCountMap.get(boxStr + "-2"));
boxPartitionCounts.add(boxCountMap.get(boxStr + "-1"));
boxPartitionCounts.add(boxCountMap.get(boxStr + "-5"));
boxPartitionCounts.add(boxCountMap.get(boxStr + "-6"));
boxPartitionCounts.add(boxCountMap.get(boxStr + "-7"));
boxPartitionCounts.add(boxCountMap.get(boxStr + "-8"));
}
Map<String,Object> resultMap = new HashMap<>();
resultMap.put("boxPartitionCounts",boxPartitionCounts); //展示数量
resultMap.put("boxAllCount", boxCount.get(boxStr)); //料箱总数量
resultMap.put("boxRemainingCount", subCodeList.size()); //剩余数量
resultMap.put("box", currentRfid);//箱子号
return ResultBean.newOkResult(resultMap);
/*String currentRfid = station.getCurrentRfid();
if (barcodeStr.startsWith("CS") || barcodeStr.startsWith("CB") || barcodeStr.startsWith("CM")) {
if (barcodeStr.indexOf("-") != -1) {
station.setLastScanBoxCode(barcodeStr);
barcodeStr = barcodeStr.substring(0, barcodeStr.indexOf("-"));
}
if (StringUtils.isBlank(currentRfid)) {
return ResultBean.newErrorResult(-1, "", "料箱不存在", new String[]{});
} else if (!currentRfid.startsWith(barcodeStr)) {
return ResultBean.newErrorResult(-1, "", "料箱" + currentRfid + "与" + barcodeStr + "不一致", new String[]{});
}
} else {
String lastScanBoxCode = station.getLastScanBoxCode();
if (Strings.isBlank(lastScanBoxCode)) {
//提示要先扫料箱
return ResultBean.newErrorResult(-1, "", "请先扫描料箱,再扫描条码");
}
CodeBean codeBean = codeResolve.resolveSingleCode(barcodeStr);
if (!codeBean.isValid()) {
return ResultBean.newErrorResult(-1, "", barcodeStr + "解析条码失败", new String[]{});
}
Barcode barcode = barcodeManager.findByBarcode(codeBean.getBarcode().getBarcode());
if (barcode == null) {
return ResultBean.newErrorResult(-1, "", barcodeStr + "未找到对应得物料");
}
Barcode barcodeApi = smfApi.canPutInAfterResolve(barcode);
if (barcodeApi != null){
barcode = barcodeApi;
}
if (!lastScanBoxCode.equals(barcode.getPosName())) {
return ResultBean.newErrorResult(-1, "", barcodeStr + "存在库位:" + barcode.getPosName());
}
//生成出库任务
Barcode pidBarcode = barcodeManager.findByBarcode(lastScanBoxCode.substring(0, lastScanBoxCode.indexOf("-")));
barcode.setAmount(0);
finishTask(pidBarcode, OP.CHECKOUT, null, barcode, 1);
}
String boxStr = currentRfid.replaceAll("A", "").replaceAll("B", "");
Barcode pidBarcode = barcodeManager.findByBarcode(boxStr);
//获取到箱子里物料信息
List<Barcode> subCodeList = pidBarcode.getSubCodeList();
Map<String, Object> resultMap = new HashMap<>();
resultMap.put(boxStr + "-1", 0l);
resultMap.put(boxStr + "-2", 0l);
resultMap.put(boxStr + "-3", 0l);
resultMap.put(boxStr + "-4", 0l);
resultMap.put(boxStr + "-5", 0l);
resultMap.put(boxStr + "-6", 0l);
resultMap.put(boxStr + "-7", 0l);
resultMap.put(boxStr + "-8", 0l);
resultMap.put("boxAllCount", 0);
resultMap.put("boxRemainingCount", 0);
resultMap.put("box", currentRfid);
Collection<String> excludeBarcodes = liteOrderCache.excludeBarcodeIds();
for (Barcode subBarcode : subCodeList) {
if (excludeBarcodes != null && !excludeBarcodes.isEmpty()) {
boolean contains = excludeBarcodes.contains(subBarcode.getBarcode());
if (contains) {
DataLog task = null;
List<DataLog> allTasks = taskService.getAllTasks();
for (DataLog dataLog : allTasks) {
if (dataLog.getBarcode().equals(subBarcode.getBarcode())) {
task = dataLog;
break;
}
}
if (task == null) {
long count = (long) resultMap.get(subBarcode.getPosName());
if (count != 0) {
resultMap.put(subBarcode.getPosName(), count + 1);
} else {
resultMap.put(subBarcode.getPosName(), 1l);
}
}
}
}
}
Map<String, List<Barcode>> barcodesPosNameMap = barcodes.stream().collect(Collectors.groupingBy(Barcode::getPosName)); if (subCodeList != null && !subCodeList.isEmpty()) {
for (Map.Entry<String, List<Barcode>> barcodePosNameMap : barcodesPosNameMap.entrySet()) { if (boxCount.get(boxStr) == null) {
Map<String, String> resultMap = new HashMap<>(); boxCount.put(boxStr, subCodeList.size());
String posName = barcodePosNameMap.getKey(); }
List<Barcode> barcodePosNames = barcodePosNameMap.getValue(); resultMap.put("boxAllCount", boxCount.get(boxStr)); //料箱总数量
resultMap.put("posName", posName); resultMap.put("boxRemainingCount", subCodeList.size()); //剩余数量
resultMap.put("posNameSize", barcodePosNames.size() + ""); Map<String, Long> subCountMap = subCodeList.stream().collect(Collectors.groupingBy(Barcode::getPosName, Collectors.counting()));
results.add(resultMap); for (Map.Entry<String, Long> countMap : subCountMap.entrySet()) {
String posName = countMap.getKey();
long count = (long) resultMap.get(posName);
if (count != 0 && count == countMap.getValue()) {
resultMap.put(posName, -1);
}
} }
} }
return ResultBean.newOkResult(results); List<Object> boxPartitionCounts = new ArrayList<>();
if (currentRfid.endsWith("A")) {
boxPartitionCounts.add(resultMap.get(boxStr + "-8"));
boxPartitionCounts.add(resultMap.get(boxStr + "-7"));
boxPartitionCounts.add(resultMap.get(boxStr + "-6"));
boxPartitionCounts.add(resultMap.get(boxStr + "-5"));
boxPartitionCounts.add(resultMap.get(boxStr + "-1"));
boxPartitionCounts.add(resultMap.get(boxStr + "-2"));
boxPartitionCounts.add(resultMap.get(boxStr + "-3"));
boxPartitionCounts.add(resultMap.get(boxStr + "-4"));
} else if (currentRfid.endsWith("B")) {
boxPartitionCounts.add(resultMap.get(boxStr + "-4"));
boxPartitionCounts.add(resultMap.get(boxStr + "-3"));
boxPartitionCounts.add(resultMap.get(boxStr + "-2"));
boxPartitionCounts.add(resultMap.get(boxStr + "-1"));
boxPartitionCounts.add(resultMap.get(boxStr + "-5"));
boxPartitionCounts.add(resultMap.get(boxStr + "-6"));
boxPartitionCounts.add(resultMap.get(boxStr + "-7"));
boxPartitionCounts.add(resultMap.get(boxStr + "-8"));
}
resultMap.put("boxPartitionCounts",boxPartitionCounts);
return ResultBean.newOkResult(resultMap);*/
}
@ApiOperation("已全部完成装箱")
@RequestMapping("/finishPutIn")
public ResultBean finishPutIn(@RequestBody Map<String, String> paramMap) {
String name = paramMap.get("name");
Station station = StationCacheUtil.getStation(name);
if (station == null) {
return ResultBean.newErrorResult(-1, "", name + "工位不存在", new String[]{});
}
station.setReelCurrentNum(0);
station.setLastScanBoxCode(null);
station.setBoxCurrentNum(0);
station.setCurrentRfid(null);
station.setReelNum(0);
station.setBoxNum(0);
StationCacheUtil.updateStation(station);
return ResultBean.newOkResult(station);
} }
...@@ -395,20 +710,19 @@ public class WarehouseController { ...@@ -395,20 +710,19 @@ public class WarehouseController {
*/ */
private void finishTask(Barcode pidBarcode, int opType, DataLog currentTask, Barcode subBarcode, int opQty) throws ValidateException { private void finishTask(Barcode pidBarcode, int opType, DataLog currentTask, Barcode subBarcode, int opQty) throws ValidateException {
//更新barcode缓存 int subAmout = subBarcode.getAmount();
pidBarcode.UpdateSubCode(subBarcode);
//更新pidBarcode的数量 //更新pidBarcode的数量
int amount = pidBarcode.getAmount(); int amount = pidBarcode.getAmount();
if (opType == OP.PUT_IN) { if (opType == OP.PUT_IN) {
pidBarcode.setAmount(amount + opQty); pidBarcode.setAmount(amount + opQty);
} else { } else {
pidBarcode.setAmount(amount - opQty); pidBarcode.setAmount(amount - opQty);
subBarcode.setAmount(0);
} }
if (opType == OP.CHECKOUT && subBarcode.getAmount() <= 0) {
//数量为0直接删除 //更新barcode缓存
barcodeManager.delete(subBarcode); pidBarcode.UpdateSubCode(subBarcode);
}
barcodeManager.saveBarcode(pidBarcode); barcodeManager.saveBarcode(pidBarcode);
DataLog task = null; DataLog task = null;
...@@ -431,17 +745,103 @@ public class WarehouseController { ...@@ -431,17 +745,103 @@ public class WarehouseController {
task.setStatus(OP_STATUS.FINISHED.name()); task.setStatus(OP_STATUS.FINISHED.name());
task.setPartNumber(subBarcode.getPartNumber()); task.setPartNumber(subBarcode.getPartNumber());
task.setBarcode(subBarcode.getBarcode()); task.setBarcode(subBarcode.getBarcode());
task.setNum(opQty); task.setNum(subAmout);
task.setType(opType); task.setType(opType);
task.setCid(pidBarcode.getPartNumber());
task.setStorageName(pidBarcode.getBarcode());
task.setPosName(pidBarcode.getBarcode()); task.setPosName(pidBarcode.getBarcode());
task.setOperator(SecurityUtils.getLoginUsername()); task.setOperator(SecurityUtils.getLoginUsername());
String orderNo = liteOrderCache.executeOrderByBarcode(subBarcode.getBarcode());
if (StringUtils.isNotBlank(orderNo)){
task.setSourceName(orderNo);
LiteOrder liteOrder = liteOrderCache.getOrderSortItems(orderNo);
for (LiteOrderItem orderItem : liteOrder.getOrderItems()) {
if (orderItem.getRi().equals(subBarcode.getBarcode())){
if (!orderItem.isOutFinished()){
task.setSubSourceId(orderItem.getId());
break;
}
}
}
}
task = dataLogManager.save(task); task = dataLogManager.save(task);
taskService.moveTaskToFinished(task); taskService.updateFinishedTask(task);
if (opType == OP.CHECKOUT && subBarcode.getAmount() <= 0) {
//数量为0直接删除
barcodeManager.delete(subBarcode);
}
} }
private int getPlatsizeOrHeight(String size, int index) { private int getPlatsizeOrHeight(String size, int index) {
return Integer.valueOf(size.split("X")[index]); return Integer.valueOf(size.split("X")[index]);
} }
private StoragePos getEmptyBoxPos(String platsize) {
//得到料盒类型
String boxCode = "";
if ("7".equals(platsize)) {
boxCode = "CS";
} else if ("13".equals(platsize)) {
boxCode = "CM";
} else if ("15".equals(platsize)) {
boxCode = "CB";
}
//料仓类型是agv的
String storageId = "";
Collection<Storage> storages = dataCache.getAllStorage().values();
for (Storage storage : storages) {
if (storage.isType(new DeviceType[]{DeviceType.AGV_BOX})) {
storageId = storage.getId();
}
}
Criteria c = Criteria.where("barcode").exists(true)
.and("enabled").is(true);//可用
//排除掉正在执行的仓位
Collection<String> excludePosIds = taskService.excludePosIds();
log.info("excludePosIds--" + JsonUtil.toJsonStr(excludePosIds));
if (excludePosIds != null && !excludePosIds.isEmpty()) {
c.and("id").nin(excludePosIds);
}
if (StringUtils.isNotBlank(storageId)) {
c.and("storageId").is(storageId);
}
if (StringUtils.isNotBlank(boxCode)) {
Pattern pattern = Pattern.compile("^.*" + boxCode + ".*$", Pattern.CASE_INSENSITIVE);
c.and("barcode.barcode").regex(pattern);
}
Query q = new Query(c).with(Sort.by(Sort.Direction.ASC, "barcode.amount")).limit(1);
List<StoragePos> storagePoss = storagePosManager.findByQuery(q);
if (storagePoss != null && !storagePoss.isEmpty()) {
return storagePoss.get(0);
}
return null;
}
private DataLog getExecuteTask(String barcode) {
List<DataLog> allTasks = taskService.getAllTasks();
for (DataLog dataLog : allTasks) {
if (dataLog.getBarcode().equals(barcode)) {
if (!dataLog.isCancel() && !dataLog.isFinished()) {
return dataLog;
}
}
}
return null;
}
/**
* 根据料箱编号获取到所有物料
*
* @param boxBarcode
* @return
*/
private List<Barcode> getAllBarcodeByBox(String boxBarcode) {
Query query = new Query();
Pattern pattern = Pattern.compile("^" + boxBarcode + ".*$", Pattern.CASE_INSENSITIVE);
Criteria criteria = Criteria.where("posName").regex(pattern);
return barcodeManager.findByQuery(query.addCriteria(criteria));
}
} }
...@@ -39,7 +39,7 @@ public class StationCacheUtil { ...@@ -39,7 +39,7 @@ public class StationCacheUtil {
@PostConstruct @PostConstruct
public void init() { public void init() {
log.info("开始工位缓存信息"); log.info("开始工位缓存信息");
for (int i = 1; i < 5; i++) { for (int i = 1; i <= 5; i++) {
String stationName = "s" + i; String stationName = "s" + i;
Station station = dataCache.getCache(stationName); Station station = dataCache.getCache(stationName);
if(station == null){ if(station == null){
...@@ -68,7 +68,7 @@ public class StationCacheUtil { ...@@ -68,7 +68,7 @@ public class StationCacheUtil {
Station station = getStation(stationName); Station station = getStation(stationName);
if(station != null){ if(station != null){
String oldRfid = station.getCurrentRfid(); String oldRfid = station.getCurrentRfid();
if (!oldRfid.equals(rfid)) { if (!rfid.equals(oldRfid)) {
log.info("工位" + stationName + " 切换料箱,当前料箱:" + rfid + ",上一料箱:" + oldRfid); log.info("工位" + stationName + " 切换料箱,当前料箱:" + rfid + ",上一料箱:" + oldRfid);
station.setCurrentRfid(rfid); station.setCurrentRfid(rfid);
updateStation(station); updateStation(station);
......
...@@ -237,7 +237,7 @@ public class InnerBoxRestController { ...@@ -237,7 +237,7 @@ public class InnerBoxRestController {
rfid = rfid.replaceAll("A", "").replaceAll("B", ""); rfid = rfid.replaceAll("A", "").replaceAll("B", "");
Pattern pattern = Pattern.compile("^" + rfid + ".*$", Pattern.CASE_INSENSITIVE); Pattern pattern = Pattern.compile("^" + rfid + ".*$", Pattern.CASE_INSENSITIVE);
List<LiteOrder> liteOrders = liteOrderManager.findByQuery(new Query(Criteria.where("boxNumber").regex(pattern))); List<LiteOrder> liteOrders = liteOrderManager.findByQuery(new Query(Criteria.where("boxNumber").regex(pattern)));
if (liteOrders != null && liteOrders.isEmpty()) { if (liteOrders != null && !liteOrders.isEmpty()) {
for (LiteOrder liteOrder : liteOrders) { for (LiteOrder liteOrder : liteOrders) {
liteOrder.setBoxNumber(""); liteOrder.setBoxNumber("");
liteOrderManager.save(liteOrder); liteOrderManager.save(liteOrder);
......
package com.neotel.smfcore.custom.lizhen.innerBox.util; package com.neotel.smfcore.custom.lizhen.innerBox.util;
import com.neotel.smfcore.common.base.AbstractBaseDao; import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants; import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.StringUtils; import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.SmfApi;
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.core.order.LiteOrderCache; import com.neotel.smfcore.core.order.LiteOrderCache;
...@@ -17,6 +19,8 @@ import com.neotel.smfcore.core.system.service.po.DataLog; ...@@ -17,6 +19,8 @@ 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.lizhen.LizhenApi; import com.neotel.smfcore.custom.lizhen.LizhenApi;
import com.neotel.smfcore.custom.lizhen.innerBox.bean.PreWarningItem; import com.neotel.smfcore.custom.lizhen.innerBox.bean.PreWarningItem;
import com.neotel.smfcore.custom.lizhen.innerBox.util.service.PreWarningItemManager;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import jdk.nashorn.internal.runtime.arrays.ArrayIndex; import jdk.nashorn.internal.runtime.arrays.ArrayIndex;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings; import org.apache.logging.log4j.util.Strings;
...@@ -25,6 +29,8 @@ import org.springframework.data.domain.Sort; ...@@ -25,6 +29,8 @@ import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.*; import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
...@@ -34,12 +40,13 @@ import java.util.stream.Collectors; ...@@ -34,12 +40,13 @@ import java.util.stream.Collectors;
/** /**
* 机台预警信息缓存 * 机台预警信息缓存
*
* @author sunke * @author sunke
* @date 2022/10/9 3:31 PM * @date 2022/10/9 3:31 PM
*/ */
@Slf4j @Slf4j
@Service @Service
public class PreWarningItemCache extends AbstractBaseDao { public class PreWarningItemCache {
/** /**
* 预警列表缓存 * 预警列表缓存
...@@ -56,6 +63,9 @@ public class PreWarningItemCache extends AbstractBaseDao { ...@@ -56,6 +63,9 @@ public class PreWarningItemCache extends AbstractBaseDao {
private static IStoragePosManager storagePosManager; private static IStoragePosManager storagePosManager;
private static SmfApi smfApi;
private static PreWarningItemManager preWarningItemManager;
/** /**
* 添加到预警列表缓存中 * 添加到预警列表缓存中
...@@ -64,7 +74,6 @@ public class PreWarningItemCache extends AbstractBaseDao { ...@@ -64,7 +74,6 @@ public class PreWarningItemCache extends AbstractBaseDao {
updateItem(items, false); updateItem(items, false);
} }
private AtomicInteger atomicInteger = new AtomicInteger(0);
/** /**
* 从缓存列表中取出预警Item生成工单并执行 * 从缓存列表中取出预警Item生成工单并执行
...@@ -130,7 +139,7 @@ public class PreWarningItemCache extends AbstractBaseDao { ...@@ -130,7 +139,7 @@ public class PreWarningItemCache extends AbstractBaseDao {
* *
* @param lineItems * @param lineItems
*/ */
private static void createAndExecuteLiteOrder(List<PreWarningItem> lineItems) { public static LiteOrder createAndExecuteLiteOrder(List<PreWarningItem> lineItems) {
List<String> noPossPosIds = new ArrayList<>(); List<String> noPossPosIds = new ArrayList<>();
List<String> outPosIds = new ArrayList<>(); List<String> outPosIds = new ArrayList<>();
//得到料仓id //得到料仓id
...@@ -145,8 +154,8 @@ public class PreWarningItemCache extends AbstractBaseDao { ...@@ -145,8 +154,8 @@ public class PreWarningItemCache extends AbstractBaseDao {
//处理线别需求单 //处理线别需求单
LiteOrder liteOrder = new LiteOrder(); LiteOrder liteOrder = new LiteOrder();
liteOrder.setType(2); liteOrder.setType(2);
liteOrder.setOrderNo(new PreWarningItemCache().getSeq()); liteOrder.setOrderNo(getSeq());
liteOrder.setSo(new PreWarningItemCache().getSeq()); //liteOrder.setSo(getSeq(2));
List<LiteOrderItem> orderItems = new ArrayList<>(); List<LiteOrderItem> orderItems = new ArrayList<>();
for (PreWarningItem item : lineItems) { for (PreWarningItem item : lineItems) {
liteOrder.setLine(item.getLine()); liteOrder.setLine(item.getLine());
...@@ -164,19 +173,25 @@ public class PreWarningItemCache extends AbstractBaseDao { ...@@ -164,19 +173,25 @@ public class PreWarningItemCache extends AbstractBaseDao {
if (StringUtils.isNotBlank(storageId)) { if (StringUtils.isNotBlank(storageId)) {
c.and("storageId").is(storageId); c.and("storageId").is(storageId);
} }
List<String> posIds = new ArrayList<>();
//排除已经执行过的物料barcode //排除已经执行过的物料barcode
if (outPosIds != null && !outPosIds.isEmpty()) { if (outPosIds != null && !outPosIds.isEmpty()) {
c.and("id").not().in(outPosIds); posIds.addAll(outPosIds);
} }
//排除校验没通过的 //排除校验没通过的
if (noPossPosIds != null && !noPossPosIds.isEmpty()) { if (noPossPosIds != null && !noPossPosIds.isEmpty()) {
// c.and("id").not().in(noPossPosIds); posIds.addAll(noPossPosIds);
} }
//排除正在执行出库的工位 //排除正在执行出库的工位
Collection<String> excludePosIds = taskService.excludePosIds(); Collection<String> excludePosIds = taskService.excludePosIds();
if (excludePosIds != null && !excludePosIds.isEmpty()) { if (excludePosIds != null && !excludePosIds.isEmpty()) {
// c.and("id").not().in(excludePosIds); posIds.addAll(excludePosIds);
} }
if (posIds != null && !posIds.isEmpty()) {
c.and("id").not().in(posIds);
}
//排除正在执行的工单物料 //排除正在执行的工单物料
Collection<String> excludeBarcodeIds = liteOrderCache.excludeBarcodeIds(); Collection<String> excludeBarcodeIds = liteOrderCache.excludeBarcodeIds();
if (excludeBarcodeIds != null && !excludeBarcodeIds.isEmpty()) { if (excludeBarcodeIds != null && !excludeBarcodeIds.isEmpty()) {
...@@ -200,9 +215,10 @@ public class PreWarningItemCache extends AbstractBaseDao { ...@@ -200,9 +215,10 @@ public class PreWarningItemCache extends AbstractBaseDao {
} else { } else {
for (StoragePos pos : storagePoss) { for (StoragePos pos : storagePoss) {
Barcode barcode = pos.getBarcode(); Barcode barcode = pos.getBarcode();
//String checkResult = LizhenApi.wmsCheckReelfob("", barcode); try {
String checkResult = ""; //立臻校验时,需要切换 Barcode barcodeApi = smfApi.canPutInAfterResolve(barcode);
if (StringUtils.isBlank(checkResult)) { //String checkResult = ""; //立臻校验时,需要切换
if (barcodeApi != null) {
outPosIds.add(pos.getId()); //防止其他地方出库 outPosIds.add(pos.getId()); //防止其他地方出库
orderItem.setRi(barcode.getBarcode()); orderItem.setRi(barcode.getBarcode());
orderItem.setNeedNum(1); orderItem.setNeedNum(1);
...@@ -210,10 +226,13 @@ public class PreWarningItemCache extends AbstractBaseDao { ...@@ -210,10 +226,13 @@ public class PreWarningItemCache extends AbstractBaseDao {
flag = false; flag = false;
break; break;
} else { } else {
log.info("partNumber:{}校验失败:{}", barcode.getPartNumber(), checkResult); log.info("partNumber:{}校验失败:{}", barcode.getPartNumber());
noPossPosIds.add(pos.getId()); noPossPosIds.add(pos.getId());
continue; continue;
} }
} catch (ValidateException e) {
e.printStackTrace();
}
} }
} }
} }
...@@ -222,9 +241,9 @@ public class PreWarningItemCache extends AbstractBaseDao { ...@@ -222,9 +241,9 @@ public class PreWarningItemCache extends AbstractBaseDao {
liteOrder.setOrderItems(orderItems); liteOrder.setOrderItems(orderItems);
liteOrder.setTaskReelCount(orderItems.size()); liteOrder.setTaskReelCount(orderItems.size());
liteOrder = liteOrderManager.createWithItems(liteOrder); liteOrder = liteOrderManager.createWithItems(liteOrder);
liteOrderManager.save(liteOrder);
liteOrderCache.addOrderToMap(liteOrder); liteOrderCache.addOrderToMap(liteOrder);
} }
return liteOrder;
} }
private static synchronized void updateItem(List<PreWarningItem> items, boolean remove) { private static synchronized void updateItem(List<PreWarningItem> items, boolean remove) {
...@@ -283,18 +302,17 @@ public class PreWarningItemCache extends AbstractBaseDao { ...@@ -283,18 +302,17 @@ public class PreWarningItemCache extends AbstractBaseDao {
PreWarningItemCache.storagePosManager = storagePosManager; PreWarningItemCache.storagePosManager = storagePosManager;
} }
@Autowired
public void setSmfApi(SmfApi smfApi) {
//待修改---- PreWarningItemCache.smfApi = smfApi;
private String getSeq() {
// return "H" + getNextId(getEntityClass().getName());
int seq = atomicInteger.addAndGet(1);
return "H" + seq;
} }
@Autowired
public void setPreWarningItemManager(PreWarningItemManager itemManager){
PreWarningItemCache.preWarningItemManager = itemManager;
}
@Override private static String getSeq() {
public Class getEntityClass() { return "H" + preWarningItemManager.getNextId(PreWarningItemCache.class.getName());
return PreWarningItemCache.class;
} }
} }
package com.neotel.smfcore.custom.lizhen.innerBox.util.service;
import com.neotel.smfcore.common.base.AbstractBaseDao;
import com.neotel.smfcore.custom.lizhen.innerBox.util.PreWarningItemCache;
import org.springframework.stereotype.Service;
@Service
public class PreWarningItemManager extends AbstractBaseDao {
@Override
public Class getEntityClass() {
return PreWarningItemCache.class;
}
}
...@@ -427,6 +427,11 @@ public class PanaApiController extends BaseSmfApiListener { ...@@ -427,6 +427,11 @@ public class PanaApiController extends BaseSmfApiListener {
} }
@Override @Override
public Barcode barcodeInfo(String barcodeInfoUrl, Barcode barcode) {
return null;
}
@Override
public void inTaskStatusChange(String inNotifyUrl, DataLog task) { public void inTaskStatusChange(String inNotifyUrl, DataLog task) {
if(task.isFinished()){ if(task.isFinished()){
if(task.isPutInTask()){ if(task.isPutInTask()){
......
...@@ -190,6 +190,11 @@ public class SiemensApi extends BaseSmfApiListener { ...@@ -190,6 +190,11 @@ public class SiemensApi extends BaseSmfApiListener {
} }
} }
@Override
public Barcode barcodeInfo(String barcodeInfoUrl, Barcode barcode) {
return null;
}
public static LotCheckInfo lotCheckIn(String lot, String url,String deviceId) { public static LotCheckInfo lotCheckIn(String lot, String url,String deviceId) {
if (ObjectUtil.isEmpty(url)) { if (ObjectUtil.isEmpty(url)) {
log.info("没有配置Siemens,无需验证"); log.info("没有配置Siemens,无需验证");
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!