This commit is contained in:
15066119699 2025-03-14 14:22:08 +08:00
parent 5af579e36a
commit 507feb9219
4 changed files with 75 additions and 24 deletions

View File

@ -33,7 +33,7 @@ public class AppConstants {
public static final String OUT_ORDER_STATUS_0 = "0";
public static final String OUT_ORDER_STATUS_1 = "1";
public static final String OUT_ORDER_STATUS_2 = "2";
//1:出库 2 9:移库 4:拣选
//1:入库 2 9:移库 4:拣选
public static final Integer TASK_TYPE_OUT = 2;
public static final Integer TASK_TYPE_IN = 1;
public static final Integer TASK_TYPE_TRANSFER = 9;

View File

@ -19,6 +19,9 @@ public class AppLocation extends BaseEntity
* 主键
*/
private Long id;
/** 库位编码 */
@Excel(name = "库位编码")
private String locationId;
/**
*
*/
@ -33,9 +36,7 @@ public class AppLocation extends BaseEntity
@Excel(name = "货架层")
private Integer wLayer;
/** 库位编码 */
@Excel(name = "库位编码")
private String locationId;
/** 备注 */
@Excel(name = "备注")

View File

@ -9,11 +9,16 @@ import java.util.stream.Collectors;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.app.domain.AppLocation;
import com.ruoyi.app.domain.AppStock;
import com.ruoyi.app.domain.AppTask;
import com.ruoyi.app.mapper.AppLocationMapper;
import com.ruoyi.app.mapper.AppStockMapper;
import com.ruoyi.app.mapper.AppTaskMapper;
import com.ruoyi.app.service.IAppLocationService;
import com.ruoyi.common.constant.AppConstants;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -28,11 +33,16 @@ import org.springframework.transaction.annotation.Transactional;
*/
@Service
public class AppLocationServiceImpl implements IAppLocationService {
private static final Logger log = LoggerFactory.getLogger(AppLocationServiceImpl.class);
private static final Logger logger = LoggerFactory.getLogger(AppLocationServiceImpl.class);
@Autowired
private AppLocationMapper appLocationMapper;
@Autowired
private AppStockMapper appStockMapper;
@Autowired
private AppTaskMapper appTaskMapper;
/**
* 查询请填写功能名称
*
@ -128,28 +138,59 @@ public class AppLocationServiceImpl implements IAppLocationService {
locationQuery.setLocationStatus(0);
locationQuery.setIsLock(0);
// todo 先放进二深度后
locationQuery.setwDepth(2);
// locationQuery.setwDepth(2);
List<AppLocation> appLocationList = appLocationMapper.selectAppLocationList(locationQuery);
if (appLocationList == null || appLocationList.isEmpty()) {
return null;
}
// 结果库位
AppLocation resultLocation = null;
// 可用库位列表
// List<AppLocation> availableLocationList = appLocationList.stream().filter(item ->
// item.getIsWorking() == 0 && item.getIsLock() == 0 && item.getLocationStatus() == 0).sorted(Comparator
// .comparingInt(AppLocation::getwCol).thenComparingInt(AppLocation::getwLayer).thenComparingInt(AppLocation::getwDepth)).collect(Collectors.toList());
// // 排序
// for (AppLocation appLocation : availableLocationList) {
// if (appLocation.getIsWorking() == 1 || appLocation.getIsLock() == 1 || appLocation.getLocationStatus() == 1) {
// continue;
// }
// if (isMaxDepthAvailable(appLocationList, appLocation)) {
// resultLocation = appLocation;
// break;
// }
// }
return appLocationList.get(0);
for(AppLocation appLocation1 : appLocationList) {
String locId = appLocation1.getLocationId();
AppLocation appLocation = appLocationMapper.selectAppLocationByLocationId(locId);
if (appLocation.getwDepth() == 2) {
//判断01是否有货
String locationId = locId.substring(0, locId.length() - 1) + "1";
List<AppTask> appTasks = getAppTaskByVehicleId(null, locationId);
if (!CollectionUtils.isEmpty(appTasks)) {
logger.error(locationId + "有任务执行,请稍后再试");
throw new RuntimeException(locationId + "有任务执行,请稍后再试!");
}
AppLocation areaLocation = new AppLocation();
areaLocation.setLocationStatus(1);
areaLocation.setLocationId(locationId);
List<AppLocation> tBaseStorageAreaLocations = appLocationMapper.selectAppLocationList(areaLocation);
if (!tBaseStorageAreaLocations.isEmpty()) {
AppStock AppStock1 = new AppStock();
AppStock1.setLocationId(locationId);
List<AppStock> tMiStocks1 = appStockMapper.selectAppStockList(AppStock1);
if (!tMiStocks1.isEmpty()) {
continue;
}
throw new RuntimeException("库位状态异常:"+ locationId);
} else {
AppStock tMiStock1 = new AppStock();
tMiStock1.setLocationId(locationId);
List<AppStock> tMiStocks1 = appStockMapper.selectAppStockList(tMiStock1);
if (!tMiStocks1.isEmpty()) {
throw new RuntimeException("库位状态异常:"+ locationId);
}
resultLocation = appLocation1;
break;
}
}else{
AppStock tMiStock1 = new AppStock();
tMiStock1.setLocationId(locId);
List<AppStock> tMiStocks1 = appStockMapper.selectAppStockList(tMiStock1);
if (!tMiStocks1.isEmpty()) {
throw new RuntimeException("库位状态异常:"+ locId);
}
resultLocation = appLocation1;
}
}
return resultLocation;
}
// @Override
@ -185,7 +226,16 @@ public class AppLocationServiceImpl implements IAppLocationService {
// return locationId;
//
// }
private List<AppTask> getAppTaskByVehicleId(String vehicleId,String locationId) {
AppTask appTask =new AppTask();
appTask.setVehicleId(vehicleId);
appTask.setLocationId(locationId);
if(StringUtils.isBlank(locationId)) {
appTask.setTaskType(AppConstants.TASK_TYPE_OUT);
}
//判断该托盘是否产生任务
return appTaskMapper.selectAppTaskList(appTask);
}
/**
* 是否是最内层可用库位
*
@ -292,7 +342,7 @@ public class AppLocationServiceImpl implements IAppLocationService {
failureNum++;
String msg = "<br/>" + failureNum + "、库位 " + appLocation.getLocationId() + " 导入失败:";
failureMsg.append(msg + e.getMessage());
log.error(msg, e);
logger.error(msg, e);
}
}
if (failureNum > 0) {

View File

@ -66,8 +66,8 @@
</where>
order by
w_layer asc,
w_col asc,
w_depth desc,
w_col asc,
w_row asc
</select>