Commit e9f952c3 hc

fix:备品仓单据获取和入库出库接口出库入库单生成、执行、生成任务确认

1 个父辈 14e1195f
......@@ -668,13 +668,13 @@ public class DataCache {
public List<String> getAvailableStorageIds(){
List<String> availableStorageIds = new ArrayList<>();
for (Storage storage : getAllStorage().values()) {
StatusBean bean = DevicesStatusUtil.getStatusBean(storage.getCid());
if (bean == null || bean.timeOut() || !bean.isAvailable()) {
continue;
}
availableStorageIds.add(storage.getId());
}
// for (Storage storage : getAllStorage().values()) {
// StatusBean bean = DevicesStatusUtil.getStatusBean(storage.getCid());
// if (bean == null || bean.timeOut() || !bean.isAvailable()) {
// continue;
// }
// availableStorageIds.add(storage.getId());
// }
return availableStorageIds;
}
public Storage AutoCreateStorage(String cid,String deviceType) {
......
......@@ -165,13 +165,13 @@ public class OrderController {
if (liteOrder == null) {
throw new ValidateException("smfcore.valueNotFind", "未找到{0}[{1}]", new String[]{"orderNo", orderNo});
}
synchronized (this) {
Long time = onClickWorkOrderOut.get(orderNo);
if (time != null && System.currentTimeMillis() - time < 1000 * 1 * 60 * 60) {
return ResultBean.newErrorResult(-1, "", orderNo + "已经在执行工单出库,请勿重复点击");
}
onClickWorkOrderOut.put(orderNo, System.currentTimeMillis());
}
// synchronized (this) {
// Long time = onClickWorkOrderOut.get(orderNo);
// if (time != null && System.currentTimeMillis() - time < 1000 * 1 * 60 * 60) {
// return ResultBean.newErrorResult(-1, "", orderNo + "已经在执行工单出库,请勿重复点击");
// }
// onClickWorkOrderOut.put(orderNo, System.currentTimeMillis());
// }
log.info("开始执行工单出库:" + orderNo);
String result = "";
if (LITEORDER_SOURCE.OUTTER.name().equals(liteOrder.getSource())) {
......
......@@ -11,8 +11,6 @@ import com.neotel.smfcore.core.storage.service.po.StoragePos;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Query;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
public interface IStoragePosManager extends IBaseManager<StoragePos> {
......@@ -101,5 +99,5 @@ public interface IStoragePosManager extends IBaseManager<StoragePos> {
StoragePos findBoxPNInStorages(List<String> storageIdList, String pn, Collection<String> excludePosIds, CHECKOUT_TYPE checkOutType ) ;
StoragePos findEmptyBoxToPutIn(List<String> storageIdList, String pn, Collection<String> excludePosIds, CHECKOUT_TYPE checkOutType ,String boxType,int maxCount) ;
StoragePos findEmptyBoxToPutIn(List<String> storageIdList, Collection<String> excludePosIds, CHECKOUT_TYPE checkOutType ,String boxType,int maxCount) ;
}
......@@ -20,7 +20,6 @@ import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.asm.Advice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
......@@ -377,7 +376,7 @@ public class StoragePosManagerImpl implements IStoragePosManager {
Criteria c = Criteria.where("barcode.subCodeList.partNumber").is(pn)
.and("id").nin(excludePosIds)
.and("enabled").is(true)//可用
.and("barcode.lockId").is(null);//没有被锁定的仓位;
.and("barcode.lockId").in(null, "");//没有被锁定的仓位;
if (storageIdList != null) {
c = c.and("storageId").in(storageIdList);
}
......@@ -386,8 +385,8 @@ public class StoragePosManagerImpl implements IStoragePosManager {
}
Query q = new Query(c);
//Sort sort = getSortByCheckOutType(checkOutType);
Sort sort = Sort.by(Sort.Direction.ASC, "barcode.amount", "barcode.expireDate","barcode.createDate");
q.with(sort);
// Sort sort = Sort.by(Sort.Direction.ASC, "barcode.amount", "barcode.expireDate","barcode.createDate");
// q.with(sort);
StoragePos pos = storagePosDao.findOne(q);
if (pos == null) {
log.info("使用" + checkOutType + " 策略出库 partNumber=" + pn + ",未找到可以出库的物料 ");
......@@ -916,9 +915,9 @@ public class StoragePosManagerImpl implements IStoragePosManager {
// c.and("barcode.subCodeList.isOut").is(isOut);
// }
//Sort sort = getSortByCheckOutType(checkOutType);
Sort sort = Sort.by(Sort.Direction.ASC, "barcode.subCodeList.createDate","barcode.subCodeList.amount"/*,"canCheckOutTime", "barcode.usedCount"*/);
// Sort sort = Sort.by(Sort.Direction.ASC, "barcode.subCodeList.createDate","barcode.subCodeList.amount"/*,"canCheckOutTime", "barcode.usedCount"*/);
Query q = new Query(c);
q.with(sort);
// q.with(sort);
StoragePos pos = storagePosDao.findOne(q);
if (pos == null) {
log.info("使用" + checkOutType + " 策略出库 partNumber=" + pn + ",库存未找到PN ");
......@@ -929,7 +928,7 @@ public class StoragePosManagerImpl implements IStoragePosManager {
}
@Override
public StoragePos findEmptyBoxToPutIn(List<String> storageIdList, String pn, Collection<String> excludePosIds, CHECKOUT_TYPE checkOutType ,String boxType,int maxCount) {
public StoragePos findEmptyBoxToPutIn(List<String> storageIdList, Collection<String> excludePosIds, CHECKOUT_TYPE checkOutType , String boxType, int maxCount) {
String regex="^"+boxType+".*";
......@@ -944,9 +943,6 @@ public class StoragePosManagerImpl implements IStoragePosManager {
if (storageIdList != null) {
c = c.and("storageId").in(storageIdList);
}
if (ObjectUtil.isNotEmpty(pn)) {
c.and("barcode.subCodeList.partNumber").is(pn);
}
Sort sort = Sort.by(Sort.Direction.ASC, "barcode.subCodeList.createDate", "barcode.subCodeList.amount"/*,"canCheckOutTime", "barcode.usedCount"*/);
Query q = new Query(c);
q.with(sort);
......@@ -955,9 +951,9 @@ public class StoragePosManagerImpl implements IStoragePosManager {
q.addCriteria(Criteria.where(proName).exists(false));
StoragePos pos = storagePosDao.findOne(q);
if (pos == null) {
log.info("使用" + checkOutType + " 策略出库 partNumber=" + pn + ",库存未找到PN ");
log.info("使用" + checkOutType + " 策略出库 partNumber=" + ",未找到空料格 ");
} else {
log.info("使用" + checkOutType + " 策略出库 partNumber=" + pn + ",找到PN【" + pos.getPosName() + "】 ");
log.info("使用" + checkOutType + " 策略出库 partNumber=" + ",找到PN【" + pos.getPosName() + "】 ");
}
return pos;
}
......
......@@ -100,8 +100,19 @@ public class SpBoxCheckOutController {
return ResultBean.newErrorResult(-1,"","没有找到正在执行的出库单");
}
String binPartNumber = binBarcode.getPartNumber();
boolean isOk = false;
String codePartNumber = codeBarcode.getPartNumber();
for (Barcode barcode : boxBarcode.getSubCodeList()) {
String pn = barcode.getPn();
int binNum = Integer.parseInt(barcode.getBarcode().split("-")[1]);
if (pn.equals(codePartNumber) && (binNum == Integer.parseInt(binCodeStr.split("-")[1]))) {
isOk = true;
break;
}
}
if (!isOk) {
return ResultBean.newErrorResult(-1, "", codeStr + "与隔口:" + binCodeStr + "的料号不匹配");
}
//判断是否已经完成了
boolean finish = true;
......
......@@ -75,8 +75,7 @@ public class SpBoxPutInController {
@ApiOperation("获取当前工位的料箱信息")
@RequestMapping("/getStationInfo")
@AnonymousAccess
public ResultBean getStationInfo() {
public ResultBean getStationInfo(Integer type) {
//默认是s1 工位
Station station = StationCacheUtil.getStation("s1");
if (station == null){
......@@ -84,10 +83,12 @@ public class SpBoxPutInController {
}
String currentRfid = station.getCurrentRfid();
// currentRfid = "s1";
if (StringUtils.isEmpty(currentRfid)){
return ResultBean.newErrorResult(-1,"","当前工位上currentRfid为空");
}
// Barcode barcode = barcodeManager.findByBarcode("C0700084");
Barcode barcode = codeResolve.resolveOneValideBarcode("=2x2=" + currentRfid);
if (barcode == null){
return ResultBean.newErrorResult(-1,"",currentRfid+"不是有效的条码");
......@@ -95,8 +96,9 @@ public class SpBoxPutInController {
String suffix = currentRfid.substring(currentRfid.length()-1);
// suffix = "A";
String currentBox = barcode.getBarcode();
List<List<Object>> boxInfo = SpBoxUtil.getBoxInfo(barcode, suffix);
List<List<Object>> boxInfo = SpBoxUtil.getBoxInfo(barcode, suffix, type);
Map<String,Object> resultMap = new HashMap<>();
resultMap.put("currentBox",currentBox);
......@@ -155,14 +157,27 @@ public class SpBoxPutInController {
binPartNumber = "";
}
boolean isOk = false;
String codePartNumber = codeBarcode.getPartNumber();
if (StringUtils.isEmpty(binPartNumber)) {
binPartNumber = codePartNumber;
} else {
if (!binPartNumber.equals(codePartNumber)) {
return ResultBean.newErrorResult(-1, "", codeStr + "与隔口:" + binCodeStr + "的料号不匹配");
for (Barcode barcode : boxBarcode.getSubCodeList()) {
String pn = barcode.getPn();
int binNum = Integer.parseInt(barcode.getBarcode().split("-")[1]);
if (pn.equals(codePartNumber) && (binNum == Integer.parseInt(binCodeStr.split("-")[1]))) {
isOk = true;
break;
}
}
// if (StringUtils.isEmpty(binPartNumber)) {
// binPartNumber = codePartNumber;
// } else {
// if (!binPartNumber.equals(codePartNumber)) {
// return ResultBean.newErrorResult(-1, "", codeStr + "与隔口:" + binCodeStr + "的料号不匹配");
// }
// }
if (!isOk) {
return ResultBean.newErrorResult(-1, "", codeStr + "与隔口:" + binCodeStr + "的料号不匹配");
}
//判断是否已经完成了
boolean finish = true;
......
package com.neotel.smfcore.custom.luxsan_sp.util;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.bean.ReelLockPosInfo;
import com.neotel.smfcore.common.utils.ReelLockPosUtil;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
......@@ -74,17 +75,20 @@ public class SpBoxUtil {
* 获取当前正在执行的工单的详情信息
* @return
*/
public static List<SpareNoDetail> getActiveDetails() {
public static List<SpareNoDetail> getActiveDetails(Integer type) {
List<SpareNoDetail> spareNoDetails = null;
// 获取正在执行入库的工单
BaseNo no = spareNoCache.getExecutIngSpareNo();
spareNoDetails = no.getDetailList();
if (spareNoDetails == null) {
no = returnNoCache.getExecutingOrderNo();
if (type == 1) {
BaseNo no = spareNoCache.getExecutIngSpareNo();
if (ObjectUtil.isNull(no)) {
return null;
}
spareNoDetails = no.getDetailList();
}
// 获取正在执行出库的工单
if (spareNoDetails == null) {
if (spareNoDetails == null) {
no = returnNoCache.getExecutingOrderNo();
spareNoDetails = no.getDetailList();
}
} else if (type == 2) {
Unclaimed orderNo = orderNoCache.getExecutingOrderNo();
spareNoDetails = orderNo.getDetailList().stream().map((Function<UnclaimedDetail, SpareNoDetail>) unclaimedDetail -> {
SpareNoDetail detail = new SpareNoDetail();
......@@ -98,7 +102,7 @@ public class SpBoxUtil {
return spareNoDetails;
}
public static List<List<Object>> getBoxInfo(Barcode barcode, String suffix) {
public static List<List<Object>> getBoxInfo(Barcode barcode, String suffix, Integer type) {
List<List<Object>> resultList = new ArrayList<>();
......@@ -106,7 +110,10 @@ public class SpBoxUtil {
String boxStr = barcode.getBarcode();
List<List<Object>> pars = new ArrayList<>();
// 正在执行的任务的details
List<SpareNoDetail> activeDetails = getActiveDetails();
List<SpareNoDetail> activeDetails = getActiveDetails(type);
if (ObjectUtil.isEmpty(activeDetails)) {
return null;
}
for (int i = 1; i <= 6; i++) {
List<Object> par = new ArrayList<>();
String materialBarcode = boxStr + "-0" + i;
......@@ -114,6 +121,8 @@ public class SpBoxUtil {
for (SpareNoDetail activeDetail : activeDetails) {
if (activeDetail.getPartno().equals(partNumber)) {
par.add(activeDetail.getInQty()); // 该pn总共需要的数量
}else {
par.add(0);
}
}
par.add(getAmount(subCodeList, materialBarcode)); //数量
......@@ -122,6 +131,8 @@ public class SpBoxUtil {
for (SpareNoDetail activeDetail : activeDetails) {
if (activeDetail.getPartno().equals(partNumber)) {
par.add(activeDetail.getAlrInQty()); // 该pn已完成数量
}else {
par.add(0);
}
}
pars.add(par);
......@@ -129,37 +140,37 @@ public class SpBoxUtil {
if (boxStr.startsWith("CS")) {
if ("A".equals(suffix)) {
resultList.add(pars.get(2));
resultList.add(pars.get(4));
resultList.add(pars.get(6));
resultList.add(pars.get(1));
resultList.add(pars.get(3));
resultList.add(pars.get(5));
resultList.add(pars.get(0));
resultList.add(pars.get(2));
resultList.add(pars.get(4));
} else if ("B".equals(suffix)) {
resultList.add(pars.get(4));
resultList.add(pars.get(2));
resultList.add(pars.get(0));
resultList.add(pars.get(5));
resultList.add(pars.get(3));
resultList.add(pars.get(1));
resultList.add(pars.get(6));
resultList.add(pars.get(4));
resultList.add(pars.get(2));
}
} else if (boxStr.startsWith("CB")) {
if ("A".equals(suffix)) {
resultList.add(pars.get(2));
resultList.add(pars.get(4));
resultList.add(pars.get(1));
resultList.add(pars.get(3));
resultList.add(pars.get(0));
resultList.add(pars.get(2));
} else if ("B".equals(suffix)) {
resultList.add(pars.get(2));
resultList.add(pars.get(0));
resultList.add(pars.get(3));
resultList.add(pars.get(1));
resultList.add(pars.get(4));
resultList.add(pars.get(2));
}
} else if (boxStr.startsWith("CM")) {
if ("A".equals(suffix)) {
resultList.add(pars.get(1));
resultList.add(pars.get(0));
} else if ("B".equals(suffix)) {
resultList.add(pars.get(1));
resultList.add(pars.get(0));
}
}
return resultList;
......
......@@ -259,12 +259,16 @@ public class SpareNoCache {
for (String type :
boxTypes) {
int count = SpBoxUtil.GetBoxSubCount(type);
emptyPos = storagePosManager.findEmptyBoxToPutIn(storageIdList, pn, excludePosIds, dataCache.getCheckOutType(), type, count);
emptyPos = storagePosManager.findEmptyBoxToPutIn(storageIdList, excludePosIds, dataCache.getCheckOutType(), type, count);
emptyBox = emptyPos.getBarcode();
if (emptyPos != null) {
newPn.setBarcode(emptyBox.getBarcode() + "-" + emptyBox.getSubCodeList().size());
newPn = barcodeManager.saveBarcode(newPn);
newPn.setBarcode(emptyBox.getBarcode() + "-" + (emptyBox.getSubCodeList() == null ? 1 : emptyBox.getSubCodeList().size()));
newPn = barcodeManager.save(newPn);
// newPn = barcodeManager.saveBarcode(newPn);
List<Barcode> subL = emptyBox.getSubCodeList();
if (subL == null) {
subL = new ArrayList<>();
}
subL.add(newPn);
emptyBox.setSubCodeList(subL);
emptyBox.setOut(false);
......@@ -288,7 +292,8 @@ public class SpareNoCache {
Barcode barcode = pos.getBarcode();
log.info("入库单" + orderNo + ", 为库位=" + pos.getPosName() + ",料箱=" + barcode.getBarcode() + "生成出库任务:" + index);
barcodeManager.saveBarcode(barcode);
barcodeManager.save(barcode);
// barcodeManager.saveBarcode(barcode);
storagePosManager.save(pos);
Storage storage = dataCache.getStorageById(pos.getStorageId());
......@@ -313,6 +318,7 @@ public class SpareNoCache {
} catch (Exception exception) {
log.error("执行ReturnInventoryNo 出错: " + exception.toString());
exception.printStackTrace();
}
return "";
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!