From f0a2d3dc7607e9b22872c9bcb0b17c6ff3d019f4 Mon Sep 17 00:00:00 2001 From: e Date: Sat, 20 Oct 2018 22:07:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E4=B8=8D=E8=B5=B0=E6=8E=A7=E5=88=B6=E5=99=A8,=E6=8B=A3?= =?UTF-8?q?=E8=B4=A7=E5=8D=95=E5=A2=9E=E5=8A=A0=E4=BA=8C=E7=BB=B4=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wm/controller/WmOmNoticeHController.java | 62 -------- .../wmapi/controller/wmBaseController.java | 135 ++++++++++++++++++ src/main/resources/spring-mvc.xml | 2 +- .../com/zzjee/wm/print/jianhuorenwu-print.jsp | 11 +- 4 files changed, 142 insertions(+), 68 deletions(-) create mode 100644 src/main/java/com/zzjee/wmapi/controller/wmBaseController.java diff --git a/src/main/java/com/zzjee/wm/controller/WmOmNoticeHController.java b/src/main/java/com/zzjee/wm/controller/WmOmNoticeHController.java index f97e0862..06b23de8 100644 --- a/src/main/java/com/zzjee/wm/controller/WmOmNoticeHController.java +++ b/src/main/java/com/zzjee/wm/controller/WmOmNoticeHController.java @@ -2007,68 +2007,6 @@ public class WmOmNoticeHController extends BaseController { } - /** - * 获取图片流/获取文件用于下载 - * @param response - * @param request - * @throws Exception - * http://localhost:8080/zzjee/wmOmNoticeHController/showOrDownqrcodeByurl.do?&qrvalue=1111223333 调用 - */ - @RequestMapping(value="showOrDownqrcodeByurl",method = RequestMethod.GET) - public void getQrImgByurl(HttpServletResponse response, HttpServletRequest request) throws Exception{ - request.setCharacterEncoding("UTF-8"); - String flag=request.getParameter("down");//是否下载否则展示图片 - - String qrvalue = request.getParameter("qrvalue"); - String dbpath = qrvalue+".jpg"; - String localPath=ResourceUtil.getConfigByName("webUploadpath"); - - try{ - String imgurl = localPath+File.separator+dbpath; - QRcodeUtil.encode(qrvalue,imgurl); - }catch (Exception e){ - - } - if("1".equals(flag)){ - response.setContentType("application/x-msdownload;charset=utf-8"); - String fileName=dbpath.substring(dbpath.lastIndexOf(File.separator)+1); - - String userAgent = request.getHeader("user-agent").toLowerCase(); - if (userAgent.contains("msie") || userAgent.contains("like gecko") ) { - fileName = URLEncoder.encode(fileName, "UTF-8"); - }else { - fileName = new String(fileName.getBytes("UTF-8"), "iso-8859-1"); - } - response.setHeader("Content-disposition", "attachment; filename="+ fileName); - - }else{ - response.setContentType("image/jpeg;charset=utf-8"); - } - - InputStream inputStream = null; - OutputStream outputStream=null; - try { - String imgurl = localPath+File.separator+dbpath; - inputStream = new BufferedInputStream(new FileInputStream(imgurl)); - outputStream = response.getOutputStream(); - byte[] buf = new byte[1024]; - int len; - while ((len = inputStream.read(buf)) > 0) { - outputStream.write(buf, 0, len); - } - response.flushBuffer(); - } catch (Exception e) { - - }finally{ - if(inputStream!=null){ - inputStream.close(); - } - if(outputStream!=null){ - outputStream.close(); - } - } - } - diff --git a/src/main/java/com/zzjee/wmapi/controller/wmBaseController.java b/src/main/java/com/zzjee/wmapi/controller/wmBaseController.java new file mode 100644 index 00000000..55563c17 --- /dev/null +++ b/src/main/java/com/zzjee/wmapi/controller/wmBaseController.java @@ -0,0 +1,135 @@ +package com.zzjee.wmapi.controller; + +import com.zzjee.api.ResultDO; +import com.zzjee.wmapi.entity.WvGiEntity; +import com.zzjee.wmapi.service.WvGiServiceI; +import com.zzjee.wmutil.wmUtil; +import org.apache.log4j.Logger; +import org.jeecgframework.core.beanvalidator.BeanValidators; +import org.jeecgframework.core.common.controller.BaseController; +import org.jeecgframework.core.common.exception.BusinessException; +import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery; +import org.jeecgframework.core.common.model.json.AjaxJson; +import org.jeecgframework.core.common.model.json.DataGrid; +import org.jeecgframework.core.constant.Globals; +import org.jeecgframework.core.util.*; +import org.jeecgframework.poi.excel.ExcelImportUtil; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.entity.ImportParams; +import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants; +import org.jeecgframework.tag.core.easyui.TagUtil; +import org.jeecgframework.web.system.service.SystemService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.util.UriComponentsBuilder; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.validation.ConstraintViolation; +import javax.validation.Validator; +import java.io.*; +import java.net.URI; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @Title: wmBaseControllerController + * @Description: wmBaseController + * @author erzhongxmu + * @date 2018-05-30 20:21:50 + * @version V1.0 + * + */ +@Controller +@RequestMapping("/wmBaseController") +public class wmBaseController extends BaseController { + /** + * Logger for this class + */ + private static final Logger logger = Logger.getLogger(wmBaseController.class); + + @Autowired + private WvGiServiceI wvGiService; + @Autowired + private SystemService systemService; + @Autowired + private Validator validator; + + + + /** + * 获取图片流/获取文件用于下载 + * @param response + * @param request + * @throws Exception + * http://localhost:8080/zzjee/wmOmNoticeHController/showOrDownqrcodeByurl.do?&qrvalue=1111223333 调用 + */ + + @RequestMapping(value="showOrDownqrcodeByurl",method = RequestMethod.GET) + public void getQrImgByurl(HttpServletResponse response, HttpServletRequest request) throws Exception{ + request.setCharacterEncoding("UTF-8"); + String flag=request.getParameter("down");//是否下载否则展示图片 + + String qrvalue = request.getParameter("qrvalue"); + String dbpath = qrvalue+".jpg"; + String localPath=ResourceUtil.getConfigByName("webUploadpath"); + + try{ + String imgurl = localPath+File.separator+dbpath; + QRcodeUtil.encode(qrvalue,imgurl); + }catch (Exception e){ + + } + if("1".equals(flag)){ + response.setContentType("application/x-msdownload;charset=utf-8"); + String fileName=dbpath.substring(dbpath.lastIndexOf(File.separator)+1); + + String userAgent = request.getHeader("user-agent").toLowerCase(); + if (userAgent.contains("msie") || userAgent.contains("like gecko") ) { + fileName = URLEncoder.encode(fileName, "UTF-8"); + }else { + fileName = new String(fileName.getBytes("UTF-8"), "iso-8859-1"); + } + response.setHeader("Content-disposition", "attachment; filename="+ fileName); + + }else{ + response.setContentType("image/jpeg;charset=utf-8"); + } + + InputStream inputStream = null; + OutputStream outputStream=null; + try { + String imgurl = localPath+File.separator+dbpath; + inputStream = new BufferedInputStream(new FileInputStream(imgurl)); + outputStream = response.getOutputStream(); + byte[] buf = new byte[1024]; + int len; + while ((len = inputStream.read(buf)) > 0) { + outputStream.write(buf, 0, len); + } + response.flushBuffer(); + } catch (Exception e) { + + }finally{ + if(inputStream!=null){ + inputStream.close(); + } + if(outputStream!=null){ + outputStream.close(); + } + } + } + +} diff --git a/src/main/resources/spring-mvc.xml b/src/main/resources/spring-mvc.xml index 64e71fef..93e87523 100644 --- a/src/main/resources/spring-mvc.xml +++ b/src/main/resources/spring-mvc.xml @@ -125,7 +125,7 @@ rest/wvStockController rest/wmSttInGoodsController rest/wmToMoveGoodsController - wmOmNoticeHController.do?showOrDownqrcodeByurl + rest/wmBaseController/showOrDownqrcodeByurl webpage/common/functionIconStyleList.jsp diff --git a/src/main/webapp/webpage/com/zzjee/wm/print/jianhuorenwu-print.jsp b/src/main/webapp/webpage/com/zzjee/wm/print/jianhuorenwu-print.jsp index 420419d3..9ee8f176 100644 --- a/src/main/webapp/webpage/com/zzjee/wm/print/jianhuorenwu-print.jsp +++ b/src/main/webapp/webpage/com/zzjee/wm/print/jianhuorenwu-print.jsp @@ -194,14 +194,15 @@ document.onreadystatechange = function () { 数量 托盘 - 备注 - + 流通码 + + - + ${poVal.binId }  ${poVal.goodsId } ${poVal.goodsName } @@ -209,8 +210,8 @@ document.onreadystatechange = function () { ${poVal.proData } ${poVal.baseGoodscount } ${poVal.tinId } -   - + ${poVal.barCode }  +