8 changed files with 399 additions and 130 deletions
-
25src/main/java/com/gaotao/modules/automatedWarehouse/mapper/WcsIntegrationMapper.java
-
20src/main/java/com/gaotao/modules/automatedWarehouse/service/DeliveryTaskService.java
-
15src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/AutoSortServiceImpl.java
-
178src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/DeliveryTaskServiceImpl.java
-
162src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsIntegrationServiceImpl.java
-
100src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsTaskServiceImpl.java
-
2src/main/resources/mapper/automatedWarehouse/KitTransportMapper.xml
-
27src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml
@ -0,0 +1,20 @@ |
|||
package com.gaotao.modules.automatedWarehouse.service; |
|||
|
|||
/** |
|||
* @Description 配送任务服务接口 - rqrq |
|||
* @Author rqrq |
|||
* @Date 2025/11/14 |
|||
*/ |
|||
public interface DeliveryTaskService { |
|||
|
|||
/** |
|||
* @Description 创建配送任务(根据栈板物料自动判断目标点位)- rqrq |
|||
* @Title createDeliveryTaskByPallet |
|||
* @param site 工厂编码 |
|||
* @param palletId 栈板编码 |
|||
* @author rqrq |
|||
* @date 2025/11/14 |
|||
*/ |
|||
void createDeliveryTaskByPallet(String site, String palletId) ; |
|||
} |
|||
|
|||
@ -0,0 +1,178 @@ |
|||
package com.gaotao.modules.automatedWarehouse.service.impl; |
|||
|
|||
import com.gaotao.modules.automatedWarehouse.entity.ScheduleDeliveryTask; |
|||
import com.gaotao.modules.automatedWarehouse.mapper.WcsIntegrationMapper; |
|||
import com.gaotao.modules.automatedWarehouse.service.AutoTaskService; |
|||
import com.gaotao.modules.automatedWarehouse.service.DeliveryTaskService; |
|||
import com.gaotao.modules.warehouse.entity.Pallet; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @Description 配送任务服务实现类 - rqrq |
|||
* @Author rqrq |
|||
* @Date 2025/11/14 |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
public class DeliveryTaskServiceImpl implements DeliveryTaskService { |
|||
|
|||
@Autowired |
|||
private WcsIntegrationMapper wcsIntegrationMapper; |
|||
|
|||
@Autowired |
|||
private AutoTaskService autoTaskService; |
|||
|
|||
/** |
|||
* @Description 创建配送任务(根据栈板物料自动判断目标点位)- rqrq |
|||
* @Title createDeliveryTaskByPallet |
|||
* @param site 工厂编码 |
|||
* @param palletId 栈板编码 |
|||
* @author rqrq |
|||
* @date 2025/11/14 |
|||
*/ |
|||
@Override |
|||
public void createDeliveryTaskByPallet(String site, String palletId) { |
|||
log.info("开始创建配送任务 - rqrq,site={}, palletId={}", site, palletId); |
|||
|
|||
// 1. 参数校验 - rqrq |
|||
if (!StringUtils.hasText(site)) { |
|||
throw new RuntimeException("站点不能为空"); |
|||
} |
|||
if (!StringUtils.hasText(palletId)) { |
|||
throw new RuntimeException("栈板编码不能为空"); |
|||
} |
|||
|
|||
// 2. 查询栈板信息 - rqrq |
|||
Pallet pallet = wcsIntegrationMapper.getPalletByCode(site, palletId); |
|||
if (pallet == null) { |
|||
throw new RuntimeException("栈板不存在:" + palletId); |
|||
} |
|||
log.info("查询到栈板信息 - rqrq:locationCode={}", pallet.getLocationCode()); |
|||
|
|||
// 3. 查询栈板物料的预约信息(关联pallet_detail和handling_unit)- rqrq |
|||
List<Map<String, Object>> palletMaterialReserveList = wcsIntegrationMapper.getPalletMaterialReserveInfo(site, palletId); |
|||
|
|||
if (palletMaterialReserveList == null || palletMaterialReserveList.isEmpty()) { |
|||
log.warn("栈板没有物料或物料没有预约信息,使用默认缓存位 - rqrq:palletId={}", palletId); |
|||
createDeliveryTask(site, palletId, pallet.getLocationCode(), "Z104", null, null); |
|||
return; |
|||
} |
|||
|
|||
log.info("查询到栈板物料预约信息 - rqrq:{}条", palletMaterialReserveList.size()); |
|||
|
|||
// 4. 选取reserve_flag='Y'的第一个条码 - rqrq |
|||
Map<String, Object> reservedMaterial = null; |
|||
for (Map<String, Object> material : palletMaterialReserveList) { |
|||
String reserveFlag = (String) material.get("reserveFlag"); |
|||
if ("Y".equals(reserveFlag)) { |
|||
reservedMaterial = material; |
|||
log.info("找到预约物料 - rqrq:serialNo={}, reserveOrderRef1={}, reserveOrderRef2={}", |
|||
material.get("serialNo"), material.get("reserveOrderRef1"), material.get("reserveOrderRef2")); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
// 5. 如果没有预约物料,使用默认缓存位 - rqrq |
|||
if (reservedMaterial == null) { |
|||
log.warn("栈板没有预约物料,使用默认缓存位 - rqrq:palletId={}", palletId); |
|||
createDeliveryTask(site, palletId, pallet.getLocationCode(), "Z104", null, null); |
|||
return; |
|||
} |
|||
|
|||
String reserveOrderRef1 = (String) reservedMaterial.get("reserveOrderRef1"); |
|||
String reserveOrderRef2 = (String) reservedMaterial.get("reserveOrderRef2"); |
|||
|
|||
// 6. 查询SOIssueNotifyOrderList表获取production_area和order_type - rqrq |
|||
Map<String, Object> orderInfo = wcsIntegrationMapper.getOrderInfoByNotifyAndItem( |
|||
site, reserveOrderRef1, reserveOrderRef2); |
|||
|
|||
if (orderInfo == null) { |
|||
log.warn("未查询到申请单信息,使用默认缓存位 - rqrq:notifyNo={}, itemNo={}", |
|||
reserveOrderRef1, reserveOrderRef2); |
|||
createDeliveryTask(site, palletId, pallet.getLocationCode(), "Z104", null, null); |
|||
return; |
|||
} |
|||
|
|||
String productionArea = (String) orderInfo.get("productionArea"); |
|||
String orderType = (String) orderInfo.get("orderType"); |
|||
|
|||
log.info("查询到订单信息 - rqrq:productionArea={}, orderType={}", productionArea, orderType); |
|||
|
|||
// 7. 判断目标点位 - rqrq |
|||
String targetArea; |
|||
|
|||
// 7.1 如果order_type是shoporder,直接去Z104(缓存位)- rqrq |
|||
if ("shoporder".equalsIgnoreCase(orderType)) { |
|||
targetArea = "Z104"; |
|||
log.info("订单类型为shoporder,目标区域=Z104(缓存位)- rqrq"); |
|||
} else { |
|||
// 7.2 其他订单类型,先判断production_area是否有空闲站点 - rqrq |
|||
if (!StringUtils.hasText(productionArea)) { |
|||
log.warn("production_area为空,使用默认缓存位 - rqrq"); |
|||
targetArea = "Z104"; |
|||
} else { |
|||
// 查询目标区域是否有空闲站点 - rqrq |
|||
String freeStation = wcsIntegrationMapper.findFirstFreeStationByAreaId(productionArea); |
|||
|
|||
if (StringUtils.hasText(freeStation)) { |
|||
// 有空闲站点,使用production_area - rqrq |
|||
targetArea = productionArea; |
|||
log.info("目标区域有空闲站点 - rqrq:productionArea={}, freeStation={}", productionArea, freeStation); |
|||
} else { |
|||
// 没有空闲站点,去Z104(缓存位)- rqrq |
|||
targetArea = "Z104"; |
|||
log.info("目标区域无空闲站点,使用缓存位 - rqrq:productionArea={}, targetArea=Z104", productionArea); |
|||
} |
|||
} |
|||
} |
|||
|
|||
// 8. 创建配送任务 - rqrq |
|||
createDeliveryTask(site, palletId, pallet.getLocationCode(), targetArea, |
|||
reserveOrderRef1, reserveOrderRef2); |
|||
|
|||
log.info("创建配送任务完成 - rqrq:palletId={}, targetArea={}", palletId, targetArea); |
|||
} |
|||
|
|||
/** |
|||
* @Description 创建配送任务(内部方法)- rqrq |
|||
* @param site 工厂编码 |
|||
* @param palletId 栈板编码 |
|||
* @param fromLocation 起始位置 |
|||
* @param toArea 目标区域 |
|||
* @param sourceBillNo 源单号(可为空) |
|||
* @param sourceLineId 源单行号(可为空) |
|||
* @author rqrq |
|||
* @date 2025/11/14 |
|||
*/ |
|||
private void createDeliveryTask(String site, String palletId, String fromLocation, |
|||
String toArea, String sourceBillNo, String sourceLineId) { |
|||
ScheduleDeliveryTask scheduleDeliveryTask = new ScheduleDeliveryTask(); |
|||
scheduleDeliveryTask.setSite(site); |
|||
scheduleDeliveryTask.setPalletId(palletId); |
|||
scheduleDeliveryTask.setFromLocation(fromLocation); |
|||
scheduleDeliveryTask.setToArea(toArea); |
|||
scheduleDeliveryTask.setUsername("SYS_WMS"); |
|||
|
|||
// 设置源单信息(如果有)- rqrq |
|||
if (StringUtils.hasText(sourceBillNo)) { |
|||
scheduleDeliveryTask.setSourceBillNo(sourceBillNo); |
|||
} |
|||
if (StringUtils.hasText(sourceLineId)) { |
|||
try { |
|||
scheduleDeliveryTask.setSourceLineId(Long.valueOf(sourceLineId)); |
|||
} catch (NumberFormatException e) { |
|||
log.warn("sourceLineId转换失败 - rqrq:sourceLineId={}", sourceLineId); |
|||
} |
|||
} |
|||
|
|||
autoTaskService.scheduleDeliveryTask(scheduleDeliveryTask); |
|||
log.info("调用配送任务调度成功 - rqrq:palletId={}, toArea={}", palletId, toArea); |
|||
} |
|||
} |
|||
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue