1
hao
2025-05-20 8e24c6fea30d9b179375ee2893710cdec2443b13
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package com.web.supplier.controller;
 
import java.util.Map;
 
import javax.servlet.http.HttpServletResponse;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
 
import com.app.base.control.WebController;
import com.app.base.data.ApiResponseResult;
import com.web.supplier.service.PrintService;
import com.web.supplier.service.SearchService;
 
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
 
@Api(description = "打印页")
@CrossOrigin
@ControllerAdvice
// @RestController
@Controller
@RequestMapping(value = "/print")
public class PrintController extends WebController {
 
    @Autowired
    private PrintService printService;
 
    /**
     * 打开打印预览页-特殊字符无法处理,url太长无法处理-废除-2022-07-21
     **/
    /*@ApiOperation(value = "打印预览页", notes = "打印预览页", hidden = true)
    @RequestMapping(value = "/toPrintLabel")
    public ModelAndView toPrintLabel(String printData) {
        ModelAndView mav = new ModelAndView();
        try {
            mav.addObject("PRINT_DATA", printData);
            mav.setViewName("/supplier0/print_label");// 返回路径
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("打开打印预览页失败!", e);
        }
        return mav;
    }*/
    
    /**
     * 打开打印预览页
     **/
    @ApiOperation(value = "打印预览页", notes = "打印预览页", hidden = true)
    @RequestMapping(value = "/toPrintLabel")
    public ModelAndView toPrintLabel(String barcodeType,String suppNo,String ebeln ,String remainQty,String materialNo,
            String qty,String prodDate,String shipDate,String envirTag,String shelfLife,String flevel,String printQty,
            String remark,String actionType) {
        ModelAndView mav = new ModelAndView();
        try {
            ApiResponseResult result = printService.printLabel(barcodeType, suppNo, ebeln,remainQty, materialNo, qty, prodDate,
                    shipDate, envirTag, shelfLife, flevel, printQty, remark,actionType);
            mav.addObject("PRINT_DATA", result);
            mav.setViewName("/supplier0/print_label");// 返回路径
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("打开打印预览页失败!", e);
        }
        return mav;
    }
 
    /**
     * 打印标签
     **/
    @ApiOperation(value = "打印标签", notes = "打印标签", hidden = true)
    @RequestMapping(value = "/printLabel", method = RequestMethod.POST)
    @ResponseBody
    public ApiResponseResult printLabel(@RequestBody Map<String, Object> params) {
        String barcodeType = params.get("barcodeType").toString();
        String suppNo = params.get("suppNo").toString();
        String ebeln = params.get("ebeln").toString();
        String remainQty = params.get("remainQty").toString();
        String materialNo = params.get("materialNo").toString();
        String qty = params.get("qty").toString();
        String prodDate = params.get("prodDate").toString();
        String shipDate = params.get("shipDate").toString();
        String envirTag = params.get("envirTag").toString();
        String shelfLife = params.get("shelfLife").toString();
        String flevel = params.get("flevel").toString();
        String printQty = params.get("printQty").toString();
        String remark = params.get("remark").toString();
        String actionType = params.get("actionType").toString();
        try {
            ApiResponseResult result = printService.printLabel(barcodeType, suppNo, ebeln,remainQty, materialNo, qty, prodDate,
                    shipDate, envirTag, shelfLife, flevel, printQty, remark,actionType);
            logger.debug(materialNo + ":打印" + barcodeType + "标签" + qty + "张");
            return result;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(materialNo + ":打印" + barcodeType + "标签" + qty + "张,失败", e);
            return ApiResponseResult.failure("打印" + materialNo + barcodeType + "标签失败!");
        }
    }
 
    /**
     * 打开打印送货单预览页-2022/6/23  lst -废除 不适合大数量处理
     **/
    /*@ApiOperation(value = "打印送货单预览页", notes = "打印送货单预览页", hidden = true)
    @RequestMapping(value = "/toPrintDeliver", method = RequestMethod.POST)
    public ModelAndView toPrintDeliver(String printData) {
        ModelAndView mav = new ModelAndView();
        try {
            mav.addObject("PRINT_DATA", printData);
            mav.setViewName("/supplier0/print_delivery");// 返回路径
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("打开打印送货单预览页失败!", e);
        }
        return mav;
    }*/
 
    /**
     * 打印送货单-2022/6/23 lst -仅做校验功能
     **/
    @ApiOperation(value = "打印送货单", notes = "打印送货单", hidden = true)
    @RequestMapping(value = "/printDelivery", method = RequestMethod.POST)
    @ResponseBody
    public ApiResponseResult printDelivery(@RequestBody Map<String, Object> params) {
        String deliveryNo = params.get("deliveryNo").toString();
        try {
            ApiResponseResult result = printService.printDelivery(deliveryNo);
            logger.debug("打印送货单:" + deliveryNo);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("打印送货单:" + deliveryNo + ",失败", e);
            return ApiResponseResult.failure("打印送货单" + deliveryNo + "失败!");
        }
    }
    
    /**
     * 获取送货单打印信息&打开打印送货单预览页合并 -2022/6/23 lst
     * 处理url too long (414)错误
     * **/
    @ApiOperation(value = "打印送货单预览页", notes = "打印送货单预览页", hidden = true)
    @RequestMapping(value = "/printDeliverB")
    public ModelAndView printDeliverB(String deliveryNo) {
        ModelAndView mav = new ModelAndView();
        try {
            ApiResponseResult result = printService.printDelivery(deliveryNo);
            mav.addObject("PRINT_DATA", result);
            mav.setViewName("/supplier0/print_delivery");// 返回路径
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("打开打印送货单预览页失败!", e);
        }
        return mav;
    }
    
    /**
     * 仅校验
     **/
    @ApiOperation(value = "重打标签", notes = "重打标签", hidden = true)
    @RequestMapping(value = "/rePrintLabelC", method = RequestMethod.POST)
    @ResponseBody
    public ApiResponseResult rePrintLabelC(@RequestBody Map<String, Object> params) {
        String labelId = params.get("labelId").toString();
        String actionType = params.get("actionType").toString();
        try {
            ApiResponseResult result = printService.rePrintLabel(labelId, actionType);
            logger.debug("重打标签:" + labelId);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("重打标签:" + labelId + ",失败", e);
            return ApiResponseResult.failure("重打标签:" + labelId + ",失败!");
        }
    }
    
    /**
     * 打开重打标签打印预览页
     **/
    @ApiOperation(value = "打印预览页", notes = "打印预览页", hidden = true)
    @RequestMapping(value = "/rePrintLabel")
    public ModelAndView rePrintLabel(String labelId,String actionType) {
        ModelAndView mav = new ModelAndView();
        try {
            ApiResponseResult result = printService.rePrintLabel(labelId, actionType);
            mav.addObject("PRINT_DATA", result);
            mav.setViewName("/supplier0/print_label");// 返回路径
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("打开打印预览页失败!", e);
        }
        return mav;
    }
    
}