Commit 746beda9733dee95d090f64f39e269485d0e3bf0
1 parent
29feef838c
Exists in
master
and in
6 other branches
excel 2007版导入
Showing 2 changed files with 211 additions and 15 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/SieveController.java
View file @
746beda
... | ... | @@ -394,7 +394,7 @@ |
394 | 394 | @TokenRequired |
395 | 395 | public BaseResponse importSerologySieve(@RequestParam MultipartFile file, HttpServletRequest request, HttpServletResponse response) { |
396 | 396 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
397 | - return sieveFacade.importSerologySieve(file, loginState.getId(), response); | |
397 | + return sieveFacade.importSerologySieve2(file, loginState.getId(), response); | |
398 | 398 | } |
399 | 399 | |
400 | 400 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/SieveFacade.java
View file @
746beda
... | ... | @@ -37,6 +37,10 @@ |
37 | 37 | import org.apache.commons.fileupload.disk.DiskFileItem; |
38 | 38 | import org.apache.commons.lang.StringUtils; |
39 | 39 | import org.apache.commons.lang.math.NumberUtils; |
40 | +import org.apache.poi.xssf.usermodel.XSSFCell; | |
41 | +import org.apache.poi.xssf.usermodel.XSSFRow; | |
42 | +import org.apache.poi.xssf.usermodel.XSSFSheet; | |
43 | +import org.apache.poi.xssf.usermodel.XSSFWorkbook; | |
40 | 44 | import org.springframework.beans.factory.annotation.Autowired; |
41 | 45 | import org.springframework.beans.factory.annotation.Qualifier; |
42 | 46 | import org.springframework.data.mongodb.core.MongoTemplate; |
... | ... | @@ -46,9 +50,7 @@ |
46 | 50 | import org.springframework.web.multipart.commons.CommonsMultipartFile; |
47 | 51 | |
48 | 52 | import javax.servlet.http.HttpServletResponse; |
49 | -import java.io.File; | |
50 | -import java.io.IOException; | |
51 | -import java.io.OutputStream; | |
53 | +import java.io.*; | |
52 | 54 | import java.util.*; |
53 | 55 | import java.util.concurrent.Callable; |
54 | 56 | import java.util.concurrent.Future; |
55 | 57 | |
56 | 58 | |
57 | 59 | |
58 | 60 | |
59 | 61 | |
60 | 62 | |
... | ... | @@ -2662,25 +2664,28 @@ |
2662 | 2664 | if(StringUtils.isEmpty(sive.getNumber())){ |
2663 | 2665 | continue; |
2664 | 2666 | } |
2667 | + data.put("ApplicationNo", "");//新增 | |
2665 | 2668 | data.put("SampleID", sive.getNumber());//样本号(标本号) |
2666 | - data.put("PatientID", sive.getPatientID());//孕妇编号 | |
2667 | 2669 | data.put("LastName", sive.getName());//姓名 |
2668 | 2670 | data.put("FirstName", "");//姓名2 |
2671 | + data.put("PatientID", sive.getPatientID());//孕妇编号 | |
2669 | 2672 | // data.put("ApplicationNo", sive.getPatientID());//申请单号 |
2670 | 2673 | data.put("BirthDate", sive.getBirthday());//生日 |
2671 | - data.put("Address", sive.getPlaceDomicile());//地址 | |
2674 | +// data.put("Address", sive.getPlaceDomicile());//地址 | |
2675 | + data.put("Address", "");//地址 | |
2672 | 2676 | data.put("Phone", sive.getPhone());//电话 |
2673 | 2677 | data.put("NoOfFetuses", sive.getNoOfFetuses());//胎儿数(胎数) |
2674 | - data.put("LMPDate", sive.getLastMenstrual());//末次月经 | |
2678 | + data.put("LMPDate", sive.getLastMenstrual());//末次月经必填 | |
2675 | 2679 | data.put("Smoking", sive.getSmoking());//吸烟 |
2676 | 2680 | data.put("Weight", sive.getWeight());//体重 |
2677 | 2681 | data.put("Insulin", sive.getInsulin());//I-型糖尿病 |
2678 | 2682 | data.put("CollectionDate", sive.getCollectionDate());//采样日期(采血日期) |
2679 | 2683 | data.put("ReceivedDate", sive.getSendTime());//送检日期 |
2680 | - data.put("ScanDate", sive.getBcCheckDate());//B超日期(B超检查日期) | |
2684 | + data.put("ScanDate", sive.getBcCheckDate());//B超日期(B超检查日期)必填 | |
2681 | 2685 | data.put("CRL", sive.getCrl());//B超信息 CRL |
2682 | 2686 | data.put("BPD", sive.getBpd());//B超信息 bpd |
2683 | 2687 | data.put("HC", sive.gethC()); |
2688 | + data.put("NasalBone", sive.getNasalBone());//鼻骨 | |
2684 | 2689 | data.put("MannualEntry", sive.getMannualEntry());//B超孕天 |
2685 | 2690 | data.put("NT", sive.getnT()); |
2686 | 2691 | data.put("ResponsibleCode", sive.getResponsibleCode());//送检单位编号(送检医院) |
2687 | 2692 | |
2688 | 2693 | |
... | ... | @@ -2691,11 +2696,12 @@ |
2691 | 2696 | data.put("ExtractionDate", sive.getExtractionDate());//辅助生殖之提取日期 |
2692 | 2697 | data.put("TransferDate", sive.getTransferDate());//辅助生殖之移植日期 |
2693 | 2698 | data.put("DonorBirthDate", sive.getDonorBirthDate());//辅助生殖之捐赠者生日 |
2694 | - data.put("NasalBone", sive.getNasalBone());//鼻骨 | |
2695 | 2699 | data.put("PatientType", sive.getPatientType());//孕妇筛查类型PatientType |
2700 | + data.put("Monozygous", sive.getMonozygous());//单卵 | |
2701 | + data.put("RecordID", "");//新增 | |
2696 | 2702 | /* data.put("Ethnicity", sive.getEthnicity());//种族(名族) |
2697 | 2703 | data.put("IdCard", sive.getCardNo());//身份证号 |
2698 | - data.put("Monozygous", sive.getMonozygous());//单卵*/ | |
2704 | + */ | |
2699 | 2705 | if(StringUtils.isEmpty(sive.getSieveApplyOrderModelId())){ |
2700 | 2706 | continue; |
2701 | 2707 | } |
2702 | 2708 | |
2703 | 2709 | |
... | ... | @@ -2720,10 +2726,11 @@ |
2720 | 2726 | } |
2721 | 2727 | |
2722 | 2728 | private void cnamesMap(Map<String, String> cnames) { |
2729 | + cnames.put("ApplicationNo", "ApplicationNo"); | |
2723 | 2730 | cnames.put("SampleID", "SampleID");//样本号 |
2724 | - cnames.put("PatientID", "PatientID");//孕妇编号 | |
2725 | 2731 | cnames.put("LastName", "LastName");//姓名 |
2726 | 2732 | cnames.put("FirstName", "FirstName");//姓名2 |
2733 | + cnames.put("PatientID", "PatientID");//孕妇编号 | |
2727 | 2734 | // cnames.put("ApplicationNo", "ApplicationNo");//申请单号 |
2728 | 2735 | cnames.put("BirthDate", "BirthDate");//生日 |
2729 | 2736 | cnames.put("Address", "Address");//地址 |
... | ... | @@ -2739,6 +2746,8 @@ |
2739 | 2746 | cnames.put("CRL", "CRL"); |
2740 | 2747 | cnames.put("BPD", "BPD"); |
2741 | 2748 | cnames.put("HC", "HC"); |
2749 | + cnames.put("NasalBone", "NasalBone");//鼻骨 | |
2750 | + | |
2742 | 2751 | cnames.put("MannualEntry", "MannualEntry");//B超孕天 |
2743 | 2752 | cnames.put("NT", "NT"); |
2744 | 2753 | cnames.put("ResponsibleCode", "ResponsibleCode");//送检单位编号 |
2745 | 2754 | |
2746 | 2755 | |
2747 | 2756 | |
... | ... | @@ -2749,15 +2758,17 @@ |
2749 | 2758 | cnames.put("ExtractionDate", "ExtractionDate");//辅助生殖之提取日期 |
2750 | 2759 | cnames.put("TransferDate", "TransferDate");//辅助生殖之移植日期 |
2751 | 2760 | cnames.put("DonorBirthDate", "DonorBirthDate");//辅助生殖之捐赠者生日 |
2752 | - cnames.put("NasalBone", "NasalBone");//鼻骨 | |
2753 | 2761 | cnames.put("PatientType", "PatientType");//孕妇筛查类型 |
2762 | + cnames.put("Monozygous", "Monozygous");//单卵 | |
2763 | + cnames.put("RecordID", "RecordID"); | |
2764 | + | |
2754 | 2765 | /* cnames.put("Ethnicity", "Ethnicity");//种族 |
2755 | - cnames.put("IdCard", "IdCard");//身份证号 | |
2756 | - cnames.put("Monozygous", "Monozygous");//单卵*/ | |
2766 | + cnames.put("IdCard", "IdCard");//身份证号*/ | |
2767 | + | |
2757 | 2768 | } |
2758 | 2769 | |
2759 | 2770 | /** |
2760 | - * 功能描述 产筛导入3.0版 血清学筛查 | |
2771 | + * 功能描述 产筛导入3.0版 血清学筛查 excle 2003 | |
2761 | 2772 | * @author 武涛涛 |
2762 | 2773 | * @date 2020/6/15 |
2763 | 2774 | */ |
... | ... | @@ -2917,6 +2928,191 @@ |
2917 | 2928 | } |
2918 | 2929 | return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); |
2919 | 2930 | |
2931 | + } | |
2932 | + /** | |
2933 | + * 功能描述 是读取2007 excle的方法 | |
2934 | + * @author 武涛涛 | |
2935 | + * @date 2020/6/23 | |
2936 | + */ | |
2937 | + public BaseResponse importSerologySieve2(MultipartFile file, Integer id, HttpServletResponse response) { | |
2938 | + | |
2939 | + try { | |
2940 | + //把MultipartFile转化为File 第一种 | |
2941 | + CommonsMultipartFile cmf = (CommonsMultipartFile) file; | |
2942 | + DiskFileItem dfi = (DiskFileItem) cmf.getFileItem(); | |
2943 | + File fo = dfi.getStoreLocation(); | |
2944 | + // 创建对excel工作簿的引用 | |
2945 | + XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(fo)); | |
2946 | + | |
2947 | + // 创建对工作表的引用,这里是按索引引用,第一张工作表的索引为0.也可以按名引用 | |
2948 | + XSSFSheet sheet = workbook.getSheetAt(0); | |
2949 | + // 需要得到总共的行数 | |
2950 | + int rowNum = sheet.getLastRowNum(); | |
2951 | + // 定义单元 | |
2952 | + XSSFCell cell = null; | |
2953 | + List<ImportResult> list = new ArrayList<>(); | |
2954 | + // 按行循环读取 | |
2955 | + for (int j = 1; j <= rowNum; j++) { | |
2956 | + ImportResult importResult = new ImportResult(); | |
2957 | + // 得到该行对象 | |
2958 | + XSSFRow rowLine = sheet.getRow(j); | |
2959 | + // 获得该行的列数 | |
2960 | + int colNum = rowLine.getLastCellNum(); | |
2961 | + StringBuffer sb = new StringBuffer(); | |
2962 | + // 按列读取每一行的各个单元格内容 | |
2963 | + for (int i = 0; i < colNum; i++) { | |
2964 | + cell = rowLine.getCell(i); | |
2965 | + String cellValue = null; | |
2966 | + if (cell != null) { | |
2967 | + switch (cell.getCellType()) { | |
2968 | + // 如果是数字格式 | |
2969 | + case XSSFCell.CELL_TYPE_NUMERIC: | |
2970 | + Integer number = new Integer( // 数字 | |
2971 | + (int) cell.getNumericCellValue()); | |
2972 | + cellValue = String.valueOf(number); | |
2973 | + break; | |
2974 | + case XSSFCell.CELL_TYPE_STRING: // 字符串 | |
2975 | + cellValue = cell.getStringCellValue(); | |
2976 | + break; | |
2977 | + default: | |
2978 | + cellValue = " "; | |
2979 | + break; | |
2980 | + } | |
2981 | + | |
2982 | + } else { | |
2983 | + cellValue = ""; | |
2984 | + } | |
2985 | + switchMth(importResult, i, cellValue); | |
2986 | + //sb.append(cellValue).append("###"); | |
2987 | + | |
2988 | + } | |
2989 | + list.add(importResult); | |
2990 | + System.out.println("list: " + list.size()); | |
2991 | + | |
2992 | + //1 根据标本号更新数据 | |
2993 | + if (StringUtils.isEmpty(importResult.get样本编号()) ) { | |
2994 | + continue; | |
2995 | + } | |
2996 | + String hospitalId = autoMatchFacade.getHospitalId(id); | |
2997 | + SieveApplyOrderQuery sieveApplyOrderQuery1 = new SieveApplyOrderQuery(); | |
2998 | + sieveApplyOrderQuery1.setNumber(importResult.get样本编号()); | |
2999 | + sieveApplyOrderQuery1.setYn(YnEnums.YES.getId()); | |
3000 | + sieveApplyOrderQuery1.setHospitalId(hospitalId); | |
3001 | + List<SieveApplyOrderModel> list1 = applyOrderService.querySieveApplyOrderWithQuery(sieveApplyOrderQuery1); | |
3002 | + if (CollectionUtils.isEmpty(list1) ) { | |
3003 | + continue; | |
3004 | + } | |
3005 | + SieveApplyOrderModel sieveApplyOrderModel1 = list1.get(0); | |
3006 | + //判断如果没有LymsSieveId就更新上 | |
3007 | + if (StringUtils.isEmpty(sieveApplyOrderModel1.getLymsSieveId())) { | |
3008 | + SieveQuery sieveQuery = new SieveQuery(); | |
3009 | + sieveQuery.setYn(YnEnums.YES.getId()); | |
3010 | + sieveQuery.setParentId(sieveApplyOrderModel1.getParentId()); | |
3011 | + sieveQuery.setHospitalId(hospitalId); | |
3012 | + sieveQuery.setStatus(2); | |
3013 | + List<SieveModel> modelList = sieveService.queryList(sieveQuery); | |
3014 | + if (CollectionUtils.isNotEmpty(modelList) && modelList.size() < 2) { | |
3015 | + SieveModel sieveModel = modelList.get(0); | |
3016 | + sieveApplyOrderModel1.setLymsSieveId(sieveModel.getId()); | |
3017 | + applyOrderService.updateSieve(sieveApplyOrderModel1); | |
3018 | + } | |
3019 | + } | |
3020 | + //1.1 修改产筛申请内容,先暂时修改B超孕天 | |
3021 | + //applyOrderService.updateSieve(sieveApplyOrderModel1); | |
3022 | + | |
3023 | + SieveAddRequest sieveAddRequest = new SieveAddRequest(); | |
3024 | + sieveAddRequest.setPublishName(String.valueOf(id));//录入人员 | |
3025 | + sieveAddRequest.setResultTime(importResult.get风险评估时间()); //结果录入时间 | |
3026 | + if (StringUtils.isNotEmpty(importResult.getT21风险值())) {// 唐氏综合症 21-三体 | |
3027 | + Map map = new HashMap(); | |
3028 | + map.put("valueOne", "1");//郝总说固定值是1 | |
3029 | + map.put("valueTwo", importResult.getT21风险值()); | |
3030 | + sieveAddRequest.setTszhzValue(map); | |
3031 | + } | |
3032 | + if (StringUtils.isNotEmpty(importResult.getT21风险结果())) { | |
3033 | + if ("低风险".equals(importResult.getT21风险结果())) { | |
3034 | + sieveAddRequest.setTszhz("0"); | |
3035 | + } else if ("高风险".equals(importResult.getT21风险结果())) { | |
3036 | + sieveAddRequest.setTszhz("2"); | |
3037 | + } | |
3038 | + } | |
3039 | + if (StringUtils.isNotEmpty(importResult.getT18风险值())) {//18-三体 T18风险结果 | |
3040 | + Map map = new HashMap(); | |
3041 | + map.put("valueOne", "1"); | |
3042 | + map.put("valueTwo", importResult.getT18风险值()); | |
3043 | + sieveAddRequest.setSbstValue(map); | |
3044 | + } | |
3045 | + if (StringUtils.isNotEmpty(importResult.getT18风险结果())) { | |
3046 | + if ("低风险".equals(importResult.getT18风险结果())) { | |
3047 | + sieveAddRequest.setSbst("0"); | |
3048 | + } else if ("高风险".equals(importResult.getT18风险结果())) { | |
3049 | + sieveAddRequest.setSbst("2"); | |
3050 | + } | |
3051 | + } | |
3052 | + sieveAddRequest.setStzhz13Value(null); //13-三体 导入的excel表格中没有该字段 | |
3053 | + sieveAddRequest.setStzhz13(null); | |
3054 | + | |
3055 | + if (StringUtils.isNotEmpty(importResult.getNTD风险值())) {// 神经管畸形 NTD NTD风险值 | |
3056 | + Map map = new HashMap(); | |
3057 | + map.put("valueOne", "1"); | |
3058 | + map.put("valueTwo", importResult.getNTD风险值()); | |
3059 | + sieveAddRequest.setSjgjxValue(map); | |
3060 | + ; | |
3061 | + } | |
3062 | + if (StringUtils.isNotEmpty(importResult.getNTD风险结果())) { | |
3063 | + if ("低风险".equals(importResult.getNTD风险结果())) { | |
3064 | + sieveAddRequest.setSjgjx("0"); | |
3065 | + } else if ("高风险".equals(importResult.getNTD风险结果())) { | |
3066 | + sieveAddRequest.setSjgjx("2"); | |
3067 | + } | |
3068 | + } | |
3069 | + if (StringUtils.isNotEmpty(importResult.gethCGb浓度())) {//hCGb浓度 | |
3070 | + sieveAddRequest.setHcg(importResult.gethCGb浓度()); | |
3071 | + } | |
3072 | + if (StringUtils.isNotEmpty(importResult.gethCGb校正MOM值())) {//hCGb校正MOM值 | |
3073 | + sieveAddRequest.setHcgMom(importResult.gethCGb校正MOM值()); | |
3074 | + } | |
3075 | + | |
3076 | + if (StringUtils.isNotEmpty(importResult.getAFP浓度())) {//AFP浓度 | |
3077 | + sieveAddRequest.setHafp(importResult.getAFP浓度()); | |
3078 | + } | |
3079 | + if (StringUtils.isNotEmpty(importResult.getAFP校正MOM值())) {//AFP校正MOM值 | |
3080 | + sieveAddRequest.setHafpMom(importResult.getAFP校正MOM值()); | |
3081 | + } | |
3082 | + if(StringUtils.isNotEmpty(importResult.getuE3UPDCN浓度())){ //uE3 | |
3083 | + sieveAddRequest.setuE3(importResult.getuE3UPDCN浓度()); | |
3084 | + } | |
3085 | + if(StringUtils.isNotEmpty(importResult.getuE3UPDCN校正MOM值())){ //uE3MOM | |
3086 | + sieveAddRequest.setuE3(importResult.getuE3UPDCN校正MOM值()); | |
3087 | + } | |
3088 | + //sieveAddRequest.setCheckerId(); | |
3089 | + //sieveAddRequest.setExamineId(); | |
3090 | + sieveAddRequest.setParentId(sieveApplyOrderModel1.getParentId()); | |
3091 | + sieveAddRequest.setLymsSieveId(sieveApplyOrderModel1.getLymsSieveId()); | |
3092 | + //避免一个产筛申请出现多次结果 | |
3093 | + SieveResultQuery sieveResultQuery = new SieveResultQuery(); | |
3094 | + sieveResultQuery.setLymsSieveId(sieveApplyOrderModel1.getLymsSieveId()); | |
3095 | + sieveResultQuery.setParentId(sieveApplyOrderModel1.getParentId()); | |
3096 | + List<SieveResultModel> sieveResultModellist = sieveService.queryListSieveResult(sieveResultQuery); | |
3097 | + if(CollectionUtils.isNotEmpty(sieveResultModellist)){ | |
3098 | + SieveResultModel sieveResultModel = sieveResultModellist.get(0); | |
3099 | + sieveAddRequest.setId(sieveResultModel.getId()); | |
3100 | + addOneSieve(sieveAddRequest, id); | |
3101 | + } | |
3102 | + sieveAddRequest.setExamineId(String.valueOf(id)); //审核者 | |
3103 | + sieveAddRequest.setCheckerId(String.valueOf(id)); //检验者 | |
3104 | + addOneSieve(sieveAddRequest, id); | |
3105 | + //记录一下添加成功内容 | |
3106 | + operateLogFacade.addModifyOptLog(id, Integer.parseInt(hospitalId),sieveAddRequest, sieveAddRequest, OptActionEnums.UPDATE.getId(), "导入添加产筛信息"); | |
3107 | + | |
3108 | + | |
3109 | + } | |
3110 | + | |
3111 | + } catch (Exception e) { | |
3112 | + e.printStackTrace(); | |
3113 | + return new BaseResponse().setErrorcode(ErrorCodeConstants.SYSTEM_ERROR).setErrormsg("导入失败"); | |
3114 | + } | |
3115 | + return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); | |
2920 | 3116 | } |
2921 | 3117 | |
2922 | 3118 | private void switchMth(ImportResult importResult, int j, String str) { |