Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -5,10 +5,10 @@ import com.ZMPrinter.LSF.LSFDecoder;
|
|||||||
import com.ZMPrinter.UsbUtility.UsbConnection;
|
import com.ZMPrinter.UsbUtility.UsbConnection;
|
||||||
import com.zg.project.Inventory.AutoInventory.domain.entity.PrintRfid;
|
import com.zg.project.Inventory.AutoInventory.domain.entity.PrintRfid;
|
||||||
import com.zg.project.Inventory.AutoInventory.mapper.PrintRfidMapper;
|
import com.zg.project.Inventory.AutoInventory.mapper.PrintRfidMapper;
|
||||||
|
import com.zg.project.information.domain.PcdeDetail;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import com.zg.project.information.mapper.PcdeDetailMapper;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -19,7 +19,8 @@ import java.util.Map;
|
|||||||
public class PrintController {
|
public class PrintController {
|
||||||
@Autowired
|
@Autowired
|
||||||
PrintRfidMapper rfidMapper;
|
PrintRfidMapper rfidMapper;
|
||||||
|
@Autowired
|
||||||
|
PcdeDetailMapper pcdeDetailMapper;
|
||||||
/**
|
/**
|
||||||
* 代码定义标签格式
|
* 代码定义标签格式
|
||||||
* @return
|
* @return
|
||||||
@@ -257,12 +258,29 @@ public class PrintController {
|
|||||||
// return AjaxResult.success(result);
|
// return AjaxResult.success(result);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@PostMapping("/printaaa")
|
||||||
|
public String printaaa(@RequestBody Map<String,Object> params){
|
||||||
|
Integer printType = (Integer) params.get("printType");
|
||||||
|
//批量打印、单个打印
|
||||||
|
if(printType == 1){
|
||||||
|
ArrayList ids = (ArrayList) params.get("ids");
|
||||||
|
|
||||||
|
List<PcdeDetail> rfidList = pcdeDetailMapper.selectPcdeDetailListIds(ids);
|
||||||
|
Long aa = 3333L;
|
||||||
|
|
||||||
|
return "tttt";
|
||||||
|
}else if(printType == 2){ //手动输入信息打印
|
||||||
|
|
||||||
|
}
|
||||||
|
return "rrrr";
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 模板定义标签格式
|
* 模板定义标签格式
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/printlsf")
|
@PostMapping("/printlsf")
|
||||||
public String printlsf() {
|
public String printlsf(@RequestBody Map<String,Object> params) {
|
||||||
|
|
||||||
zmprinter thiszmprinter = new zmprinter();//定义打印机对象
|
zmprinter thiszmprinter = new zmprinter();//定义打印机对象
|
||||||
zmlabel thiszmlabel = new zmlabel();//定义标签对象
|
zmlabel thiszmlabel = new zmlabel();//定义标签对象
|
||||||
List<zmlabelobject> thiszmlabelobjectlist = new ArrayList<>();//定义标签上需要打印的对象列表
|
List<zmlabelobject> thiszmlabelobjectlist = new ArrayList<>();//定义标签上需要打印的对象列表
|
||||||
@@ -321,14 +339,15 @@ public class PrintController {
|
|||||||
//endregion
|
//endregion
|
||||||
}
|
}
|
||||||
//endregion
|
//endregion
|
||||||
// 查print_rfid表,打印标签
|
//批量打印、单个打印
|
||||||
PrintRfid printRfid = new PrintRfid();
|
Integer printType = (Integer) params.get("printType");
|
||||||
printRfid.setIsprint(0L);
|
//批量打印、单个打印
|
||||||
List<PrintRfid> rfidList = new ArrayList<>();
|
if(printType == 1){
|
||||||
rfidList = rfidMapper.selectPrintRfidList(printRfid);
|
ArrayList ids = (ArrayList) params.get("ids");
|
||||||
|
|
||||||
|
List<PcdeDetail> rfidList = pcdeDetailMapper.selectPcdeDetailListIds(ids);
|
||||||
if(rfidList.size()>0){
|
if(rfidList.size()>0){
|
||||||
//region 循环打印标签
|
for(PcdeDetail info : rfidList) {
|
||||||
for(PrintRfid info : rfidList) {
|
|
||||||
|
|
||||||
// System.out.println("打印第"+pnum+"张");
|
// System.out.println("打印第"+pnum+"张");
|
||||||
|
|
||||||
@@ -384,9 +403,9 @@ public class PrintController {
|
|||||||
|
|
||||||
//region 设置对象里变量的值(如果需要)
|
//region 设置对象里变量的值(如果需要)
|
||||||
//注意:参数varName是lsf文件里对象变量的“子字符串共享名称”,varValue是需要设置的新值
|
//注意:参数varName是lsf文件里对象变量的“子字符串共享名称”,varValue是需要设置的新值
|
||||||
zmprintoperate.setVarValue(thiszmlabelobjectlist,"position",info.getPcde());//设置变量的子字符串共享名称为“name”的值
|
zmprintoperate.setVarValue(thiszmlabelobjectlist,"position",info.getPcode());//设置变量的子字符串共享名称为“name”的值
|
||||||
zmprintoperate.setVarValue(thiszmlabelobjectlist,"maposition",info.getPcde());//设置变量的子字符串共享名称为“model”的值
|
zmprintoperate.setVarValue(thiszmlabelobjectlist,"maposition",info.getPcode());//设置变量的子字符串共享名称为“model”的值
|
||||||
zmprintoperate.setVarValue(thiszmlabelobjectlist,"rfid",info.getRfid());//设置变量的子字符串共享名称为“location”的值
|
zmprintoperate.setVarValue(thiszmlabelobjectlist,"rfid",info.getEncodedId());//设置变量的子字符串共享名称为“location”的值
|
||||||
// zmprintoperate.setVarValue(thiszmlabelobjectlist,"department","国产操作系统研发13组");//设置变量的子字符串共享名称为“department”的值
|
// zmprintoperate.setVarValue(thiszmlabelobjectlist,"department","国产操作系统研发13组");//设置变量的子字符串共享名称为“department”的值
|
||||||
// zmprintoperate.setVarValue(thiszmlabelobjectlist,"purchasedate","2020-10-08");//设置变量的子字符串共享名称为“purchasedate”的值
|
// zmprintoperate.setVarValue(thiszmlabelobjectlist,"purchasedate","2020-10-08");//设置变量的子字符串共享名称为“purchasedate”的值
|
||||||
// zmprintoperate.setVarValue(thiszmlabelobjectlist,"assetcode","2021092300090002"+String.format("%04d",pnum));//设置变量的子字符串共享名称为“assetcode”的值
|
// zmprintoperate.setVarValue(thiszmlabelobjectlist,"assetcode","2021092300090002"+String.format("%04d",pnum));//设置变量的子字符串共享名称为“assetcode”的值
|
||||||
@@ -434,11 +453,126 @@ public class PrintController {
|
|||||||
//endregion
|
//endregion
|
||||||
//修改表字段,标记为已打印
|
//修改表字段,标记为已打印
|
||||||
|
|
||||||
rfidMapper.updatePrintRfid(info.getId());
|
// rfidMapper.updatePrintRfid(info.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}else if(printType == 2){ //手动输入信息打印
|
||||||
|
String printStr = (String) params.get("printStr");
|
||||||
|
// 将 printStr 转换为十六进制字符串
|
||||||
|
StringBuilder hex = new StringBuilder();
|
||||||
|
for (int i = 0; i < printStr.length(); i++) {
|
||||||
|
char c = printStr.charAt(i);
|
||||||
|
String hexPart = Integer.toHexString(c).toUpperCase();
|
||||||
|
hex.append(hexPart);
|
||||||
|
}
|
||||||
|
String rfidStr = hex.toString();
|
||||||
|
//region 处理读取标签数据(如果需要)
|
||||||
|
String tagTID="";
|
||||||
|
if(isRFIDread) {
|
||||||
|
//region 读取UHF标签数据
|
||||||
|
UsbConnection usbConnection = new UsbConnection();//建立USB连接
|
||||||
|
if (!usbConnection.Open()) {
|
||||||
|
System.out.println("连接打印机失败,请检查。");
|
||||||
|
return "连接打印机失败,请检查";
|
||||||
|
}
|
||||||
|
if(isRFIDwrite)
|
||||||
|
tagTID = usbConnection.readUHFTag(0, 3);//读TID,后面需要写EPC操作
|
||||||
|
else
|
||||||
|
tagTID=usbConnection.readUHFTag(0,2);//读TID,不需要写EPC操作
|
||||||
|
usbConnection.Close();//关闭USB连接
|
||||||
|
|
||||||
|
if (tagTID.isEmpty() || tagTID.equals("X"))//未读到数据
|
||||||
|
{
|
||||||
|
System.out.println("未读到标签数据。");
|
||||||
|
return "未读到标签数据";
|
||||||
|
}
|
||||||
|
|
||||||
|
//更新读到的数据
|
||||||
|
if(tagTID!=null&&!tagTID.isEmpty()) {
|
||||||
|
for (zmlabelobject thisLabelObject : thiszmlabelobjectlist) {
|
||||||
|
for (int vi = 0; vi < thisLabelObject.Variables.size(); vi++) {
|
||||||
|
objectvariable thisVariable = thisLabelObject.Variables.get(vi);
|
||||||
|
if (thisVariable.type == 4||thisVariable.type == 5) {//LSF文件中有读取HF或UHF的ID对象
|
||||||
|
thisVariable.data=tagTID;
|
||||||
|
thisLabelObject.Variables.set(vi, thisVariable);//更新数据
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
//更新读到的数据
|
||||||
|
if(tagTID!=null&&!tagTID.isEmpty()) {
|
||||||
|
for (zmlabelobject thisLabelObject : thiszmlabelobjectlist) {
|
||||||
|
for (int vi = 0; vi < thisLabelObject.Variables.size(); vi++) {
|
||||||
|
objectvariable thisVariable = thisLabelObject.Variables.get(vi);
|
||||||
|
if (thisVariable.type == 4||thisVariable.type == 5) {
|
||||||
|
thisVariable.data=tagTID;
|
||||||
|
thisLabelObject.Variables.set(vi, thisVariable);//更新数据
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
//region 设置对象里变量的值(如果需要)
|
||||||
|
//注意:参数varName是lsf文件里对象变量的“子字符串共享名称”,varValue是需要设置的新值
|
||||||
|
zmprintoperate.setVarValue(thiszmlabelobjectlist,"position",printStr);//设置变量的子字符串共享名称为“name”的值
|
||||||
|
zmprintoperate.setVarValue(thiszmlabelobjectlist,"maposition",printStr);//设置变量的子字符串共享名称为“model”的值
|
||||||
|
zmprintoperate.setVarValue(thiszmlabelobjectlist,"rfid",rfidStr);//设置变量的子字符串共享名称为“location”的值
|
||||||
|
// zmprintoperate.setVarValue(thiszmlabelobjectlist,"department","国产操作系统研发13组");//设置变量的子字符串共享名称为“department”的值
|
||||||
|
// zmprintoperate.setVarValue(thiszmlabelobjectlist,"purchasedate","2020-10-08");//设置变量的子字符串共享名称为“purchasedate”的值
|
||||||
|
// zmprintoperate.setVarValue(thiszmlabelobjectlist,"assetcode","2021092300090002"+String.format("%04d",pnum));//设置变量的子字符串共享名称为“assetcode”的值
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
//region 预览标签(即生成标签图片)
|
||||||
|
/* BufferedImage labelimage=zmprintoperate.CreateLabelImage(thiszmprinter, thiszmlabel, thiszmlabelobjectlist);//生成标签图片
|
||||||
|
try {
|
||||||
|
if(labelimage!=null) {
|
||||||
|
File imageoutputfile = new File("labelpreview.png");
|
||||||
|
ImageIO.write(labelimage, "png", imageoutputfile);//保存图片
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("保存预览图片出错,错误信息:"+e.getMessage());
|
||||||
|
}*/
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
//region 将标签生成打印数据
|
||||||
|
byte[] zmpclecommand = zmprintoperate.CreateLabelCommand(thiszmprinter, thiszmlabel, thiszmlabelobjectlist);//生成标签数据
|
||||||
|
if (zmpclecommand == null) {
|
||||||
|
System.out.println("生成标签数据异常为空.");
|
||||||
|
return "生成标签数据异常为空";
|
||||||
|
}
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
//region 通过打印机USB端口发送打印数据
|
||||||
|
UsbConnection usbConnection = new UsbConnection();//建立USB连接
|
||||||
|
if (!usbConnection.Open()) {
|
||||||
|
System.out.println("连接打印机失败,请检查。");
|
||||||
|
return "连接打印机失败,请检查";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
usbConnection.write(zmpclecommand);//发送数据给打印机
|
||||||
|
if (thiszmprinter.printerinterface == printerstyle.RFID_USB) {
|
||||||
|
//如果是RFID打印机,则通过打印机USB端口读回状态,确定打印机收到数据并等待打印完成
|
||||||
|
String returnmsg = usbConnection.read(512);//读取打印机数据
|
||||||
|
if (!returnmsg.isEmpty())
|
||||||
|
System.out.println("打印机返回的数据:" + returnmsg);
|
||||||
|
zmprintoperate.WaitPrintProcess(thiszmprinter, thiszmlabel);//等待打印完成
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
usbConnection.Close();//关闭USB连接
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 查print_rfid表,打印标签
|
||||||
|
|
||||||
|
|
||||||
return "打印成功";
|
return "打印成功";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public interface PcdeDetailMapper
|
|||||||
*/
|
*/
|
||||||
public List<PcdeDetail> selectPcdeDetailList(PcdeDetail pcdeDetail);
|
public List<PcdeDetail> selectPcdeDetailList(PcdeDetail pcdeDetail);
|
||||||
|
|
||||||
|
public List<PcdeDetail> selectPcdeDetailListIds(Object ids);
|
||||||
/**
|
/**
|
||||||
* 新增库位明细
|
* 新增库位明细
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.zg.project.information.service;
|
package com.zg.project.information.service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.zg.project.information.domain.PcdeDetail;
|
import com.zg.project.information.domain.PcdeDetail;
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,21 @@
|
|||||||
<if test="updatedAt != null">and d.updated_at = #{updatedAt}</if>
|
<if test="updatedAt != null">and d.updated_at = #{updatedAt}</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectPcdeDetailListIds" parameterType="PcdeDetail" resultMap="PcdeDetailResult">
|
||||||
|
<include refid="selectPcdeDetailVo"/>
|
||||||
|
<where>
|
||||||
|
<choose>
|
||||||
|
<when test="ids != null and ids.size > 0">
|
||||||
|
AND d.id IN
|
||||||
|
<foreach collection="ids" item="val" open="(" separator="," close=")">
|
||||||
|
#{val}
|
||||||
|
</foreach>
|
||||||
|
</when>
|
||||||
|
|
||||||
|
</choose>
|
||||||
|
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectPcdeDetailById" parameterType="Long" resultMap="PcdeDetailResult">
|
<select id="selectPcdeDetailById" parameterType="Long" resultMap="PcdeDetailResult">
|
||||||
<include refid="selectPcdeDetailVo"/>
|
<include refid="selectPcdeDetailVo"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user