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.

1062 lines
36 KiB

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