├── .gitignore ├── LICENSE ├── README.md ├── doc ├── apidoc.http ├── demo.png ├── init_print_template.sql ├── mock-data │ ├── preview-component │ │ ├── chuzongdan.json │ │ ├── jiezhangdan.json │ │ ├── kekandan.json │ │ ├── tangkoudan.json │ │ ├── xiaofeiqingdan.json │ │ └── yujiedan.json │ ├── request │ │ ├── content.json │ │ ├── preview-component.json │ │ ├── queryType.json │ │ ├── save.json │ │ ├── system-component.json │ │ └── update.json │ └── system-component │ │ ├── chuzongdan.json │ │ ├── jiezhangdan.json │ │ ├── kekandan.json │ │ ├── tangkoudan.json │ │ ├── xiaofeiqingdan.json │ │ └── yujiedan.json ├── preview │ ├── 厨总单.png │ ├── 堂口单.png │ ├── 客看单.png │ ├── 消费清单.png │ ├── 结账单.png │ └── 预结单.png └── table.sql ├── h5-demo ├── assets │ ├── angular.js │ └── template-web.js ├── css │ ├── bootstrap.css │ ├── main.css │ └── main.less ├── index.html └── js │ ├── main.js │ └── utils.js ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── zxcs │ │ └── printtemplate │ │ ├── PrintTemplateApplication.java │ │ ├── constant │ │ └── SystemComponentTypeEnum.java │ │ ├── controller │ │ ├── PrinterDeviceController.java │ │ ├── PrinterKitchenController.java │ │ └── PrinterTicketController.java │ │ ├── dao │ │ ├── PrinterCustomComponentMapper.java │ │ ├── PrinterDeviceMapper.java │ │ ├── PrinterDocumentTypeMapper.java │ │ ├── PrinterKitchenDocumentTypeRulesMapper.java │ │ ├── PrinterKitchenGoodsRulesMapper.java │ │ ├── PrinterKitchenMapper.java │ │ ├── PrinterKitchenTableRulesMapper.java │ │ ├── PrinterSystemComponentMapper.java │ │ ├── PrinterTemplateDocumentMapper.java │ │ └── PrinterTemplateModuleMapper.java │ │ ├── exception │ │ ├── BaseException.java │ │ ├── GlobalExceptionHandler.java │ │ ├── common │ │ │ ├── ParameterException.java │ │ │ ├── ParameterIllegalException.java │ │ │ ├── ParamterErrorException.java │ │ │ └── PermissionRefusedException.java │ │ └── print │ │ │ ├── PrinterDeviceException.java │ │ │ ├── PrinterKitchenException.java │ │ │ └── PrinterTemplateDocumentException.java │ │ ├── form │ │ ├── BaseForm.java │ │ ├── CustomTemplateDocumentForm.java │ │ ├── DocumentTypeRule.java │ │ ├── PrinterKitchenForm.java │ │ ├── PrinterKitchenGoodsRule.java │ │ ├── PrinterKitchenTableRule.java │ │ ├── SavePrinterDeviceForm.java │ │ ├── TemplateDocumentEnableForm.java │ │ ├── UpdateCustomTemplateDocumentForm.java │ │ └── UpdatePrinterDeviceForm.java │ │ ├── helper │ │ └── MapHelper.java │ │ ├── model │ │ ├── PrinterCustomComponentDO.java │ │ ├── PrinterDeviceDO.java │ │ ├── PrinterDocumentTypeDO.java │ │ ├── PrinterKitchenDO.java │ │ ├── PrinterKitchenDocumentTypeRulesDO.java │ │ ├── PrinterKitchenGoodsRulesDO.java │ │ ├── PrinterKitchenTableRulesDO.java │ │ ├── PrinterSystemComponentDO.java │ │ ├── PrinterTemplateDocumentDO.java │ │ └── PrinterTemplateModuleDO.java │ │ ├── service │ │ ├── IPrinterCustomComponentService.java │ │ ├── IPrinterDeviceService.java │ │ ├── IPrinterDocumentTypeService.java │ │ ├── IPrinterKitchenDocumentTypeRulesService.java │ │ ├── IPrinterKitchenGoodsRulesService.java │ │ ├── IPrinterKitchenService.java │ │ ├── IPrinterKitchenTableRulesService.java │ │ ├── IPrinterSystemComponentService.java │ │ ├── IPrinterTemplateDocumentService.java │ │ ├── IPrinterTemplateModuleService.java │ │ └── impl │ │ │ ├── PrinterCustomComponentImpl.java │ │ │ ├── PrinterDeviceServiceImpl.java │ │ │ ├── PrinterDocumentTypeServiceImpl.java │ │ │ ├── PrinterKitchenDocumentTypeRulesServiceImpl.java │ │ │ ├── PrinterKitchenGoodsRulesServiceImpl.java │ │ │ ├── PrinterKitchenServiceImpl.java │ │ │ ├── PrinterKitchenTableRulesServiceImpl.java │ │ │ ├── PrinterSystemComponentServiceImpl.java │ │ │ ├── PrinterTemplateDocumentServiceImpl.java │ │ │ └── PrinterTemplateModuleServiceImpl.java │ │ └── vo │ │ ├── PrinterDeviceVO.java │ │ ├── PrinterDocumentTypeVO.java │ │ ├── PrinterKitchenIntegrationVO.java │ │ ├── PrinterKitchenVO.java │ │ ├── PrinterTemplateDocumentVO.java │ │ └── Response.java └── resources │ ├── application.yml │ ├── mapper │ ├── PrinterCustomComponentMapper.xml │ ├── PrinterDeviceMapper.xml │ ├── PrinterDocumentTypeMapper.xml │ ├── PrinterKitchenDocumentTypeRulesMapper.xml │ ├── PrinterKitchenGoodsRulesMapper.xml │ ├── PrinterKitchenMapper.xml │ ├── PrinterKitchenTableRulesMapper.xml │ ├── PrinterSystemComponentMapper.xml │ ├── PrinterTemplateDocumentMapper.xml │ └── PrinterTemplateModuleMapper.xml │ └── mybatis-config.xml └── test └── java └── com └── zxcs └── printtemplate ├── MainTest.java └── api ├── IScOperationPrinterCustomComponentServiceTest.java ├── IScOperationPrinterDeviceServiceTest.java ├── IScOperationPrinterDocumentTypeServiceTest.java ├── IScOperationPrinterKitchenDocumentTypeRulesServiceTest.java ├── IScOperationPrinterKitchenGoodsRulesServiceTest.java ├── IScOperationPrinterKitchenServiceTest.java ├── IScOperationPrinterKitchenTableRulesServiceTest.java ├── IScOperationPrinterSystemComponentServiceTest.java ├── IScOperationPrinterTemplateDocumentServiceTest.java └── IScOperationPrinterTemplateModuleServiceTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | .class 3 | 4 | # idea 5 | .idea/ 6 | .gradle/ 7 | build/ 8 | *.iml 9 | *.ipr 10 | *.iws 11 | 12 | # Eclipse 13 | bin/ 14 | gen/ 15 | .settings/ 16 | .project 17 | .classpath 18 | 19 | # maven 20 | target/ 21 | *.war 22 | *.zip 23 | *.tar 24 | *.tar.gz 25 | 26 | # temp 27 | *.log 28 | *.cache 29 | *.diff 30 | *.patch 31 | *.tmp 32 | logs/ 33 | .svn 34 | 35 | # system 36 | .DS_Store 37 | Thumbs.db 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## printtemplate 2 | 3 | `printtemplate`是一款设计完整,使用在80mm热敏小票打印机上的打印模板,模板包含的模块已经满足 餐饮店堂食、外卖小票的绝大部分场景。 4 | 开箱即用,开发者可以很快速的集成到内部应用中。 5 | 6 | 7 | ## Demo 8 | 9 | ![预览图](./doc/demo.png) 10 | 11 | ### [Demo演示视频](https://www.bilibili.com/video/BV1aK4y1k7tg/) 12 | 13 | 14 | ## Design 15 | 16 | - 1.打印模板-设计输出流程: 17 | 18 | 1)根据不同的模板类型,设计小票排版的`HTML`静态页面。 19 | 20 | 2)将订单数据渲染到`HTML`文件中。 21 | 22 | 3)将渲染好的`HTML`文件发送到小票打印机,完成打印出票。 23 | 24 | - 2.出票口设计思路 25 | 26 | 1)出票口 是一组打印规则,用于打印指定的菜品;比如配置:桌位的区域、餐饮菜品的种类、特定的商品。 27 | 28 | 2)出票口 可以配置 一品一纸、多品一纸等等。 29 | 30 | 3)出票口列表、新增出票口、删除出票口、修改出票口。 31 | 32 | 33 | ## Deployment 34 | 35 | 1.初始化数据,在MySQL中新建数据库`print_template`导`doc`目录下`init_print_template.sql`脚本。 36 | 37 | 2.服务端基于`Spring Boot`的web项目,打包成jar直接部署。(接口文档在`doc`目录下`apidoc.http`文件) 38 | 39 | 3.在项目的`h5-demo`目录中提供了一个demo,介绍了如何在浏览器中绘制一个打印模板。 40 | 41 | 42 | ## License 43 | 44 | The project is licensed under the Apache 2 license. 45 | -------------------------------------------------------------------------------- /doc/apidoc.http: -------------------------------------------------------------------------------- 1 | ### 1.查询-票据类型 2 | GET 127.0.0.1:8080/printerTicket/types 3 | 4 | ### 2.查询店铺-模板列表(含默认模板) 5 | GET 127.0.0.1:8080/printerTicket/list?shopId=1&documentType=1 6 | 7 | ### 3.票据样式-获取系统组件 8 | GET 127.0.0.1:8080/printerTicket/systemComponents?templateId=1 9 | 10 | ### 4.票据样式-获取预览组件 11 | GET 127.0.0.1:81/printerTicket/previewComponents?templateId=1 12 | 13 | ### 5.店铺-新增模板 14 | POST 127.0.0.1:8080/printerTicket/save 15 | Content-Type: application/json 16 | 17 | { 18 | "documentType": 1, 19 | "modules": "...", 20 | "name": "模板二", 21 | "operatorId": 0, 22 | "shopId": "1", 23 | "url": "" 24 | } 25 | 26 | ### 6.店铺-更新模板 27 | POST 127.0.0.1:8080/printerTicket/update 28 | Content-Type: application/json 29 | 30 | { 31 | "templateId": 1, 32 | "modules": "", 33 | "name": "模板二", 34 | "operatorId": 0, 35 | "shopId": "1", 36 | "url": "" 37 | } 38 | 39 | ### 7.店铺-删除模板 40 | DELETE 127.0.0.1:81/printerTicket?id=1 41 | 42 | ### 8.店铺-启用模板 43 | PUT 127.0.0.1:81/printerTicket/enable 44 | 45 | ### 9.打印机列表 46 | GET 127.0.0.1:8080/printerDevice/list?shopId=1&page=1&rows=1 47 | 48 | ### 10.新增-打印机 49 | POST 127.0.0.1:8080/printerDevice/save 50 | Content-Type: application/json 51 | 52 | { 53 | "deviceName": "后厨打印机", 54 | "printerDeviceType": 2, 55 | "address": "192.168.1.13", 56 | "shopId": 1, 57 | "operatorId": 0 58 | } 59 | 60 | ### 11.更新-打印机 61 | POST 127.0.0.1:8080/printerDevice/edit 62 | Content-Type: application/json 63 | 64 | { 65 | "id": 2, 66 | "deviceName": "后厨打印机", 67 | "printerDeviceType": 2, 68 | "address": "192.168.1.13", 69 | "shopId": 1, 70 | "operatorId": 0 71 | } 72 | 73 | ### 12.删除-打印机 74 | DELETE 127.0.0.1:8080/printerDevice?id=1 75 | 76 | ### 13.出票口-列表 77 | GET 127.0.0.1:8080/printerKitchen/list?shopId=1&page=1&rows=1 78 | 79 | ### 14.新增-出票口 80 | POST 127.0.0.1:8080/printerKitchen/save 81 | Content-Type: application/json 82 | 83 | { 84 | "name": "出票口规则一", 85 | "printerDeviceId": 1, 86 | "shopId": 1, 87 | "operatorId": 1, 88 | "documentTypeRules": [ 89 | { 90 | "documentTypeId": 1, 91 | "number": 1, 92 | "printerType": 1 93 | } 94 | ], 95 | "table": 1, 96 | "goods": 1, 97 | "tableRules": [ 98 | { 99 | "tableId": 1 100 | } 101 | ], 102 | "goodsRules": [ 103 | { 104 | "goodsId": 1, 105 | "stockId": 0 106 | } 107 | ] 108 | } 109 | 110 | ### 15.更新-出票口 111 | PUT 127.0.0.1:8080/printerKitchen/edit 112 | Content-Type: application/json 113 | 114 | { 115 | "id": 1, 116 | "name": "出票口规则一", 117 | "printerDeviceId": 1, 118 | "shopId": 1, 119 | "operatorId": 1, 120 | "documentTypeRules": [ 121 | { 122 | "documentTypeId": 1, 123 | "number": 1, 124 | "printerType": 1 125 | } 126 | ], 127 | "table": 1, 128 | "goods": 1, 129 | "tableRules": [ 130 | { 131 | "tableId": 1 132 | } 133 | ], 134 | "goodsRules": [ 135 | { 136 | "goodsId": 2, 137 | "stockId": 0 138 | } 139 | ] 140 | } 141 | 142 | ### 16.查询-出票口 143 | GET 127.0.0.1:8080/printerKitchen?id=1 144 | 145 | ### 17.删除-出票口 146 | DELETE 127.0.0.1:8080/printerKitchen?id=2 147 | -------------------------------------------------------------------------------- /doc/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smart-rabbit-china/printtemplate/a5ca32264f601cc7dc80a673cbb9a9d1231c5671/doc/demo.png -------------------------------------------------------------------------------- /doc/mock-data/request/content.json: -------------------------------------------------------------------------------- 1 | { 2 | "content": { 3 | "rows": [ 4 | { 5 | "cells": [ 6 | { 7 | "percent": 100, 8 | "style": { 9 | "align": "center", 10 | "fontSize": 4 11 | }, 12 | "text": "#{shopName}" 13 | } 14 | ], 15 | "type": "text" 16 | }, 17 | { 18 | "cells": [ 19 | { 20 | "percent": 100, 21 | "style": { 22 | "align": "center", 23 | "fontSize": 4 24 | }, 25 | "text": "#{ticketType}" 26 | } 27 | ], 28 | "type": "text" 29 | }, 30 | { 31 | "text": "-", 32 | "type": "line" 33 | }, 34 | { 35 | "cells": [ 36 | { 37 | "percent": 70, 38 | "style": { 39 | "align": "left", 40 | "fontSize": 1 41 | }, 42 | "text": "桌台号:#{tableNum}" 43 | }, 44 | { 45 | "percent": 30, 46 | "style": { 47 | "align": "right", 48 | "fontSize": 1 49 | }, 50 | "text": "流水号:#{serialNum}" 51 | } 52 | ], 53 | "type": "text" 54 | }, 55 | { 56 | "cells": [ 57 | { 58 | "percent": 80, 59 | "style": { 60 | "align": "left", 61 | "fontSize": 1 62 | }, 63 | "text": "订单号:#{orderNum}" 64 | }, 65 | { 66 | "percent": 20, 67 | "style": { 68 | "align": "right", 69 | "fontSize": 1 70 | }, 71 | "text": "人数:#{peopleNum}" 72 | } 73 | ], 74 | "type": "text" 75 | }, 76 | { 77 | "cells": [ 78 | { 79 | "percent": 100, 80 | "style": { 81 | "align": "left", 82 | "fontSize": 1 83 | }, 84 | "text": "会员:#{memberNum}" 85 | } 86 | ], 87 | "type": "text" 88 | }, 89 | { 90 | "cells": [ 91 | { 92 | "percent": 100, 93 | "style": { 94 | "align": "left", 95 | "fontSize": 1 96 | }, 97 | "text": "#{mealPeopleDetail}" 98 | } 99 | ], 100 | "type": "text" 101 | }, 102 | { 103 | "text": "-", 104 | "type": "line" 105 | }, 106 | { 107 | "cells": [ 108 | { 109 | "percent": 40, 110 | "style": { 111 | "align": "left", 112 | "fontSize": 1 113 | }, 114 | "text": "商品", 115 | "visible": "#{goodSourceSize}!=0" 116 | }, 117 | { 118 | "percent": 20, 119 | "style": { 120 | "align": "right", 121 | "fontSize": 1 122 | }, 123 | "text": "单价", 124 | "visible": "#{goodSourceSize}!=0" 125 | }, 126 | { 127 | "percent": 20, 128 | "style": { 129 | "align": "right", 130 | "fontSize": 1 131 | }, 132 | "text": "数量", 133 | "visible": "#{goodSourceSize}!=0" 134 | }, 135 | { 136 | "percent": 20, 137 | "style": { 138 | "align": "right", 139 | "fontSize": 1 140 | }, 141 | "text": "价格", 142 | "visible": "#{goodSourceSize}!=0" 143 | } 144 | ], 145 | "type": "text" 146 | }, 147 | { 148 | "childRows": [ 149 | { 150 | "style": { 151 | "align": "center", 152 | "fontSize": 1 153 | }, 154 | "text": "-", 155 | "type": "line", 156 | "value": "#{goodMiddleCategoryName}" 157 | }, 158 | { 159 | "childRows": [ 160 | { 161 | "cells": [ 162 | { 163 | "percent": 40, 164 | "style": { 165 | "align": "left", 166 | "fontSize": 1 167 | }, 168 | "text": "#{good}" 169 | }, 170 | { 171 | "percent": 20, 172 | "style": { 173 | "align": "right", 174 | "fontSize": 1 175 | }, 176 | "text": "#{price}" 177 | }, 178 | { 179 | "percent": 20, 180 | "style": { 181 | "align": "right", 182 | "fontSize": 1 183 | }, 184 | "text": "#{number}" 185 | }, 186 | { 187 | "percent": 20, 188 | "style": { 189 | "align": "right", 190 | "fontSize": 1 191 | }, 192 | "text": "#{amount}" 193 | } 194 | ], 195 | "type": "text" 196 | }, 197 | { 198 | "cells": [ 199 | { 200 | "percent": 80, 201 | "style": { 202 | "align": "left", 203 | "fontSize": 1 204 | }, 205 | "text": "#{practice}" 206 | }, 207 | { 208 | "percent": 20, 209 | "style": { 210 | "align": "right", 211 | "fontSize": 1 212 | }, 213 | "text": "#{practicePrice}" 214 | } 215 | ], 216 | "type": "text" 217 | }, 218 | { 219 | "cells": [ 220 | { 221 | "percent": 80, 222 | "style": { 223 | "align": "left", 224 | "fontSize": 1 225 | }, 226 | "text": "#{burdening}" 227 | }, 228 | { 229 | "percent": 20, 230 | "style": { 231 | "align": "right", 232 | "fontSize": 1 233 | }, 234 | "text": "#{burdeningPrice}" 235 | } 236 | ], 237 | "type": "text" 238 | }, 239 | { 240 | "cells": [ 241 | { 242 | "percent": 100, 243 | "style": { 244 | "align": "left", 245 | "fontSize": 1 246 | }, 247 | "text": "#{memo}" 248 | } 249 | ], 250 | "type": "text" 251 | }, 252 | { 253 | "childRows": [ 254 | { 255 | "style": { 256 | "align": "center", 257 | "fontSize": 1 258 | }, 259 | "text": "-", 260 | "type": "line", 261 | "value": "#{setMealGroupCategoryNew}" 262 | }, 263 | { 264 | "childRows": [ 265 | { 266 | "cells": [ 267 | { 268 | "percent": 40, 269 | "style": { 270 | "align": "left", 271 | "fontSize": 1 272 | }, 273 | "text": "#{setMealGroupCategoryGood}" 274 | }, 275 | { 276 | "percent": 20, 277 | "style": { 278 | "align": "right", 279 | "fontSize": 1 280 | }, 281 | "text": "#{setMealGroupCategoryPrice}" 282 | }, 283 | { 284 | "percent": 20, 285 | "style": { 286 | "align": "right", 287 | "fontSize": 1 288 | }, 289 | "text": "#{setMealGroupCategoryNumber}" 290 | }, 291 | { 292 | "percent": 20, 293 | "style": { 294 | "align": "right", 295 | "fontSize": 1 296 | }, 297 | "text": "#{setMealGroupCategoryAmount}" 298 | } 299 | ], 300 | "type": "text" 301 | }, 302 | { 303 | "cells": [ 304 | { 305 | "percent": 80, 306 | "style": { 307 | "align": "left", 308 | "fontSize": 1 309 | }, 310 | "text": "#{setMealGroupCategoryPractice}" 311 | }, 312 | { 313 | "percent": 20, 314 | "style": { 315 | "align": "right", 316 | "fontSize": 1 317 | }, 318 | "text": "#{setMealGroupCategoryPracticePrice}" 319 | } 320 | ], 321 | "type": "text" 322 | }, 323 | { 324 | "cells": [ 325 | { 326 | "percent": 80, 327 | "style": { 328 | "align": "left", 329 | "fontSize": 1 330 | }, 331 | "text": "#{setMealGroupCategoryBurdening}" 332 | }, 333 | { 334 | "percent": 20, 335 | "style": { 336 | "align": "right", 337 | "fontSize": 1 338 | }, 339 | "text": "#{setMealGroupCategoryBurdeningPrice}" 340 | } 341 | ], 342 | "type": "text" 343 | }, 344 | { 345 | "cells": [ 346 | { 347 | "percent": 100, 348 | "style": { 349 | "align": "left", 350 | "fontSize": 1 351 | }, 352 | "text": "#{setMealGroupCategoryMemo}" 353 | } 354 | ], 355 | "type": "text" 356 | } 357 | ], 358 | "source": "#{setMealGroupCategorySource}", 359 | "type": "list" 360 | } 361 | ], 362 | "source": "#{setMealGroupSource}", 363 | "type": "list" 364 | } 365 | ], 366 | "source": "#{goodMiddleCategorySource}", 367 | "type": "list" 368 | } 369 | ], 370 | "source": "#{goodSource}", 371 | "type": "list" 372 | }, 373 | { 374 | "text": "-", 375 | "type": "line" 376 | }, 377 | { 378 | "cells": [ 379 | { 380 | "percent": 60, 381 | "style": { 382 | "align": "left", 383 | "fontSize": 1 384 | }, 385 | "text": "合计" 386 | }, 387 | { 388 | "percent": 20, 389 | "style": { 390 | "align": "right", 391 | "fontSize": 1 392 | }, 393 | "text": "#{goodNumber}" 394 | }, 395 | { 396 | "percent": 20, 397 | "style": { 398 | "align": "right", 399 | "fontSize": 1 400 | }, 401 | "text": "#{goodPrice}" 402 | } 403 | ], 404 | "type": "text" 405 | }, 406 | { 407 | "text": "-", 408 | "type": "line" 409 | }, 410 | { 411 | "cells": [ 412 | { 413 | "percent": 100, 414 | "style": { 415 | "align": "left", 416 | "fontSize": 1 417 | }, 418 | "text": "整单备注:#{orderMemo}" 419 | } 420 | ], 421 | "type": "text" 422 | }, 423 | { 424 | "text": "-", 425 | "type": "line" 426 | }, 427 | { 428 | "cells": [ 429 | { 430 | "percent": 50, 431 | "style": { 432 | "align": "left", 433 | "fontSize": 1 434 | }, 435 | "text": "服务员:#{waiter}" 436 | }, 437 | { 438 | "percent": 50, 439 | "style": { 440 | "align": "right", 441 | "fontSize": 1 442 | }, 443 | "text": "操作员:#{cashier}" 444 | } 445 | ], 446 | "type": "text" 447 | }, 448 | { 449 | "cells": [ 450 | { 451 | "percent": 50, 452 | "style": { 453 | "align": "left", 454 | "fontSize": 1 455 | }, 456 | "text": "开单:#{openBillingTime}" 457 | }, 458 | { 459 | "percent": 50, 460 | "style": { 461 | "align": "right", 462 | "fontSize": 1 463 | }, 464 | "text": "打印:#{printTime}" 465 | } 466 | ], 467 | "type": "text" 468 | }, 469 | { 470 | "cells": [ 471 | { 472 | "percent": 100, 473 | "style": { 474 | "align": "center", 475 | "fontSize": 1 476 | }, 477 | "text": "#{shopAddress}" 478 | } 479 | ], 480 | "type": "text" 481 | }, 482 | { 483 | "cells": [ 484 | { 485 | "percent": 100, 486 | "style": { 487 | "align": "center", 488 | "fontSize": 1 489 | }, 490 | "text": "#{shopPhone}" 491 | } 492 | ], 493 | "type": "text" 494 | }, 495 | { 496 | "cells": [ 497 | { 498 | "percent": 100, 499 | "style": { 500 | "align": "center", 501 | "fontSize": 1 502 | }, 503 | "text": "欢迎下次光临" 504 | } 505 | ], 506 | "type": "text" 507 | } 508 | ] 509 | } 510 | } -------------------------------------------------------------------------------- /doc/mock-data/request/queryType.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "结账单", 4 | "id": 1 5 | }, 6 | { 7 | "name": "客看单", 8 | "id": 2 9 | }, 10 | { 11 | "name": "预结单", 12 | "id": 3 13 | }, 14 | { 15 | "name": "消费清单", 16 | "id": 4 17 | }, 18 | { 19 | "name": "厨总单", 20 | "id": 5 21 | }, 22 | { 23 | "name": "堂口单", 24 | "id": 6 25 | } 26 | ] -------------------------------------------------------------------------------- /doc/preview/厨总单.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smart-rabbit-china/printtemplate/a5ca32264f601cc7dc80a673cbb9a9d1231c5671/doc/preview/厨总单.png -------------------------------------------------------------------------------- /doc/preview/堂口单.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smart-rabbit-china/printtemplate/a5ca32264f601cc7dc80a673cbb9a9d1231c5671/doc/preview/堂口单.png -------------------------------------------------------------------------------- /doc/preview/客看单.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smart-rabbit-china/printtemplate/a5ca32264f601cc7dc80a673cbb9a9d1231c5671/doc/preview/客看单.png -------------------------------------------------------------------------------- /doc/preview/消费清单.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smart-rabbit-china/printtemplate/a5ca32264f601cc7dc80a673cbb9a9d1231c5671/doc/preview/消费清单.png -------------------------------------------------------------------------------- /doc/preview/结账单.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smart-rabbit-china/printtemplate/a5ca32264f601cc7dc80a673cbb9a9d1231c5671/doc/preview/结账单.png -------------------------------------------------------------------------------- /doc/preview/预结单.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smart-rabbit-china/printtemplate/a5ca32264f601cc7dc80a673cbb9a9d1231c5671/doc/preview/预结单.png -------------------------------------------------------------------------------- /doc/table.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `print_template` CHARACTER SET = utf8mb4; 2 | 3 | -- 打印机表 4 | CREATE TABLE IF NOT EXISTS `printer_device` ( 5 | `id` int(11) UNSIGNED AUTO_INCREMENT, 6 | `device_name` varchar(30) NOT NULL DEFAULT '' COMMENT '名称', 7 | `printer_device_type` tinyint NOT NULL DEFAULT 0 COMMENT '打印机类型:1-服务器 2-网络打印机', 8 | `address` varchar(20) NOT NULL DEFAULT '' COMMENT 'ip地址', 9 | `is_delete` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否状态:0-未删除 1-删除', 10 | `shop_id` int(11) NOT NULL DEFAULT 0 COMMENT '店铺id', 11 | `creator_id` int(11) DEFAULT 0 COMMENT '创建人', 12 | `creator_name` varchar(30) DEFAULT '' COMMENT '创建人姓名', 13 | `updator_id` int(11) DEFAULT 0 COMMENT '修改人', 14 | `updator_name` varchar(30) DEFAULT '' COMMENT '修改人姓名', 15 | `create_time` datetime DEFAULT NULL, 16 | `update_time` datetime DEFAULT NULL, 17 | PRIMARY KEY (`id`), 18 | KEY `idx_printer_device_shop_id`(`shop_id`) 19 | ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT '打印机表'; 20 | 21 | -- 出票口表 22 | CREATE TABLE IF NOT EXISTS `printer_kitchen` ( 23 | `id` int(11) UNSIGNED AUTO_INCREMENT, 24 | `name` varchar(30) NOT NULL DEFAULT '' COMMENT '出票口名称', 25 | `printer_device_id` int NOT NULL DEFAULT 0 COMMENT '打印机id', 26 | `is_table` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否配置桌台区域:0-未配置 1-配置', 27 | `is_goods` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否配置打印菜品:0-未配置 1-配置', 28 | `is_delete` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否删除:0-未删除 1-删除', 29 | `shop_id` int(11) NOT NULL DEFAULT 0 COMMENT '店铺id', 30 | `creator_id` int DEFAULT 0 COMMENT '创建人', 31 | `creator_name` varchar(30) DEFAULT '' COMMENT '创建人姓名', 32 | `updator_id` int DEFAULT 0 COMMENT '修改人', 33 | `updator_name` varchar(30) DEFAULT '' COMMENT '修改人姓名', 34 | `create_time` datetime DEFAULT NULL, 35 | `update_time` datetime DEFAULT NULL, 36 | PRIMARY KEY(`id`), 37 | KEY `idx_printer_kitchen_shop_id`(`shop_id`) 38 | ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT '出票口表'; 39 | 40 | -- 出票口票据类型表 41 | CREATE TABLE IF NOT EXISTS `printer_kitchen_document_type_rules` ( 42 | `id` int(11) UNSIGNED AUTO_INCREMENT, 43 | `printer_kitchen_id` int(11) NOT NULL DEFAULT 0 COMMENT '出票口id', 44 | `document_type_id` int NOT NULL DEFAULT 0 COMMENT '票据类型', 45 | `number` tinyint NOT NULL DEFAULT 1 COMMENT '打印份数', 46 | `printer_type` tinyint UNSIGNED NOT NULL DEFAULT 1 COMMENT '打印方式:1-一纸多菜 2-一纸一菜 3-各打一张', 47 | `is_delete` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否删除:0-未删除 1-删除', 48 | `create_time` datetime DEFAULT NULL, 49 | `update_time` datetime DEFAULT NULL, 50 | PRIMARY KEY(`id`), 51 | KEY `idx_kitchen_document_type_printer_kitchen_id`(`printer_kitchen_id`), 52 | KEY `idx_kitchen_document_type_document_type_id`(`document_type_id`) 53 | ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT '出票口票据类型表'; 54 | 55 | -- 出票口配置桌台区域表 56 | CREATE TABLE IF NOT EXISTS `printer_kitchen_table_rules` ( 57 | `id` int(11) UNSIGNED AUTO_INCREMENT, 58 | `printer_kitchen_id` int(11) NOT NULL DEFAULT 0 COMMENT '出票口id', 59 | `table_id` int(11) NOT NULL DEFAULT 0 COMMENT '桌台号', 60 | `is_delete` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否删除:0-未删除 1-删除', 61 | `create_time` datetime DEFAULT NULL, 62 | `update_time` datetime DEFAULT NULL, 63 | PRIMARY KEY(`id`), 64 | KEY `idx_kitchen_table_rules_printer_kitchen_id`(`printer_kitchen_id`), 65 | KEY `idx_kitchen_table_rules_table_id`(`table_id`) 66 | ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT '出票口配置桌台区域表'; 67 | 68 | -- 出票口配置打印菜品表 69 | CREATE TABLE IF NOT EXISTS `printer_kitchen_goods_rules` ( 70 | `id` int(11) UNSIGNED AUTO_INCREMENT, 71 | `printer_kitchen_id` int(11) NOT NULL DEFAULT 0 COMMENT '出票口id', 72 | `goods_id` int(11) NOT NULL DEFAULT 0 COMMENT '商品id', 73 | `stock_id` int(11) NOT NULL DEFAULT 0 COMMENT '规格id', 74 | `is_delete` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否删除:0-未删除 1-删除', 75 | `create_time` datetime DEFAULT NULL, 76 | `update_time` datetime DEFAULT NULL, 77 | PRIMARY KEY(`id`), 78 | KEY `idx_kitchen_goods_rules_printer_kitchen_id`(`printer_kitchen_id`), 79 | KEY `idx_kitchen_goods_rules_goods_id`(`goods_id`), 80 | KEY `idx_kitchen_goods_rules_stock_id`(`stock_id`) 81 | ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT '出票口配置打印菜品表'; 82 | 83 | -- 打印模板类型表 84 | CREATE TABLE IF NOT EXISTS `printer_document_type` ( 85 | `id` INT UNSIGNED AUTO_INCREMENT, 86 | `name` VARCHAR(10) NOT NULL DEFAULT '' COMMENT '类型名称', 87 | `status` TINYINT NOT NULL DEFAULT 0 COMMENT '状态:0-禁用 1-启用', 88 | `create_time` datetime DEFAULT NULL COMMENT '添加时间', 89 | `update_time` datetime DEFAULT NULL COMMENT '更新时间', 90 | PRIMARY KEY(`id`), 91 | KEY `idx_name`(`name`) 92 | ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT '打印模板类型表'; 93 | 94 | -- 打印模板模块表 95 | CREATE TABLE IF NOT EXISTS `printer_template_module` ( 96 | `id` INT UNSIGNED AUTO_INCREMENT, 97 | `module_name` VARCHAR(10) NOT NULL COMMENT '模块名称', 98 | `module_describe` VARCHAR(30) NOT NULL COMMENT '模块描述', 99 | `document_type` INT NOT NULL COMMENT '模板类型', 100 | `sort` INT DEFAULT 0 COMMENT '排序', 101 | `create_time` datetime DEFAULT NULL COMMENT '添加时间', 102 | `update_time` datetime DEFAULT NULL COMMENT '更新时间', 103 | PRIMARY KEY(`id`) 104 | ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT '打印模板模块表'; 105 | 106 | -- 打印模板系统组件表 107 | CREATE TABLE IF NOT EXISTS `printer_system_component`( 108 | `id` INTEGER UNSIGNED AUTO_INCREMENT, 109 | `module_id` INT NOT NULL DEFAULT 0 COMMENT '模块id', 110 | `parent_id` INT NOT NULL DEFAULT 0 COMMENT '父组件id', 111 | `ref_id` INT NOT NULL DEFAULT 0 COMMENT '引用id', 112 | `label` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '组件名称', 113 | `value` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '组件值', 114 | `value_style` VARCHAR(150) NOT NULL DEFAULT '' COMMENT '组件值排版属性', 115 | `placeholder` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '占位符,例如:#{orderSource}', 116 | `type` VARCHAR(10) NOT NULL DEFAULT '' COMMENT '组件类型:hidden-隐藏(refId) text-文本 grid-网格 title-表格标题 category-分类 head-表格头', 117 | `row` INT NOT NULL DEFAULT 0 COMMENT '行号', 118 | `column` INT NOT NULL DEFAULT 0 COMMENT '列号', 119 | `width` INT NOT NULL DEFAULT 0 COMMENT '宽度,百分比', 120 | `sort` INT NOT NULL DEFAULT 0 COMMENT '序号', 121 | `is_enable` tinyint NOT NULL DEFAULT 1 COMMENT '启用状态:0 未启用 1已启用', 122 | `create_time` datetime DEFAULT NULL COMMENT '添加时间', 123 | `update_time` datetime DEFAULT NULL COMMENT '更新时间', 124 | PRIMARY KEY(`id`), 125 | UNIQUE KEY `idx_temponent_component_id`(`id`), 126 | KEY `idx_template_component_module_id`(`module_id`), 127 | KEY `idx_template_component_parent_id`(`parent_id`) 128 | ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT '打印模板系统组件表'; 129 | 130 | -- 应用-打印模板表 131 | CREATE TABLE IF NOT EXISTS `printer_template_document` ( 132 | `id` INT UNSIGNED AUTO_INCREMENT, 133 | `name` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '模板名称', 134 | `document_type` INT NOT NULL DEFAULT 0 COMMENT '文档类型', 135 | `url` VARCHAR(100) DEFAULT '' COMMENT '文档预览图', 136 | `status` INT NOT NULL DEFAULT 0 COMMENT '模板状态:0-删除 1-启用 2-禁用', 137 | `shop_id` INT NOT NULL DEFAULT 0 COMMENT '店铺id', 138 | `creator_id` INT NOT NULL DEFAULT 0 COMMENT '添加者id', 139 | `creator_name` VARCHAR(20) DEFAULT '' COMMENT '添加者名称', 140 | `create_time` datetime DEFAULT NULL, 141 | `update_time` datetime DEFAULT NULL, 142 | PRIMARY KEY(`id`), 143 | KEY `idx_template_document_shop_id`(`shop_id`) 144 | ) ENGINE = InnoDB AUTO_INCREMENT = 0 DEFAULT CHARSET = utf8mb4 COMMENT '应用-打印模板表'; 145 | 146 | -- 自定义组件表 147 | CREATE TABLE `printer_custom_component` ( 148 | `id` int(11) unsigned NOT NULL AUTO_INCREMENT, 149 | `document_template_id` int(11) NOT NULL DEFAULT '0' COMMENT '模板id', 150 | `system_component_id` int(11) DEFAULT '0' COMMENT '系统组件id', 151 | `value_style` varchar(150) NOT NULL DEFAULT '' COMMENT '自定义组件属性', 152 | `is_delete` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否删除:0-未删除 1-删除', 153 | PRIMARY KEY (`id`), 154 | KEY `idx_systemComponentId` (`system_component_id`) 155 | ) ENGINE=InnoDB AUTO_INCREMENT=827 DEFAULT CHARSET=utf8mb4 COMMENT='自定义组件表'; -------------------------------------------------------------------------------- /h5-demo/css/main.css: -------------------------------------------------------------------------------- 1 | .component-box { 2 | border: 4px dotted dodgerblue; 3 | padding: 20px 30px; 4 | } 5 | .component-box .panel-module { 6 | margin: 10px 20px; 7 | border: 2px solid gray; 8 | } 9 | .component-box .panel-module .panel-module-title { 10 | padding: 0 10px; 11 | border-bottom: 2px solid gray; 12 | } 13 | .component-box .panel-module .panel-module-body { 14 | padding: 2%; 15 | /*启用状态*/ 16 | } 17 | .component-box .panel-module .panel-module-body .panel-component { 18 | margin: 2%; 19 | width: 28%; 20 | background-color: gray; 21 | display: inline-block; 22 | border: 1px solid white; 23 | height: 45px; 24 | cursor: pointer; 25 | } 26 | .component-box .panel-module .panel-module-body .panel-component table { 27 | vertical-align: middle; 28 | height: 100%; 29 | width: 100%; 30 | } 31 | .component-box .panel-module .panel-module-body .panel-component table tbody { 32 | display: table-row-group; 33 | vertical-align: middle; 34 | border-color: inherit; 35 | } 36 | .component-box .panel-module .panel-module-body .panel-component table tbody tr { 37 | display: table-row; 38 | vertical-align: inherit; 39 | border-color: inherit; 40 | } 41 | .component-box .panel-module .panel-module-body .panel-component table tbody tr td { 42 | color: white; 43 | font-size: 14px; 44 | text-align: center; 45 | display: table-cell; 46 | vertical-align: inherit; 47 | } 48 | .component-box .panel-module .panel-module-body .panel-component:hover { 49 | border: 1px solid gray; 50 | } 51 | .component-box .panel-module .panel-module-body .switch-on { 52 | background-color: #2D93CA; 53 | color: #000; 54 | } 55 | .template-container { 56 | width: 70%; 57 | border: 4px dotted dodgerblue; 58 | padding: 30px 30px; 59 | background-color: #e4e4e4; 60 | } 61 | .template-container .template-module-list { 62 | background-color: white; 63 | margin: 0 20px; 64 | padding: 20px 15px; 65 | } 66 | .template-container .template-module-list .template-module { 67 | /*模块分隔线*/ 68 | } 69 | .template-container .template-module-list .template-module .template-row { 70 | display: flex; 71 | justify-content: space-between; 72 | /*获取焦点*/ 73 | /*店铺logo*/ 74 | } 75 | .template-container .template-module-list .template-module .template-row .template-component { 76 | width: 100%; 77 | box-sizing: border-box; 78 | border: 1px solid white; 79 | } 80 | .template-container .template-module-list .template-module .template-row .template-component:hover { 81 | border: 1px solid orange; 82 | background-color: rgba(247, 248, 74, 0.67); 83 | cursor: pointer; 84 | } 85 | .template-container .template-module-list .template-module .template-row .template-component-focus { 86 | border: 1px solid orange; 87 | background-color: rgba(247, 248, 74, 0.67); 88 | } 89 | .template-container .template-module-list .template-module .template-row .template-component-individuation { 90 | width: 100%; 91 | } 92 | .template-container .template-module-list .template-module .template-row .template-component-individuation .template-component-table .template-component-thead .template-component-tr, 93 | .template-container .template-module-list .template-module .template-row .template-component-individuation .template-component-table .template-component-tbody .template-component-tr { 94 | display: flex; 95 | justify-content: space-between; 96 | } 97 | .template-container .template-module-list .template-module .template-row .shop-logo { 98 | width: 100%; 99 | color: #3194ff; 100 | padding: 10px; 101 | margin: 10px 0; 102 | text-align: center; 103 | box-sizing: border-box; 104 | border: 1px solid black; 105 | background-color: #e6e6e6; 106 | } 107 | .template-container .template-module-list .template-module .the-divider { 108 | margin: 5px 0; 109 | } 110 | .template-property-panel { 111 | position: fixed; 112 | bottom: 10%; 113 | right: 18%; 114 | width: 14%; 115 | } 116 | -------------------------------------------------------------------------------- /h5-demo/css/main.less: -------------------------------------------------------------------------------- 1 | .component-box { 2 | border: 4px dotted dodgerblue; 3 | padding: 20px 30px; 4 | .panel-module { 5 | margin: 10px 20px; 6 | border: 2px solid gray; 7 | .panel-module-title { 8 | padding: 0 10px; 9 | border-bottom: 2px solid gray; 10 | } 11 | .panel-module-body { 12 | padding: 2%; 13 | .panel-component { 14 | margin: 2%; 15 | width: 28%; 16 | background-color: gray; 17 | display: inline-block; 18 | border: 1px solid white; 19 | height: 45px; 20 | cursor: pointer; 21 | table { 22 | vertical-align: middle; 23 | height: 100%; 24 | width: 100%; 25 | tbody { 26 | display: table-row-group; 27 | vertical-align: middle; 28 | border-color: inherit; 29 | tr { 30 | display: table-row; 31 | vertical-align: inherit; 32 | border-color: inherit; 33 | td { 34 | color: white; 35 | font-size: 14px; 36 | text-align: center; 37 | display: table-cell; 38 | vertical-align: inherit; 39 | } 40 | } 41 | } 42 | } 43 | } 44 | .panel-component:hover { 45 | border: 1px solid gray; 46 | } 47 | /*启用状态*/ 48 | .switch-on { 49 | background-color: #2D93CA; 50 | color: #000; 51 | } 52 | } 53 | } 54 | } 55 | 56 | .template-container { 57 | width: 70%; 58 | border: 4px dotted dodgerblue; 59 | padding: 30px 30px; 60 | background-color: #e4e4e4; 61 | .template-module-list { 62 | background-color: white; 63 | margin: 0 20px; 64 | padding: 20px 15px; 65 | .template-module { 66 | .template-row { 67 | display: flex; 68 | justify-content: space-between; 69 | .template-component { 70 | width: 100%; 71 | box-sizing:border-box; 72 | border: 1px solid white; 73 | } 74 | .template-component:hover { 75 | border: 1px solid orange; 76 | background-color: rgba(247, 248, 74, 0.67); 77 | cursor: pointer; 78 | } 79 | /*获取焦点*/ 80 | .template-component-focus { 81 | border: 1px solid orange; 82 | background-color: rgba(247, 248, 74, 0.67); 83 | } 84 | .template-component-individuation { 85 | width: 100%; 86 | .template-component-table { 87 | .template-component-thead, 88 | .template-component-tbody { 89 | .template-component-tr { 90 | display: flex; 91 | justify-content: space-between; 92 | .table-component-td { 93 | 94 | } 95 | } 96 | } 97 | } 98 | } 99 | /*店铺logo*/ 100 | .shop-logo { 101 | width: 100%; 102 | color: #3194ff; 103 | padding: 10px; 104 | margin: 10px 0; 105 | text-align: center; 106 | box-sizing:border-box; 107 | border: 1px solid black; 108 | background-color: #e6e6e6; 109 | } 110 | } 111 | /*模块分隔线*/ 112 | .the-divider { 113 | margin: 5px 0; 114 | } 115 | } 116 | } 117 | } 118 | 119 | .template-property-panel { 120 | position: fixed; 121 | bottom: 10%; 122 | right: 18%; 123 | width: 14%; 124 | } 125 | -------------------------------------------------------------------------------- /h5-demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 打印模块 12 | 13 | 14 |
15 |
16 |
17 |

打印机-模板样式

18 |
19 |
20 |
21 |
22 |
23 |
24 | 25 | 26 |
27 | 28 | 29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |

{{panelModule.moduleName}} {{panelModule.moduleDescribe}}

38 |
39 |
40 |
43 | 44 | 45 | 46 | 47 | 48 | 49 |
{{panelComponent.label}}
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | 61 |
66 | 67 | 68 | {{templateComponent.value}} 69 | 70 |
74 | 75 | {{templateComponent.tableTitle.value}} 76 |
77 |
78 | 79 |
80 |
81 |
85 | 86 | {{tableHeadColumn.value}} 87 |
88 |
89 |
90 | 91 |
92 |
93 |
94 | 95 | {{templateComponent.category.value}} 96 |
97 |
98 |
99 |
103 | 104 | {{tableTbodyRowColumn.value}} 105 |
106 |
107 |
108 |
109 |
110 |
111 | 112 |
113 |
114 |
115 |
116 |
117 |
118 |
属性
119 |
120 |
121 |
122 | 123 | 129 |
130 |
131 | 132 | 138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 | 147 | 148 | 149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /h5-demo/js/utils.js: -------------------------------------------------------------------------------- 1 | /** 2 | * AngularJS统一请求(Content-Type:application/json) 3 | * @param $http 4 | * @param param 5 | */ 6 | function baseRequestForm ($http, param) { 7 | if (!param.method) { 8 | param.method = "GET"; 9 | } else { 10 | param.data = JSON.stringify(param.data); 11 | } 12 | $http({ 13 | url: param.url, 14 | method: param.method, 15 | data: param.data 16 | }).then( 17 | function (res) { 18 | param.sCallback && param.sCallback(res); 19 | }, 20 | function (res) { 21 | console.log("error: ", res); 22 | } 23 | ); 24 | } 25 | 26 | /** 27 | * 判断对象属性不为空 28 | * object = null false 29 | * object[property] = null false 30 | * object[property] = "" false 31 | * @param object 对象 32 | * @param property 属性 33 | * @return boolean 34 | */ 35 | function isNotEmpty (object, property) { 36 | return object != null && object.hasOwnProperty(property) && object[property] != null && object[property] !== ""; 37 | } 38 | 39 | /** 40 | * 横线连接转换驼峰 41 | * @param value 横线连接 42 | * @return {string} 43 | */ 44 | function lineToHump(value) { 45 | return value.replace(/\-(\w)/g, function(all, letter){ 46 | return letter.toUpperCase(); 47 | }); 48 | } 49 | 50 | /** 51 | * 驼峰转换横线连接 52 | * @param value 驼峰 53 | * @returns {string} 54 | */ 55 | function humpToLine(value) { 56 | return value.replace(/([A-Z])/g,"-$1").toLowerCase(); 57 | } 58 | 59 | /** 60 | * 根据参数名获取地址栏URL里的参数 61 | * @param name 参数名 62 | * @return {string} 63 | */ 64 | function getUrlQueryString(name) { 65 | var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); 66 | var r = window.location.search.substr(1).match(reg); 67 | return r !== null ? unescape(r[2]) : null; 68 | } 69 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | org.springframework.boot 6 | spring-boot-starter-parent 7 | 2.2.5.RELEASE 8 | 9 | 10 | 4.0.0 11 | printtemplate 12 | 1.0.0 13 | print-template ${project.version} 14 | 小票打印机,自定义模板样式 15 | 16 | 17 | 1.1.10 18 | 1.3.2 19 | 5.1.48 20 | 3.3.2 21 | 1.2.61 22 | 28.0-jre 23 | 5.1.8 24 | 1.18.12 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-web 31 | 32 | 33 | com.alibaba 34 | druid-spring-boot-starter 35 | ${druid.version} 36 | 37 | 38 | org.mybatis.spring.boot 39 | mybatis-spring-boot-starter 40 | ${mybatis-spring-boot.version} 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-test 45 | test 46 | 47 | 48 | mysql 49 | mysql-connector-java 50 | ${mysql-connector-java.version} 51 | 52 | 53 | org.apache.commons 54 | commons-lang3 55 | ${commons-lang.version} 56 | 57 | 58 | com.alibaba 59 | fastjson 60 | ${fastjson.version} 61 | 62 | 63 | com.google.guava 64 | guava 65 | ${guava.version} 66 | 67 | 68 | com.github.pagehelper 69 | pagehelper 70 | ${pagehelper.version} 71 | 72 | 73 | org.projectlombok 74 | lombok 75 | ${lombok.version} 76 | 77 | 78 | 79 | 80 | print-template 81 | 82 | 83 | org.springframework.boot 84 | spring-boot-maven-plugin 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/PrintTemplateApplication.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * Created by zfh on 2018/12/10 8 | */ 9 | @SpringBootApplication 10 | public class PrintTemplateApplication{ 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(PrintTemplateApplication.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/constant/SystemComponentTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.constant; 2 | 3 | /** 4 | * 打印模板-系统组件类型枚举 5 | * Created by zfh on 2018/12/27 6 | */ 7 | public enum SystemComponentTypeEnum { 8 | 9 | HIDDEN("hidden", "隐藏-refId"), 10 | TEXT("text", "文本"), 11 | GRID("grid", "网格"), 12 | TITLE("title", "表格标题"), 13 | CATEGORY("category", "分类"), 14 | TABLE_HEAD("head", "表格头"); 15 | 16 | private String name; 17 | 18 | private String desc; 19 | 20 | SystemComponentTypeEnum (String name, String desc) { 21 | this.name = name; 22 | this.desc = desc; 23 | } 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public String getDesc() { 30 | return desc; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/controller/PrinterDeviceController.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.controller; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.zxcs.printtemplate.exception.print.PrinterDeviceException; 5 | import com.zxcs.printtemplate.form.SavePrinterDeviceForm; 6 | import com.zxcs.printtemplate.form.UpdatePrinterDeviceForm; 7 | import com.zxcs.printtemplate.helper.MapHelper; 8 | import com.zxcs.printtemplate.model.PrinterDeviceDO; 9 | import com.zxcs.printtemplate.service.IPrinterDeviceService; 10 | import com.zxcs.printtemplate.vo.PrinterDeviceVO; 11 | import com.zxcs.printtemplate.vo.Response; 12 | import org.springframework.beans.BeanUtils; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.web.bind.annotation.*; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | /** 20 | * 设备-打印机 21 | *

22 | * Created by zfh on 2019/01/09 23 | */ 24 | @RequestMapping("printerDevice") 25 | @RestController 26 | public class PrinterDeviceController { 27 | 28 | @Autowired 29 | private IPrinterDeviceService printerDeviceService; 30 | 31 | /** 32 | * 新增-打印机 33 | * 34 | * @param form {@link SavePrinterDeviceForm} 35 | * @return {@link Response} 36 | */ 37 | @PostMapping("save") 38 | public Response save(@RequestBody SavePrinterDeviceForm form) { 39 | form.validateParam(); 40 | 41 | printerDeviceService.save(form.getPrinterDevice()); 42 | return Response.newInstance(); 43 | } 44 | 45 | /** 46 | * 打印机列表 47 | * 48 | * @return {@link Response} 49 | */ 50 | @GetMapping("list") 51 | public Response queryList(@RequestParam(name = "shopId", defaultValue = "0") Integer shopId, 52 | @RequestParam(name = "page", defaultValue = "1") Integer page, 53 | @RequestParam(name = "rows", defaultValue = "10") Integer rows) { 54 | PageInfo pageInfo = printerDeviceService.listPrinterDeviceByShopId(shopId, page, rows); 55 | List voList = new ArrayList<>(10); 56 | for (PrinterDeviceDO printerDevice : pageInfo.getList()) { 57 | PrinterDeviceVO printerDeviceVO = new PrinterDeviceVO(); 58 | BeanUtils.copyProperties(printerDevice, printerDeviceVO); 59 | voList.add(printerDeviceVO); 60 | } 61 | return Response.newInstance().setData(MapHelper.newInstance().put("total", pageInfo.getTotal()).put("list", voList).map()); 62 | } 63 | 64 | /** 65 | * 查询-打印机 66 | * 67 | * @return {@link Response} 68 | */ 69 | @GetMapping("") 70 | public Response doQuery(@RequestParam(name = "id", defaultValue = "0") Integer id) { 71 | PrinterDeviceDO printerDevice = printerDeviceService.getScShopPrinterDeviceByPrimaryKey(id); 72 | if (printerDevice == null || printerDevice.getDelete().equals(1)) { 73 | throw new PrinterDeviceException(); 74 | } 75 | PrinterDeviceVO printerDeviceVO = new PrinterDeviceVO(); 76 | BeanUtils.copyProperties(printerDevice, printerDeviceVO); 77 | return Response.newInstance().setData(printerDeviceVO); 78 | } 79 | 80 | /** 81 | * 更新-打印机 82 | * 83 | * @param form {@link UpdatePrinterDeviceForm} 84 | * @return {@link Response} 85 | */ 86 | @PutMapping("edit") 87 | public Response doEdit(@RequestBody UpdatePrinterDeviceForm form) { 88 | form.validateParam(); 89 | 90 | PrinterDeviceDO printerDevice = printerDeviceService.getScShopPrinterDeviceByPrimaryKey(form.getId()); 91 | if (printerDevice == null || printerDevice.getDelete().equals(1)) { 92 | throw new PrinterDeviceException(); 93 | } 94 | printerDeviceService.updateByPrimaryKeySelective(form.getScShopPrinterDevice()); 95 | return Response.newInstance(); 96 | } 97 | 98 | /** 99 | * 删除-打印机 100 | * 101 | * @return {@link Response} 102 | */ 103 | @DeleteMapping("") 104 | public Response doDelete(@RequestParam(name = "id", defaultValue = "0") Integer id) { 105 | PrinterDeviceDO printerDevice = printerDeviceService.getScShopPrinterDeviceByPrimaryKey(id); 106 | if (printerDevice == null || printerDevice.getDelete().equals(1)) { 107 | throw new PrinterDeviceException(); 108 | } 109 | PrinterDeviceDO params = new PrinterDeviceDO(); 110 | params.setId(printerDevice.getId()); 111 | printerDevice.setDelete(1); 112 | printerDeviceService.updateByPrimaryKeySelective(printerDevice); 113 | return Response.newInstance(); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/controller/PrinterKitchenController.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.controller; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.zxcs.printtemplate.exception.print.PrinterKitchenException; 5 | import com.zxcs.printtemplate.form.PrinterKitchenForm; 6 | import com.zxcs.printtemplate.helper.MapHelper; 7 | import com.zxcs.printtemplate.model.PrinterKitchenDO; 8 | import com.zxcs.printtemplate.model.PrinterKitchenDocumentTypeRulesDO; 9 | import com.zxcs.printtemplate.model.PrinterKitchenGoodsRulesDO; 10 | import com.zxcs.printtemplate.model.PrinterKitchenTableRulesDO; 11 | import com.zxcs.printtemplate.service.IPrinterKitchenDocumentTypeRulesService; 12 | import com.zxcs.printtemplate.service.IPrinterKitchenGoodsRulesService; 13 | import com.zxcs.printtemplate.service.IPrinterKitchenService; 14 | import com.zxcs.printtemplate.service.IPrinterKitchenTableRulesService; 15 | import com.zxcs.printtemplate.vo.PrinterKitchenIntegrationVO; 16 | import com.zxcs.printtemplate.vo.PrinterKitchenVO; 17 | import com.zxcs.printtemplate.vo.Response; 18 | import org.springframework.beans.BeanUtils; 19 | import org.springframework.beans.factory.annotation.Autowired; 20 | import org.springframework.web.bind.annotation.*; 21 | 22 | import java.util.ArrayList; 23 | import java.util.HashMap; 24 | import java.util.List; 25 | import java.util.Map; 26 | 27 | /** 28 | * 打印机-出票口Rest 29 | * Created by zfh on 2019/01/09 30 | */ 31 | @RequestMapping("printerKitchen") 32 | @RestController 33 | public class PrinterKitchenController { 34 | 35 | @Autowired 36 | private IPrinterKitchenService printerKitchenService; 37 | 38 | @Autowired 39 | private IPrinterKitchenDocumentTypeRulesService printerKitchenDocumentTypeRulesService; 40 | 41 | @Autowired 42 | private IPrinterKitchenTableRulesService printerKitchenTableRulesService; 43 | 44 | @Autowired 45 | private IPrinterKitchenGoodsRulesService printerKitchenGoodsRulesService; 46 | 47 | /** 48 | * 新增-出票口 49 | * @param form {@link PrinterKitchenForm} 50 | * @return {@link Response} 51 | */ 52 | @PostMapping("save") 53 | public Response save (@RequestBody PrinterKitchenForm form) { 54 | form.validateParam(); 55 | 56 | Integer printerKitchenId = 0; 57 | try { 58 | printerKitchenId = printerKitchenService.save(form.getPrinterKitchen()); 59 | printerKitchenDocumentTypeRulesService.saveMultipleRecord(form.getDocumentTypeRulesList(printerKitchenId)); 60 | if (form.getTable() == 1) { 61 | printerKitchenTableRulesService.saveMultipleRecord(form.getTableRulesList(printerKitchenId)); 62 | } 63 | if (form.getGoods() == 1) { 64 | printerKitchenGoodsRulesService.saveMultipleRecord(form.getGoodsRulesList(printerKitchenId)); 65 | } 66 | } catch (Exception e) { 67 | // 回滚 68 | PrinterKitchenDO params = new PrinterKitchenDO(); 69 | params.setId(printerKitchenId); 70 | params.setDelete(1); 71 | printerKitchenService.updateByPrimaryKeySelective(params); 72 | throw new PrinterKitchenException("新增出票口异常!"); 73 | } 74 | return Response.newInstance().setData(MapHelper.newInstance().put("printerKitchenId", printerKitchenId).map()); 75 | } 76 | 77 | /** 78 | * 出票口-列表 79 | * @return {@link Response} 80 | */ 81 | @GetMapping("list") 82 | public Response queryList (@RequestParam(name = "shopId", defaultValue = "0") Integer shopId, 83 | @RequestParam(name = "page", defaultValue = "1") Integer page, 84 | @RequestParam(name = "rows", defaultValue = "10") Integer rows) { 85 | PageInfo pageInfo = printerKitchenService.listPrinterKitchenByShopId(shopId, page, rows); 86 | 87 | List voList = new ArrayList<>(10); 88 | for (PrinterKitchenDO printerKitchen : pageInfo.getList()) { 89 | PrinterKitchenVO printerKitchenVO = new PrinterKitchenVO(); 90 | BeanUtils.copyProperties(printerKitchen, printerKitchenVO); 91 | voList.add(printerKitchenVO); 92 | } 93 | return Response.newInstance().setData(MapHelper.newInstance().put("total", pageInfo.getTotal()).put("list", voList).map()); 94 | } 95 | 96 | /** 97 | * 查询-出票口 98 | * @return {@link Response} 99 | */ 100 | @GetMapping("") 101 | public Response queryInfo (@RequestParam(name = "id", defaultValue = "0") Integer id) { 102 | PrinterKitchenDO printerKitchen = printerKitchenService.getByPrimaryKey(id); 103 | if (printerKitchen == null || printerKitchen.getDelete() == 1) { 104 | throw new PrinterKitchenException(); 105 | } 106 | PrinterKitchenIntegrationVO printerKitchenIntegrationVO = new PrinterKitchenIntegrationVO(); 107 | BeanUtils.copyProperties(printerKitchen, printerKitchenIntegrationVO); 108 | List documentTypeRulesList = printerKitchenDocumentTypeRulesService.listPrinterKitchenDocumentTypeRulesByPrinterKitchenId(id); 109 | List> documentTypeRules = new ArrayList<>(10); 110 | for (PrinterKitchenDocumentTypeRulesDO kitchenDocumentTypeRules : documentTypeRulesList) { 111 | Map documentTypeRulesItem = new HashMap<>(10); 112 | documentTypeRulesItem.put("documentTypeId", kitchenDocumentTypeRules.getDocumentTypeId()); 113 | documentTypeRulesItem.put("number", kitchenDocumentTypeRules.getNumber()); 114 | documentTypeRulesItem.put("printerType", kitchenDocumentTypeRules.getPrinterType()); 115 | documentTypeRules.add(documentTypeRulesItem); 116 | } 117 | List> tableRules = new ArrayList<>(10); 118 | if (printerKitchen.getTable() == 1) { 119 | List kitchenTableRulesList = printerKitchenTableRulesService.listPrinterKitchenTableRulesByPrinterKitchenId(id); 120 | for (PrinterKitchenTableRulesDO kitchenTableRules : kitchenTableRulesList) { 121 | Map tableRulesItem = new HashMap<>(10); 122 | tableRulesItem.put("tableId", kitchenTableRules.getTableId()); 123 | tableRules.add(tableRulesItem); 124 | } 125 | } 126 | List> goodsRules = new ArrayList<>(10); 127 | if (printerKitchen.getGoods() == 1) { 128 | List printerKitchenGoodsRulesList = printerKitchenGoodsRulesService.listPrinterKitchenGoodsRulesByPrinterKitchenId(id); 129 | for (PrinterKitchenGoodsRulesDO kitchenGoodsRules : printerKitchenGoodsRulesList) { 130 | Map goodsRulesItem = new HashMap<>(10); 131 | goodsRulesItem.put("goodsId", kitchenGoodsRules.getGoodsId()); 132 | goodsRulesItem.put("stockId", kitchenGoodsRules.getStockId()); 133 | goodsRules.add(goodsRulesItem); 134 | } 135 | } 136 | printerKitchenIntegrationVO.setDocumentTypeRules(documentTypeRules); 137 | printerKitchenIntegrationVO.setTableRules(tableRules); 138 | printerKitchenIntegrationVO.setGoodsRules(goodsRules); 139 | return Response.newInstance().setData(printerKitchenIntegrationVO); 140 | } 141 | 142 | /** 143 | * 更新-出票口 144 | * @return {@link Response} 145 | */ 146 | @PutMapping("edit") 147 | public Response doEdit (@RequestBody PrinterKitchenForm form) { 148 | form.validateParam(); 149 | 150 | Integer printerKitchenId = form.getId(); 151 | PrinterKitchenDO printerKitchenDO = printerKitchenService.getByPrimaryKey(printerKitchenId); 152 | if (printerKitchenDO == null || printerKitchenDO.getDelete() == 1) { 153 | throw new PrinterKitchenException(); 154 | } 155 | printerKitchenService.updateByPrimaryKeySelective(form.getUpdatePrinterKitchen()); 156 | printerKitchenDocumentTypeRulesService.removeMultipleRecordByPrinterKitchenId(form.getId()); 157 | printerKitchenTableRulesService.removeMultipleRecordByPrinterKitchenId(printerKitchenId); 158 | printerKitchenGoodsRulesService.removeMultipleRecordByPrinterKitchenId(printerKitchenId); 159 | 160 | printerKitchenDocumentTypeRulesService.saveMultipleRecord(form.getDocumentTypeRulesList(printerKitchenId)); 161 | if (form.getTable() == 1) { 162 | printerKitchenTableRulesService.saveMultipleRecord(form.getTableRulesList(printerKitchenId)); 163 | } 164 | if (form.getGoods() == 1) { 165 | printerKitchenGoodsRulesService.saveMultipleRecord(form.getGoodsRulesList(printerKitchenId)); 166 | } 167 | return Response.newInstance(); 168 | } 169 | 170 | /** 171 | * 删除-出票口 172 | * @return {@link Response} 173 | */ 174 | @DeleteMapping("") 175 | public Response doDelete (@RequestParam(name = "id", defaultValue = "0") Integer id) { 176 | PrinterKitchenDO printerKitchen = printerKitchenService.getByPrimaryKey(id); 177 | if (printerKitchen == null || printerKitchen.getDelete().equals(1)) { 178 | throw new PrinterKitchenException(); 179 | } 180 | PrinterKitchenDO params = new PrinterKitchenDO(); 181 | params.setId(printerKitchen.getId()); 182 | params.setDelete(1); 183 | Integer affected = printerKitchenService.updateByPrimaryKeySelective(params); 184 | if (affected > 0) { 185 | printerKitchenDocumentTypeRulesService.removeMultipleRecordByPrinterKitchenId(id); 186 | printerKitchenTableRulesService.removeMultipleRecordByPrinterKitchenId(id); 187 | printerKitchenGoodsRulesService.removeMultipleRecordByPrinterKitchenId(id); 188 | } 189 | return Response.newInstance(); 190 | } 191 | } 192 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/dao/PrinterCustomComponentMapper.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.dao; 2 | 3 | import com.zxcs.printtemplate.model.PrinterCustomComponentDO; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 打印模板-自定义组件Mapper 10 | * Created by zfh on 2019/01/03 11 | */ 12 | @Mapper 13 | public interface PrinterCustomComponentMapper { 14 | 15 | /** 16 | * 保存多个自定义组件 17 | * @param shopPrinterCustomComponentList 组件列表 18 | * @return 受影响的行数 19 | */ 20 | Integer insertMultiplePrinterCustomComponent (List shopPrinterCustomComponentList); 21 | 22 | /** 23 | * 根据模板id移除组件 24 | * @param templateId 模板id 25 | * @return 受影响的行数 26 | */ 27 | Integer updateMultiplePrinterCustomComponentByTemplateId (Integer templateId); 28 | 29 | /** 30 | * 通过模板id查询模板组件(预览组件) 31 | * @param documentTemplateId 模板id 32 | * @return 组件列表 33 | */ 34 | List selectPrinterTemplateCustomComponentByTemplateId(Integer documentTemplateId); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/dao/PrinterDeviceMapper.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.dao; 2 | 3 | import com.zxcs.printtemplate.model.PrinterDeviceDO; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 打印机相关的Mapper 10 | * Created by zfh on 2019/1/9 11 | */ 12 | @Mapper 13 | public interface PrinterDeviceMapper { 14 | 15 | /** 16 | * 新增记录 17 | * @param record {@link PrinterDeviceDO} 18 | * @return 自增主键 19 | */ 20 | Integer insert(PrinterDeviceDO record); 21 | 22 | /** 23 | * 根据主键查询记录 24 | * @param id 主键 25 | * @return {@link PrinterDeviceDO} 26 | */ 27 | PrinterDeviceDO selectByPrimaryKey(Integer id); 28 | 29 | /** 30 | * 查询店铺下所有的打印机(未删除) 31 | * @param shopId 店铺id 32 | * @return list 33 | */ 34 | List selectPrinterDeviceListByShopId(Integer shopId); 35 | 36 | /** 37 | * 更新记录 38 | * @param record {@link PrinterDeviceDO} 39 | * @return 受影响的条数 40 | */ 41 | Integer updateByPrimaryKeySelective(PrinterDeviceDO record); 42 | } -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/dao/PrinterDocumentTypeMapper.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.dao; 2 | 3 | import com.zxcs.printtemplate.model.PrinterDocumentTypeDO; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 打印模板文档类型Mapper 10 | * Created by zfh on 2018/12/11 11 | */ 12 | @Mapper 13 | public interface PrinterDocumentTypeMapper { 14 | 15 | /** 16 | * 主键查询文档类型 17 | * @param id 主键 18 | * @return 实体 19 | */ 20 | PrinterDocumentTypeDO selectPrinterDocumentTypeByPrimaryId (Integer id); 21 | 22 | /** 23 | * 查询文档类型列表(status=1) 24 | * @return list 25 | */ 26 | List selectPrinterDocumentType (); 27 | 28 | /** 29 | * 更新文档类型属性 30 | * @param scShopPrinterDocumentType 实体 31 | * @return 受影响的行数 32 | */ 33 | Integer updatePrinterDocumentType (PrinterDocumentTypeDO scShopPrinterDocumentType); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/dao/PrinterKitchenDocumentTypeRulesMapper.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.dao; 2 | 3 | import com.zxcs.printtemplate.model.PrinterKitchenDocumentTypeRulesDO; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 出票口票据类型相关Mapper 10 | * Created by zfh on 2019/1/9 11 | */ 12 | @Mapper 13 | public interface PrinterKitchenDocumentTypeRulesMapper { 14 | 15 | /** 16 | * 新增记录 17 | * @param record {@link PrinterKitchenDocumentTypeRulesDO} 18 | * @return 自增主键 19 | */ 20 | Integer insert(PrinterKitchenDocumentTypeRulesDO record); 21 | 22 | /** 23 | * 添加多条记录 24 | * @param documentTypeRulesList list 25 | * @return 受影响的条数 26 | */ 27 | Integer insertMultipleRecord (List documentTypeRulesList); 28 | 29 | /** 30 | * 根据 出票口ID 删除多条记录(软删除) 31 | * @param printerKitchenId 出票口ID 32 | * @return 受影响的条数 33 | */ 34 | Integer updateMultipleRecordByPrinterKitchenId (Integer printerKitchenId); 35 | 36 | /** 37 | * 查询 出票口 票据类型 38 | * @param printerKitchenId 出票口id 39 | * @return list 40 | */ 41 | List selectPrinterKitchenDocumentTypeRulesListByPrinterKitchenId(Integer printerKitchenId); 42 | 43 | /** 44 | * 根据主键查记录 45 | * @param id 主键 46 | * @return {@link PrinterKitchenDocumentTypeRulesDO} 47 | */ 48 | PrinterKitchenDocumentTypeRulesDO selectByPrimaryKey(Integer id); 49 | 50 | /** 51 | * 根据主键更新记录 52 | * @param record {@link PrinterKitchenDocumentTypeRulesDO} 53 | * @return 受影响的条数 54 | */ 55 | Integer updateByPrimaryKeySelective(PrinterKitchenDocumentTypeRulesDO record); 56 | } -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/dao/PrinterKitchenGoodsRulesMapper.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.dao; 2 | 3 | import com.zxcs.printtemplate.model.PrinterKitchenGoodsRulesDO; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 出票口配置打印菜品 10 | * Created by zfh on 2019/1/9 11 | */ 12 | @Mapper 13 | public interface PrinterKitchenGoodsRulesMapper { 14 | 15 | /** 16 | * 新增记录 17 | * @param record {@link PrinterKitchenGoodsRulesDO} 18 | * @return 自增主键 19 | */ 20 | Integer insert(PrinterKitchenGoodsRulesDO record); 21 | 22 | /** 23 | * 新增多条记录 24 | * @param recordList list 25 | * @return 受影响的条数 26 | */ 27 | Integer insertMultipleRecord(List recordList); 28 | 29 | /** 30 | * 通过出票口ID 删除多条记录(软删除) 31 | * @param printerKitchenId 出票口ID 32 | * @return 受影响的条数 33 | */ 34 | Integer updateMultipleRecordByPrinterKitchenId (Integer printerKitchenId); 35 | 36 | /** 37 | * 查询出票口 配置的打印菜品 38 | * @param printerKitchenId 出票口id 39 | * @return list 40 | */ 41 | List selectPrinterKitchenGoodsRulesListByPrinterKitchenId(Integer printerKitchenId); 42 | 43 | /** 44 | * 根据主键查记录 45 | * @param id 主键 46 | * @return {@link PrinterKitchenGoodsRulesDO} 47 | */ 48 | PrinterKitchenGoodsRulesDO selectByPrimaryKey(Integer id); 49 | 50 | /** 51 | * 根据主键更新记录 52 | * @param record {@link PrinterKitchenGoodsRulesDO} 53 | * @return 受影响的条数 54 | */ 55 | Integer updateByPrimaryKeySelective(PrinterKitchenGoodsRulesDO record); 56 | } -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/dao/PrinterKitchenMapper.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.dao; 2 | 3 | import com.zxcs.printtemplate.model.PrinterKitchenDO; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 出票口相关Mapper 10 | * Created by zfh on 2019/1/9 11 | */ 12 | @Mapper 13 | public interface PrinterKitchenMapper { 14 | 15 | /** 16 | * 添加记录 17 | * @param record {@link PrinterKitchenDO} 18 | * @return 自增主键 19 | */ 20 | Integer insert(PrinterKitchenDO record); 21 | 22 | /** 23 | * 根据主键查询 24 | * @param id 主键 25 | * @return {@link PrinterKitchenDO} 26 | */ 27 | PrinterKitchenDO selectByPrimaryKey(Integer id); 28 | 29 | /** 30 | * 查询店铺下所有的出票口(未删除) 31 | * @param shopId 店铺id 32 | * @return list 33 | */ 34 | List selectPrinterKitchenListByShopId (Integer shopId); 35 | 36 | /** 37 | * 根据主键有选择性的更新 38 | * @param record {@link PrinterKitchenDO} 39 | * @return 受影响的条数 40 | */ 41 | Integer updateByPrimaryKeySelective(PrinterKitchenDO record); 42 | } -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/dao/PrinterKitchenTableRulesMapper.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.dao; 2 | 3 | import com.zxcs.printtemplate.model.PrinterKitchenTableRulesDO; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 出票口配置桌台区域相关Mapper 10 | */ 11 | @Mapper 12 | public interface PrinterKitchenTableRulesMapper { 13 | 14 | /** 15 | * 新增记录 16 | * @param record {@link PrinterKitchenTableRulesDO} 17 | * @return 自增主键 18 | */ 19 | Integer insert(PrinterKitchenTableRulesDO record); 20 | 21 | /** 22 | * 新增多条记录 23 | * @param recordList list 24 | * @return 受影响的条数 25 | */ 26 | Integer insertMultipleRecord (List recordList); 27 | 28 | /** 29 | * 根据出票口 删除多条记录(软删除) 30 | * @param printerKitchenId 出票口ID 31 | * @return 受影响的条数 32 | */ 33 | Integer updateMultipleRecordByPrinterKitchenId (Integer printerKitchenId); 34 | 35 | /** 36 | * 查询出票口配置的桌台区域 37 | * @param printerKitchenId 出票口id 38 | * @return list 39 | */ 40 | List selectPrinterKitchenTableRulesListByPrinterKitchenId(Integer printerKitchenId); 41 | 42 | /** 43 | * 根据主键查询记录 44 | * @param id 主键 45 | * @return {@link PrinterKitchenTableRulesDO} 46 | */ 47 | PrinterKitchenTableRulesDO selectByPrimaryKey(Integer id); 48 | 49 | /** 50 | * 根据主键更新记录 51 | * @param record {@link PrinterKitchenTableRulesDO} 52 | * @return 受影响的条数 53 | */ 54 | Integer updateByPrimaryKeySelective(PrinterKitchenTableRulesDO record); 55 | } -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/dao/PrinterSystemComponentMapper.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.dao; 2 | 3 | import com.zxcs.printtemplate.model.PrinterSystemComponentDO; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by zfh on 2018/12/27 10 | */ 11 | @Mapper 12 | public interface PrinterSystemComponentMapper { 13 | 14 | /** 15 | * 添加系统组件 16 | * @param systemComponent {@link PrinterSystemComponentDO} 17 | * @return 自增长主键 18 | */ 19 | Integer insertPrinterSystemComponent (PrinterSystemComponentDO systemComponent); 20 | 21 | /** 22 | * 通过模板类型查询模板组件(系统组件) 23 | * @param templateType 模板类型 24 | * @return 组件列表 25 | */ 26 | List selectPrinterSystemComponentListByTemplateTypeId(Integer templateType); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/dao/PrinterTemplateDocumentMapper.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.dao; 2 | 3 | import com.zxcs.printtemplate.model.PrinterTemplateDocumentDO; 4 | import org.apache.ibatis.annotations.Mapper; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * 打印模板-模板相关Mapper 11 | * Created by zfh on 2018/12/12 12 | */ 13 | @Mapper 14 | public interface PrinterTemplateDocumentMapper { 15 | 16 | /** 17 | * 添加模板 18 | * @param scShopPrinterTemplateDocument {@link PrinterTemplateDocumentDO} 19 | * @return 受影响的行数 20 | */ 21 | Integer insertShopPrinterTemplateDocument (PrinterTemplateDocumentDO scShopPrinterTemplateDocument); 22 | 23 | /** 24 | * 根据主键查询模板 25 | * @param id 主键 26 | * @return {@link PrinterTemplateDocumentDO} 27 | */ 28 | PrinterTemplateDocumentDO selectShopPrinterTemplateDocumentByPrimaryId(Integer id); 29 | 30 | /** 31 | * 根据模板名称查询模板 32 | * @param name 模板名称 33 | * @return {@link PrinterTemplateDocumentDO} 34 | */ 35 | PrinterTemplateDocumentDO selectShopPrinterTemplateDocumentByName(String name); 36 | 37 | /** 38 | * 根据主键更新模板 39 | * @param scShopPrinterTemplateDocument {@link PrinterTemplateDocumentDO} 40 | * @return 受影响的行数 41 | */ 42 | Integer updateShopPrinterTemplateDocumentByPrimaryId(PrinterTemplateDocumentDO scShopPrinterTemplateDocument); 43 | 44 | /** 45 | * 移除自定义模板(软删除) 46 | * @param id 主键 47 | * @return 受影响的条数 48 | */ 49 | Integer updateShopPrinterTemplateDocumentStatusByPrimaryId(Integer id); 50 | 51 | /** 52 | * 禁用店铺指定类型的模板 53 | * @param shopId 店铺ID 54 | * @param templateType 模板类型 55 | * @return 受影响的条数 56 | */ 57 | Integer disableShopPrinterTemplateDocumentStatusByShopIdAndDocumentType (@Param("shopId") Integer shopId, @Param("documentType") Integer templateType); 58 | 59 | /** 60 | * 更新店铺模板 启用/禁用 状态 61 | * @param templateId 模板ID 62 | * @param status 1-启用 2-禁用 63 | * @return 受影响条数 64 | */ 65 | Integer updateShopPrinterTemplateDocumentStatusByShopIdAndDocumentType(@Param("templateId") Integer templateId, @Param("status") Integer status); 66 | 67 | /** 68 | * 查询店铺下模板列表和默认的模板 69 | * @param shopId 店铺id 70 | * @param documentType 票据类型 71 | * @return list 72 | */ 73 | List selectPrinterTemplateDocumentByShopIdAndDocumentType (@Param("shopId") Integer shopId, @Param("documentType") Integer documentType); 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/dao/PrinterTemplateModuleMapper.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.dao; 2 | 3 | import com.zxcs.printtemplate.model.PrinterTemplateModuleDO; 4 | import org.apache.ibatis.annotations.Mapper; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 打印模板-模块Mapper 10 | * Created by zfh on 2018/12/12 11 | */ 12 | @Mapper 13 | public interface PrinterTemplateModuleMapper { 14 | 15 | /** 16 | * 通过文档类型查询包含的模块 17 | * @param documentType 文档类型主键 18 | * @return list 19 | */ 20 | List selectPrinterTemplateModuleByDocumentId (Integer documentType); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/exception/BaseException.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.exception; 2 | 3 | /** 4 | * 统一异常处理,异常基类 5 | * Created by zfh on 2018/12/28 6 | */ 7 | public class BaseException extends RuntimeException { 8 | 9 | private static final long serialVersionUID = -8720779928866878060L; 10 | 11 | private String errCode; 12 | 13 | private String errMessage; 14 | 15 | public BaseException (String errCode, String errMessage) { 16 | super(errMessage); 17 | this.errCode = errCode; 18 | this.errMessage = errMessage; 19 | } 20 | 21 | public String getErrCode() { 22 | return errCode; 23 | } 24 | 25 | public void setErrCode(String errCode) { 26 | this.errCode = errCode; 27 | } 28 | 29 | public String getErrMessage() { 30 | return errMessage; 31 | } 32 | 33 | public void setErrMessage(String errMessage) { 34 | this.errMessage = errMessage; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/exception/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.exception; 2 | 3 | import com.alibaba.fastjson.JSONException; 4 | import com.zxcs.printtemplate.vo.Response; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.http.HttpStatus; 8 | import org.springframework.http.ResponseEntity; 9 | import org.springframework.web.bind.annotation.ControllerAdvice; 10 | import org.springframework.web.bind.annotation.ExceptionHandler; 11 | 12 | /** 13 | * 全局异常处理 14 | * Created by zfh on 2018/09/14 15 | */ 16 | @ControllerAdvice 17 | public class GlobalExceptionHandler { 18 | 19 | private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class); 20 | 21 | @ExceptionHandler(Exception.class) 22 | public ResponseEntity handlerException(Exception e) { 23 | logger.warn("【全局异常处理】errMessage = {}", e.getMessage(), e); 24 | Response result = new Response(); 25 | if (e instanceof BaseException) { 26 | result.setErrMsg(((BaseException) e).getErrMessage()); 27 | result.setErrCode(((BaseException) e).getErrCode()); 28 | return new ResponseEntity<>(result, HttpStatus.OK); 29 | } else { 30 | result.setErrMsg("Sorry,server mistake"); 31 | return new ResponseEntity<>(result, HttpStatus.INTERNAL_SERVER_ERROR); 32 | } 33 | } 34 | 35 | @ExceptionHandler(JSONException.class) 36 | public ResponseEntity handlerJSONException (JSONException e) { 37 | logger.warn("【全局异常处理】参数解析异常!", e); 38 | Response response = Response.newInstance().setErrCode("00001").setErrMsg("参数无法解析"); 39 | return new ResponseEntity<>(response, HttpStatus.OK); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/exception/common/ParameterException.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.exception.common; 2 | 3 | import com.zxcs.printtemplate.exception.BaseException; 4 | 5 | /** 6 | * 参数异常 7 | * Created by zfh on 2018/12/28 8 | */ 9 | public class ParameterException extends BaseException { 10 | 11 | private static final long serialVersionUID = 4118870983589945134L; 12 | 13 | public ParameterException() { 14 | super("00001", "缺少参数!"); 15 | } 16 | 17 | public ParameterException(String errMessage) { 18 | super("00001", errMessage); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/exception/common/ParameterIllegalException.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.exception.common; 2 | 3 | import com.zxcs.printtemplate.exception.BaseException; 4 | 5 | /** 6 | * 非法参数异常 7 | *

8 | * Created by zfh on 2019/05/15 9 | */ 10 | public class ParameterIllegalException extends BaseException { 11 | 12 | private static final long serialVersionUID = -8642079556184469474L; 13 | 14 | public ParameterIllegalException() { 15 | super("00001", "非法参数!"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/exception/common/ParamterErrorException.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.exception.common; 2 | 3 | import com.zxcs.printtemplate.exception.BaseException; 4 | 5 | /** 6 | * 参数错误异常 7 | * Created by zfh on 2018/12/28 8 | */ 9 | public class ParamterErrorException extends BaseException { 10 | 11 | private static final long serialVersionUID = 5653210212160051562L; 12 | 13 | public ParamterErrorException() { 14 | super("00002", "参数错误!"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/exception/common/PermissionRefusedException.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.exception.common; 2 | 3 | import com.zxcs.printtemplate.exception.BaseException; 4 | 5 | /** 6 | * 权限拒绝异常 7 | *

8 | * Created by zfh on 2020/01/13 9 | */ 10 | public class PermissionRefusedException extends BaseException { 11 | 12 | private static final long serialVersionUID = 4484282829789560446L; 13 | 14 | public PermissionRefusedException() { 15 | super("100018", "权限拒绝!"); 16 | } 17 | 18 | public PermissionRefusedException (String errMsg) { 19 | super("100018", errMsg); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/exception/print/PrinterDeviceException.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.exception.print; 2 | 3 | import com.zxcs.printtemplate.exception.BaseException; 4 | 5 | /** 6 | * 打印机异常 7 | *

8 | * Created by zfh on 2020/04/23 9 | */ 10 | public class PrinterDeviceException extends BaseException { 11 | 12 | public PrinterDeviceException() { 13 | super("00001", "打印机不存在!"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/exception/print/PrinterKitchenException.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.exception.print; 2 | 3 | import com.zxcs.printtemplate.exception.BaseException; 4 | 5 | /** 6 | * 出票口异常 7 | *

8 | * Created by zfh on 2020/04/24 9 | */ 10 | public class PrinterKitchenException extends BaseException { 11 | 12 | public PrinterKitchenException() { 13 | super("00002", "出票口不存在!"); 14 | } 15 | 16 | public PrinterKitchenException(String errMsg) { 17 | super("00002", errMsg); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/exception/print/PrinterTemplateDocumentException.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.exception.print; 2 | 3 | import com.zxcs.printtemplate.exception.BaseException; 4 | 5 | /** 6 | * 模板-文档异常 7 | *

8 | * Created by zfh on 2020/04/24 9 | */ 10 | public class PrinterTemplateDocumentException extends BaseException { 11 | 12 | public PrinterTemplateDocumentException() { 13 | super("00003", "文档不存在"); 14 | } 15 | 16 | public PrinterTemplateDocumentException(String errMsg) { 17 | super("00003", errMsg); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/form/BaseForm.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.form; 2 | 3 | 4 | import com.zxcs.printtemplate.exception.common.ParameterException; 5 | 6 | import javax.validation.ConstraintViolation; 7 | import javax.validation.Validation; 8 | import javax.validation.Validator; 9 | import javax.validation.ValidatorFactory; 10 | import java.util.Iterator; 11 | import java.util.Set; 12 | 13 | /** 14 | * Form实体基础类 15 | *

16 | * Created by zfh on 2019/10/19 17 | */ 18 | public class BaseForm { 19 | 20 | /** 21 | * JSR 303参数校验 22 | */ 23 | public void validateParam() { 24 | ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); 25 | Validator validator = factory.getValidator(); 26 | Set> validate = validator.validate(this); 27 | Iterator> iterator = validate.iterator(); 28 | if (iterator.hasNext()) { 29 | throw new ParameterException(iterator.next().getMessage()); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/form/CustomTemplateDocumentForm.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.form; 2 | 3 | import com.zxcs.printtemplate.model.PrinterTemplateDocumentDO; 4 | import lombok.Data; 5 | import lombok.ToString; 6 | 7 | import javax.validation.constraints.NotEmpty; 8 | import javax.validation.constraints.NotNull; 9 | 10 | /** 11 | * 添加模板请求对象 12 | * Created by zfh on 2019/01/04 13 | */ 14 | @Data 15 | @ToString 16 | public class CustomTemplateDocumentForm extends BaseForm{ 17 | 18 | /** 19 | * 店铺id 20 | */ 21 | @NotNull(message = "缺少shopId") 22 | private Integer shopId; 23 | 24 | /** 25 | * 操作员id 26 | */ 27 | @NotNull(message = "缺少operatorId") 28 | private Integer operatorId; 29 | 30 | /** 31 | * 模板名称 32 | */ 33 | @NotEmpty(message = "缺少name") 34 | private String name; 35 | 36 | /** 37 | * 文档类型 38 | */ 39 | @NotNull(message = "缺少documentType") 40 | private Integer documentType; 41 | 42 | /** 43 | * 票据预览图 44 | */ 45 | @NotNull(message = "缺少url") 46 | private String url; 47 | 48 | /** 49 | * 模板-模块 50 | */ 51 | @NotEmpty(message = "缺少modules") 52 | private String modules; 53 | 54 | /** 55 | * 入参对象转换为实体对象 56 | * @return {@link PrinterTemplateDocumentDO} 57 | */ 58 | public PrinterTemplateDocumentDO convertToScShopPrinterTemplateDocument () { 59 | PrinterTemplateDocumentDO templateDocument = new PrinterTemplateDocumentDO(); 60 | templateDocument.setName(name); 61 | templateDocument.setDocumentType(documentType); 62 | templateDocument.setUrl(url); 63 | // 默认状态:1-启用 2-禁用 64 | templateDocument.setStatus(2); 65 | templateDocument.setShopId(shopId); 66 | templateDocument.setCreatorId(operatorId); 67 | templateDocument.setCreatorName(""); 68 | return templateDocument; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/form/DocumentTypeRule.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.form; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import javax.validation.constraints.NotNull; 7 | 8 | /** 9 | * 出票口票据类型 10 | *

11 | * Created by zfh on 2020/04/24 12 | */ 13 | @Data 14 | @ToString 15 | public class DocumentTypeRule extends BaseForm { 16 | 17 | /** 18 | * 票据类型ID 19 | */ 20 | @NotNull(message = "缺少documentTypeId") 21 | private Integer documentTypeId; 22 | 23 | /** 24 | * 打印份数 25 | */ 26 | @NotNull(message = "缺少number") 27 | private Integer number; 28 | 29 | /** 30 | * 打印方式:1-一纸多菜 2-一纸一菜 3-各打一张 31 | */ 32 | @NotNull(message = "缺少printerType") 33 | private Integer printerType; 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/form/PrinterKitchenForm.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.form; 2 | 3 | import com.zxcs.printtemplate.model.PrinterKitchenDO; 4 | import com.zxcs.printtemplate.model.PrinterKitchenDocumentTypeRulesDO; 5 | import com.zxcs.printtemplate.model.PrinterKitchenGoodsRulesDO; 6 | import com.zxcs.printtemplate.model.PrinterKitchenTableRulesDO; 7 | import lombok.Data; 8 | import lombok.ToString; 9 | import org.springframework.beans.BeanUtils; 10 | 11 | import javax.validation.constraints.NotEmpty; 12 | import javax.validation.constraints.NotNull; 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | /** 17 | * 新增/更新-出票口 请求对象 18 | * Created by zfh on 2019/01/09 19 | */ 20 | @Data 21 | @ToString 22 | public class PrinterKitchenForm extends BaseForm { 23 | 24 | /** 25 | * 出票口ID 26 | */ 27 | private Integer id; 28 | 29 | /** 30 | * 出票口名称 31 | */ 32 | @NotEmpty(message = "缺少name") 33 | private String name; 34 | 35 | /** 36 | * 打印机ID 37 | */ 38 | @NotNull(message = "缺少printerDeviceId") 39 | private Integer printerDeviceId; 40 | 41 | /** 42 | * 店铺ID 43 | */ 44 | @NotNull(message = "缺少shopId") 45 | private Integer shopId; 46 | 47 | /** 48 | * 平台用户ID 49 | */ 50 | @NotNull(message = "缺少operatorId") 51 | private Integer operatorId; 52 | 53 | /** 54 | * 出票口票据类型 55 | */ 56 | @NotEmpty(message = "缺少documentTypeRules") 57 | private List documentTypeRules; 58 | 59 | /** 60 | * 是否配置桌台区域:0-未配置 1-配置 61 | */ 62 | @NotNull(message = "缺少table") 63 | private Integer table; 64 | 65 | /** 66 | * 是否配置打印的菜品:0-未配置 1-配置 67 | */ 68 | @NotNull(message = "缺少goods") 69 | private Integer goods; 70 | 71 | /** 72 | * 桌台区域,没有配置传空数组 73 | */ 74 | @NotNull(message = "缺少tableRules") 75 | private List tableRules; 76 | 77 | /** 78 | * 打印菜品,没有配置传空数组 79 | */ 80 | @NotNull(message = "缺少goodsRules") 81 | private List goodsRules; 82 | 83 | @Override 84 | public void validateParam() { 85 | super.validateParam(); 86 | for (DocumentTypeRule typeRule : documentTypeRules) { 87 | typeRule.validateParam(); 88 | } 89 | for (PrinterKitchenTableRule tableRule : tableRules) { 90 | tableRule.validateParam(); 91 | } 92 | for (PrinterKitchenGoodsRule goodsRule : goodsRules) { 93 | goodsRule.validateParam(); 94 | } 95 | } 96 | 97 | /** 98 | * 获取-新增-出票口实体对象 99 | */ 100 | public PrinterKitchenDO getPrinterKitchen () { 101 | PrinterKitchenDO printerKitchen = new PrinterKitchenDO(); 102 | BeanUtils.copyProperties(this, printerKitchen); 103 | printerKitchen.setDelete(0); 104 | printerKitchen.setCreatorId(operatorId); 105 | printerKitchen.setCreatorName(""); 106 | return printerKitchen; 107 | } 108 | 109 | /** 110 | * 获取-更新-出票口实体对象 111 | */ 112 | public PrinterKitchenDO getUpdatePrinterKitchen() { 113 | PrinterKitchenDO printerKitchen = new PrinterKitchenDO(); 114 | BeanUtils.copyProperties(this, printerKitchen); 115 | printerKitchen.setUpdatorId(operatorId); 116 | printerKitchen.setUpdatorName(""); 117 | return printerKitchen; 118 | } 119 | 120 | /** 121 | * 出票口票据类型 122 | * @param printerKitchenId 出票口ID 123 | */ 124 | public List getDocumentTypeRulesList(Integer printerKitchenId) { 125 | List typeRulesDOList = new ArrayList<>(10); 126 | for (DocumentTypeRule typeRule : documentTypeRules) { 127 | PrinterKitchenDocumentTypeRulesDO typeRulesDO = new PrinterKitchenDocumentTypeRulesDO(); 128 | BeanUtils.copyProperties(typeRule, typeRulesDO); 129 | typeRulesDO.setPrinterKitchenId(printerKitchenId); 130 | typeRulesDOList.add(typeRulesDO); 131 | } 132 | return typeRulesDOList; 133 | } 134 | 135 | /** 136 | * 获取出票口 配置的桌台区域 137 | * @param printerKitchenId 出票口ID 138 | */ 139 | public List getTableRulesList(Integer printerKitchenId) { 140 | List tableRulesDOList = new ArrayList<>(10); 141 | for (PrinterKitchenTableRule tableRule : tableRules) { 142 | PrinterKitchenTableRulesDO tableRuleDO = new PrinterKitchenTableRulesDO(); 143 | BeanUtils.copyProperties(tableRule, tableRuleDO); 144 | tableRuleDO.setPrinterKitchenId(printerKitchenId); 145 | tableRulesDOList.add(tableRuleDO); 146 | } 147 | return tableRulesDOList; 148 | } 149 | 150 | /** 151 | * 获取出票口 配置的打印菜品 152 | * @param printerKitchenId 出票口ID 153 | */ 154 | public List getGoodsRulesList(Integer printerKitchenId) { 155 | List goodsRulesDOList = new ArrayList<>(10); 156 | for (PrinterKitchenGoodsRule goodsRule : goodsRules) { 157 | PrinterKitchenGoodsRulesDO goodsRulesDO = new PrinterKitchenGoodsRulesDO(); 158 | BeanUtils.copyProperties(goodsRule, goodsRulesDO); 159 | goodsRulesDO.setPrinterKitchenId(printerKitchenId); 160 | goodsRulesDOList.add(goodsRulesDO); 161 | } 162 | return goodsRulesDOList; 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/form/PrinterKitchenGoodsRule.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.form; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import javax.validation.constraints.NotNull; 7 | 8 | /** 9 | * 打印菜品 10 | *

11 | * Created by zfh on 2020/04/24 12 | */ 13 | @Data 14 | @ToString 15 | public class PrinterKitchenGoodsRule extends BaseForm { 16 | 17 | /** 18 | * 商品ID 19 | */ 20 | @NotNull(message = "缺少goodsId") 21 | private Integer goodsId; 22 | 23 | /** 24 | * 商品规格 25 | */ 26 | @NotNull(message = "缺少stockId") 27 | private Integer stockId; 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/form/PrinterKitchenTableRule.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.form; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import javax.validation.constraints.NotNull; 7 | 8 | /** 9 | * 出票口桌台区域 10 | *

11 | * Created by zfh on 2020/04/24 12 | */ 13 | @Data 14 | @ToString 15 | public class PrinterKitchenTableRule extends BaseForm { 16 | 17 | /** 18 | * 桌台号 19 | */ 20 | @NotNull(message = "缺少tableId") 21 | private Integer tableId; 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/form/SavePrinterDeviceForm.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.form; 2 | 3 | import com.zxcs.printtemplate.model.PrinterDeviceDO; 4 | import lombok.Data; 5 | import lombok.ToString; 6 | import org.springframework.beans.BeanUtils; 7 | 8 | import javax.validation.constraints.NotEmpty; 9 | import javax.validation.constraints.NotNull; 10 | 11 | /** 12 | * 新增 打印机 请求 13 | * Created by zfh on 2019/01/09 14 | */ 15 | @Data 16 | @ToString 17 | public class SavePrinterDeviceForm extends BaseForm{ 18 | 19 | /** 20 | * 打印机名称 21 | */ 22 | @NotEmpty(message = "缺少deviceName") 23 | private String deviceName; 24 | 25 | /** 26 | * 打印机类型:1-服务器 2-网络打印机 27 | */ 28 | @NotNull(message = "缺少printerDeviceType") 29 | private Integer printerDeviceType; 30 | 31 | /** 32 | * ip地址 33 | */ 34 | @NotEmpty(message = "缺少address") 35 | private String address; 36 | 37 | /** 38 | * 店铺id 39 | */ 40 | @NotNull(message = "缺少shopId") 41 | private Integer shopId; 42 | 43 | /** 44 | * 平台用户ID 45 | */ 46 | @NotNull(message = "缺少operatorId") 47 | private Integer operatorId; 48 | 49 | /** 50 | * 获取 打印机实体对象 51 | */ 52 | public PrinterDeviceDO getPrinterDevice () { 53 | PrinterDeviceDO printerDevice = new PrinterDeviceDO(); 54 | BeanUtils.copyProperties(this, printerDevice); 55 | printerDevice.setDelete(0); 56 | printerDevice.setCreatorId(operatorId); 57 | printerDevice.setCreatorName(""); 58 | return printerDevice; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/form/TemplateDocumentEnableForm.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.form; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import javax.validation.constraints.NotNull; 7 | 8 | /** 9 | * 应用模板 请求对象 10 | *

11 | * Created by zfh on 2020/04/25 12 | */ 13 | @Data 14 | @ToString 15 | public class TemplateDocumentEnableForm extends BaseForm { 16 | 17 | /** 18 | * 店铺ID 19 | */ 20 | @NotNull(message = "缺少shopId") 21 | private Integer shopId; 22 | 23 | /** 24 | * 模板ID 25 | */ 26 | @NotNull(message = "缺少templateId") 27 | private Integer templateId; 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/form/UpdateCustomTemplateDocumentForm.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.form; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import javax.validation.constraints.NotEmpty; 7 | import javax.validation.constraints.NotNull; 8 | 9 | /** 10 | * 更新模板请求对象 11 | * Created by zfh on 2019/01/04 12 | */ 13 | @Data 14 | @ToString 15 | public class UpdateCustomTemplateDocumentForm extends BaseForm { 16 | 17 | /** 18 | * 店铺id 19 | */ 20 | @NotNull(message = "缺少shopId") 21 | private Integer shopId; 22 | 23 | /** 24 | * 模板名称 25 | */ 26 | @NotEmpty(message = "缺少name") 27 | private String name; 28 | 29 | /** 30 | * 模板id 31 | */ 32 | @NotNull(message = "缺少templateId") 33 | private Integer templateId; 34 | 35 | /** 36 | * 票据预览图 37 | */ 38 | @NotEmpty(message = "缺少url") 39 | private String url; 40 | 41 | /** 42 | * 模板-模块 43 | */ 44 | @NotEmpty(message = "缺少modules") 45 | private String modules; 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/form/UpdatePrinterDeviceForm.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.form; 2 | 3 | import com.zxcs.printtemplate.model.PrinterDeviceDO; 4 | import lombok.Data; 5 | import lombok.ToString; 6 | import org.springframework.beans.BeanUtils; 7 | 8 | import javax.validation.constraints.NotEmpty; 9 | import javax.validation.constraints.NotNull; 10 | 11 | /** 12 | * 更新打印机 请求 13 | * Created by zfh on 2019/01/09 14 | */ 15 | @Data 16 | @ToString 17 | public class UpdatePrinterDeviceForm extends BaseForm { 18 | 19 | /** 20 | * 设备ID 21 | */ 22 | @NotNull(message = "缺少id") 23 | private Integer id; 24 | 25 | /** 26 | * 打印机名称 27 | */ 28 | @NotEmpty(message = "缺少deviceName") 29 | private String deviceName; 30 | 31 | /** 32 | * 打印机类型 33 | */ 34 | @NotNull(message = "缺少printerDeviceType") 35 | private Integer printerDeviceType; 36 | 37 | /** 38 | * ip地址 39 | */ 40 | @NotEmpty(message = "缺少address") 41 | private String address; 42 | 43 | /** 44 | * 店铺id 45 | */ 46 | @NotNull(message = "缺少shopId") 47 | private Integer shopId; 48 | 49 | /** 50 | * 平台用户ID 51 | */ 52 | @NotNull(message = "缺少operatorId") 53 | private Integer operatorId; 54 | 55 | /** 56 | * 获取 打印机实体对象 57 | * @return {@link PrinterDeviceDO} 58 | */ 59 | public PrinterDeviceDO getScShopPrinterDevice () { 60 | PrinterDeviceDO printerDevice = new PrinterDeviceDO(); 61 | BeanUtils.copyProperties(this, printerDevice); 62 | printerDevice.setUpdatorId(operatorId); 63 | printerDevice.setUpdatorName(""); 64 | return printerDevice; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/helper/MapHelper.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.helper; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | /** 9 | * Map帮助类 10 | *

11 | * Created by zfh on 2020/04/23 12 | */ 13 | public class MapHelper { 14 | 15 | public Map data = new HashMap<>(10); 16 | 17 | public static MapHelper newInstance() { 18 | return new MapHelper(); 19 | } 20 | 21 | public MapHelper put(String key, Object value) { 22 | data.put(key, value); 23 | return this; 24 | } 25 | 26 | public String json() { 27 | return JSONObject.toJSONString(data); 28 | } 29 | 30 | public Map map() { 31 | return data; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/model/PrinterCustomComponentDO.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.model; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | /** 10 | * 打印模板-自定义模板组件 实体 11 | * Created by zfh on 2018/12/27 12 | */ 13 | @Data 14 | @ToString 15 | public class PrinterCustomComponentDO implements Serializable { 16 | 17 | private static final long serialVersionUID = -5596577451287093325L; 18 | 19 | /** 20 | * 主键 21 | */ 22 | private Integer id; 23 | 24 | /** 25 | * 模板id 26 | */ 27 | private Integer documentTemplateId; 28 | 29 | /** 30 | * 系统组件id 31 | */ 32 | private Integer systemComponentId; 33 | 34 | /** 35 | * 自定义组件样式 36 | */ 37 | private String valueStyle; 38 | 39 | /** 40 | * 模块id 41 | */ 42 | private Integer moduleId; 43 | 44 | /** 45 | * 父组件id 46 | */ 47 | private Integer parentId; 48 | 49 | /** 50 | * 引用id 51 | */ 52 | private Integer refId; 53 | 54 | /** 55 | * 组件名称 56 | */ 57 | private String label; 58 | 59 | /** 60 | * 组件值 61 | */ 62 | private String value; 63 | 64 | /** 65 | * 占位符 66 | */ 67 | private String placeholder; 68 | 69 | /** 70 | * 组件类型 71 | */ 72 | private String type; 73 | 74 | /** 75 | * 行号 76 | */ 77 | private Integer row; 78 | 79 | /** 80 | * 列号 81 | */ 82 | private Integer column; 83 | 84 | /** 85 | * 宽度,百分比 86 | */ 87 | private Integer width; 88 | 89 | /** 90 | * 序号 91 | */ 92 | private Integer sort; 93 | 94 | /** 95 | * 启用状态:0 未启用 1已启用 96 | */ 97 | private Integer enable; 98 | 99 | /** 100 | * 是否删除:0-未删除 1-删除 101 | */ 102 | private Integer delete; 103 | 104 | /** 105 | * 创建时间 106 | */ 107 | private Date createTime; 108 | 109 | /** 110 | * 更新时间 111 | */ 112 | private Date updateTime; 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/model/PrinterDeviceDO.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.model; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | /** 10 | * 打印机 实体 11 | * Created by zfh on 2019/1/8 12 | */ 13 | @Data 14 | @ToString 15 | public class PrinterDeviceDO implements Serializable { 16 | 17 | private static final long serialVersionUID = 3784955434189951427L; 18 | 19 | /** 20 | * 主键 21 | */ 22 | private Integer id; 23 | 24 | /** 25 | * 名称 26 | */ 27 | private String deviceName; 28 | 29 | /** 30 | * 打印机类型:1-服务器 2-网络打印机 31 | */ 32 | private Integer printerDeviceType; 33 | 34 | /** 35 | * ip地址 36 | */ 37 | private String address; 38 | 39 | /** 40 | * 是否删除:0-未删除 1-已删除 41 | */ 42 | private Integer delete; 43 | 44 | /** 45 | * 店铺id 46 | */ 47 | private Integer shopId; 48 | 49 | /** 50 | * 创建人 51 | */ 52 | private Integer creatorId; 53 | 54 | /** 55 | * 创建人姓名 56 | */ 57 | private String creatorName; 58 | 59 | /** 60 | * 更新人 61 | */ 62 | private Integer updatorId; 63 | 64 | /** 65 | * 更新人姓名 66 | */ 67 | private String updatorName; 68 | 69 | /** 70 | * 添加时间 71 | */ 72 | private Date createTime; 73 | 74 | /** 75 | * 更新时间 76 | */ 77 | private Date updateTime; 78 | } -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/model/PrinterDocumentTypeDO.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.model; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | /** 10 | * 打印文档类型 实体 11 | * Created by zfh on 2018/12/11 12 | */ 13 | @Data 14 | @ToString 15 | public class PrinterDocumentTypeDO implements Serializable { 16 | 17 | private static final long serialVersionUID = 2779853373257838652L; 18 | 19 | /** 20 | * 主键 21 | */ 22 | private Integer id; 23 | 24 | /** 25 | * 类型名称 26 | */ 27 | private String name; 28 | 29 | /** 30 | * 状态:0-禁用 1-启用 31 | */ 32 | private Integer status; 33 | 34 | /** 35 | * 添加时间 36 | */ 37 | private Date createTime; 38 | 39 | /** 40 | * 更新时间 41 | */ 42 | private Date updateTime; 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/model/PrinterKitchenDO.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.model; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | /** 10 | * 出票口 实体 11 | * Created by zfh on 2019/1/8 12 | */ 13 | @Data 14 | @ToString 15 | public class PrinterKitchenDO implements Serializable { 16 | 17 | private static final long serialVersionUID = 4609560622003259131L; 18 | 19 | /** 20 | * 主键 21 | */ 22 | private Integer id; 23 | 24 | /** 25 | * 出票口名称 26 | */ 27 | private String name; 28 | 29 | /** 30 | * 打印机id 31 | */ 32 | private Integer printerDeviceId; 33 | 34 | /** 35 | * 是否配置桌台区域:0-未配置 1-配置 36 | */ 37 | private Integer table; 38 | 39 | /** 40 | * 是否配置打印的菜品:0-未配置 1-配置 41 | */ 42 | private Integer goods; 43 | 44 | /** 45 | * 是否删除:0-未删除 1-删除 46 | */ 47 | private Integer delete; 48 | 49 | /** 50 | * 店铺id 51 | */ 52 | private Integer shopId; 53 | 54 | /** 55 | * 创建人 56 | */ 57 | private Integer creatorId; 58 | 59 | /** 60 | * 创建人姓名 61 | */ 62 | private String creatorName; 63 | 64 | /** 65 | * 更新人 66 | */ 67 | private Integer updatorId; 68 | 69 | /** 70 | * 更新人姓名 71 | */ 72 | private String updatorName; 73 | 74 | /** 75 | * 添加时间 76 | */ 77 | private Date createTime; 78 | 79 | /** 80 | * 更新时间 81 | */ 82 | private Date updateTime; 83 | } -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/model/PrinterKitchenDocumentTypeRulesDO.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.model; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | /** 10 | * 出票口-票据类型规则 实体 11 | * Created by zfh on 2019/1/8 12 | */ 13 | @Data 14 | @ToString 15 | public class PrinterKitchenDocumentTypeRulesDO implements Serializable { 16 | 17 | private static final long serialVersionUID = -5920364244309155023L; 18 | 19 | /** 20 | * 主键 21 | */ 22 | private Integer id; 23 | 24 | /** 25 | * 出票口id 26 | */ 27 | private Integer printerKitchenId; 28 | 29 | /** 30 | * 票据类型id 31 | */ 32 | private Integer documentTypeId; 33 | 34 | /** 35 | * 打印的份数 36 | */ 37 | private Integer number; 38 | 39 | /** 40 | * 打印方式:1-一纸多菜 2-一纸一菜 3-各打一张 41 | */ 42 | private Integer printerType; 43 | 44 | /** 45 | * 是否删除:0-未删除 1-删除 46 | */ 47 | private Integer delete; 48 | 49 | /** 50 | * 添加时间 51 | */ 52 | private Date createTime; 53 | 54 | /** 55 | * 更新时间 56 | */ 57 | private Date updateTime; 58 | } -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/model/PrinterKitchenGoodsRulesDO.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.model; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | /** 10 | * 出票口配置打印菜品 实体 11 | * Created by zfh on 2019/1/8 12 | */ 13 | @Data 14 | @ToString 15 | public class PrinterKitchenGoodsRulesDO implements Serializable { 16 | 17 | private static final long serialVersionUID = -3530065658560092393L; 18 | 19 | /** 20 | * 主键 21 | */ 22 | private Integer id; 23 | 24 | /** 25 | * 出票口id 26 | */ 27 | private Integer printerKitchenId; 28 | 29 | /** 30 | * 商品id 31 | */ 32 | private Integer goodsId; 33 | 34 | /** 35 | * 商品规格 36 | */ 37 | private Integer stockId; 38 | 39 | /** 40 | * 是否删除:0-未删除 1-删除 41 | */ 42 | private Integer delete; 43 | 44 | /** 45 | * 添加时间 46 | */ 47 | private Date createTime; 48 | 49 | /** 50 | * 更新时间 51 | */ 52 | private Date updateTime; 53 | } -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/model/PrinterKitchenTableRulesDO.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.model; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | /** 9 | * 出票口配置打印菜品 实体 10 | * Created by zfh on 2019/1/9 11 | */ 12 | @Data 13 | @ToString 14 | public class PrinterKitchenTableRulesDO implements Serializable { 15 | 16 | private static final long serialVersionUID = -8771246143755692032L; 17 | 18 | /** 19 | * 主键 20 | */ 21 | private Integer id; 22 | 23 | /** 24 | * 出票口 25 | */ 26 | private Integer printerKitchenId; 27 | 28 | /** 29 | * 桌台号 30 | */ 31 | private Integer tableId; 32 | 33 | /** 34 | * 是否删除 35 | */ 36 | private Integer delete; 37 | 38 | /** 39 | * 添加时间 40 | */ 41 | private Date createTime; 42 | 43 | /** 44 | * 更新时间 45 | */ 46 | private Date updateTime; 47 | } -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/model/PrinterSystemComponentDO.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.model; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | /** 10 | * 打印模板-系统组件 实体 11 | * Created by zfh on 2018/12/27 12 | */ 13 | @Data 14 | @ToString 15 | public class PrinterSystemComponentDO implements Serializable { 16 | 17 | private static final long serialVersionUID = -8209780276534664188L; 18 | 19 | /** 20 | * 主键 21 | */ 22 | private Integer id; 23 | 24 | /** 25 | * 模块id 26 | */ 27 | private Integer moduleId; 28 | 29 | /** 30 | * 父组件id 31 | */ 32 | private Integer parentId; 33 | 34 | /** 35 | * 引用id 36 | */ 37 | private Integer refId; 38 | 39 | /** 40 | * 组件名称 41 | */ 42 | private String label; 43 | 44 | /** 45 | * 组件值 46 | */ 47 | private String value; 48 | 49 | /** 50 | * 组件样式 51 | */ 52 | private String valueStyle; 53 | 54 | /** 55 | * 占位符 56 | */ 57 | private String placeholder; 58 | 59 | /** 60 | * 组件类型 61 | */ 62 | private String type; 63 | 64 | /** 65 | * 行号 66 | */ 67 | private Integer row; 68 | 69 | /** 70 | * 列号 71 | */ 72 | private Integer column; 73 | 74 | /** 75 | * 宽度,百分比 76 | */ 77 | private Integer width; 78 | 79 | /** 80 | * 序号 81 | */ 82 | private Integer sort; 83 | 84 | /** 85 | * 启用状态:0 未启用 1已启用 86 | */ 87 | private Integer enable; 88 | 89 | /** 90 | * 创建时间 91 | */ 92 | private Date createTime; 93 | 94 | /** 95 | * 更新时间 96 | */ 97 | private Date updateTime; 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/model/PrinterTemplateDocumentDO.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.model; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | /** 10 | * 打印模板-文档表 11 | * Created by zfh on 2018/12/12 12 | */ 13 | @Data 14 | @ToString 15 | public class PrinterTemplateDocumentDO implements Serializable { 16 | 17 | private static final long serialVersionUID = 5061220291589710884L; 18 | 19 | /** 20 | * 主键 21 | */ 22 | private Integer id; 23 | 24 | /** 25 | * 模板文档名称 26 | */ 27 | private String name; 28 | 29 | /** 30 | * 文档类型 31 | */ 32 | private Integer documentType; 33 | 34 | /** 35 | * 模板预览图 36 | */ 37 | private String url; 38 | 39 | /** 40 | * 模板状态:0-删除 1-启用 2-禁用 41 | */ 42 | private Integer status; 43 | 44 | /** 45 | * 店铺id 46 | */ 47 | private Integer shopId; 48 | 49 | /** 50 | * 创建者id 51 | */ 52 | private Integer creatorId; 53 | 54 | /** 55 | * 创建者姓名 56 | */ 57 | private String creatorName; 58 | 59 | /** 60 | * 添加时间 61 | */ 62 | private Date createTime; 63 | 64 | /** 65 | * 更新时间 66 | */ 67 | private Date updateTime; 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/model/PrinterTemplateModuleDO.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.model; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | /** 10 | * 打印模板-模块实体 11 | * Created by zfh on 2018/12/12 12 | */ 13 | @Data 14 | @ToString 15 | public class PrinterTemplateModuleDO implements Serializable { 16 | 17 | private static final long serialVersionUID = 8485241363055149502L; 18 | 19 | /** 20 | * 主键 21 | */ 22 | private Integer id; 23 | 24 | /** 25 | * 模块名称 26 | */ 27 | private String moduleName; 28 | 29 | /** 30 | * 模块描述 31 | */ 32 | private String moduleDescribe; 33 | 34 | /** 35 | * 文档类型 36 | */ 37 | private Integer documentType; 38 | 39 | /** 40 | * 模块排序 41 | */ 42 | private Integer sort; 43 | 44 | /** 45 | * 添加时间 46 | */ 47 | private Date createTime; 48 | 49 | /** 50 | * 更新时间 51 | */ 52 | private Date updateTime; 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/service/IPrinterCustomComponentService.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.service; 2 | 3 | import com.zxcs.printtemplate.model.PrinterCustomComponentDO; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 打印模板-自定义模板组件相关Service 9 | * Created by zfh on 2019/01/03 10 | */ 11 | public interface IPrinterCustomComponentService { 12 | 13 | /** 14 | * 保存多个自定义组件 15 | * @param shopPrinterCustomComponentList 组件列表 16 | * @return 受影响的行数 17 | */ 18 | Integer saveMultiplePrinterCustomComponent (List shopPrinterCustomComponentList); 19 | 20 | /** 21 | * 根据模板id移除组件(软删除) 22 | * @param templateId 模板id 23 | * @return 受影响的行数 24 | */ 25 | Integer removeMultiplePrinterCustomComponentByTemplateId (Integer templateId); 26 | 27 | /** 28 | * 通过模板id查询模板组件(预览组件) 29 | * @param documentTemplateId 模板id 30 | * @return 组件列表 31 | */ 32 | List listPrinterTemplateCustomComponentByTemplateId(Integer documentTemplateId); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/service/IPrinterDeviceService.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.zxcs.printtemplate.model.PrinterDeviceDO; 5 | 6 | /** 7 | * 打印机相关Service 8 | * Created by zfh on 2019/01/09 9 | */ 10 | public interface IPrinterDeviceService { 11 | 12 | /** 13 | * 新增记录 14 | * @param record {@link PrinterDeviceDO} 15 | * @return 自增主键 16 | */ 17 | Integer save(PrinterDeviceDO record); 18 | 19 | /** 20 | * 根据主键查询记录 21 | * @param id 主键 22 | * @return {@link PrinterDeviceDO} 23 | */ 24 | PrinterDeviceDO getScShopPrinterDeviceByPrimaryKey(Integer id); 25 | 26 | /** 27 | * 查询店铺下所有的打印机(未删除) 28 | * @param shopId 店铺id 29 | * @param page 页码 30 | * @param rows 页条数 31 | * @return {@link PageInfo} 32 | */ 33 | PageInfo listPrinterDeviceByShopId(Integer shopId, Integer page, Integer rows); 34 | 35 | /** 36 | * 更新记录 37 | * @param record {@link PrinterDeviceDO} 38 | * @return 受影响的条数 39 | */ 40 | Integer updateByPrimaryKeySelective(PrinterDeviceDO record); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/service/IPrinterDocumentTypeService.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.service; 2 | 3 | import com.zxcs.printtemplate.model.PrinterDocumentTypeDO; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 打印模板-文档类型Service 9 | * Created by zfh on 2018/12/12 10 | */ 11 | public interface IPrinterDocumentTypeService { 12 | 13 | /** 14 | * 查询文档类型列表(status=1) 15 | * @return list 16 | */ 17 | List listPrinterDocumentType (); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/service/IPrinterKitchenDocumentTypeRulesService.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.service; 2 | 3 | import com.zxcs.printtemplate.model.PrinterKitchenDocumentTypeRulesDO; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 出票口票据类型相关Service 9 | * Created by zfh on 2019/01/09 10 | */ 11 | public interface IPrinterKitchenDocumentTypeRulesService { 12 | 13 | /** 14 | * 新增记录 15 | * @param record {@link PrinterKitchenDocumentTypeRulesDO} 16 | * @return 自增主键 17 | */ 18 | Integer save(PrinterKitchenDocumentTypeRulesDO record); 19 | 20 | /** 21 | * 添加多条记录 22 | * @param documentTypeRulesList list 23 | * @return 受影响的条数 24 | */ 25 | Integer saveMultipleRecord (List documentTypeRulesList); 26 | 27 | /** 28 | * 根据 出票口ID 删除多条记录(软删除) 29 | * @param printerKitchenId 出票口ID 30 | * @return 受影响的条数 31 | */ 32 | Integer removeMultipleRecordByPrinterKitchenId (Integer printerKitchenId); 33 | 34 | /** 35 | * 查询 出票口 票据类型 36 | * @param printerKitchenId 出票口id 37 | * @return list 38 | */ 39 | List listPrinterKitchenDocumentTypeRulesByPrinterKitchenId(Integer printerKitchenId); 40 | 41 | /** 42 | * 根据主键查记录 43 | * @param id 主键 44 | * @return {@link PrinterKitchenDocumentTypeRulesDO} 45 | */ 46 | PrinterKitchenDocumentTypeRulesDO selectByPrimaryKey(Integer id); 47 | 48 | /** 49 | * 根据主键更新记录 50 | * @param record {@link PrinterKitchenDocumentTypeRulesDO} 51 | * @return 受影响的条数 52 | */ 53 | Integer updateByPrimaryKeySelective(PrinterKitchenDocumentTypeRulesDO record); 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/service/IPrinterKitchenGoodsRulesService.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.service; 2 | 3 | import com.zxcs.printtemplate.model.PrinterKitchenGoodsRulesDO; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 出票口配置打印菜品相关Service 9 | * Created by zfh on 2019/01/09 10 | */ 11 | public interface IPrinterKitchenGoodsRulesService { 12 | 13 | /** 14 | * 新增记录 15 | * @param record {@link PrinterKitchenGoodsRulesDO} 16 | * @return 自增主键 17 | */ 18 | Integer save(PrinterKitchenGoodsRulesDO record); 19 | 20 | /** 21 | * 新增多条记录 22 | * @param recordList list 23 | * @return 受影响的条数 24 | */ 25 | Integer saveMultipleRecord(List recordList); 26 | 27 | /** 28 | * 通过出票口ID 删除多条记录(软删除) 29 | * @param printerKitchenId 出票口ID 30 | * @return 受影响的条数 31 | */ 32 | Integer removeMultipleRecordByPrinterKitchenId (Integer printerKitchenId); 33 | 34 | /** 35 | * 查询出票口 配置的打印菜品 36 | * @param printerKitchenId 出票口id 37 | * @return list 38 | */ 39 | List listPrinterKitchenGoodsRulesByPrinterKitchenId(Integer printerKitchenId); 40 | 41 | /** 42 | * 根据主键查记录 43 | * @param id 主键 44 | * @return {@link PrinterKitchenGoodsRulesDO} 45 | */ 46 | PrinterKitchenGoodsRulesDO getByPrimaryKey(Integer id); 47 | 48 | /** 49 | * 根据主键更新记录 50 | * @param record {@link PrinterKitchenGoodsRulesDO} 51 | * @return 受影响的条数 52 | */ 53 | Integer updateByPrimaryKeySelective(PrinterKitchenGoodsRulesDO record); 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/service/IPrinterKitchenService.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.zxcs.printtemplate.model.PrinterKitchenDO; 5 | 6 | /** 7 | * 出票口相关Service 8 | * Created by zfh on 2019/01/09 9 | */ 10 | public interface IPrinterKitchenService { 11 | 12 | /** 13 | * 添加记录 14 | * @param record {@link PrinterKitchenDO} 15 | * @return 自增主键 16 | */ 17 | Integer save(PrinterKitchenDO record); 18 | 19 | /** 20 | * 根据主键查询 21 | * @param id 主键 22 | * @return {@link PrinterKitchenDO} 23 | */ 24 | PrinterKitchenDO getByPrimaryKey(Integer id); 25 | 26 | /** 27 | * 查询店铺下所有的出票口(未删除) 28 | * @param shopId 店铺id 29 | * @param page 页码 30 | * @param rows 页条数 31 | * @return {@link PageInfo} 32 | */ 33 | PageInfo listPrinterKitchenByShopId (Integer shopId, Integer page, Integer rows); 34 | 35 | /** 36 | * 根据主键有选择性的更新 37 | * @param record {@link PrinterKitchenDO} 38 | * @return 受影响的条数 39 | */ 40 | Integer updateByPrimaryKeySelective(PrinterKitchenDO record); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/service/IPrinterKitchenTableRulesService.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.service; 2 | 3 | import com.zxcs.printtemplate.model.PrinterKitchenTableRulesDO; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 出票口配置桌台区域相关Service 9 | * Created by zfh on 2019/01/09 10 | */ 11 | public interface IPrinterKitchenTableRulesService { 12 | 13 | /** 14 | * 新增记录 15 | * @param record {@link PrinterKitchenTableRulesDO} 16 | * @return 自增主键 17 | */ 18 | Integer save(PrinterKitchenTableRulesDO record); 19 | 20 | /** 21 | * 新增多条记录 22 | * @param recordList list 23 | * @return 受影响的条数 24 | */ 25 | Integer saveMultipleRecord (List recordList); 26 | 27 | /** 28 | * 根据出票口 删除多条记录(软删除) 29 | * @param printerKitchenId 出票口ID 30 | * @return 受影响的条数 31 | */ 32 | Integer removeMultipleRecordByPrinterKitchenId (Integer printerKitchenId); 33 | 34 | /** 35 | * 查询出票口配置的桌台区域 36 | * @param printerKitchenId 出票口id 37 | * @return list 38 | */ 39 | List listPrinterKitchenTableRulesByPrinterKitchenId(Integer printerKitchenId); 40 | 41 | /** 42 | * 根据主键查询记录 43 | * @param id 主键 44 | * @return {@link PrinterKitchenTableRulesDO} 45 | */ 46 | PrinterKitchenTableRulesDO getByPrimaryKey(Integer id); 47 | 48 | /** 49 | * 根据主键更新记录 50 | * @param record {@link PrinterKitchenTableRulesDO} 51 | * @return 受影响的条数 52 | */ 53 | Integer updateByPrimaryKeySelective(PrinterKitchenTableRulesDO record); 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/service/IPrinterSystemComponentService.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.service; 2 | 3 | import com.zxcs.printtemplate.model.PrinterSystemComponentDO; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 打印模板-系统组件相关Service 9 | * Created by zfh on 2018/12/27 10 | */ 11 | public interface IPrinterSystemComponentService { 12 | 13 | /** 14 | * 添加系统组件 15 | * @param systemComponent {@link PrinterSystemComponentDO} 16 | * @return 自增长主键 17 | */ 18 | Integer savePrinterSystemComponent (PrinterSystemComponentDO systemComponent); 19 | 20 | /** 21 | * 通过模板类型查询模板组件(系统组件) 22 | * @param templateType 模板类型 23 | * @return 组件列表 24 | */ 25 | List listPrinterSystemComponentByTemplateType(Integer templateType); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/service/IPrinterTemplateDocumentService.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.service; 2 | 3 | import com.zxcs.printtemplate.model.PrinterTemplateDocumentDO; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 打印模板-模板相关接口 9 | * Created by zfh on 2018/12/12 10 | */ 11 | public interface IPrinterTemplateDocumentService { 12 | 13 | /** 14 | * 添加模板 15 | * @param scShopPrinterTemplateDocument {@link PrinterTemplateDocumentDO} 16 | * @return 自增主键 17 | */ 18 | Integer saveShopPrinterTemplateDocument (PrinterTemplateDocumentDO scShopPrinterTemplateDocument); 19 | 20 | /** 21 | * 根据主键模板查询 22 | * @param id 主键 23 | * @return {@link PrinterTemplateDocumentDO} 24 | */ 25 | PrinterTemplateDocumentDO getShopPrinterTemplateDocumentByPrimaryId(Integer id); 26 | 27 | /** 28 | * 根据模板名称查询模板 29 | * @param name 模板名称 30 | * @return {@link PrinterTemplateDocumentDO} 31 | */ 32 | PrinterTemplateDocumentDO getShopPrinterTemplateDocumentByName(String name); 33 | 34 | /** 35 | * 根据主键更新模板 36 | * @param scShopPrinterTemplateDocument {@link PrinterTemplateDocumentDO} 37 | * @return 受影响的行数 38 | */ 39 | Integer updateShopPrinterTemplateDocumentByPrimaryId(PrinterTemplateDocumentDO scShopPrinterTemplateDocument); 40 | 41 | /** 42 | * 启用店铺模板 43 | * @param shopId 店铺id 44 | * @param documentType 票据类型 45 | * @param templateId 模板ID 46 | * @return 受影响条数 47 | */ 48 | Integer enableShopPrinterTemplate(Integer shopId, Integer documentType, Integer templateId); 49 | 50 | /** 51 | * 移除自定义模板(软删除) 52 | * @param id 主键 53 | * @return 受影响的条数 54 | */ 55 | Integer removeShopPrinterTemplateDocumentByPrimaryId(Integer id); 56 | 57 | /** 58 | * 查询店铺下模板列表和默认的模板 59 | * @param shopId 店铺id 60 | * @param documentType 票据类型 61 | * @return list 62 | */ 63 | List listPrinterTemplateDocumentByShopIdAndDocumentType (Integer shopId, Integer documentType); 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/service/IPrinterTemplateModuleService.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.service; 2 | 3 | import com.zxcs.printtemplate.model.PrinterTemplateModuleDO; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 打印模板-模块相关接口 9 | * Created by zfh on 2018/12/12 10 | */ 11 | public interface IPrinterTemplateModuleService { 12 | 13 | /** 14 | * 通过文档类型查询包含的模块 15 | * @param documentType 文档类型主键 16 | * @return list 17 | */ 18 | List listPrinterTemplateModuleByDocumentId (Integer documentType); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/service/impl/PrinterCustomComponentImpl.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.service.impl; 2 | 3 | import com.zxcs.printtemplate.dao.PrinterCustomComponentMapper; 4 | import com.zxcs.printtemplate.model.PrinterCustomComponentDO; 5 | import com.zxcs.printtemplate.service.IPrinterCustomComponentService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * 打印模板-自定义组件相关Service 13 | * Created by zfh on 2019/01/03 14 | */ 15 | @Service("printerCustomComponentService") 16 | public class PrinterCustomComponentImpl implements IPrinterCustomComponentService { 17 | 18 | @Autowired 19 | private PrinterCustomComponentMapper printerCustomComponentMapper; 20 | 21 | @Override 22 | public Integer saveMultiplePrinterCustomComponent(List shopPrinterCustomComponentList) { 23 | return printerCustomComponentMapper.insertMultiplePrinterCustomComponent(shopPrinterCustomComponentList); 24 | } 25 | 26 | @Override 27 | public Integer removeMultiplePrinterCustomComponentByTemplateId(Integer templateId) { 28 | return printerCustomComponentMapper.updateMultiplePrinterCustomComponentByTemplateId(templateId); 29 | } 30 | 31 | @Override 32 | public List listPrinterTemplateCustomComponentByTemplateId(Integer documentTemplateId) { 33 | return printerCustomComponentMapper.selectPrinterTemplateCustomComponentByTemplateId(documentTemplateId); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/service/impl/PrinterDeviceServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.service.impl; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import com.zxcs.printtemplate.dao.PrinterDeviceMapper; 6 | import com.zxcs.printtemplate.model.PrinterDeviceDO; 7 | import com.zxcs.printtemplate.service.IPrinterDeviceService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * 打印机相关Serice实现类 15 | * Created by zfh on 2019/01/09 16 | */ 17 | @Service("printerDeviceService") 18 | public class PrinterDeviceServiceImpl implements IPrinterDeviceService { 19 | 20 | @Autowired 21 | private PrinterDeviceMapper printerDeviceMapper; 22 | 23 | @Override 24 | public Integer save(PrinterDeviceDO record) { 25 | printerDeviceMapper.insert(record); 26 | return record.getId(); 27 | } 28 | 29 | @Override 30 | public PrinterDeviceDO getScShopPrinterDeviceByPrimaryKey(Integer id) { 31 | return printerDeviceMapper.selectByPrimaryKey(id); 32 | } 33 | 34 | @Override 35 | public PageInfo listPrinterDeviceByShopId(Integer shopId, Integer page, Integer rows) { 36 | PageHelper.startPage(page, rows); 37 | List printerDeviceList = printerDeviceMapper.selectPrinterDeviceListByShopId(shopId); 38 | return new PageInfo<>(printerDeviceList); 39 | } 40 | 41 | @Override 42 | public Integer updateByPrimaryKeySelective(PrinterDeviceDO record) { 43 | return printerDeviceMapper.updateByPrimaryKeySelective(record); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/service/impl/PrinterDocumentTypeServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.service.impl; 2 | 3 | import com.zxcs.printtemplate.dao.PrinterDocumentTypeMapper; 4 | import com.zxcs.printtemplate.model.PrinterDocumentTypeDO; 5 | import com.zxcs.printtemplate.service.IPrinterDocumentTypeService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * 打印模板实现类 13 | * Created by zfh on 2018/12/12 14 | */ 15 | @Service("printerDocumentTypeService") 16 | public class PrinterDocumentTypeServiceImpl implements IPrinterDocumentTypeService { 17 | 18 | @Autowired 19 | private PrinterDocumentTypeMapper printerDocumentTypeMapper; 20 | 21 | @Override 22 | public List listPrinterDocumentType() { 23 | return printerDocumentTypeMapper.selectPrinterDocumentType(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/service/impl/PrinterKitchenDocumentTypeRulesServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.service.impl; 2 | 3 | import com.zxcs.printtemplate.dao.PrinterKitchenDocumentTypeRulesMapper; 4 | import com.zxcs.printtemplate.model.PrinterKitchenDocumentTypeRulesDO; 5 | import com.zxcs.printtemplate.service.IPrinterKitchenDocumentTypeRulesService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * 出票口票据类型相关Service实现类 13 | * Created by zfh on 2019/01/09 14 | */ 15 | @Service("printerKitchenDocumentTypeRulesService") 16 | public class PrinterKitchenDocumentTypeRulesServiceImpl implements IPrinterKitchenDocumentTypeRulesService { 17 | 18 | @Autowired 19 | private PrinterKitchenDocumentTypeRulesMapper printerKitchenDocumentTypeRulesMapper; 20 | 21 | @Override 22 | public Integer save(PrinterKitchenDocumentTypeRulesDO record) { 23 | printerKitchenDocumentTypeRulesMapper.insert(record); 24 | return record.getId(); 25 | } 26 | 27 | @Override 28 | public Integer saveMultipleRecord(List recordList) { 29 | return printerKitchenDocumentTypeRulesMapper.insertMultipleRecord(recordList); 30 | } 31 | 32 | @Override 33 | public Integer removeMultipleRecordByPrinterKitchenId(Integer printerKitchenId) { 34 | return printerKitchenDocumentTypeRulesMapper.updateMultipleRecordByPrinterKitchenId(printerKitchenId); 35 | } 36 | 37 | @Override 38 | public List listPrinterKitchenDocumentTypeRulesByPrinterKitchenId(Integer printerKitchenId) { 39 | return printerKitchenDocumentTypeRulesMapper.selectPrinterKitchenDocumentTypeRulesListByPrinterKitchenId(printerKitchenId); 40 | } 41 | 42 | @Override 43 | public PrinterKitchenDocumentTypeRulesDO selectByPrimaryKey(Integer id) { 44 | return printerKitchenDocumentTypeRulesMapper.selectByPrimaryKey(id); 45 | } 46 | 47 | @Override 48 | public Integer updateByPrimaryKeySelective(PrinterKitchenDocumentTypeRulesDO record) { 49 | return printerKitchenDocumentTypeRulesMapper.updateByPrimaryKeySelective(record); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/service/impl/PrinterKitchenGoodsRulesServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.service.impl; 2 | 3 | import com.zxcs.printtemplate.dao.PrinterKitchenGoodsRulesMapper; 4 | import com.zxcs.printtemplate.model.PrinterKitchenGoodsRulesDO; 5 | import com.zxcs.printtemplate.service.IPrinterKitchenGoodsRulesService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * 出票口配置打印菜品相关Service实现类 13 | * Created by zfh on 2019/01/09 14 | */ 15 | @Service("printerKitchenGoodsRulesService") 16 | public class PrinterKitchenGoodsRulesServiceImpl implements IPrinterKitchenGoodsRulesService { 17 | 18 | @Autowired 19 | private PrinterKitchenGoodsRulesMapper printerKitchenGoodsRulesMapper; 20 | 21 | @Override 22 | public Integer save(PrinterKitchenGoodsRulesDO record) { 23 | printerKitchenGoodsRulesMapper.insert(record); 24 | return record.getId(); 25 | } 26 | 27 | @Override 28 | public Integer saveMultipleRecord(List recordList) { 29 | return printerKitchenGoodsRulesMapper.insertMultipleRecord(recordList); 30 | } 31 | 32 | @Override 33 | public Integer removeMultipleRecordByPrinterKitchenId(Integer printerKitchenId) { 34 | return printerKitchenGoodsRulesMapper.updateMultipleRecordByPrinterKitchenId(printerKitchenId); 35 | } 36 | 37 | @Override 38 | public List listPrinterKitchenGoodsRulesByPrinterKitchenId(Integer printerKitchenId) { 39 | return printerKitchenGoodsRulesMapper.selectPrinterKitchenGoodsRulesListByPrinterKitchenId(printerKitchenId); 40 | } 41 | 42 | @Override 43 | public PrinterKitchenGoodsRulesDO getByPrimaryKey(Integer id) { 44 | return printerKitchenGoodsRulesMapper.selectByPrimaryKey(id); 45 | } 46 | 47 | @Override 48 | public Integer updateByPrimaryKeySelective(PrinterKitchenGoodsRulesDO record) { 49 | return printerKitchenGoodsRulesMapper.updateByPrimaryKeySelective(record); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/service/impl/PrinterKitchenServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.service.impl; 2 | 3 | import com.github.pagehelper.PageHelper; 4 | import com.github.pagehelper.PageInfo; 5 | import com.zxcs.printtemplate.dao.PrinterKitchenMapper; 6 | import com.zxcs.printtemplate.model.PrinterKitchenDO; 7 | import com.zxcs.printtemplate.service.IPrinterKitchenService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * 出票口相关Service实现类 15 | * Created by zfh on 2019/01/09 16 | */ 17 | @Service("printerKitchenService") 18 | public class PrinterKitchenServiceImpl implements IPrinterKitchenService { 19 | 20 | @Autowired 21 | private PrinterKitchenMapper printerKitchenMapper; 22 | 23 | @Override 24 | public Integer save(PrinterKitchenDO record) { 25 | printerKitchenMapper.insert(record); 26 | return record.getId(); 27 | } 28 | 29 | @Override 30 | public PrinterKitchenDO getByPrimaryKey(Integer id) { 31 | return printerKitchenMapper.selectByPrimaryKey(id); 32 | } 33 | 34 | @Override 35 | public PageInfo listPrinterKitchenByShopId(Integer shopId, Integer page, Integer rows) { 36 | PageHelper.startPage(page, rows); 37 | List kitchenList = printerKitchenMapper.selectPrinterKitchenListByShopId(shopId); 38 | return new PageInfo<>(kitchenList); 39 | } 40 | 41 | @Override 42 | public Integer updateByPrimaryKeySelective(PrinterKitchenDO record) { 43 | return printerKitchenMapper.updateByPrimaryKeySelective(record); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/service/impl/PrinterKitchenTableRulesServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.service.impl; 2 | 3 | import com.zxcs.printtemplate.dao.PrinterKitchenTableRulesMapper; 4 | import com.zxcs.printtemplate.model.PrinterKitchenTableRulesDO; 5 | import com.zxcs.printtemplate.service.IPrinterKitchenTableRulesService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * 出票口配置桌台区域相关Service实现类 13 | * Created by zfh on 2019/01/09 14 | */ 15 | @Service("printerKitchenTableRulesService") 16 | public class PrinterKitchenTableRulesServiceImpl implements IPrinterKitchenTableRulesService { 17 | 18 | @Autowired 19 | private PrinterKitchenTableRulesMapper printerKitchenTableRulesMapper; 20 | 21 | @Override 22 | public Integer save(PrinterKitchenTableRulesDO record) { 23 | printerKitchenTableRulesMapper.insert(record); 24 | return record.getId(); 25 | } 26 | 27 | @Override 28 | public Integer saveMultipleRecord(List recordList) { 29 | return printerKitchenTableRulesMapper.insertMultipleRecord(recordList); 30 | } 31 | 32 | @Override 33 | public Integer removeMultipleRecordByPrinterKitchenId(Integer printerKitchenId) { 34 | return printerKitchenTableRulesMapper.updateMultipleRecordByPrinterKitchenId(printerKitchenId); 35 | } 36 | 37 | @Override 38 | public List listPrinterKitchenTableRulesByPrinterKitchenId(Integer printerKitchenId) { 39 | return printerKitchenTableRulesMapper.selectPrinterKitchenTableRulesListByPrinterKitchenId(printerKitchenId); 40 | } 41 | 42 | @Override 43 | public PrinterKitchenTableRulesDO getByPrimaryKey(Integer id) { 44 | return printerKitchenTableRulesMapper.selectByPrimaryKey(id); 45 | } 46 | 47 | @Override 48 | public Integer updateByPrimaryKeySelective(PrinterKitchenTableRulesDO record) { 49 | return printerKitchenTableRulesMapper.updateByPrimaryKeySelective(record); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/service/impl/PrinterSystemComponentServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.service.impl; 2 | 3 | import com.zxcs.printtemplate.dao.PrinterSystemComponentMapper; 4 | import com.zxcs.printtemplate.model.PrinterSystemComponentDO; 5 | import com.zxcs.printtemplate.service.IPrinterSystemComponentService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * 打印模板-系统组件实现类 13 | * Created by zfh on 2018/12/27 14 | */ 15 | @Service("printerSystemComponentService") 16 | public class PrinterSystemComponentServiceImpl implements IPrinterSystemComponentService { 17 | 18 | @Autowired 19 | private PrinterSystemComponentMapper printerSystemComponentMapper; 20 | 21 | @Override 22 | public Integer savePrinterSystemComponent(PrinterSystemComponentDO systemComponent) { 23 | return printerSystemComponentMapper.insertPrinterSystemComponent(systemComponent); 24 | } 25 | 26 | @Override 27 | public List listPrinterSystemComponentByTemplateType(Integer templateType) { 28 | return printerSystemComponentMapper.selectPrinterSystemComponentListByTemplateTypeId(templateType); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/service/impl/PrinterTemplateDocumentServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.service.impl; 2 | 3 | import com.zxcs.printtemplate.dao.PrinterTemplateDocumentMapper; 4 | import com.zxcs.printtemplate.model.PrinterTemplateDocumentDO; 5 | import com.zxcs.printtemplate.service.IPrinterTemplateDocumentService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * 打印模板-文档相关实现类 13 | * Created by zfh on 2018/12/12 14 | */ 15 | @Service("printerTemplateDocumentService") 16 | public class PrinterTemplateDocumentServiceImpl implements IPrinterTemplateDocumentService { 17 | 18 | @Autowired 19 | private PrinterTemplateDocumentMapper printerTemplateDocumentMapper; 20 | 21 | @Override 22 | public Integer saveShopPrinterTemplateDocument(PrinterTemplateDocumentDO scShopPrinterTemplateDocument) { 23 | printerTemplateDocumentMapper.insertShopPrinterTemplateDocument(scShopPrinterTemplateDocument); 24 | return scShopPrinterTemplateDocument.getId(); 25 | } 26 | 27 | @Override 28 | public PrinterTemplateDocumentDO getShopPrinterTemplateDocumentByPrimaryId(Integer id) { 29 | return printerTemplateDocumentMapper.selectShopPrinterTemplateDocumentByPrimaryId(id); 30 | } 31 | 32 | @Override 33 | public PrinterTemplateDocumentDO getShopPrinterTemplateDocumentByName(String name) { 34 | return printerTemplateDocumentMapper.selectShopPrinterTemplateDocumentByName(name); 35 | } 36 | 37 | @Override 38 | public Integer updateShopPrinterTemplateDocumentByPrimaryId(PrinterTemplateDocumentDO scShopPrinterTemplateDocument) { 39 | return printerTemplateDocumentMapper.updateShopPrinterTemplateDocumentByPrimaryId(scShopPrinterTemplateDocument); 40 | } 41 | 42 | @Override 43 | public Integer enableShopPrinterTemplate(Integer shopId, Integer documentType, Integer templateId) { 44 | // 禁用已启用的模板 45 | printerTemplateDocumentMapper.disableShopPrinterTemplateDocumentStatusByShopIdAndDocumentType(shopId, documentType); 46 | return printerTemplateDocumentMapper.updateShopPrinterTemplateDocumentStatusByShopIdAndDocumentType(templateId, 1); 47 | } 48 | 49 | @Override 50 | public Integer removeShopPrinterTemplateDocumentByPrimaryId(Integer id) { 51 | return printerTemplateDocumentMapper.updateShopPrinterTemplateDocumentStatusByPrimaryId(id); 52 | } 53 | 54 | @Override 55 | public List listPrinterTemplateDocumentByShopIdAndDocumentType(Integer shopId, Integer documentType) { 56 | return printerTemplateDocumentMapper.selectPrinterTemplateDocumentByShopIdAndDocumentType(shopId, documentType); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/service/impl/PrinterTemplateModuleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.service.impl; 2 | 3 | import com.zxcs.printtemplate.dao.PrinterTemplateModuleMapper; 4 | import com.zxcs.printtemplate.model.PrinterTemplateModuleDO; 5 | import com.zxcs.printtemplate.service.IPrinterTemplateModuleService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * 打印模板-模块接口实现类 13 | * Created by zfh on 2018/12/12 14 | */ 15 | @Service("printerTemplateModuleService") 16 | public class PrinterTemplateModuleServiceImpl implements IPrinterTemplateModuleService { 17 | 18 | @Autowired 19 | private PrinterTemplateModuleMapper printerTemplateModuleMapper; 20 | 21 | @Override 22 | public List listPrinterTemplateModuleByDocumentId(Integer documentType) { 23 | return printerTemplateModuleMapper.selectPrinterTemplateModuleByDocumentId(documentType); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/vo/PrinterDeviceVO.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.vo; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | import lombok.ToString; 6 | 7 | import java.util.Date; 8 | 9 | /** 10 | * 打印机详情VO 11 | * Created by zfh on 2019/01/09 12 | */ 13 | @Data 14 | @ToString 15 | public class PrinterDeviceVO { 16 | 17 | /** 18 | * 主键 19 | */ 20 | private Integer id; 21 | 22 | /** 23 | * 名称 24 | */ 25 | private String deviceName; 26 | 27 | /** 28 | * 打印机类型 29 | */ 30 | private Integer printerDeviceType; 31 | 32 | /** 33 | * ip地址 34 | */ 35 | private String address; 36 | 37 | /** 38 | * 创建人姓名 39 | */ 40 | private String creatorName; 41 | 42 | /** 43 | * 更新人姓名 44 | */ 45 | private String updatorName; 46 | 47 | /** 48 | * 添加时间 49 | */ 50 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 51 | private Date createTime; 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/vo/PrinterDocumentTypeVO.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.vo; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | /** 7 | * 打印文档类型 视图VO 8 | * Created by zfh on 2018/12/12 9 | */ 10 | @Data 11 | @ToString 12 | public class PrinterDocumentTypeVO { 13 | 14 | /** 15 | * 类型ID 16 | */ 17 | private Integer id; 18 | 19 | /** 20 | * 类型名称 21 | */ 22 | private String name; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/vo/PrinterKitchenIntegrationVO.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.vo; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 出票口详情视图 10 | * Created by zfh on 2019/01/09 11 | */ 12 | @Data 13 | @ToString 14 | public class PrinterKitchenIntegrationVO { 15 | 16 | /** 17 | * 出票口ID 18 | */ 19 | private Integer id; 20 | 21 | /** 22 | * 出票口名称 23 | */ 24 | private String name; 25 | 26 | /** 27 | * 打印机ID 28 | */ 29 | private Integer printerDeviceId; 30 | 31 | /** 32 | * 店铺ID 33 | */ 34 | private Integer shopId; 35 | 36 | /** 37 | * 出票口票据类型 38 | */ 39 | private List documentTypeRules; 40 | 41 | /** 42 | * 是否配置桌台区域:0-未配置 1-配置 43 | */ 44 | private Integer table; 45 | 46 | /** 47 | * 是否配置打印的菜品:0-未配置 1-配置 48 | */ 49 | private Integer goods; 50 | 51 | /** 52 | * 出票口桌台区域 53 | */ 54 | private List tableRules; 55 | 56 | /** 57 | * 出票口配置的商品 58 | */ 59 | private List goodsRules; 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/vo/PrinterKitchenVO.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.vo; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | import lombok.ToString; 6 | 7 | import java.util.Date; 8 | 9 | /** 10 | * 出票口视图对象 11 | * Created by zfh on 2019/01/09 12 | */ 13 | @Data 14 | @ToString 15 | public class PrinterKitchenVO { 16 | 17 | /** 18 | * 主键 19 | */ 20 | private Integer id; 21 | 22 | /** 23 | * 出票口名称 24 | */ 25 | private String name; 26 | 27 | /** 28 | * 打印机id 29 | */ 30 | private Integer printerDeviceId; 31 | 32 | /** 33 | * 创建人姓名 34 | */ 35 | private String creatorName; 36 | 37 | /** 38 | * 更新人姓名 39 | */ 40 | private String updatorName; 41 | 42 | /** 43 | * 添加时间 44 | */ 45 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 46 | private Date createTime; 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/vo/PrinterTemplateDocumentVO.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.vo; 2 | 3 | import lombok.Data; 4 | import lombok.ToString; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 打印模板列表 视图VO 10 | * Created by zfh on 2018/12/27 11 | */ 12 | @Data 13 | @ToString 14 | public class PrinterTemplateDocumentVO { 15 | 16 | /** 17 | * 模板id 18 | */ 19 | private Integer id; 20 | 21 | /** 22 | * 模板类型 23 | */ 24 | private Integer documentType; 25 | 26 | /** 27 | * 模板名称 28 | */ 29 | private String name; 30 | 31 | /** 32 | * 模板状态:1-启用 2-禁用 33 | */ 34 | private Integer status; 35 | 36 | /** 37 | * 模板默认表示 0-否 1-是 38 | */ 39 | private Integer defaultTemplet; 40 | 41 | /** 42 | * 票据预览图 43 | */ 44 | private String url; 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/zxcs/printtemplate/vo/Response.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.vo; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import lombok.ToString; 8 | 9 | /** 10 | * 统一请求响应 11 | */ 12 | @Data 13 | @ToString 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | @JsonInclude(JsonInclude.Include.NON_NULL) 17 | public class Response { 18 | 19 | private String errCode; 20 | 21 | private String errMsg; 22 | 23 | private Object data; 24 | 25 | public static Response newInstance() { 26 | return new Response(); 27 | } 28 | 29 | public Response setErrCode(String errCode) { 30 | this.errCode = errCode; 31 | return this; 32 | } 33 | 34 | public Response setErrMsg(String errMsg) { 35 | this.errMsg = errMsg; 36 | return this; 37 | } 38 | 39 | public Response setData(Object data) { 40 | this.data = data; 41 | return this; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | 4 | spring: 5 | datasource: 6 | type: com.alibaba.druid.pool.DruidDataSource 7 | druid: 8 | url: jdbc:mysql://127.0.0.1:3306/print_template?useUnicode=true&characterEncoding=utf-8&useSSL=false 9 | username: root 10 | password: 123456 11 | initial-size: 1 12 | min-idle: 1 13 | max-active: 20 14 | max-wait: 60000 15 | time-between-eviction-runs-millis: 60000 16 | min-evictable-idle-time-millis: 300000 17 | validation-query: SELECT 'x' 18 | test-while-idle: true 19 | test-on-borrow: false 20 | test-on-return: false 21 | pool-prepared-statements: true 22 | max-pool-prepared-statement-per-connection-size: 20 23 | 24 | # mybatis整合 25 | mybatis: 26 | config-location: classpath:mybatis-config.xml 27 | mapper-locations: classpath:mapper/*.xml 28 | -------------------------------------------------------------------------------- /src/main/resources/mapper/PrinterCustomComponentMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | id, document_template_id, system_component_id, value_style, is_delete 37 | 38 | 39 | 40 | INSERT INTO printer_custom_component 41 | ( 42 | document_template_id, 43 | system_component_id, 44 | value_style 45 | ) 46 | VALUES 47 | 48 | ( 49 | #{item.documentTemplateId}, 50 | #{item.systemComponentId}, 51 | #{item.valueStyle} 52 | ) 53 | 54 | 55 | 56 | 57 | UPDATE printer_custom_component 58 | SET is_delete = 1 59 | WHERE document_template_id = #{documentTemplateId} 60 | 61 | 62 | 88 | -------------------------------------------------------------------------------- /src/main/resources/mapper/PrinterDeviceMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | id, device_name, printer_device_type, address, is_delete, shop_id, creator_id, creator_name, 21 | updator_id, updator_name, create_time, update_time 22 | 23 | 24 | 30 | 31 | 38 | 39 | 40 | INSERT INTO printer_device 41 | ( 42 | device_name, printer_device_type, address, is_delete, shop_id, creator_id, creator_name, 43 | updator_id, updator_name, create_time, update_time 44 | ) 45 | VALUES 46 | ( 47 | #{deviceName}, #{printerDeviceType}, #{address}, #{delete}, #{shopId}, #{creatorId}, #{creatorName}, 48 | #{updatorId}, #{updatorName}, now(), now() 49 | ) 50 | 51 | 52 | 53 | update printer_device 54 | 55 | 56 | device_name = #{deviceName,jdbcType=VARCHAR}, 57 | 58 | 59 | printer_device_type = #{printerDeviceType,jdbcType=TINYINT}, 60 | 61 | 62 | address = #{address,jdbcType=VARCHAR}, 63 | 64 | 65 | is_delete = #{delete,jdbcType=TINYINT}, 66 | 67 | 68 | shop_id = #{shopId,jdbcType=INTEGER}, 69 | 70 | 71 | updator_id = #{updatorId,jdbcType=INTEGER}, 72 | 73 | 74 | updator_name = #{updatorName,jdbcType=VARCHAR}, 75 | 76 | update_time = now() 77 | 78 | where id = #{id,jdbcType=INTEGER} 79 | 80 | -------------------------------------------------------------------------------- /src/main/resources/mapper/PrinterDocumentTypeMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | id, `name`, status, create_time, update_time 14 | 15 | 16 | 22 | 23 | 29 | 30 | 31 | UPDATE printer_document_type 32 | 33 | `name` = #{name}, 34 | status = #{status}, 35 | update_time = #{updateTime} 36 | 37 | WHERE id = #{id} 38 | 39 | -------------------------------------------------------------------------------- /src/main/resources/mapper/PrinterKitchenDocumentTypeRulesMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | id, printer_kitchen_id, document_type_id, `number`, printer_type, is_delete, create_time, update_time 17 | 18 | 19 | 25 | 26 | 33 | 34 | 35 | insert into printer_kitchen_document_type_rules 36 | ( 37 | printer_kitchen_id, document_type_id, 38 | `number`, printer_type, is_delete, create_time, 39 | update_time 40 | ) 41 | values 42 | ( 43 | #{printerKitchenId,jdbcType=INTEGER}, #{documentTypeId,jdbcType=INTEGER}, 44 | #{number,jdbcType=TINYINT}, #{printerType,jdbcType=TINYINT}, #{delete, jdbcType=TINYINT}, 45 | now(), 46 | now() 47 | ) 48 | 49 | 50 | 51 | INSERT INTO printer_kitchen_document_type_rules 52 | ( 53 | printer_kitchen_id, document_type_id, 54 | `number`, printer_type, is_delete, create_time, 55 | update_time 56 | ) 57 | VALUES 58 | 59 | ( 60 | #{item.printerKitchenId}, 61 | #{item.documentTypeId}, 62 | #{item.number}, 63 | #{item.printerType}, 64 | 0, 65 | now(), 66 | now() 67 | ) 68 | 69 | 70 | 71 | 72 | UPDATE printer_kitchen_document_type_rules 73 | SET is_delete = 1 74 | WHERE printer_kitchen_id = #{printerKitchenId} 75 | 76 | 77 | 78 | update printer_kitchen_document_type_rules 79 | 80 | 81 | printer_kitchen_id = #{printerKitchenId,jdbcType=INTEGER}, 82 | 83 | 84 | document_type_id = #{documentTypeId,jdbcType=INTEGER}, 85 | 86 | 87 | `number` = #{number,jdbcType=TINYINT}, 88 | 89 | 90 | printer_type = #{printerType,jdbcType=TINYINT}, 91 | 92 | 93 | is_delete = #{delete, jdbcType=TINYINT}, 94 | 95 | update_time = now() 96 | 97 | where id = #{id,jdbcType=INTEGER} 98 | 99 | -------------------------------------------------------------------------------- /src/main/resources/mapper/PrinterKitchenGoodsRulesMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | id, printer_kitchen_id, goods_id, stock_id, is_delete, create_time, update_time 16 | 17 | 18 | 24 | 25 | 32 | 33 | 34 | insert into printer_kitchen_goods_rules 35 | ( 36 | printer_kitchen_id, goods_id, 37 | stock_id, is_delete, create_time, update_time 38 | ) 39 | values 40 | ( 41 | #{printerKitchenId,jdbcType=INTEGER}, #{goodsId,jdbcType=INTEGER}, 42 | #{stockId,jdbcType=INTEGER}, #{delete, jdbcType=TINYINT}, now(), now() 43 | ) 44 | 45 | 46 | 47 | INSERT INTO printer_kitchen_goods_rules 48 | ( 49 | printer_kitchen_id, goods_id, 50 | stock_id, is_delete, create_time, update_time 51 | ) 52 | values 53 | 54 | ( 55 | #{item.printerKitchenId}, 56 | #{item.goodsId}, 57 | #{item.stockId}, 58 | 0, 59 | now(), 60 | now() 61 | ) 62 | 63 | 64 | 65 | 66 | UPDATE printer_kitchen_goods_rules 67 | SET is_delete = 1 68 | WHERE printer_kitchen_id = #{printerKitchenId} 69 | 70 | 71 | 72 | update printer_kitchen_goods_rules 73 | 74 | 75 | printer_kitchen_id = #{printerKitchenId,jdbcType=INTEGER}, 76 | 77 | 78 | goods_id = #{goodsId,jdbcType=INTEGER}, 79 | 80 | 81 | stock_id = #{stockId,jdbcType=INTEGER}, 82 | 83 | 84 | is_delete = #{delete,jdbcType=TINYINT}, 85 | 86 | update_time = now() 87 | 88 | where id = #{id,jdbcType=INTEGER} 89 | 90 | -------------------------------------------------------------------------------- /src/main/resources/mapper/PrinterKitchenMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | id, `name`, printer_device_id, is_table, is_goods, is_delete, shop_id, creator_id, 22 | creator_name, updator_id, updator_name, create_time, update_time 23 | 24 | 25 | 31 | 32 | 39 | 40 | 41 | insert into printer_kitchen 42 | ( 43 | `name`, printer_device_id, 44 | is_table, is_goods, is_delete, 45 | shop_id, creator_id, creator_name, 46 | updator_id, updator_name, create_time, 47 | update_time 48 | ) 49 | values 50 | ( 51 | #{name,jdbcType=VARCHAR}, #{printerDeviceId,jdbcType=INTEGER}, 52 | #{table,jdbcType=TINYINT}, #{goods,jdbcType=TINYINT}, #{delete,jdbcType=TINYINT}, 53 | #{shopId,jdbcType=INTEGER}, #{creatorId,jdbcType=INTEGER}, #{creatorName,jdbcType=VARCHAR}, 54 | #{updatorId,jdbcType=INTEGER}, #{updatorName,jdbcType=VARCHAR}, 55 | now(), 56 | now() 57 | ) 58 | 59 | 60 | 61 | update printer_kitchen 62 | 63 | 64 | name = #{name,jdbcType=VARCHAR}, 65 | 66 | 67 | printer_device_id = #{printerDeviceId,jdbcType=INTEGER}, 68 | 69 | 70 | is_table = #{table,jdbcType=TINYINT}, 71 | 72 | 73 | is_goods = #{goods,jdbcType=TINYINT}, 74 | 75 | 76 | is_delete = #{delete,jdbcType=TINYINT}, 77 | 78 | 79 | shop_id = #{shopId,jdbcType=INTEGER}, 80 | 81 | 82 | updator_id = #{updatorId,jdbcType=INTEGER}, 83 | 84 | 85 | updator_name = #{updatorName,jdbcType=VARCHAR}, 86 | 87 | update_time = now() 88 | 89 | where id = #{id,jdbcType=INTEGER} 90 | 91 | -------------------------------------------------------------------------------- /src/main/resources/mapper/PrinterKitchenTableRulesMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | id, printer_kitchen_id, table_id, is_delete, create_time, update_time 15 | 16 | 17 | 23 | 24 | 31 | 32 | 33 | insert into printer_kitchen_table_rules 34 | ( 35 | printer_kitchen_id, table_id, 36 | is_delete, create_time, update_time 37 | ) 38 | values 39 | ( 40 | #{printerKitchenId,jdbcType=INTEGER}, #{tableId,jdbcType=INTEGER}, 41 | #{delete,jdbcType=TINYINT}, 42 | now(), 43 | now() 44 | ) 45 | 46 | 47 | 48 | insert into printer_kitchen_table_rules 49 | ( 50 | printer_kitchen_id, table_id, 51 | is_delete, create_time, update_time 52 | ) 53 | values 54 | 55 | ( 56 | #{item.printerKitchenId}, 57 | #{item.tableId}, 58 | 0, 59 | now(), 60 | now() 61 | ) 62 | 63 | 64 | 65 | 66 | UPDATE printer_kitchen_table_rules 67 | SET is_delete = 1 68 | WHERE printer_kitchen_id = #{printerKitchenId} 69 | 70 | 71 | 72 | update printer_kitchen_table_rules 73 | 74 | 75 | printer_kitchen_id = #{printerKitchenId,jdbcType=INTEGER}, 76 | 77 | 78 | table_id = #{tableId,jdbcType=INTEGER}, 79 | 80 | 81 | is_delete = #{delete,jdbcType=TINYINT}, 82 | 83 | update_time = now() 84 | 85 | where id = #{id,jdbcType=INTEGER} 86 | 87 | -------------------------------------------------------------------------------- /src/main/resources/mapper/PrinterSystemComponentMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | id, module_id, parent_id, ref_id, label, `value`, value_style, placeholder, `type`, row, `column`, width, sort, is_enable, create_time, update_time 25 | 26 | 27 | 28 | INSERT INTO printer_system_component 29 | ( 30 | module_id, parentId, ref_id, label, `value`, value_style, placeholder, `type`, row, `column`, width, sort, is_enable, create_time, update_time 31 | ) 32 | VALUES(#{moduleId}, #{parentId}, #{refId}, #{label}, #{value}, #{valueStyle}, #{placeholder}, #{type}, #{row}, #{column}, #{width}, #{sort}, #{enable}, now(), now()) 33 | 34 | 35 | 46 | -------------------------------------------------------------------------------- /src/main/resources/mapper/PrinterTemplateDocumentMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | id, `name`, document_type, url, status, shop_id, creator_id, creator_name, create_time, update_time 19 | 20 | 21 | 22 | INSERT INTO printer_template_document 23 | ( 24 | `name`, document_type, url, status, shop_id, creator_id, creator_name, create_time, update_time 25 | ) 26 | VALUES (#{name}, #{documentType}, #{url}, #{status}, #{shopId}, #{creatorId}, #{creatorName}, now(), now()) 27 | 28 | 29 | 35 | 36 | 43 | 44 | 45 | UPDATE printer_template_document 46 | 47 | `name` = #{name}, 48 | document_type = #{documentType}, 49 | url = #{url}, 50 | status = #{status}, 51 | shop_id = #{shopId}, 52 | update_time = now() 53 | 54 | WHERE id = #{id} 55 | 56 | 57 | 58 | UPDATE printer_template_document 59 | SET status = 0 60 | WHERE id = #{id} 61 | 62 | 63 | 64 | UPDATE printer_template_document 65 | SET status = 2 66 | WHERE shop_id = #{shopId} 67 | AND status = 1 68 | AND document_type = #{documentType} 69 | 70 | 71 | 72 | UPDATE printer_template_document 73 | SET status = #{status} 74 | WHERE id = #{templateId} 75 | 76 | 77 | 85 | -------------------------------------------------------------------------------- /src/main/resources/mapper/PrinterTemplateModuleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | id, module_name, module_describe, document_type, sort, create_time, update_time 16 | 17 | 18 | 25 | -------------------------------------------------------------------------------- /src/main/resources/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/test/java/com/zxcs/printtemplate/MainTest.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alibaba.fastjson.JSONArray; 5 | import com.alibaba.fastjson.JSONObject; 6 | import com.zxcs.printtemplate.service.IPrinterCustomComponentService; 7 | import com.zxcs.printtemplate.service.IPrinterKitchenService; 8 | import com.zxcs.printtemplate.model.PrinterCustomComponentDO; 9 | import com.zxcs.printtemplate.model.PrinterKitchenDO; 10 | import com.zxcs.printtemplate.model.PrinterSystemComponentDO; 11 | import com.zxcs.printtemplate.vo.PrinterKitchenVO; 12 | import org.apache.commons.lang3.StringUtils; 13 | import org.junit.Test; 14 | import org.junit.runner.RunWith; 15 | import org.slf4j.Logger; 16 | import org.slf4j.LoggerFactory; 17 | import org.springframework.beans.BeanUtils; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | import org.springframework.boot.test.context.SpringBootTest; 20 | import org.springframework.test.context.junit4.SpringRunner; 21 | 22 | import java.io.FileReader; 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | 26 | /** 27 | * 测试类 28 | * Created by zfh on 2018/12/28 29 | */ 30 | @RunWith(SpringRunner.class) 31 | @SpringBootTest 32 | public class MainTest { 33 | 34 | private static final Logger logger = LoggerFactory.getLogger(MainTest.class); 35 | 36 | @Autowired 37 | private IPrinterCustomComponentService scOperationPrinterCustomComponentService; 38 | 39 | @Autowired 40 | private IPrinterKitchenService scOperationPrinterKitchenService; 41 | 42 | @Test 43 | public void testConvertToVO () { 44 | PrinterKitchenDO printerKitchen = scOperationPrinterKitchenService.getByPrimaryKey(1); 45 | PrinterKitchenVO printerKitchenVO = new PrinterKitchenVO(); 46 | BeanUtils.copyProperties(printerKitchen, printerKitchenVO); 47 | System.out.println("printerKitchenVO: " + printerKitchenVO); 48 | } 49 | 50 | @Test 51 | public void testFileStream () { 52 | try { 53 | long startTimeStamp = System.currentTimeMillis(); 54 | 55 | StringBuilder stringBuilder = new StringBuilder(); 56 | FileReader fileReader = new FileReader("F:\\bulb\\print-template\\data\\save-custom.json"); 57 | char[] chars = new char[1024]; 58 | int length; 59 | while ((length = fileReader.read(chars)) != -1) { 60 | stringBuilder.append(chars, 0, length); 61 | } 62 | 63 | JSONObject jsonObject = JSONObject.parseObject(stringBuilder.toString()); 64 | System.out.println("documentType: " + jsonObject.getInteger("documentType")); 65 | System.out.println("name:" + jsonObject.getString("name")); 66 | System.out.println("baseTemplet: " + jsonObject.getInteger("baseTemplet")); 67 | System.out.println("url:" + jsonObject.getString("url")); 68 | 69 | Integer documentId = 10; 70 | 71 | JSONArray modules = jsonObject.getJSONArray("modules"); 72 | List customComponentList = new ArrayList<>(30); 73 | for (Object item : modules) { 74 | JSONArray rows = ((JSONObject) item).getJSONArray("rows"); 75 | for (Object row : rows) { 76 | JSONArray components = ((JSONObject) row).getJSONArray("components"); 77 | JSONObject o = (JSONObject) components.get(0); 78 | 79 | String componentStr = o.getString("component"); 80 | if (StringUtils.isBlank(componentStr)) { 81 | convertCustomComponent(documentId, JSONObject.toJSONString(components.get(0)), customComponentList); 82 | continue; 83 | } else { 84 | convertCustomComponent(documentId, componentStr, customComponentList); 85 | } 86 | String tableTitleStr = o.getString("tableTitle"); 87 | if (StringUtils.isNotBlank(tableTitleStr)) { 88 | convertCustomComponent(documentId, tableTitleStr, customComponentList); 89 | } 90 | String categoryStr = o.getString("category"); 91 | if (StringUtils.isNotBlank(categoryStr)) { 92 | convertCustomComponent(documentId, categoryStr, customComponentList); 93 | } 94 | String theadStr = o.getString("thead"); 95 | if (StringUtils.isNotBlank(theadStr)) { 96 | JSONObject thead = JSON.parseObject(theadStr); 97 | JSONObject tableRowSet = (JSONObject) thead.get("tableRowSet"); 98 | JSONArray columnSet = tableRowSet.getJSONArray("columnSet"); 99 | for (Object columnItem : columnSet) { 100 | convertCustomComponent(documentId, JSONObject.toJSONString(columnItem), customComponentList); 101 | } 102 | } 103 | String tbodyStr = o.getString("tbody"); 104 | if (StringUtils.isNotBlank(tbodyStr)) { 105 | JSONObject tbody = JSON.parseObject(tbodyStr); 106 | JSONArray tableRowSet = tbody.getJSONArray("tableRowSet"); 107 | for (Object tableRowSetItem : tableRowSet) { 108 | JSONArray columnSet = ((JSONObject) tableRowSetItem).getJSONArray("columnSet"); 109 | for (Object columnSetItem : columnSet) { 110 | convertCustomComponent(documentId, JSONObject.toJSONString(columnSetItem), customComponentList); 111 | } 112 | } 113 | } 114 | } 115 | } 116 | 117 | System.out.println("size: " + customComponentList.size()); 118 | System.out.println("JSON: " + JSON.toJSON(customComponentList)); 119 | Integer integer = scOperationPrinterCustomComponentService.saveMultiplePrinterCustomComponent(customComponentList); 120 | System.out.println("受影响的条数: " + integer); 121 | System.out.println("耗时:" + (System.currentTimeMillis() - startTimeStamp) + "ms"); 122 | } catch (Exception e) { 123 | e.printStackTrace(); 124 | } 125 | } 126 | 127 | /** 128 | * 转换自定义组件 129 | * @param documentId 模板id 130 | * @param componentStr 系统组件 131 | * @param customComponentList 自定义组件列表 132 | */ 133 | private void convertCustomComponent (Integer documentId, String componentStr, List customComponentList) { 134 | PrinterSystemComponentDO systemComponent = JSONObject.parseObject(componentStr, PrinterSystemComponentDO.class); 135 | PrinterCustomComponentDO customComponent = new PrinterCustomComponentDO(); 136 | customComponent.setDocumentTemplateId(documentId); 137 | customComponent.setSystemComponentId(systemComponent.getId()); 138 | customComponent.setValueStyle(systemComponent.getValueStyle()); 139 | customComponentList.add(customComponent); 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /src/test/java/com/zxcs/printtemplate/api/IScOperationPrinterCustomComponentServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.api; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.zxcs.printtemplate.model.PrinterCustomComponentDO; 5 | import com.zxcs.printtemplate.service.IPrinterCustomComponentService; 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | import org.springframework.transaction.annotation.Transactional; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | @RunWith(SpringRunner.class) 18 | @SpringBootTest 19 | public class IScOperationPrinterCustomComponentServiceTest { 20 | 21 | @Autowired 22 | private IPrinterCustomComponentService scOperationPrinterCustomComponentService; 23 | 24 | @Transactional 25 | @Test 26 | public void saveMultiplePrinterCustomComponent() { 27 | List customComponentList = new ArrayList(10); 28 | for (int i = 0; i < 3; i++) { 29 | PrinterCustomComponentDO customComponent = new PrinterCustomComponentDO(); 30 | customComponent.setDocumentTemplateId(1); 31 | customComponent.setSystemComponentId(i); 32 | customComponent.setValueStyle("css"); 33 | customComponentList.add(customComponent); 34 | } 35 | Integer count = scOperationPrinterCustomComponentService.saveMultiplePrinterCustomComponent(customComponentList); 36 | System.out.println("count:" + count); 37 | } 38 | 39 | @Test 40 | public void listPrinterTemplateCustomComponentByTemplateId() { 41 | List scShopPrinterCustomComponents = scOperationPrinterCustomComponentService.listPrinterTemplateCustomComponentByTemplateId(1); 42 | System.out.println("json: " + JSON.toJSON(scShopPrinterCustomComponents)); 43 | Assert.assertEquals(scShopPrinterCustomComponents.size(), 151); 44 | } 45 | } -------------------------------------------------------------------------------- /src/test/java/com/zxcs/printtemplate/api/IScOperationPrinterDeviceServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.api; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alibaba.fastjson.JSONObject; 5 | import com.github.pagehelper.PageInfo; 6 | import com.zxcs.printtemplate.model.PrinterDeviceDO; 7 | import com.zxcs.printtemplate.service.IPrinterDeviceService; 8 | import org.junit.Assert; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.boot.test.context.SpringBootTest; 13 | import org.springframework.test.context.junit4.SpringRunner; 14 | import org.springframework.transaction.annotation.Transactional; 15 | 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest 18 | public class IScOperationPrinterDeviceServiceTest { 19 | 20 | @Autowired 21 | private IPrinterDeviceService scOperationPrinterDeviceService; 22 | 23 | @Transactional 24 | @Test 25 | public void save() { 26 | PrinterDeviceDO scShopPrinterDevice = new PrinterDeviceDO(); 27 | scShopPrinterDevice.setDeviceName("一号机"); 28 | scShopPrinterDevice.setPrinterDeviceType(1); 29 | scShopPrinterDevice.setAddress("127.0.0.3"); 30 | scShopPrinterDevice.setDelete(0); 31 | scShopPrinterDevice.setShopId(288); 32 | scShopPrinterDevice.setCreatorId(1); 33 | scShopPrinterDevice.setCreatorName("dazuo"); 34 | scShopPrinterDevice.setUpdatorId(1); 35 | scShopPrinterDevice.setUpdatorName("dazuo"); 36 | Integer id = scOperationPrinterDeviceService.save(scShopPrinterDevice); 37 | Assert.assertTrue(id > 0); 38 | } 39 | 40 | @Test 41 | public void getScShopPrinterDeviceByPrimaryKey() { 42 | PrinterDeviceDO printerDevice = scOperationPrinterDeviceService.getScShopPrinterDeviceByPrimaryKey(1); 43 | System.out.println(JSONObject.toJSON(printerDevice)); 44 | Assert.assertNotNull(printerDevice); 45 | } 46 | 47 | @Test 48 | public void listPrinterDeviceByShopId () { 49 | PageInfo pageInfo = scOperationPrinterDeviceService.listPrinterDeviceByShopId(288, 2, 1); 50 | System.out.println(JSON.toJSON(pageInfo)); 51 | Assert.assertEquals(pageInfo.getList().size(), 1); 52 | Assert.assertEquals(pageInfo.getList().get(0).getAddress(), "127.0.0.3"); 53 | } 54 | 55 | @Transactional 56 | @Test 57 | public void updateByPrimaryKeySelective() { 58 | PrinterDeviceDO printerDevice = scOperationPrinterDeviceService.getScShopPrinterDeviceByPrimaryKey(1); 59 | printerDevice.setDelete(1); 60 | Integer integer = scOperationPrinterDeviceService.updateByPrimaryKeySelective(printerDevice); 61 | Assert.assertTrue(integer > 0); 62 | } 63 | } -------------------------------------------------------------------------------- /src/test/java/com/zxcs/printtemplate/api/IScOperationPrinterDocumentTypeServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.api; 2 | 3 | import com.zxcs.printtemplate.model.PrinterDocumentTypeDO; 4 | import com.zxcs.printtemplate.service.impl.PrinterDocumentTypeServiceImpl; 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | 12 | import java.util.List; 13 | 14 | @RunWith(SpringRunner.class) 15 | @SpringBootTest 16 | public class IScOperationPrinterDocumentTypeServiceTest { 17 | 18 | @Autowired 19 | private PrinterDocumentTypeServiceImpl scOperationPrinterDocumentTypeService; 20 | 21 | @Test 22 | public void getPrinterDocumentTypeByPrimaryId() { 23 | 24 | } 25 | 26 | @Test 27 | public void listPrinterDocumentType() { 28 | List typeList = scOperationPrinterDocumentTypeService.listPrinterDocumentType(); 29 | Assert.assertEquals(typeList.size(), 6); 30 | } 31 | 32 | @Test 33 | public void updatePrinterDocumentType() { 34 | } 35 | } -------------------------------------------------------------------------------- /src/test/java/com/zxcs/printtemplate/api/IScOperationPrinterKitchenDocumentTypeRulesServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.api; 2 | 3 | import com.zxcs.printtemplate.model.PrinterKitchenDocumentTypeRulesDO; 4 | import com.zxcs.printtemplate.service.IPrinterKitchenDocumentTypeRulesService; 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest 18 | public class IScOperationPrinterKitchenDocumentTypeRulesServiceTest { 19 | 20 | @Autowired 21 | private IPrinterKitchenDocumentTypeRulesService scOperationPrinterKitchenDocumentTypeRulesService; 22 | 23 | @Transactional 24 | @Test 25 | public void save() { 26 | PrinterKitchenDocumentTypeRulesDO documentTypeRules = new PrinterKitchenDocumentTypeRulesDO(); 27 | documentTypeRules.setPrinterKitchenId(1); 28 | documentTypeRules.setDocumentTypeId(1); 29 | documentTypeRules.setNumber(1); 30 | documentTypeRules.setPrinterType(1); 31 | documentTypeRules.setDelete(0); 32 | Integer affected = scOperationPrinterKitchenDocumentTypeRulesService.save(documentTypeRules); 33 | Assert.assertTrue(affected > 0); 34 | } 35 | 36 | @Transactional 37 | @Test 38 | public void saveMultipleRecord() { 39 | List documentTypeRulesList = new ArrayList<>(10); 40 | for (int i = 0; i < 5; i++) { 41 | PrinterKitchenDocumentTypeRulesDO documentTypeRules = new PrinterKitchenDocumentTypeRulesDO(); 42 | documentTypeRules.setPrinterKitchenId(i); 43 | documentTypeRules.setDocumentTypeId(i); 44 | documentTypeRules.setNumber(1); 45 | documentTypeRules.setPrinterType(i); 46 | documentTypeRules.setDelete(0); 47 | documentTypeRulesList.add(documentTypeRules); 48 | } 49 | Integer affected = scOperationPrinterKitchenDocumentTypeRulesService.saveMultipleRecord(documentTypeRulesList); 50 | Assert.assertTrue(affected > 5); 51 | } 52 | 53 | @Test 54 | public void listPrinterKitchenDocumentTypeRulesByPrinterKitchenId() { 55 | List documentTypeRulesList = scOperationPrinterKitchenDocumentTypeRulesService.listPrinterKitchenDocumentTypeRulesByPrinterKitchenId(1); 56 | Assert.assertEquals(documentTypeRulesList.size(), 2); 57 | } 58 | 59 | @Test 60 | public void selectByPrimaryKey() { 61 | PrinterKitchenDocumentTypeRulesDO documentTypeRules = scOperationPrinterKitchenDocumentTypeRulesService.selectByPrimaryKey(2); 62 | Assert.assertEquals(documentTypeRules.getId().longValue(), 2); 63 | } 64 | 65 | @Transactional 66 | @Test 67 | public void updateByPrimaryKeySelective() { 68 | PrinterKitchenDocumentTypeRulesDO documentTypeRules = scOperationPrinterKitchenDocumentTypeRulesService.selectByPrimaryKey(2); 69 | documentTypeRules.setDocumentTypeId(2); 70 | Integer integer = scOperationPrinterKitchenDocumentTypeRulesService.updateByPrimaryKeySelective(documentTypeRules); 71 | Assert.assertTrue(integer > 0); 72 | } 73 | 74 | @Transactional 75 | @Test 76 | public void removeMultipleRecordByPrinterKitchenId() { 77 | Integer integer = scOperationPrinterKitchenDocumentTypeRulesService.removeMultipleRecordByPrinterKitchenId(1); 78 | Assert.assertEquals(integer.longValue(), 2); 79 | } 80 | } -------------------------------------------------------------------------------- /src/test/java/com/zxcs/printtemplate/api/IScOperationPrinterKitchenGoodsRulesServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.api; 2 | 3 | import com.zxcs.printtemplate.model.PrinterKitchenGoodsRulesDO; 4 | import com.zxcs.printtemplate.service.IPrinterKitchenGoodsRulesService; 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest 18 | public class IScOperationPrinterKitchenGoodsRulesServiceTest { 19 | 20 | @Autowired 21 | private IPrinterKitchenGoodsRulesService scOperationPrinterKitchenGoodsRulesService; 22 | 23 | @Transactional 24 | @Test 25 | public void save() { 26 | PrinterKitchenGoodsRulesDO printerKitchenGoodsRules = new PrinterKitchenGoodsRulesDO(); 27 | printerKitchenGoodsRules.setPrinterKitchenId(1); 28 | printerKitchenGoodsRules.setGoodsId(1); 29 | printerKitchenGoodsRules.setStockId(1); 30 | printerKitchenGoodsRules.setDelete(0); 31 | Integer id = scOperationPrinterKitchenGoodsRulesService.save(printerKitchenGoodsRules); 32 | Assert.assertTrue(id > 0); 33 | } 34 | 35 | @Transactional 36 | @Test 37 | public void saveMultipleRecord() { 38 | List printerKitchenGoodsRulesList = new ArrayList<>(10); 39 | for (int i = 0; i < 5; i++) { 40 | PrinterKitchenGoodsRulesDO printerKitchenGoodsRules = new PrinterKitchenGoodsRulesDO(); 41 | printerKitchenGoodsRules.setPrinterKitchenId(i); 42 | printerKitchenGoodsRules.setGoodsId(i); 43 | printerKitchenGoodsRules.setStockId(i); 44 | printerKitchenGoodsRules.setDelete(0); 45 | printerKitchenGoodsRulesList.add(printerKitchenGoodsRules); 46 | } 47 | Integer integer = scOperationPrinterKitchenGoodsRulesService.saveMultipleRecord(printerKitchenGoodsRulesList); 48 | Assert.assertEquals(integer.longValue(), 5); 49 | } 50 | 51 | @Test 52 | public void listPrinterKitchenGoodsRulesByPrinterKitchenId() { 53 | List printerKitchenGoodsRulesList = scOperationPrinterKitchenGoodsRulesService.listPrinterKitchenGoodsRulesByPrinterKitchenId(1); 54 | Assert.assertEquals(printerKitchenGoodsRulesList.size(), 2); 55 | } 56 | 57 | @Test 58 | public void getByPrimaryKey() { 59 | PrinterKitchenGoodsRulesDO kitchenGoodsRules = scOperationPrinterKitchenGoodsRulesService.getByPrimaryKey(2); 60 | Assert.assertEquals(kitchenGoodsRules.getId().longValue(), 2); 61 | } 62 | 63 | @Transactional 64 | @Test 65 | public void updateByPrimaryKeySelective() { 66 | PrinterKitchenGoodsRulesDO kitchenGoodsRules = scOperationPrinterKitchenGoodsRulesService.getByPrimaryKey(2); 67 | kitchenGoodsRules.setGoodsId(2); 68 | Integer integer = scOperationPrinterKitchenGoodsRulesService.updateByPrimaryKeySelective(kitchenGoodsRules); 69 | Assert.assertTrue(integer > 0); 70 | } 71 | 72 | @Transactional 73 | @Test 74 | public void removeMultipleRecordByPrinterKitchenId() { 75 | Integer integer = scOperationPrinterKitchenGoodsRulesService.removeMultipleRecordByPrinterKitchenId(1); 76 | Assert.assertEquals(integer.longValue(), 2); 77 | } 78 | } -------------------------------------------------------------------------------- /src/test/java/com/zxcs/printtemplate/api/IScOperationPrinterKitchenServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.api; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.zxcs.printtemplate.model.PrinterKitchenDO; 5 | import com.zxcs.printtemplate.service.IPrinterKitchenService; 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | import org.springframework.transaction.annotation.Transactional; 13 | 14 | @RunWith(SpringRunner.class) 15 | @SpringBootTest 16 | public class IScOperationPrinterKitchenServiceTest { 17 | 18 | @Autowired 19 | private IPrinterKitchenService scOperationPrinterKitchenService; 20 | 21 | @Transactional 22 | @Test 23 | public void save() { 24 | PrinterKitchenDO printerKitchen = new PrinterKitchenDO(); 25 | printerKitchen.setName("一号口"); 26 | printerKitchen.setPrinterDeviceId(1); 27 | printerKitchen.setTable(0); 28 | printerKitchen.setGoods(0); 29 | printerKitchen.setDelete(0); 30 | printerKitchen.setShopId(288); 31 | printerKitchen.setCreatorId(1); 32 | printerKitchen.setCreatorName("dazuo"); 33 | printerKitchen.setUpdatorId(1); 34 | printerKitchen.setUpdatorName("dazuo"); 35 | Integer id = scOperationPrinterKitchenService.save(printerKitchen); 36 | Assert.assertTrue(id > 0); 37 | } 38 | 39 | @Test 40 | public void getByPrimaryKey() { 41 | PrinterKitchenDO printerKitchen = scOperationPrinterKitchenService.getByPrimaryKey(1); 42 | Assert.assertEquals(printerKitchen.getId().longValue(), 1); 43 | } 44 | 45 | @Test 46 | public void listPrinterKitchenByShopId() { 47 | PageInfo printerKitchenPageInfo = scOperationPrinterKitchenService.listPrinterKitchenByShopId(288, 2, 1); 48 | Assert.assertEquals(printerKitchenPageInfo.getList().size(), 1); 49 | Assert.assertEquals(printerKitchenPageInfo.getList().get(0).getId().longValue(), 2); 50 | } 51 | 52 | @Transactional 53 | @Test 54 | public void updateByPrimaryKeySelective() { 55 | PrinterKitchenDO printerKitchen = scOperationPrinterKitchenService.getByPrimaryKey(1); 56 | printerKitchen.setGoods(1); 57 | Integer integer = scOperationPrinterKitchenService.updateByPrimaryKeySelective(printerKitchen); 58 | Assert.assertTrue(integer > 0); 59 | } 60 | } -------------------------------------------------------------------------------- /src/test/java/com/zxcs/printtemplate/api/IScOperationPrinterKitchenTableRulesServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.api; 2 | 3 | import com.zxcs.printtemplate.model.PrinterKitchenTableRulesDO; 4 | import com.zxcs.printtemplate.service.IPrinterKitchenTableRulesService; 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest 18 | public class IScOperationPrinterKitchenTableRulesServiceTest { 19 | 20 | @Autowired 21 | private IPrinterKitchenTableRulesService scOperationPrinterKitchenTableRulesService; 22 | 23 | @Transactional 24 | @Test 25 | public void save() { 26 | PrinterKitchenTableRulesDO scShopPrinterKitchenTableRules = new PrinterKitchenTableRulesDO(); 27 | scShopPrinterKitchenTableRules.setPrinterKitchenId(1); 28 | scShopPrinterKitchenTableRules.setTableId(1); 29 | scShopPrinterKitchenTableRules.setDelete(0); 30 | Integer affected = scOperationPrinterKitchenTableRulesService.save(scShopPrinterKitchenTableRules); 31 | Assert.assertTrue(affected > 0); 32 | } 33 | 34 | @Transactional 35 | @Test 36 | public void saveMultipleRecord() { 37 | List kitchenTableRulesList = new ArrayList<>(10); 38 | for (int i = 0; i < 5; i++) { 39 | PrinterKitchenTableRulesDO scShopPrinterKitchenTableRules = new PrinterKitchenTableRulesDO(); 40 | scShopPrinterKitchenTableRules.setPrinterKitchenId(i); 41 | scShopPrinterKitchenTableRules.setTableId(1); 42 | scShopPrinterKitchenTableRules.setDelete(0); 43 | kitchenTableRulesList.add(scShopPrinterKitchenTableRules); 44 | } 45 | Integer integer = scOperationPrinterKitchenTableRulesService.saveMultipleRecord(kitchenTableRulesList); 46 | Assert.assertEquals(integer.longValue(), 5); 47 | } 48 | 49 | @Test 50 | public void listPrinterKitchenTableRulesByPrinterKitchenId() { 51 | List kitchenTableRulesList = scOperationPrinterKitchenTableRulesService.listPrinterKitchenTableRulesByPrinterKitchenId(1); 52 | Assert.assertEquals(kitchenTableRulesList.size(), 2); 53 | } 54 | 55 | @Test 56 | public void getByPrimaryKey() { 57 | PrinterKitchenTableRulesDO kitchenTableRules = scOperationPrinterKitchenTableRulesService.getByPrimaryKey(2); 58 | Assert.assertEquals(kitchenTableRules.getId().longValue(), 2); 59 | } 60 | 61 | @Transactional 62 | @Test 63 | public void updateByPrimaryKeySelective() { 64 | PrinterKitchenTableRulesDO kitchenTableRules = scOperationPrinterKitchenTableRulesService.getByPrimaryKey(2); 65 | kitchenTableRules.setPrinterKitchenId(3); 66 | Integer integer = scOperationPrinterKitchenTableRulesService.updateByPrimaryKeySelective(kitchenTableRules); 67 | Assert.assertTrue(integer > 0); 68 | } 69 | 70 | @Transactional 71 | @Test 72 | public void removeMultipleRecordByPrinterKitchenId() { 73 | Integer integer = scOperationPrinterKitchenTableRulesService.removeMultipleRecordByPrinterKitchenId(3); 74 | Assert.assertEquals(integer.longValue(), 2); 75 | } 76 | } -------------------------------------------------------------------------------- /src/test/java/com/zxcs/printtemplate/api/IScOperationPrinterSystemComponentServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.api; 2 | 3 | import com.zxcs.printtemplate.model.PrinterSystemComponentDO; 4 | import com.zxcs.printtemplate.service.IPrinterSystemComponentService; 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import java.util.List; 14 | 15 | @RunWith(SpringRunner.class) 16 | @SpringBootTest 17 | public class IScOperationPrinterSystemComponentServiceTest { 18 | 19 | @Autowired 20 | private IPrinterSystemComponentService scOperationPrinterSystemComponentService; 21 | 22 | @Transactional 23 | @Test 24 | public void savePrinterSystemComponent () { 25 | // TODO: 26 | } 27 | 28 | @Test 29 | public void listPrinterSystemComponentByTemplateType() { 30 | List systemComponentList = scOperationPrinterSystemComponentService.listPrinterSystemComponentByTemplateType(1); 31 | Assert.assertEquals(systemComponentList.size(), 151); 32 | } 33 | } -------------------------------------------------------------------------------- /src/test/java/com/zxcs/printtemplate/api/IScOperationPrinterTemplateDocumentServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.api; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.zxcs.printtemplate.model.PrinterTemplateDocumentDO; 5 | import com.zxcs.printtemplate.service.IPrinterTemplateDocumentService; 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | 13 | import java.util.Date; 14 | import java.util.List; 15 | 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest 18 | public class IScOperationPrinterTemplateDocumentServiceTest { 19 | 20 | @Autowired 21 | private IPrinterTemplateDocumentService scOperationPrinterTemplateDocumentService; 22 | 23 | @Test 24 | public void saveShopPrinterTemplateDocument() { 25 | PrinterTemplateDocumentDO printerTemplateDocument = new PrinterTemplateDocumentDO(); 26 | printerTemplateDocument.setName("自定义模板"); 27 | printerTemplateDocument.setDocumentType(1); 28 | printerTemplateDocument.setUrl(""); 29 | printerTemplateDocument.setStatus(2); 30 | printerTemplateDocument.setShopId(288); 31 | printerTemplateDocument.setCreatorId(1); 32 | printerTemplateDocument.setCreatorName("dazuo"); 33 | printerTemplateDocument.setCreateTime(new Date()); 34 | Integer integer = scOperationPrinterTemplateDocumentService.saveShopPrinterTemplateDocument(printerTemplateDocument); 35 | System.out.println("id: " + integer); 36 | } 37 | 38 | @Test 39 | public void getShopPrinterTemplateDocumentByPrimaryId() { 40 | PrinterTemplateDocumentDO templateDocument = scOperationPrinterTemplateDocumentService.getShopPrinterTemplateDocumentByPrimaryId(1); 41 | Assert.assertEquals(templateDocument.getName(), "系统模板-结账单"); 42 | } 43 | 44 | @Test 45 | public void updateShopPrinterTemplateDocumentByPrimaryId() { 46 | } 47 | 48 | @Test 49 | public void listPrinterTemplateDocumentByShopIdAndDocumentType() { 50 | List scShopPrinterTemplateDocuments = scOperationPrinterTemplateDocumentService.listPrinterTemplateDocumentByShopIdAndDocumentType(0, 1); 51 | System.out.println("scShopPrinterTemplateDocuments: " + JSON.toJSON(scShopPrinterTemplateDocuments)); 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /src/test/java/com/zxcs/printtemplate/api/IScOperationPrinterTemplateModuleServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.zxcs.printtemplate.api; 2 | 3 | import com.zxcs.printtemplate.model.PrinterTemplateModuleDO; 4 | import com.zxcs.printtemplate.service.impl.PrinterTemplateModuleServiceImpl; 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | 12 | import java.util.List; 13 | 14 | @RunWith(SpringRunner.class) 15 | @SpringBootTest 16 | public class IScOperationPrinterTemplateModuleServiceTest { 17 | 18 | @Autowired 19 | private PrinterTemplateModuleServiceImpl scOperationPrinterTemplateModuleService; 20 | 21 | @Test 22 | public void listPrinterTemplateModuleByDocumentId() { 23 | List moduleList = scOperationPrinterTemplateModuleService.listPrinterTemplateModuleByDocumentId(1); 24 | Assert.assertEquals(moduleList.size(), 8); 25 | } 26 | } --------------------------------------------------------------------------------