diff --git a/src/main/java/com/gaotao/modules/base/controller/ReportFamilyListController.java b/src/main/java/com/gaotao/modules/base/controller/ReportFamilyListController.java
new file mode 100644
index 0000000..1f1a8e2
--- /dev/null
+++ b/src/main/java/com/gaotao/modules/base/controller/ReportFamilyListController.java
@@ -0,0 +1,166 @@
+package com.gaotao.modules.base.controller;
+
+import com.gaotao.common.utils.PageUtils;
+import com.gaotao.common.utils.R;
+import com.gaotao.modules.base.entity.ReportFamilyList;
+import com.gaotao.modules.base.service.ReportFamilyListService;
+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.List;
+import java.util.Map;
+
+/**
+ * 标签类型管理控制器
+ *
+ *
主要功能:
+ *
+ * - 标签类型的增删改查
+ * - 标签类型列表查询
+ * - 标签类型与视图的映射管理
+ *
+ *
+ * @author System
+ * @since 2025-10-13
+ */
+@Slf4j
+@RestController
+@RequestMapping("/label/labelType")
+public class ReportFamilyListController extends AbstractController {
+
+ @Autowired
+ private ReportFamilyListService reportFamilyListService;
+
+ /**
+ * @Author System
+ * @Description 分页查询标签类型列表
+ * @Date 2025/10/13
+ * @Param [params]
+ * @return com.gaotao.common.utils.R
+ **/
+ @PostMapping("getList")
+ public R getList(@RequestBody Map params) {
+ try {
+ log.info("查询标签类型列表 - params: {}", params);
+
+ // 转换分页参数为String类型(Query工具类需要String类型)
+ if (params.get("page") != null) {
+ params.put("page", String.valueOf(params.get("page")));
+ }
+ if (params.get("limit") != null) {
+ params.put("limit", String.valueOf(params.get("limit")));
+ }
+
+ PageUtils page = reportFamilyListService.queryPage(params);
+ return R.ok()
+ .put("code", 200)
+ .put("msg", "查询成功")
+ .put("page", page);
+ } catch (Exception e) {
+ log.error("查询标签类型列表失败: " + e.getMessage(), e);
+ return R.error("查询失败: " + e.getMessage());
+ }
+ }
+
+ /**
+ * @Author System
+ * @Description 获取所有标签类型(用于下拉选择)
+ * @Date 2025/10/13
+ * @Param [params]
+ * @return com.gaotao.common.utils.R
+ **/
+ @PostMapping("getAllList")
+ public R getAllList(@RequestBody Map params) {
+ try {
+ String site = (String) params.get("site");
+ log.info("获取所有标签类型 - site: {}", site);
+ List list = reportFamilyListService.getLabelTypeList(site);
+ return R.ok()
+ .put("code", 200)
+ .put("msg", "查询成功")
+ .put("data", list);
+ } catch (Exception e) {
+ log.error("获取标签类型失败: " + e.getMessage(), e);
+ return R.error("查询失败: " + e.getMessage());
+ }
+ }
+
+ /**
+ * @Author System
+ * @Description 保存标签类型
+ * @Date 2025/10/13
+ * @Param [reportFamilyList]
+ * @return com.gaotao.common.utils.R
+ **/
+ @PostMapping("save")
+ public R save(@RequestBody ReportFamilyList reportFamilyList) {
+ try {
+ log.info("保存标签类型 - name: {}", reportFamilyList.getName());
+
+ // 设置创建人
+ reportFamilyList.setCreatedBy(getUser().getUsername());
+ reportFamilyList.setUpdatedBy(getUser().getUsername());
+
+ reportFamilyListService.saveLabelType(reportFamilyList);
+ return R.ok()
+ .put("code", 200)
+ .put("msg", "保存成功");
+ } catch (Exception e) {
+ log.error("保存标签类型失败: " + e.getMessage(), e);
+ return R.error("保存失败: " + e.getMessage());
+ }
+ }
+
+ /**
+ * @Author System
+ * @Description 更新标签类型
+ * @Date 2025/10/13
+ * @Param [reportFamilyList]
+ * @return com.gaotao.common.utils.R
+ **/
+ @PostMapping("update")
+ public R update(@RequestBody ReportFamilyList reportFamilyList) {
+ try {
+ log.info("更新标签类型 - name: {}", reportFamilyList.getName());
+
+ // 设置更新人
+ reportFamilyList.setUpdatedBy(getUser().getUsername());
+
+ reportFamilyListService.updateLabelType(reportFamilyList);
+ return R.ok()
+ .put("code", 200)
+ .put("msg", "更新成功");
+ } catch (Exception e) {
+ log.error("更新标签类型失败: " + e.getMessage(), e);
+ return R.error("更新失败: " + e.getMessage());
+ }
+ }
+
+ /**
+ * @Author System
+ * @Description 删除标签类型
+ * @Date 2025/10/13
+ * @Param [params]
+ * @return com.gaotao.common.utils.R
+ **/
+ @PostMapping("delete")
+ public R delete(@RequestBody Map params) {
+ try {
+ String name = (String) params.get("name");
+ String site = (String) params.get("site");
+
+ log.info("删除标签类型 - name: {}, site: {}", name, site);
+
+ reportFamilyListService.deleteLabelType(name, site);
+ return R.ok()
+ .put("code", 200)
+ .put("msg", "删除成功");
+ } catch (Exception e) {
+ log.error("删除标签类型失败: " + e.getMessage(), e);
+ return R.error("删除失败: " + e.getMessage());
+ }
+ }
+}
+
diff --git a/src/main/java/com/gaotao/modules/base/dao/ReportFamilyListMapper.java b/src/main/java/com/gaotao/modules/base/dao/ReportFamilyListMapper.java
new file mode 100644
index 0000000..af11588
--- /dev/null
+++ b/src/main/java/com/gaotao/modules/base/dao/ReportFamilyListMapper.java
@@ -0,0 +1,35 @@
+package com.gaotao.modules.base.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gaotao.modules.base.entity.ReportFamilyList;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+/**
+ * 标签类型管理Mapper接口
+ *
+ * 主要功能:
+ *
+ * - 标签类型的增删改查操作
+ * - 标签类型与视图的映射管理
+ *
+ *
+ * @author System
+ * @since 2025-10-13
+ */
+@Mapper
+public interface ReportFamilyListMapper extends BaseMapper {
+
+ /**
+ * 检查标签类型是否被使用
+ *
+ * @param reportFamily 标签类型名称
+ * @param site 站点编码
+ * @return 使用该标签类型的数量
+ */
+ @Select("SELECT COUNT(1) FROM ReportFileList WHERE ReportFamily = #{reportFamily}")
+ Integer countLabelTypeUsage(@Param("reportFamily") String reportFamily, @Param("site") String site);
+
+}
+
diff --git a/src/main/java/com/gaotao/modules/base/entity/ReportFamilyList.java b/src/main/java/com/gaotao/modules/base/entity/ReportFamilyList.java
index f233ab2..eedc298 100644
--- a/src/main/java/com/gaotao/modules/base/entity/ReportFamilyList.java
+++ b/src/main/java/com/gaotao/modules/base/entity/ReportFamilyList.java
@@ -1,24 +1,72 @@
package com.gaotao.modules.base.entity;
+import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
+import java.util.Date;
/**
- * report_family_list实体类
+ * 标签类型信息实体类
+ *
+ * 核心字段说明:
+ *
+ * - name:标签类型名称(唯一标识)
+ * - site:站点编码
+ * - view_sql:WMS视图名称
+ * - ifs_view_sql:IFS视图名称
+ *
*/
@Data
@TableName("report_family_list")
public class ReportFamilyList implements Serializable {
- private String name; // 标签类型
+ /**
+ * 标签类型名称 - 必须字段
+ */
+ @TableField("name")
+ private String name;
- private String site; // 工厂
+ /**
+ * 站点编码
+ */
+ @TableField("site")
+ private String site;
- private String viewSql; // 视图名称
+ /**
+ * 创建人
+ */
+ @TableField("created_by")
+ private String createdBy;
- private String ifsViewSql; // IFS视图名称
+ /**
+ * 创建时间
+ */
+ @TableField("created_time")
+ private Date createdTime;
- // 其他字段根据实际表结构添加
+ /**
+ * 更新人
+ */
+ @TableField("updated_by")
+ private String updatedBy;
+
+ /**
+ * 更新时间
+ */
+ @TableField("updated_time")
+ private Date updatedTime;
+
+ /**
+ * WMS视图名称
+ */
+ @TableField("view_sql")
+ private String viewSql;
+
+ /**
+ * IFS视图名称
+ */
+ @TableField("ifs_view_sql")
+ private String ifsViewSql;
}
diff --git a/src/main/java/com/gaotao/modules/base/service/Impl/ReportFamilyListServiceImpl.java b/src/main/java/com/gaotao/modules/base/service/Impl/ReportFamilyListServiceImpl.java
new file mode 100644
index 0000000..b904896
--- /dev/null
+++ b/src/main/java/com/gaotao/modules/base/service/Impl/ReportFamilyListServiceImpl.java
@@ -0,0 +1,238 @@
+package com.gaotao.modules.base.service.Impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gaotao.common.utils.PageUtils;
+import com.gaotao.common.utils.Query;
+import com.gaotao.modules.base.dao.ReportFamilyListMapper;
+import com.gaotao.modules.base.entity.ReportFamilyList;
+import com.gaotao.modules.base.service.ReportFamilyListService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 标签类型管理服务实现类
+ *
+ * 主要功能:
+ *
+ * - 标签类型的增删改查
+ * - 标签类型与视图的映射管理
+ *
+ *
+ * 关键业务规则:
+ *
+ * - 标签类型名称在同一站点下唯一
+ * - 删除标签类型前需要检查是否被标签引用
+ *
+ *
+ * @author System
+ * @since 2025-10-13
+ */
+@Slf4j
+@Service
+@Transactional
+public class ReportFamilyListServiceImpl extends ServiceImpl
+ implements ReportFamilyListService {
+
+ /**
+ * 分页查询标签类型列表
+ *
+ * @param params 查询参数
+ * @return 分页结果
+ */
+ @Override
+ public PageUtils queryPage(Map params) {
+ log.info("=== 开始查询标签类型列表 ===");
+
+ String site = (String) params.get("site");
+ String name = (String) params.get("name");
+
+ log.info("查询条件 - site: {}, name: {}", site, name);
+
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
+
+ if (StringUtils.isNotBlank(site)) {
+ wrapper.eq(ReportFamilyList::getSite, site);
+ }
+
+ if (StringUtils.isNotBlank(name)) {
+ wrapper.like(ReportFamilyList::getName, name);
+ }
+
+ wrapper.orderByDesc(ReportFamilyList::getCreatedTime);
+
+ IPage page = this.page(
+ new Query().getPage(params),
+ wrapper
+ );
+
+ log.info("查询完成,共 {} 条记录", page.getTotal());
+ return new PageUtils(page);
+ }
+
+ /**
+ * 获取所有标签类型列表(用于下拉选择)
+ *
+ * @param site 工厂编码
+ * @return 标签类型列表
+ */
+ @Override
+ public List getLabelTypeList(String site) {
+ log.info("获取标签类型列表 - site: {}", site);
+
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
+
+ if (StringUtils.isNotBlank(site)) {
+ wrapper.eq(ReportFamilyList::getSite, site);
+ }
+
+ wrapper.orderByAsc(ReportFamilyList::getName);
+
+ return this.list(wrapper);
+ }
+
+ /**
+ * 保存标签类型
+ *
+ * @param reportFamilyList 标签类型信息
+ */
+ @Override
+ @Transactional
+ public void saveLabelType(ReportFamilyList reportFamilyList) {
+ log.info("=== 开始保存标签类型 ===");
+ log.info("标签类型: {}, 站点: {}", reportFamilyList.getName(), reportFamilyList.getSite());
+
+ // 验证标签类型名称是否已存在
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
+ wrapper.eq(ReportFamilyList::getName, reportFamilyList.getName())
+ .eq(ReportFamilyList::getSite, reportFamilyList.getSite());
+
+ ReportFamilyList existing = this.getOne(wrapper);
+ if (existing != null) {
+ log.error("标签类型已存在: {}", reportFamilyList.getName());
+ throw new RuntimeException("标签类型名称已存在: " + reportFamilyList.getName());
+ }
+
+ // 设置创建时间
+ reportFamilyList.setCreatedTime(new Date());
+ reportFamilyList.setUpdatedTime(new Date());
+
+ boolean result = this.save(reportFamilyList);
+
+ if (!result) {
+ log.error("保存标签类型失败");
+ throw new RuntimeException("保存标签类型失败");
+ }
+
+ log.info("=== 标签类型保存成功 ===");
+ }
+
+ /**
+ * 更新标签类型
+ *
+ * @param reportFamilyList 标签类型信息
+ */
+ @Override
+ @Transactional
+ public void updateLabelType(ReportFamilyList reportFamilyList) {
+ log.info("=== 开始更新标签类型 ===");
+ log.info("标签类型: {}, 站点: {}", reportFamilyList.getName(), reportFamilyList.getSite());
+
+ // 检查标签类型是否正在被使用
+ if (isLabelTypeInUse(reportFamilyList.getName(), reportFamilyList.getSite())) {
+ log.error("标签类型正在被使用,不允许修改: {}", reportFamilyList.getName());
+ throw new RuntimeException("该标签类型正在被标签使用,不允许修改");
+ }
+
+ // 设置更新时间
+ reportFamilyList.setUpdatedTime(new Date());
+
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
+ wrapper.eq(ReportFamilyList::getName, reportFamilyList.getName())
+ .eq(ReportFamilyList::getSite, reportFamilyList.getSite());
+
+ boolean result = this.update(reportFamilyList, wrapper);
+
+ if (!result) {
+ log.error("更新标签类型失败");
+ throw new RuntimeException("更新标签类型失败");
+ }
+
+ log.info("=== 标签类型更新成功 ===");
+ }
+
+ /**
+ * 删除标签类型
+ *
+ * @param name 标签类型名称
+ * @param site 工厂编码
+ */
+ @Override
+ @Transactional
+ public void deleteLabelType(String name, String site) {
+ log.info("=== 开始删除标签类型 ===");
+ log.info("标签类型: {}, 站点: {}", name, site);
+
+ // 验证标签类型是否存在
+ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
+ wrapper.eq(ReportFamilyList::getName, name)
+ .eq(ReportFamilyList::getSite, site);
+
+ ReportFamilyList existing = this.getOne(wrapper);
+ if (existing == null) {
+ log.error("标签类型不存在: {}", name);
+ throw new RuntimeException("标签类型不存在: " + name);
+ }
+
+ // 检查标签类型是否正在被使用
+ if (isLabelTypeInUse(name, site)) {
+ log.error("标签类型正在被使用,不允许删除: {}", name);
+ throw new RuntimeException("该标签类型正在被标签使用,不允许删除");
+ }
+
+ boolean result = this.remove(wrapper);
+
+ if (!result) {
+ log.error("删除标签类型失败");
+ throw new RuntimeException("删除标签类型失败");
+ }
+
+ log.info("=== 标签类型删除成功 ===");
+ }
+
+ /**
+ * 检查标签类型是否正在被使用
+ *
+ * @param name 标签类型名称
+ * @param site 工厂编码
+ * @return true=正在使用,false=未使用
+ */
+ @Override
+ public boolean isLabelTypeInUse(String name, String site) {
+ log.info("检查标签类型是否被使用 - name: {}, site: {}", name, site);
+
+ try {
+ // 使用Mapper接口的@Select注解方法查询
+ Integer count = baseMapper.countLabelTypeUsage(name, site);
+
+ boolean inUse = count != null && count > 0;
+ log.info("标签类型 {} 的使用情况: {} (使用该类型的标签数量: {})",
+ name, inUse ? "正在使用" : "未使用", count);
+
+ return inUse;
+ } catch (Exception e) {
+ log.error("检查标签类型使用情况时发生异常: " + e.getMessage(), e);
+ // 出现异常时,为了安全起见,返回true(假设正在使用,不允许删除)
+ return true;
+ }
+ }
+}
+
diff --git a/src/main/java/com/gaotao/modules/base/service/Impl/ReportLabelListServiceImpl.java b/src/main/java/com/gaotao/modules/base/service/Impl/ReportLabelListServiceImpl.java
index c12b8d6..ba60edf 100644
--- a/src/main/java/com/gaotao/modules/base/service/Impl/ReportLabelListServiceImpl.java
+++ b/src/main/java/com/gaotao/modules/base/service/Impl/ReportLabelListServiceImpl.java
@@ -240,19 +240,9 @@ public class ReportLabelListServiceImpl extends ServiceImpl labelData = i < labelDataList.size() ? labelDataList.get(i) : new HashMap<>();
- String epc = getStringValue(labelData, "unit_id", "");
- // 补齐到24位,不足的在前面加0
- epc = String.format("%24s", epc).replace(' ', '0');
- log.info("epc24位: {}", epc);
// 发送ZPL到打印机
- RfidProcessResult printResult = sendZplToPrinterAndGetResult(printerIP, zplCode, requestedCopies, rfidFlag,labelData);
-
- // 打印成功后保存标签记录
- /*if (printResult.isSuccess()) {
- saveWmsLabelRecord(printRequest, labelSettingDataList.getFirst().getLabelType(), printResult, defaultLabelSettingData.getLabelNo(), i + 1, labelData);
- }*/
+ sendZplToPrinterAndGetResult(printerIP, zplCode, requestedCopies, rfidFlag,labelData);
}
-
// 6. 记录打印日志
log.info("所有标签打印任务执行成功,共打印 {} 张标签,每张 {} 份", totalLabels, requestedCopies);
} catch (Exception e) {
@@ -264,8 +254,8 @@ public class ReportLabelListServiceImpl extends ServiceImpl labelData) {
+ private void sendZplToPrinterAndGetResult(String printerIP, String zplCode,
+ Integer copies, String rfidFlag, Map labelData) {
try {
log.info("开始处理标签打印: {}, 请求份数: {}, RFID标志: {}", printerIP, copies, rfidFlag);
@@ -286,7 +276,6 @@ public class ReportLabelListServiceImpl extends ServiceImpl labelData) {
- try {
- log.info("开始保存WMS标签记录,标签索引: {}", labelIndex);
-
- // 1. 获取流水号 - 从数据库中查询已保存的流水号
- /*String serialNo = getSerialNumberFromDatabase(labelNo, labelIndex);
-
- // 2. 从查询参数中获取其他信息
- WmsLabel wmsLabel = new WmsLabel();
- wmsLabel.setSite(printRequest.getSite());
- wmsLabel.setSerialNo(serialNo);
-
- // 3. 从labelData中获取实际的字段值
- wmsLabel.setPartNo(getStringValue(labelData, "part_no", "UNKNOWN_PART"));
- wmsLabel.setQty(getBigDecimalValue(labelData, "qty_received", null));
- wmsLabel.setInStockFlag("Y".equals(printRequest.getNeedCheck())?"N":"Y"); // 根据needCheck决定是否直接入库
- wmsLabel.setLabelType(labelType); // 标签类型
- wmsLabel.setBatchNo(getStringValue(labelData, "batch_no", null));
- wmsLabel.setWarehouseId(getStringValue(labelData, "warehouse_id", null));
- wmsLabel.setLocationId(getStringValue(labelData, "location_id", null));
- wmsLabel.setRemark("采购接收"+printRequest.getReceiptNo()+",打印时间: " + java.time.LocalDateTime.now());
-
- // 4. 如果是RFID标签,设置TID和EPC
- if (printResult.getTid() != null && !printResult.getTid().trim().isEmpty()) {
- wmsLabel.setTid(printResult.getTid());
- wmsLabel.setEpc(printResult.getEpcData());
- log.info("RFID标签信息 - TID: {}, EPC: {}", printResult.getTid(), printResult.getEpcData());
- }
-
- // 5. 保存到数据库
- baseService.saveWmsLabel(wmsLabel);*/
- // 根据site+unitId获取HU,更新HU的tid和epc
- HandlingUnit hUnit = handlingUnitService.lambdaQuery()
- .eq(HandlingUnit::getSite, printRequest.getSite())
- .eq(HandlingUnit::getUnitId, getStringValue(labelData, "unit_id", null))
- .one();
- hUnit.setTid(printResult.getTid());
- hUnit.setEpc(printResult.getEpcData());
- handlingUnitService.lambdaUpdate()
- .set(HandlingUnit::getTid, printResult.getTid())
- .set(HandlingUnit::getEpc, printResult.getEpcData())
- .eq(HandlingUnit::getSite, printRequest.getSite())
- .eq(HandlingUnit::getUnitId, getStringValue(labelData, "unit_id", null))
- .update();
- log.info("WMS标签记录保存成功: {}", hUnit);
- } catch (Exception e) {
- log.error("保存WMS标签记录失败: {}", e.getMessage(), e);
- // 不抛出异常,避免影响打印流程
- }
- }
-
- /**
- * 从数据库中获取流水号
- */
- private String getSerialNumberFromDatabase(String labelNo, int labelIndex) {
- try {
- // 查询该标签的serialNumber元素
- List serialElement = baseService.getReportLabelListByReportId(labelNo);
- for (ReportLabelList element : serialElement) {
- if (element != null && "serialNumber".equals(element.getType())) {
- String fullSerialNumber = element.getFullSerialNumber();
- if (fullSerialNumber != null && !fullSerialNumber.trim().isEmpty()) {
- return fullSerialNumber;
- }
- }
- }
- return "";
- } catch (Exception e) {
- log.warn("获取流水号失败,使用临时流水号: {}", e.getMessage());
- return "";
- }
- }
-
/**
* 从Map中安全地获取字符串值
*/
@@ -406,30 +317,6 @@ public class ReportLabelListServiceImpl extends ServiceImpl data, String key, java.math.BigDecimal defaultValue) {
- if (data == null || !data.containsKey(key)) {
- return defaultValue;
- }
- Object value = data.get(key);
- if (value == null) {
- return defaultValue;
- }
- try {
- if (value instanceof java.math.BigDecimal) {
- return (java.math.BigDecimal) value;
- } else if (value instanceof Number) {
- return new java.math.BigDecimal(value.toString());
- } else {
- return new java.math.BigDecimal(value.toString());
- }
- } catch (Exception e) {
- log.warn("转换BigDecimal失败,使用默认值: key={}, value={}, error={}", key, value, e.getMessage());
- return defaultValue;
- }
- }
@Override
public void printLabelTest(PrintLabelRequest printRequest) {
@@ -556,23 +443,6 @@ public class ReportLabelListServiceImpl extends ServiceImpl 12) {
- epc = epc.substring(epc.length() - 12);
- } else if (epc.length() < 12) {
- epc = String.format("%012s", epc).replace(' ', '0');
- }
- log.info("生成EPC: {}", epc);
- return epc;
- }
/**
* 清理ZPL代码,移除可能导致多张打印的指令
@@ -704,4 +574,86 @@ public class ReportLabelListServiceImpl extends ServiceImpl labelSettingDataList = baseService.getLabelSettingList(labelSettingData);
+ LabelSettingData labelSetting;
+ if (labelSettingDataList.isEmpty()) {
+ throw new RuntimeException("未找到对应的标签");
+ } else {
+ labelSetting = labelSettingDataList.getFirst();
+ rfidFlag = labelSetting.getRfidFlag();
+ }
+ try {
+ // 1. 构建查询参数Map
+ Map queryParams = new HashMap<>();
+ queryParams.put("site", printRequest.getSite());
+ List unitIds = Collections.singletonList(printRequest.getUnitId());
+ queryParams.put("unitIds", unitIds);
+ // 可以根据需要添加更多参数
+ // 生成带真实数据的ZPL代码和对应的数据
+ List zplCodeList = previewLabelWithRealData(labelSetting.getLabelNo(), true, queryParams);
+ // 同时获取原始数据用于保存WMS标签记录
+ List> labelDataList = getLabelDataForSaving(labelSetting.getLabelNo(), queryParams);
+ // 2. 验证ZPL代码
+ if (zplCodeList == null || zplCodeList.isEmpty()) {
+ throw new RuntimeException("ZPL代码获取失败");
+ }
+ log.info("生成了 {} 个ZPL代码,准备打印", zplCodeList.size());
+ // 3. 获取用户的打印机配置
+ UserLabelPrinterData printerQuery = new UserLabelPrinterData();
+ printerQuery.setUserId(printRequest.getUserId());
+ printerQuery.setLabelNo(labelSetting.getLabelNo());
+ List printers = baseService.getUserLabelPrinters(printerQuery);
+ if (printers.isEmpty()) {
+ throw new RuntimeException("未找到指定的打印机配置");
+ }
+ UserLabelPrinterData printer = printers.getFirst();
+ String printerIP = printer.getIpAddress();
+ if (printerIP == null || printerIP.trim().isEmpty()) {
+ throw new RuntimeException("打印机IP地址未配置");
+ }
+ // 4. 处理打印份数
+ int requestedCopies = 1;
+ // 5. 循环发送每个ZPL到打印机并保存标签记录
+ int totalLabels = zplCodeList.size();
+ for (int i = 0; i < totalLabels; i++) {
+ String zplCode = zplCodeList.get(i);
+ log.info("正在打印第 {} / {} 张标签", i + 1, totalLabels);
+ Map labelData = i < labelDataList.size() ? labelDataList.get(i) : new HashMap<>();
+ // 发送ZPL到打印机
+ sendZplToPrinterAndGetResult(printerIP, zplCode, requestedCopies, rfidFlag,labelData);
+ }
+ // 6. 记录打印日志
+ log.info("所有标签打印任务执行成功,共打印 {} 张标签,每张 {} 份", totalLabels, requestedCopies);
+ } catch (Exception e) {
+ System.err.println("RFID标签打印失败: " + e.getMessage());
+ throw new RuntimeException("RFID标签打印失败: " + e.getMessage());
+ }
+ }
}
diff --git a/src/main/java/com/gaotao/modules/base/service/ReportFamilyListService.java b/src/main/java/com/gaotao/modules/base/service/ReportFamilyListService.java
new file mode 100644
index 0000000..a7bd33b
--- /dev/null
+++ b/src/main/java/com/gaotao/modules/base/service/ReportFamilyListService.java
@@ -0,0 +1,72 @@
+package com.gaotao.modules.base.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gaotao.common.utils.PageUtils;
+import com.gaotao.modules.base.entity.ReportFamilyList;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 标签类型管理服务接口
+ *
+ * 主要功能:
+ *
+ * - 标签类型的增删改查
+ * - 标签类型列表查询
+ * - 标签类型与视图的映射管理
+ *
+ *
+ * @author System
+ * @since 2025-10-13
+ */
+public interface ReportFamilyListService extends IService {
+
+ /**
+ * 分页查询标签类型列表
+ *
+ * @param params 查询参数(包含site、name等)
+ * @return 分页结果
+ */
+ PageUtils queryPage(Map params);
+
+ /**
+ * 获取所有标签类型列表(用于下拉选择)
+ *
+ * @param site 工厂编码
+ * @return 标签类型列表
+ */
+ List getLabelTypeList(String site);
+
+ /**
+ * 保存标签类型
+ *
+ * @param reportFamilyList 标签类型信息
+ */
+ void saveLabelType(ReportFamilyList reportFamilyList);
+
+ /**
+ * 更新标签类型
+ *
+ * @param reportFamilyList 标签类型信息
+ */
+ void updateLabelType(ReportFamilyList reportFamilyList);
+
+ /**
+ * 删除标签类型
+ *
+ * @param name 标签类型名称
+ * @param site 工厂编码
+ */
+ void deleteLabelType(String name, String site);
+
+ /**
+ * 检查标签类型是否正在被使用
+ *
+ * @param name 标签类型名称
+ * @param site 工厂编码
+ * @return true=正在使用,false=未使用
+ */
+ boolean isLabelTypeInUse(String name, String site);
+}
+
diff --git a/src/main/java/com/gaotao/modules/base/service/ReportLabelListService.java b/src/main/java/com/gaotao/modules/base/service/ReportLabelListService.java
index 724d691..a827536 100644
--- a/src/main/java/com/gaotao/modules/base/service/ReportLabelListService.java
+++ b/src/main/java/com/gaotao/modules/base/service/ReportLabelListService.java
@@ -18,6 +18,8 @@ public interface ReportLabelListService extends IService {
void printLabelTest(PrintLabelRequest printRequest);
+ void printLabelCommon(PrintLabelRequest printRequest);
+
/**
* 获取处理后的标签元素(用于前端预览)
* @param reportId 标签ID