소스 검색

Merge remote-tracking branch 'origin/master'

zhoutg 5 년 전
부모
커밋
45901f72e9

+ 2 - 0
src/main/java/com/diagbot/dto/AverageStatisticsDTO.java

@@ -13,5 +13,7 @@ import lombok.Setter;
 public class AverageStatisticsDTO {
     private String deptId;
     private String deptName;
+    private Integer num;
     private Double averageValue;
+    private Double totleValue;
 }

+ 25 - 1
src/main/java/com/diagbot/facade/BehospitalInfoFacade.java

@@ -88,7 +88,31 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
     AuthServiceClient authServiceClient;
 
     public IPage<BehospitalInfoDTO> pageFac(BehospitalPageVO behospitalPageVO) {
-
+        //入参验证
+        //入院时间
+        if (null != behospitalPageVO && null != behospitalPageVO.getBehosDateStart()) {
+            behospitalPageVO.setBehosDateStart(DateUtil.getFirstTimeOfDay(behospitalPageVO.getBehosDateStart()));
+        }
+        if (null != behospitalPageVO && null != behospitalPageVO.getBehosDateEnd()) {
+            behospitalPageVO.setBehosDateEnd(DateUtil.getLastTimeOfDay(behospitalPageVO.getBehosDateEnd()));
+        }
+        if (null != behospitalPageVO && null != behospitalPageVO.getBehosDateStart() && null != behospitalPageVO.getBehosDateEnd()) {
+            if (DateUtil.after(behospitalPageVO.getBehosDateStart(), behospitalPageVO.getBehosDateEnd())) {
+                throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "入院时间的开始时间必须大于结束时间!");
+            }
+        }
+        //出院时间
+        if (null != behospitalPageVO && null != behospitalPageVO.getLeaveHosDateStart()) {
+            behospitalPageVO.setLeaveHosDateStart(DateUtil.getFirstTimeOfDay(behospitalPageVO.getLeaveHosDateStart()));
+        }
+        if (null != behospitalPageVO && null != behospitalPageVO.getLeaveHosDateEnd()) {
+            behospitalPageVO.setLeaveHosDateEnd(DateUtil.getLastTimeOfDay(behospitalPageVO.getLeaveHosDateEnd()));
+        }
+        if (null != behospitalPageVO && null != behospitalPageVO.getLeaveHosDateStart() && null != behospitalPageVO.getLeaveHosDateEnd()) {
+            if (DateUtil.after(behospitalPageVO.getLeaveHosDateStart(), behospitalPageVO.getLeaveHosDateEnd())) {
+                throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "出院时间的开始时间必须大于结束时间!");
+            }
+        }
         behospitalPageVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
         IPage<BehospitalInfoDTO> res = getPage(behospitalPageVO);
         return res;

+ 12 - 11
src/main/java/com/diagbot/facade/ConsoleFacade.java

@@ -18,7 +18,6 @@ import org.springframework.stereotype.Component;
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -184,19 +183,16 @@ public class ConsoleFacade {
                         retResults.add(result);
                     } else {
                         num += result.getNum();
-
                     }
                 }
                 ResultDetailDTO retResult = new ResultDetailDTO();
                 retResult.setName("其他");
                 retResult.setNum(num);
-                retResult.setPercent(BigDecimal.valueOf(1)
-                        .min(BigDecimal.valueOf(rate))
-                        .doubleValue());
+                retResult.setPercent(BigDecimal.valueOf(1).subtract(BigDecimal.valueOf(rate)).doubleValue());
                 retResults.add(retResult);
             }
             retResults.forEach(result -> {
-                DecimalFormat df = new DecimalFormat("#.00");
+                DecimalFormat df = new DecimalFormat("#0.00");
                 String percentStr
                         = df.format(BigDecimal.valueOf(result.getPercent()).multiply(BigDecimal.valueOf(100))) + "%";
                 result.setPercentStr(percentStr);
@@ -280,22 +276,27 @@ public class ConsoleFacade {
             retAverageList = BeanUtil.listCopyTo(averageList, AverageStatisticsDTO.class);
         } else {
             Double averageValue = 0d;
+            Double totleValue = 0d;
             Integer num = 0;
             for (AverageStatisticsDTO averageStatisticsDTO : averageList) {
                 if (retAverageList.size() < limitCount - 1) {
                     retAverageList.add(averageStatisticsDTO);
                 } else {
-                    averageValue = BigDecimal
-                            .valueOf(averageValue)
-                            .add(BigDecimal.valueOf(averageStatisticsDTO.getAverageValue()))
+                    totleValue = BigDecimal
+                            .valueOf(totleValue)
+                            .add(BigDecimal.valueOf(averageStatisticsDTO.getTotleValue()))
                             .doubleValue();
-                    num++;
+                    num += averageStatisticsDTO.getNum();
                 }
             }
-            averageValue = BigDecimal.valueOf(averageValue).divide(BigDecimal.valueOf(num), 2).doubleValue();
+            averageValue = BigDecimal.valueOf(totleValue)
+                    .divide(BigDecimal.valueOf(num), 2)
+                    .doubleValue();
             AverageStatisticsDTO retAverageStatistics = new AverageStatisticsDTO();
             retAverageStatistics.setDeptName("其他");
+            retAverageStatistics.setNum(num);
             retAverageStatistics.setAverageValue(averageValue);
+            retAverageStatistics.setTotleValue(totleValue);
             retAverageList.add(retAverageStatistics);
         }
         return retAverageList;

+ 5 - 5
src/main/java/com/diagbot/vo/BehospitalPageVO.java

@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.util.Date;
 
 /**
  * <p>
@@ -43,23 +44,22 @@ public class BehospitalPageVO extends Page implements Serializable {
     /**
      * 入院时间开始时间
      */
-    private String behosDateStart;
-
+    private Date behosDateStart;
 
     /**
      * 入院时间结束时间
      */
-    private String behosDateEnd;
+    private Date behosDateEnd;
 
     /**
      * 出院时间开始时间
      */
-    private String leaveHosDateStart;
+    private Date leaveHosDateStart;
 
     /**
      * 出院时间结束时间
      */
-    private String leaveHosDateEnd;
+    private Date leaveHosDateEnd;
 
 
 }

+ 3 - 0
src/main/java/com/diagbot/web/BehospitalInfoController.java

@@ -88,6 +88,7 @@ public class BehospitalInfoController {
             notes = "")
     @PostMapping("/addCase")
     @SysLogger("addCase")
+    @Transactional
     public RespDTO<AnalyzeDTO> addCase(@RequestBody QcresultVO qcresultVO){
         qcresultVO.setType(1);
         return RespDTO.onSuc(qcresultInfoFacade.changeQcResult(qcresultVO));
@@ -98,6 +99,7 @@ public class BehospitalInfoController {
                     "id:明细id,必填<br>")
     @PostMapping("/delCase")
     @SysLogger("delCase")
+    @Transactional
     public RespDTO<AnalyzeDTO> delCase(@RequestBody QcresultVO qcresultVO){
         qcresultVO.setType(2);
         return RespDTO.onSuc(qcresultInfoFacade.changeQcResult(qcresultVO));
@@ -107,6 +109,7 @@ public class BehospitalInfoController {
             notes = "")
     @PostMapping("/updCase")
     @SysLogger("updCase")
+    @Transactional
     public RespDTO<AnalyzeDTO> updCase(@RequestBody QcresultVO qcresultVO){
         qcresultVO.setType(3);
         return RespDTO.onSuc(qcresultInfoFacade.changeQcResult(qcresultVO));

+ 2 - 0
src/main/java/com/diagbot/web/QcCasesController.java

@@ -9,6 +9,7 @@ import com.diagbot.vo.QcCasesSaveVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -46,6 +47,7 @@ public class QcCasesController {
             notes = "")
     @PostMapping("/saveQcCases")
     @SysLogger("saveQcCases")
+    @Transactional
     public RespDTO<Boolean> saveQcCases(@RequestBody QcCasesSaveListVO qcCasesSaveVOList) {
         return RespDTO.onSuc(qcCasesFacade.saveQcCases(qcCasesSaveVOList));
     }

+ 4 - 4
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -50,16 +50,16 @@
         <if test="behospitalCode != null and behospitalCode != ''">
             and a.behospitalCode like CONCAT('%',#{behospitalCode},'%')
         </if>
-        <if test="behosDateStart != null and behosDateStart != ''">
+        <if test="behosDateStart != null">
             <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
         </if>
-        <if test="behosDateEnd != null and behosDateEnd != ''">
+        <if test="behosDateEnd != null">
             <![CDATA[ and a.behospital_date <= #{behosDateEnd}]]>
         </if>
-        <if test="leaveHosDateStart != null and leaveHosDateStart != ''">
+        <if test="leaveHosDateStart != null">
             <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
         </if>
-        <if test="leaveHosDateEnd != null and leaveHosDateEnd != ''">
+        <if test="leaveHosDateEnd != null">
             <![CDATA[ and a.leave_hospital_date <= #{leaveHosDateEnd}]]>
         </if>
     </select>

+ 6 - 2
src/main/resources/mapper/HomePageMapper.xml

@@ -143,7 +143,9 @@
         SELECT
         a.beh_dept_id as deptId,
         a.beh_dept_name as deptName,
-        round( sum( b.behospital_day_num )/ count(*), 2 ) AS averageValue
+        count(*) AS num,
+        round( sum( b.behospital_day_num )/ count(*), 2 ) AS averageValue,
+        round( sum( b.behospital_day_num ), 2 ) AS totleValue
         FROM
         med_behospital_info a,
         med_home_page b
@@ -170,7 +172,9 @@
         SELECT
         a.beh_dept_id as deptId,
         a.beh_dept_name as deptName,
-        round( sum( b.total_fee )/ count(*), 2 ) AS averageValue
+        count(*) AS num,
+        round( sum( b.total_fee )/ count(*), 2 ) AS averageValue,
+        round( sum( b.total_fee ), 2 ) AS totleValue
         FROM
         med_behospital_info a,
         med_home_page b