You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
3.0 KiB

5 months ago
  1. package com.gaotao.modules.handlingunit.controller;
  2. import com.gaotao.common.utils.R;
  3. import com.gaotao.modules.handlingunit.entity.HandlingUnit;
  4. import com.gaotao.modules.handlingunit.service.HandlingUnitService;
  5. import com.gaotao.modules.sys.controller.AbstractController;
  6. import lombok.extern.slf4j.Slf4j;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.web.bind.annotation.*;
  9. import java.util.Map;
  10. /**
  11. * PDA标签查询控制器
  12. *
  13. * <p><b>主要功能</b></p>
  14. * <ul>
  15. * <li>扫描标签查询HandlingUnit信息</li>
  16. * <li>显示物料编码库位仓库批次号wdr等信息</li>
  17. * </ul>
  18. *
  19. * @author System
  20. * @since 2025-01-23
  21. */
  22. @Slf4j
  23. @RestController
  24. @RequestMapping("/pda/label")
  25. public class PdaLabelController extends AbstractController {
  26. @Autowired
  27. private HandlingUnitService handlingUnitService;
  28. /**
  29. * @Author System
  30. * @Description 查询标签信息
  31. * @Date 2025/01/23
  32. * @Param [Map<String, Object>]
  33. * @return com.gaotao.common.utils.R
  34. **/
  35. @PostMapping("query")
  36. public R queryLabelInfo(@RequestBody Map<String, Object> params) {
  37. try {
  38. String site = (String) params.get("site");
  39. String labelCode = (String) params.get("labelCode");
  40. log.info("=== 开始查询标签信息 ===");
  41. log.info("工厂: {}, 标签编码: {}", site, labelCode);
  42. // 参数验证
  43. if (site == null || site.trim().isEmpty()) {
  44. return R.error("工厂编码不能为空");
  45. }
  46. if (labelCode == null || labelCode.trim().isEmpty()) {
  47. return R.error("标签编码不能为空");
  48. }
  49. // 查询HandlingUnit信息
  50. HandlingUnit handlingUnit = handlingUnitService.lambdaQuery()
  51. .eq(HandlingUnit::getSite, site)
  52. .eq(HandlingUnit::getUnitId, labelCode.trim())
  53. .one();
  54. if (handlingUnit == null) {
  55. log.warn("标签不存在: site={}, labelCode={}", site, labelCode);
  56. return R.error("标签不存在");
  57. }
  58. log.info("查询到标签信息: unitId={}, partNo={}, locationId={}, warehouseId={}, batchNo={}, wdr={}",
  59. handlingUnit.getUnitId(),
  60. handlingUnit.getPartNo(),
  61. handlingUnit.getLocationId(),
  62. handlingUnit.getWarehouseId(),
  63. handlingUnit.getBatchNo(),
  64. handlingUnit.getWdr());
  65. log.info("=== 标签信息查询完成 ===");
  66. return R.ok().put("data", handlingUnit);
  67. } catch (Exception e) {
  68. log.error("=== 查询标签信息失败 === 错误信息: {}", e.getMessage(), e);
  69. return R.error("查询失败: " + e.getMessage());
  70. }
  71. }
  72. }