Index: ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/imagefilemanager/action/ShowImageAction.java =================================================================== diff -u -r25725 -r31456 --- ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/imagefilemanager/action/ShowImageAction.java (.../ShowImageAction.java) (revision 25725) +++ ssts-tousse/src/main/java/com/forgon/disinfectsystem/tousse/imagefilemanager/action/ShowImageAction.java (.../ShowImageAction.java) (revision 31456) @@ -1,16 +1,20 @@ package com.forgon.disinfectsystem.tousse.imagefilemanager.action; +import java.awt.image.BufferedImage; +import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.net.URLDecoder; import java.util.List; import java.util.Map; +import javax.imageio.ImageIO; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import net.sf.json.JSONObject; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.Namespace; @@ -21,6 +25,11 @@ import com.forgon.disinfectsystem.entity.basedatamanager.imagefilemanager.ImageFile; import com.forgon.disinfectsystem.entity.basedatamanager.materialdefinition.MaterialDefinition; import com.forgon.disinfectsystem.entity.basedatamanager.toussedefinition.TousseDefinition; +import com.forgon.disinfectsystem.entity.qualitymonitoringmanager.qualitymonitoring.QualityMonitoringInstance; +import com.forgon.disinfectsystem.entity.sterilizationmanager.sterilizationrecord.SterilizationRecord; +import com.forgon.disinfectsystem.entity.sterilizationmanager.sterilizationrecord.SterilizationRecordPic; +import com.forgon.disinfectsystem.entity.washanddisinfectmanager.washanddisinfectrecord.WashAndDisinfectPic; +import com.forgon.disinfectsystem.entity.washanddisinfectmanager.washanddisinfectrecord.WashAndDisinfectRecord; import com.forgon.disinfectsystem.expensiveGoods.service.ExpensiveGoodsBillManager; import com.forgon.disinfectsystem.tousse.imagefilemanager.service.ImageFileManager; import com.forgon.disinfectsystem.tousse.materialdefinition.service.MaterialDefinitionManager; @@ -50,6 +59,9 @@ private SupplyRoomConfigManager supplyRoomConfigManager; private ExpensiveGoodsBillManager expensiveGoodsBillManager; private ObjectDao objectDao; + private Integer width; + private Integer height; + private Integer pageSize; public void setObjectDao(ObjectDao objectDao) { this.objectDao = objectDao; @@ -123,14 +135,32 @@ String page = StrutsParamUtils.getPraramValue("page", "1"); String imageType = StrutsParamUtils.getPraramValue("imageType", ""); String objectId = StrutsParamUtils.getPraramValue("objectId", ""); + 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.isNotBlank(objectId)) { if (ImageFile.IMAGE_TYPE_ExpensiveGoodsBill.equals(imageType)) { ExpensiveGoodsBill expensiveGoodsBill = expensiveGoodsBillManager .getExpensiveGoodsBillById(objectId); if(expensiveGoodsBill!=null){ - img = imageFileManager.getImageByIdAndType(expensiveGoodsBill.getId(), - ImageFile.IMAGE_TYPE_ExpensiveGoodsBill, page); + int rangle = 90 * rotateIndex; + if(rangle == 0){ + img = imageFileManager.getImageByIdAndType(expensiveGoodsBill.getId(), + ImageFile.IMAGE_TYPE_ExpensiveGoodsBill, page, showSourceImg); + }else{ + ImageFile imageFile = imageFileManager.getImageAt(expensiveGoodsBill.getId(), ImageFile.IMAGE_TYPE_ExpensiveGoodsBill, Integer.parseInt(page)); + String filePath = getImagePath(imageFile, Integer.parseInt(page), showSourceImg); + String rotaeFileName = filePath.replace(".jpg", "") + rotateIndex + ".jpg"; + if(!FileUtils.fileExist(rotaeFileName)){ + FileUtils.rotatePicAndSave(filePath, rangle, rotaeFileName); + } + img = FileUtils.readFileBytes(rotaeFileName); + } } } } @@ -368,4 +398,295 @@ return json; } + /** + * 查看图片(高值耗材发票图片、质量监测图片、生物监测图片、灭菌记录图片、清洗记录图片) + */ + public void getImage(){ + String page = StrutsParamUtils.getPraramValue("page", "1"); + String imageType = StrutsParamUtils.getPraramValue("imageType", ""); + String objectIdStr = StrutsParamUtils.getPraramValue("objectId", ""); + String rotateIndexStr = StrutsParamUtils.getPraramValue("rotateIndex", "0"); + String nshowSourceImgStr = StrutsParamUtils.getPraramValue("showSourceImg", ""); + boolean showSourceImg = false; + if(StringUtils.equals("true", nshowSourceImgStr)) { + showSourceImg = true; + } + int rotateIndex = Integer.valueOf(rotateIndexStr); + byte[] img = null; + if (StringUtils.isNotBlank(objectIdStr)) { + int pageIndex = Integer.parseInt(page); + Object imageObject = getImageObject(imageType, objectIdStr, pageIndex); + if(imageObject != null){ + if(imageObject instanceof ImageFile){ + // 图片保存到了数据库中 + ImageFile image = (ImageFile) imageObject; + img = image.getImage(); + } + if(img == null || img.length == 0){ + // 读取图片文件 + String filePath = getImagePath(imageObject, pageIndex, showSourceImg); + img = getImgByPathAndRangle(filePath, rotateIndex); + } + } + } + img = ImageUtils.defaultIfEmpty(img); + OutputStream outputStream = null; + try { + HttpServletResponse response = StrutsParamUtils.getResponse(); + response.setContentType("image/jpeg"); + outputStream = response.getOutputStream(); + outputStream.write(img, 0, img.length); + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (outputStream != null) { + try { + outputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + /** + * 获取图片宽高(高值耗材发票图片、质量监测图片、生物监测图片、灭菌记录图片、清洗记录图片) + */ + public void getImageHW(){ + String page = StrutsParamUtils.getPraramValue("page", "1"); + String indexStr = StrutsParamUtils.getPraramValue("rotateIndex", "0"); + String imageType = StrutsParamUtils.getPraramValue("imageType", ""); + String objectIdStr = StrutsParamUtils.getPraramValue("objectId", ""); + String nshowSourceImgStr = StrutsParamUtils.getPraramValue("showSourceImg", ""); + boolean showSourceImg = false; + if(StringUtils.equals("true", nshowSourceImgStr)) { + showSourceImg = true; + } + int rotateIndex = Integer.valueOf(indexStr); + this.height = 0; + this.width = 0; + try { + if(DatabaseUtil.isPoIdValid(objectIdStr)){ + int pageIndex = Integer.parseInt(page); + Object imageObject = getImageObject(imageType, objectIdStr, pageIndex); + if(imageObject != null){ + String filePath = getImagePath(imageObject, pageIndex, showSourceImg); + getImageHW(filePath, rotateIndex, showSourceImg); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + JSONObject obj = new JSONObject(); + JSONUtil.addProperty(obj, "height", this.height); + JSONUtil.addProperty(obj, "width", this.width); + JSONUtil.addProperty(obj, "totalPage", this.pageSize); + StrutsResponseUtils.output(obj); + } + + /** + * 删除图片(高值耗材发票图片、质量监测图片、生物监测图片、灭菌记录图片、清洗记录图片) + */ + public void deleteImage(){ + String page = StrutsParamUtils.getPraramValue("page", "1"); + String imageType = StrutsParamUtils.getPraramValue("imageType", ""); + String objectIdStr = StrutsParamUtils.getPraramValue("objectId", ""); + //imageType = "灭菌记录图片"; + int pageSize = 0; + if(DatabaseUtil.isPoIdValid(objectIdStr)){ + int pageIndex = Integer.parseInt(page); + // 获取图片 + Object imageObject = getImageObject(imageType, objectIdStr, pageIndex); + if(imageObject != null){ + if(imageObject instanceof ImageFile){ + ImageFile imageFile = (ImageFile) imageObject; + imageFileManager.deleteImageFile(imageFile); + }else { + objectDao.delete(imageObject); + } + pageSize--; + } + + } + StrutsResponseUtils.output(pageSize); + } + + /** + * 获取图片对象(ImageFile、SterilizationRecordPic、WashAndDisinfectPic) + * @param imageType + * @param objectIdStr + * @param pageIndex + * @return + */ + private Object getImageObject(String imageType, String objectIdStr, int pageIndex) { + Object imageObject = null; + if(ImageFile.IMAGE_TYPE_ExpensiveGoodsBill.equals(imageType) + || ImageFile.IMAGE_TYPE_QUALITYMONITORING.equals(imageType) + || ImageFile.IMAGE_TYPE_STERILIZATION.equals(imageType)){ + // 验证图片的关联对象是否存在 + Long objectId = getObjectIdByImageType(imageType, objectIdStr); + if(DatabaseUtil.isPoIdValid(objectId)){ + String sql = " where po.objectId = '" + + objectIdStr + "' and po.imageType = '" + + imageType + + "' order by po.serialNum asc"; + List imagesList = imageFileManager.getImageFileBySql(sql); + if(CollectionUtils.isNotEmpty(imagesList)){ + pageSize = imagesList.size(); + if(pageIndex <= pageSize){ + imageObject = imagesList.get(pageIndex - 1); + } + } + } + }else if(StringUtils.equals(imageType, "灭菌记录图片")){ + SterilizationRecord sterilizationRecord = (SterilizationRecord) objectDao.getById(SterilizationRecord.class.getSimpleName(), objectIdStr); + if(sterilizationRecord != null){ + List pictureList = sterilizationRecord.getRecordPictures(); + if(CollectionUtils.isNotEmpty(pictureList)){ + pageSize = pictureList.size(); + if(pageIndex <= pageSize){ + imageObject = pictureList.get(pageIndex - 1); + } + } + } + } else if(StringUtils.equals(imageType, "清洗记录图片")){ + WashAndDisinfectRecord washAndDisinfectRecord = (WashAndDisinfectRecord) objectDao.getById(WashAndDisinfectRecord.class.getSimpleName(), objectIdStr); + if(washAndDisinfectRecord != null){ + List pictureList = washAndDisinfectRecord.getWashAndDisinfectPictures(); + if(CollectionUtils.isNotEmpty(pictureList)){ + pageSize = pictureList.size(); + if(pageIndex <= pageSize){ + imageObject = pictureList.get(pageIndex - 1); + } + } + } + } + return imageObject; + } + + /** + * 通过图片路径,和旋转的角度,获取图片数据,如果该角度的图片不存在,则创建 + * @param filePath + * @param rotateIndex + * @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; + } + + /** + * 获取图片文件路径 + * @param imagesList + * @param pageIndex + * @param showSourceImg 是否显示原图,显示原图则返回原图的文件路径,显示缩略图则返回缩略图的文件路径 + * @return + */ + private String getImagePath(Object imageObject, int pageIndex, boolean showSourceImg) { + String saveImagePath = supplyRoomConfigManager.getSystemParamsObj().getSaveImagePath(); + String filePath = ""; + if(imageObject instanceof ImageFile){ + ImageFile imageFile = (ImageFile) imageObject; + String uuidImageName = null; + String imagePath = null; + if(showSourceImg){ + imagePath = imageFile.getImagePath(); + uuidImageName = imageFile.getUUIDImageName(); + }else{ + imagePath = imageFile.getThumbnailImagePath(); + uuidImageName = imageFile.getUUIDAndImageName(); + } + filePath = saveImagePath + imagePath + "\\" + uuidImageName; + }else if (imageObject instanceof SterilizationRecordPic){ + SterilizationRecordPic sterilizationRecordPic = (SterilizationRecordPic) imageObject; + String thumbnailImagePath = "\\thumbnail";// 缩略图路径 + String thumbnailImageAbsolutePath = saveImagePath + + thumbnailImagePath; + filePath = thumbnailImageAbsolutePath + "\\" + sterilizationRecordPic.getThumbnailFileName(); + if(showSourceImg){ + // 获取原图 + filePath = sterilizationRecordPic.getFilePath(); + } + }else if(imageObject instanceof WashAndDisinfectPic){ + WashAndDisinfectPic washAndDisinfectPic = (WashAndDisinfectPic) imageObject; + String thumbnailImagePath = "\\thumbnail";// 缩略图路径 + String thumbnailImageAbsolutePath = saveImagePath + + thumbnailImagePath; + filePath = thumbnailImageAbsolutePath + "\\" + washAndDisinfectPic.getThumbnailFileName(); + if(showSourceImg){ + // 获取原图 + filePath = washAndDisinfectPic.getFilePath(); + } + } + return filePath; + } + + /** + * 获取图片的宽高 + * @param filePath + * @param rotateIndex + * @param showSourceImg + * @param height + * @param width + * @throws Exception + */ + private void getImageHW(String filePath, int rotateIndex, boolean showSourceImg) throws Exception { + if(rotateIndex == 0){ + if(FileUtils.fileExist(filePath)){ + BufferedImage bufferedImage = ImageIO.read(new File(filePath)); + this.width = bufferedImage.getWidth(); + this.height = bufferedImage.getHeight(); + } + }else{ + String rotaeFileName = filePath.replace(".jpg", "") + rotateIndex + ".jpg"; + if(!FileUtils.fileExist(rotaeFileName)){ + int rangle = 90 * rotateIndex; + FileUtils.rotatePicAndSave(filePath, rangle, rotaeFileName); + } + BufferedImage bufferedImage = ImageIO.read(new File(rotaeFileName)); + this.width = bufferedImage.getWidth(); + this.height = bufferedImage.getHeight(); + } + + } + + /** + * 根据图片类型和关联对象id查找关联对象 + * @param imageType + * @param objectIdStr + * @return + */ + private Long getObjectIdByImageType(String imageType, String objectIdStr) { + Long objectID = null; + if(ImageFile.IMAGE_TYPE_ExpensiveGoodsBill.equals(imageType)){ + ExpensiveGoodsBill expensiveGoodsBill = expensiveGoodsBillManager.getExpensiveGoodsBillById(objectIdStr); + if(expensiveGoodsBill != null){ + objectID = expensiveGoodsBill.getId(); + } + }else if(ImageFile.IMAGE_TYPE_QUALITYMONITORING.equals(imageType)){ + QualityMonitoringInstance qmInstance = (QualityMonitoringInstance) objectDao.getById(QualityMonitoringInstance.class.getSimpleName(), objectIdStr); + if(qmInstance != null){ + objectID = qmInstance.getId(); + } + }else if(ImageFile.IMAGE_TYPE_STERILIZATION.equals(imageType)){ + SterilizationRecord sterilizationRecord = (SterilizationRecord) objectDao.getById(SterilizationRecord.class.getSimpleName(), objectIdStr); + if(sterilizationRecord != null){ + objectID = sterilizationRecord.getId(); + } + } + return objectID; + } + } Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/basedatamanager/imagefilemanager/ImageFile.java =================================================================== diff -u -r31368 -r31456 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/basedatamanager/imagefilemanager/ImageFile.java (.../ImageFile.java) (revision 31368) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/entity/basedatamanager/imagefilemanager/ImageFile.java (.../ImageFile.java) (revision 31456) @@ -55,7 +55,7 @@ public static final String IMAGE_TYPE_TOUSSEPACKING = "器械包装配教学图片"; public static final String IMAGE_TYPE_QUALITYMONITORING = "质量监测图片"; public static final String IMAGE_TYPE_STAFFARCHIVE = "员工头像"; - public static final String IMAGE_TYPE_STERILIZATION = "灭菌监测图片"; + public static final String IMAGE_TYPE_STERILIZATION = "生物监测图片"; public static final String IMAGE_TYPE_WASHANDDISINFECT = "清洗监测图片"; public static final String IMAGE_TYPE_SPECIFICATION = "器械包说明书"; public static final String IMAGE_TYPE_CERTIFICATION = "高值耗材注册证图片"; Index: ssts-web/src/main/webapp/dataUpdater/sqls/4.9.76_4.9.77.sql =================================================================== diff -u --- ssts-web/src/main/webapp/dataUpdater/sqls/4.9.76_4.9.77.sql (revision 0) +++ ssts-web/src/main/webapp/dataUpdater/sqls/4.9.76_4.9.77.sql (revision 31456) @@ -0,0 +1 @@ +update ImageFile set imageType = '生物监测图片' where imageType = '灭菌监测图片'; \ No newline at end of file Index: forgon-tools/src/main/java/com/forgon/Constants.java =================================================================== diff -u -r31368 -r31456 --- forgon-tools/src/main/java/com/forgon/Constants.java (.../Constants.java) (revision 31368) +++ forgon-tools/src/main/java/com/forgon/Constants.java (.../Constants.java) (revision 31456) @@ -26,7 +26,7 @@ "4.9.7","4.9.8","4.9.9","4.9.10","4.9.11","4.9.12","4.9.13","4.9.14","4.9.15","4.9.16","4.9.17","4.9.18","4.9.19","4.9.20","4.9.21","4.9.22","4.9.23","4.9.24", "4.9.25","4.9.26","4.9.27","4.9.28","4.9.29","4.9.30","4.9.31","4.9.32","4.9.33","4.9.34","4.9.35","4.9.36","4.9.37","4.9.38","4.9.39","4.9.40","4.9.41","4.9.42","4.9.43","4.9.44", "4.9.45","4.9.46","4.9.47","4.9.48","4.9.49","4.9.50","4.9.51","4.9.52","4.9.53","4.9.54","4.9.55","4.9.56","4.9.57","4.9.58","4.9.59","4.9.60","4.9.61","4.9.62", - "4.9.63","4.9.64","4.9.65","4.9.66","4.9.67","4.9.68","4.9.69","4.9.70","4.9.71","4.9.72","4.9.73","4.9.74","4.9.75","4.9.76"}; + "4.9.63","4.9.64","4.9.65","4.9.66","4.9.67","4.9.68","4.9.69","4.9.70","4.9.71","4.9.72","4.9.73","4.9.74","4.9.75","4.9.76","4.9.77"}; // 版本列表(4.0版本升级4.1版需要分两步:先从4.0升到4.1.0、然后从4.1.0升级4.1最新版本) /*public final static String[] SOFTWARE_VERSION_ARRAY = new String[] {