You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					94 lines
				
				3.5 KiB
			
		
		
			
		
	
	
					94 lines
				
				3.5 KiB
			| 
											3 years ago
										 | package com.ynxbd.common.action;
 | ||
|  | 
 | ||
|  | import com.ynxbd.common.action.base.BaseAction;
 | ||
|  | import com.ynxbd.common.bean.pacs.RISPacsReportInfo;
 | ||
|  | import com.ynxbd.common.dao.pacs.RISPacsDao;
 | ||
|  | import com.ynxbd.common.helper.common.ImageHelper;
 | ||
|  | import com.ynxbd.common.helper.pacs.RISPacsHelper;
 | ||
|  | import com.ynxbd.common.result.Result;
 | ||
|  | import com.ynxbd.common.result.ResultEnum;
 | ||
|  | import com.ynxbd.wx.wxfactory.ReqParamHelper;
 | ||
|  | import lombok.extern.slf4j.Slf4j;
 | ||
|  | import org.apache.struts2.convention.annotation.Action;
 | ||
|  | import org.apache.struts2.convention.annotation.Namespace;
 | ||
|  | 
 | ||
|  | import javax.servlet.ServletOutputStream;
 | ||
|  | import javax.servlet.http.HttpServletRequest;
 | ||
|  | import javax.servlet.http.HttpServletResponse;
 | ||
|  | import java.io.IOException;
 | ||
|  | import java.util.ArrayList;
 | ||
|  | import java.util.List;
 | ||
|  | 
 | ||
|  | /**
 | ||
|  |  * @author 李进才
 | ||
|  |  * @ClassName PacsRisAction
 | ||
|  |  * @Description description
 | ||
|  |  * @date 2023/3/21 17:04
 | ||
|  |  */
 | ||
|  | 
 | ||
|  | @Slf4j
 | ||
|  | @Namespace("/risPacs")
 | ||
|  | public class PacsReportAction extends BaseAction {
 | ||
|  | 
 | ||
|  | 
 | ||
|  |     @Action("/list")
 | ||
|  |     public Result list(String outPatientNum, String inPatientNum,Integer pageNum){
 | ||
|  |         outPatientNum = ReqParamHelper.decode(outPatientNum);
 | ||
|  |         inPatientNum = ReqParamHelper.decode(inPatientNum);
 | ||
|  |         if(outPatientNum==null&&inPatientNum==null){
 | ||
|  |             return Result.error(ResultEnum.PARAM_IS_BLANK);
 | ||
|  |         }
 | ||
|  |         List<RISPacsReportInfo> risPacsReportInfos = new ArrayList<>();
 | ||
|  |         if(outPatientNum!=null){
 | ||
|  |             risPacsReportInfos = new RISPacsDao().getReportInfoForOutPatientNum(outPatientNum);
 | ||
|  |         }
 | ||
|  |         if(inPatientNum!=null){
 | ||
|  |             risPacsReportInfos =new RISPacsDao().getReportInfoForInPatientNum(inPatientNum);
 | ||
|  |         }
 | ||
|  |         Integer pageTotal = risPacsReportInfos.size();
 | ||
|  |         if(pageTotal>1){
 | ||
|  |             risPacsReportInfos = risPacsReportInfos.subList(pageNum-1,pageNum);
 | ||
|  |         }
 | ||
|  |         List<RISPacsReportInfo> resultList = new ArrayList<>();
 | ||
|  |         for(RISPacsReportInfo risPacsReportInfo : risPacsReportInfos) {
 | ||
|  |             try {
 | ||
|  |                 log.info("[Pacs]报告单路径-{},报告单Id-{}",risPacsReportInfo.getReportFile(),risPacsReportInfo.getReportId());
 | ||
|  |                 risPacsReportInfo.setReportFile("data:application/jpg;base64," +
 | ||
|  |                         ImageHelper.convertPDFtoImageBase64(
 | ||
|  |                                 RISPacsHelper.smbHelper.smbGet("smb:" +
 | ||
|  |                                         risPacsReportInfo.getReportFile().replaceAll("\\\\", "/"))));
 | ||
|  |                 resultList.add(risPacsReportInfo);
 | ||
|  |             } catch (Exception e) {
 | ||
|  |                 throw new RuntimeException(e);
 | ||
|  |             }
 | ||
|  |         }
 | ||
|  |         return Result.success(resultList,pageTotal);
 | ||
|  |     }
 | ||
|  | 
 | ||
|  |     @Action("/download")
 | ||
|  |     public Result report(String reportId) throws Exception {
 | ||
|  |         HttpServletResponse response = getResponse();
 | ||
|  |         response.setContentType("application/octet-stream");
 | ||
|  |         response.setHeader("Content-Disposition", "attachment; filename=file.pdf");
 | ||
|  |         ServletOutputStream outputStream = response.getOutputStream();
 | ||
|  |         byte[] fileByte = RISPacsHelper.smbHelper.smbGet("smb:"+
 | ||
|  |                 new RISPacsDao().
 | ||
|  |                         getReportPath(reportId).
 | ||
|  |                         replaceAll("\\\\","/"));
 | ||
|  |         outputStream.write(fileByte);
 | ||
|  |         outputStream.flush();
 | ||
|  |         return Result.success();
 | ||
|  |     }
 | ||
|  | 
 | ||
|  |     @Action("/test")
 | ||
|  |     public Result test() throws Exception {
 | ||
|  |         List<String> images = new ArrayList<>();
 | ||
|  |         images.add("1");
 | ||
|  |         images.add("2");
 | ||
|  |         images.add("2");
 | ||
|  |         images.add("2");
 | ||
|  |         images = images.subList(1,2);
 | ||
|  |         return Result.success(images);
 | ||
|  |     }
 | ||
|  | }
 |