From 6c3cc6842009f3897c3fb18bef8a6634fe653818 Mon Sep 17 00:00:00 2001
From: 1 <1@123>
Date: 星期三, 04 三月 2026 19:59:11 +0800
Subject: [PATCH] lsh#
---
rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/LocManageUtil.java | 224 ++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 171 insertions(+), 53 deletions(-)
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/LocManageUtil.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/LocManageUtil.java
index aca7d0c..da7af21 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/LocManageUtil.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/utils/LocManageUtil.java
@@ -1,7 +1,9 @@
package com.vincent.rsf.server.manager.utils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.vincent.rsf.framework.common.Cools;
import com.vincent.rsf.framework.common.SpringUtils;
+import com.vincent.rsf.framework.exception.CoolException;
import com.vincent.rsf.server.api.utils.LocUtils;
import com.vincent.rsf.server.manager.controller.dto.ExistDto;
import com.vincent.rsf.server.manager.controller.dto.OrderOutItemDto;
@@ -13,7 +15,6 @@
import com.vincent.rsf.server.manager.enums.LocStsType;
import org.apache.commons.lang3.StringUtils;
-import javax.swing.*;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@@ -21,21 +22,67 @@
public class LocManageUtil {
/**
- * @author Ryan
- * @description 鑾峰彇鐩爣搴撲綅, 鍖呭惈搴撲綅鑾峰彇绛栫暐
* @param
* @return
+ * @author Ryan
+ * @description 鑾峰彇鐩爣搴撲綅, 鍖呭惈搴撲綅鑾峰彇绛栫暐
* @time 2025/3/31 08:50
*/
public static String getTargetLoc(Long areaId) {
//TODO 搴撲綅绛栫暐鍚庣画鎺掓湡
+
+ return getTargetLoc(areaId, null);
+ }
+
+ public static String getTargetLoc(Long areaId, Long containerType,List<Integer> rowList) {
+
+ Long locType = containerType;
+ //TODO 搴撲綅绛栫暐鍚庣画鎺掓湡
LocService locService = SpringUtils.getBean(LocService.class);
Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>()
+ .eq(!Objects.isNull(locType), Loc::getType, locType)
.eq(Loc::getAreaId, areaId)
+ .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
+ .in(Objects.nonNull(rowList) && !rowList.isEmpty(), Loc::getRow, rowList)
.orderByAsc(Loc::getLev)
.orderByAsc(Loc::getCol)
.orderByAsc(Loc::getRow)
- .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type), false
+ .last("LIMIT 1")
+ );
+
+ return !Objects.isNull(loc) ? loc.getCode() : null;
+ }
+
+ public static String getTargetLoc(Long areaId, Long containerType) {
+ Long locType = containerType;
+// if (!Objects.isNull(containerType)) {
+// LocTypeService locService = SpringUtils.getBean(LocTypeService.class);
+// if (containerType.equals(ContainerType.CONTAINER_TYPE_NORMAL.val)) {
+// LocType low = locService.getOne(new LambdaQueryWrapper<LocType>()
+// .eq(LocType::getCode, "L"));
+// if (Objects.isNull(low)) {
+// throw new CoolException("搴綅椤炲瀷涓嶅瓨鍦紒锛�");
+// }
+// locType = low.getId();
+// } else {
+// LocType low = locService.getOne(new LambdaQueryWrapper<LocType>()
+// .eq(LocType::getCode, "H"));
+// if (Objects.isNull(low)) {
+// throw new CoolException("搴綅椤炲瀷涓嶅瓨鍦紒锛�");
+// }
+// locType = low.getId();
+// }
+// }
+ //TODO 搴撲綅绛栫暐鍚庣画鎺掓湡
+ LocService locService = SpringUtils.getBean(LocService.class);
+ Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>()
+ .eq(!Objects.isNull(locType), Loc::getType, locType)
+ .eq(Loc::getAreaId, areaId)
+ .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
+ .orderByAsc(Loc::getLev)
+ .orderByAsc(Loc::getCol)
+ .orderByAsc(Loc::getRow)
+ .last("LIMIT 1")
);
return !Objects.isNull(loc) ? loc.getCode() : null;
@@ -43,12 +90,12 @@
/**
- * @author Ryan
- * @description 鑾峰彇鐩爣绔欑偣
- * @param
- * @return
- * @time 2025/3/31 09:49
- */
+ * @param
+ * @return
+ * @author Ryan
+ * @description 鑾峰彇鐩爣绔欑偣
+ * @time 2025/3/31 09:49
+ */
public static String getTargetSite() {
//TODO 绔欑偣绛栫暐鍚庣画鎺掓湡
DeviceSiteService deviceSite = SpringUtils.getBean(DeviceSiteService.class);
@@ -58,6 +105,7 @@
/**
* 鍑哄簱绛栫暐锛�--銆堟晥鐜囦紭鍖栥��
+ *
* @param matnrCode
* @param splrBatch
* @param anfme
@@ -88,6 +136,7 @@
/**
* 鍑哄簱绛栫暐锛�--<鍏堣繘鍏堝嚭>
+ *
* @param matnrCode
* @param splrBatch
* @param anfme
@@ -97,7 +146,12 @@
LambdaQueryWrapper<LocItem> locItemQueryWrapper = new LambdaQueryWrapper<>();
locItemQueryWrapper.eq(LocItem::getMatnrCode, matnrCode);
locItemQueryWrapper.eq(StringUtils.isNotEmpty(splrBatch), LocItem::getBatch, splrBatch);
- locItemQueryWrapper.orderByAsc(LocItem::getCreateTime);
+ //濡傛灉鎵规涓嶄负绌猴紝鎸夋壒娆″厛鍚庡嚭搴�
+ if (StringUtils.isNotBlank(splrBatch)) {
+ locItemQueryWrapper.orderByAsc(LocItem::getBatch);
+ } else {
+ locItemQueryWrapper.orderByAsc(LocItem::getCreateTime);
+ }
String applySql = String.format(
"EXISTS (SELECT 1 FROM man_loc ml " +
"WHERE ml.use_status = '%s'" +
@@ -113,6 +167,7 @@
/**
* 鑾峰彇鍑哄簱搴撲綅淇℃伅
+ *
* @param params
* @param waveRule
* @return
@@ -121,8 +176,12 @@
LocService locService = SpringUtils.getBean(LocService.class);
LocItemService locItemService = SpringUtils.getBean(LocItemService.class);
DeviceSiteService deviceSiteService = SpringUtils.getBean(DeviceSiteService.class);
-
+ BasStationAreaService basStationAreaService = SpringUtils.getBean(BasStationAreaService.class);
+// List<BasStationArea> basStationAreas = basStationAreaService.list(new LambdaQueryWrapper<>());//
+ List<Loc> locList = new ArrayList<>();
List<OrderOutItemDto> list = new ArrayList<>();
+ //涓嶈绔欑偣閲嶅浣跨敤闂
+ List<BasStation> stations = new ArrayList<>();
Set<ExistDto> existDtos = new HashSet<>();
for (WaveToLocParams item : params) {
BigDecimal issued = new BigDecimal(item.getAnfme().toString())
@@ -145,62 +204,121 @@
for (LocItem locItem : locItems) {
Loc loc = locService.getById(locItem.getLocId());
- List<LocItem> itemList = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocCode, locItem.getLocCode()));
- if (issued.doubleValue() > 0) {
+ List<LocItem> itemList = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, loc.getId()));
+
+ if (issued.doubleValue() > 0 && locList.contains(loc)) {
+ for (OrderOutItemDto itemDto : list) {
+ if (itemDto.getLoc().equals(loc)) {
+ ExistDto existDto = new ExistDto().setBatch(locItem.getBatch()).setMatnr(locItem.getMatnrCode()).setLocNo(locItem.getLocCode());
+ if (existDtos.add(existDto)) {
+ locItem.setOutQty(issued.doubleValue() >= locItem.getAnfme() ? locItem.getAnfme() : issued.doubleValue());
+ locItem.setBarcode(loc.getBarcode())
+ .setSourceId(item.getWaveId())//娉㈡ID
+ .setSource(item.getItemId());//娉㈡鏄庣粏ID
+ itemDto.getLocItemList().add(locItem);
+ issued = issued.subtract(new BigDecimal(locItem.getAnfme().toString()));
+ }
+ break;
+ }
+ }
+ } else if (issued.doubleValue() > 0) {
ExistDto existDto = new ExistDto().setBatch(locItem.getBatch()).setMatnr(locItem.getMatnrCode()).setLocNo(locItem.getLocCode());
if (existDtos.add(existDto)) {
locItem.setOutQty(issued.doubleValue() >= locItem.getAnfme() ? locItem.getAnfme() : issued.doubleValue());
locItem.setBarcode(loc.getBarcode())
- .setSourceId(item.getWaveId())
- .setSource(item.getItemId());
+ .setSourceId(item.getWaveId())//娉㈡ID
+ .setSource(item.getItemId());//娉㈡鏄庣粏ID
OrderOutItemDto orderOutItemDto = new OrderOutItemDto();
- orderOutItemDto.setLocItem(locItem);
-
- List<DeviceSite> deviceSites = deviceSiteService.list(new LambdaQueryWrapper<DeviceSite>()
- .eq(DeviceSite::getChannel, loc.getChannel())
- .eq(DeviceSite::getType, issued.doubleValue() >= locItem.getAnfme() && itemList.size() == 1 ? TaskType.TASK_TYPE_OUT.type : TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)
- );
-
- if (!deviceSites.isEmpty()) {
- List<OrderOutItemDto.staListDto> maps = new ArrayList<>();
- for (DeviceSite sta : deviceSites) {
- OrderOutItemDto.staListDto staListDto = new OrderOutItemDto.staListDto();
- staListDto.setStaNo(sta.getSite());
- staListDto.setStaName(sta.getSite());
- maps.add(staListDto);
- }
- orderOutItemDto.setStaNos(maps);
- //榛樿鑾峰彇绗竴绔欑偣
- DeviceSite deviceSite = deviceSites.stream().findFirst().get();
- orderOutItemDto.setSiteNo(deviceSite.getSite());
+// orderOutItemDto.setLocItem(locItem);
+ orderOutItemDto.setLoc(loc);
+ orderOutItemDto.getLocItemList().add(locItem);
+ BasContainer containerType = getContainerType(loc.getBarcode());
+ List<BasStationArea> basStationAreas = basStationAreaService.list(new LambdaQueryWrapper<BasStationArea>()
+ .apply("JSON_CONTAINS(cross_zone_area, '{0}') = 1", loc.getAreaId())//鍙墽琛屽簱鍖哄尯鍖哄煙id
+ .apply("JSON_CONTAINS(container_type, '{0}') = 1", containerType)//瀹瑰櫒绫诲瀷
+// .apply("JSON_CONTAINS(station_alias, '\"{0}\"') = 1", null)//鍖哄煙鍖呭惈绔欑偣闆�
+ .eq(BasStationArea::getDeleted, 0));// 閫氬父闇�瑕佸姞涓婃湭鍒犻櫎鏉′欢
+ List<String> targSiteAreaList = new ArrayList<>();
+ for (BasStationArea basStationArea : basStationAreas) {
+ targSiteAreaList.add(basStationArea.getStationAreaId());
}
+ int count = 0;
+ for (BasStationArea basStationArea : basStationAreas) {
+ count++;
+ if (!basStationArea.getStationAlias().isEmpty()) {
+ List<OrderOutItemDto.staListDto> maps = new ArrayList<>();
+ for (String site : basStationArea.getStationAlias()) {
+ OrderOutItemDto.staListDto staListDto = new OrderOutItemDto.staListDto();
+ staListDto.setStaNo(site);
+ staListDto.setStaName(site);
+ maps.add(staListDto);
+ }
+ orderOutItemDto.setStaNos(maps);
+ //鑾峰彇婊¤冻鏉′欢绔欑偣
+ Set<String> stationSet = new HashSet<>(basStationArea.getStationAlias());
+// Set<String> stationSet = basStationArea.getStationAlias().stream().collect(Collectors.toSet());
+// Set<String> stationSet = deviceSites.stream().map(DeviceSite::getSite).collect(Collectors.toSet());
+ //宸蹭娇鐢ㄧ珯鐐�
+ Set<String> stas = stations.stream().map(BasStation::getStationName).collect(Collectors.toSet());
+ BasStationService basStationService = SpringUtils.getBean(BasStationService.class);
+ BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
+ .eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
+ .in(BasStation::getStationName, stationSet)
+ .notIn(!stas.isEmpty(), BasStation::getStationName, stas)
+ .last("LIMIT 1"));
+ if (!Objects.isNull(basStation)) {
+ stations.add(basStation);
+ }
- orderOutItemDto.setSource(item.getItemId())
- .setSourceId(item.getWaveId());
+ if (count == basStationAreas.size()) {
+ if (!Objects.isNull(basStation)) {
+ orderOutItemDto.setSiteNo(basStation.getStationName());
+// throw new CoolException("绔欓粸涓嶅瓨鍦紒锛�");
+ }
+ } else {
+ if (Objects.isNull(basStation)) {
+ continue;
+// throw new CoolException("绔欓粸涓嶅瓨鍦紒锛�");
+ }
+ orderOutItemDto.setSiteNo(basStation.getStationName());
+ }
- list.add(orderOutItemDto);
+ }
- issued = issued.subtract(new BigDecimal(locItem.getAnfme().toString()));
+ orderOutItemDto.setSource(item.getItemId().toString())
+ .setTargSiteAreaList(targSiteAreaList)
+ .setSourceId(item.getWaveId().toString());
+ list.add(orderOutItemDto);
+ locList.add(loc);
+
+ issued = issued.subtract(new BigDecimal(locItem.getAnfme().toString()));
+ break;
+ }
}
}
}
-// if (issued.doubleValue() > 0) {
-// LocItem locItem = new LocItem()
-// .setId(new Random().nextLong())
-// .setMatnrCode(item.getMatnrCode())
-// .setMaktx(item.getMaktx())
-// .setAnfme(0.00)
-// .setWorkQty(issued.doubleValue())
-// .setOutQty(issued.doubleValue())
-// .setUnit(item.getUnit())
-// .setBatch(item.getBatch());
-// OrderOutItemDto orderOutItemDto = new OrderOutItemDto();
-// orderOutItemDto.setLocItem(locItem);
-// list.add(orderOutItemDto);
-// }
}
return list;
}
+
+
+
+ //鏍规嵁鏉$爜鑾峰彇瑙勫垯
+ private static BasContainer getContainerType(String barcode) {
+ BasContainerService basContainerService = SpringUtils.getBean(BasContainerService.class);
+ if (Cools.isEmpty(barcode)) {
+ throw new CoolException("瀹瑰櫒鐮佷笉鑳戒负绌�");
+ }
+ List<BasContainer> containers = basContainerService.list(new LambdaQueryWrapper<>());
+ for (BasContainer container : containers) {
+ String codeType = container.getCodeType(); // 鑾峰彇姝e垯琛ㄨ揪寮�
+ if (barcode.matches(codeType)) { // 鍒ゆ柇鏉$爜鏄惁绗﹀悎杩欎釜姝e垯
+ return container;
+ }
+ }
+ return null;
+ }
+
}
--
Gitblit v1.9.1