Browse Source

wcs接口

master
常熟吴彦祖 5 months ago
parent
commit
061a64ae34
  1. 52
      src/main/java/com/gaotao/modules/automatedWarehouse/controller/WcsIntegrationController.java
  2. 60
      src/main/java/com/gaotao/modules/automatedWarehouse/entity/CheckPalletResult.java
  3. 26
      src/main/java/com/gaotao/modules/automatedWarehouse/mapper/WcsIntegrationMapper.java
  4. 36
      src/main/java/com/gaotao/modules/automatedWarehouse/service/WcsIntegrationService.java
  5. 214
      src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsIntegrationServiceImpl.java
  6. 51
      src/main/resources/mapper/automatedWarehouse/WcsIntegrationMapper.xml

52
src/main/java/com/gaotao/modules/automatedWarehouse/controller/WcsIntegrationController.java

@ -6,6 +6,7 @@ import com.gaotao.modules.api.service.IfsApiService;
import com.gaotao.modules.automatedWarehouse.entity.*;
import com.gaotao.modules.automatedWarehouse.service.WcsIntegrationService;
import com.gaotao.modules.automatedWarehouse.service.PalletChangeStationService;
import com.gaotao.modules.base.entity.PalletType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -379,7 +380,7 @@ public class WcsIntegrationController {
@PostMapping(value="/checkPalletForChangeStation")
@ResponseBody
public R checkPalletForChangeStation(@RequestBody Map<String, Object> params) {
Map<String, Object> row = wcsIntegrationService.checkPalletForChangeStation(params);
CheckPalletResult row = wcsIntegrationService.checkPalletForChangeStation(params);
return R.ok().put("row", row);
}
@ -441,7 +442,7 @@ public class WcsIntegrationController {
@PostMapping(value="/checkPalletForManualMove")
@ResponseBody
public R checkPalletForManualMove(@RequestBody Map<String, Object> params) {
Map<String, Object> row = wcsIntegrationService.checkPalletForManualMove(params);
CheckPalletResult row = wcsIntegrationService.checkPalletForManualMove(params);
return R.ok().put("row", row);
}
@ -504,4 +505,51 @@ public class WcsIntegrationController {
wcsIntegrationService.bindPalletToStation(params);
return R.ok();
}
// ==================== 空托盘组盘相关方法 - rqrq ====================
/**
* @Description 检查托盘是否为空托盘 - rqrq
* @Title checkEmptyPallet
* @param params {site, palletId}
* @return R
* @author rqrq
* @date 2025/10/16
*/
@PostMapping(value="/checkEmptyPallet")
@ResponseBody
public R checkEmptyPallet(@RequestBody Map<String, Object> params) {
CheckPalletResult row = wcsIntegrationService.checkEmptyPallet(params);
return R.ok().put("row", row);
}
/**
* @Description 获取托盘类型列表根据pallet_family过滤- rqrq
* @Title getPalletTypes
* @param params {site, palletFamily}
* @return R
* @author rqrq
* @date 2025/10/16
*/
@PostMapping(value="/getPalletTypes")
@ResponseBody
public R getPalletTypes(@RequestBody Map<String, Object> params) {
List<PalletType> rows = wcsIntegrationService.getPalletTypes(params);
return R.ok().put("rows", rows);
}
/**
* @Description 空托盘通知入库 - rqrq
* @Title notifyEmptyPalletInbound
* @param params {site, palletId, transportFlag}
* @return R
* @author rqrq
* @date 2025/10/16
*/
@PostMapping(value="/notifyEmptyPalletInbound")
@ResponseBody
public R notifyEmptyPalletInbound(@RequestBody Map<String, Object> params) {
wcsIntegrationService.notifyEmptyPalletInbound(params);
return R.ok();
}
}

60
src/main/java/com/gaotao/modules/automatedWarehouse/entity/CheckPalletResult.java

@ -0,0 +1,60 @@
package com.gaotao.modules.automatedWarehouse.entity;
import lombok.Data;
import org.apache.ibatis.type.Alias;
/**
* @Description 检查托盘结果实体类 - rqrq
* @Author rqrq
* @Date 2025/10/16
*/
@Data
@Alias("CheckPalletResult")
public class CheckPalletResult {
/**
* 托盘编码
*/
private String palletId;
/**
* 托盘类型
*/
private String palletType;
/**
* 托盘族用于过滤托盘类型
*/
private String palletFamily;
/**
* 调用标志Y-被调用N-未被调用
*/
private String callingFlag;
/**
* 当前站点编码
*/
private String currentStationCode;
/**
* 当前站点ID
*/
private String currentStationId;
/**
* 站点类型
*/
private String stationType;
/**
* 是否可操作Y-可操作N-不可操作
*/
private String canOperate;
/**
* 是否为空托盘Y-N-
*/
private String isEmpty;
}

26
src/main/java/com/gaotao/modules/automatedWarehouse/mapper/WcsIntegrationMapper.java

@ -400,7 +400,7 @@ public interface WcsIntegrationMapper {
* @author rqrq
* @date 2025/10/16
*/
Map<String, Object> checkPalletForChangeStation(@Param("site") String site, @Param("palletId") String palletId);
CheckPalletResult checkPalletForChangeStation(@Param("site") String site, @Param("palletId") String palletId);
/**
* @Description 获取可选择的区域列表(choose_able为Y) - rqrq
@ -438,7 +438,7 @@ public interface WcsIntegrationMapper {
* @author rqrq
* @date 2025/10/16
*/
Map<String, Object> checkPalletForManualMove(@Param("site") String site, @Param("palletId") String palletId);
CheckPalletResult checkPalletForManualMove(@Param("site") String site, @Param("palletId") String palletId);
/**
* @Description 更新托盘location_code为null移出站点- rqrq
@ -474,4 +474,26 @@ public interface WcsIntegrationMapper {
* @date 2025/10/16
*/
void updateStationToOccupied(@Param("stationCode") String stationCode);
// ==================== 空托盘组盘相关方法 - rqrq ====================
/**
* @Description 检查托盘是否为空托盘pallet_detail表无数据- rqrq
* @param site 工厂编码
* @param palletId 托盘编码
* @return 托盘信息(包含当前站点ID站点编码托盘类型)
* @author rqrq
* @date 2025/10/16
*/
CheckPalletResult checkEmptyPallet(@Param("site") String site, @Param("palletId") String palletId);
/**
* @Description 获取托盘类型列表根据pallet_family过滤- rqrq
* @param site 工厂编码
* @param palletFamily 托盘族可为空
* @return 托盘类型列表
* @author rqrq
* @date 2025/10/16
*/
List<PalletType> getPalletTypes(@Param("site") String site, @Param("palletFamily") String palletFamily);
}

36
src/main/java/com/gaotao/modules/automatedWarehouse/service/WcsIntegrationService.java

@ -1,6 +1,7 @@
package com.gaotao.modules.automatedWarehouse.service;
import com.gaotao.modules.automatedWarehouse.entity.*;
import com.gaotao.modules.base.entity.PalletType;
import java.util.List;
import java.util.Map;
@ -168,7 +169,7 @@ public interface WcsIntegrationService {
* @author rqrq
* @date 2025/10/16
*/
Map<String, Object> checkPalletForChangeStation(Map<String, Object> params);
CheckPalletResult checkPalletForChangeStation(Map<String, Object> params);
/**
* @Description 获取可选择的区域列表choose_able为Y- rqrq
@ -200,7 +201,7 @@ public interface WcsIntegrationService {
* @author rqrq
* @date 2025/10/16
*/
Map<String, Object> checkPalletForManualMove(Map<String, Object> params);
CheckPalletResult checkPalletForManualMove(Map<String, Object> params);
/**
* @Description 移出站点更新托盘location_code为null更新站点状态为空闲- rqrq
@ -220,4 +221,35 @@ public interface WcsIntegrationService {
*/
void bindPalletToStation(Map<String, Object> params);
// ==================== 空托盘组盘相关方法 - rqrq ====================
/**
* @Description 检查托盘是否为空托盘 - rqrq
* @Title checkEmptyPallet
* @param params {site, palletId}
* @return 托盘信息(包含当前站点ID站点编码托盘类型是否为空托盘)
* @author rqrq
* @date 2025/10/16
*/
CheckPalletResult checkEmptyPallet(Map<String, Object> params);
/**
* @Description 获取托盘类型列表根据pallet_family过滤- rqrq
* @Title getPalletTypes
* @param params {site, palletFamily}
* @return 托盘类型列表
* @author rqrq
* @date 2025/10/16
*/
List<PalletType> getPalletTypes(Map<String, Object> params);
/**
* @Description 空托盘通知入库 - rqrq
* @Title notifyEmptyPalletInbound
* @param params {site, palletId, transportFlag}
* @author rqrq
* @date 2025/10/16
*/
void notifyEmptyPalletInbound(Map<String, Object> params);
}

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

@ -1523,7 +1523,7 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService {
// ==================== 栈板换站相关方法实现 - rqrq ====================
@Override
public Map<String, Object> checkPalletForChangeStation(Map<String, Object> params) {
public CheckPalletResult checkPalletForChangeStation(Map<String, Object> params) {
System.out.println("开始检查栈板换站条件 - rqrq");
String site = (String) params.get("site");
@ -1538,13 +1538,13 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService {
}
// 查询栈板信息 - rqrq
Map<String, Object> palletInfo = wcsIntegrationMapper.checkPalletForChangeStation(site, palletId);
CheckPalletResult palletInfo = wcsIntegrationMapper.checkPalletForChangeStation(site, palletId);
if (palletInfo == null || palletInfo.isEmpty()) {
if (palletInfo == null) {
throw new RuntimeException("栈板不存在:" + palletId);
}
System.out.println("检查栈板换站条件完成 - rqrq,callingFlag=" + palletInfo.get("callingFlag"));
System.out.println("检查栈板换站条件完成 - rqrq,callingFlag=" + palletInfo.getCallingFlag());
return palletInfo;
}
@ -1578,7 +1578,7 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService {
// ==================== 手工移动托盘相关方法实现 - rqrq ====================
@Override
public Map<String, Object> checkPalletForManualMove(Map<String, Object> params) {
public CheckPalletResult checkPalletForManualMove(Map<String, Object> params) {
System.out.println("开始检查托盘是否可以手工移动 - rqrq");
String site = (String) params.get("site");
@ -1593,7 +1593,7 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService {
}
// 查询托盘信息 - rqrq
Map<String, Object> palletInfo = wcsIntegrationMapper.checkPalletForManualMove(site, palletId);
CheckPalletResult palletInfo = wcsIntegrationMapper.checkPalletForManualMove(site, palletId);
if (palletInfo == null) {
throw new RuntimeException("托盘不存在");
}
@ -1623,20 +1623,18 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService {
}
// 检查托盘是否存在 - rqrq
Map<String, Object> palletInfo = wcsIntegrationMapper.checkPalletForManualMove(site, palletId);
CheckPalletResult palletInfo = wcsIntegrationMapper.checkPalletForManualMove(site, palletId);
if (palletInfo == null) {
throw new RuntimeException("托盘不存在");
}
// 检查托盘是否被调用 - rqrq
String callingFlag = (String) palletInfo.get("callingFlag");
if ("Y".equals(callingFlag)) {
if ("Y".equals(palletInfo.getCallingFlag())) {
throw new RuntimeException("托盘正在被调用中,无法移出站点");
}
// 检查是否可操作必须是正式站点- rqrq
String canOperate = (String) palletInfo.get("canOperate");
if (!"Y".equals(canOperate)) {
if (!"Y".equals(palletInfo.getCanOperate())) {
throw new RuntimeException("当前站点位置不可变更");
}
@ -1670,21 +1668,19 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService {
}
// 检查托盘是否存在 - rqrq
Map<String, Object> palletInfo = wcsIntegrationMapper.checkPalletForManualMove(site, palletId);
CheckPalletResult palletInfo = wcsIntegrationMapper.checkPalletForManualMove(site, palletId);
if (palletInfo == null) {
throw new RuntimeException("托盘不存在");
}
// 检查托盘是否被调用 - rqrq
String callingFlag = (String) palletInfo.get("callingFlag");
if ("Y".equals(callingFlag)) {
if ("Y".equals(palletInfo.getCallingFlag())) {
throw new RuntimeException("托盘正在被调用中,无法绑定站点");
}
// 检查托盘当前是否已有站点 - rqrq
String currentStationCode = (String) palletInfo.get("currentStationCode");
if (StringUtils.hasText(currentStationCode)) {
throw new RuntimeException("托盘已绑定站点【" + currentStationCode + "】,请先移出站点");
if (StringUtils.hasText(palletInfo.getCurrentStationCode())) {
throw new RuntimeException("托盘已绑定站点【" + palletInfo.getCurrentStationCode() + "】,请先移出站点");
}
// 检查站点是否存在且可用 - rqrq
@ -1719,4 +1715,188 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService {
System.out.println("绑定托盘到站点完成 - rqrq");
}
// ==================== 空托盘组盘相关方法实现 - rqrq ====================
@Override
public CheckPalletResult checkEmptyPallet(Map<String, Object> params) {
System.out.println("开始检查空托盘 - rqrq");
String site = (String) params.get("site");
String palletId = (String) params.get("palletId");
// 参数校验 - rqrq
if (!StringUtils.hasText(site)) {
throw new RuntimeException("站点不能为空");
}
if (!StringUtils.hasText(palletId)) {
throw new RuntimeException("托盘编码不能为空");
}
// 查询托盘信息 - rqrq
CheckPalletResult palletInfo = wcsIntegrationMapper.checkEmptyPallet(site, palletId);
if (palletInfo == null) {
throw new RuntimeException("托盘不存在");
}
// 判断是否为空托盘 - rqrq
if (!"Y".equals(palletInfo.getIsEmpty())) {
throw new RuntimeException("该托盘不是空托盘,无法进行空托盘组盘操作");
}
System.out.println("检查空托盘完成 - rqrq,托盘信息:" + palletInfo);
return palletInfo;
}
@Override
public List<PalletType> getPalletTypes(Map<String, Object> params) {
System.out.println("开始获取托盘类型列表 - rqrq");
String site = (String) params.get("site");
String palletFamily = (String) params.get("palletFamily");
// 参数校验 - rqrq
if (!StringUtils.hasText(site)) {
throw new RuntimeException("站点不能为空");
}
// 查询托盘类型列表根据pallet_family过滤- rqrq
List<PalletType> list = wcsIntegrationMapper.getPalletTypes(site, palletFamily);
System.out.println("获取托盘类型列表完成,共" + list.size() + "条记录 - rqrq,palletFamily=" + palletFamily);
return list;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void notifyEmptyPalletInbound(Map<String, Object> params) {
System.out.println("开始空托盘通知入库 - rqrq");
SysUserEntity currentUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
String site = (String) params.get("site");
String palletId = (String) params.get("palletId");
String transportFlag = (String) params.get("transportFlag");
// 参数校验 - rqrq
if (!StringUtils.hasText(site)) {
throw new RuntimeException("工厂编码不能为空");
}
if (!StringUtils.hasText(palletId)) {
throw new RuntimeException("栈板编码不能为空");
}
// 校验栈板是否存在 - rqrq
Map<String, Object> palletInfo = wcsIntegrationMapper.getPalletInfo(site, palletId);
if (palletInfo == null) {
throw new RuntimeException("栈板不存在");
}
// 生成入库任务编号 - rqrq
TransNoControl transData = transNoService.getTransNo(site, "WOT", 10);
Date currentTime = new Date();
// 创建入库任务记录 - rqrq
WmsOrderTask orderTask = new WmsOrderTask();
orderTask.setSite(site);
orderTask.setTaskNo(transData.getNewTransNo());
orderTask.setItemNo(1);
orderTask.setSourceType("空托盘入库"); // 设置为空托盘入库 - rqrq
orderTask.setSourceBillNo("");
orderTask.setSourceLineId(0L);
orderTask.setPartNo("");
orderTask.setQty(BigDecimal.ZERO);
orderTask.setBatchNo("");
orderTask.setSerialNo("");
orderTask.setFromLocation("无");
orderTask.setToLocation("无");
orderTask.setPalletId(palletId);
orderTask.setAgvCode("");
orderTask.setPriority(1);
orderTask.setStatus("已创建");
orderTask.setWmsSendTime(currentTime);
orderTask.setCreatedBy(currentUser.getUsername());
orderTask.setCreatedTime(currentTime);
orderTask.setUpdatedTime(currentTime);
orderTask.setFinishQty(BigDecimal.ZERO);
// 保存任务记录 - rqrq
wcsIntegrationMapper.insertOrderTask(orderTask);
System.out.println("空托盘入库任务已创建 - rqrq,taskNo=" + orderTask.getTaskNo());
// 调用空托盘推送方法只推送托盘数据cargoInfos为null- rqrq
pushEmptyPalletDetail(site, palletId, orderTask.getTaskNo(), orderTask.getItemNo());
// 如果是入库并运输在这里新增逻辑暂时留空- rqrq
if ("Y".equals(transportFlag)) {
System.out.println("入库并运输标志为Y,后续将在此处新增运输逻辑 - rqrq");
// TODO: 新增运输相关逻辑 - rqrq
}
System.out.println("空托盘通知入库完成 - rqrq");
}
/**
* @Description 推送空托盘数据到WCS只传托盘数据cargoInfos为null- rqrq
* @param site 工厂编码
* @param palletId 托盘编码
* @param taskNo 任务编号
* @param itemNo 项次
* @author rqrq
* @date 2025/10/16
*/
private void pushEmptyPalletDetail(String site, String palletId, String taskNo, Integer itemNo) {
System.out.println("开始推送空托盘数据到WCS - rqrq,palletId=" + palletId + ", taskNo=" + taskNo);
// 获取栈板信息包含pallet_type表关联数据- rqrq
com.gaotao.modules.warehouse.entity.PalletData palletInfo = wcsIntegrationMapper.getPalletInfoWithTypeDetails(site, palletId);
String locationCode = palletInfo.getLocationCode();
// 从pallet表关联pallet_type获取WCS相关字段 - rqrq
Integer wcsPalletType = palletInfo.getWcsPalletType() != null ? palletInfo.getWcsPalletType() : 1;
Integer wcsBasePalletType = palletInfo.getWcsBasePalletType() != null ? palletInfo.getWcsBasePalletType() : 1;
Integer soreType = palletInfo.getWcsSoreType();
if (palletInfo.getSoreType() != null) {
soreType = palletInfo.getSoreType();
}
String autoSort = palletInfo.getAutoSort();
boolean isAutoSort = "Y".equals(autoSort);
// 更新栈板calling_flag为Y - rqrq
String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername();
wcsIntegrationMapper.updatePalletCallingFlag(site, palletId, "Y", username);
// 构建推送数据 - rqrq
PushPalletDetailDto inData = new PushPalletDetailDto();
// 设置物料类型 - rqrq
if ("A01".equals(palletInfo.getPalletFamily())) {
inData.setPartType(PartTypeEnum.fromCode(2));
} else if ("A02".equals(palletInfo.getPalletFamily())) {
inData.setPartType(PartTypeEnum.fromCode(1));
} else if ("A03".equals(palletInfo.getPalletFamily())) {
inData.setPartType(PartTypeEnum.fromCode(0));
} else {
inData.setPartType(PartTypeEnum.fromCode(3));
}
inData.setSite(site);
inData.setTaskNo(taskNo);
inData.setItemNo(itemNo);
inData.setPalletBarcode(palletId);
inData.setPalletType(wcsPalletType);
inData.setBasePalletType(wcsBasePalletType);
inData.setCommonUsed(false); // 空托盘没有常用料标记 - rqrq
inData.setAutoSort(isAutoSort);
inData.setSoreType(soreType);
inData.setAssemblyPosition(locationCode);
inData.setEndFlag(true); // 空托盘直接结束组盘 - rqrq
inData.setCargoInfos(null); // 空托盘没有货物信息传null - rqrq
// 调用WCS推送接口不修改此方法- rqrq
wcsApiService.pushZuPanApi(inData);
System.out.println("推送空托盘数据到WCS完成 - rqrq");
}
}

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

@ -845,7 +845,7 @@
<!-- ==================== 栈板换站相关SQL - rqrq ==================== -->
<!-- rqrq - 检查栈板calling_flag并获取当前站点信息 -->
<select id="checkPalletForChangeStation" resultType="java.util.HashMap">
<select id="checkPalletForChangeStation" resultType="CheckPalletResult">
SELECT
p.calling_flag AS callingFlag,
s.station_id AS currentStationId,
@ -900,7 +900,7 @@
<!-- ==================== 手工移动托盘相关SQL - rqrq ==================== -->
<!-- rqrq - 检查托盘是否可以手工移动 -->
<select id="checkPalletForManualMove" resultType="java.util.HashMap">
<select id="checkPalletForManualMove" resultType="CheckPalletResult">
SELECT
p.calling_flag AS callingFlag,
p.location_code AS currentStationCode,
@ -954,4 +954,51 @@
WHERE station_code = #{stationCode}
</update>
<!-- ==================== 空托盘组盘相关SQL - rqrq ==================== -->
<!-- rqrq - 检查托盘是否为空托盘 -->
<select id="checkEmptyPallet" resultType="CheckPalletResult">
SELECT
p.pallet_id AS palletId,
p.pallet_type AS palletType,
p.pallet_family AS palletFamily,
p.location_code AS currentStationCode,
s.station_id AS currentStationId,
CASE
WHEN EXISTS (
SELECT 1 FROM pallet_detail pd
WHERE pd.site = p.site
AND pd.pallet_id = p.pallet_id
)
THEN 'N'
ELSE 'Y'
END AS isEmpty
FROM pallet p
LEFT JOIN agv_station s ON p.location_code = s.station_code
WHERE p.site = #{site}
AND p.pallet_id = #{palletId}
AND p.is_deleted = '0'
</select>
<!-- rqrq - 获取托盘类型列表(根据pallet_family过滤)-->
<select id="getPalletTypes" resultType="PalletType">
SELECT
site,
pallet_type AS palletType,
type_desc AS typeDesc,
pallet_family AS palletFamily,
max_layer AS maxLayer,
wcs_auto_sort AS wcsAutoSort,
wcs_pallet_type AS wcsPalletType,
wcs_base_pallet_type AS wcsBasePalletType,
wcs_sore_type AS wcsSoreType
FROM pallet_type
WHERE site = #{site}
<if test="palletFamily != null and palletFamily != ''">
AND pallet_family = #{palletFamily}
</if>
ORDER BY pallet_type
</select>
</mapper>
Loading…
Cancel
Save