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.
		
		
		
		
			
				
					279 lines
				
				11 KiB
			
		
		
			
		
	
	
					279 lines
				
				11 KiB
			| 
											3 years ago
										 | /*
 | ||
|  |  * *
 | ||
|  |  *  * @Project 微信公众号
 | ||
|  |  *  * @Author 张剑峰
 | ||
|  |  *  * @Date 2020/12/3 下午4:35
 | ||
|  |  *  * @Description
 | ||
|  |  *  * @Version v1.0.0
 | ||
|  |  *  * @Copyright @ 2020 云南新八达科技有限公司 All rights reserved.
 | ||
|  |  *
 | ||
|  |  */
 | ||
|  | 
 | ||
|  | package com.ynxbd.common.action;
 | ||
|  | 
 | ||
|  | import com.ynxbd.common.action.base.BaseAction;
 | ||
|  | import com.ynxbd.common.bean.lis.XBDLisBactResult;
 | ||
|  | import com.ynxbd.common.bean.lis.XBDLisImageResult;
 | ||
|  | import com.ynxbd.common.bean.lis.XBDLisReport;
 | ||
|  | import com.ynxbd.common.bean.lis.XBDLisResult;
 | ||
|  | import com.ynxbd.common.dao.lis.RMLisDao;
 | ||
|  | import com.ynxbd.common.dao.lis.XBDLisDao;
 | ||
|  | import com.ynxbd.common.helper.common.Base64Helper;
 | ||
|  | import com.ynxbd.common.helper.common.ImageHelper;
 | ||
|  | import com.ynxbd.common.helper.common.NumHelper;
 | ||
|  | import com.ynxbd.common.result.Result;
 | ||
|  | import com.ynxbd.common.result.ResultEnum;
 | ||
|  | import com.ynxbd.wx.config.WeChatConfig;
 | ||
|  | import com.ynxbd.wx.wxfactory.ReqParamHelper;
 | ||
|  | import lombok.extern.slf4j.Slf4j;
 | ||
|  | import org.apache.commons.codec.digest.DigestUtils;
 | ||
|  | import org.apache.commons.lang3.ObjectUtils;
 | ||
|  | import org.apache.struts2.convention.annotation.Action;
 | ||
|  | import org.apache.struts2.convention.annotation.Namespace;
 | ||
|  | 
 | ||
|  | import java.io.File;
 | ||
|  | import java.io.FileInputStream;
 | ||
|  | import java.util.ArrayList;
 | ||
|  | import java.util.List;
 | ||
|  | 
 | ||
|  | 
 | ||
|  | @Slf4j
 | ||
|  | @Namespace("/lis")
 | ||
|  | public class LisReportAction extends BaseAction {
 | ||
|  | 
 | ||
|  |     /**
 | ||
|  |      * 查询报告列表
 | ||
|  |      *
 | ||
|  |      * @return 报告列表
 | ||
|  |      */
 | ||
|  |     @Action("report")
 | ||
|  |     public Result getReportList(String treatNum, String treatNumPrefix, String flag, String patientType,String startTime,String endTime) {
 | ||
|  |         treatNum = getDecodeString(treatNum);
 | ||
|  |         log.info("[Lis报告单]查询: flag={{}}, treatNumPrefix={{}}, treatNum={{}}, patientType={{}}", flag, treatNumPrefix, treatNum, patientType);
 | ||
|  |         if (flag == null || patientType == null || treatNum == null) {
 | ||
|  |             return Result.error(ResultEnum.PARAM_IS_DEFECT);
 | ||
|  |         }
 | ||
|  |         if (!ObjectUtils.isEmpty(treatNumPrefix)) { // 瑞美lis报告前缀
 | ||
|  |             treatNum = treatNumPrefix + treatNum;
 | ||
|  |         }
 | ||
|  | 
 | ||
|  |         List<XBDLisReport> lstReport = new ArrayList<>();
 | ||
|  |         switch (flag) {
 | ||
|  |             case "1": // 新八达
 | ||
|  |                 lstReport = new XBDLisDao().getReport(treatNum, patientType);
 | ||
|  |                 break;
 | ||
|  |             case "2": // 瑞美
 | ||
|  |                 lstReport = new XBDLisDao().getReport4RM(treatNum);
 | ||
|  | 
 | ||
|  |                 String reportId;
 | ||
|  |                 for (XBDLisReport reportItem : lstReport) {
 | ||
|  |                     // 倒叙->base64->md5
 | ||
|  |                     reportId = NumHelper.numDesc(reportItem.getId());
 | ||
|  |                     if (reportId != null) {
 | ||
|  |                         reportId = Base64Helper.encode(reportId);
 | ||
|  |                         reportId = DigestUtils.md5Hex(reportId);
 | ||
|  |                         reportItem.setRm_cipherText(reportId);
 | ||
|  |                     }
 | ||
|  |                 }
 | ||
|  |                 break;
 | ||
|  |             case "3": // 科华
 | ||
|  |                 if (WeChatConfig.APP_ID.equals("wxc01532c55273dc6b")) { // 红河州妇幼门诊号从bed_no查
 | ||
|  |                     lstReport = new XBDLisDao().getReport4KH_Hhzfy(treatNum, patientType);
 | ||
|  |                 } else {
 | ||
|  |                     lstReport = new XBDLisDao().getReport4KH(treatNum, patientType);
 | ||
|  |                 }
 | ||
|  |                 break;
 | ||
|  |             case "4": // 石林
 | ||
|  |                 lstReport = new XBDLisDao().getReport4Sl(treatNum, patientType);
 | ||
|  |                 break;
 | ||
|  |             case "5":
 | ||
|  |                 lstReport = RMLisDao.getReportList("1",treatNum,startTime,endTime,"0");
 | ||
|  |                 break;
 | ||
|  |         }
 | ||
|  | 
 | ||
|  |         for (XBDLisReport item : lstReport) {
 | ||
|  |             if (item.getId() != null) {
 | ||
|  |                 item.setEnReportId(ReqParamHelper.encode(item.getId()));
 | ||
|  |             }
 | ||
|  |             if (item.getSampleCode() != null) {
 | ||
|  |                 item.setEnSampleCode(ReqParamHelper.encode(item.getSampleCode()));
 | ||
|  |             }
 | ||
|  |         }
 | ||
|  |         return Result.success(lstReport);
 | ||
|  |     }
 | ||
|  | 
 | ||
|  | 
 | ||
|  |     /**
 | ||
|  |      * 普通报告
 | ||
|  |      */
 | ||
|  |     @Action("result")
 | ||
|  |     public Result getResult(String reportId, String sampleCode, String flag, String testDate, String openid) {
 | ||
|  |         reportId = getDecodeString(reportId);
 | ||
|  |         sampleCode = getDecodeString(sampleCode);
 | ||
|  | 
 | ||
|  |         log.info("[Lis结果]查询: flag={{}}, reportId={}, testDate={{}}, sampleCode={{}}", flag, reportId, testDate, sampleCode);
 | ||
|  | 
 | ||
|  |         if ("1".equals(flag) && (testDate == null || sampleCode == null)) {
 | ||
|  |             return Result.error(ResultEnum.PARAM_IS_BLANK);
 | ||
|  |         }
 | ||
|  | 
 | ||
|  |         if (("2".equals(flag) || "4".equals(flag)) && reportId == null) {
 | ||
|  |             return Result.error(ResultEnum.PARAM_IS_BLANK);
 | ||
|  |         }
 | ||
|  | 
 | ||
|  |         List<XBDLisResult> lstResult = new ArrayList<>();
 | ||
|  |         switch (flag) {
 | ||
|  |             case "1": // 新八达
 | ||
|  |                 lstResult = new XBDLisDao().getResult(testDate, sampleCode);
 | ||
|  |                 break;
 | ||
|  |             case "2": // 瑞美
 | ||
|  |                 lstResult = new XBDLisDao().getResult4RM(Integer.parseInt(reportId));
 | ||
|  |                 break;
 | ||
|  |             case "3": // 科华
 | ||
|  |                 lstResult = new XBDLisDao().getResult4KH(testDate, sampleCode);
 | ||
|  |                 break;
 | ||
|  |             case "4":
 | ||
|  |                 lstResult = new XBDLisDao().getResult4Sl(reportId);
 | ||
|  |                 break;
 | ||
|  |             case "5":
 | ||
|  |                 lstResult = RMLisDao.getReportResult(reportId);
 | ||
|  |                 break;
 | ||
|  |         }
 | ||
|  |         return Result.success(lstResult);
 | ||
|  |     }
 | ||
|  | 
 | ||
|  |     /**
 | ||
|  |      * 图像报告
 | ||
|  |      */
 | ||
|  |     @Action("image")
 | ||
|  |     public Result getImage(String reportId, String sampleCode, String flag, String testDate, String openid) {
 | ||
|  |         reportId = getDecodeString(reportId);
 | ||
|  |         sampleCode = getDecodeString(sampleCode);
 | ||
|  | 
 | ||
|  |         log.info("查询Lis图像: flag={{}}, reportId={}, testDate={{}}, sampleCode={{}}", flag, reportId, testDate, sampleCode);
 | ||
|  |         if ("1".equals(flag) && (testDate == null || sampleCode == null)) {
 | ||
|  |             return Result.error(ResultEnum.PARAM_IS_BLANK);
 | ||
|  |         }
 | ||
|  | 
 | ||
|  |         if (("2".equals(flag) || "4".equals(flag)) && reportId == null) {
 | ||
|  |             return Result.error(ResultEnum.PARAM_IS_BLANK);
 | ||
|  |         }
 | ||
|  | 
 | ||
|  |         List<XBDLisImageResult> lstImage = new ArrayList<>();
 | ||
|  |         switch (flag) {
 | ||
|  |             case "1":
 | ||
|  |                 lstImage = new XBDLisDao().getImage(testDate, sampleCode);
 | ||
|  |                 break;
 | ||
|  |             case "2":
 | ||
|  |                 lstImage = new XBDLisDao().getImage4RM(Integer.parseInt(reportId));
 | ||
|  |                 break;
 | ||
|  |             case "3":
 | ||
|  |                 lstImage = new XBDLisDao().getImage4KH(testDate, sampleCode);
 | ||
|  |                 break;
 | ||
|  |             case "4":
 | ||
|  |                 lstImage = new XBDLisDao().getImage4Sl(reportId);
 | ||
|  |         }
 | ||
|  | 
 | ||
|  |         FileInputStream fis = null;
 | ||
|  |         byte[] bytes;
 | ||
|  |         List<XBDLisImageResult> resultList = new ArrayList<>();
 | ||
|  |         for (XBDLisImageResult item : lstImage) {
 | ||
|  |             if (item.getImage() == null && item.getUrl() != null) {
 | ||
|  |                 try {
 | ||
|  |                     fis = new FileInputStream(new File(item.getUrl()));
 | ||
|  |                     bytes = new byte[fis.available()];
 | ||
|  |                     //将文件内容写入字节数组
 | ||
|  |                     fis.read(bytes);
 | ||
|  |                     item.setImage(bytes);
 | ||
|  |                     item.setUrl(null);
 | ||
|  | 
 | ||
|  |                     // 将图片字节码进行压缩
 | ||
|  |                     byte[] decompressPicByte = ImageHelper.decompressPicByte(item.getImage(), 0); // 0:按100*200压缩、1:按原图片的50%压缩
 | ||
|  |                     // 将图片字节进行base64编码(在word文档中显示图片时会用到base64转码)
 | ||
|  |                     if (decompressPicByte != null) {
 | ||
|  |                         item.setImageBase64(
 | ||
|  |                                 "data:image/jpg;base64," + ImageHelper.converPicBase64(decompressPicByte));
 | ||
|  |                     }
 | ||
|  |                     item.setImage(null);
 | ||
|  |                     resultList.add(item);
 | ||
|  |                 } catch (Exception e) {
 | ||
|  |                     e.printStackTrace();
 | ||
|  |                 } finally {
 | ||
|  |                     try {
 | ||
|  |                         if (fis != null) {
 | ||
|  |                             fis.close();
 | ||
|  |                         }
 | ||
|  |                     } catch (Exception e) {
 | ||
|  |                         e.printStackTrace();
 | ||
|  |                     }
 | ||
|  |                 }
 | ||
|  |             }
 | ||
|  |         }
 | ||
|  |         return Result.success(resultList);
 | ||
|  |     }
 | ||
|  | 
 | ||
|  |     /**
 | ||
|  |      * 细菌报告
 | ||
|  |      */
 | ||
|  |     @Action("bact")
 | ||
|  |     public Result getBactResult(String reportId, String sampleCode, String flag, String testDate, String openid) {
 | ||
|  |         reportId = getDecodeString(reportId);
 | ||
|  |         sampleCode = getDecodeString(sampleCode);
 | ||
|  | 
 | ||
|  |         log.info("[Lis微生物结果]查询: flag={{}}, reportId={}, testDate={{}}, sampleCode={{}}", flag, reportId, testDate, sampleCode);
 | ||
|  | 
 | ||
|  |         if ("1".equals(flag) && (testDate == null || sampleCode == null)) {
 | ||
|  |             return Result.error(ResultEnum.PARAM_IS_BLANK);
 | ||
|  |         }
 | ||
|  | 
 | ||
|  |         if (("2".equals(flag) || "4".equals(flag)) && reportId == null) {
 | ||
|  |             return Result.error(ResultEnum.PARAM_IS_BLANK);
 | ||
|  |         }
 | ||
|  | 
 | ||
|  |         List<XBDLisBactResult> bactResults = new ArrayList<>();
 | ||
|  |         switch (flag) {
 | ||
|  |             case "1":
 | ||
|  |                 bactResults = new XBDLisDao().getBactResult(testDate, sampleCode);
 | ||
|  |                 break;
 | ||
|  |             case "2":
 | ||
|  |                 bactResults = new XBDLisDao().getBactResult4RM(Integer.parseInt(reportId));
 | ||
|  |                 break;
 | ||
|  |             case "3":
 | ||
|  |                 bactResults = new XBDLisDao().getBactResult4KH(testDate, sampleCode);
 | ||
|  |                 break;
 | ||
|  |             case "4":
 | ||
|  |                 bactResults = new XBDLisDao().getBactResult4Sl(reportId);
 | ||
|  |                 break;
 | ||
|  |             case "5":
 | ||
|  |                 bactResults = RMLisDao.getBactResult(reportId);
 | ||
|  |                 break;
 | ||
|  |         }
 | ||
|  |         return Result.success(bactResults);
 | ||
|  |     }
 | ||
|  | 
 | ||
|  |     /**
 | ||
|  |      * 下载报告
 | ||
|  |      */
 | ||
|  |     @Action("downLisReport")
 | ||
|  |     public Result downLisReport(String callNo) {
 | ||
|  |         // LIS类型 { 1:新八达LIS  2:瑞美LIS(需要加前缀M,红河不用加)  3:科华LIS }
 | ||
|  |         log.info("[LIS报告]下载: callNo={{}}", callNo);
 | ||
|  |         if ("2".equals(callNo)) { // 瑞美
 | ||
|  |             String queryCode = getString("queryCode");
 | ||
|  |             String queryType = getString("queryType");
 | ||
|  |             return RMLisDao.downLisReport(queryType, queryCode);
 | ||
|  |         }
 | ||
|  |         return Result.error();
 | ||
|  |     }
 | ||
|  | 
 | ||
|  |     /**
 | ||
|  |      * 展示报告 瑞美专用
 | ||
|  |      */
 | ||
|  |     @Action("showLisReport")
 | ||
|  |     public Result showLisReport(String queryCode ) {
 | ||
|  |         queryCode = getDecodeString(queryCode);
 | ||
|  |         String queryType = "1"; //ReportID 报告单ID
 | ||
|  |         return RMLisDao.downLisReport(queryType, queryCode);
 | ||
|  |     }
 | ||
|  | }
 |