You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1015 lines
34 KiB

12 months ago
11 months ago
10 months ago
12 months ago
10 months ago
10 months ago
12 months ago
12 months ago
12 months ago
10 months ago
12 months ago
10 months ago
12 months ago
12 months ago
10 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
12 months ago
  1. package com.gaotao.modules.base.controller;
  2. import com.gaotao.common.constant.SysMsgConstant;
  3. import com.gaotao.common.utils.R;
  4. import com.gaotao.modules.base.entity.*;
  5. import com.gaotao.modules.base.service.BaseService;
  6. import com.gaotao.modules.base.service.ReportLabelListService;
  7. import com.gaotao.modules.base.service.ReportPaperListService;
  8. import com.gaotao.modules.base.dto.*;
  9. import com.gaotao.modules.base.vo.PaperUsageCheckResponse;
  10. import com.gaotao.modules.base.service.PdfExportService;
  11. import com.gaotao.modules.sys.controller.AbstractController;
  12. import jakarta.servlet.http.HttpServletResponse;
  13. import lombok.extern.slf4j.Slf4j;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.web.bind.annotation.*;
  16. import java.util.List;
  17. import java.util.Map;
  18. @Slf4j
  19. @RestController
  20. @RequestMapping("/label/setting")
  21. public class LabelSettingController extends AbstractController {
  22. @Autowired
  23. private BaseService baseService;
  24. @Autowired
  25. private ReportLabelListService reportLabelListService;
  26. @Autowired
  27. private ReportPaperListService reportPaperListService;
  28. @Autowired
  29. private PdfExportService pdfExportService;
  30. @Autowired
  31. private com.gaotao.modules.base.service.LabelDataProcessorService labelDataProcessorService;
  32. /**
  33. * @description: 查询打印标签的定义参数
  34. * @author LR
  35. * @date 2022/12/27 17:49
  36. * @version 1.0
  37. */
  38. @RequestMapping(value = "/getLabelSettingList")
  39. public R getLabelSettingList(@RequestBody LabelSettingData inData){
  40. List<LabelSettingData> resultList = baseService.getLabelSettingList(inData);
  41. return R.ok()
  42. .put("code", 200)
  43. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000))
  44. .put("rows", resultList)
  45. .put("total", resultList.size());
  46. }
  47. /**
  48. * @description: 插入标签自定义的数据
  49. * @author LR
  50. * @date 2022/12/28 15:29
  51. * @version 1.0
  52. */
  53. @RequestMapping(value = "/insertLabelSetting")
  54. public R insertLabelSetting(@RequestBody LabelSettingData inData){
  55. baseService.insertLabelSetting(inData);
  56. return R.ok()
  57. .put("code", 200)
  58. .put("msg", "操作成功!");
  59. }
  60. /**
  61. * @description: 修改标签自定义的数据
  62. * @author LR
  63. * @date 2022/12/28 15:30
  64. * @version 1.0
  65. */
  66. @RequestMapping(value = "/updateLabelSetting")
  67. public R updateLabelSetting(@RequestBody LabelSettingData inData){
  68. baseService.updateLabelSetting(inData);
  69. return R.ok()
  70. .put("code", 200)
  71. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  72. }
  73. /**
  74. * @description: 删除标签数据
  75. * @author LR
  76. * @date 2023/1/3 11:15
  77. * @version 1.0
  78. */
  79. @RequestMapping(value = "/deleteLabelSetting")
  80. public R deleteLabelSetting(@RequestBody LabelSettingData inData){
  81. baseService.deleteLabelSetting(inData);
  82. return R.ok()
  83. .put("code", 200)
  84. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  85. }
  86. /**
  87. * @description: 获取默认打印列表信息
  88. * @author LR
  89. * @date 2023/1/3 16:15
  90. * @version 1.0
  91. */
  92. @RequestMapping(value = "/getDefaultLabelSettingList")
  93. public R getDefaultLabelSettingList(@RequestBody DefaultLabelSettingData inData){
  94. List<DefaultLabelSettingData> resultList = baseService.getDefaultLabelSettingList(inData);
  95. return R.ok()
  96. .put("code", 200)
  97. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000))
  98. .put("rows", resultList)
  99. .put("total", resultList.size());
  100. }
  101. /**
  102. * @description: 检查标签边编号
  103. * @author LR
  104. * @date 2023/1/3 17:48
  105. * @version 1.0
  106. */
  107. @RequestMapping(value = "checkLabelNo")
  108. public R checkLabelNo(@RequestBody LabelSettingData inData){
  109. LabelSettingData resultRow = baseService.checkLabelNo(inData);
  110. return R.ok()
  111. .put("code", 200)
  112. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000))
  113. .put("resultRow", resultRow);
  114. }
  115. /**
  116. * @description: 插入默认标签的配置信息
  117. * @author LR
  118. * @date 2023/1/4 10:23
  119. * @version 1.0
  120. */
  121. @RequestMapping(value = "/insertDefaultLabelSetting")
  122. public R insertDefaultLabelSetting(@RequestBody DefaultLabelSettingData inData){
  123. baseService.insertDefaultLabelSetting(inData);
  124. return R.ok()
  125. .put("code", 200)
  126. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  127. }
  128. /**
  129. * @description: 修改默认标签的配置信息
  130. * @author LR
  131. * @date 2023/1/4 10:24
  132. * @version 1.0
  133. */
  134. @RequestMapping(value = "/updateDefaultLabelSetting")
  135. public R updateDefaultLabelSetting(@RequestBody DefaultLabelSettingData inData){
  136. baseService.updateDefaultLabelSetting(inData);
  137. return R.ok()
  138. .put("code", 200)
  139. .put("msg",getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  140. }
  141. /**
  142. * @description: 删除默认标签数据
  143. * @author LR
  144. * @date 2023/1/3 11:15
  145. * @version 1.0
  146. */
  147. @RequestMapping(value = "/deleteDefaultLabelSetting")
  148. public R deleteDefaultLabelSetting(@RequestBody DefaultLabelSettingData inData) {
  149. baseService.deleteDefaultLabelSetting(inData);
  150. return R.ok()
  151. .put("code", 200)
  152. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  153. }
  154. /**
  155. * @description: 查询客制化标签的配置信息
  156. * @author LR
  157. * @date 2023/1/4 15:33
  158. * @version 1.0
  159. */
  160. @RequestMapping(value = "/getCustomerLabelSettingList")
  161. public R getCustomerLabelSettingList(@RequestBody CustomerLabelSettingData inData){
  162. List<CustomerLabelSettingData> resultList = baseService.getCustomerLabelSettingList(inData);
  163. return R.ok()
  164. .put("code", 200)
  165. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000))
  166. .put("rows", resultList)
  167. .put("total", resultList.size());
  168. }
  169. /**
  170. * @description: 插入客制化标签的配置信息
  171. * @author LR
  172. * @date 2023/1/4 16:15
  173. * @version 1.0
  174. */
  175. @RequestMapping(value = "/insertCustomerLabelSetting")
  176. public R insertCustomerLabelSetting(@RequestBody CustomerLabelSettingData inData){
  177. baseService.insertCustomerLabelSetting(inData);
  178. return R.ok()
  179. .put("code", 200)
  180. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  181. }
  182. /**
  183. * @description: 修改客制化标签的配置信息
  184. * @author LR
  185. * @date 2023/1/4 16:16
  186. * @version 1.0
  187. */
  188. @RequestMapping(value = "/updateCustomerLabelSetting")
  189. public R updateCustomerLabelSetting(@RequestBody CustomerLabelSettingData inData){
  190. baseService.updateCustomerLabelSetting(inData);
  191. return R.ok()
  192. .put("code", 200)
  193. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  194. }
  195. /**
  196. * @description: 删除客制化标签数据
  197. * @author LR
  198. * @date 2023/1/4 16:16
  199. * @version 1.0
  200. */
  201. @RequestMapping(value = "/deleteCustomerLabelSetting")
  202. public R deleteCustomerLabelSetting(@RequestBody CustomerLabelSettingData inData) {
  203. baseService.deleteCustomerLabelSetting(inData);
  204. return R.ok()
  205. .put("code", 200)
  206. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  207. }
  208. /**
  209. * @description: 获取用户的标签打印机配置信息
  210. * @author LR
  211. * @date 2023/1/5 17:35
  212. * @version 1.0
  213. */
  214. @RequestMapping(value = "/getUserLabelPrinters")
  215. public R getUserLabelPrinters(@RequestBody UserLabelPrinterData inData){
  216. List<UserLabelPrinterData> resultList = baseService.getUserLabelPrinters(inData);
  217. return R.ok()
  218. .put("code", 200)
  219. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000))
  220. .put("rows", resultList)
  221. .put("total", resultList.size());
  222. }
  223. /**
  224. * @description: 检查用户的id
  225. * @author LR
  226. * @date 2023/1/6 11:09
  227. * @version 1.0
  228. */
  229. @RequestMapping(value = "/checkUserId")
  230. public R checkUserId(@RequestBody UserLabelPrinterData inData){
  231. SysUserData sysUser = baseService.checkUserId(inData);
  232. return R.ok()
  233. .put("code", 200)
  234. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000))
  235. .put("sysUser", sysUser);
  236. }
  237. /**
  238. * @description: 插入用户标签打印机信息
  239. * @author LR
  240. * @date 2023/1/6 11:47
  241. * @version 1.0
  242. */
  243. @RequestMapping(value = "/insertUserLabelPrinter")
  244. public R insertUserLabelPrinter(@RequestBody UserLabelPrinterData inData){
  245. baseService.insertUserLabelPrinter(inData);
  246. return R.ok()
  247. .put("code", 200)
  248. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  249. }
  250. /**
  251. * @description: 修改用户标签打印机信息
  252. * @author LR
  253. * @date 2023/1/6 11:47
  254. * @version 1.0
  255. */
  256. @RequestMapping(value = "/updateUserLabelPrinter")
  257. public R updateUserLabelPrinter(@RequestBody UserLabelPrinterData inData){
  258. baseService.updateUserLabelPrinter(inData);
  259. return R.ok()
  260. .put("code", 200)
  261. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  262. }
  263. /**
  264. * @description: 删除用户标签打印机信息
  265. * @author LR
  266. * @date 2023/1/6 11:49
  267. * @version 1.0
  268. */
  269. @RequestMapping(value = "/deleteUserLabelPrinter")
  270. public R deleteUserLabelPrinter(@RequestBody UserLabelPrinterData inData) {
  271. baseService.deleteUserLabelPrinter(inData);
  272. return R.ok()
  273. .put("code", 200)
  274. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  275. }
  276. /**
  277. * @description: 获取标签打印参数配置信息
  278. * @author LR
  279. * @date 2023/1/6 17:13
  280. * @version 1.0
  281. */
  282. @RequestMapping(value = "/getLabelParameterList")
  283. public R getLabelParameterList(@RequestBody LabelParameterData inData){
  284. List<LabelParameterData> resultList = baseService.getLabelParameterList(inData);
  285. return R.ok()
  286. .put("code", 200)
  287. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000))
  288. .put("rows", resultList)
  289. .put("total", resultList.size());
  290. }
  291. /**
  292. * @description: 插入标签打印参数
  293. * @author LR
  294. * @date 2023/1/8 20:15
  295. * @version 1.0
  296. */
  297. @RequestMapping(value = "/insertLabelPrintParameter")
  298. public R insertLabelPrintParameter(@RequestBody LabelParameterData inData){
  299. baseService.insertLabelPrintParameter(inData);
  300. return R.ok()
  301. .put("code", 200)
  302. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  303. }
  304. /**
  305. * @description: 修改标签打印参数的配置信息
  306. * @author LR
  307. * @date 2023/1/9 9:14
  308. * @version 1.0
  309. */
  310. @RequestMapping(value = "/updateLabelPrintParameter")
  311. public R updateLabelPrintParameter(@RequestBody LabelParameterData inData){
  312. baseService.updateLabelPrintParameter(inData);
  313. return R.ok()
  314. .put("code", 200)
  315. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  316. }
  317. /**
  318. * @description: 删除标签打印的配置信息
  319. * @author LR
  320. * @date 2023/1/9 9:14
  321. * @version 1.0
  322. */
  323. @RequestMapping(value = "/deleteLabelPrintParameter")
  324. public R deleteLabelPrintParameter(@RequestBody LabelParameterData inData){
  325. baseService.deleteLabelPrintParameter(inData);
  326. return R.ok()
  327. .put("code", 200)
  328. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  329. }
  330. /**
  331. * @description: 复制标签打印参数
  332. * @author LR
  333. * @date 2023/1/9 14:39
  334. * @version 1.0
  335. */
  336. @RequestMapping(value = "/copyLabelPrintParameter")
  337. public R copyLabelPrintParameter(@RequestBody LabelParameterData inData){
  338. baseService.copyLabelPrintParameter(inData);
  339. return R.ok()
  340. .put("code", 200)
  341. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  342. }
  343. /**
  344. * @description: 查询标签内容定义列表
  345. * @author LR
  346. * @date 2023/1/9 17:46
  347. * @version 1.0
  348. */
  349. @RequestMapping(value = "/getLabelContentList")
  350. public R getLabelContentList(@RequestBody LabelContentData inData){
  351. List<LabelContentData> resultList = baseService.getLabelContentList(inData);
  352. return R.ok()
  353. .put("code", 200)
  354. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000))
  355. .put("rows", resultList)
  356. .put("total", resultList.size());
  357. }
  358. /**
  359. * @description: 插入标签内容定义
  360. * @author LR
  361. * @date 2023/1/9 18:16
  362. * @version 1.0
  363. */
  364. @RequestMapping(value = "/insertLabelContent")
  365. public R insertLabelContent(@RequestBody LabelContentData inData){
  366. baseService.insertLabelContent(inData);
  367. return R.ok()
  368. .put("code", 200)
  369. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  370. }
  371. /**
  372. * @description: 修改标签内容定义
  373. * @author LR
  374. * @date 2023/1/9 19:11
  375. * @version 1.0
  376. */
  377. @RequestMapping(value = "/updateLabelContent")
  378. public R updateLabelContent(@RequestBody LabelContentData inData){
  379. baseService.updateLabelContent(inData);
  380. return R.ok()
  381. .put("code", 200)
  382. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  383. }
  384. /**
  385. * @description: 删除标签内容定义
  386. * @author LR
  387. * @date 2023/1/9 19:25
  388. * @version 1.0
  389. */
  390. @RequestMapping(value = "/deleteLabelContent")
  391. public R deleteLabelContent(@RequestBody LabelContentData inData){
  392. baseService.deleteLabelContent(inData);
  393. return R.ok()
  394. .put("code", 200)
  395. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  396. }
  397. /**
  398. * @description: 复制标签内容定义
  399. * @author LR
  400. * @date 2023/1/9 19:27
  401. * @version 1.0
  402. */
  403. @RequestMapping(value = "/copyLabelContent")
  404. public R copyLabelContent(@RequestBody LabelContentData inData){
  405. baseService.copyLabelContent(inData);
  406. return R.ok()
  407. .put("code", 200)
  408. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  409. }
  410. /**
  411. * @description: 查询可以复制的标签内容定义
  412. * @author LR
  413. * @date 2023/1/10 10:58
  414. * @version 1.0
  415. */
  416. @RequestMapping(value = "/getCopyLabelSettingList")
  417. public R getCopyLabelSettingList(@RequestBody LabelSettingData inData){
  418. List<LabelSettingData> resultList = baseService.getCopyLabelSettingList(inData);
  419. return R.ok()
  420. .put("code", 200)
  421. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000))
  422. .put("rows", resultList)
  423. .put("total", resultList.size());
  424. }
  425. /**
  426. * @description: 复制其他标签的标签内容定义
  427. * @author LR
  428. * @date 2023/1/10 11:37
  429. * @version 1.0
  430. */
  431. @RequestMapping(value = "/copyLabelAllContentsWithOther")
  432. public R copyLabelAllContentsWithOther(@RequestBody LabelSettingData inData){
  433. baseService.copyLabelAllContentsWithOther(inData);
  434. return R.ok()
  435. .put("code", 200)
  436. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  437. }
  438. /**
  439. * @description: 获取要用的标签内容
  440. * @author LR
  441. * @date 2023/1/10 14:48
  442. * @version 1.0
  443. */
  444. @RequestMapping(value = "/getUsedLabelContent")
  445. public R getUsedLabelContent(@RequestBody LabelContentData inData){
  446. List<LabelContentData> resultList = baseService.getUsedLabelContent(inData);
  447. return R.ok()
  448. .put("code", 200)
  449. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000))
  450. .put("rows", resultList)
  451. .put("total", resultList.size());
  452. }
  453. /**
  454. * @description: 获取标签内容的流水号规则
  455. * @author LR
  456. * @date 2023/1/10 14:56
  457. * @version 1.0
  458. */
  459. @RequestMapping(value = "/getLabelContentSerialRule")
  460. public R getLabelContentSerialRule(@RequestBody LabelContentData inData){
  461. List<LabelContentSerialRuleData> resultList = baseService.getLabelContentSerialRule(inData);
  462. return R.ok()
  463. .put("code", 200)
  464. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000))
  465. .put("rows", resultList)
  466. .put("total", resultList.size());
  467. }
  468. /**
  469. * @description: 插入标签内容流水号规则
  470. * @author LR
  471. * @date 2023/1/10 15:40
  472. * @version 1.0
  473. */
  474. @RequestMapping(value = "/insertLabelContentSerialRule")
  475. public R insertLabelContentSerialRule(@RequestBody LabelContentData inData){
  476. baseService.insertLabelContentSerialRule(inData);
  477. return R.ok()
  478. .put("code", 200)
  479. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  480. }
  481. /**
  482. * @description: 删除标签内容的流水号规则
  483. * @author LR
  484. * @date 2023/1/10 16:04
  485. * @version 1.0
  486. */
  487. @RequestMapping(value = "/deleteLabelContentSerialRule")
  488. public R deleteLabelContentSerialRule(@RequestBody LabelContentSerialRuleData inData){
  489. baseService.deleteLabelContentSerialRule(inData);
  490. return R.ok()
  491. .put("code", 200)
  492. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  493. }
  494. /**
  495. * @description: 获取标签内容的流水号信息
  496. * @author LR
  497. * @date 2023/1/10 14:56
  498. * @version 1.0
  499. */
  500. @RequestMapping(value = "/getLabelSerialInfos")
  501. public R getLabelSerialInfos(@RequestBody LabelContentData inData){
  502. List<LabelContentSerialInfoData> resultList = baseService.getLabelSerialInfos(inData);
  503. return R.ok()
  504. .put("code", 200)
  505. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000))
  506. .put("rows", resultList)
  507. .put("total", resultList.size());
  508. }
  509. /**
  510. * @description: 插入标签流水号信息
  511. * @author LR
  512. * @date 2023/1/10 17:06
  513. * @version 1.0
  514. */
  515. @RequestMapping(value = "/insertLabelSerialInfo")
  516. public R insertLabelSerialInfo(@RequestBody LabelContentSerialInfoData inData){
  517. baseService.insertLabelSerialInfo(inData);
  518. return R.ok()
  519. .put("code", 200)
  520. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  521. }
  522. /**
  523. * @description: 修改标签流水号信息
  524. * @author LR
  525. * @date 2023/1/10 17:07
  526. * @version 1.0
  527. */
  528. @RequestMapping(value = "/updateLabelSerialInfo")
  529. public R updateLabelSerialInfo(@RequestBody LabelContentSerialInfoData inData){
  530. baseService.updateLabelSerialInfo(inData);
  531. return R.ok()
  532. .put("code", 200)
  533. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  534. }
  535. /**
  536. * @description: 删除标签流水号信息
  537. * @author LR
  538. * @date 2023/1/10 17:45
  539. * @version 1.0
  540. */
  541. @RequestMapping(value = "/deleteLabelSerialInfo")
  542. public R deleteLabelSerialInfo(@RequestBody LabelContentSerialInfoData inData){
  543. baseService.deleteLabelSerialInfo(inData);
  544. return R.ok()
  545. .put("code", 200)
  546. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000));
  547. }
  548. @PostMapping("saveZplElements")
  549. public R saveZplElements(@RequestBody ZplDataDto zplData){
  550. reportLabelListService.saveZplElements(zplData);
  551. return R.ok();
  552. }
  553. @RequestMapping(value = "getZplElements")
  554. public R getZplElements(@RequestBody ReportLabelList reportLabelList){
  555. return R.ok()
  556. .put("code", 200)
  557. .put("data", reportLabelListService.getZplElements(reportLabelList.getReportId()));
  558. }
  559. /**
  560. * @description: 打印标签
  561. * @author Kiro
  562. * @date 2025/1/24
  563. * @version 1.0
  564. */
  565. @PostMapping("printLabel")
  566. public R printLabel(@RequestBody PrintLabelRequest printRequest){
  567. try {
  568. reportLabelListService.printLabel(printRequest);
  569. return R.ok()
  570. .put("code", 200)
  571. .put("msg", "打印任务已发送成功");
  572. } catch (Exception e) {
  573. return R.error("打印失败: " + e.getMessage());
  574. }
  575. }
  576. // ==================== 纸张管理API ====================
  577. /**
  578. * @description: 获取纸张列表
  579. * @author system
  580. * @date 2024/01/01
  581. * @version 1.0
  582. */
  583. @RequestMapping(value = "/paper/getPaperList")
  584. public R getPaperList(@RequestBody PaperListRequest request) {
  585. try {
  586. List<ReportPaperList> paperList = reportPaperListService.getPaperList(request);
  587. return R.ok()
  588. .put("code", 200)
  589. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000))
  590. .put("data", paperList)
  591. .put("total", paperList.size());
  592. } catch (Exception e) {
  593. return R.error("获取纸张列表失败: " + e.getMessage());
  594. }
  595. }
  596. /**
  597. * @description: 保存纸张新增/更新
  598. * @author system
  599. * @date 2024/01/01
  600. * @version 1.0
  601. */
  602. @RequestMapping(value = "/paper/savePaper")
  603. public R savePaper(@RequestBody PaperSaveRequest request) {
  604. try {
  605. ReportPaperList savedPaper = reportPaperListService.savePaper(request);
  606. return R.ok()
  607. .put("code", 200)
  608. .put("msg", request.getId() != null ? "纸张更新成功" : "纸张保存成功")
  609. .put("data", savedPaper);
  610. } catch (Exception e) {
  611. return R.error("保存纸张失败: " + e.getMessage());
  612. }
  613. }
  614. /**
  615. * @description: 删除纸张
  616. * @author system
  617. * @date 2024/01/01
  618. * @version 1.0
  619. */
  620. @RequestMapping(value = "/paper/deletePaper")
  621. public R deletePaper(@RequestBody PaperUsageCheckRequest request) {
  622. try {
  623. boolean success = reportPaperListService.deletePaper(
  624. request.getId(),
  625. request.getSite(),
  626. getUser().getUsername()
  627. );
  628. if (success) {
  629. return R.ok()
  630. .put("code", 200)
  631. .put("msg", "删除成功");
  632. } else {
  633. return R.error("删除失败");
  634. }
  635. } catch (Exception e) {
  636. return R.error("删除纸张失败: " + e.getMessage());
  637. }
  638. }
  639. /**
  640. * @description: 检查纸张名称是否重复
  641. * @author system
  642. * @date 2024/01/01
  643. * @version 1.0
  644. */
  645. @RequestMapping(value = "/paper/checkPaperName")
  646. public R checkPaperName(@RequestBody PaperSaveRequest request) {
  647. try {
  648. boolean exists = reportPaperListService.checkNameDuplicate(
  649. request.getName(),
  650. request.getSite(),
  651. request.getId()
  652. );
  653. return R.ok()
  654. .put("code", 200)
  655. .put("msg", "检查完成")
  656. .put("data", new java.util.HashMap<String, Object>() {{
  657. put("exists", exists);
  658. }});
  659. } catch (Exception e) {
  660. return R.error("检查纸张名称失败: " + e.getMessage());
  661. }
  662. }
  663. /**
  664. * @description: 检查纸张使用情况
  665. * @author system
  666. * @date 2024/01/01
  667. * @version 1.0
  668. */
  669. @RequestMapping(value = "/paper/checkPaperUsage")
  670. public R checkPaperUsage(@RequestBody PaperUsageCheckRequest request) {
  671. try {
  672. PaperUsageCheckResponse usageInfo = reportPaperListService.checkPaperUsage(request);
  673. return R.ok()
  674. .put("code", 200)
  675. .put("msg", "检查完成")
  676. .put("data", usageInfo);
  677. } catch (Exception e) {
  678. return R.error("检查纸张使用情况失败: " + e.getMessage());
  679. }
  680. }
  681. /**
  682. * @description: 切换纸张状态启用/禁用
  683. * @author system
  684. * @date 2024/01/01
  685. * @version 1.0
  686. */
  687. @RequestMapping(value = "/paper/togglePaperStatus")
  688. public R togglePaperStatus(@RequestBody java.util.Map<String, Object> params) {
  689. try {
  690. Long id = Long.valueOf(params.get("id").toString());
  691. Boolean isActive = Boolean.valueOf(params.get("isActive").toString());
  692. String site = params.get("site").toString();
  693. String username = params.get("username").toString();
  694. boolean success = reportPaperListService.togglePaperStatus(id, isActive, site, username);
  695. if (success) {
  696. return R.ok()
  697. .put("code", 200)
  698. .put("msg", isActive ? "启用成功" : "禁用成功");
  699. } else {
  700. return R.error("操作失败");
  701. }
  702. } catch (Exception e) {
  703. return R.error("切换纸张状态失败: " + e.getMessage());
  704. }
  705. }
  706. /**
  707. * @description: 根据ID获取纸张信息
  708. * @author system
  709. * @date 2024/01/01
  710. * @version 1.0
  711. */
  712. @RequestMapping(value = "/paper/getPaperById")
  713. public R getPaperById(@RequestBody java.util.Map<String, Object> params) {
  714. try {
  715. Long id = Long.valueOf(params.get("id").toString());
  716. ReportPaperList paper = reportPaperListService.getPaperById(id);
  717. if (paper != null) {
  718. return R.ok()
  719. .put("code", 200)
  720. .put("msg", "获取成功")
  721. .put("data", paper);
  722. } else {
  723. return R.error("纸张不存在");
  724. }
  725. } catch (Exception e) {
  726. return R.error("获取纸张信息失败: " + e.getMessage());
  727. }
  728. }
  729. /**
  730. * @description: 批量删除纸张
  731. * @author system
  732. * @date 2024/01/01
  733. * @version 1.0
  734. */
  735. @RequestMapping(value = "/paper/batchDeletePaper")
  736. public R batchDeletePaper(@RequestBody java.util.Map<String, Object> params) {
  737. try {
  738. @SuppressWarnings("unchecked")
  739. List<Long> ids = (List<Long>) params.get("ids");
  740. String site = params.get("site").toString();
  741. String username = params.get("username").toString();
  742. int deletedCount = reportPaperListService.batchDeletePaper(ids, site, username);
  743. return R.ok()
  744. .put("code", 200)
  745. .put("msg", "批量删除成功,共删除 " + deletedCount + " 个纸张");
  746. } catch (Exception e) {
  747. return R.error("批量删除纸张失败: " + e.getMessage());
  748. }
  749. }
  750. /**
  751. * @description: 获取标签类型列表
  752. * @author system
  753. * @date 2025/01/24
  754. * @version 1.0
  755. */
  756. @RequestMapping(value = "/getLabelTypeList")
  757. public R getLabelTypeList(@RequestBody java.util.Map<String, Object> params) {
  758. try {
  759. String site = params.get("site").toString();
  760. List<java.util.Map<String, Object>> labelTypeList = baseService.getLabelTypeList(site,null);
  761. return R.ok()
  762. .put("code", 200)
  763. .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000))
  764. .put("data", labelTypeList);
  765. } catch (Exception e) {
  766. return R.error("获取标签类型列表失败: " + e.getMessage());
  767. }
  768. }
  769. /**
  770. * @description: 复制标签包括基本信息和绘制内容
  771. * @author Kiro
  772. * @date 2025/01/25
  773. * @version 1.0
  774. */
  775. @RequestMapping(value = "/copyLabelSetting")
  776. public R copyLabelSetting(@RequestBody java.util.Map<String, Object> params) {
  777. try {
  778. String site = params.get("site").toString();
  779. String username = params.get("username").toString();
  780. String originalLabelNo = params.get("originalLabelNo").toString();
  781. // 调用服务层方法复制标签
  782. String newLabelNo = baseService.copyLabelSetting(site, username, originalLabelNo);
  783. return R.ok()
  784. .put("code", 200)
  785. .put("msg", "标签复制成功")
  786. .put("data", new java.util.HashMap<String, Object>() {{
  787. put("newLabelNo", newLabelNo);
  788. }});
  789. } catch (Exception e) {
  790. return R.error("复制标签失败: " + e.getMessage());
  791. }
  792. }
  793. /**
  794. * @description: 使用真实数据预览标签从数据库视图获取数据
  795. * @author Kiro
  796. * @date 2025/1/24
  797. * @version 1.0
  798. */
  799. @PostMapping("previewLabelWithRealData")
  800. public R previewLabelWithRealData(@RequestBody Map<String, Object> params) {
  801. try {
  802. String reportId = (String) params.get("reportId");
  803. if (reportId == null || reportId.trim().isEmpty()) {
  804. log.warn("标签ID为空");
  805. return R.error("标签ID不能为空");
  806. }
  807. // 使用真实数据生成ZPL代码预览
  808. String zplCode = reportLabelListService.previewLabelWithRealData(reportId,false);
  809. log.info("使用真实数据的ZPL代码生成成功,长度: {}", zplCode != null ? zplCode.length() : 0);
  810. return R.ok()
  811. .put("code", 200)
  812. .put("msg", "使用真实数据的ZPL代码生成成功")
  813. .put("data", zplCode);
  814. } catch (Exception e) {
  815. log.error("使用真实数据的标签预览失败: {}", e.getMessage(), e);
  816. return R.error(e.getMessage());
  817. }
  818. }
  819. /**
  820. * @description: 导出预览图为PDF
  821. * @author Kiro
  822. * @date 2025/1/24
  823. * @version 1.0
  824. */
  825. @PostMapping("exportPreviewToPdf")
  826. public void exportPreviewToPdf(@RequestBody Map<String, Object> params,
  827. HttpServletResponse response) {
  828. try {
  829. log.info("收到PDF导出请求: {}", params);
  830. String reportId = (String) params.get("reportId");
  831. String imageData = (String) params.get("imageData");
  832. if (reportId == null || reportId.trim().isEmpty()) {
  833. response.setStatus(400);
  834. response.getWriter().write("标签ID不能为空");
  835. return;
  836. }
  837. if (imageData == null || imageData.trim().isEmpty()) {
  838. response.setStatus(400);
  839. response.getWriter().write("预览图数据不能为空");
  840. return;
  841. }
  842. log.info("开始生成PDF: reportId={}", reportId);
  843. // 生成PDF
  844. java.io.ByteArrayOutputStream pdfStream = pdfExportService.exportPreviewToPdf(imageData, reportId);
  845. // 设置响应头
  846. response.setContentType("application/pdf");
  847. response.setHeader("Content-Disposition",
  848. "attachment; filename=\"label_preview_" + reportId + "_" +
  849. java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss")) +
  850. ".pdf\"");
  851. response.setContentLength(pdfStream.size());
  852. // 输出PDF
  853. response.getOutputStream().write(pdfStream.toByteArray());
  854. response.getOutputStream().flush();
  855. log.info("PDF导出成功: reportId={}, size={}KB", reportId, pdfStream.size() / 1024);
  856. } catch (Exception e) {
  857. log.error("PDF导出失败: {}", e.getMessage(), e);
  858. try {
  859. response.setStatus(500);
  860. response.getWriter().write("PDF导出失败: " + e.getMessage());
  861. } catch (Exception ex) {
  862. log.error("写入错误响应失败", ex);
  863. }
  864. }
  865. }
  866. /**
  867. * @description: 获取父标签信息
  868. * @author AI Assistant
  869. * @date 2024/12/19
  870. * @version 1.0
  871. */
  872. @GetMapping("/getParentLabelInfo")
  873. public R getParentLabelInfo(@RequestParam String labelNo) {
  874. try {
  875. log.info("收到获取父标签信息请求: labelNo={}", labelNo);
  876. if (labelNo == null || labelNo.trim().isEmpty()) {
  877. return R.error("标签编号不能为空");
  878. }
  879. Map<String, Object> parentInfo = baseService.getParentLabelInfo(labelNo);
  880. if (parentInfo != null && !parentInfo.isEmpty()) {
  881. log.info("父标签信息获取成功: {}", parentInfo);
  882. return R.ok()
  883. .put("code", 200)
  884. .put("msg", "父标签信息获取成功")
  885. .put("data", parentInfo);
  886. } else {
  887. log.info("未找到父标签信息: labelNo={}", labelNo);
  888. return R.ok()
  889. .put("code", 200)
  890. .put("msg", "未找到父标签信息")
  891. .put("data", null);
  892. }
  893. } catch (Exception e) {
  894. log.error("获取父标签信息失败: {}", e.getMessage(), e);
  895. return R.error("获取父标签信息失败: " + e.getMessage());
  896. }
  897. }
  898. @GetMapping("/getParentSerialElements")
  899. public R getParentSerialElements(@RequestParam String labelNo) {
  900. try {
  901. log.info("收到获取父标签信息请求: labelNo={}", labelNo);
  902. if (labelNo == null || labelNo.trim().isEmpty()) {
  903. return R.error("标签编号不能为空");
  904. }
  905. List<Map<String, Object>> parentInfo = baseService.getParentSerialElements(labelNo);
  906. if (parentInfo != null && !parentInfo.isEmpty()) {
  907. log.info("父标签信息获取成功: {}", parentInfo);
  908. return R.ok()
  909. .put("code", 200)
  910. .put("msg", "父标签信息获取成功")
  911. .put("data", parentInfo);
  912. } else {
  913. log.info("未找到父标签信息: labelNo={}", labelNo);
  914. return R.ok()
  915. .put("code", 200)
  916. .put("msg", "未找到父标签信息")
  917. .put("data", null);
  918. }
  919. } catch (Exception e) {
  920. log.error("获取父标签信息失败: {}", e.getMessage(), e);
  921. return R.error("获取父标签信息失败: " + e.getMessage());
  922. }
  923. }
  924. }