first commit
This commit is contained in:
49
ktg-print/pom.xml
Normal file
49
ktg-print/pom.xml
Normal file
@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ktg</artifactId>
|
||||
<groupId>com.ktg</groupId>
|
||||
<version>3.8.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ktg-print</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>4.1.65.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-models</artifactId>
|
||||
<version>1.6.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>3.20.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ktg</groupId>
|
||||
<artifactId>ktg-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ktg</groupId>
|
||||
<artifactId>ktg-mes</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@ -0,0 +1,95 @@
|
||||
package com.ktg.print.controller;
|
||||
|
||||
import com.ktg.common.annotation.Log;
|
||||
import com.ktg.common.core.controller.BaseController;
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.common.core.page.TableDataInfo;
|
||||
import com.ktg.common.enums.BusinessType;
|
||||
import com.ktg.print.domain.PrintClient;
|
||||
import com.ktg.print.domain.PrintPrinterConfig;
|
||||
import com.ktg.print.service.IPrintClientService;
|
||||
import org.aspectj.weaver.loadtime.Aj;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/print/client")
|
||||
public class PrintClientController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IPrintClientService clientService;
|
||||
|
||||
/**
|
||||
* 查询打印机配置列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(PrintClient client) {
|
||||
List<PrintClient> list = clientService.getClientList(client);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
public TableDataInfo page(PrintClient client)
|
||||
{
|
||||
startPage();
|
||||
List<PrintClient> list = clientService.getClientList(client);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 打印机客户端新增
|
||||
* @param client
|
||||
* @return
|
||||
*/
|
||||
@Log(title = "打印机客户端配置", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
public AjaxResult add(@RequestBody PrintClient client) {
|
||||
return clientService.insertClient(client);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印机客户端详情
|
||||
* @param clientId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/{clientId}")
|
||||
public AjaxResult getInfo(@PathVariable("clientId") Long clientId) {
|
||||
return clientService.selectClientById(clientId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印机客户端修改
|
||||
* @param client
|
||||
* @return
|
||||
*/
|
||||
@Log(title = "客户端配置", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
public AjaxResult edit(@RequestBody PrintClient client) {
|
||||
return clientService.updateClient(client);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除客户端配置
|
||||
* @param clientIds
|
||||
* @return
|
||||
*/
|
||||
@Log(title = "客户端配置", businessType = BusinessType.DELETE)
|
||||
@GetMapping("/remove/{clientIds}")
|
||||
public AjaxResult remove(@PathVariable String clientIds) {
|
||||
return clientService.remove(clientIds);
|
||||
}
|
||||
|
||||
@GetMapping("/getWorkshopAndWorkstation")
|
||||
public AjaxResult getWorkshopAndWorkstation() {
|
||||
return clientService.getWorkshopAndWorkstation();
|
||||
}
|
||||
|
||||
@GetMapping("/getAll")
|
||||
public AjaxResult getAll() {
|
||||
return clientService.getAll();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,83 @@
|
||||
package com.ktg.print.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.ktg.common.constant.UserConstants;
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.common.utils.StringUtils;
|
||||
import com.ktg.mes.dv.domain.DvMachinery;
|
||||
import com.ktg.mes.dv.service.IDvMachineryService;
|
||||
import com.ktg.mes.md.domain.MdItem;
|
||||
import com.ktg.mes.md.service.IMdItemService;
|
||||
import com.ktg.mes.pro.domain.ProCard;
|
||||
import com.ktg.mes.pro.domain.ProRouteProcess;
|
||||
import com.ktg.mes.pro.domain.ProRouteProduct;
|
||||
import com.ktg.mes.pro.mapper.ProRouteMapper;
|
||||
import com.ktg.mes.pro.mapper.ProRouteProductMapper;
|
||||
import com.ktg.mes.pro.service.IProCardService;
|
||||
import com.ktg.mes.pro.service.IProRouteProcessService;
|
||||
import com.ktg.mes.wm.domain.WmBarcode;
|
||||
import com.ktg.mes.wm.service.IWmBarcodeService;
|
||||
import com.ktg.print.domain.PrintBarcodeModel;
|
||||
import com.ktg.print.domain.PrintPrinterConfig;
|
||||
import com.ktg.print.protocol.PrintMessageProto;
|
||||
import com.ktg.print.server.PrintClientInfoMessageHandler;
|
||||
import com.ktg.print.server.PrintServerDefaultHandler;
|
||||
import com.ktg.print.service.IPrintPrinterConfigService;
|
||||
import com.ktg.print.service.IPrintService;
|
||||
import io.netty.channel.Channel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author yanshikui
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/print/barcodePrint")
|
||||
public class PrintController {
|
||||
|
||||
@Autowired
|
||||
private IPrintService iPrintService;
|
||||
|
||||
/**
|
||||
* 条码打印公共接口
|
||||
*
|
||||
* @param printBarcodeModel
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/printing")
|
||||
public AjaxResult printBarcodeLabel(@RequestBody PrintBarcodeModel printBarcodeModel) {
|
||||
Map<String, Object> result = iPrintService.printLabel(printBarcodeModel);
|
||||
String clientIp = "";
|
||||
PrintMessageProto.Printer msg = null;
|
||||
if (!"SUCESS".equals(result.get("msg"))) {
|
||||
return AjaxResult.error(result.get("data").toString());
|
||||
} else {
|
||||
clientIp = result.get("clientIp").toString();
|
||||
msg = (PrintMessageProto.Printer) result.get("data");
|
||||
}
|
||||
// 获取信道数据并发送消息对象给指定打印机客户端
|
||||
//打印机名称和打印机客户端地址映射 一对一关系
|
||||
ConcurrentHashMap<String, SocketAddress> socketAddress = PrintClientInfoMessageHandler.socketAddressMap;
|
||||
//根据客户端和通道信息
|
||||
ConcurrentHashMap<SocketAddress, Channel> channels = PrintServerDefaultHandler.chanelMap;
|
||||
if (channels.isEmpty()
|
||||
|| socketAddress.isEmpty()
|
||||
|| socketAddress.get(clientIp) == null
|
||||
|| channels.get(socketAddress.get(clientIp)) == null) {
|
||||
return AjaxResult.error("打印机客户端连接异常" + "(" + clientIp + ")");
|
||||
}
|
||||
Channel channel = channels.get(socketAddress.get(clientIp));
|
||||
channel.writeAndFlush(msg);
|
||||
return AjaxResult.success("打印成功");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,136 @@
|
||||
package com.ktg.print.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ktg.common.constant.UserConstants;
|
||||
import com.ktg.print.domain.PrintPrinterConfig;
|
||||
import com.ktg.print.service.IPrintPrinterConfigService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ktg.common.annotation.Log;
|
||||
import com.ktg.common.core.controller.BaseController;
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.common.enums.BusinessType;
|
||||
|
||||
import com.ktg.common.utils.poi.ExcelUtil;
|
||||
import com.ktg.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 打印机配置Controller
|
||||
*
|
||||
* @author yinjinlu
|
||||
* @date 2023-09-01
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/print/printerconfig")
|
||||
public class PrintPrinterConfigController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IPrintPrinterConfigService printPrinterConfigService;
|
||||
|
||||
/**
|
||||
* 查询打印机配置列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('print:printerconfig:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(PrintPrinterConfig printPrinterConfig)
|
||||
{
|
||||
startPage();
|
||||
List<PrintPrinterConfig> list = printPrinterConfigService.selectPrintPrinterConfigList(printPrinterConfig);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出打印机配置列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('print:printerconfig:export')")
|
||||
@Log(title = "打印机配置", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, PrintPrinterConfig printPrinterConfig)
|
||||
{
|
||||
List<PrintPrinterConfig> list = printPrinterConfigService.selectPrintPrinterConfigList(printPrinterConfig);
|
||||
ExcelUtil<PrintPrinterConfig> util = new ExcelUtil<PrintPrinterConfig>(PrintPrinterConfig.class);
|
||||
util.exportExcel(response, list, "打印机配置数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取打印机配置详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('print:printerconfig:query')")
|
||||
@GetMapping(value = "/{printerId}")
|
||||
public AjaxResult getInfo(@PathVariable("printerId") Long printerId)
|
||||
{
|
||||
return AjaxResult.success(printPrinterConfigService.selectPrintPrinterConfigByPrinterId(printerId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增打印机配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('print:printerconfig:add')")
|
||||
@Log(title = "打印机配置", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody PrintPrinterConfig printPrinterConfig)
|
||||
{
|
||||
if(UserConstants.NOT_UNIQUE.equals(printPrinterConfigService.checkPrinterCodeUnique(printPrinterConfig))){
|
||||
return AjaxResult.error("打印机编号已存在!");
|
||||
}
|
||||
|
||||
return toAjax(printPrinterConfigService.insertPrintPrinterConfig(printPrinterConfig));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改打印机配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('print:printerconfig:edit')")
|
||||
@Log(title = "打印机配置", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PrintPrinterConfig printPrinterConfig)
|
||||
{
|
||||
if(UserConstants.NOT_UNIQUE.equals(printPrinterConfigService.checkPrinterCodeUnique(printPrinterConfig))){
|
||||
return AjaxResult.error("打印机编号已存在!");
|
||||
}
|
||||
|
||||
return toAjax(printPrinterConfigService.updatePrintPrinterConfig(printPrinterConfig));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除打印机配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('print:printerconfig:remove')")
|
||||
@Log(title = "打印机配置", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{printerIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] printerIds)
|
||||
{
|
||||
return toAjax(printPrinterConfigService.deletePrintPrinterConfigByPrinterIds(printerIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询默认打印机
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('print:printerconfig:query')")
|
||||
@GetMapping("/getDefaultPrint/{clientId}")
|
||||
public AjaxResult getDefaultPrint(@PathVariable Long clientId) {
|
||||
return printPrinterConfigService.getDefaultPrint(clientId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置默认打印机
|
||||
* @param printPrinterConfig
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('print:printerconfig:query')")
|
||||
@PostMapping("/editDefaultPrint")
|
||||
public AjaxResult editDefaultPrint(@RequestBody PrintPrinterConfig printPrinterConfig) {
|
||||
return printPrinterConfigService.editDefaultPrint(printPrinterConfig);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,121 @@
|
||||
package com.ktg.print.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ktg.common.annotation.Log;
|
||||
import com.ktg.common.core.controller.BaseController;
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.common.enums.BusinessType;
|
||||
import com.ktg.print.domain.PrintTemplate;
|
||||
import com.ktg.print.service.IPrintTemplateService;
|
||||
import com.ktg.common.utils.poi.ExcelUtil;
|
||||
import com.ktg.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 打印模板配置Controller
|
||||
*
|
||||
* @author yinjinlu
|
||||
* @date 2024-04-17
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/print/template")
|
||||
public class PrintTemplateController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IPrintTemplateService printTemplateService;
|
||||
|
||||
/**
|
||||
* 查询打印模板配置列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('print:template:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(PrintTemplate printTemplate)
|
||||
{
|
||||
startPage();
|
||||
List<PrintTemplate> list = printTemplateService.selectPrintTemplateList(printTemplate);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出打印模板配置列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('print:template:export')")
|
||||
@Log(title = "打印模板配置", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, PrintTemplate printTemplate)
|
||||
{
|
||||
List<PrintTemplate> list = printTemplateService.selectPrintTemplateList(printTemplate);
|
||||
ExcelUtil<PrintTemplate> util = new ExcelUtil<PrintTemplate>(PrintTemplate.class);
|
||||
util.exportExcel(response, list, "打印模板配置数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取打印模板配置详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('print:template:query')")
|
||||
@GetMapping(value = "/{templateId}")
|
||||
public AjaxResult getInfo(@PathVariable("templateId") Long templateId)
|
||||
{
|
||||
return AjaxResult.success(printTemplateService.selectPrintTemplateByTemplateId(templateId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增打印模板配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('print:template:add')")
|
||||
@Log(title = "打印模板配置", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody PrintTemplate printTemplate)
|
||||
{
|
||||
return printTemplateService.insertPrintTemplate(printTemplate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改打印模板配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('print:template:edit')")
|
||||
@Log(title = "打印模板配置", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PrintTemplate printTemplate)
|
||||
{
|
||||
return toAjax(printTemplateService.updatePrintTemplate(printTemplate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除打印模板配置
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('print:template:remove')")
|
||||
@Log(title = "打印模板配置", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{templateIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] templateIds)
|
||||
{
|
||||
return toAjax(printTemplateService.deletePrintTemplateByTemplateIds(templateIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据打印模板类型获取打印模板配置详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('print:template:query')")
|
||||
@GetMapping(value = "/templateType/{templateType}")
|
||||
public AjaxResult getInfo(@PathVariable("templateType") String templateType)
|
||||
{
|
||||
PrintTemplate printTemplate = new PrintTemplate();
|
||||
printTemplate.setTemplateType(templateType);
|
||||
List<PrintTemplate> printTemplates = printTemplateService.selectPrintTemplateList(printTemplate);
|
||||
if (printTemplates != null && printTemplates.size() > 0) {
|
||||
return AjaxResult.success(printTemplates.get(0));
|
||||
} else {
|
||||
return AjaxResult.error("打印模板不存在");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,91 @@
|
||||
package com.ktg.print.controller.mobile;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.ktg.common.constant.UserConstants;
|
||||
import com.ktg.common.core.controller.BaseController;
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.common.utils.StringUtils;
|
||||
import com.ktg.mes.dv.domain.DvMachinery;
|
||||
import com.ktg.mes.dv.service.IDvMachineryService;
|
||||
import com.ktg.mes.md.domain.MdItem;
|
||||
import com.ktg.mes.md.service.IMdItemService;
|
||||
import com.ktg.mes.pro.domain.ProCard;
|
||||
import com.ktg.mes.pro.domain.ProRouteProcess;
|
||||
import com.ktg.mes.pro.domain.ProRouteProduct;
|
||||
import com.ktg.mes.pro.mapper.ProRouteMapper;
|
||||
import com.ktg.mes.pro.mapper.ProRouteProductMapper;
|
||||
import com.ktg.mes.pro.service.IProCardService;
|
||||
import com.ktg.mes.pro.service.IProRouteProcessService;
|
||||
import com.ktg.mes.wm.domain.WmBarcode;
|
||||
import com.ktg.mes.wm.service.IWmBarcodeService;
|
||||
import com.ktg.print.domain.PrintBarcodeModel;
|
||||
import com.ktg.print.domain.PrintPrinterConfig;
|
||||
import com.ktg.print.protocol.PrintMessageProto;
|
||||
import com.ktg.print.server.PrintClientInfoMessageHandler;
|
||||
import com.ktg.print.server.PrintServerDefaultHandler;
|
||||
import com.ktg.print.service.IPrintPrinterConfigService;
|
||||
import com.ktg.print.service.IPrintService;
|
||||
import io.netty.channel.Channel;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author yinjinlu
|
||||
* @description
|
||||
* @date 2024/11/25
|
||||
*/
|
||||
@Api("标签打印机查询接口")
|
||||
@RestController
|
||||
@RequestMapping("/mobile/print/barcodePrint")
|
||||
public class PrintMobController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IPrintService iPrintService;
|
||||
|
||||
/**
|
||||
* 条码打印公共接口
|
||||
*
|
||||
* @param printBarcodeModel
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/printing")
|
||||
public AjaxResult printBarcodeLabel(@RequestBody PrintBarcodeModel printBarcodeModel) {
|
||||
Map<String, Object> result = iPrintService.printLabel(printBarcodeModel);
|
||||
String clientIp = "";
|
||||
PrintMessageProto.Printer msg = null;
|
||||
if (!"SUCESS".equals(result.get("msg"))) {
|
||||
return AjaxResult.error(result.get("data").toString());
|
||||
} else {
|
||||
clientIp = result.get("clientIp").toString();
|
||||
msg = (PrintMessageProto.Printer) result.get("data");
|
||||
}
|
||||
// 获取信道数据并发送消息对象给指定打印机客户端
|
||||
//打印机名称和打印机客户端地址映射 一对一关系
|
||||
ConcurrentHashMap<String, SocketAddress> socketAddress = PrintClientInfoMessageHandler.socketAddressMap;
|
||||
//根据客户端和通道信息
|
||||
ConcurrentHashMap<SocketAddress, Channel> channels = PrintServerDefaultHandler.chanelMap;
|
||||
if (channels.isEmpty()
|
||||
|| socketAddress.isEmpty()
|
||||
|| socketAddress.get(clientIp) == null
|
||||
|| channels.get(socketAddress.get(clientIp)) == null) {
|
||||
return AjaxResult.error("打印机客户端连接异常" + "(" + clientIp + ")");
|
||||
}
|
||||
Channel channel = channels.get(socketAddress.get(clientIp));
|
||||
channel.writeAndFlush(msg);
|
||||
return AjaxResult.success("打印成功");
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package com.ktg.print.controller.mobile;
|
||||
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.print.domain.PrintPrinterConfig;
|
||||
import com.ktg.print.service.IPrintPrinterConfigService;
|
||||
import io.swagger.annotations.Api;
|
||||
import com.ktg.common.core.controller.BaseController;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yinjinlu
|
||||
* @description
|
||||
* @date 2024/11/24
|
||||
*/
|
||||
@Api("标签打印机查询接口")
|
||||
@RestController
|
||||
@RequestMapping("/mobile/print/printerconfig")
|
||||
public class PrintPrinterMobileController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IPrintPrinterConfigService printPrinterConfigService;
|
||||
|
||||
@ApiOperation("查询打印机清单")
|
||||
@GetMapping("/list")
|
||||
public AjaxResult getPrinterList(PrintPrinterConfig param){
|
||||
List<PrintPrinterConfig> list = printPrinterConfigService.selectPrintPrinterConfigList(param);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.ktg.print.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yanshikui
|
||||
*/
|
||||
@Data
|
||||
public class PrintBarcodeModel {
|
||||
private Map<String, String> params;
|
||||
private String printerCode;
|
||||
private String businessType;
|
||||
private Long businessId;
|
||||
private String businessCode;
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
package com.ktg.print.domain;
|
||||
|
||||
import com.ktg.common.annotation.Excel;
|
||||
import com.ktg.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PrintClient extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 打印机客户端ID */
|
||||
private Long clientId;
|
||||
|
||||
/** 打印机客户端编码 */
|
||||
private String clientCode;
|
||||
|
||||
/** 打印机客户端名称 */
|
||||
private String clientName;
|
||||
|
||||
/** 打印客户端IP */
|
||||
@Excel(name = "打印客户端IP")
|
||||
private String clientIp;
|
||||
|
||||
/** 打印客户端端口 */
|
||||
@Excel(name = "打印客户端端口")
|
||||
private Long clientPort;
|
||||
|
||||
/** 打印客户端token */
|
||||
private String clientToken;
|
||||
|
||||
/** 客户端状态 */
|
||||
private String status;
|
||||
|
||||
/** 所属车间ID */
|
||||
private Long workshopId;
|
||||
|
||||
/** 所属车间编码 */
|
||||
private String workshopCode;
|
||||
|
||||
/** 所属车间名称 */
|
||||
private String workshopName;
|
||||
|
||||
/** 工作站ID */
|
||||
private Long workstationId;
|
||||
|
||||
/** 工作站编码 */
|
||||
private String workstationCode;
|
||||
|
||||
/** 工作站名称 */
|
||||
private String workstationName;
|
||||
|
||||
/** 预留字段1 */
|
||||
private String attr1;
|
||||
|
||||
/** 预留字段2 */
|
||||
private String attr2;
|
||||
|
||||
/** 预留字段3 */
|
||||
private Long attr3;
|
||||
|
||||
/** 预留字段4 */
|
||||
private Long attr4;
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
package com.ktg.print.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ktg.common.annotation.Excel;
|
||||
import com.ktg.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 打印机配置对象 print_printer_config
|
||||
*
|
||||
* @author yinjinlu
|
||||
* @date 2023-09-01
|
||||
*/
|
||||
@Data
|
||||
public class PrintPrinterConfig extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 打印机ID */
|
||||
private Long printerId;
|
||||
|
||||
/** 打印机客户端ID */
|
||||
private Long clientId;
|
||||
|
||||
/**
|
||||
* 打印机编号
|
||||
*/
|
||||
private String printerCode;
|
||||
|
||||
/** 打印机类型 */
|
||||
@Excel(name = "打印机类型")
|
||||
private String printerType;
|
||||
|
||||
/** 打印机名称 */
|
||||
@Excel(name = "打印机名称")
|
||||
private String printerName;
|
||||
|
||||
/** 品牌 */
|
||||
@Excel(name = "品牌")
|
||||
private String brand;
|
||||
|
||||
/** 型号 */
|
||||
@Excel(name = "型号")
|
||||
private String printerModel;
|
||||
|
||||
/** 连接类型 */
|
||||
@Excel(name = "连接类型")
|
||||
private String connectionType;
|
||||
|
||||
/** 图片URL */
|
||||
@Excel(name = "图片URL")
|
||||
private String printerUrl;
|
||||
|
||||
/** 打印机IP */
|
||||
@Excel(name = "打印机IP")
|
||||
private String printerIp;
|
||||
|
||||
/** 打印机端口 */
|
||||
@Excel(name = "打印机端口")
|
||||
private Long printerPort;
|
||||
|
||||
/** 启用状态 */
|
||||
@Excel(name = "启用状态")
|
||||
private String enableFlag;
|
||||
|
||||
/** 打印机状态 */
|
||||
@Excel(name = "打印机状态")
|
||||
private String status;
|
||||
|
||||
private String defaultFlag;
|
||||
|
||||
/** 预留字段1 */
|
||||
private String attr1;
|
||||
|
||||
/** 预留字段2 */
|
||||
private String attr2;
|
||||
|
||||
/** 预留字段3 */
|
||||
private Long attr3;
|
||||
|
||||
/** 预留字段4 */
|
||||
private Long attr4;
|
||||
}
|
||||
223
ktg-print/src/main/java/com/ktg/print/domain/PrintTemplate.java
Normal file
223
ktg-print/src/main/java/com/ktg/print/domain/PrintTemplate.java
Normal file
@ -0,0 +1,223 @@
|
||||
package com.ktg.print.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ktg.common.annotation.Excel;
|
||||
import com.ktg.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 打印模板配置对象 print_template
|
||||
*
|
||||
* @author yinjinlu
|
||||
* @date 2024-04-17
|
||||
*/
|
||||
public class PrintTemplate extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 模板ID */
|
||||
private Long templateId;
|
||||
|
||||
/** 模板编号 */
|
||||
@Excel(name = "模板编号")
|
||||
private String templateCode;
|
||||
|
||||
/** 模板名称 */
|
||||
@Excel(name = "模板名称")
|
||||
private String templateName;
|
||||
|
||||
/** 模板类型 */
|
||||
@Excel(name = "模板类型")
|
||||
private String templateType;
|
||||
|
||||
/** 模板内容 */
|
||||
@Excel(name = "模板内容")
|
||||
private String templateJson;
|
||||
|
||||
private String paperType;
|
||||
|
||||
private Integer templateWidth;
|
||||
|
||||
private Integer templateHeight;
|
||||
|
||||
/** 是否默认 */
|
||||
@Excel(name = "是否默认")
|
||||
private String isDefault;
|
||||
|
||||
/** 启用状态 */
|
||||
@Excel(name = "启用状态")
|
||||
private String enableFlag;
|
||||
|
||||
/** 预留字段1 */
|
||||
private String attr1;
|
||||
|
||||
/** 预留字段2 */
|
||||
private String attr2;
|
||||
|
||||
/** 预留字段3 */
|
||||
private Long attr3;
|
||||
|
||||
/** 预留字段4 */
|
||||
private Long attr4;
|
||||
|
||||
/** $column.columnComment */
|
||||
@Excel(name = "启用状态")
|
||||
private String templatePic;
|
||||
|
||||
public void setTemplateId(Long templateId)
|
||||
{
|
||||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
public Long getTemplateId()
|
||||
{
|
||||
return templateId;
|
||||
}
|
||||
public void setTemplateCode(String templateCode)
|
||||
{
|
||||
this.templateCode = templateCode;
|
||||
}
|
||||
|
||||
public String getTemplateCode()
|
||||
{
|
||||
return templateCode;
|
||||
}
|
||||
public void setTemplateName(String templateName)
|
||||
{
|
||||
this.templateName = templateName;
|
||||
}
|
||||
|
||||
public String getTemplateName()
|
||||
{
|
||||
return templateName;
|
||||
}
|
||||
public void setTemplateType(String templateType)
|
||||
{
|
||||
this.templateType = templateType;
|
||||
}
|
||||
|
||||
public String getTemplateType()
|
||||
{
|
||||
return templateType;
|
||||
}
|
||||
public void setTemplateJson(String templateJson)
|
||||
{
|
||||
this.templateJson = templateJson;
|
||||
}
|
||||
|
||||
public String getTemplateJson()
|
||||
{
|
||||
return templateJson;
|
||||
}
|
||||
|
||||
public String getPaperType() {
|
||||
return paperType;
|
||||
}
|
||||
|
||||
public void setPaperType(String paperType) {
|
||||
this.paperType = paperType;
|
||||
}
|
||||
|
||||
public Integer getTemplateWidth() {
|
||||
return templateWidth;
|
||||
}
|
||||
|
||||
public void setTemplateWidth(Integer templateWidth) {
|
||||
this.templateWidth = templateWidth;
|
||||
}
|
||||
|
||||
public Integer getTemplateHeight() {
|
||||
return templateHeight;
|
||||
}
|
||||
|
||||
public void setTemplateHeight(Integer templateHeight) {
|
||||
this.templateHeight = templateHeight;
|
||||
}
|
||||
|
||||
public void setIsDefault(String isDefault)
|
||||
{
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
|
||||
public String getIsDefault()
|
||||
{
|
||||
return isDefault;
|
||||
}
|
||||
public void setEnableFlag(String enableFlag)
|
||||
{
|
||||
this.enableFlag = enableFlag;
|
||||
}
|
||||
|
||||
public String getEnableFlag()
|
||||
{
|
||||
return enableFlag;
|
||||
}
|
||||
public void setAttr1(String attr1)
|
||||
{
|
||||
this.attr1 = attr1;
|
||||
}
|
||||
|
||||
public String getAttr1()
|
||||
{
|
||||
return attr1;
|
||||
}
|
||||
public void setAttr2(String attr2)
|
||||
{
|
||||
this.attr2 = attr2;
|
||||
}
|
||||
|
||||
public String getAttr2()
|
||||
{
|
||||
return attr2;
|
||||
}
|
||||
public void setAttr3(Long attr3)
|
||||
{
|
||||
this.attr3 = attr3;
|
||||
}
|
||||
|
||||
public Long getAttr3()
|
||||
{
|
||||
return attr3;
|
||||
}
|
||||
public void setAttr4(Long attr4)
|
||||
{
|
||||
this.attr4 = attr4;
|
||||
}
|
||||
|
||||
public Long getAttr4()
|
||||
{
|
||||
return attr4;
|
||||
}
|
||||
public void setTemplatePic(String templatePic)
|
||||
{
|
||||
this.templatePic = templatePic;
|
||||
}
|
||||
|
||||
public String getTemplatePic()
|
||||
{
|
||||
return templatePic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("templateId", getTemplateId())
|
||||
.append("templateCode", getTemplateCode())
|
||||
.append("templateName", getTemplateName())
|
||||
.append("templateType", getTemplateType())
|
||||
.append("templateJson", getTemplateJson())
|
||||
.append("isDefault", getIsDefault())
|
||||
.append("enableFlag", getEnableFlag())
|
||||
.append("remark", getRemark())
|
||||
.append("attr1", getAttr1())
|
||||
.append("attr2", getAttr2())
|
||||
.append("attr3", getAttr3())
|
||||
.append("attr4", getAttr4())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("templatePic", getTemplatePic())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.ktg.print.domain.vo;
|
||||
|
||||
import com.ktg.mes.md.domain.MdWorkshop;
|
||||
import com.ktg.mes.md.domain.MdWorkstation;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ClientDictVO {
|
||||
|
||||
// 车间列表
|
||||
private List<MdWorkshop> workshopList;
|
||||
|
||||
// 工作站列表
|
||||
private List<MdWorkstation> workstations;
|
||||
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.ktg.print.mapper;
|
||||
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.print.domain.PrintClient;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PrintClientMapper {
|
||||
List<PrintClient> getClientList(PrintClient client);
|
||||
|
||||
int insertClient(PrintClient client);
|
||||
|
||||
PrintClient checkCilentCodeUnique(PrintClient client);
|
||||
|
||||
PrintClient selectById(Long clientId);
|
||||
|
||||
int updateClient(PrintClient client);
|
||||
|
||||
int deleteByIds(@Param("clientIds") List<String> clientIds);
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
package com.ktg.print.mapper;
|
||||
|
||||
import com.ktg.print.domain.PrintPrinterConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 打印机配置Mapper接口
|
||||
*
|
||||
* @author yinjinlu
|
||||
* @date 2023-09-01
|
||||
*/
|
||||
public interface PrintPrinterConfigMapper
|
||||
{
|
||||
/**
|
||||
* 查询打印机配置
|
||||
*
|
||||
* @param printerId 打印机配置主键
|
||||
* @return 打印机配置
|
||||
*/
|
||||
public PrintPrinterConfig selectPrintPrinterConfigByPrinterId(Long printerId);
|
||||
|
||||
/**
|
||||
* 查询打印机配置
|
||||
*
|
||||
* @param printerCode 打印机编号
|
||||
* @return 打印机配置
|
||||
*/
|
||||
public PrintPrinterConfig selectPrintPrinterConfigByPrinterCode(String printerCode);
|
||||
|
||||
/**
|
||||
* 查询打印机配置列表
|
||||
*
|
||||
* @param printPrinterConfig 打印机配置
|
||||
* @return 打印机配置集合
|
||||
*/
|
||||
public List<PrintPrinterConfig> selectPrintPrinterConfigList(PrintPrinterConfig printPrinterConfig);
|
||||
|
||||
/**
|
||||
* 检查编号是否唯一
|
||||
* @param config
|
||||
* @return
|
||||
*/
|
||||
public PrintPrinterConfig checkPrinterCodeUnique(PrintPrinterConfig config);
|
||||
|
||||
/**
|
||||
* 新增打印机配置
|
||||
*
|
||||
* @param printPrinterConfig 打印机配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPrintPrinterConfig(PrintPrinterConfig printPrinterConfig);
|
||||
|
||||
/**
|
||||
* 修改打印机配置
|
||||
*
|
||||
* @param printPrinterConfig 打印机配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePrintPrinterConfig(PrintPrinterConfig printPrinterConfig);
|
||||
|
||||
/**
|
||||
* 删除打印机配置
|
||||
*
|
||||
* @param printerId 打印机配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePrintPrinterConfigByPrinterId(Long printerId);
|
||||
|
||||
/**
|
||||
* 批量删除打印机配置
|
||||
*
|
||||
* @param printerIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePrintPrinterConfigByPrinterIds(Long[] printerIds);
|
||||
|
||||
/**
|
||||
* 查询默认打印机
|
||||
* @return
|
||||
*/
|
||||
public PrintPrinterConfig getDefaultPrint(Long clientId);
|
||||
|
||||
List<PrintPrinterConfig> getByClientId(Long clientId);
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package com.ktg.print.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ktg.print.domain.PrintTemplate;
|
||||
|
||||
/**
|
||||
* 打印模板配置Mapper接口
|
||||
*
|
||||
* @author yinjinlu
|
||||
* @date 2024-04-17
|
||||
*/
|
||||
public interface PrintTemplateMapper
|
||||
{
|
||||
/**
|
||||
* 查询打印模板配置
|
||||
*
|
||||
* @param templateId 打印模板配置主键
|
||||
* @return 打印模板配置
|
||||
*/
|
||||
public PrintTemplate selectPrintTemplateByTemplateId(Long templateId);
|
||||
|
||||
/**
|
||||
* 查询打印模板配置列表
|
||||
*
|
||||
* @param printTemplate 打印模板配置
|
||||
* @return 打印模板配置集合
|
||||
*/
|
||||
public List<PrintTemplate> selectPrintTemplateList(PrintTemplate printTemplate);
|
||||
|
||||
/**
|
||||
* 新增打印模板配置
|
||||
*
|
||||
* @param printTemplate 打印模板配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPrintTemplate(PrintTemplate printTemplate);
|
||||
|
||||
/**
|
||||
* 修改打印模板配置
|
||||
*
|
||||
* @param printTemplate 打印模板配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePrintTemplate(PrintTemplate printTemplate);
|
||||
|
||||
/**
|
||||
* 删除打印模板配置
|
||||
*
|
||||
* @param templateId 打印模板配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePrintTemplateByTemplateId(Long templateId);
|
||||
|
||||
/**
|
||||
* 批量删除打印模板配置
|
||||
*
|
||||
* @param templateIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePrintTemplateByTemplateIds(Long[] templateIds);
|
||||
}
|
||||
17174
ktg-print/src/main/java/com/ktg/print/protocol/PrintMessageProto.java
Normal file
17174
ktg-print/src/main/java/com/ktg/print/protocol/PrintMessageProto.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,130 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package com.ktg.print.protocol;
|
||||
|
||||
option java_package = "com.ktg.print.protocol";
|
||||
|
||||
option java_outer_classname = "PrintMessageProto";
|
||||
|
||||
message Printer{
|
||||
|
||||
enum DataType{
|
||||
IQC_PrintMessage = 0;//proto3枚举enum编号从0开始
|
||||
PQC_PrintMessage = 1;
|
||||
OQC_PrintMessage = 2;
|
||||
Print_ClientInfoMessage = 3;
|
||||
Printing_OfCirculation = 4;
|
||||
Material_Products = 5;
|
||||
Warehouse_=6;
|
||||
Warehouse_Location=7;
|
||||
Warehouse_Area=8;
|
||||
Equipment_=9;
|
||||
Workstation_=10;
|
||||
TestPrinter_=11;
|
||||
}
|
||||
|
||||
//用data_type来识别哪个枚举类型(DataType是People的第一个属性,属性名是data_type)
|
||||
DataType data_type = 1;
|
||||
PrintInfo printInfo = 14;
|
||||
//每次枚举类型最多只能出现其中一个,节省空间
|
||||
oneof dataBody{
|
||||
IQCPrintMessage iqcPrintMessage = 2;
|
||||
PQCPrintMessage pqcPrintMessage = 3;
|
||||
OQCPrintMessage oqPrintMessage = 4;
|
||||
PrintClientInfoMessage printClientInfoMessage = 5;
|
||||
PrintingOfCirculation printingOfCirculation = 6;
|
||||
MaterialProducts materialProducts = 7;
|
||||
Warehouse warehouse = 8;
|
||||
WarehouseLocation warehouseLocation = 9;
|
||||
WarehouseArea warehouseArea = 10;
|
||||
Equipment equipment = 11;
|
||||
Workstation workstation = 12;
|
||||
TestPrinter testPrinter = 13;
|
||||
}
|
||||
|
||||
message IQCPrintMessage {
|
||||
string sampleCode = 1;
|
||||
string qcObject = 2;
|
||||
string sampleTime = 3;
|
||||
string batchCode = 4;
|
||||
}
|
||||
|
||||
message PQCPrintMessage {
|
||||
string sampleCode = 1;
|
||||
string qcObject = 2;
|
||||
string sampleTime = 3;
|
||||
string sampleLocation = 4;
|
||||
}
|
||||
|
||||
message OQCPrintMessage {
|
||||
string sampleCode = 1;
|
||||
string qcObject = 2;
|
||||
string sampleTime = 3;
|
||||
string batchCode = 4;
|
||||
string packageType = 5;
|
||||
}
|
||||
|
||||
//客户端信息
|
||||
message PrintClientInfoMessage {
|
||||
string ip = 1;
|
||||
string location = 2;
|
||||
string sid = 3;
|
||||
}
|
||||
|
||||
message PrintingOfCirculation{
|
||||
string workOrderNumber = 1;
|
||||
string materialCode = 2;
|
||||
string materialName = 3;
|
||||
string specificationAndModel = 4;
|
||||
string processingProcedure = 5;
|
||||
string param = 6;
|
||||
}
|
||||
|
||||
message MaterialProducts{
|
||||
string materialCode = 1;
|
||||
string materialName = 2;
|
||||
string specificationAndModel = 3;
|
||||
string param = 4;
|
||||
}
|
||||
message Warehouse{
|
||||
string warehouseCode = 1;
|
||||
string warehouseName = 2;
|
||||
string personInCharge = 3;
|
||||
string param = 4;
|
||||
}
|
||||
message WarehouseLocation{
|
||||
string warehouseLocationCode = 1;
|
||||
string warehouseLocationName = 2;
|
||||
string position = 3;
|
||||
string param = 4;
|
||||
}
|
||||
message WarehouseArea{
|
||||
string warehouseAreaCode = 1;
|
||||
string warehouseAreaName = 2;
|
||||
string param = 3;
|
||||
}
|
||||
message Equipment{
|
||||
string equipmentCode = 1;
|
||||
string equipmentName = 2;
|
||||
string specificationAndModel = 3;
|
||||
string param = 4;
|
||||
}
|
||||
message Workstation{
|
||||
string workstationCode = 1;
|
||||
string workstationName = 2;
|
||||
string belongingProcess = 3;
|
||||
string param = 4;
|
||||
}
|
||||
message TestPrinter{
|
||||
string title = 1;
|
||||
string text = 2;
|
||||
}
|
||||
|
||||
//打印机信息
|
||||
message PrintInfo {
|
||||
string ip = 1;
|
||||
string code = 2;
|
||||
string name = 3;
|
||||
string port = 4;
|
||||
}
|
||||
}
|
||||
80
ktg-print/src/main/java/com/ktg/print/response/R.java
Normal file
80
ktg-print/src/main/java/com/ktg/print/response/R.java
Normal file
@ -0,0 +1,80 @@
|
||||
package com.ktg.print.response;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class R<T> implements Serializable {
|
||||
/**
|
||||
* 成功失败标识
|
||||
*/
|
||||
private boolean flag;
|
||||
|
||||
/**
|
||||
* 响应数据
|
||||
*/
|
||||
private T data;
|
||||
/**
|
||||
* 状态码
|
||||
*/
|
||||
private Integer code;
|
||||
/**
|
||||
* 响应消息
|
||||
*/
|
||||
private String message;
|
||||
|
||||
public static Integer SUCCESS_200 = 200;
|
||||
public static Integer FAIL_500 = 500;
|
||||
|
||||
public static <T> R<T> success() {
|
||||
return R.success(null);
|
||||
}
|
||||
|
||||
public static <T> R<T> success(T result) {
|
||||
R<T> systemResult = new R<>();
|
||||
systemResult.setFlag(true);
|
||||
systemResult.setData(result);
|
||||
systemResult.setMessage("成功");
|
||||
systemResult.setCode(SUCCESS_200);
|
||||
return systemResult;
|
||||
}
|
||||
|
||||
public static <T> R<T> success(String msg) {
|
||||
R<T> systemResult = new R<>();
|
||||
systemResult.setFlag(true);
|
||||
systemResult.setMessage(msg);
|
||||
return systemResult;
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(T result) {
|
||||
R<T> systemResult = new R<>();
|
||||
systemResult.setFlag(false);
|
||||
systemResult.setCode(FAIL_500);
|
||||
systemResult.setData(result);
|
||||
return systemResult;
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(String msg) {
|
||||
R<T> systemResult = new R<>();
|
||||
systemResult.setFlag(false);
|
||||
systemResult.setCode(FAIL_500);
|
||||
systemResult.setMessage(msg);
|
||||
return systemResult;
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(T result, String msg) {
|
||||
R<T> systemResult = new R<>();
|
||||
systemResult.setFlag(false);
|
||||
systemResult.setCode(FAIL_500);
|
||||
systemResult.setMessage(msg);
|
||||
systemResult.setData(result);
|
||||
return systemResult;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.ktg.print.server;
|
||||
|
||||
import com.ktg.print.protocol.PrintMessageProto;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class PrintClientInfoMessageHandler extends SimpleChannelInboundHandler<PrintMessageProto.Printer> {
|
||||
|
||||
public static ConcurrentHashMap<String, SocketAddress> socketAddressMap = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext channelHandlerContext, PrintMessageProto.Printer printClientInfoMessage) throws Exception {
|
||||
//打印机名称和打印机客户端地址映射 一对一关系
|
||||
socketAddressMap.put(printClientInfoMessage.getPrintClientInfoMessage().getLocation(), channelHandlerContext.channel().remoteAddress());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
package com.ktg.print.server;
|
||||
|
||||
import com.ktg.print.protocol.PrintMessageProto;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
import io.netty.handler.codec.protobuf.ProtobufDecoder;
|
||||
import io.netty.handler.codec.protobuf.ProtobufEncoder;
|
||||
import io.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder;
|
||||
import io.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
//@Component
|
||||
public class PrintServer implements DisposableBean {
|
||||
|
||||
EventLoopGroup bossGroup = null;
|
||||
EventLoopGroup workerGroup = null;
|
||||
int port = 9016;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void nettyServerInit() {
|
||||
ExecutorService executorService = Executors.newSingleThreadExecutor();
|
||||
executorService.submit(new service());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
if (bossGroup!=null) {
|
||||
bossGroup.shutdownGracefully();
|
||||
}
|
||||
if (workerGroup!=null) {
|
||||
workerGroup.shutdownGracefully();
|
||||
}
|
||||
}
|
||||
|
||||
public class service implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
bossGroup = new NioEventLoopGroup(1);
|
||||
workerGroup = new NioEventLoopGroup();
|
||||
try {
|
||||
ServerBootstrap serverBootstrap = new ServerBootstrap();
|
||||
serverBootstrap.group(bossGroup, workerGroup)
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.childHandler(new ChannelInitializer<SocketChannel>() {
|
||||
@Override
|
||||
public void initChannel(SocketChannel ch) {
|
||||
ch.pipeline().addLast(new ProtobufVarint32FrameDecoder());
|
||||
ch.pipeline().addLast(new ProtobufDecoder(PrintMessageProto.Printer.getDefaultInstance()));
|
||||
ch.pipeline().addLast(new ProtobufVarint32LengthFieldPrepender());
|
||||
ch.pipeline().addLast(new ProtobufEncoder());
|
||||
ch.pipeline().addLast(new PrintClientInfoMessageHandler());
|
||||
ch.pipeline().addLast(new PrintServerDefaultHandler());
|
||||
}
|
||||
});
|
||||
ChannelFuture channelFuture = serverBootstrap.bind(port).sync();
|
||||
System.out.println("==========Netty服务端启动成功========");
|
||||
channelFuture.channel().closeFuture().sync();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
if (bossGroup!=null) {
|
||||
bossGroup.shutdownGracefully();
|
||||
}
|
||||
if (workerGroup!=null) {
|
||||
workerGroup.shutdownGracefully();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package com.ktg.print.server;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class PrintServerDefaultHandler extends ChannelInboundHandlerAdapter {
|
||||
|
||||
public static ConcurrentHashMap<SocketAddress, Channel> chanelMap = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
//客户端和通道映射 也是一对一关系
|
||||
chanelMap.put(ctx.channel().remoteAddress(), ctx.channel());
|
||||
System.out.println("客户端连接已建立:" + ctx.channel().remoteAddress());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
chanelMap.remove(ctx.channel().remoteAddress());
|
||||
System.out.println("客户端连接已关闭:" + ctx.channel().remoteAddress());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
//package com.ktg.print.server;
|
||||
//
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.boot.ApplicationArguments;
|
||||
//import org.springframework.boot.ApplicationRunner;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import javax.annotation.Resource;
|
||||
//
|
||||
//@Component
|
||||
//public class PrintServerOpenListener implements ApplicationRunner {
|
||||
//
|
||||
// @Autowired
|
||||
// private PrintServer printerServer;
|
||||
//
|
||||
// @Override
|
||||
// public void run(ApplicationArguments args) throws Exception {
|
||||
// printerServer.start();
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.ktg.print.service;
|
||||
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.print.domain.PrintClient;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IPrintClientService {
|
||||
List<PrintClient> getClientList(PrintClient client);
|
||||
|
||||
AjaxResult insertClient(PrintClient client);
|
||||
|
||||
AjaxResult selectClientById(Long clientId);
|
||||
|
||||
AjaxResult updateClient(PrintClient client);
|
||||
|
||||
AjaxResult remove(String clientIds);
|
||||
|
||||
AjaxResult getWorkshopAndWorkstation();
|
||||
|
||||
AjaxResult getAll();
|
||||
}
|
||||
@ -0,0 +1,87 @@
|
||||
package com.ktg.print.service;
|
||||
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.print.domain.PrintPrinterConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 打印机配置Service接口
|
||||
*
|
||||
* @author yinjinlu
|
||||
* @date 2023-09-01
|
||||
*/
|
||||
public interface IPrintPrinterConfigService
|
||||
{
|
||||
/**
|
||||
* 查询打印机配置
|
||||
*
|
||||
* @param printerId 打印机配置主键
|
||||
* @return 打印机配置
|
||||
*/
|
||||
public PrintPrinterConfig selectPrintPrinterConfigByPrinterId(Long printerId);
|
||||
|
||||
/**
|
||||
* 根据打印机编号查询打印机配置
|
||||
*
|
||||
* @param printerCode 打印机编号
|
||||
* @return 打印机配置
|
||||
*/
|
||||
public PrintPrinterConfig selectPrintPrinterConfigByPrinterCode(String printerCode);
|
||||
|
||||
/**
|
||||
* 查询打印机配置列表
|
||||
*
|
||||
* @param printPrinterConfig 打印机配置
|
||||
* @return 打印机配置集合
|
||||
*/
|
||||
public List<PrintPrinterConfig> selectPrintPrinterConfigList(PrintPrinterConfig printPrinterConfig);
|
||||
|
||||
|
||||
/**
|
||||
* 检查编号是否唯一
|
||||
* @param config
|
||||
* @return
|
||||
*/
|
||||
public String checkPrinterCodeUnique(PrintPrinterConfig config);
|
||||
|
||||
/**
|
||||
* 新增打印机配置
|
||||
*
|
||||
* @param printPrinterConfig 打印机配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPrintPrinterConfig(PrintPrinterConfig printPrinterConfig);
|
||||
|
||||
/**
|
||||
* 修改打印机配置
|
||||
*
|
||||
* @param printPrinterConfig 打印机配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePrintPrinterConfig(PrintPrinterConfig printPrinterConfig);
|
||||
|
||||
/**
|
||||
* 批量删除打印机配置
|
||||
*
|
||||
* @param printerIds 需要删除的打印机配置主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePrintPrinterConfigByPrinterIds(Long[] printerIds);
|
||||
|
||||
/**
|
||||
* 删除打印机配置信息
|
||||
*
|
||||
* @param printerId 打印机配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePrintPrinterConfigByPrinterId(Long printerId);
|
||||
|
||||
/**
|
||||
* 获取默认打印机
|
||||
* @return
|
||||
*/
|
||||
AjaxResult getDefaultPrint(Long clientId);
|
||||
|
||||
AjaxResult editDefaultPrint(PrintPrinterConfig printPrinterConfig);
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.ktg.print.service;
|
||||
|
||||
import com.ktg.print.domain.PrintBarcodeModel;
|
||||
import com.ktg.print.domain.PrintTemplate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 打印模板配置Service接口
|
||||
*
|
||||
* @author yanshikui
|
||||
* @date 2024-04-17
|
||||
*/
|
||||
public interface IPrintService
|
||||
{
|
||||
/**
|
||||
* 标签打印
|
||||
* @param printBarcodeModel
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> printLabel(PrintBarcodeModel printBarcodeModel);
|
||||
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
package com.ktg.print.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.print.domain.PrintTemplate;
|
||||
|
||||
/**
|
||||
* 打印模板配置Service接口
|
||||
*
|
||||
* @author yinjinlu
|
||||
* @date 2024-04-17
|
||||
*/
|
||||
public interface IPrintTemplateService
|
||||
{
|
||||
/**
|
||||
* 查询打印模板配置
|
||||
*
|
||||
* @param templateId 打印模板配置主键
|
||||
* @return 打印模板配置
|
||||
*/
|
||||
public PrintTemplate selectPrintTemplateByTemplateId(Long templateId);
|
||||
|
||||
/**
|
||||
* 查询打印模板配置列表
|
||||
*
|
||||
* @param printTemplate 打印模板配置
|
||||
* @return 打印模板配置集合
|
||||
*/
|
||||
public List<PrintTemplate> selectPrintTemplateList(PrintTemplate printTemplate);
|
||||
|
||||
/**
|
||||
* 新增打印模板配置
|
||||
*
|
||||
* @param printTemplate 打印模板配置
|
||||
* @return 结果
|
||||
*/
|
||||
public AjaxResult insertPrintTemplate(PrintTemplate printTemplate);
|
||||
|
||||
/**
|
||||
* 修改打印模板配置
|
||||
*
|
||||
* @param printTemplate 打印模板配置
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePrintTemplate(PrintTemplate printTemplate);
|
||||
|
||||
/**
|
||||
* 批量删除打印模板配置
|
||||
*
|
||||
* @param templateIds 需要删除的打印模板配置主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePrintTemplateByTemplateIds(Long[] templateIds);
|
||||
|
||||
/**
|
||||
* 删除打印模板配置信息
|
||||
*
|
||||
* @param templateId 打印模板配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePrintTemplateByTemplateId(Long templateId);
|
||||
}
|
||||
@ -0,0 +1,104 @@
|
||||
package com.ktg.print.service.impl;
|
||||
|
||||
import com.ktg.common.constant.UserConstants;
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.common.utils.DateUtils;
|
||||
import com.ktg.common.utils.StringUtils;
|
||||
import com.ktg.mes.md.domain.MdWorkshop;
|
||||
import com.ktg.mes.md.domain.MdWorkstation;
|
||||
import com.ktg.mes.md.service.IMdWorkshopService;
|
||||
import com.ktg.mes.md.service.IMdWorkstationService;
|
||||
import com.ktg.print.domain.PrintClient;
|
||||
import com.ktg.print.domain.vo.ClientDictVO;
|
||||
import com.ktg.print.mapper.PrintClientMapper;
|
||||
import com.ktg.print.service.IPrintClientService;
|
||||
import org.aspectj.weaver.loadtime.Aj;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class PrintClientServiceImpl implements IPrintClientService {
|
||||
|
||||
@Autowired
|
||||
private PrintClientMapper clientMapper;
|
||||
|
||||
@Autowired
|
||||
private IMdWorkshopService mdWorkshopService;
|
||||
|
||||
@Autowired
|
||||
private IMdWorkstationService mdWorkstationService;
|
||||
|
||||
@Override
|
||||
public List<PrintClient> getClientList(PrintClient client) {
|
||||
return clientMapper.getClientList(client);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult insertClient(PrintClient client) {
|
||||
// 校验客户端编码是否存在
|
||||
if (UserConstants.NOT_UNIQUE.equals(checkClientCodeUnique(client))) {
|
||||
return AjaxResult.error("客户端编码已存在");
|
||||
}
|
||||
client.setCreateTime(DateUtils.getNowDate());
|
||||
return AjaxResult.success(clientMapper.insertClient(client));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult selectClientById(Long clientId) {
|
||||
PrintClient printClient = clientMapper.selectById(clientId);
|
||||
return AjaxResult.success(printClient);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult updateClient(PrintClient client) {
|
||||
// 校验客户端编码是否存在
|
||||
if (UserConstants.NOT_UNIQUE.equals(checkClientCodeUnique(client))) {
|
||||
return AjaxResult.error("客户端编码已存在");
|
||||
}
|
||||
client.setUpdateTime(DateUtils.getNowDate());
|
||||
clientMapper.updateClient(client);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult remove(String clientIds) {
|
||||
List<String> list = Arrays.asList(clientIds.split(","));
|
||||
return AjaxResult.success(clientMapper.deleteByIds(list));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getWorkshopAndWorkstation() {
|
||||
ClientDictVO clientDictVO = new ClientDictVO();
|
||||
// 获取工作站列表
|
||||
MdWorkstation mdWorkstation = new MdWorkstation();
|
||||
List<MdWorkstation> workstations = mdWorkstationService.selectMdWorkstationList(mdWorkstation);
|
||||
|
||||
clientDictVO.setWorkstations(workstations);
|
||||
return AjaxResult.success(clientDictVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getAll() {
|
||||
PrintClient client = new PrintClient();
|
||||
return AjaxResult.success(clientMapper.getClientList(client));
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验客户端编码是否唯一
|
||||
* @param client
|
||||
* @return
|
||||
*/
|
||||
private String checkClientCodeUnique(PrintClient client) {
|
||||
PrintClient printClient = clientMapper.checkCilentCodeUnique(client);
|
||||
|
||||
Long clientId = client.getClientId() == null ? -1L : client.getClientId();
|
||||
if (StringUtils.isNotNull(printClient) && clientId.longValue() != printClient.getClientId().longValue()) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
} else {
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,162 @@
|
||||
package com.ktg.print.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.ktg.common.constant.UserConstants;
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.common.utils.DateUtils;
|
||||
import com.ktg.common.utils.StringUtils;
|
||||
import com.ktg.print.domain.PrintPrinterConfig;
|
||||
import com.ktg.print.mapper.PrintPrinterConfigMapper;
|
||||
import com.ktg.print.service.IPrintPrinterConfigService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 打印机配置Service业务层处理
|
||||
*
|
||||
* @author yinjinlu
|
||||
* @date 2023-09-01
|
||||
*/
|
||||
@Service
|
||||
public class PrintPrinterConfigServiceImpl implements IPrintPrinterConfigService
|
||||
{
|
||||
@Autowired
|
||||
private PrintPrinterConfigMapper printPrinterConfigMapper;
|
||||
|
||||
/**
|
||||
* 查询打印机配置
|
||||
*
|
||||
* @param printerId 打印机配置主键
|
||||
* @return 打印机配置
|
||||
*/
|
||||
@Override
|
||||
public PrintPrinterConfig selectPrintPrinterConfigByPrinterId(Long printerId)
|
||||
{
|
||||
return printPrinterConfigMapper.selectPrintPrinterConfigByPrinterId(printerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrintPrinterConfig selectPrintPrinterConfigByPrinterCode(String printerCode) {
|
||||
return printPrinterConfigMapper.selectPrintPrinterConfigByPrinterCode(printerCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询打印机配置列表
|
||||
*
|
||||
* @param printPrinterConfig 打印机配置
|
||||
* @return 打印机配置
|
||||
*/
|
||||
@Override
|
||||
public List<PrintPrinterConfig> selectPrintPrinterConfigList(PrintPrinterConfig printPrinterConfig)
|
||||
{
|
||||
return printPrinterConfigMapper.selectPrintPrinterConfigList(printPrinterConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String checkPrinterCodeUnique(PrintPrinterConfig config) {
|
||||
|
||||
PrintPrinterConfig p = printPrinterConfigMapper.checkPrinterCodeUnique(config);
|
||||
|
||||
Long configId = config.getPrinterId() == null? -1L:config.getPrinterId();
|
||||
if(StringUtils.isNotNull(p) && configId.longValue() !=p.getPrinterId().longValue()){
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}else {
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增打印机配置
|
||||
*
|
||||
* @param printPrinterConfig 打印机配置
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertPrintPrinterConfig(PrintPrinterConfig printPrinterConfig)
|
||||
{
|
||||
// 根据客户端ID查询客户端下的打印机列表
|
||||
List<PrintPrinterConfig> printPrinterConfigs = printPrinterConfigMapper.getByClientId(printPrinterConfig.getClientId());
|
||||
if (printPrinterConfigs != null && printPrinterConfigs.size() > 0) {
|
||||
printPrinterConfig.setDefaultFlag("N");
|
||||
} else {
|
||||
printPrinterConfig.setDefaultFlag("Y");
|
||||
}
|
||||
printPrinterConfig.setCreateTime(DateUtils.getNowDate());
|
||||
return printPrinterConfigMapper.insertPrintPrinterConfig(printPrinterConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改打印机配置
|
||||
*
|
||||
* @param printPrinterConfig 打印机配置
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updatePrintPrinterConfig(PrintPrinterConfig printPrinterConfig)
|
||||
{
|
||||
printPrinterConfig.setUpdateTime(DateUtils.getNowDate());
|
||||
return printPrinterConfigMapper.updatePrintPrinterConfig(printPrinterConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除打印机配置
|
||||
*
|
||||
* @param printerIds 需要删除的打印机配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePrintPrinterConfigByPrinterIds(Long[] printerIds)
|
||||
{
|
||||
return printPrinterConfigMapper.deletePrintPrinterConfigByPrinterIds(printerIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除打印机配置信息
|
||||
*
|
||||
* @param printerId 打印机配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePrintPrinterConfigByPrinterId(Long printerId)
|
||||
{
|
||||
return printPrinterConfigMapper.deletePrintPrinterConfigByPrinterId(printerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getDefaultPrint(Long clientId) {
|
||||
PrintPrinterConfig defaultPrint = printPrinterConfigMapper.getDefaultPrint(clientId);
|
||||
if (ObjectUtil.isNotEmpty(defaultPrint)) {
|
||||
return AjaxResult.success(defaultPrint);
|
||||
} else {
|
||||
return AjaxResult.error("默认打印机不存在");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult editDefaultPrint(PrintPrinterConfig printPrinterConfig) {
|
||||
try {
|
||||
// 获取原来的默认打印机
|
||||
PrintPrinterConfig defaultPrint = printPrinterConfigMapper.getDefaultPrint(printPrinterConfig.getClientId());
|
||||
|
||||
// 检查原来的默认打印机是否存在
|
||||
if (!ObjectUtil.isEmpty(defaultPrint)) {
|
||||
// 将原来的默认打印机设置为非默认打印机
|
||||
defaultPrint.setDefaultFlag("N");
|
||||
printPrinterConfigMapper.updatePrintPrinterConfig(defaultPrint);
|
||||
}
|
||||
|
||||
// 将新的默认打印机设置为默认打印机
|
||||
printPrinterConfig.setDefaultFlag("Y");
|
||||
printPrinterConfigMapper.updatePrintPrinterConfig(printPrinterConfig);
|
||||
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
// 捕获并处理可能的异常
|
||||
return AjaxResult.error("修改默认打印机失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,408 @@
|
||||
package com.ktg.print.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.ktg.common.constant.UserConstants;
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.common.utils.DateUtils;
|
||||
import com.ktg.common.utils.StringUtils;
|
||||
import com.ktg.mes.dv.domain.DvMachinery;
|
||||
import com.ktg.mes.dv.service.IDvMachineryService;
|
||||
import com.ktg.mes.md.domain.MdItem;
|
||||
import com.ktg.mes.md.service.IMdItemService;
|
||||
import com.ktg.mes.pro.domain.ProCard;
|
||||
import com.ktg.mes.pro.domain.ProRouteProcess;
|
||||
import com.ktg.mes.pro.domain.ProRouteProduct;
|
||||
import com.ktg.mes.pro.mapper.ProRouteMapper;
|
||||
import com.ktg.mes.pro.mapper.ProRouteProductMapper;
|
||||
import com.ktg.mes.pro.service.IProCardService;
|
||||
import com.ktg.mes.pro.service.IProRouteProcessService;
|
||||
import com.ktg.mes.wm.domain.WmBarcode;
|
||||
import com.ktg.mes.wm.service.IWmBarcodeService;
|
||||
import com.ktg.print.domain.PrintBarcodeModel;
|
||||
import com.ktg.print.domain.PrintPrinterConfig;
|
||||
import com.ktg.print.domain.PrintTemplate;
|
||||
import com.ktg.print.mapper.PrintTemplateMapper;
|
||||
import com.ktg.print.protocol.PrintMessageProto;
|
||||
import com.ktg.print.server.PrintClientInfoMessageHandler;
|
||||
import com.ktg.print.server.PrintServerDefaultHandler;
|
||||
import com.ktg.print.service.IPrintPrinterConfigService;
|
||||
import com.ktg.print.service.IPrintService;
|
||||
import com.ktg.print.service.IPrintTemplateService;
|
||||
import io.netty.channel.Channel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 标签打印业务处理类
|
||||
*
|
||||
* @author yinjinlu
|
||||
* @date 2024-04-17
|
||||
*/
|
||||
@Service
|
||||
public class PrintServiceImpl implements IPrintService {
|
||||
|
||||
@Autowired
|
||||
private IPrintPrinterConfigService printPrinterConfigService;
|
||||
@Autowired
|
||||
private IMdItemService iMdItemService;
|
||||
@Autowired
|
||||
private IWmBarcodeService wmBarcodeService;
|
||||
@Autowired
|
||||
private IDvMachineryService iDvMachineryService;
|
||||
@Autowired
|
||||
private IProCardService iProCardService;
|
||||
@Autowired
|
||||
private ProRouteProductMapper proRouteProductMapper;
|
||||
@Autowired
|
||||
private ProRouteMapper proRouteMapper;
|
||||
@Autowired
|
||||
private IProRouteProcessService iProRouteProcessService;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> printLabel(PrintBarcodeModel printBarcodeModel) {
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
result.put("msg","ERROR");
|
||||
String printerCode = printBarcodeModel.getPrinterCode();
|
||||
String businessType = printBarcodeModel.getBusinessType();
|
||||
Map<String, String> params = printBarcodeModel.getParams();
|
||||
Long businessId = printBarcodeModel.getBusinessId();
|
||||
String businessCode = printBarcodeModel.getBusinessCode();
|
||||
PrintPrinterConfig printPrinterConfig = printPrinterConfigService.selectPrintPrinterConfigByPrinterCode(printerCode);
|
||||
if (printPrinterConfig == null) {
|
||||
result.put("data","打印机:" + printerCode + "不存在");
|
||||
return result;
|
||||
}
|
||||
String ip = printPrinterConfig.getPrinterIp();
|
||||
String printPort = printPrinterConfig.getPrinterPort().toString();
|
||||
String printName = printPrinterConfig.getPrinterName();
|
||||
PrintMessageProto.Printer.DataType dataType = PrintMessageProto.Printer.DataType.IQC_PrintMessage;
|
||||
//根据打印机编码id获取打印机你信息
|
||||
// String clientIp = printPrinterConfig.getClientIp();
|
||||
// if (StringUtils.isEmpty(clientIp)) {
|
||||
// result.put("data","请检查打印机客户端信息配置!");
|
||||
// return result;
|
||||
// }
|
||||
PrintMessageProto.Printer msg = null;
|
||||
PrintMessageProto.Printer.PrintInfo printInfo = PrintMessageProto.Printer.PrintInfo.newBuilder().setIp(ip).setCode(printerCode).setName(printName).setPort(printPort).build();
|
||||
|
||||
switch (businessType) {
|
||||
case UserConstants.BARCODE_TYPE_ITEM:
|
||||
//物料标签打印
|
||||
//封装模板数据
|
||||
MdItem item = null;
|
||||
if (Optional.ofNullable(businessId).isPresent()) {
|
||||
item = iMdItemService.selectMdItemById(businessId);
|
||||
if (item == null) {
|
||||
result.put("data","条码内容数据为空!" + "(" + businessId + ")");
|
||||
return result;
|
||||
}
|
||||
} else if (StringUtils.isNotEmpty(businessCode)) {
|
||||
MdItem itemParam = new MdItem();
|
||||
itemParam.setItemCode(businessCode);
|
||||
List<MdItem> itemList = iMdItemService.selectMdItemList(itemParam);
|
||||
if (CollectionUtils.isEmpty(itemList)) {
|
||||
result.put("data","条码内容数据为空!" + "(" + businessCode + ")");
|
||||
return result;
|
||||
}
|
||||
item = itemList.get(0);
|
||||
} else {
|
||||
result.put("data","缺少业务参数!");
|
||||
return result;
|
||||
}
|
||||
//二维码信息查询
|
||||
WmBarcode bacode = new WmBarcode();
|
||||
bacode.setBussinessId(item.getItemId());
|
||||
bacode.setBussinessCode(item.getItemCode());
|
||||
bacode.setBarcodeType(UserConstants.BARCODE_TYPE_ITEM);
|
||||
List<WmBarcode> wmBarcodes = wmBarcodeService.selectWmBarcodeList(bacode);
|
||||
if (CollectionUtils.isEmpty(wmBarcodes)) {
|
||||
result.put("data","未查询到二维码信息!" + "(" + businessCode + ")");
|
||||
return result;
|
||||
}
|
||||
WmBarcode wmBarcode = wmBarcodes.get(0);
|
||||
String materialCode = item.getItemCode();//物料编码
|
||||
String materialName = item.getItemName();//物料名称
|
||||
String specificationAndModel = item.getSpecification();//物料规格类型
|
||||
|
||||
String param = wmBarcode.getBarcodeUrl();//物料二维码
|
||||
dataType = PrintMessageProto.Printer.DataType.Material_Products;
|
||||
PrintMessageProto.Printer.MaterialProducts materialProducts = PrintMessageProto.Printer.MaterialProducts.newBuilder().setMaterialCode(materialCode).setMaterialName(materialName).setSpecificationAndModel(specificationAndModel).setParam(param).build();
|
||||
// 构造对应的消息对象
|
||||
msg = PrintMessageProto.Printer.newBuilder().setMaterialProducts(materialProducts).setDataType(dataType).setPrintInfo(printInfo).build();
|
||||
break;
|
||||
case UserConstants.BARCODE_TYPE_PACKAGE:
|
||||
// String materialCode = params.get("materialCode");
|
||||
// String materialName = params.get("materialName");
|
||||
// String specificationAndModel = params.get("specificationAndModel");
|
||||
// String param = params.get("param");
|
||||
// PrintMessageProto.Printer.DataType dataType = PrintMessageProto.Printer.DataType.Material_Products;
|
||||
// PrintMessageProto.Printer.MaterialProducts materialProducts = PrintMessageProto.Printer.MaterialProducts.newBuilder().setMaterialCode(materialCode).setMaterialName(materialName).setSpecificationAndModel(specificationAndModel).setParam(param).build();
|
||||
// // 构造对应的消息对象
|
||||
// msg = PrintMessageProto.Printer.newBuilder().setMaterialProducts(materialProducts).setDataType(dataType).setPrintInfo(printInfo).build();
|
||||
// break;
|
||||
case UserConstants.BARCODE_TYPE_STOCK:
|
||||
//仓库标签打印
|
||||
//封装模板数据
|
||||
// String warehouseCode = params.get("warehouseCode");
|
||||
// String warehouseName = params.get("warehouseName");
|
||||
// String personInCharge = params.get("personInCharge");
|
||||
// dataType = PrintMessageProto.Printer.DataType.Warehouse_;
|
||||
// PrintMessageProto.Printer.Warehouse warehouse = PrintMessageProto.Printer.Warehouse.newBuilder().setWarehouseCode(warehouseCode).setWarehouseName(warehouseName).setPersonInCharge(personInCharge).build();
|
||||
// // 构造对应的消息对象
|
||||
// msg = PrintMessageProto.Printer.newBuilder().setWarehouse(warehouse).setDataType(dataType).setPrintInfo(printInfo).build();
|
||||
// break;
|
||||
case UserConstants.BARCODE_TYPE_MACHINERY:
|
||||
//设备标签打印
|
||||
//封装模板数据
|
||||
DvMachinery dvMachinery = null;
|
||||
if (Optional.ofNullable(businessId).isPresent()) {
|
||||
dvMachinery = iDvMachineryService.selectDvMachineryByMachineryId(businessId);
|
||||
if (dvMachinery == null) {
|
||||
result.put("data","条码内容数据为空!" + "(" + businessId + ")");
|
||||
return result;
|
||||
}
|
||||
} else if (StringUtils.isNotEmpty(businessCode)) {
|
||||
DvMachinery mParam = new DvMachinery();
|
||||
mParam.setMachineryCode(businessCode);
|
||||
List<DvMachinery> mList = iDvMachineryService.selectDvMachineryList(mParam);
|
||||
if (CollectionUtils.isEmpty(mList)) {
|
||||
result.put("data","条码内容数据为空!" + "(" + businessId + ")");
|
||||
return result;
|
||||
}
|
||||
dvMachinery = mList.get(0);
|
||||
} else {
|
||||
result.put("data","缺少业务参数!");
|
||||
return result;
|
||||
}
|
||||
//二维码信息查询
|
||||
WmBarcode mcode = new WmBarcode();
|
||||
mcode.setBussinessId(dvMachinery.getMachineryId());
|
||||
mcode.setBussinessCode(dvMachinery.getMachineryCode());
|
||||
mcode.setBarcodeType(UserConstants.BARCODE_TYPE_MACHINERY);
|
||||
List<WmBarcode> mBarcodes = wmBarcodeService.selectWmBarcodeList(mcode);
|
||||
if (CollectionUtils.isEmpty(mBarcodes)) {
|
||||
result.put("data","未查询到二维码信息!" + "(" + businessCode + ")");
|
||||
return result;
|
||||
}
|
||||
dataType = PrintMessageProto.Printer.DataType.Equipment_;
|
||||
PrintMessageProto.Printer.Equipment equipment = PrintMessageProto.Printer.Equipment.newBuilder().
|
||||
setEquipmentCode(dvMachinery.getMachineryCode()).
|
||||
setEquipmentName(dvMachinery.getMachineryName()).
|
||||
setSpecificationAndModel(dvMachinery.getMachinerySpec()).
|
||||
setParam(mBarcodes.get(0).getBarcodeUrl()).build();
|
||||
// 构造对应的消息对象
|
||||
msg = PrintMessageProto.Printer.newBuilder().setEquipment(equipment).setDataType(dataType).setPrintInfo(printInfo).build();
|
||||
break;
|
||||
case UserConstants.BARCODE_TYPE_WORKSTATION:
|
||||
//工作站标签打印
|
||||
//封装模板数据
|
||||
String workstationCode = params.get("workstationCode");
|
||||
String workstationName = params.get("workstationName");
|
||||
String belongingProcess = params.get("belongingProcess");
|
||||
String param2 = params.get("param");
|
||||
dataType = PrintMessageProto.Printer.DataType.Workstation_;
|
||||
PrintMessageProto.Printer.Workstation workstation = PrintMessageProto.Printer.Workstation.newBuilder().setWorkstationCode(workstationCode).setWorkstationName(workstationName).setBelongingProcess(belongingProcess).setParam(param2).build();
|
||||
// 构造对应的消息对象
|
||||
msg = PrintMessageProto.Printer.newBuilder().setWorkstation(workstation).setDataType(dataType).setPrintInfo(printInfo).build();
|
||||
break;
|
||||
case UserConstants.BARCODE_TYPE_PROCARD:
|
||||
//流转卡标签打印
|
||||
//封装模板数据
|
||||
ProCard proCard = null;
|
||||
if (Optional.ofNullable(businessId).isPresent()) {
|
||||
proCard = iProCardService.selectProCardByCardId(businessId);
|
||||
if (proCard == null) {
|
||||
result.put("data","条码内容数据为空!" + "(" + businessId + ")");
|
||||
return result;
|
||||
}
|
||||
} else if (StringUtils.isNotEmpty(businessCode)) {
|
||||
ProCard pcParam = new ProCard();
|
||||
pcParam.setCardCode(businessCode);
|
||||
List<ProCard> mList = iProCardService.selectProCardList(pcParam);
|
||||
if (CollectionUtils.isEmpty(mList)) {
|
||||
result.put("data","条码内容数据为空!" + "(" + businessCode + ")");
|
||||
return result;
|
||||
}
|
||||
proCard = mList.get(0);
|
||||
} else {
|
||||
result.put("data","缺少业务参数!");
|
||||
return result;
|
||||
}
|
||||
//二维码信息查询
|
||||
WmBarcode pcBarcode = new WmBarcode();
|
||||
pcBarcode.setBussinessId(proCard.getCardId());
|
||||
pcBarcode.setBussinessCode(proCard.getCardCode());
|
||||
pcBarcode.setBarcodeType(UserConstants.BARCODE_TYPE_PROCARD);
|
||||
List<WmBarcode> pcBarcodes = wmBarcodeService.selectWmBarcodeList(pcBarcode);
|
||||
if (CollectionUtils.isEmpty(pcBarcodes)) {
|
||||
result.put("data","未查询到二维码信息!" + "(" + businessCode + ")");
|
||||
return result;
|
||||
}
|
||||
Long routeId = -1L, processId = -1L;
|
||||
ProRouteProduct proRouteProduct = new ProRouteProduct();
|
||||
proRouteProduct.setItemId(proCard.getItemId());
|
||||
List<ProRouteProduct> products = proRouteProductMapper.selectProRouteProductList(proRouteProduct);
|
||||
if (CollectionUtil.isNotEmpty(products)) {
|
||||
products = products.stream().filter(i -> proRouteMapper.selectProRouteByRouteId(i.getRouteId()).getEnableFlag().equals(UserConstants.YES)).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(products)) {
|
||||
routeId = products.get(0).getRouteId();
|
||||
}
|
||||
}
|
||||
ProRouteProcess proRouteProcess = new ProRouteProcess();
|
||||
proRouteProcess.setRouteId(routeId);
|
||||
String processingProcedure = "";
|
||||
List<ProRouteProcess> proList = iProRouteProcessService.selectProRouteProcessList(proRouteProcess);
|
||||
for (ProRouteProcess process : proList) {
|
||||
processingProcedure = processingProcedure + "," + process.getProcessName();
|
||||
}
|
||||
dataType = PrintMessageProto.Printer.DataType.Printing_OfCirculation;
|
||||
PrintMessageProto.Printer.PrintingOfCirculation printingOfCirculation = PrintMessageProto.Printer.PrintingOfCirculation.newBuilder().
|
||||
setWorkOrderNumber(proCard.getWorkorderCode()).
|
||||
setMaterialCode(proCard.getItemCode()).
|
||||
setMaterialName(proCard.getItemName()).
|
||||
setSpecificationAndModel(proCard.getSpecification() == null ? "" : proCard.getSpecification()).
|
||||
setProcessingProcedure(processingProcedure).
|
||||
setParam(pcBarcodes.get(0).getBarcodeUrl()).build();
|
||||
// 构造对应的消息对象
|
||||
msg = PrintMessageProto.Printer.newBuilder().setPrintingOfCirculation(printingOfCirculation).setDataType(dataType).setPrintInfo(printInfo).build();
|
||||
break;
|
||||
case UserConstants.BARCODE_TYPE_WAREHOUSE:
|
||||
// 仓库标签打印
|
||||
//封装模板数据
|
||||
String warehouseCode = params.get("warehouseCode");
|
||||
String warehouseName = params.get("warehouseName");
|
||||
String personInCharge = params.get("personInCharge");
|
||||
String param3 = params.get("param");
|
||||
dataType = PrintMessageProto.Printer.DataType.Warehouse_;
|
||||
PrintMessageProto.Printer.Warehouse warehouse = PrintMessageProto.Printer.Warehouse.newBuilder().setWarehouseCode(warehouseCode).setWarehouseName(warehouseName).setPersonInCharge(personInCharge).setParam(param3).build();
|
||||
// 构造对应的消息对象
|
||||
msg = PrintMessageProto.Printer.newBuilder().setWarehouse(warehouse).setDataType(dataType).setPrintInfo(printInfo).build();
|
||||
break;
|
||||
case UserConstants.BARCODE_TYPE_STORAGELOCATION:
|
||||
// 库区标签打印
|
||||
//封装模板数据
|
||||
String warehouseLocationCode = params.get("warehouseLocationCode");
|
||||
String warehouseLocationName = params.get("warehouseLocationName");
|
||||
String position = params.get("position");
|
||||
String param4 = params.get("param");
|
||||
dataType = PrintMessageProto.Printer.DataType.Warehouse_Location;
|
||||
PrintMessageProto.Printer.WarehouseLocation location = PrintMessageProto.Printer.WarehouseLocation.newBuilder().setWarehouseLocationCode(warehouseLocationCode).setWarehouseLocationName(warehouseLocationName).setPosition(position).setParam(param4).build();
|
||||
// 构造对应的消息对象
|
||||
msg = PrintMessageProto.Printer.newBuilder().setWarehouseLocation(location).setDataType(dataType).setPrintInfo(printInfo).build();
|
||||
break;
|
||||
case UserConstants.BARCODE_TYPE_STORAGEAREA:
|
||||
// 库位标签打印
|
||||
//封装模板数据
|
||||
String warehouseAreaCode = params.get("warehouseAreaCode");
|
||||
String warehouseAreaName = params.get("warehouseAreaName");
|
||||
dataType = PrintMessageProto.Printer.DataType.Warehouse_Area;
|
||||
String param5 = params.get("param");
|
||||
PrintMessageProto.Printer.WarehouseArea warehouseArea = PrintMessageProto.Printer.WarehouseArea.newBuilder().setWarehouseAreaCode(warehouseAreaCode).setWarehouseAreaName(warehouseAreaName).setParam(param5).build();
|
||||
// 构造对应的消息对象
|
||||
msg = PrintMessageProto.Printer.newBuilder().setWarehouseArea(warehouseArea).setDataType(dataType).setPrintInfo(printInfo).build();
|
||||
break;
|
||||
case UserConstants.BARCODE_TYPE_TRANSORDER:
|
||||
// 流转单标签打印
|
||||
//封装模板数据
|
||||
//String sampleCode =params.get("sampleCode");
|
||||
//String qcObject =params.get("qcObject");
|
||||
//String sampleTime =params.get("sampleTime");
|
||||
//String batchCode =params.get("batchCode");
|
||||
//PrintMessageProt//o.Printer.IQCPrintMessage iQCPrintMessage = PrintMessageProto.Printer.IQCPrintMessage.newBuilder().setSampleCode(sampleCode).setQcObject(qcObject).setSampleTime(sampleTime).setBatchCode(batchCode).build();
|
||||
// 构造对应的消息对象
|
||||
// msg = PrintMessageProto.Printer.newBuilder().setIqcPrintMessage(iQCPrintMessage).setDataType(dataType).setPrintInfo(printClientInfoMessage).build();
|
||||
break;
|
||||
case UserConstants.BARCODE_TYPE_CLIENT:
|
||||
// 客户标签打印
|
||||
//封装模板数据
|
||||
//String sampleCode =params.get("sampleCode");
|
||||
//String qcObject =params.get("qcObject");
|
||||
//String sampleTime =params.get("sampleTime");
|
||||
//String batchCode =params.get("batchCode");
|
||||
//PrintMessageProt//o.Printer.IQCPrintMessage iQCPrintMessage = PrintMessageProto.Printer.IQCPrintMessage.newBuilder().setSampleCode(sampleCode).setQcObject(qcObject).setSampleTime(sampleTime).setBatchCode(batchCode).build();
|
||||
// 构造对应的消息对象
|
||||
// msg = PrintMessageProto.Printer.newBuilder().setIqcPrintMessage(iQCPrintMessage).setDataType(dataType).setPrintInfo(printClientInfoMessage).build();
|
||||
break;
|
||||
case UserConstants.BARCODE_TYPE_VENDOR:
|
||||
// 供应商标签打印
|
||||
//封装模板数据
|
||||
//String sampleCode =params.get("sampleCode");
|
||||
//String qcObject =params.get("qcObject");
|
||||
//String sampleTime =params.get("sampleTime");
|
||||
//String batchCode =params.get("batchCode");
|
||||
//PrintMessageProt//o.Printer.IQCPrintMessage iQCPrintMessage = PrintMessageProto.Printer.IQCPrintMessage.newBuilder().setSampleCode(sampleCode).setQcObject(qcObject).setSampleTime(sampleTime).setBatchCode(batchCode).build();
|
||||
// 构造对应的消息对象
|
||||
// msg = PrintMessageProto.Printer.newBuilder().setIqcPrintMessage(iQCPrintMessage).setDataType(dataType).setPrintInfo(printClientInfoMessage).build();
|
||||
break;
|
||||
case UserConstants.BARCODE_TYPE_WORKSHOP:
|
||||
// 工作站标签打印
|
||||
//封装模板数据
|
||||
//String sampleCode =params.get("sampleCode");
|
||||
//String qcObject =params.get("qcObject");
|
||||
//String sampleTime =params.get("sampleTime");
|
||||
//String batchCode =params.get("batchCode");
|
||||
//PrintMessageProt//o.Printer.IQCPrintMessage iQCPrintMessage = PrintMessageProto.Printer.IQCPrintMessage.newBuilder().setSampleCode(sampleCode).setQcObject(qcObject).setSampleTime(sampleTime).setBatchCode(batchCode).build();
|
||||
// 构造对应的消息对象
|
||||
// msg = PrintMessageProto.Printer.newBuilder().setIqcPrintMessage(iQCPrintMessage).setDataType(dataType).setPrintInfo(printClientInfoMessage).build();
|
||||
break;
|
||||
case UserConstants.BARCODE_TYPE_WORKORDER:
|
||||
// 生产工单标签打印
|
||||
//封装模板数据
|
||||
//String sampleCode =params.get("sampleCode");
|
||||
//String qcObject =params.get("qcObject");
|
||||
//String sampleTime =params.get("sampleTime");
|
||||
//String batchCode =params.get("batchCode");
|
||||
//PrintMessageProt//o.Printer.IQCPrintMessage iQCPrintMessage = PrintMessageProto.Printer.IQCPrintMessage.newBuilder().setSampleCode(sampleCode).setQcObject(qcObject).setSampleTime(sampleTime).setBatchCode(batchCode).build();
|
||||
// 构造对应的消息对象
|
||||
// msg = PrintMessageProto.Printer.newBuilder().setIqcPrintMessage(iQCPrintMessage).setDataType(dataType).setPrintInfo(printClientInfoMessage).build();
|
||||
break;
|
||||
case UserConstants.BARCODE_TYPE_TOOL:
|
||||
// 工装夹具标签打印
|
||||
//封装模板数据
|
||||
//String sampleCode =params.get("sampleCode");
|
||||
//String qcObject =params.get("qcObject");
|
||||
//String sampleTime =params.get("sampleTime");
|
||||
//String batchCode =params.get("batchCode");
|
||||
//PrintMessageProt//o.Printer.IQCPrintMessage iQCPrintMessage = PrintMessageProto.Printer.IQCPrintMessage.newBuilder().setSampleCode(sampleCode).setQcObject(qcObject).setSampleTime(sampleTime).setBatchCode(batchCode).build();
|
||||
// 构造对应的消息对象
|
||||
// msg = PrintMessageProto.Printer.newBuilder().setIqcPrintMessage(iQCPrintMessage).setDataType(dataType).setPrintInfo(printClientInfoMessage).build();
|
||||
break;
|
||||
case UserConstants.BARCODE_TYPE_SN:
|
||||
// SN标签打印
|
||||
//封装模板数据
|
||||
//String sampleCode =params.get("sampleCode");
|
||||
//String qcObject =params.get("qcObject");
|
||||
//String sampleTime =params.get("sampleTime");
|
||||
//String batchCode =params.get("batchCode");
|
||||
//PrintMessageProt//o.Printer.IQCPrintMessage iQCPrintMessage = PrintMessageProto.Printer.IQCPrintMessage.newBuilder().setSampleCode(sampleCode).setQcObject(qcObject).setSampleTime(sampleTime).setBatchCode(batchCode).build();
|
||||
// 构造对应的消息对象
|
||||
// msg = PrintMessageProto.Printer.newBuilder().setIqcPrintMessage(iQCPrintMessage).setDataType(dataType).setPrintInfo(printClientInfoMessage).build();
|
||||
break;
|
||||
case UserConstants.TEST_TYPE_PRINTER:
|
||||
// 测试模板
|
||||
//封装模板数据
|
||||
String title =params.get("title");
|
||||
String text =params.get("text");
|
||||
PrintMessageProto.Printer.TestPrinter testPrinter = PrintMessageProto.Printer.TestPrinter.newBuilder().setTitle(title).setText(text).build();
|
||||
// 构造对应的消息对象
|
||||
msg = PrintMessageProto.Printer.newBuilder().setTestPrinter(testPrinter).setDataType(dataType).setPrintInfo(printInfo).build();
|
||||
break;
|
||||
default:
|
||||
result.put("data","打印机不支持当前模板:" + "(" + businessType + ")");
|
||||
return result;
|
||||
}
|
||||
result.put("msg","SUCESS");
|
||||
// result.put("clientIp",clientIp);
|
||||
result.put("data",msg);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,106 @@
|
||||
package com.ktg.print.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ktg.print.mapper.PrintTemplateMapper;
|
||||
import com.ktg.print.domain.PrintTemplate;
|
||||
import com.ktg.print.service.IPrintTemplateService;
|
||||
|
||||
/**
|
||||
* 打印模板配置Service业务层处理
|
||||
*
|
||||
* @author yinjinlu
|
||||
* @date 2024-04-17
|
||||
*/
|
||||
@Service
|
||||
public class PrintTemplateServiceImpl implements IPrintTemplateService
|
||||
{
|
||||
@Autowired
|
||||
private PrintTemplateMapper printTemplateMapper;
|
||||
|
||||
/**
|
||||
* 查询打印模板配置
|
||||
*
|
||||
* @param templateId 打印模板配置主键
|
||||
* @return 打印模板配置
|
||||
*/
|
||||
@Override
|
||||
public PrintTemplate selectPrintTemplateByTemplateId(Long templateId)
|
||||
{
|
||||
return printTemplateMapper.selectPrintTemplateByTemplateId(templateId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询打印模板配置列表
|
||||
*
|
||||
* @param printTemplate 打印模板配置
|
||||
* @return 打印模板配置
|
||||
*/
|
||||
@Override
|
||||
public List<PrintTemplate> selectPrintTemplateList(PrintTemplate printTemplate)
|
||||
{
|
||||
return printTemplateMapper.selectPrintTemplateList(printTemplate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增打印模板配置
|
||||
*
|
||||
* @param printTemplate 打印模板配置
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult insertPrintTemplate(PrintTemplate printTemplate)
|
||||
{
|
||||
// 校验:根据模板类型作为一校验
|
||||
PrintTemplate params = new PrintTemplate();
|
||||
params.setTemplateType(printTemplate.getTemplateType());
|
||||
List<PrintTemplate> printTemplates = printTemplateMapper.selectPrintTemplateList(params);
|
||||
if (printTemplates != null && printTemplates.size() > 0) {
|
||||
return AjaxResult.error("模板类型已存在");
|
||||
}
|
||||
printTemplate.setCreateTime(DateUtils.getNowDate());
|
||||
printTemplateMapper.insertPrintTemplate(printTemplate);
|
||||
return AjaxResult.success(printTemplate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改打印模板配置
|
||||
*
|
||||
* @param printTemplate 打印模板配置
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updatePrintTemplate(PrintTemplate printTemplate)
|
||||
{
|
||||
printTemplate.setUpdateTime(DateUtils.getNowDate());
|
||||
return printTemplateMapper.updatePrintTemplate(printTemplate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除打印模板配置
|
||||
*
|
||||
* @param templateIds 需要删除的打印模板配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePrintTemplateByTemplateIds(Long[] templateIds)
|
||||
{
|
||||
return printTemplateMapper.deletePrintTemplateByTemplateIds(templateIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除打印模板配置信息
|
||||
*
|
||||
* @param templateId 打印模板配置主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePrintTemplateByTemplateId(Long templateId)
|
||||
{
|
||||
return printTemplateMapper.deletePrintTemplateByTemplateId(templateId);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package com.ktg.print.util;
|
||||
|
||||
/**
|
||||
* 负责将模板内容转换为具体的标签打印机协议
|
||||
*/
|
||||
public class ContentConverter {
|
||||
|
||||
|
||||
}
|
||||
146
ktg-print/src/main/resources/mapper/print/PrintClientMapper.xml
Normal file
146
ktg-print/src/main/resources/mapper/print/PrintClientMapper.xml
Normal file
@ -0,0 +1,146 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ktg.print.mapper.PrintClientMapper">
|
||||
|
||||
<resultMap type="PrintClient" id="PrintClientResult">
|
||||
<result property="clientId" column="client_id" />
|
||||
<result property="clientCode" column="client_code" />
|
||||
<result property="clientName" column="client_name" />
|
||||
<result property="clientIp" column="client_ip" />
|
||||
<result property="clientPort" column="client_port" />
|
||||
<result property="clientToken" column="client_token" />
|
||||
<result property="status" column="status" />
|
||||
<result property="workshopId" column="workshop_id" />
|
||||
<result property="workshopCode" column="workshop_code" />
|
||||
<result property="workshopName" column="workshop_name" />
|
||||
<result property="workstationId" column="workstation_id" />
|
||||
<result property="workstationCode" column="workstation_code" />
|
||||
<result property="workstationName" column="workstation_name" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="attr1" column="attr1" />
|
||||
<result property="attr2" column="attr2" />
|
||||
<result property="attr3" column="attr3" />
|
||||
<result property="attr4" column="attr4" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPrintClientVo">
|
||||
select client_id, client_code, client_name, client_ip, client_port, client_token, workshop_id, workshop_code, workshop_name, workstation_id, workstation_code, workstation_name, status, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from print_client
|
||||
</sql>
|
||||
|
||||
<select id="getClientList" resultType="com.ktg.print.domain.PrintClient" resultMap="PrintClientResult">
|
||||
<include refid="selectPrintClientVo"/>
|
||||
<where>
|
||||
<if test="clientCode != null and clientCode != ''"> and client_code = #{clientCode}</if>
|
||||
<if test="clientName != null and clientName != ''"> and client_name like concat('%', #{clientName}, '%')</if>
|
||||
<if test="clientIp != null and clientIp != ''"> and client_ip = #{clientIp}</if>
|
||||
<if test="clientPort != null"> and client_port = #{clientPort}</if>
|
||||
<if test="clientToken != null and clientToken != ''"> and client_token = #{clientToken}</if>
|
||||
<if test="workshopName != null and workshopName != ''"> and workshop_name like concat('%', #{workshopName}, '%')</if>
|
||||
<if test="workshopCode != null and workshopCode != ''"> and workshop_code = #{workshopCode}</if>
|
||||
<if test="workstationName != null and workstationName != ''"> and workstation_name like concat('%', #{workstationName}, '%')</if>
|
||||
<if test="workstationCode != null and workstationCode != ''"> and workstationCode = #{workstationCode}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="checkCilentCodeUnique" resultType="com.ktg.print.domain.PrintClient" resultMap="PrintClientResult">
|
||||
<include refid="selectPrintClientVo"/>
|
||||
where client_code = #{clientCode}
|
||||
limit 1
|
||||
</select>
|
||||
<select id="selectById" resultType="com.ktg.print.domain.PrintClient" resultMap="PrintClientResult">
|
||||
<include refid="selectPrintClientVo"/>
|
||||
where client_id = #{clientId}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertClient" parameterType="PrintClient" useGeneratedKeys="true" keyProperty="clientId">
|
||||
insert into print_client
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="clientCode != null">client_code,</if>
|
||||
<if test="clientName != null">client_name,</if>
|
||||
<if test="clientIp != null and clientIp != ''">client_ip,</if>
|
||||
<if test="clientPort != null">client_port,</if>
|
||||
<if test="clientToken != null">client_token,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="workshopId != null">workshop_id,</if>
|
||||
<if test="workshopCode != null">workshop_code,</if>
|
||||
<if test="workshopName != null">workshop_name,</if>
|
||||
<if test="workstationId != null">workstation_id,</if>
|
||||
<if test="workstationCode != null">workstation_code,</if>
|
||||
<if test="workstationName != null">workstation_name,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="attr1 != null">attr1,</if>
|
||||
<if test="attr2 != null">attr2,</if>
|
||||
<if test="attr3 != null">attr3,</if>
|
||||
<if test="attr4 != null">attr4,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="clientCode != null">#{clientCode},</if>
|
||||
<if test="clientName != null">#{clientName},</if>
|
||||
<if test="clientIp != null and clientIp != ''">#{clientIp},</if>
|
||||
<if test="clientPort != null">#{clientPort},</if>
|
||||
<if test="clientToken != null">#{clientToken},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="workshopId != null">#{workshopId},</if>
|
||||
<if test="workshopCode != null">#{workshopCode},</if>
|
||||
<if test="workshopName != null">#{workshopName},</if>
|
||||
<if test="workstationId != null">#{workstationId},</if>
|
||||
<if test="workstationCode != null">#{workstationCode},</if>
|
||||
<if test="workstationName != null">#{workstationName},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="attr1 != null">#{attr1},</if>
|
||||
<if test="attr2 != null">#{attr2},</if>
|
||||
<if test="attr3 != null">#{attr3},</if>
|
||||
<if test="attr4 != null">#{attr4},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateClient" parameterType="PrintClient">
|
||||
update print_client
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="clientCode != null">client_code = #{clientCode},</if>
|
||||
<if test="clientName != null">client_name = #{clientName},</if>
|
||||
<if test="clientIp != null and clientIp != ''">client_ip = #{clientIp},</if>
|
||||
<if test="clientPort != null">client_port = #{clientPort},</if>
|
||||
<if test="clientToken != null">client_token = #{clientToken},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="workshopId != null">workshop_id = #{workshopId},</if>
|
||||
<if test="workshopCode != null">workshop_code = #{workshopCode},</if>
|
||||
<if test="workshopName != null">workshop_name = #{workshopName},</if>
|
||||
<if test="workstationId != null">workstation_id = #{workstationId},</if>
|
||||
<if test="workstationCode != null">workstation_code = #{workstationCode},</if>
|
||||
<if test="workstationName != null">workstation_name = #{workstationName},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="attr1 != null">attr1 = #{attr1},</if>
|
||||
<if test="attr2 != null">attr2 = #{attr2},</if>
|
||||
<if test="attr3 != null">attr3 = #{attr3},</if>
|
||||
<if test="attr4 != null">attr4 = #{attr4},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where client_id = #{clientId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteByIds">
|
||||
delete from print_client where client_id in
|
||||
<foreach item="item" collection="clientIds" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@ -0,0 +1,169 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ktg.print.mapper.PrintPrinterConfigMapper">
|
||||
<resultMap type="PrintPrinterConfig" id="PrintPrinterConfigResult">
|
||||
<result property="printerId" column="printer_id" />
|
||||
<result property="clientId" column="client_id" />
|
||||
<result property="printerCode" column="printer_code" />
|
||||
<result property="printerType" column="printer_type" />
|
||||
<result property="printerName" column="printer_name" />
|
||||
<result property="brand" column="brand" />
|
||||
<result property="printerModel" column="printer_model" />
|
||||
<result property="connectionType" column="connection_type" />
|
||||
<result property="printerUrl" column="printer_url" />
|
||||
<result property="printerIp" column="printer_ip" />
|
||||
<result property="printerPort" column="printer_port" />
|
||||
<result property="enableFlag" column="enable_flag" />
|
||||
<result property="status" column="status" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="attr1" column="attr1" />
|
||||
<result property="attr2" column="attr2" />
|
||||
<result property="attr3" column="attr3" />
|
||||
<result property="attr4" column="attr4" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="defaultFlag" column="default_flag" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPrintPrinterConfigVo">
|
||||
select printer_id, client_id, printer_code, printer_type, printer_name, brand, printer_model, connection_type, printer_url, printer_ip, printer_port, enable_flag, status, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time, default_flag from print_printer_config
|
||||
</sql>
|
||||
|
||||
<select id="selectPrintPrinterConfigList" parameterType="PrintPrinterConfig" resultMap="PrintPrinterConfigResult">
|
||||
<include refid="selectPrintPrinterConfigVo"/>
|
||||
<where>
|
||||
<if test="clientId != null "> and client_id = #{clientId}</if>
|
||||
<if test="printerType != null and printerType != ''"> and printer_type = #{printerType}</if>
|
||||
<if test="printerCode != null and printerCode != ''"> and printer_code = #{printerCode}</if>
|
||||
<if test="printerName != null and printerName != ''"> and printer_name like concat('%', #{printerName}, '%')</if>
|
||||
<if test="brand != null and brand != ''"> and brand = #{brand}</if>
|
||||
<if test="printerModel != null and printerModel != ''"> and printer_model = #{printerModel}</if>
|
||||
<if test="connectionType != null and connectionType != ''"> and connection_type = #{connectionType}</if>
|
||||
<if test="printerUrl != null and printerUrl != ''"> and printer_url = #{printerUrl}</if>
|
||||
<if test="printerIp != null and printerIp != ''"> and printer_ip = #{printerIp}</if>
|
||||
<if test="printerPort != null "> and printer_port = #{printerPort}</if>
|
||||
<if test="enableFlag != null and enableFlag != ''"> and enable_flag = #{enableFlag}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectPrintPrinterConfigByPrinterId" parameterType="Long" resultMap="PrintPrinterConfigResult">
|
||||
<include refid="selectPrintPrinterConfigVo"/>
|
||||
where printer_id = #{printerId}
|
||||
</select>
|
||||
|
||||
<select id="selectPrintPrinterConfigByPrinterCode" parameterType="String" resultMap="PrintPrinterConfigResult">
|
||||
<include refid="selectPrintPrinterConfigVo"/>
|
||||
where printer_code = #{printerCode} limit 1
|
||||
</select>
|
||||
|
||||
<select id="checkPrinterCodeUnique" parameterType="PrintPrinterConfig" resultMap="PrintPrinterConfigResult">
|
||||
<include refid="selectPrintPrinterConfigVo"/>
|
||||
where printer_code = #{printerCode} limit 1
|
||||
</select>
|
||||
<select id="getDefaultPrint" resultType="com.ktg.print.domain.PrintPrinterConfig" resultMap="PrintPrinterConfigResult">
|
||||
<include refid="selectPrintPrinterConfigVo"/>
|
||||
where default_flag = "Y" and client_id = #{clientId}
|
||||
</select>
|
||||
<select id="getByClientId" resultType="com.ktg.print.domain.PrintPrinterConfig" resultMap="PrintPrinterConfigResult">
|
||||
<include refid="selectPrintPrinterConfigVo"/>
|
||||
where client_id = #{clientId}
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertPrintPrinterConfig" parameterType="PrintPrinterConfig" useGeneratedKeys="true" keyProperty="printerId">
|
||||
insert into print_printer_config
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="clientId != null">client_id,</if>
|
||||
<if test="printerCode != null">printer_code,</if>
|
||||
<if test="printerType != null">printer_type,</if>
|
||||
<if test="printerName != null and printerName != ''">printer_name,</if>
|
||||
<if test="brand != null">brand,</if>
|
||||
<if test="printerModel != null">printer_model,</if>
|
||||
<if test="connectionType != null">connection_type,</if>
|
||||
<if test="printerUrl != null">printer_url,</if>
|
||||
<if test="printerIp != null">printer_ip,</if>
|
||||
<if test="printerPort != null">printer_port,</if>
|
||||
<if test="enableFlag != null">enable_flag,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="attr1 != null">attr1,</if>
|
||||
<if test="attr2 != null">attr2,</if>
|
||||
<if test="attr3 != null">attr3,</if>
|
||||
<if test="attr4 != null">attr4,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="defaultFlag != null">default_flag,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="clientId != null">#{clientId},</if>
|
||||
<if test="printerCode != null">#{printerCode},</if>
|
||||
<if test="printerType != null">#{printerType},</if>
|
||||
<if test="printerName != null and printerName != ''">#{printerName},</if>
|
||||
<if test="brand != null">#{brand},</if>
|
||||
<if test="printerModel != null">#{printerModel},</if>
|
||||
<if test="connectionType != null">#{connectionType},</if>
|
||||
<if test="printerUrl != null">#{printerUrl},</if>
|
||||
<if test="printerIp != null">#{printerIp},</if>
|
||||
<if test="printerPort != null">#{printerPort},</if>
|
||||
<if test="enableFlag != null">#{enableFlag},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="attr1 != null">#{attr1},</if>
|
||||
<if test="attr2 != null">#{attr2},</if>
|
||||
<if test="attr3 != null">#{attr3},</if>
|
||||
<if test="attr4 != null">#{attr4},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="defaultFlag != null">#{defaultFlag},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updatePrintPrinterConfig" parameterType="PrintPrinterConfig">
|
||||
update print_printer_config
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="printerCode != null">printer_code = #{printerCode},</if>
|
||||
<if test="clientId != null">client_id = #{clientId},</if>
|
||||
<if test="printerType != null">printer_type = #{printerType},</if>
|
||||
<if test="printerName != null and printerName != ''">printer_name = #{printerName},</if>
|
||||
<if test="brand != null">brand = #{brand},</if>
|
||||
<if test="printerModel != null">printer_model = #{printerModel},</if>
|
||||
<if test="connectionType != null">connection_type = #{connectionType},</if>
|
||||
<if test="printerUrl != null">printer_url = #{printerUrl},</if>
|
||||
<if test="printerIp != null">printer_ip = #{printerIp},</if>
|
||||
<if test="printerPort != null">printer_port = #{printerPort},</if>
|
||||
<if test="enableFlag != null">enable_flag = #{enableFlag},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="attr1 != null">attr1 = #{attr1},</if>
|
||||
<if test="attr2 != null">attr2 = #{attr2},</if>
|
||||
<if test="attr3 != null">attr3 = #{attr3},</if>
|
||||
<if test="attr4 != null">attr4 = #{attr4},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="defaultFlag != null">default_flag = #{defaultFlag}</if>
|
||||
</trim>
|
||||
where printer_id = #{printerId}
|
||||
</update>
|
||||
|
||||
<delete id="deletePrintPrinterConfigByPrinterId" parameterType="Long">
|
||||
delete from print_printer_config where printer_id = #{printerId}
|
||||
</delete>
|
||||
|
||||
<delete id="deletePrintPrinterConfigByPrinterIds" parameterType="String">
|
||||
delete from print_printer_config where printer_id in
|
||||
<foreach item="printerId" collection="array" open="(" separator="," close=")">
|
||||
#{printerId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ktg.print.mapper.PrintTemplateMapper">
|
||||
|
||||
<resultMap type="PrintTemplate" id="PrintTemplateResult">
|
||||
<result property="templateId" column="template_id" />
|
||||
<result property="templateCode" column="template_code" />
|
||||
<result property="templateName" column="template_name" />
|
||||
<result property="templateType" column="template_type" />
|
||||
<result property="templateJson" column="template_json" />
|
||||
<result property="paperType" column="paper_type" />
|
||||
<result property="templateWidth" column="template_width" />
|
||||
<result property="templateHeight" column="template_height" />
|
||||
<result property="isDefault" column="is_default" />
|
||||
<result property="enableFlag" column="enable_flag" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="attr1" column="attr1" />
|
||||
<result property="attr2" column="attr2" />
|
||||
<result property="attr3" column="attr3" />
|
||||
<result property="attr4" column="attr4" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="templatePic" column="template_pic" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPrintTemplateVo">
|
||||
select template_id, template_code, template_name, template_type, template_json, paper_type, template_width, template_height, is_default, enable_flag, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time, template_pic from print_template
|
||||
</sql>
|
||||
|
||||
<select id="selectPrintTemplateList" parameterType="PrintTemplate" resultMap="PrintTemplateResult">
|
||||
<include refid="selectPrintTemplateVo"/>
|
||||
<where>
|
||||
<if test="templateCode != null and templateCode != ''"> and template_code = #{templateCode}</if>
|
||||
<if test="templateName != null and templateName != ''"> and template_name like concat('%', #{templateName}, '%')</if>
|
||||
<if test="templateType != null and templateType != ''"> and template_type = #{templateType}</if>
|
||||
<if test="templateJson != null and templateJson != ''"> and template_json = #{templateJson}</if>
|
||||
<if test="paperType != null and paperType != ''"> and paper_type = #{paperType}</if>
|
||||
<if test="isDefault != null and isDefault != ''"> and is_default = #{isDefault}</if>
|
||||
<if test="enableFlag != null and enableFlag != ''"> and enable_flag = #{enableFlag}</if>
|
||||
<if test="templatePic != null and templatePic != ''"> and template_pic = #{templatePic}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectPrintTemplateByTemplateId" parameterType="Long" resultMap="PrintTemplateResult">
|
||||
<include refid="selectPrintTemplateVo"/>
|
||||
where template_id = #{templateId}
|
||||
</select>
|
||||
|
||||
<insert id="insertPrintTemplate" parameterType="PrintTemplate" useGeneratedKeys="true" keyProperty="templateId">
|
||||
insert into print_template
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="templateCode != null and templateCode != ''">template_code,</if>
|
||||
<if test="templateName != null">template_name,</if>
|
||||
<if test="templateType != null and templateType != ''">template_type,</if>
|
||||
<if test="templateJson != null">template_json,</if>
|
||||
<if test="paperType != null">paper_type,</if>
|
||||
<if test="templateWidth != null">template_width,</if>
|
||||
<if test="templateHeight != null">template_height,</if>
|
||||
<if test="isDefault != null">is_default,</if>
|
||||
<if test="enableFlag != null">enable_flag,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="attr1 != null">attr1,</if>
|
||||
<if test="attr2 != null">attr2,</if>
|
||||
<if test="attr3 != null">attr3,</if>
|
||||
<if test="attr4 != null">attr4,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="templatePic != null">template_pic,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="templateCode != null and templateCode != ''">#{templateCode},</if>
|
||||
<if test="templateName != null">#{templateName},</if>
|
||||
<if test="templateType != null and templateType != ''">#{templateType},</if>
|
||||
<if test="templateJson != null">#{templateJson},</if>
|
||||
<if test="paperType != null">#{paperType},</if>
|
||||
<if test="templateWidth != null">#{templateWidth},</if>
|
||||
<if test="templateHeight != null">#{templateHeight},</if>
|
||||
<if test="isDefault != null">#{isDefault},</if>
|
||||
<if test="enableFlag != null">#{enableFlag},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="attr1 != null">#{attr1},</if>
|
||||
<if test="attr2 != null">#{attr2},</if>
|
||||
<if test="attr3 != null">#{attr3},</if>
|
||||
<if test="attr4 != null">#{attr4},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="templatePic != null">#{templatePic},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updatePrintTemplate" parameterType="PrintTemplate">
|
||||
update print_template
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="templateCode != null and templateCode != ''">template_code = #{templateCode},</if>
|
||||
<if test="templateName != null">template_name = #{templateName},</if>
|
||||
<if test="templateType != null and templateType != ''">template_type = #{templateType},</if>
|
||||
<if test="templateJson != null">template_json = #{templateJson},</if>
|
||||
<if test="paperType != null">paper_type = #{paperType},</if>
|
||||
<if test="templateWidth != null">template_width = #{templateWidth},</if>
|
||||
<if test="templateHeight != null">template_height = #{templateHeight},</if>
|
||||
<if test="isDefault != null">is_default = #{isDefault},</if>
|
||||
<if test="enableFlag != null">enable_flag = #{enableFlag},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="attr1 != null">attr1 = #{attr1},</if>
|
||||
<if test="attr2 != null">attr2 = #{attr2},</if>
|
||||
<if test="attr3 != null">attr3 = #{attr3},</if>
|
||||
<if test="attr4 != null">attr4 = #{attr4},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="templatePic != null">template_pic = #{templatePic},</if>
|
||||
</trim>
|
||||
where template_id = #{templateId}
|
||||
</update>
|
||||
|
||||
<delete id="deletePrintTemplateByTemplateId" parameterType="Long">
|
||||
delete from print_template where template_id = #{templateId}
|
||||
</delete>
|
||||
|
||||
<delete id="deletePrintTemplateByTemplateIds" parameterType="String">
|
||||
delete from print_template where template_id in
|
||||
<foreach item="templateId" collection="array" open="(" separator="," close=")">
|
||||
#{templateId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user