Index: ssts-web/src/main/webapp/disinfectsystem/sterilizationmanager/sterilizationrecord/sterilizationRecordPic.js =================================================================== diff -u -r15684 -r16406 --- ssts-web/src/main/webapp/disinfectsystem/sterilizationmanager/sterilizationrecord/sterilizationRecordPic.js (.../sterilizationRecordPic.js) (revision 15684) +++ ssts-web/src/main/webapp/disinfectsystem/sterilizationmanager/sterilizationrecord/sterilizationRecordPic.js (.../sterilizationRecordPic.js) (revision 16406) @@ -14,6 +14,8 @@ var currentRotateHeight = 0; // 连续选择次数 var continueRotateCount = 0; +// 是否显示源图 +var showSourceImg = false; Ext.onReady(function() { //屏蔽右击事件 @@ -305,6 +307,7 @@ currentRotateWidth = 0; currentRotateHeight = 0; continueRotateCount = 0; + showSourceImg = false; var toolbarPage = new top.Ext.Toolbar.TextItem({ text : '第1页' }); @@ -361,7 +364,7 @@ continueRotateCount++; // 切换宽高 Ext.get(currentImageId).parent.switchHeightWidth(imageBrowse,currentRotateWidth,currentRotateHeight,continueRotateCount); - var url = WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPic.do?id=' + id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&time='+new Date(); + var url = WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPic.do?id=' + id + '&page=' + page + '&rotateIndex=' + curRotateIndex +'&showSourceImg=' + showSourceImg + '&time='+new Date(); var image = imageBrowse.dom; image.src = url;// 覆盖原来的图片 } @@ -382,7 +385,7 @@ continueRotateCount++; // 切换宽高 Ext.get(currentImageId).parent.switchHeightWidth(imageBrowse,currentRotateWidth,currentRotateHeight,continueRotateCount); - var url = WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPic.do?id=' + id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&time='+new Date(); + var url = WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPic.do?id=' + id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&showSourceImg=' + showSourceImg +'&time='+new Date(); var image = imageBrowse.dom; image.src = url;// 覆盖原来的图片 @@ -403,15 +406,15 @@ element.update('共' + totalPage + '页'); // 删除后显示第一张 page = 1; - var url = WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPic.do?id=' + id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&time='+new Date(); + var url = WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPic.do?id=' + id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&showSourceImg=' + showSourceImg +'&time='+new Date(); var imageBrowse = Ext.get(currentImageId); 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(), + url : WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPicHW.do?id='+ id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&showSourceImg=' + showSourceImg +'&time='+new Date(), success : function(result){ var re = Ext.decode(result.responseText); var height = re.height; @@ -436,6 +439,42 @@ } },{ xtype : 'button', + text : "切换缩略图和原图", + handler : function(){ + if(showSourceImg == true){ + showSourceImg = false; + }else{ + showSourceImg = true; + } + curRotateIndex = 0; + currentRotateWidth = 0; + currentRotateHeight = 0; + continueRotateCount = 0; + var imageBrowse = Ext.get(currentImageId); + var url = WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPic.do?id=' + id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&showSourceImg=' + showSourceImg + '&time='+new Date(); + // 获取图片宽高,还原图片 + Ext.Ajax.request({ + url : WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPicHW.do?id='+ id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&showSourceImg=' + showSourceImg + '&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(){ + + } + }); + } + },{ + xtype : 'button', text : '上一页', handler : function(){ if (page - 1 <= 0) { @@ -451,10 +490,10 @@ var imageBrowse = Ext.get(currentImageId); // 还原大小 // Ext.get(currentImageId).parent.restore(imageBrowse); - var url = WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPic.do?id=' + id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&time='+new Date(); + var url = WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPic.do?id=' + id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&showSourceImg=' + showSourceImg +'&time='+new Date(); // 获取图片宽高,还原图片 Ext.Ajax.request({ - url : WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPicHW.do?id='+ id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&time='+new Date(), + url : WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPicHW.do?id='+ id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&showSourceImg=' + showSourceImg +'&time='+new Date(), success : function(result){ var re = Ext.decode(result.responseText); var height = re.height; @@ -490,12 +529,12 @@ currentRotateHeight = 0; continueRotateCount = 0; var imageBrowse = Ext.get(currentImageId); - var url = WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPic.do?id=' + id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&time='+new Date(); + var url = WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPic.do?id=' + id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&showSourceImg=' + showSourceImg +'&time='+new Date(); // 获取图片宽高,还原图片 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(), + url : WWWROOT + '/disinfectSystem/sterilization/sterilizationRecordAction!getSterilizationRecordPicHW.do?id='+ id + '&page=' + page + '&rotateIndex=' + curRotateIndex + '&showSourceImg=' + showSourceImg +'&time='+new Date(), success : function(result){ var re = Ext.decode(result.responseText); height = re.height; Index: ssts-sterile/src/main/java/com/forgon/disinfectsystem/sterilizationmanager/sterilizationrecord/action/SterilizationRecordAction.java =================================================================== diff -u -r16402 -r16406 --- ssts-sterile/src/main/java/com/forgon/disinfectsystem/sterilizationmanager/sterilizationrecord/action/SterilizationRecordAction.java (.../SterilizationRecordAction.java) (revision 16402) +++ ssts-sterile/src/main/java/com/forgon/disinfectsystem/sterilizationmanager/sterilizationrecord/action/SterilizationRecordAction.java (.../SterilizationRecordAction.java) (revision 16406) @@ -1144,6 +1144,11 @@ List pictureList = sterilizationRecord .getRecordPictures(); int pageSize = pictureList.size(); + String nshowSourceImgStr = StrutsParamUtils.getPraramValue("showSourceImg", ""); + boolean showSourceImg = false; + if(StringUtils.equals("true", nshowSourceImgStr)) { + showSourceImg = true; + } int width = 0; int height = 0; try { @@ -1157,6 +1162,10 @@ String thumbnailImageAbsolutePath = saveImagePath + thumbnailImagePath; String filePath = thumbnailImageAbsolutePath + "\\" + picture.getThumbnailFileName(); + if(showSourceImg){ + // 获取原图 + filePath = picture.getFilePath(); + } if(rotateIndex == 0){ if(FileUtils.fileExist(filePath)){ BufferedImage bufferedImage = ImageIO.read(new File(filePath)); @@ -1187,6 +1196,11 @@ public void getSterilizationRecordPic() { String page = StrutsParamUtils.getPraramValue("page", "1"); String indexStr = StrutsParamUtils.getPraramValue("rotateIndex", "0"); + String nshowSourceImgStr = StrutsParamUtils.getPraramValue("showSourceImg", ""); + boolean showSourceImg = false; + if(StringUtils.equals("true", nshowSourceImgStr)) { + showSourceImg = true; + } int rotateIndex = Integer.valueOf(indexStr); byte[] img = null; if (StringUtils.isNumeric(page)) { @@ -1206,16 +1220,11 @@ + thumbnailImagePath; int rangle = 90 * rotateIndex; String filePath = thumbnailImageAbsolutePath + "\\" + picture.getThumbnailFileName(); - if( FileUtils.fileExist(filePath) ){ - if(rangle == 0){ - img = FileUtils.readFileBytes(filePath); - }else{ - String rotaeFileName = filePath.replace(".jpg", "") + rotateIndex + ".jpg"; - if(!FileUtils.fileExist(rotaeFileName)){ - FileUtils.rotatePicAndSave(filePath, rangle, rotaeFileName); - } - img = FileUtils.readFileBytes(rotaeFileName); - } + if(showSourceImg){ + // 显示原图 + img = getImgByPathAndRangle(picture.getFilePath(),rotateIndex); + }else if( FileUtils.fileExist(filePath) ){ + img = getImgByPathAndRangle(filePath,rotateIndex); }else{ // 找不到缩略图,尝试找源图显示 filePath = picture.getFilePath(); @@ -1262,7 +1271,29 @@ } } } - + /** + * 通过图片路劲,和旋转的角度,获取图片数据,如果该角度的图片不存在,则创建 + * @param filePath + * @param range + * @return + */ + private byte[] getImgByPathAndRangle(String filePath,int rotateIndex){ + byte[] img = null; + int rangle = 90 * rotateIndex; + if(StringUtils.isNotBlank(filePath) && FileUtils.fileExist(filePath)){ + if(rangle == 0){ + img = FileUtils.readFileBytes(filePath); + }else{ + String rotaeFileName = filePath.replace(".jpg", "") + rotateIndex + ".jpg"; + if(!FileUtils.fileExist(rotaeFileName)){ + FileUtils.rotatePicAndSave(filePath, rangle, rotaeFileName); + } + img = FileUtils.readFileBytes(rotaeFileName); + } + } + return img; + } + public void iniInfo() { String id = StrutsParamUtils.getPraramValue("id", ""); if (StringUtils.isNotBlank(id) && !id.equals("0")) {