Browse Source

Merge branch 'master' into innerDevelop

gaodm 4 years ago
parent
commit
43fe1baab2

+ 1 - 1
src/main/java/com/diagbot/dto/TemplateInfoDTO.java

@@ -17,7 +17,7 @@ public class TemplateInfoDTO {
     private Date gmtCreate;//创建时间
     private String name;//模板名字
     private Integer sex;//性别
-    private Integer age;//年龄
+    private String age;//年龄
     private String patName;//病人姓名
     private String doctorName;//医生姓名
     private String inquiryCode;//门诊号

+ 1 - 1
src/main/java/com/diagbot/dto/TemplateInfoPageDTO.java

@@ -18,7 +18,7 @@ public class TemplateInfoPageDTO {
     private Date gmtCreate;//创建时间
     private String name;//模板名字
     private Integer sex;//性别
-    private Integer age;//年龄
+    private String age;//年龄
     private String patName;//病人姓名
     private String doctorName;//医生姓名
     private String inquiryCode;//门诊号

+ 1 - 1
src/main/java/com/diagbot/entity/TemplateInfo.java

@@ -73,7 +73,7 @@ public class TemplateInfo implements Serializable {
     /**
      * 年龄
      */
-    private Integer age;
+    private String age;
 
     /**
      * 病人姓名

+ 2 - 0
src/main/java/com/diagbot/facade/AssembleFacade.java

@@ -5,6 +5,7 @@ import com.diagbot.entity.HospitalInfo;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
+import com.diagbot.util.CoreUtil;
 import com.diagbot.vo.SearchData;
 import io.github.lvyahui8.spring.facade.DataFacade;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -30,6 +31,7 @@ public class AssembleFacade {
      * @return
      */
     public SearchData assembleData(SearchData searchData) {
+        searchData.setAgeNum(CoreUtil.convertAge(searchData.getAge()));
         HospitalInfo hospitalInfo = hospitalInfoFacade.getById(searchData.getHospitalId());
         Integer isConnect = 0;
         if (hospitalInfo != null && hospitalInfo.getIsDeleted().equals(IsDeleteEnum.N.getKey())) {

+ 116 - 0
src/main/java/com/diagbot/util/CoreUtil.java

@@ -0,0 +1,116 @@
+package com.diagbot.util;
+
+import lombok.extern.slf4j.Slf4j;
+import java.math.BigDecimal;
+
+/**
+ * @description:
+ * @author: zhoutg
+ * @time: 2020/7/30 15:18
+ */
+@Slf4j
+public class CoreUtil {
+
+    /**
+     * 年龄字符串转换成double类型
+     *
+     * @param ageStr
+     * @return
+     */
+    public static Double convertAge(String ageStr) {
+        try {
+            // 防止程序出错
+            if (StringUtil.isEmpty(ageStr)) {
+                return 20.0;
+            }
+            // 全是整形数字,当成年龄处理
+            if (numbersOnly(ageStr)) {
+                return Double.parseDouble(ageStr);
+            }
+            // 20日
+            if (ageStr.endsWith("日")) {
+                return getHalfUp((Double.parseDouble(ageStr.substring(0, ageStr.length() - 1))) / 365);
+            }
+            // 3岁
+            if (ageStr.endsWith("岁")) {
+                return Double.parseDouble(ageStr.substring(0, ageStr.length() - 1));
+            }
+            // 3岁7个月
+            if (ageSuiYue(ageStr)) {
+                String[] ageArr = new String[2];
+                int indexSui = ageStr.indexOf("岁");
+                ageArr[0] = ageStr.substring(0, indexSui);
+                ageArr[1] = ageStr.substring(indexSui + 1,ageStr.indexOf("个月"));
+                return Double.parseDouble(ageArr[0]) + getHalfUp(Double.parseDouble(ageArr[1]) / 12);
+            }
+            // 1.08月 | .11月 | 3月
+            if (ageYue(ageStr)) {
+                String noUnit = ageStr.substring(0, ageStr.length() - 1);
+                String[] ageArr = new String[2];
+                String[] splitArr = noUnit.split("\\.");
+                if (splitArr.length == 1) {
+                    ageArr[0] = splitArr[0];
+                } else if (splitArr.length == 2) {
+                    ageArr[0] = splitArr[0];
+                    ageArr[1] = splitArr[1];
+                }
+                Double daySum = 0.0D;
+                if (StringUtil.isNotBlank(ageArr[0])) {
+                    daySum += Double.parseDouble(ageArr[0]) * 30;
+                }
+                if (StringUtil.isNotBlank(ageArr[1])) {
+                    daySum += Double.parseDouble(ageArr[1]);
+                }
+                return getHalfUp(daySum / 365);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return 20.0;
+        }
+        return 20.0;
+    }
+
+    /**
+     * 判断字符串是否 仅 包含数字
+     *
+     * @param str
+     * @return
+     */
+    public static boolean numbersOnly(String str) {
+        String regex = "^[0-9]+$";
+        return str.matches(regex);
+    }
+
+    /**
+     * 判断年龄字符串:xx月
+     *
+     * @param str
+     * @return
+     */
+    public static boolean ageYue(String str) {
+        String regex = "^[0-9]*[\\.]*[0-9]{1,2}月$";
+        return str.matches(regex);
+    }
+
+    /**
+     * 判断年龄字符串:3岁7个月
+     *
+     * @param str
+     * @return
+     */
+    public static boolean ageSuiYue(String str) {
+        String regex = "^[0-9]{1,3}岁[0-9]{1,2}个月$";
+        return str.matches(regex);
+    }
+
+    /**
+     * 四舍五入保留2位小数
+     *
+     * @param ageStr
+     * @return
+     */
+    public static Double getHalfUp(Double ageStr) {
+        BigDecimal bg = new BigDecimal(String.valueOf(ageStr));
+        return bg.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
+    }
+}

+ 7 - 3
src/main/java/com/diagbot/vo/PushJoinVO.java

@@ -8,7 +8,6 @@ import lombok.Getter;
 import lombok.Setter;
 
 import javax.validation.constraints.NotNull;
-import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -26,10 +25,15 @@ public class PushJoinVO {
     private Long hospitalId;
 
     /**
-     * 年龄
+     * 年龄文本数据
      */
     @NotNull(message = "请输入年龄")
-    private Integer age;
+    private String age;
+    /**
+     * 年龄数字数据
+     */
+    @ApiModelProperty(hidden = true)
+    private Double ageNum;
     /**
      * 性别
      */

+ 8 - 2
src/main/java/com/diagbot/vo/SearchData.java

@@ -3,6 +3,7 @@ package com.diagbot.vo;
 import com.diagbot.biz.push.entity.Item;
 import com.diagbot.biz.push.entity.Lis;
 import com.diagbot.biz.push.entity.Pacs;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -22,9 +23,14 @@ public class SearchData extends HospitalBaseVO {
      */
     private Integer length = 10;
     /**
-     * 年龄
+     * 年龄文本数据
      */
-    private Integer age;
+    private String age;
+    /**
+     * 年龄数字数据
+     */
+    @ApiModelProperty(hidden = true)
+    private Double ageNum;
     /**
      * 性别(1:男,2:女,3:通用)
      */

+ 2 - 2
src/main/java/com/diagbot/vo/TemplateInfosVO.java

@@ -22,8 +22,8 @@ public class TemplateInfosVO {
     private Long hospitalId = -1L;//医院ID
     @NotNull(message = "请输入性别")
     private Integer sex;//性别
-    @NotNull(message = "请输入年龄")
-    private Integer age;//年龄
+    @NotBlank(message = "请输入年龄")
+    private String age;//年龄
     @NotBlank(message = "请输入病人姓名")
     private String patName;//病人姓名
     @NotBlank(message = "请输入医生姓名")