Index: ssts-web/src/main/webapp/disinfectsystem/sterilizationmanager/sterilizationrecord/sterilizationRecordPic.js =================================================================== diff -u -r15677 -r15684 --- ssts-web/src/main/webapp/disinfectsystem/sterilizationmanager/sterilizationrecord/sterilizationRecordPic.js (.../sterilizationRecordPic.js) (revision 15677) +++ ssts-web/src/main/webapp/disinfectsystem/sterilizationmanager/sterilizationrecord/sterilizationRecordPic.js (.../sterilizationRecordPic.js) (revision 15684) @@ -165,11 +165,11 @@ alert(e.message); } }, - restore: function(el){ + restore: function(el,sWidth,sHeight){ var width = el.getWidth(); var height = el.getHeight(); - var nwidth = srcWidth; - var nheight = srcHeight; + var nwidth = sWidth; + var nheight = sHeight; var left = (width > nwidth) ? -((nwidth - width) / 2):((width - nwidth) / 2); var top = (height > nheight) ? -((nheight - height) / 2):((height - nheight) / 2); try{ @@ -409,6 +409,22 @@ image.src = url;// 覆盖原来的图片 var element = top.Ext.get(toolbarPage.el); element.update('第' + page + '页'); + // 获取图片宽高,还原图片 + Ext.Ajax.request({ + url : WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPicHW.do?id='+ id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&time='+new Date(), + success : function(result){ + var re = Ext.decode(result.responseText); + var height = re.height; + var width = re.width; + // 还原大小 + if(width > 0 && height > 0){ + Ext.get(currentImageId).parent.restore(imageBrowse,width,height); + } + }, + failure : function(){ + + } + }); currentRotateWidth = 0; currentRotateHeight = 0; continueRotateCount = 0; @@ -433,18 +449,29 @@ currentRotateHeight = 0; continueRotateCount = 0; var imageBrowse = Ext.get(currentImageId); - -// if(lastRotateIndex == 1 || lastRotateIndex == 3){ -// // 已经旋转过图片,宽高需要互换 -// Ext.get(currentImageId).parent.switchHeightWidth(imageBrowse); -// } // 还原大小 - Ext.get(currentImageId).parent.restore(imageBrowse); +// Ext.get(currentImageId).parent.restore(imageBrowse); var url = WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPic.do?id=' + id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&time='+new Date(); - var image = imageBrowse.dom; - image.src = url;// 覆盖原来的图片 - var element = top.Ext.get(toolbarPage.el); - element.update('第' + page + '页'); + // 获取图片宽高,还原图片 + Ext.Ajax.request({ + url : WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPicHW.do?id='+ id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&time='+new Date(), + success : function(result){ + var re = Ext.decode(result.responseText); + var height = re.height; + var width = re.width; + // 还原大小 + if(width > 0 && height > 0){ + Ext.get(currentImageId).parent.restore(imageBrowse,width,height); + } + var image = imageBrowse.dom; + image.src = url;// 覆盖原来的图片 + var element = top.Ext.get(toolbarPage.el); + element.update('第' + page + '页'); + }, + failure : function(){ + + } + }); } }, toolbarPage, @@ -463,17 +490,29 @@ currentRotateHeight = 0; continueRotateCount = 0; var imageBrowse = Ext.get(currentImageId); -// if(lastRotateIndex == 1 || lastRotateIndex == 3){ -// // 已经旋转过图片,宽高需要互换 -// Ext.get(currentImageId).parent.switchHeightWidth(imageBrowse); -// } - // 还原大小 - Ext.get(currentImageId).parent.restore(imageBrowse); var url = WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPic.do?id=' + id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&time='+new Date(); - var image = imageBrowse.dom; - image.src = url;// 覆盖原来的图片 - var element = top.Ext.get(toolbarPage.el); - element.update('第' + page + '页'); + // 获取图片宽高,还原图片 + var width = 0; + var height = 0; + Ext.Ajax.request({ + url : WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPicHW.do?id='+ id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&time='+new Date(), + success : function(result){ + var re = Ext.decode(result.responseText); + height = re.height; + width = re.width; + // 还原大小 + if(width > 0 && height > 0){ + Ext.get(currentImageId).parent.restore(imageBrowse,width,height); + } + var image = imageBrowse.dom; + image.src = url;// 覆盖原来的图片 + var element = top.Ext.get(toolbarPage.el); + element.update('第' + page + '页'); + }, + failure : function(){ + + } + }); } }] }] @@ -510,7 +549,7 @@ sterilizationRecordWin.show(); // alert( srcWidth + " : " + srcHeight); // 图片的原始宽高 - srcWidth = Ext.get(currentImageId).getWidth(); - srcHeight = Ext.get(currentImageId).getHeight(); +// srcWidth = Ext.get(currentImageId).getWidth(); +// srcHeight = Ext.get(currentImageId).getHeight(); } \ No newline at end of file Index: ssts-sterile/src/main/java/com/forgon/disinfectsystem/sterilizationmanager/sterilizationrecord/action/SterilizationRecordAction.java =================================================================== diff -u -r15657 -r15684 --- ssts-sterile/src/main/java/com/forgon/disinfectsystem/sterilizationmanager/sterilizationrecord/action/SterilizationRecordAction.java (.../SterilizationRecordAction.java) (revision 15657) +++ ssts-sterile/src/main/java/com/forgon/disinfectsystem/sterilizationmanager/sterilizationrecord/action/SterilizationRecordAction.java (.../SterilizationRecordAction.java) (revision 15684) @@ -1,5 +1,7 @@ package com.forgon.disinfectsystem.sterilizationmanager.sterilizationrecord.action; +import java.awt.image.BufferedImage; +import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; @@ -17,6 +19,7 @@ import java.util.Set; import java.util.UUID; +import javax.imageio.ImageIO; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -68,6 +71,7 @@ import com.forgon.tools.StrutsResponseUtils; import com.forgon.tools.db.DatabaseUtil; import com.forgon.tools.hibernate.ObjectDao; +import com.forgon.tools.json.JSONUtil; import com.forgon.tools.json.JsonPropertyFilter; import com.forgon.tools.string.StringTools; import com.forgon.tools.util.FileUtils; @@ -1118,6 +1122,53 @@ } } /** + * 获取灭菌记录图片宽高 + */ + public void getSterilizationRecordPicHW(){ + String page = StrutsParamUtils.getPraramValue("page", "1"); + String indexStr = StrutsParamUtils.getPraramValue("rotateIndex", "0"); + int rotateIndex = Integer.valueOf(indexStr); + List pictureList = sterilizationRecord + .getRecordPictures(); + int pageSize = pictureList.size(); + int width = 0; + int height = 0; + try { + if (StringUtils.isNumeric(page)) { + int pageIndex = Integer.parseInt(page); + if(pageIndex <= pageSize){ + SterilizationRecordPic picture = pictureList.get(pageIndex - 1); + String saveImagePath = supplyRoomConfigManager + .getSystemParamsObj().getSaveImagePath(); + String thumbnailImagePath = "\\thumbnail";// 缩略图路径 + String thumbnailImageAbsolutePath = saveImagePath + + thumbnailImagePath; + String filePath = thumbnailImageAbsolutePath + "\\" + picture.getThumbnailFileName(); + if(rotateIndex == 0){ + if(FileUtils.fileExist(filePath)){ + BufferedImage bufferedImage = ImageIO.read(new File(filePath)); + width = bufferedImage.getWidth(); + height = bufferedImage.getHeight(); + } + }else{ + String rotaeFileName = filePath.replace(".jpg", "") + rotateIndex + ".jpg"; + if(FileUtils.fileExist(rotaeFileName)){ + BufferedImage bufferedImage = ImageIO.read(new File(rotaeFileName)); + width = bufferedImage.getWidth(); + height = bufferedImage.getHeight(); + } + } + } + } + JSONObject obj = new JSONObject(); + JSONUtil.addProperty(obj, "height", height); + JSONUtil.addProperty(obj, "width", width); + StrutsResponseUtils.output(obj); + } catch (IOException e) { + e.printStackTrace(); + } + } + /** * 灭菌图片 */ public void getSterilizationRecordPic() {