Commit 8a69e21b zshaohui

smdbox方舱 修改

1 个父辈 7c935ae2
......@@ -22,8 +22,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.4</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
......
......@@ -14,6 +14,16 @@ public class VerticalBoxOperateBean {
private List<StoragePos> extendPosList;
private int partitionAmount = 0;
public int getPartitionAmount() {
return partitionAmount;
}
public void setPartitionAmount(int partitionAmount) {
this.partitionAmount = partitionAmount;
}
public DataLog getCurrentTask() {
return currentTask;
}
......
package com.myproject.bean.storage;
import com.myproject.bean.update.StoragePos;
import java.util.List;
public class XlStoragePos {
/**
* 箱子号
*/
private String posName;
private String posId;
private int partitionAmount = 0;
/**
* 隔口号
*/
private List<Partition> partitionList;
public int getPartitionAmount() {
return partitionAmount;
}
public void setPartitionAmount(int partitionAmount) {
this.partitionAmount = partitionAmount;
}
public String getPosName() {
return posName;
}
public void setPosName(String posName) {
this.posName = posName;
}
public String getPosId() {
return posId;
}
public void setPosId(String posId) {
this.posId = posId;
}
public List<Partition> getPartitionList() {
return partitionList;
}
public void setPartitionList(List<Partition> partitionList) {
this.partitionList = partitionList;
}
public static class Partition {
private String partition;
private List<StoragePos> storagePosList;
public String getPartition() {
return partition;
}
public void setPartition(String partition) {
this.partition = partition;
}
public List<StoragePos> getStoragePosList() {
return storagePosList;
}
public void setStoragePosList(List<StoragePos> storagePosList) {
this.storagePosList = storagePosList;
}
}
}
......@@ -51,6 +51,32 @@ public class StoragePos extends BaseMongoBean {
*/
private List<String> mergePosList;
/**
* 隔口
*/
private String partition;
/**
* 隔口数量
*/
private int partitionAmount = 1;
public int getPartitionAmount() {
return partitionAmount;
}
public void setPartitionAmount(int partitionAmount) {
this.partitionAmount = partitionAmount;
}
public String getPartition() {
return partition;
}
public void setPartition(String partition) {
this.partition = partition;
}
public Barcode getBarcode() {
return barcode;
}
......
......@@ -126,4 +126,8 @@ public class BoxStatusBean {
public String getPosId(){
return data.get("posId");
}
public String getDoor(){
return data.get("door");
}
}
......@@ -111,4 +111,8 @@ public interface IStoragePosManager extends IManager<StoragePos> {
List<PlateSizeBean> getStoragePosUsage(String storageId);
List<StoragePos> getSameSizeContinuityEmptyPosList(Storage storage, Barcode barcode) throws ValidateException;
List<StoragePos> findusedByStorageId(String id);
void updatePosPartitionAmount(String posName, String partitionAmount);
}
......@@ -25,6 +25,7 @@ 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.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
import java.util.*;
......@@ -639,6 +640,25 @@ public class StoragePosManagerImpl implements IStoragePosManager {
return new ArrayList<>();
}
@Override
public List<StoragePos> findusedByStorageId(String storageId) {
Criteria c = Criteria.where("used").is(true)
.and("enabled").is(true);//可用;
if (!Strings.isNullOrEmpty(storageId)) {
c = c.and("storageId").is(storageId);
}
Query query = new Query(c);
query.with(new Sort(Sort.Direction.ASC, "updateDate"));
return storagePosDao.findByQuery(query);
}
@Override
public void updatePosPartitionAmount(String posName, String partitionAmount) {
Query query = new Query(Criteria.where("posName").is(posName));
Update update = Update.update("partitionAmount", partitionAmount);
storagePosDao.updateMulti(query, update);
}
/**
* 获取下一库位的库位名(后缀数字+1)
*/
......
package com.myproject.webapp.controller.storage;
import com.mongodb.util.JSON;
import com.myproject.bean.CodeBean;
import com.myproject.bean.json.VerticalBoxOperateBean;
import com.myproject.bean.storage.XlStoragePos;
import com.myproject.bean.update.*;
import com.myproject.dao.mongo.IDataLogDao;
import com.myproject.exception.ValidateException;
......@@ -13,6 +15,7 @@ import com.myproject.webapp.controller.webService.DataCache;
import com.myproject.webapp.controller.webService.ITaskService;
import com.myproject.webapp.controller.webService.boxHandler.SmdXlBoxHandler;
import com.myproject.webapp.controller.webService.boxHandler.VerticalBoxHandler;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -20,10 +23,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -84,11 +85,52 @@ public class SmdXLController extends BaseController{
*/
@RequestMapping("/service/store/xl/storagePosList")
@ResponseBody
public List<StoragePos> checkAll(HttpServletRequest request){
public List<XlStoragePos> checkAll(HttpServletRequest request) {
String cid = request.getParameter("cid");
Storage storage = dataCache.getStorage(cid);
List<StoragePos> notEmptyPosList = storagePosManager.findNotEmptyByStorageId(storage.getId());
return notEmptyPosList;
List<StoragePos> notEmptyPosList = storagePosManager.findusedByStorageId(storage.getId());
//提取箱子号
List<XlStoragePos> xlStoragePosList = notEmptyPosList.stream().map(item -> {
XlStoragePos xlStoragePos = new XlStoragePos();
String hostPosId = item.getHostPosId();
if (StringUtils.isNotBlank(hostPosId)) {
StoragePos storagePos = storagePosManager.get(hostPosId);
if (storagePos != null) {
xlStoragePos.setPosId(storagePos.getId());
xlStoragePos.setPosName(storagePos.getPosName());
}
} else {
xlStoragePos.setPartitionAmount(item.getPartitionAmount());
xlStoragePos.setPosId(item.getId());
xlStoragePos.setPosName(item.getPosName());
}
return xlStoragePos;
}).collect(Collectors.toList());
xlStoragePosList = xlStoragePosList.stream().collect(Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(
Comparator.comparing(p -> p.getPosId()))), ArrayList::new));
//2.找到隔口信息
if (xlStoragePosList != null && !xlStoragePosList.isEmpty()) {
for (XlStoragePos xlStoragePos : xlStoragePosList) {
List<String> partitionStrList = notEmptyPosList.stream().filter(item -> {
return xlStoragePos.getPosId().equals(item.getHostPosId()) && StringUtils.isNotBlank(item.getPartition());
}).map(item -> {
return item.getPartition();
}).collect(Collectors.toList());
partitionStrList = partitionStrList.stream().distinct().collect(Collectors.toList());
//3.整合隔口下的物料信息
List<XlStoragePos.Partition> partitionList = new ArrayList<>();
for (String partitionStr : partitionStrList) {
XlStoragePos.Partition partition = new XlStoragePos.Partition();
List<StoragePos> storagePosList = notEmptyPosList.stream().filter(item -> partitionStr.equals(item.getPartition()) && xlStoragePos.getPosId().equals(item.getHostPosId())).collect(Collectors.toList());
partition.setPartition(partitionStr);
partition.setStoragePosList(storagePosList);
partitionList.add(partition);
}
xlStoragePos.setPartitionList(partitionList);
}
}
return xlStoragePosList;
}
/**
......@@ -148,21 +190,22 @@ public class SmdXLController extends BaseController{
}
@RequestMapping("/service/store/xl/exePutIn")
@ResponseBody
public String exePutIn(HttpServletRequest request){
public String exePutIn(HttpServletRequest request) {
String cid = request.getParameter("cid");
String doorInfo = request.getParameter("door");
DataLog currentTask = smdXlBoxHandler.getCurrentTask(cid);
if(currentTask != null){
String posName = request.getParameter("posName");
DataLog currentTask = smdXlBoxHandler.getCurrentTask(cid,posName);
if (currentTask != null) {
DataLog putInTask = currentTask;
log.info(currentTask.getPosName()+"开始回库");
if(currentTask.isPutInTask()){
log.info(currentTask.getPosName() + "开始回库");
if (currentTask.isPutInTask()) {
}else{
} else {
StoragePos pos = storagePosManager.findOneById(putInTask.getPosId());
if(pos.isExpandPos()){
if (pos.isExpandPos()) {
pos = storagePosManager.findOneById(pos.getHostPosId());
}
if(pos != null){
if (pos != null) {
putInTask = new DataLog();
putInTask.setType(StorageConstants.OP.PUT_IN);
putInTask.setCid(currentTask.getCid());
......@@ -215,9 +258,13 @@ public class SmdXLController extends BaseController{
posOutTask.setStatus(StorageConstants.OP_STATUS.WAIT.name());
posOutTask.setCid(cid);
Barcode barcode = pos.getBarcode();
if (barcode != null) {
posOutTask.setPartNumber(barcode.getPartNumber());
posOutTask.setBarcode(barcode.getBarcode());
posOutTask.setNum(barcode.getAmount());
} else {
posOutTask.setBarcode(pos.getPosName());
}
posOutTask.setStorageId(storage.getId());
posOutTask.setStorageName(storage.getName());
posOutTask.setPosId(pos.getId());
......@@ -243,6 +290,8 @@ public class SmdXLController extends BaseController{
String codeStr = request.getParameter("code");
String posName = request.getParameter("pos");
String cid = request.getParameter("cid");
String partition = request.getParameter("partition");
String partitionAmount = request.getParameter("partitionAmount");
DataLog currentTask = smdXlBoxHandler.getCurrentTask(cid);
StoragePos hostPos = storagePosManager.getByPosName(posName);
......@@ -306,6 +355,7 @@ public class SmdXLController extends BaseController{
existBarcode.setAmount(oldAmount + opQty);
existBarcode = barcodeManager.save(existBarcode);
existPnPos.setBarcode(existBarcode);
existPnPos.setPartition(partition);
storagePosManager.save(existPnPos);
finishTask(existPnPos, opType, currentTask, existBarcode, opQty);
......@@ -333,6 +383,7 @@ public class SmdXLController extends BaseController{
StoragePos posToPut = getOrCreateNewPos(hostPos, barcode.getId());
posToPut.setUsed(true);
posToPut.setBarcode(barcode);
posToPut.setPartition(partition);
storagePosManager.save(posToPut);
finishTask(posToPut, opType, currentTask, barcode, opQty);
......@@ -377,6 +428,7 @@ public class SmdXLController extends BaseController{
StoragePos posToPut = getOrCreateNewPos(hostPos, barcode.getId());
posToPut.setUsed(true);
posToPut.setBarcode(barcode);
posToPut.setPartition(partition);
storagePosManager.save(posToPut);
finishTask(posToPut,opQty, currentTask, barcode, barcode.getAmount());
log.info("条码"+ barcode.getBarcode()+"["+barcode.getPartNumber() + "]入库到库位["+posToPut.getPosName()+"]数量:" + barcode.getAmount());
......@@ -443,6 +495,7 @@ public class SmdXLController extends BaseController{
}
StoragePos hostPos = storagePosManager.get(currentTask.getPosId());
operateBean.setPartitionAmount(hostPos.getPartitionAmount());
List<StoragePos> extendPosList = storagePosManager.getExtendPosList(hostPos.getId());
for (StoragePos storagePos : extendPosList) {
if(outTaskIdList.contains(storagePos.getId())){
......@@ -458,6 +511,21 @@ public class SmdXLController extends BaseController{
/**
* 修改库位中
* @param request
* @return
*/
@RequestMapping(value = "/service/store/xl/updatePosPartitionAmount")
@ResponseBody
public String updatePosPartitionAmount(HttpServletRequest request) {
String posName = request.getParameter("posName");
String partitionAmount = request.getParameter("partitionAmount");
storagePosManager.updatePosPartitionAmount(posName,partitionAmount);
return "";
}
/**
* 完成出入库任务
* @param operatePos 库位
* @param currentTask 当前任务
......
......@@ -70,8 +70,13 @@ public class SmdXlBoxHandler {
//判断是否存在
String newKey = cid;
if (operateTaskMap.get(cid) != null) {
DataLog dataLog = operateTaskMap.get(cid);
if (dataLog.getId().equals(task.getId())) {
} else {
newKey = cid + task.getId();
}
}
operateTaskMap.put(newKey, task);
}
}
......@@ -94,7 +99,9 @@ public class SmdXlBoxHandler {
for (DataLog queueTask : queueTasks) {
if(queueTask.isExecuting() && queueTask.getPosName().equals(posName)){
currentTask = queueTask;
String doorInfo = statusBean.getFromData("door");
//String doorInfo = statusBean.getFromData("door");
String doorInfo = boxStatus.getData().get("door");
log.info(currentTask.getPosName()+"---door:"+doorInfo);
if(doorInfo == null){
doorInfo = "1";
}
......@@ -104,10 +111,16 @@ public class SmdXlBoxHandler {
}
}
DataLog cacheTask = operateTaskMap.get(cid);
if(currentTask != null){
if(cacheTask == null || !cacheTask.getId().equals(currentTask.getId())){
updateCurrentTask(currentTask.getCid(),currentTask);
if (currentTask != null) {
/* if (cacheTask != null) {
if (cacheTask.getId().equals(currentTask.getId())) {
updateCurrentTask(currentTask.getCid(), currentTask);
}
}
if (cacheTask == null || !cacheTask.getId().equals(currentTask.getId())) {
updateCurrentTask(currentTask.getCid(), currentTask);
}*/
updateCurrentTask(currentTask.getCid(), currentTask);
}
}
}
......@@ -154,4 +167,27 @@ public class SmdXlBoxHandler {
}
public DataLog getCurrentTask(String cid, String posName) {
DataLog task = null;
if (operateTaskMap.get(cid) == null) {
for (Map.Entry<String, DataLog> taskEntry : operateTaskMap.entrySet()) {
if (taskEntry.getKey().contains(cid)) {
if (posName.equals(taskEntry.getValue().getPosName())) {
task = taskEntry.getValue();
break;
}
}
}
if (task != null) {
operateTaskMap.remove(cid + task.getId());
operateTaskMap.put(cid, task);
}
}
if (operateTaskMap.get(cid) != null) {
if (posName.equals(operateTaskMap.get(cid).getPosName())) {
task = operateTaskMap.get(cid);
}
}
return task;
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!