Commit 8a69e21b zshaohui

smdbox方舱 修改

1 个父辈 7c935ae2
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>2.4</version> <version>2.4</version>
<configuration> <configuration>
<source>${java.version}</source> <source>8</source>
<target>${java.version}</target> <target>8</target>
</configuration> </configuration>
</plugin> </plugin>
......
...@@ -14,6 +14,16 @@ public class VerticalBoxOperateBean { ...@@ -14,6 +14,16 @@ public class VerticalBoxOperateBean {
private List<StoragePos> extendPosList; private List<StoragePos> extendPosList;
private int partitionAmount = 0;
public int getPartitionAmount() {
return partitionAmount;
}
public void setPartitionAmount(int partitionAmount) {
this.partitionAmount = partitionAmount;
}
public DataLog getCurrentTask() { public DataLog getCurrentTask() {
return currentTask; 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 { ...@@ -51,6 +51,32 @@ public class StoragePos extends BaseMongoBean {
*/ */
private List<String> mergePosList; 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() { public Barcode getBarcode() {
return barcode; return barcode;
} }
......
...@@ -126,4 +126,8 @@ public class BoxStatusBean { ...@@ -126,4 +126,8 @@ public class BoxStatusBean {
public String getPosId(){ public String getPosId(){
return data.get("posId"); return data.get("posId");
} }
public String getDoor(){
return data.get("door");
}
} }
...@@ -111,4 +111,8 @@ public interface IStoragePosManager extends IManager<StoragePos> { ...@@ -111,4 +111,8 @@ public interface IStoragePosManager extends IManager<StoragePos> {
List<PlateSizeBean> getStoragePosUsage(String storageId); List<PlateSizeBean> getStoragePosUsage(String storageId);
List<StoragePos> getSameSizeContinuityEmptyPosList(Storage storage, Barcode barcode) throws ValidateException; 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; ...@@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort; 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.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
...@@ -639,6 +640,25 @@ public class StoragePosManagerImpl implements IStoragePosManager { ...@@ -639,6 +640,25 @@ public class StoragePosManagerImpl implements IStoragePosManager {
return new ArrayList<>(); 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) * 获取下一库位的库位名(后缀数字+1)
*/ */
......
package com.myproject.webapp.controller.storage; package com.myproject.webapp.controller.storage;
import com.mongodb.util.JSON;
import com.myproject.bean.CodeBean; import com.myproject.bean.CodeBean;
import com.myproject.bean.json.VerticalBoxOperateBean; import com.myproject.bean.json.VerticalBoxOperateBean;
import com.myproject.bean.storage.XlStoragePos;
import com.myproject.bean.update.*; import com.myproject.bean.update.*;
import com.myproject.dao.mongo.IDataLogDao; import com.myproject.dao.mongo.IDataLogDao;
import com.myproject.exception.ValidateException; import com.myproject.exception.ValidateException;
...@@ -13,6 +15,7 @@ import com.myproject.webapp.controller.webService.DataCache; ...@@ -13,6 +15,7 @@ import com.myproject.webapp.controller.webService.DataCache;
import com.myproject.webapp.controller.webService.ITaskService; import com.myproject.webapp.controller.webService.ITaskService;
import com.myproject.webapp.controller.webService.boxHandler.SmdXlBoxHandler; import com.myproject.webapp.controller.webService.boxHandler.SmdXlBoxHandler;
import com.myproject.webapp.controller.webService.boxHandler.VerticalBoxHandler; import com.myproject.webapp.controller.webService.boxHandler.VerticalBoxHandler;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
...@@ -20,10 +23,8 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -20,10 +23,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.util.*;
import java.util.Collection; import java.util.stream.Collectors;
import java.util.Date;
import java.util.List;
/** /**
...@@ -84,11 +85,52 @@ public class SmdXLController extends BaseController{ ...@@ -84,11 +85,52 @@ public class SmdXLController extends BaseController{
*/ */
@RequestMapping("/service/store/xl/storagePosList") @RequestMapping("/service/store/xl/storagePosList")
@ResponseBody @ResponseBody
public List<StoragePos> checkAll(HttpServletRequest request){ public List<XlStoragePos> checkAll(HttpServletRequest request) {
String cid = request.getParameter("cid"); String cid = request.getParameter("cid");
Storage storage = dataCache.getStorage(cid); Storage storage = dataCache.getStorage(cid);
List<StoragePos> notEmptyPosList = storagePosManager.findNotEmptyByStorageId(storage.getId()); List<StoragePos> notEmptyPosList = storagePosManager.findusedByStorageId(storage.getId());
return notEmptyPosList; //提取箱子号
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{ ...@@ -148,21 +190,22 @@ public class SmdXLController extends BaseController{
} }
@RequestMapping("/service/store/xl/exePutIn") @RequestMapping("/service/store/xl/exePutIn")
@ResponseBody @ResponseBody
public String exePutIn(HttpServletRequest request){ public String exePutIn(HttpServletRequest request) {
String cid = request.getParameter("cid"); String cid = request.getParameter("cid");
String doorInfo = request.getParameter("door"); String doorInfo = request.getParameter("door");
DataLog currentTask = smdXlBoxHandler.getCurrentTask(cid); String posName = request.getParameter("posName");
if(currentTask != null){ DataLog currentTask = smdXlBoxHandler.getCurrentTask(cid,posName);
if (currentTask != null) {
DataLog putInTask = currentTask; DataLog putInTask = currentTask;
log.info(currentTask.getPosName()+"开始回库"); log.info(currentTask.getPosName() + "开始回库");
if(currentTask.isPutInTask()){ if (currentTask.isPutInTask()) {
}else{ } else {
StoragePos pos = storagePosManager.findOneById(putInTask.getPosId()); StoragePos pos = storagePosManager.findOneById(putInTask.getPosId());
if(pos.isExpandPos()){ if (pos.isExpandPos()) {
pos = storagePosManager.findOneById(pos.getHostPosId()); pos = storagePosManager.findOneById(pos.getHostPosId());
} }
if(pos != null){ if (pos != null) {
putInTask = new DataLog(); putInTask = new DataLog();
putInTask.setType(StorageConstants.OP.PUT_IN); putInTask.setType(StorageConstants.OP.PUT_IN);
putInTask.setCid(currentTask.getCid()); putInTask.setCid(currentTask.getCid());
...@@ -215,9 +258,13 @@ public class SmdXLController extends BaseController{ ...@@ -215,9 +258,13 @@ public class SmdXLController extends BaseController{
posOutTask.setStatus(StorageConstants.OP_STATUS.WAIT.name()); posOutTask.setStatus(StorageConstants.OP_STATUS.WAIT.name());
posOutTask.setCid(cid); posOutTask.setCid(cid);
Barcode barcode = pos.getBarcode(); Barcode barcode = pos.getBarcode();
posOutTask.setPartNumber(barcode.getPartNumber()); if (barcode != null) {
posOutTask.setBarcode(barcode.getBarcode()); posOutTask.setPartNumber(barcode.getPartNumber());
posOutTask.setNum(barcode.getAmount()); posOutTask.setBarcode(barcode.getBarcode());
posOutTask.setNum(barcode.getAmount());
} else {
posOutTask.setBarcode(pos.getPosName());
}
posOutTask.setStorageId(storage.getId()); posOutTask.setStorageId(storage.getId());
posOutTask.setStorageName(storage.getName()); posOutTask.setStorageName(storage.getName());
posOutTask.setPosId(pos.getId()); posOutTask.setPosId(pos.getId());
...@@ -243,6 +290,8 @@ public class SmdXLController extends BaseController{ ...@@ -243,6 +290,8 @@ public class SmdXLController extends BaseController{
String codeStr = request.getParameter("code"); String codeStr = request.getParameter("code");
String posName = request.getParameter("pos"); String posName = request.getParameter("pos");
String cid = request.getParameter("cid"); String cid = request.getParameter("cid");
String partition = request.getParameter("partition");
String partitionAmount = request.getParameter("partitionAmount");
DataLog currentTask = smdXlBoxHandler.getCurrentTask(cid); DataLog currentTask = smdXlBoxHandler.getCurrentTask(cid);
StoragePos hostPos = storagePosManager.getByPosName(posName); StoragePos hostPos = storagePosManager.getByPosName(posName);
...@@ -306,6 +355,7 @@ public class SmdXLController extends BaseController{ ...@@ -306,6 +355,7 @@ public class SmdXLController extends BaseController{
existBarcode.setAmount(oldAmount + opQty); existBarcode.setAmount(oldAmount + opQty);
existBarcode = barcodeManager.save(existBarcode); existBarcode = barcodeManager.save(existBarcode);
existPnPos.setBarcode(existBarcode); existPnPos.setBarcode(existBarcode);
existPnPos.setPartition(partition);
storagePosManager.save(existPnPos); storagePosManager.save(existPnPos);
finishTask(existPnPos, opType, currentTask, existBarcode, opQty); finishTask(existPnPos, opType, currentTask, existBarcode, opQty);
...@@ -333,6 +383,7 @@ public class SmdXLController extends BaseController{ ...@@ -333,6 +383,7 @@ public class SmdXLController extends BaseController{
StoragePos posToPut = getOrCreateNewPos(hostPos, barcode.getId()); StoragePos posToPut = getOrCreateNewPos(hostPos, barcode.getId());
posToPut.setUsed(true); posToPut.setUsed(true);
posToPut.setBarcode(barcode); posToPut.setBarcode(barcode);
posToPut.setPartition(partition);
storagePosManager.save(posToPut); storagePosManager.save(posToPut);
finishTask(posToPut, opType, currentTask, barcode, opQty); finishTask(posToPut, opType, currentTask, barcode, opQty);
...@@ -353,7 +404,7 @@ public class SmdXLController extends BaseController{ ...@@ -353,7 +404,7 @@ public class SmdXLController extends BaseController{
//全部出库,禁用库位 //全部出库,禁用库位
existPnPos.setBarcode(null); existPnPos.setBarcode(null);
existPnPos.setEnabled(false); existPnPos.setEnabled(false);
}else{ }else{
existPnPos.setBarcode(existBarcode); existPnPos.setBarcode(existBarcode);
} }
storagePosManager.save(existPnPos); storagePosManager.save(existPnPos);
...@@ -377,6 +428,7 @@ public class SmdXLController extends BaseController{ ...@@ -377,6 +428,7 @@ public class SmdXLController extends BaseController{
StoragePos posToPut = getOrCreateNewPos(hostPos, barcode.getId()); StoragePos posToPut = getOrCreateNewPos(hostPos, barcode.getId());
posToPut.setUsed(true); posToPut.setUsed(true);
posToPut.setBarcode(barcode); posToPut.setBarcode(barcode);
posToPut.setPartition(partition);
storagePosManager.save(posToPut); storagePosManager.save(posToPut);
finishTask(posToPut,opQty, currentTask, barcode, barcode.getAmount()); finishTask(posToPut,opQty, currentTask, barcode, barcode.getAmount());
log.info("条码"+ barcode.getBarcode()+"["+barcode.getPartNumber() + "]入库到库位["+posToPut.getPosName()+"]数量:" + barcode.getAmount()); log.info("条码"+ barcode.getBarcode()+"["+barcode.getPartNumber() + "]入库到库位["+posToPut.getPosName()+"]数量:" + barcode.getAmount());
...@@ -443,6 +495,7 @@ public class SmdXLController extends BaseController{ ...@@ -443,6 +495,7 @@ public class SmdXLController extends BaseController{
} }
StoragePos hostPos = storagePosManager.get(currentTask.getPosId()); StoragePos hostPos = storagePosManager.get(currentTask.getPosId());
operateBean.setPartitionAmount(hostPos.getPartitionAmount());
List<StoragePos> extendPosList = storagePosManager.getExtendPosList(hostPos.getId()); List<StoragePos> extendPosList = storagePosManager.getExtendPosList(hostPos.getId());
for (StoragePos storagePos : extendPosList) { for (StoragePos storagePos : extendPosList) {
if(outTaskIdList.contains(storagePos.getId())){ if(outTaskIdList.contains(storagePos.getId())){
...@@ -458,6 +511,21 @@ public class SmdXLController extends BaseController{ ...@@ -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 operatePos 库位
* @param currentTask 当前任务 * @param currentTask 当前任务
......
...@@ -70,7 +70,12 @@ public class SmdXlBoxHandler { ...@@ -70,7 +70,12 @@ public class SmdXlBoxHandler {
//判断是否存在 //判断是否存在
String newKey = cid; String newKey = cid;
if (operateTaskMap.get(cid) != null) { if (operateTaskMap.get(cid) != null) {
newKey = cid + task.getId(); DataLog dataLog = operateTaskMap.get(cid);
if (dataLog.getId().equals(task.getId())) {
} else {
newKey = cid + task.getId();
}
} }
operateTaskMap.put(newKey, task); operateTaskMap.put(newKey, task);
} }
...@@ -94,7 +99,9 @@ public class SmdXlBoxHandler { ...@@ -94,7 +99,9 @@ public class SmdXlBoxHandler {
for (DataLog queueTask : queueTasks) { for (DataLog queueTask : queueTasks) {
if(queueTask.isExecuting() && queueTask.getPosName().equals(posName)){ if(queueTask.isExecuting() && queueTask.getPosName().equals(posName)){
currentTask = queueTask; 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){ if(doorInfo == null){
doorInfo = "1"; doorInfo = "1";
} }
...@@ -104,10 +111,16 @@ public class SmdXlBoxHandler { ...@@ -104,10 +111,16 @@ public class SmdXlBoxHandler {
} }
} }
DataLog cacheTask = operateTaskMap.get(cid); DataLog cacheTask = operateTaskMap.get(cid);
if(currentTask != null){ if (currentTask != null) {
if(cacheTask == null || !cacheTask.getId().equals(currentTask.getId())){ /* if (cacheTask != null) {
updateCurrentTask(currentTask.getCid(),currentTask); 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 { ...@@ -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!