From 4460a78b776cfb6254fac6c4688a1cd344fc2c10 Mon Sep 17 00:00:00 2001 From: Leon <3066758958@qq.com> Date: Wed, 11 Aug 2021 16:51:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8D=B0=E6=9C=BA=E7=BB=B4=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/controller/PrinterController.java | 93 +++++++++++++ .../mesnac/common/enums/HandleEnum.java | 2 + .../mesnac/common}/mapper/PrinterMapper.java | 6 +- .../mesnac/common}/model/Printer.java | 11 +- .../common}/service/PrinterService.java | 6 +- .../service/impl/PrinterServiceImpl.java | 10 +- .../main/resources/mapper/PrinterMapper.xml | 34 ++--- integration/pom.xml | 4 +- .../meapi/controller/PrinterController.java | 130 ------------------ 9 files changed, 131 insertions(+), 165 deletions(-) create mode 100644 common/src/main/java/com/foreverwin/mesnac/common/controller/PrinterController.java rename {meapi/src/main/java/com/foreverwin/mesnac/meapi => common/src/main/java/com/foreverwin/mesnac/common}/mapper/PrinterMapper.java (67%) rename {meapi/src/main/java/com/foreverwin/mesnac/meapi => common/src/main/java/com/foreverwin/mesnac/common}/model/Printer.java (91%) rename {meapi/src/main/java/com/foreverwin/mesnac/meapi => common/src/main/java/com/foreverwin/mesnac/common}/service/PrinterService.java (81%) rename {meapi/src/main/java/com/foreverwin/mesnac/meapi => common/src/main/java/com/foreverwin/mesnac/common}/service/impl/PrinterServiceImpl.java (83%) rename {meapi => common}/src/main/resources/mapper/PrinterMapper.xml (94%) delete mode 100644 meapi/src/main/java/com/foreverwin/mesnac/meapi/controller/PrinterController.java diff --git a/common/src/main/java/com/foreverwin/mesnac/common/controller/PrinterController.java b/common/src/main/java/com/foreverwin/mesnac/common/controller/PrinterController.java new file mode 100644 index 00000000..17e6ee63 --- /dev/null +++ b/common/src/main/java/com/foreverwin/mesnac/common/controller/PrinterController.java @@ -0,0 +1,93 @@ +package com.foreverwin.mesnac.common.controller; + + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.foreverwin.mesnac.common.enums.HandleEnum; +import com.foreverwin.mesnac.common.model.Printer; +import com.foreverwin.modular.core.util.CommonMethods; +import com.foreverwin.modular.core.util.R; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import com.foreverwin.mesnac.common.service.PrinterService; +import java.time.LocalDateTime; +import java.util.List; + +/** + * + * @author Leon.L + * @since 2021-08-11 + */ +@RestController +@RequestMapping("/PRINTER") +public class PrinterController { + + @Autowired + public PrinterService printerService; + + /** + * 查询所有数据 + * + * @return + */ + @ResponseBody + @GetMapping("") + public R getPrinterList(Printer printer){ + List result; + try { + String site = CommonMethods.getSite(); + printer.setSite(site); + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.setEntity(printer); + result = printerService.list(queryWrapper); + } catch (Exception e) { + return R.failed(e.getMessage()); + } + + return R.ok(result); + } + + @ResponseBody + @GetMapping("/getPrinter") + public R savePrinter(String printer) { + Printer result = null; + try { + String site = CommonMethods.getSite(); + String handle = HandleEnum.PRINT.getHandle(site, printer); + result = printerService.getById(handle); + } catch (Exception e) { + return R.failed(e.getMessage()); + } + + return R.ok(result); + } + + @ResponseBody + @PostMapping("/savePrinter") + public R savePrinter(Printer printer) { + try { + LocalDateTime nowDate = LocalDateTime.now(); + String site = CommonMethods.getSite(); + + String handle = HandleEnum.PRINT.getHandle(site, printer.getPrinter()); + Printer printerModel = printerService.getById(handle); + if (printerModel == null) { + printer.setHandle(handle); + printer.setSite(site); + printer.setCreatedDateTime(nowDate); + printer.setModifiedDateTime(nowDate); + printerService.save(printer); + } else { + printerModel.setDescription(printer.getDescription()); + printerModel.setModifiedDateTime(nowDate); + printerService.updateById(printerModel); + } + } catch (Exception e) { + return R.failed(e.getMessage()); + } + + return R.ok(); + } +} \ No newline at end of file diff --git a/common/src/main/java/com/foreverwin/mesnac/common/enums/HandleEnum.java b/common/src/main/java/com/foreverwin/mesnac/common/enums/HandleEnum.java index 7a72e34a..3e3b1ca7 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/enums/HandleEnum.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/enums/HandleEnum.java @@ -20,6 +20,8 @@ public enum HandleEnum { /**物料清单**/ BOM("BOMBO:","BOMBO:{0},{1},{2},{3}"), + PRINT("PrintBO:", "StatusBO:{0},{1}"), + /**叫料**/ CALL_ITEM("CallItemBO:", "CallItemBO:{0},{1}"), diff --git a/meapi/src/main/java/com/foreverwin/mesnac/meapi/mapper/PrinterMapper.java b/common/src/main/java/com/foreverwin/mesnac/common/mapper/PrinterMapper.java similarity index 67% rename from meapi/src/main/java/com/foreverwin/mesnac/meapi/mapper/PrinterMapper.java rename to common/src/main/java/com/foreverwin/mesnac/common/mapper/PrinterMapper.java index da30ef1c..c5884313 100644 --- a/meapi/src/main/java/com/foreverwin/mesnac/meapi/mapper/PrinterMapper.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/mapper/PrinterMapper.java @@ -1,6 +1,6 @@ -package com.foreverwin.mesnac.meapi.mapper; +package com.foreverwin.mesnac.common.mapper; -import com.foreverwin.mesnac.meapi.model.Printer; +import com.foreverwin.mesnac.common.model.Printer; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.springframework.stereotype.Repository; @@ -10,7 +10,7 @@ import org.springframework.stereotype.Repository; *

* * @author Leon.L - * @since 2021-07-22 + * @since 2021-08-11 */ @Repository public interface PrinterMapper extends BaseMapper { diff --git a/meapi/src/main/java/com/foreverwin/mesnac/meapi/model/Printer.java b/common/src/main/java/com/foreverwin/mesnac/common/model/Printer.java similarity index 91% rename from meapi/src/main/java/com/foreverwin/mesnac/meapi/model/Printer.java rename to common/src/main/java/com/foreverwin/mesnac/common/model/Printer.java index dde11f5f..3c07a59f 100644 --- a/meapi/src/main/java/com/foreverwin/mesnac/meapi/model/Printer.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/model/Printer.java @@ -1,7 +1,8 @@ -package com.foreverwin.mesnac.meapi.model; +package com.foreverwin.mesnac.common.model; import java.io.Serializable; +import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model; import java.time.LocalDateTime; @@ -15,15 +16,15 @@ import com.baomidou.mybatisplus.annotation.IdType; *

* * @author Leon.L - * @since 2021-07-22 + * @since 2021-08-11 */ -@TableName("PRINTER") +@TableName("Z_PRINTER") public class Printer extends Model { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - @TableField("HANDLE") + @TableId(value = "HANDLE", type = IdType.INPUT) private String handle; @TableField("SITE") private String site; diff --git a/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/PrinterService.java b/common/src/main/java/com/foreverwin/mesnac/common/service/PrinterService.java similarity index 81% rename from meapi/src/main/java/com/foreverwin/mesnac/meapi/service/PrinterService.java rename to common/src/main/java/com/foreverwin/mesnac/common/service/PrinterService.java index 0e63e6a4..50d35fbc 100644 --- a/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/PrinterService.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/service/PrinterService.java @@ -1,7 +1,7 @@ -package com.foreverwin.mesnac.meapi.service; +package com.foreverwin.mesnac.common.service; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.foreverwin.mesnac.meapi.model.Printer; +import com.foreverwin.mesnac.common.model.Printer; import com.baomidou.mybatisplus.extension.service.IService; import com.foreverwin.modular.core.util.FrontPage; @@ -13,7 +13,7 @@ import java.util.List; *

* * @author Leon.L - * @since 2021-07-22 + * @since 2021-08-11 */ public interface PrinterService extends IService { diff --git a/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/impl/PrinterServiceImpl.java b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/PrinterServiceImpl.java similarity index 83% rename from meapi/src/main/java/com/foreverwin/mesnac/meapi/service/impl/PrinterServiceImpl.java rename to common/src/main/java/com/foreverwin/mesnac/common/service/impl/PrinterServiceImpl.java index 3d461f85..c8ac3174 100644 --- a/meapi/src/main/java/com/foreverwin/mesnac/meapi/service/impl/PrinterServiceImpl.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/PrinterServiceImpl.java @@ -1,11 +1,11 @@ -package com.foreverwin.mesnac.meapi.service.impl; +package com.foreverwin.mesnac.common.service.impl; import com.foreverwin.modular.core.util.FrontPage; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.foreverwin.mesnac.meapi.model.Printer; -import com.foreverwin.mesnac.meapi.mapper.PrinterMapper; -import com.foreverwin.mesnac.meapi.service.PrinterService; +import com.foreverwin.mesnac.common.model.Printer; +import com.foreverwin.mesnac.common.mapper.PrinterMapper; +import com.foreverwin.mesnac.common.service.PrinterService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import org.springframework.beans.factory.annotation.Autowired; @@ -18,7 +18,7 @@ import java.util.List; *

* * @author Leon.L - * @since 2021-07-22 + * @since 2021-08-11 */ @Service @Transactional(rollbackFor = Exception.class) diff --git a/meapi/src/main/resources/mapper/PrinterMapper.xml b/common/src/main/resources/mapper/PrinterMapper.xml similarity index 94% rename from meapi/src/main/resources/mapper/PrinterMapper.xml rename to common/src/main/resources/mapper/PrinterMapper.xml index 503ec683..08976fde 100644 --- a/meapi/src/main/resources/mapper/PrinterMapper.xml +++ b/common/src/main/resources/mapper/PrinterMapper.xml @@ -1,9 +1,9 @@ - + - + @@ -22,7 +22,7 @@ - SELECT FROM PRINTER + SELECT FROM Z_PRINTER HANDLE=#{ew.handle} @@ -51,7 +51,7 @@ - - INSERT INTO PRINTER + + INSERT INTO Z_PRINTER HANDLE, SITE, @@ -222,8 +222,8 @@ - - INSERT INTO PRINTER + + INSERT INTO Z_PRINTER VALUES @@ -244,7 +244,7 @@ - UPDATE PRINTER + UPDATE Z_PRINTER HANDLE=#{et.handle}, SITE=#{et.site}, PRINTER=#{et.printer}, @@ -276,7 +276,7 @@ - DELETE FROM PRINTER + DELETE FROM Z_PRINTER @@ -289,7 +289,7 @@ - DELETE FROM PRINTER + DELETE FROM Z_PRINTER diff --git a/integration/pom.xml b/integration/pom.xml index 640557f7..deeb8a22 100644 --- a/integration/pom.xml +++ b/integration/pom.xml @@ -36,11 +36,11 @@ com.foreverwin.mesnac - dispatch + common com.foreverwin.mesnac - common + dispatch \ No newline at end of file diff --git a/meapi/src/main/java/com/foreverwin/mesnac/meapi/controller/PrinterController.java b/meapi/src/main/java/com/foreverwin/mesnac/meapi/controller/PrinterController.java deleted file mode 100644 index d189884d..00000000 --- a/meapi/src/main/java/com/foreverwin/mesnac/meapi/controller/PrinterController.java +++ /dev/null @@ -1,130 +0,0 @@ -package com.foreverwin.mesnac.meapi.controller; - -import com.foreverwin.modular.core.util.R; -import com.foreverwin.modular.core.util.FrontPage; -import com.foreverwin.modular.core.util.CommonMethods; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import com.foreverwin.mesnac.meapi.service.PrinterService; -import com.foreverwin.mesnac.meapi.model.Printer; -import java.util.List; - -/** - * - * @author Leon.L - * @since 2021-07-22 - */ -@RestController -@RequestMapping("/PRINTER") -public class PrinterController { - - @Autowired - public PrinterService printerService; - - /** - * 根据id查询 - * - * @param id 主键 - * @return - */ - @ResponseBody - @GetMapping("/{id:.+}") - public R getPrinterById(@PathVariable String id) { - return R.ok( printerService.getById(id)); - } - - /** - * 查询所有数据 - * - * @return - */ - @ResponseBody - @GetMapping("") - public R getPrinterList(Printer printer){ - List result; - try { - String site = CommonMethods.getSite(); - printer.setSite(site); - - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.setEntity(printer); - result = printerService.list(queryWrapper); - } catch (Exception e) { - return R.failed(e.getMessage()); - } - - return R.ok(result); - } - - /** - * 分页查询数据 - * - * @param frontPage 分页信息 - * @return - */ - @ResponseBody - @GetMapping("/page") - public R page(FrontPage frontPage, Printer printer){ - IPage result; - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.setEntity(printer); - if (frontPage.getGlobalQuery() != null && !"".equals(frontPage.getGlobalQuery().trim())) { - //TODO modify global query - queryWrapper.lambda().and(wrapper -> wrapper - .like(Printer::getHandle, frontPage.getGlobalQuery()) - .or().like(Printer::getSite, frontPage.getGlobalQuery()) - .or().like(Printer::getPrinter, frontPage.getGlobalQuery()) - .or().like(Printer::getDescription, frontPage.getGlobalQuery()) - .or().like(Printer::getEnabled, frontPage.getGlobalQuery()) - ); - } - result = printerService.page(frontPage.getPagePlus(), queryWrapper); - return R.ok(result); - } - - /** - * 新增 - * @param printer 传递的实体 - * @return null 失败 实体成功 - */ - @PostMapping - public R save(@RequestBody Printer printer) { - return R.ok(printerService.save(printer)); - } - - /** - * 修改 - * @param printer 传递的实体 - * @return null 失败 实体成功 - */ - @PutMapping - public R updateById(@RequestBody Printer printer) { - return R.ok(printerService.updateById(printer)); - } - - /** - * 根据id删除对象 - * @param id 实体ID - * @return 0 失败 1 成功 - */ - @ResponseBody - @RequestMapping(method = RequestMethod.DELETE, value = "/{id:.+}") - public R removeById(@PathVariable("id") String id){ - return R.ok(printerService.removeById(id)); - } - - /** - * 批量删除对象 - * @param ids 实体集合ID - * @return 0 失败 1 成功 - */ - @ResponseBody - @RequestMapping(method = RequestMethod.POST, value = "/delete-batch") - public R removeByIds(List ids){ - return R.ok(printerService.removeByIds(ids)); - } -} \ No newline at end of file