3 Commits d16651112b ... 6e37e32856

Author SHA1 Message Date
  hill.liu 6e37e32856 sql语句修改 4 months ago
  hill.liu d5b47d6189 增加打印机配置属性,当前写死的空白打印dicId=93,rfid的dictId =94 4 months ago
  hill.liu 811a92af96 定时任务增加过滤条件。dev,local不执行 4 months ago

+ 5 - 1
20240516.sql

@@ -1,3 +1,7 @@
 ALTER TABLE `tenant_coinage`.`rfid_delivery`
     ADD COLUMN `transport_url` varchar(255) NULL COMMENT '运送接收人url' AFTER `securities`,
-ADD COLUMN `branch_url` varchar(255) NULL COMMENT '分行接收人url' AFTER `transport_url`
+ADD COLUMN `branch_url` varchar(255) NULL COMMENT '分行接收人url' AFTER `transport_url`;
+
+insert into `tenant_coinage`.`sys_dict` (`id`, `status`, `levels`, `sorted`, `pid`, `name`, `tag`, `val`, `dept_id`, `tenant_id`) values (92, '1', '1', '3', '0', '打印数量', 'printOpt', null, null, '2');
+insert into `tenant_coinage`.`sys_dict` (`id`, `status`, `levels`, `sorted`, `pid`, `name`, `tag`, `val`, `dept_id`, `tenant_id`) values ( 93,'1', '2', '1', '78', '空白标签', 'printOpt', '1', null, '2');
+insert into `tenant_coinage`.`sys_dict` ( `id`,`status`, `levels`, `sorted`, `pid`, `name`, `tag`, `val`, `dept_id`, `tenant_id`) values ( 94,'1', '2', '2', '78', 'RFID', 'printOpt', '2', null, '2');

+ 3 - 2
src/main/java/com/sy/coinage/task/ScheduleTask.java

@@ -62,6 +62,7 @@ public class ScheduleTask {
     // 每天02:00:00 执行生成台账
     @Scheduled(cron = everyDay02)
     private void createAccount() {
+        if(type.equals("dev")||type.equals("local"))return;
         log.debug("执行了定时任务={}", "每天02:00:00生成台账");
         this.workshopAccountService.createAccount(new Date(), 2);
     }
@@ -132,7 +133,7 @@ public class ScheduleTask {
     @Scheduled(cron = second_30)
     private void printRfidBaseInfo(){
 
-        if(type.equals("dev"))return;
+        if(type.equals("dev")||type.equals("local"))return;
 
         //获取数据  rfid_base_info中 status ==1 ,且res_dept_id==2
         LambdaQueryWrapper<BaseInfo> queryWrapper = new LambdaQueryWrapper<>();
@@ -157,7 +158,7 @@ public class ScheduleTask {
             });
         }
 
-        log.info("执行了定时任务={} ,打印rfid信息={}","每五分钟执行打印rfid标签列表","标签列表数量"+ls!=null?ls.size():0);
+        log.info("执行了定时任务={} ,打印rfid信息={}","每30秒执行打印rfid标签列表","标签列表数量"+ls!=null?ls.size():0);
 
     }
 

+ 40 - 2
src/main/java/com/sy/coinage/util/printer/ZplImgConvertPrinter.java

@@ -1,6 +1,9 @@
 package com.sy.coinage.util.printer;
 
 import com.alibaba.fastjson.JSONObject;
+import com.sy.coinage.core.util.SpringUtils;
+import com.sy.coinage.sys.model.Dict;
+import com.sy.coinage.sys.service.IDictService;
 import com.sy.coinage.util.Common;
 import com.sy.coinage.util.RfidEpcTool;
 import com.zebra.sdk.comm.Connection;
@@ -10,6 +13,7 @@ import com.zebra.sdk.printer.PrinterStatus;
 import com.zebra.sdk.printer.ZebraPrinter;
 import com.zebra.sdk.printer.ZebraPrinterFactory;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 
 import java.awt.image.BufferedImage;
 import java.io.UnsupportedEncodingException;
@@ -24,6 +28,7 @@ public class ZplImgConvertPrinter {
     private static Integer DEFAULT_PORT = 9100; // 默认9100端口
 
 
+
     /**
      *
      * @param rfidInfoDTO
@@ -161,7 +166,11 @@ public class ZplImgConvertPrinter {
 //        zplSb.append("^PQ1,0,1,Y"); //打印一张
         //打印两张 >> 打印三张
 //        zplSb.append("^PQ3,0,1,Y");
-        zplSb.append("^PQ2,0,1,Y");
+        //        zplSb.append("^PQ2,0,1,Y");
+        //根据配置来获取打印数量
+        int amount =  getPrintAmoutByDictId(80); // rfid打印标签的dictId
+        zplSb.append("^PQ").append(amount).append(",0,1,Y");
+//
         return zplSb.toString();
     }
 
@@ -244,8 +253,12 @@ public class ZplImgConvertPrinter {
         //写入指令
         zplSb.append("^RFW,H,,12,E^FD").append(rfidHex).append("^FS");
         //打印指令  打印数量1;当每个rfid标签打印2个,每个拷贝是1个
-        zplSb.append("^PQ1,0,1,Y");
 
+//        zplSb.append("^PQ1,0,1,Y");
+
+        //根据配置来获取打印数量
+        int amount =  getPrintAmoutByDictId(79); // 空白标签的dictId
+        zplSb.append("^PQ").append(amount).append(",0,1,Y");
         return zplSb.toString();
     }
 
@@ -282,5 +295,30 @@ public class ZplImgConvertPrinter {
         }
     }
 
+    /**
+     *  获取打印数量 : 根据ID写死配置
+     *  ID: 79 ->空白标签
+     *  ID: 80 -> rfid实际打印数量
+     *  * @param dictId : 字典表里的ID
+     * @return
+     */
+    private static int getPrintAmoutByDictId(int dictId){
+
+         int result = 1;
+         IDictService dictService = SpringUtils.getBean(IDictService.class);
+
+         Dict dict = dictService.getById(dictId);
+
+         if(dictId == 93){//空白标签
+             if(dict != null) {
+                 result = dict.getVal() != null ? Integer.valueOf(dict.getVal()) : 1; //默认值是1
+             }
+         }else if(dictId == 94) {//rfid实体标签
+             if(dict != null) {
+                 result = dict.getVal() != null ? Integer.valueOf(dict.getVal()) : 2; //默认值是2
+             }
+         }
+            return result;
+    }
 
 }