Commit ebb0f334 LN

入库增加就近坐标查找功能。

1 个父辈 05f11d7f
......@@ -4,12 +4,14 @@ import com.google.common.base.Strings;
import com.myproject.bean.BaseMongoBean;
import org.springframework.data.mongodb.core.index.GeoSpatialIndexType;
import org.springframework.data.mongodb.core.index.GeoSpatialIndexed;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.List;
/**
* Created by kangmor on 2015/12/4.
*/
@Document
public class StoragePos extends BaseMongoBean {
private String storageId;
......
......@@ -46,6 +46,8 @@ public interface IStoragePosManager extends IManager<StoragePos> {
StoragePos getEmptyPosByStorage(Storage storage, Barcode barcode, Collection<String> excludePosIds) throws ValidateException;
StoragePos getEmptyPosByStorage(Storage storage, Barcode barcode, Collection<String> excludePosIds, String lastPosId) throws ValidateException;
int countTotalStorageSize(String storageId);
int countEmptyStorageSize(String storageId);
......
......@@ -15,6 +15,7 @@ import com.myproject.manager.IStorageManager;
import com.myproject.manager.IStoragePosManager;
import com.myproject.util.DateUtil;
import com.myproject.util.PLATE_SIZE;
import com.myproject.util.PointUtil;
import com.myproject.util.StorageConstants;
import com.myproject.webapp.controller.webService.DataCache;
import org.apache.commons.lang.StringUtils;
......@@ -22,11 +23,14 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.geo.Point;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.awt.*;
import java.util.*;
import java.util.List;
/**
* Created by kangmor on 2015/12/4.
......@@ -139,9 +143,12 @@ public class StoragePosManagerImpl implements IStoragePosManager {
// query.limit(1);
// return storagePosDao.findByQuery(query);
// }
@Override
public StoragePos getEmptyPosByStorage(Storage storage, Barcode barcode, Collection<String> excludePosIds) throws ValidateException {
return getEmptyPosByStorage(storage, barcode, excludePosIds, "");
}
@Override
public StoragePos getEmptyPosByStorage(Storage storage, Barcode barcode, Collection<String> excludePosIds,String lastPosId) throws ValidateException {
if(storage == null){
throw new ValidateException("指定的料仓不存在");
......@@ -178,8 +185,14 @@ public class StoragePosManagerImpl implements IStoragePosManager {
c = c.and("id").nin(excludePosIds);
}
Query query = new Query(c);
//优先放入最合适的位置(根据尺寸),相同尺寸按优先级排序
query.with(new Sort(Sort.Direction.ASC, "w").and(new Sort(Sort.Direction.ASC, "h")).and(new Sort(Sort.Direction.DESC, "priority")));
if(lastPosId==null||lastPosId.equals("")){
//优先放入最合适的位置(根据尺寸),相同尺寸按优先级排序
query.with(new Sort(Sort.Direction.ASC, "w").and(new Sort(Sort.Direction.ASC, "h")).and(new Sort(Sort.Direction.DESC, "priority")));
}else{
Point point= PointUtil.getPosPoint(lastPosId,false);
query.addCriteria(Criteria.where("coordinate").nearSphere(point));
}
StoragePos pos = storagePosDao.findOne(query);
return pos;
}
......
......@@ -14,7 +14,14 @@ public class PointUtil {
public static Point getPosPoint(String posId ) {
return getPosPoint(posId,true );
}
public static Point getPosPoint(String posId, boolean useDrawerPoint) {
/**
* 获取坐标
* @param posId 库位号
* @param isUpdatePos true=更新库位坐标。false=查询使用
* @return
*/
public static Point getPosPoint(String posId, boolean isUpdatePos) {
// 库位号格式:
// 例:05AA03040102
// 05:表示料仓编号,01-08
......@@ -31,9 +38,18 @@ public class PointUtil {
String typeStr = posId.substring(2, 4);
if (typeStr.equals("AA")) {
storageNum = storage * 10 + 1;
if(isUpdatePos){
storageNum = storage * 10 + 1;
}else{
storageNum = storage * 10 + 2;
}
} else {
storageNum = storage * 10 + 2;
if(isUpdatePos){
storageNum = storage * 10 + 2;
}else{
storageNum = storage * 10 + 1;
}
}
double row = Integer.parseInt(posId.substring(4, 6));
double column = Integer.parseInt(posId.substring(6, 8));
......@@ -41,12 +57,14 @@ public class PointUtil {
double x = storageNum + column / 100;
double y = storageNum + row / 1000;
if (useDrawerPoint) {
double drawerRow = Integer.parseInt(posId.substring(8, 10));
double drawerColumn = Integer.parseInt(posId.substring(10, 12));
x += drawerColumn / 100 / 1000;
y += +drawerRow / 1000 / 100;
double drawerRow=1;
double drawerColumn=1;
if (isUpdatePos) {
drawerRow = Integer.parseInt(posId.substring(8, 10));
drawerColumn = Integer.parseInt(posId.substring(10, 12));
}
x += drawerColumn / 100 / 1000;
y += +drawerRow / 1000 / 100;
p = new Point(x, y);
}
......
......@@ -196,7 +196,7 @@ public class AccShelfController extends BaseController {
}
List<Storage> storageList = Lists.newArrayList(storage);
StoragePos pos = taskService.findEmptyPosForPutIn(storageList, barcode,"");
StoragePos pos = taskService.findEmptyPosForPutIn(storageList, barcode,"","");
int delayCloseTime = 30000;
String color = "red";
if(pos != null){
......
......@@ -22,7 +22,7 @@ import java.util.Map;
public interface ITaskService {
StoragePos findEmptyPosForPutIn(List<Storage> storageList, Barcode barcode, String inRFID) throws ValidateException;
StoragePos findEmptyPosForPutIn(List<Storage> storageList, Barcode barcode, String inRFID,String lastPosId) throws ValidateException;
/**
* 取消单个任务
......
......@@ -558,6 +558,7 @@ public class StorageDataController extends BaseController {
String cids = request.getParameter("cids");
String rfid = request.getParameter("rfid");
String rfidLoc = request.getParameter("rfidLoc");
String lastPosId=request.getParameter("lastPosId");
lineMsg = "";
// if(Strings.isNullOrEmpty(cids)){
......@@ -642,7 +643,7 @@ public class StorageDataController extends BaseController {
}
}
StoragePos pos = taskService.findEmptyPosForPutIn(storageList,barcode, rfid);
StoragePos pos = taskService.findEmptyPosForPutIn(storageList,barcode, rfid,lastPosId);
if(pos != null){
......
......@@ -443,7 +443,7 @@ public class TaskService implements ITaskService {
* @return
*/
@Override
public StoragePos findEmptyPosForPutIn(List<Storage> storageList, Barcode barcode, String inRFID) throws ValidateException{
public StoragePos findEmptyPosForPutIn(List<Storage> storageList, Barcode barcode, String inRFID,String lastPosId) throws ValidateException{
verifyBarcodePutIn(storageList ,barcode, inRFID);
//查找任务数最少的料仓
......@@ -551,16 +551,16 @@ public class TaskService implements ITaskService {
});
}
return findEmptyPosInStorages(barcode, availbleStorageList, storageTaskCountMap);
return findEmptyPosInStorages(barcode, availbleStorageList, storageTaskCountMap,lastPosId);
}
private synchronized StoragePos findEmptyPosInStorages(Barcode barcode, List<Storage> availbleStorageList, final Map<String,Integer> executingTaskCountMap){
private synchronized StoragePos findEmptyPosInStorages(Barcode barcode, List<Storage> availbleStorageList, final Map<String,Integer> executingTaskCountMap,String lastPosId){
for (Storage storage : availbleStorageList) {
try{
Collection<String> operatingPosIds = excludePosIds();
log.debug("尝试从["+storage.getCid()+"]中为["+barcode.getBarcode()+"]查找空位");
StoragePos pos = storagePosManager.getEmptyPosByStorage(storage, barcode , operatingPosIds);
StoragePos pos = storagePosManager.getEmptyPosByStorage(storage, barcode , operatingPosIds,lastPosId);
if(pos != null){
return pos;
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!