package com.gaotao.modules.handlingunit.controller; import com.gaotao.common.utils.R; import com.gaotao.modules.handlingunit.entity.HandlingUnit; import com.gaotao.modules.handlingunit.service.HandlingUnitService; import com.gaotao.modules.sys.controller.AbstractController; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Map; /** * PDA标签查询控制器 * *

主要功能:

* * * @author System * @since 2025-01-23 */ @Slf4j @RestController @RequestMapping("/pda/label") public class PdaLabelController extends AbstractController { @Autowired private HandlingUnitService handlingUnitService; /** * @Author System * @Description 查询标签信息 * @Date 2025/01/23 * @Param [Map] * @return com.gaotao.common.utils.R **/ @PostMapping("query") public R queryLabelInfo(@RequestBody Map params) { try { String site = (String) params.get("site"); String labelCode = (String) params.get("labelCode"); log.info("=== 开始查询标签信息 ==="); log.info("工厂: {}, 标签编码: {}", site, labelCode); // 参数验证 if (site == null || site.trim().isEmpty()) { return R.error("工厂编码不能为空"); } if (labelCode == null || labelCode.trim().isEmpty()) { return R.error("标签编码不能为空"); } // 查询HandlingUnit信息 HandlingUnit handlingUnit = handlingUnitService.lambdaQuery() .eq(HandlingUnit::getSite, site) .eq(HandlingUnit::getUnitId, labelCode.trim()) .one(); if (handlingUnit == null) { log.warn("标签不存在: site={}, labelCode={}", site, labelCode); return R.error("标签不存在"); } log.info("查询到标签信息: unitId={}, partNo={}, locationId={}, warehouseId={}, batchNo={}, wdr={}", handlingUnit.getUnitId(), handlingUnit.getPartNo(), handlingUnit.getLocationId(), handlingUnit.getWarehouseId(), handlingUnit.getBatchNo(), handlingUnit.getWdr()); log.info("=== 标签信息查询完成 ==="); return R.ok().put("data", handlingUnit); } catch (Exception e) { log.error("=== 查询标签信息失败 === 错误信息: {}", e.getMessage(), e); return R.error("查询失败: " + e.getMessage()); } } }