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;
|
}
|
|
}
|