Browse Source

优化

master
常熟吴彦祖 3 months ago
parent
commit
8b1bf7b2fe
  1. 14
      src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/AutoSortServiceImpl.java
  2. 4
      src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/KitTransportServiceImpl.java
  3. 39
      src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsIntegrationServiceImpl.java
  4. 8
      src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml
  5. 14
      src/main/resources/mapper/notify/NewIssureMapper.xml

14
src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/AutoSortServiceImpl.java

@ -151,7 +151,21 @@ public class AutoSortServiceImpl implements AutoSortService {
if (incrementalDetails.isEmpty()) {
log.info("无增量数据,无需扫进 - rqrq");
Pallet pallet = wcsIntegrationMapper.getPalletByCode(callback.getSite(), callback.getPalletId());
if (pallet == null) {
throw new RuntimeException("栈板不存在:" + callback.getPalletId());
}
wcsCallbackPalletScanMapper.updateProcessStatus(callback.getId(), "COMPLETED", "无增量数据");
//碰到异常订单 如果没有明细 直接回库 --和左工沟通过
ScheduleDeliveryTask scheduleDeliveryTask = new ScheduleDeliveryTask();
scheduleDeliveryTask.setSite(callback.getSite());
scheduleDeliveryTask.setPalletId(callback.getPalletId());
scheduleDeliveryTask.setFromLocation(pallet.getLocationCode());
scheduleDeliveryTask.setToArea("Z103");
scheduleDeliveryTask.setUsername("SYS_WMS");
autoTaskService.scheduleDeliveryTask(scheduleDeliveryTask);
log.info("调用配送任务调度成功 - rqrq:palletId={}, toArea={}", callback.getPalletId(), "Z103");
return;
}

4
src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/KitTransportServiceImpl.java

@ -96,9 +96,9 @@ public class KitTransportServiceImpl implements KitTransportService {
// 继续处理下一个订单 - rqrq
}
// 每处理完一个订单后休息2s释放锁资源让其他事务有机会执行减少死锁风险 - rqrq
// 每处理完一个订单后休息1s释放锁资源让其他事务有机会执行减少死锁风险 - rqrq
try {
Thread.sleep(2000);
Thread.sleep(1000);
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
log.warn("齐套运输任务被中断 - rqrq");

39
src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsIntegrationServiceImpl.java

@ -454,6 +454,19 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService {
if (!"Y".equals(inStockFlag)) {
throw new Exception("标签不在库状态:in_stock_flag不为Y");
}
// 校验栈板里已有物料的仓库库位与要扫入标签的仓库库位是否一致 - rqrq
List<PalletDetailData> existingPalletDetails = wcsIntegrationMapper.getPalletDetailsData(site, palletId);
if (existingPalletDetails != null && !existingPalletDetails.isEmpty()) {
// 栈板有物料获取第一条记录的仓库和库位
PalletDetailData firstDetail = existingPalletDetails.get(0);
String existingWarehouseId = firstDetail.getWarehouseId();
String existingLocationId = firstDetail.getLocationId();
// 比较仓库和库位是否一致
if (!labelWarehouseId.equals(existingWarehouseId)) {
throw new Exception("扫入的标签和栈板里的标签仓库不同");
}
}
// 获取栈板当前所在站点
AgvStation nowStation = wcsIntegrationMapper.getNowStation(site, palletId);
@ -478,29 +491,17 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService {
}else {
throw new Exception("栈板不在运输点位,无法进行打托操作");
}
}
// 校验栈板和物料的仓库是否一致栈板的仓库通过location_code关联agv_station获取warehouse_code
nowStation=wcsIntegrationMapper.getNowStation(site, palletId);
String palletWarehouseCode = nowStation.getWarehouseCode();
if (!labelWarehouseId.equals(palletWarehouseCode)) {
throw new Exception("栈板和物料的仓库不同,无法进行打托操作");
}
}else {
// 校验栈板里已有物料的仓库库位与要扫入标签的仓库库位是否一致 - rqrq
List<PalletDetailData> existingPalletDetails = wcsIntegrationMapper.getPalletDetailsData(site, palletId);
if (existingPalletDetails != null && !existingPalletDetails.isEmpty()) {
// 栈板有物料获取第一条记录的仓库和库位
PalletDetailData firstDetail = existingPalletDetails.get(0);
String existingWarehouseId = firstDetail.getWarehouseId();
String existingLocationId = firstDetail.getLocationId();
// 比较仓库和库位是否一致
if (!labelWarehouseId.equals(existingWarehouseId)) {
throw new Exception("扫入的标签和栈板里的标签仓库不同");
// 校验栈板和物料的仓库是否一致栈板的仓库通过location_code关联agv_station获取warehouse_code
nowStation = wcsIntegrationMapper.getNowStation(site, palletId);
String palletWarehouseCode = nowStation.getWarehouseCode();
if (!labelWarehouseId.equals(palletWarehouseCode)) {
throw new Exception("栈板和物料的仓库不同,无法进行打托操作");
}
}
String oldPalletId="";
// 2. 检查标签是否已在栈板中当前栈板或其他栈板

8
src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml

@ -269,8 +269,8 @@
<!-- 优化:添加 WITH (NOLOCK) 避免死锁 - rqrq -->
<select id="getNowStation" resultType="AgvStation">
SELECT TOP 1 b.station_code, b.location_code, b.warehouse_code
FROM pallet a WITH (NOLOCK)
LEFT JOIN agv_station b WITH (NOLOCK) ON a.location_code = b.station_code
FROM pallet a
LEFT JOIN agv_station b ON a.location_code = b.station_code
WHERE a.site = #{site} AND a.pallet_id = #{palletId} AND a.is_deleted = '0'
</select>
@ -354,7 +354,7 @@
<!-- rqrq - 更新栈板库位编码 -->
<!-- 优化:添加 WITH (ROWLOCK) 避免锁升级导致死锁 - rqrq -->
<update id="updatePalletLocationCode" >
UPDATE pallet WITH (ROWLOCK)
UPDATE pallet
SET location_code = #{newLocationCode},
updated_by = 'WMS_SYSTEM',
updated_time = GETDATE()
@ -1802,7 +1802,7 @@
<!-- 优化:添加 WITH (NOLOCK) 避免死锁 - rqrq -->
<select id="getPalletIdsBySerialNos" resultType="String">
SELECT DISTINCT pallet_id
FROM pallet_detail WITH (NOLOCK)
FROM pallet_detail
WHERE site = #{site}
<if test="serialNoList != null and serialNoList.size() > 0">
AND serial_no IN

14
src/main/resources/mapper/notify/NewIssureMapper.xml

@ -212,9 +212,10 @@
</select>
<!-- rqrq - 根据notifyNo和productionOrderNo查询itemNo -->
<!-- 注意:不能用NOLOCK,结果用于后续INSERT和UPDATE操作,脏读可能导致数据不一致 - rqrq -->
<select id="getItemNoByNotifyNoAndOrderNo" resultType="java.math.BigDecimal">
SELECT TOP 1 item_no
FROM SOIssueNotifyOrderList WITH (NOLOCK)
FROM SOIssueNotifyOrderList
<where>
AND site = #{site}
AND notify_no = #{notifyNo}
@ -280,7 +281,7 @@
production_area AS productionArea,
transport_flag AS transportFlag,
order_type AS orderType
FROM SOIssueNotifyOrderList WITH (NOLOCK)
FROM SOIssueNotifyOrderList
WHERE site = #{site}
AND notify_no = #{notifyNo}
AND item_no = #{itemNo,jdbcType=DECIMAL}
@ -351,7 +352,7 @@
<!-- 优化:添加 WITH (NOLOCK) 避免死锁 - rqrq -->
<select id="getPalletDetailsByPalletAndSerials" resultType="com.gaotao.modules.automatedWarehouse.entity.PalletDetail">
SELECT position, layer, serial_no as serialNo
FROM pallet_detail WITH (NOLOCK)
FROM pallet_detail
WHERE site = #{site}
AND pallet_id = #{palletId}
AND serial_no IN
@ -361,10 +362,11 @@
ORDER BY position, layer
</select>
<!-- rqrq - 查询序列号在handling_unit中的location_id(无锁查询)-->
<!-- rqrq - 查询序列号在handling_unit中的location_id -->
<!-- 注意:不能用NOLOCK,结果用于设置outWcsFlag后INSERT到detail表,脏读可能导致标记错误 - rqrq -->
<select id="getSerialNoLocationId" resultType="java.lang.String">
SELECT location_id
FROM handling_unit WITH (NOLOCK)
FROM handling_unit
WHERE site = #{site}
AND unit_id = #{serialNo}
</select>
@ -383,7 +385,7 @@
out_wcs_flag AS outWcsFlag,
issure_flag AS issureFlag,
order_type AS orderType
FROM SOIssueNotifyOrderMaterialList_detail WITH (NOLOCK)
FROM SOIssueNotifyOrderMaterialList_detail
WHERE site = #{site}
AND notify_no = #{notifyNo}
ORDER BY item_no, BOM_item_no, task_seq

Loading…
Cancel
Save