From c3b58b1d0d4601a046428bc48b7d428ee6246f8f Mon Sep 17 00:00:00 2001 From: zhaoyf <1783123481@qq.com> Date: Sat, 9 May 2026 14:22:25 +0800 Subject: [PATCH] =?UTF-8?q?opt:=E5=A4=A7=E5=B1=8F=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E5=8A=9F=E8=83=BD-=E6=96=B0=E5=A2=9E=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E6=9C=BA=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=A4=9A=E6=89=93=E5=8D=B0=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../printer/SysPrinterController.java | 71 ++++++++++ .../service/printer/ISysPrinterService.java | 44 ++++++ .../service/printer/dao/SysPrinter.java | 77 +++++++++++ .../printer/dao/mapper/SysPrinterMapper.java | 12 ++ .../printer/dao/mapper/SysPrinterMapper.xml | 5 + .../service/printer/dto/SysPrinterDto.java | 14 ++ .../service/printer/dto/SysPrinterQuery.java | 12 ++ .../printer/impl/SysPrinterServiceImpl.java | 80 +++++++++++ .../wms/ext/handheld/dto/PrintEntityDto.java | 2 + .../service/impl/HandheldServiceImpl.java | 8 +- lms/nladmin-ui/public/index.html | 2 - .../src/views/system/printer/index.vue | 128 ++++++++++++++++++ .../src/views/system/printer/printer.js | 34 +++++ .../src/views/wms/produceScreen/index.vue | 63 ++++++++- .../views/wms/produceScreen/produceScreen.js | 15 ++ 15 files changed, 559 insertions(+), 8 deletions(-) create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/printer/SysPrinterController.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/ISysPrinterService.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/dao/SysPrinter.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/dao/mapper/SysPrinterMapper.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/dao/mapper/SysPrinterMapper.xml create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/dto/SysPrinterDto.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/dto/SysPrinterQuery.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/impl/SysPrinterServiceImpl.java create mode 100644 lms/nladmin-ui/src/views/system/printer/index.vue create mode 100644 lms/nladmin-ui/src/views/system/printer/printer.js diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/printer/SysPrinterController.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/printer/SysPrinterController.java new file mode 100644 index 0000000..2fc20f5 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/printer/SysPrinterController.java @@ -0,0 +1,71 @@ +package org.nl.system.controller.printer; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.nl.common.base.TableDataInfo; +import org.nl.common.domain.query.PageQuery; +import org.nl.common.logging.annotation.Log; +import org.nl.system.service.param.dao.Param; +import org.nl.system.service.printer.ISysPrinterService; +import org.nl.system.service.printer.dao.SysPrinter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** +* @author zhaoyf +* @date 2026-05-07 +**/ +@Slf4j +@RestController +@RequestMapping("/api/printer") +@Api("打印机管理") +public class SysPrinterController { + + @Autowired + private ISysPrinterService iSysPrinterService; + + @GetMapping + @Log("查询所有打印机") + @ApiOperation("查询打印机") + public ResponseEntity query(@RequestParam Map whereJson, PageQuery page){ + return new ResponseEntity<>(TableDataInfo.build(iSysPrinterService.queryAll(whereJson, page)), HttpStatus.OK); + } + + @GetMapping("/all") + public ResponseEntity all(){ + return new ResponseEntity<>(iSysPrinterService.list(),HttpStatus.OK); + } + + @PostMapping + @Log("新增打印机") + @ApiOperation("新增") + public ResponseEntity create(@Validated @RequestBody SysPrinter param){ + iSysPrinterService.create(param); + return new ResponseEntity<>(HttpStatus.CREATED); + } + + @PutMapping + @Log("修改打印机参数") + @ApiOperation("修改打印机参数") + public ResponseEntity update(@Validated @RequestBody SysPrinter param){ + iSysPrinterService.update(param); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @Log("删除打印机") + @ApiOperation("删除打印机") + @DeleteMapping + public ResponseEntity delete(@RequestBody String[] ids) { + List Ids = Arrays.asList(ids); + iSysPrinterService.deleteAll(Ids); + return new ResponseEntity<>(HttpStatus.OK); + } +} \ No newline at end of file diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/ISysPrinterService.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/ISysPrinterService.java new file mode 100644 index 0000000..1379dd0 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/ISysPrinterService.java @@ -0,0 +1,44 @@ +package org.nl.system.service.printer; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.nl.common.domain.query.PageQuery; +import com.baomidou.mybatisplus.extension.service.IService; +import org.nl.system.service.printer.dao.SysPrinter; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** +* @description 服务接口 +* @author zhaoyf +* @date 2026-05-07 +**/ +public interface ISysPrinterService extends IService { + + /** + * 查询数据分页 + * @param whereJson 条件 + * @param pageable 分页参数 + * @return IPage + */ + IPage queryAll(Map whereJson, PageQuery pageable); + + /** + * 创建 + * @param entity / + */ + void create(SysPrinter entity); + + /** + * 编辑 + * @param entity / + */ + void update(SysPrinter entity); + + /** + * 多选删除 + * @param ids / + */ + void deleteAll(List ids); +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/dao/SysPrinter.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/dao/SysPrinter.java new file mode 100644 index 0000000..cbedc57 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/dao/SysPrinter.java @@ -0,0 +1,77 @@ +package org.nl.system.service.printer.dao; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** +* @description / +* @author zhaoyf +* @date 2026-05-07 +**/ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("sys_printer") +public class SysPrinter implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + private String name; + + private String ip; + + private Integer port; + + /** + * 备注 + */ + private String remark; + + /** + * 是否启用 + */ + private Boolean is_active; + + /** + * 是否删除 + */ + private Boolean is_delete; + + /** + * 创建者ID + */ + private String create_id; + + /** + * 创建者 + */ + private String create_name; + + /** + * 创建时间 + */ + private String create_time; + + /** + * 修改者ID + */ + private String update_id; + + /** + * 修改者 + */ + private String update_name; + + /** + * 修改时间 + */ + private String update_time; +} \ No newline at end of file diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/dao/mapper/SysPrinterMapper.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/dao/mapper/SysPrinterMapper.java new file mode 100644 index 0000000..03d950a --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/dao/mapper/SysPrinterMapper.java @@ -0,0 +1,12 @@ +package org.nl.system.service.printer.dao.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.nl.system.service.printer.dao.SysPrinter; + +/** +* @author zhaoyf +* @date 2026-05-07 +**/ +public interface SysPrinterMapper extends BaseMapper { + +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/dao/mapper/SysPrinterMapper.xml b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/dao/mapper/SysPrinterMapper.xml new file mode 100644 index 0000000..1ae7301 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/dao/mapper/SysPrinterMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/dto/SysPrinterDto.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/dto/SysPrinterDto.java new file mode 100644 index 0000000..cf627f0 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/dto/SysPrinterDto.java @@ -0,0 +1,14 @@ +package org.nl.system.service.printer.dto; + +import lombok.Data; +import java.io.Serializable; + +/** +* @description / +* @author zhaoyf +* @date 2026-05-07 +**/ +@Data +public class SysPrinterDto implements Serializable { + +} \ No newline at end of file diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/dto/SysPrinterQuery.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/dto/SysPrinterQuery.java new file mode 100644 index 0000000..0f045b3 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/dto/SysPrinterQuery.java @@ -0,0 +1,12 @@ +package org.nl.system.service.printer.dto; + +import org.nl.common.domain.query.BaseQuery; +import org.nl.system.service.printer.dao.SysPrinter; + +/** +* @author zhaoyf +* @date 2026-05-07 +**/ +public class SysPrinterQuery extends BaseQuery { + +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/impl/SysPrinterServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/impl/SysPrinterServiceImpl.java new file mode 100644 index 0000000..bb1632e --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/printer/impl/SysPrinterServiceImpl.java @@ -0,0 +1,80 @@ +package org.nl.system.service.printer.impl; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.common.domain.query.PageQuery; +import org.nl.common.exception.BadRequestException; +import org.nl.common.utils.SecurityUtils; +import org.nl.system.service.printer.ISysPrinterService; +import org.nl.system.service.printer.dao.SysPrinter; +import org.nl.system.service.printer.dao.mapper.SysPrinterMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** +* @description 服务实现 +* @author zhaoyf +* @date 2026-05-07 +**/ +@Slf4j +@Service +public class SysPrinterServiceImpl extends ServiceImpl implements ISysPrinterService { + + @Autowired + private SysPrinterMapper sysPrinterMapper; + + @Override + public IPage queryAll(Map whereJson, PageQuery page){ + LambdaQueryWrapper lam = new LambdaQueryWrapper<>(); + IPage pages = new Page<>(page.getPage() + 1, page.getSize()); + sysPrinterMapper.selectPage(pages, lam); + return pages; + } + + @Override + public void create(SysPrinter entity) { + String currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + String now = DateUtil.now(); + + entity.setCreate_id(currentUserId); + entity.setCreate_name(nickName); + entity.setCreate_time(now); + entity.setUpdate_id(currentUserId); + entity.setUpdate_name(nickName); + entity.setUpdate_time(now); + sysPrinterMapper.insert(entity); + } + + @Override + public void update(SysPrinter entity) { + SysPrinter dto = sysPrinterMapper.selectById(entity.getId()); + if (dto == null) throw new BadRequestException("被删除或无权限,操作失败!"); + + String currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + String now = DateUtil.now(); + entity.setUpdate_id(currentUserId); + entity.setUpdate_name(nickName); + entity.setUpdate_time(now); + + sysPrinterMapper.updateById(entity); + } + + @Override + public void deleteAll(List ids) { + // 真删除 + sysPrinterMapper.deleteBatchIds(ids); + } + +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/handheld/dto/PrintEntityDto.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/handheld/dto/PrintEntityDto.java index a8a0ba6..f22f668 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/handheld/dto/PrintEntityDto.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/handheld/dto/PrintEntityDto.java @@ -17,4 +17,6 @@ public class PrintEntityDto { private String MaterialCode; @JsonProperty("username") private String username; + private String ip; + private Integer port; } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/handheld/service/impl/HandheldServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/handheld/service/impl/HandheldServiceImpl.java index 1b3261d..67be6a2 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/handheld/service/impl/HandheldServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/handheld/service/impl/HandheldServiceImpl.java @@ -1724,17 +1724,15 @@ public class HandheldServiceImpl implements HandheldService { @Override public void print(PrintEntityDto printEntityDto) { - String ip = sysParamServiceImpl.findByCode("printerIP").getValue(); - String port = sysParamServiceImpl.findByCode("printerPort").getValue(); - if (ip == null || StringUtils.isBlank(ip)) { + if (printEntityDto.getIp() == null || StringUtils.isBlank(printEntityDto.getIp())) { throw new BadRequestException("打印出错:未配置打印机IP(printerIP)"); } - if (port == null || StringUtils.isBlank(port)) { + if (printEntityDto.getPort() == null) { throw new BadRequestException("打印出错:未配置打印机端口(printerPort)"); } try (Socket client = new Socket()) { // 3. 设置超时时间,防止网络不通时线程卡死 (单位:毫秒) - client.connect(new InetSocketAddress(ip, Integer.parseInt(port)), 3000); // 连接超时 3秒 + client.connect(new InetSocketAddress(printEntityDto.getIp(), printEntityDto.getPort()), 3000); // 连接超时 3秒 client.setSoTimeout(10000); // 读取超时 10秒 try (OutputStream outputStream = client.getOutputStream()) { diff --git a/lms/nladmin-ui/public/index.html b/lms/nladmin-ui/public/index.html index 4adf994..3bad79d 100644 --- a/lms/nladmin-ui/public/index.html +++ b/lms/nladmin-ui/public/index.html @@ -8,8 +8,6 @@ - - <%= webpackConfig.name %> diff --git a/lms/nladmin-ui/src/views/system/printer/index.vue b/lms/nladmin-ui/src/views/system/printer/index.vue new file mode 100644 index 0000000..324b797 --- /dev/null +++ b/lms/nladmin-ui/src/views/system/printer/index.vue @@ -0,0 +1,128 @@ + + + + + diff --git a/lms/nladmin-ui/src/views/system/printer/printer.js b/lms/nladmin-ui/src/views/system/printer/printer.js new file mode 100644 index 0000000..e1d0b5d --- /dev/null +++ b/lms/nladmin-ui/src/views/system/printer/printer.js @@ -0,0 +1,34 @@ +import request from '@/utils/request' + +export function add(data) { + return request({ + url: 'api/printer', + method: 'post', + data + }) +} + +export function del(ids) { + return request({ + url: 'api/printer/', + method: 'delete', + data: ids + }) +} + +export function edit(data) { + return request({ + url: 'api/printer', + method: 'put', + data + }) +} + +export function getValueByCode(code) { + return request({ + url: 'api/printer/getValueByCode/' + code, + method: 'post' + }) +} + +export default { add, edit, del, getValueByCode } diff --git a/lms/nladmin-ui/src/views/wms/produceScreen/index.vue b/lms/nladmin-ui/src/views/wms/produceScreen/index.vue index 5fc084e..9f28817 100644 --- a/lms/nladmin-ui/src/views/wms/produceScreen/index.vue +++ b/lms/nladmin-ui/src/views/wms/produceScreen/index.vue @@ -404,6 +404,25 @@
确认打印内容
+ +
+
打印机
+
+ + + + + + + +
+
订单号
@@ -449,6 +468,25 @@
自定义打印
+ +
+
打印机
+
+ + + + + + + +
+
订单号
@@ -493,7 +531,7 @@