Browse Source

盘点

master
常熟吴彦祖 6 months ago
parent
commit
d9a68529bb
  1. 18
      src/main/java/com/gaotao/modules/api/service/InterfaceCallLogService.java
  2. 44
      src/main/java/com/gaotao/modules/api/service/impl/InterfaceCallLogServiceImpl.java
  3. 36
      src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/WcsIntegrationServiceImpl.java
  4. 21
      src/main/java/com/gaotao/modules/check/service/impl/PhysicalInventoryServiceImpl.java
  5. 5
      src/main/resources/mapper/check/PhysicalInventoryMapper.xml

18
src/main/java/com/gaotao/modules/api/service/InterfaceCallLogService.java

@ -43,4 +43,22 @@ public interface InterfaceCallLogService extends IService<InterfaceCallLog> {
* @date 2025/10/07
*/
PageUtils queryPage(InterfaceCallLogData data) throws Exception;
/**
* @Description 一次性记录完整的接口调用日志调用后只保存1次不需要先存再修改- rqrq
* @param interfaceName 接口名称
* @param methodName 方法名称
* @param requestData 请求数据
* @param responseData 响应数据
* @param status 状态SUCCESS/ERROR/TIMEOUT
* @param errorMessage 错误信息
* @param executionTime 执行时间毫秒
* @param site 站点
* @param businessKey 业务主键
* @param remark 备注
* @author rqrq
*/
void logCompleteCall(String interfaceName, String methodName, String requestData,
String responseData, String status, String errorMessage,
Long executionTime, String site, String businessKey, String remark);
}

44
src/main/java/com/gaotao/modules/api/service/impl/InterfaceCallLogServiceImpl.java

@ -140,4 +140,48 @@ public class InterfaceCallLogServiceImpl extends ServiceImpl<InterfaceCallLogMap
return new PageUtils(pageResult);
}
/**
* @Description 一次性记录完整的接口调用日志调用后只保存1次不需要先存再修改- rqrq
* @param interfaceName 接口名称
* @param methodName 方法名称
* @param requestData 请求数据
* @param responseData 响应数据
* @param status 状态SUCCESS/ERROR/TIMEOUT
* @param errorMessage 错误信息
* @param executionTime 执行时间毫秒
* @param site 站点
* @param businessKey 业务主键
* @param remark 备注
* @author rqrq
*/
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void logCompleteCall(String interfaceName, String methodName, String requestData,
String responseData, String status, String errorMessage,
Long executionTime, String site, String businessKey, String remark) {
try {
InterfaceCallLog callLog = new InterfaceCallLog();
callLog.setInterfaceName(interfaceName);
callLog.setMethodName(methodName);
callLog.setRequestData(requestData);
callLog.setResponseData(responseData);
callLog.setStatus(status);
callLog.setErrorMessage(errorMessage);
callLog.setExecutionTime(executionTime);
callLog.setSite(site);
callLog.setBusinessKey(businessKey);
callLog.setRemark(remark);
callLog.setCreatedTime(new Date());
callLog.setCreatedBy("SYSTEM");
this.save(callLog);
log.info("接口调用日志一次性记录成功 - rqrq,接口: {}, 方法: {}, 状态: {}",
interfaceName, methodName, status);
} catch (Exception e) {
log.error("一次性记录接口调用日志失败 - rqrq: {}", e.getMessage(), e);
}
}
}

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

@ -71,6 +71,9 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService {
@Autowired
private CountModeChecker countModeChecker;
@Autowired
private com.gaotao.modules.api.service.InterfaceCallLogService interfaceCallLogService; // rqrq - 接口调用日志服务
@org.springframework.beans.factory.annotation.Value("${custom.wcs-url}")
private String wcsUrl;
@Override
@ -2761,12 +2764,16 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService {
// 3. 调用WCS接口获取分拣明细 - rqrq
List<String> rfidList = new ArrayList<>();
try {
String url = wcsUrl + "query-auto-sorting-info";
String jsonBody = "\"" + devCode + "\"";
String url = wcsUrl + "query-auto-sorting-info";
String jsonBody = "\"" + devCode + "\"";
long startTime = System.currentTimeMillis(); // rqrq - 记录开始时间
String wcsResponse = null;
String logStatus = "SUCCESS";
String errorMsg = null;
try {
System.out.println("调用WCS API - rqrq,url=" + url + ", devCode=" + devCode);
String wcsResponse = com.gaotao.common.utils.HttpUtils.doPost(url, jsonBody, null);
wcsResponse = com.gaotao.common.utils.HttpUtils.doPost(url, jsonBody, null);
System.out.println("WCS API返回数据 - rqrq");
// 解析JSON数据 - rqrq
@ -2802,7 +2809,28 @@ public class WcsIntegrationServiceImpl implements WcsIntegrationService {
} catch (Exception e) {
System.out.println("获取WCS分拣明细失败 - rqrq:" + e.getMessage());
log.error("获取WCS分拣明细失败", e);
logStatus = "ERROR";
errorMsg = e.getMessage();
// 失败时返回空列表不抛异常 - rqrq
} finally {
// rqrq - 记录接口调用日志调用后只保存1次
long executionTime = System.currentTimeMillis() - startTime;
try {
interfaceCallLogService.logCompleteCall(
"WCS", // 接口名称
"query-auto-sorting-info", // 方法名称
jsonBody, // 请求数据
wcsResponse, // 响应数据
logStatus, // 状态
errorMsg, // 错误信息
executionTime, // 执行时间
site, // 站点
palletId, // 业务主键栈板号
"获取分拣明细RFID列表,devCode=" + devCode // 备注
);
} catch (Exception logEx) {
log.error("记录接口调用日志失败 - rqrq:{}", logEx.getMessage());
}
}
// 4. 构造返回数据 - rqrq

21
src/main/java/com/gaotao/modules/check/service/impl/PhysicalInventoryServiceImpl.java

@ -622,9 +622,11 @@ public class PhysicalInventoryServiceImpl extends ServiceImpl<PhysicalInventoryM
*
* <p><b>业务逻辑</b></p>
* <pre>
* 1. 查询未推送的栈板task_no为空的
* 2. 每次推送10个栈板尽量每层都有栈板
* 3. 生成wms_order_task单据并推送给WCS
* 1. 校验盘点单状态必须是"盘点中"
* 2. 校验是否存在未完成的任务单防止重复下达
* 3. 查询未推送的栈板task_no为空的
* 4. 每次推送10个栈板尽量每层都有栈板
* 5. 生成wms_order_task单据并推送给WCS
* </pre>
*/
@Override
@ -641,7 +643,14 @@ public class PhysicalInventoryServiceImpl extends ServiceImpl<PhysicalInventoryM
throw new RuntimeException("盘点单状态不是盘点中,终止盘点");
}
// 2. 执行推送 - rqrq
// 2. 校验是否存在未完成的任务单状态不是已完成或已取消- rqrq
int uncompletedTaskCount = baseMapper.countUncompletedTask(query.getSite(), query.getCountNo());
if (uncompletedTaskCount > 0) {
throw new RuntimeException("当前盘点单存在" + uncompletedTaskCount + "个未完成的任务单,请等待任务完成后再继续下达");
}
log.info("校验通过,无未完成的任务单");
// 3. 执行推送 - rqrq
int pushedCount = doPushPallets(query.getSite(), query.getCountNo(), query.getUsername(), 10);
log.info("continuePushCount 结束,本次推送栈板数: {}", pushedCount);
@ -1844,7 +1853,7 @@ public class PhysicalInventoryServiceImpl extends ServiceImpl<PhysicalInventoryM
// 6. 处理任务单与RFID接口一致- rqrq
handleTaskAfterCount(site, countNo, palletId, username);
log.info("pdaQuickSubmitCount 结束,处理标签数: {}", labelList.size());
log.info("pdaQuickSubmitCount 结束,生成盘点结果数: {}", labelList.size());
return labelList.size();
}
@ -1969,7 +1978,7 @@ public class PhysicalInventoryServiceImpl extends ServiceImpl<PhysicalInventoryM
// 8. 处理任务单与RFID接口一致- rqrq
handleTaskAfterCount(site, countNo, palletId, username);
log.info("pdaSubmitCount 结束,处理标签数: {}", labelList.size());
log.info("pdaSubmitCount 结束,生成盘点结果数: {}", labelList.size());
return labelList.size();
}

5
src/main/resources/mapper/check/PhysicalInventoryMapper.xml

@ -530,12 +530,13 @@
</select>
<!-- rqrq - 检查是否存在未完成的任务单 -->
<!-- rqrq - 检查是否存在未完成的任务单(排除已完成和已取消)-->
<select id="countUncompletedTask" resultType="int">
SELECT COUNT(1)
FROM wms_order_task t
FROM wms_order_task t WITH (NOLOCK)
WHERE t.site = #{site}
AND t.source_bill_no = #{countNo}
AND t.status != '已完成'
AND t.status NOT IN ('已完成', '已取消')
</select>
<!-- rqrq - 检查未盘点的栈板数量 -->

Loading…
Cancel
Save