Forráskód Böngészése

Merge remote-tracking branch 'origin/debug' into debug

zhoutg 5 éve
szülő
commit
9c166e5d83

+ 0 - 48
src/main/java/com/diagbot/config/JwtConfigurer.java

@@ -1,48 +0,0 @@
-package com.diagbot.config;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
-import org.springframework.security.oauth2.provider.token.TokenStore;
-import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
-import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
-import org.springframework.util.FileCopyUtils;
-
-import java.io.IOException;
-
-/**
- * @Description: JWT配置类
- * @author: gaodm
- * @time: 2018/8/2 13:38
- */
-@Configuration
-public class JwtConfigurer {
-    @Autowired
-    private CustomAccessTokenConverter customAccessTokenConverter;
-
-    @Bean
-    @Qualifier("tokenStoreClient")
-    public TokenStore tokenStoreClient() {
-
-        System.out.println("Created JwtTokenStoreClient");
-        return new JwtTokenStore(jwtTokenEnhancer());
-    }
-
-    @Bean
-    protected JwtAccessTokenConverter jwtTokenEnhancer() {
-        JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
-        Resource resource = new ClassPathResource("public.cert");
-        String publicKey;
-        try {
-            publicKey = new String(FileCopyUtils.copyToByteArray(resource.getInputStream()));
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-        converter.setVerifierKey(publicKey);
-        converter.setAccessTokenConverter(customAccessTokenConverter);
-        return converter;
-    }
-}

+ 8 - 9
src/main/java/com/diagbot/config/OAuth2Configurer.java

@@ -1,6 +1,7 @@
 package com.diagbot.config;
 
 import com.diagbot.service.UrlUserService;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.context.annotation.Bean;
@@ -28,9 +29,11 @@ import java.util.Arrays;
  */
 @Configuration
 @EnableAuthorizationServer
+@Slf4j
 public class OAuth2Configurer extends AuthorizationServerConfigurerAdapter {
     @Autowired
     private UrlUserService urlUserService;
+
     @Override
     public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
         clients.inMemory()
@@ -58,10 +61,10 @@ public class OAuth2Configurer extends AuthorizationServerConfigurerAdapter {
         //指定认证管理器
         endpoints.authenticationManager(authenticationManager).userDetailsService(urlUserService);
         //指定token存储位置
-        endpoints.tokenStore(tokenStore());
+        endpoints.tokenStore(new JwtTokenStore(jwtTokenEnhancerServer()));
         // 自定义token生成方式
         TokenEnhancerChain tokenEnhancerChain = new TokenEnhancerChain();
-        tokenEnhancerChain.setTokenEnhancers(Arrays.asList(customerEnhancer(), jwtTokenEnhancer()));
+        tokenEnhancerChain.setTokenEnhancers(Arrays.asList(customerEnhancer(), jwtTokenEnhancerServer()));
         endpoints.tokenEnhancer(tokenEnhancerChain);
     }
 
@@ -76,16 +79,12 @@ public class OAuth2Configurer extends AuthorizationServerConfigurerAdapter {
     @Qualifier("authenticationManagerBean")
     private AuthenticationManager authenticationManager;
 
-    @Bean
-    public TokenStore tokenStore() {
-        return new JwtTokenStore(jwtTokenEnhancer());
-    }
-
-    @Bean
-    protected JwtAccessTokenConverter jwtTokenEnhancer() {
+    @Bean("JwtTokenEnhancerServer")
+    protected JwtAccessTokenConverter jwtTokenEnhancerServer() {
         KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory(new ClassPathResource("diagbot-jwt.jks"), "diagbot123456".toCharArray());
         JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
         converter.setKeyPair(keyStoreKeyFactory.getKeyPair("diagbot-jwt"));
+        log.info("Created JwtTokenEnhancerServer");
         return converter;
     }
 }

+ 32 - 4
src/main/java/com/diagbot/config/ResourceServerConfigurer.java

@@ -4,12 +4,22 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.jwt.crypto.sign.RsaVerifier;
 import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
 import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
 import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
 import org.springframework.security.oauth2.provider.token.TokenStore;
+import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
+import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
+import org.springframework.util.FileCopyUtils;
+
+import java.io.IOException;
 
 /**
  * @Description: 权限资源配置类
@@ -18,6 +28,7 @@ import org.springframework.security.oauth2.provider.token.TokenStore;
  */
 @Configuration
 @EnableResourceServer
+@ComponentScan({"com.diagbot.config"})
 public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
     Logger log = LoggerFactory.getLogger(ResourceServerConfigurer.class);
 
@@ -44,11 +55,28 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
 
     @Override
     public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
-        log.info("Configuring ResourceServerSecurityConfigurer ");
-        resources.resourceId("user-service").tokenStore(tokenStore);
+        log.info("Configuring ResourceServerSecurityConfigurer");
+        resources.resourceId("user-service").tokenStore(new JwtTokenStore(jwtTokenEnhancerClient()));
     }
 
     @Autowired
-    @Qualifier("tokenStoreClient")
-    TokenStore tokenStore;
+    private CustomAccessTokenConverter customAccessTokenConverter;
+
+    @Bean("jwtTokenEnhancerClient")
+    protected JwtAccessTokenConverter jwtTokenEnhancerClient() {
+        JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
+        Resource resource = new ClassPathResource("public.cert");
+        String publicKey;
+        try {
+            publicKey = new String(FileCopyUtils.copyToByteArray(resource.getInputStream()));
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        converter.setVerifierKey(publicKey);
+        //不设置这个会出现 Cannot convert access token to JSON
+        converter.setVerifier(new RsaVerifier(publicKey));
+        converter.setAccessTokenConverter(customAccessTokenConverter);
+        log.info("Created jwtTokenEnhancerClient");
+        return converter;
+    }
 }

+ 30 - 0
src/main/java/com/diagbot/dto/ResultDetailDTO.java

@@ -0,0 +1,30 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2020/4/15 16:26
+ */
+@Getter
+@Setter
+public class ResultDetailDTO {
+    /**
+     * 缺陷名称/科室名称
+     */
+    private String name;
+    /**
+     * 数量
+     */
+    private Integer num;
+    /**
+     * 占比
+     */
+    private Double percent;
+    /**
+     * 百分比
+     */
+    private String percentStr;
+}

+ 17 - 0
src/main/java/com/diagbot/dto/ResultStatisticsDTO.java

@@ -0,0 +1,17 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2020/4/15 15:59
+ */
+@Getter
+@Setter
+public class ResultStatisticsDTO {
+    List<ResultDetailDTO> details;
+}

+ 144 - 0
src/main/java/com/diagbot/entity/SysTaskCron.java

@@ -0,0 +1,144 @@
+package com.diagbot.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 定时任务
+ * </p>
+ *
+ * @author gaodm
+ * @since 2020-04-15
+ */
+public class SysTaskCron implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 是否删除,N:未删除,Y:删除
+     */
+    private String isDeleted;
+
+    /**
+     * 记录创建时间
+     */
+    private LocalDateTime gmtCreate;
+
+    /**
+     * 记录修改时间,如果时间是1970年则表示纪录未修改
+     */
+    private LocalDateTime gmtModified;
+
+    /**
+     * 创建人,0表示无创建人值
+     */
+    private String creator;
+
+    /**
+     * 修改人,如果为0则表示纪录未修改
+     */
+    private String modifier;
+
+    /**
+     * 任务编号
+     */
+    private String cronCode;
+
+    /**
+     * 任务执行周期
+     */
+    private String cron;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+    public String getIsDeleted() {
+        return isDeleted;
+    }
+
+    public void setIsDeleted(String isDeleted) {
+        this.isDeleted = isDeleted;
+    }
+    public LocalDateTime getGmtCreate() {
+        return gmtCreate;
+    }
+
+    public void setGmtCreate(LocalDateTime gmtCreate) {
+        this.gmtCreate = gmtCreate;
+    }
+    public LocalDateTime getGmtModified() {
+        return gmtModified;
+    }
+
+    public void setGmtModified(LocalDateTime gmtModified) {
+        this.gmtModified = gmtModified;
+    }
+    public String getCreator() {
+        return creator;
+    }
+
+    public void setCreator(String creator) {
+        this.creator = creator;
+    }
+    public String getModifier() {
+        return modifier;
+    }
+
+    public void setModifier(String modifier) {
+        this.modifier = modifier;
+    }
+    public String getCronCode() {
+        return cronCode;
+    }
+
+    public void setCronCode(String cronCode) {
+        this.cronCode = cronCode;
+    }
+    public String getCron() {
+        return cron;
+    }
+
+    public void setCron(String cron) {
+        this.cron = cron;
+    }
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    @Override
+    public String toString() {
+        return "SysTaskCron{" +
+            "id=" + id +
+            ", isDeleted=" + isDeleted +
+            ", gmtCreate=" + gmtCreate +
+            ", gmtModified=" + gmtModified +
+            ", creator=" + creator +
+            ", modifier=" + modifier +
+            ", cronCode=" + cronCode +
+            ", cron=" + cron +
+            ", remark=" + remark +
+        "}";
+    }
+}

+ 88 - 6
src/main/java/com/diagbot/facade/ConsoleFacade.java

@@ -1,17 +1,26 @@
 package com.diagbot.facade;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.diagbot.dto.ResultDetailDTO;
+import com.diagbot.dto.ResultStatisticsDTO;
 import com.diagbot.entity.BehospitalInfo;
 import com.diagbot.entity.QcresultInfo;
 import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.util.BeanUtil;
 import com.diagbot.util.DateUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.SysUserUtils;
+import com.diagbot.vo.FilterVO;
+import com.fasterxml.jackson.datatype.jsr310.DecimalUtils;
+import com.google.common.collect.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
 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;
 import java.util.stream.Collectors;
@@ -81,32 +90,32 @@ public class ConsoleFacade {
                     .size());
             retMap.put("本月甲级病历-人工", qcresultInfoList
                     .stream()
-                    .filter(i -> i.getGradeType().equals(2) && i.getLevel().equals("甲"))
+                    .filter(i -> i.getGradeType().equals(2) && i.getLevel().equals("甲"))
                     .collect(Collectors.toList())
                     .size());
             retMap.put("本月甲级病历-机器", qcresultInfoList
                     .stream()
-                    .filter(i -> i.getGradeType().equals(1) && i.getLevel().equals("甲"))
+                    .filter(i -> i.getGradeType().equals(1) && i.getLevel().equals("甲"))
                     .collect(Collectors.toList())
                     .size());
             retMap.put("本月乙级病历-人工", qcresultInfoList
                     .stream()
-                    .filter(i -> i.getGradeType().equals(2) && i.getLevel().equals("乙"))
+                    .filter(i -> i.getGradeType().equals(2) && i.getLevel().equals("乙"))
                     .collect(Collectors.toList())
                     .size());
             retMap.put("本月乙级病历-机器", qcresultInfoList
                     .stream()
-                    .filter(i -> i.getGradeType().equals(1) && i.getLevel().equals("乙"))
+                    .filter(i -> i.getGradeType().equals(1) && i.getLevel().equals("乙"))
                     .collect(Collectors.toList())
                     .size());
             retMap.put("本月不合格病历-人工", qcresultInfoList
                     .stream()
-                    .filter(i -> i.getGradeType().equals(2) && i.getLevel().equals("丙"))
+                    .filter(i -> i.getGradeType().equals(2) && i.getLevel().equals("丙"))
                     .collect(Collectors.toList())
                     .size());
             retMap.put("本月不合格病历-机器", qcresultInfoList
                     .stream()
-                    .filter(i -> i.getGradeType().equals(1) && i.getLevel().equals("丙"))
+                    .filter(i -> i.getGradeType().equals(1) && i.getLevel().equals("丙"))
                     .collect(Collectors.toList())
                     .size());
         }
@@ -115,4 +124,77 @@ public class ConsoleFacade {
 
     }
 
+    /**
+     * 缺陷相关统计
+     *
+     * @param filterVO
+     * @return
+     */
+    public Map<String, Object> resultStatistics(FilterVO filterVO) {
+        Map<String, Object> retMap = new LinkedHashMap<>();
+        retMap.put("缺陷排行列表", Lists.newLinkedList());
+        retMap.put("各科室缺陷占比", Lists.newLinkedList());
+        String hospitalId = SysUserUtils.getCurrentHospitalID();
+        Date date = new Date();
+        String startDate = "";
+        String year = DateUtil.getYear(date);
+        int month = DateUtil.getMonth(date);
+        if (filterVO.getType().equals(1)) {
+            //本月统计
+            startDate = year + "-" + month + "-1";
+        } else if (filterVO.getType().equals(2)) {
+            //本年统计
+            startDate = year + "-1-1";
+        }
+        filterVO.setStartDate(startDate);
+        filterVO.setHospitalId(hospitalId);
+        filterVO.setLimitCount(10);
+        List<ResultDetailDTO> results = behospitalInfoFacade.resultStatistics(filterVO);
+        if (ListUtil.isNotEmpty(results)) {
+            results.forEach(result -> {
+                DecimalFormat df = new DecimalFormat("#.00");
+                String percentStr
+                        = df.format(BigDecimal.valueOf(result.getPercent()).multiply(BigDecimal.valueOf(100))) + "%";
+                result.setPercentStr(percentStr);
+            });
+            retMap.put("缺陷排行列表", results);
+        }
+        List<ResultDetailDTO> results2 = behospitalInfoFacade.resultStatisticsByDept(filterVO);
+        if (ListUtil.isNotEmpty(results2)) {
+            List<ResultDetailDTO> retResults = Lists.newLinkedList();
+            if (results2.size() <= 6) {
+                retResults = BeanUtil.listCopyTo(results2, ResultDetailDTO.class);
+            } else {
+
+                Double rate = 0d;
+                Integer num = 0;
+                for (ResultDetailDTO result : results2) {
+                    if (retResults.size() < 5) {
+                        rate = BigDecimal.valueOf(rate)
+                                .add(BigDecimal.valueOf(Double.valueOf(result.getPercent())))
+                                .doubleValue();
+                        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());
+                retResults.add(retResult);
+            }
+            retResults.forEach(result -> {
+                DecimalFormat df = new DecimalFormat("#.00");
+                String percentStr
+                        = df.format(BigDecimal.valueOf(result.getPercent()).multiply(BigDecimal.valueOf(100))) + "%";
+                result.setPercentStr(percentStr);
+            });
+            retMap.put("各科室缺陷占比", retResults);
+        }
+        return retMap;
+    }
 }

+ 6 - 7
src/main/java/com/diagbot/facade/QcCasesFacade.java

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.diagbot.dto.QcCasesAllDTO;
 import com.diagbot.dto.QcCasesDTO;
 import com.diagbot.entity.QcCases;
-import com.diagbot.entity.QcCasesEntryHospital;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
@@ -14,12 +13,11 @@ import com.diagbot.util.DateUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.SysUserUtils;
 import com.diagbot.vo.QcCasesQueryVO;
+import com.diagbot.vo.QcCasesSaveListVO;
 import com.diagbot.vo.QcCasesSaveVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
-import org.springframework.util.FileCopyUtils;
 
-import javax.rmi.CORBA.Util;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -41,10 +39,11 @@ public class QcCasesFacade extends QcCasesServiceImpl {
         return this.getQcCases(queryVO);
     }
 
-    public Boolean saveQcCases(List<QcCasesSaveVO> qcCasesSaveVOList) {
-        if (ListUtil.isNotEmpty(qcCasesSaveVOList)) {
+    public Boolean saveQcCases(QcCasesSaveListVO qcCasesSaveVOList) {
+        if (null != qcCasesSaveVOList
+                && ListUtil.isNotEmpty(qcCasesSaveVOList.getQcCasesSaveVOList())) {
             Date now = DateUtil.now();
-            for (QcCasesSaveVO qcCasesSaveVO : qcCasesSaveVOList) {
+            for (QcCasesSaveVO qcCasesSaveVO : qcCasesSaveVOList.getQcCasesSaveVOList()) {
                 qcCasesSaveVO.setHospitalId(Long.valueOf(SysUserUtils.getCurrentHospitalID()));
                 qcCasesSaveVO.setModifier(SysUserUtils.getCurrentPrincipleID());
                 qcCasesSaveVO.setGmtModified(now);
@@ -52,7 +51,7 @@ public class QcCasesFacade extends QcCasesServiceImpl {
         } else {
             throw new CommonException(CommonErrorCode.PARAM_IS_NULL);
         }
-        qcCasesHospitalFacade.updateBatch(qcCasesSaveVOList);
+        qcCasesHospitalFacade.updateBatch(qcCasesSaveVOList.getQcCasesSaveVOList());
         return true;
 
     }

+ 13 - 0
src/main/java/com/diagbot/facade/SysTaskCronFacade.java

@@ -0,0 +1,13 @@
+package com.diagbot.facade;
+
+import com.diagbot.service.impl.SysTaskCronServiceImpl;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Description: 定时任务装饰层
+ * @author: gaodm
+ * @time: 2020/4/15 17:44
+ */
+@Component
+public class SysTaskCronFacade extends SysTaskCronServiceImpl {
+}

+ 18 - 0
src/main/java/com/diagbot/mapper/BehospitalInfoMapper.java

@@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.MsgDTO;
+import com.diagbot.dto.ResultDetailDTO;
 import com.diagbot.entity.BehospitalInfo;
 import com.diagbot.vo.AnalyzeVO;
 import com.diagbot.vo.BehospitalPageVO;
+import com.diagbot.vo.FilterVO;
 
 import java.util.List;
 
@@ -23,4 +25,20 @@ public interface BehospitalInfoMapper extends BaseMapper<BehospitalInfo> {
     public IPage<BehospitalInfoDTO> getPage(BehospitalPageVO behospitalPageVO);
 
     public List<MsgDTO> getMsg(AnalyzeVO analyzeVO);
+
+    /**
+     * 缺陷排行列表统计
+     *
+     * @param filterVO
+     * @return
+     */
+    public List<ResultDetailDTO> resultStatistics(FilterVO filterVO);
+
+    /**
+     * 各科室缺陷占比
+     *
+     * @param filterVO
+     * @return
+     */
+    public List<ResultDetailDTO> resultStatisticsByDept(FilterVO filterVO);
 }

+ 16 - 0
src/main/java/com/diagbot/mapper/SysTaskCronMapper.java

@@ -0,0 +1,16 @@
+package com.diagbot.mapper;
+
+import com.diagbot.entity.SysTaskCron;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 定时任务 Mapper 接口
+ * </p>
+ *
+ * @author gaodm
+ * @since 2020-04-15
+ */
+public interface SysTaskCronMapper extends BaseMapper<SysTaskCron> {
+
+}

+ 18 - 0
src/main/java/com/diagbot/service/BehospitalInfoService.java

@@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.MsgDTO;
+import com.diagbot.dto.ResultDetailDTO;
 import com.diagbot.entity.BehospitalInfo;
 import com.diagbot.vo.AnalyzeVO;
 import com.diagbot.vo.BehospitalPageVO;
+import com.diagbot.vo.FilterVO;
 
 import java.util.List;
 
@@ -23,4 +25,20 @@ public interface BehospitalInfoService extends IService<BehospitalInfo> {
     public IPage<BehospitalInfoDTO> getPage(BehospitalPageVO behospitalPageVO);
 
     public List<MsgDTO> getMsg(AnalyzeVO analyzeVO);
+
+    /**
+     * 缺陷排行列表统计
+     *
+     * @param filterVO
+     * @return
+     */
+    public List<ResultDetailDTO> resultStatistics(FilterVO filterVO);
+
+    /**
+     * 各科室缺陷占比
+     *
+     * @param filterVO
+     * @return
+     */
+    public List<ResultDetailDTO> resultStatisticsByDept(FilterVO filterVO);
 }

+ 16 - 0
src/main/java/com/diagbot/service/SysTaskCronService.java

@@ -0,0 +1,16 @@
+package com.diagbot.service;
+
+import com.diagbot.entity.SysTaskCron;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 定时任务 服务类
+ * </p>
+ *
+ * @author gaodm
+ * @since 2020-04-15
+ */
+public interface SysTaskCronService extends IService<SysTaskCron> {
+
+}

+ 25 - 1
src/main/java/com/diagbot/service/impl/BehospitalInfoServiceImpl.java

@@ -4,11 +4,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.MsgDTO;
+import com.diagbot.dto.ResultDetailDTO;
 import com.diagbot.entity.BehospitalInfo;
 import com.diagbot.mapper.BehospitalInfoMapper;
 import com.diagbot.service.BehospitalInfoService;
 import com.diagbot.vo.AnalyzeVO;
 import com.diagbot.vo.BehospitalPageVO;
+import com.diagbot.vo.FilterVO;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -33,4 +35,26 @@ public class BehospitalInfoServiceImpl extends ServiceImpl<BehospitalInfoMapper,
     public List<MsgDTO> getMsg(AnalyzeVO analyzeVO) {
         return baseMapper.getMsg(analyzeVO);
     }
-}
+
+    /**
+     * 缺陷排行列表统计
+     *
+     * @param filterVO
+     * @return
+     */
+    @Override
+    public List<ResultDetailDTO> resultStatistics(FilterVO filterVO) {
+        return baseMapper.resultStatistics(filterVO);
+    }
+
+    /**
+     * 各科室缺陷占比
+     *
+     * @param filterVO
+     * @return
+     */
+    @Override
+    public List<ResultDetailDTO> resultStatisticsByDept(FilterVO filterVO) {
+        return baseMapper.resultStatisticsByDept(filterVO);
+    }
+}

+ 20 - 0
src/main/java/com/diagbot/service/impl/SysTaskCronServiceImpl.java

@@ -0,0 +1,20 @@
+package com.diagbot.service.impl;
+
+import com.diagbot.entity.SysTaskCron;
+import com.diagbot.mapper.SysTaskCronMapper;
+import com.diagbot.service.SysTaskCronService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 定时任务 服务实现类
+ * </p>
+ *
+ * @author gaodm
+ * @since 2020-04-15
+ */
+@Service
+public class SysTaskCronServiceImpl extends ServiceImpl<SysTaskCronMapper, SysTaskCron> implements SysTaskCronService {
+
+}

+ 64 - 0
src/main/java/com/diagbot/task/BehospitalInfoAnalyzeTask.java

@@ -0,0 +1,64 @@
+package com.diagbot.task;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.diagbot.entity.SysTaskCron;
+import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.facade.SysTaskCronFacade;
+import com.diagbot.util.StringUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.Trigger;
+import org.springframework.scheduling.TriggerContext;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.SchedulingConfigurer;
+import org.springframework.scheduling.config.ScheduledTaskRegistrar;
+import org.springframework.scheduling.support.CronTrigger;
+import org.springframework.stereotype.Component;
+
+import java.time.LocalDateTime;
+import java.util.Date;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/4/15 17:45
+ */
+//@Component
+//@Configuration      //1.主要用于标记配置类,兼备Component的效果。
+//@EnableScheduling   // 2.开启定时任务
+public class BehospitalInfoAnalyzeTask implements SchedulingConfigurer {
+    @Autowired
+    private SysTaskCronFacade sysTaskCronFacade;
+
+    private SysTaskCron task001 = new SysTaskCron();
+
+    /**
+     * 执行定时任务.
+     */
+    @Override
+    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
+        taskRegistrar.addTriggerTask(new Runnable() {
+            @Override
+            public void run() {
+                //1.添加任务内容(Runnable)
+                if (null != task001 && task001.getIsDeleted().equals(IsDeleteEnum.N.getKey())){
+                    System.out.println("执行动态定时任务: " + LocalDateTime.now().toLocalTime());
+                }
+            }
+        }, new Trigger() {
+            @Override
+            public Date nextExecutionTime(TriggerContext triggerContext) {
+                //2.1 从数据库获取执行周期
+                task001 = sysTaskCronFacade.getOne(new QueryWrapper<SysTaskCron>()
+                        .eq("cron_code", "TASK001"));
+                String cron = "0/5 * * * * ?";
+                //2.2 合法性校验.
+                if (null != task001 && StringUtil.isNotBlank(task001.getCron())) {
+                    cron = task001.getCron();
+                }
+                CronTrigger trigger=new CronTrigger(cron);
+                return trigger.nextExecutionTime(triggerContext);
+            }
+        });
+    }
+}

+ 34 - 0
src/main/java/com/diagbot/vo/FilterVO.java

@@ -0,0 +1,34 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2020/4/15 16:04
+ */
+@Getter
+@Setter
+public class FilterVO {
+    /**
+     * 统计维度 1-本月,2-本年
+     */
+    private Integer type;
+    /**
+     * 起始时间
+     */
+    private String startDate;
+    /**
+     * 结束时间
+     */
+    private String endDate;
+    /**
+     * 医院id
+     */
+    private String hospitalId;
+    /**
+     * 限制条数
+     */
+    private Integer limitCount;
+}

+ 17 - 0
src/main/java/com/diagbot/vo/QcCasesSaveListVO.java

@@ -0,0 +1,17 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/4/15 16:16
+ */
+@Getter
+@Setter
+public class QcCasesSaveListVO {
+    private List<QcCasesSaveVO> qcCasesSaveVOList;
+}

+ 11 - 0
src/main/java/com/diagbot/web/ConsoleController.java

@@ -3,10 +3,12 @@ package com.diagbot.web;
 import com.diagbot.annotation.SysLogger;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.ConsoleFacade;
+import com.diagbot.vo.FilterVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -34,4 +36,13 @@ public class ConsoleController {
         Map<String, Object> data = consoleFacade.mrStatistics();
         return RespDTO.onSuc(data);
     }
+
+    @ApiOperation(value = "缺陷相关统计[by:zhaops]",
+            notes = "")
+    @PostMapping("/resultStatistics")
+    @SysLogger("resultStatistics")
+    public RespDTO<Map<String, Object>> resultStatistics(@RequestBody FilterVO filterVO) {
+        Map<String, Object> data = consoleFacade.resultStatistics(filterVO);
+        return RespDTO.onSuc(data);
+    }
 }

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

@@ -4,6 +4,7 @@ import com.diagbot.annotation.SysLogger;
 import com.diagbot.dto.QcCasesDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.QcCasesFacade;
+import com.diagbot.vo.QcCasesSaveListVO;
 import com.diagbot.vo.QcCasesSaveVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -45,7 +46,7 @@ public class QcCasesController {
             notes = "")
     @PostMapping("/saveQcCases")
     @SysLogger("saveQcCases")
-    public RespDTO<Boolean> saveQcCases(@RequestBody List<QcCasesSaveVO> qcCasesSaveVOList) {
+    public RespDTO<Boolean> saveQcCases(@RequestBody QcCasesSaveListVO qcCasesSaveVOList) {
         return RespDTO.onSuc(qcCasesFacade.saveQcCases(qcCasesSaveVOList));
     }
 }

+ 125 - 0
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -72,4 +72,129 @@
         order by a.order_no
     </select>
 
+
+    <!-- 缺陷排行列表 -->
+    <select id="resultStatistics"  parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.ResultDetailDTO">
+        SELECT
+        t1.msg AS name,
+        t1.num AS num,
+        round( t1.num / t2.totle, 4) AS percent
+        FROM
+        (
+        (
+        SELECT
+        c.msg,
+        count(*) AS num
+        FROM
+        med_behospital_info a,
+        med_qcresult_info b,
+        med_qcresult_detail c
+        WHERE
+        a.behospital_code = b.behospital_code
+        AND a.hospital_id = b.hospital_id
+        AND b.behospital_code = c.behospital_code
+        AND b.hospital_id = c.hospital_id
+        AND a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null and startDate != ''">
+            <![CDATA[ and a.leave_hospital_date >= #{startDate}]]>
+        </if>
+        GROUP BY
+        c.msg
+        ORDER BY
+        count(*) DESC
+        ) t1,
+        (
+        SELECT
+        count(*) AS totle
+        FROM
+        med_behospital_info a,
+        med_qcresult_info b,
+        med_qcresult_detail c
+        WHERE
+        a.behospital_code = b.behospital_code
+        AND a.hospital_id = b.hospital_id
+        AND b.behospital_code = c.behospital_code
+        AND b.hospital_id = c.hospital_id
+        AND a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null and startDate != ''">
+            <![CDATA[ and a.leave_hospital_date >= #{startDate}]]>
+        </if>
+        ) t2
+        )
+        <if test="limitCount != null and limitCount != ''">
+            limit 0,#{limitCount}
+        </if>
+    </select>
+
+    <!-- 各科室缺陷占比 -->
+    <select id="resultStatisticsByDept"  parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.ResultDetailDTO">
+        SELECT
+        t1.beh_dept_name AS name,
+        t1.num AS num,
+        round( t1.num / t2.totle, 4 ) AS percent
+        FROM
+        (
+        (
+        SELECT
+        a.beh_dept_id,
+        a.beh_dept_name,
+        count(*) AS num
+        FROM
+        med_behospital_info a,
+        med_qcresult_info b,
+        med_qcresult_detail c
+        WHERE
+        a.behospital_code = b.behospital_code
+        AND a.hospital_id = b.hospital_id
+        AND b.behospital_code = c.behospital_code
+        AND b.hospital_id = c.hospital_id
+        AND a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null and startDate != ''">
+            <![CDATA[ and a.leave_hospital_date >= #{startDate}]]>
+        </if>
+        GROUP BY
+        a.beh_dept_id,
+        a.beh_dept_name
+        ORDER BY
+        count(*) DESC
+        ) t1,
+        (
+        SELECT
+        count(*) AS totle
+        FROM
+        med_behospital_info a,
+        med_qcresult_info b,
+        med_qcresult_detail c
+        WHERE
+        a.behospital_code = b.behospital_code
+        AND a.hospital_id = b.hospital_id
+        AND b.behospital_code = c.behospital_code
+        AND b.hospital_id = c.hospital_id
+        AND a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null and startDate != ''">
+            <![CDATA[ and a.leave_hospital_date >= #{startDate}]]>
+        </if>
+        ) t2
+        )
+    </select>
 </mapper>

+ 2 - 2
src/test/java/com/diagbot/CodeGeneration.java

@@ -33,7 +33,7 @@ public class CodeGeneration {
         gc.setEnableCache(false);// XML 二级缓存
         gc.setBaseResultMap(true);// XML ResultMap
         gc.setBaseColumnList(false);// XML columList
-        gc.setAuthor("zhoutg");// 作者
+        gc.setAuthor("gaodm");// 作者
 
         // 自定义文件命名,注意 %s 会自动填充表实体属性!
         gc.setControllerName("%sController");
@@ -56,7 +56,7 @@ public class CodeGeneration {
         StrategyConfig strategy = new StrategyConfig();
 //        strategy.setTablePrefix(new String[] { "med_" });// 此处可以修改为您的表前缀
         strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
-        strategy.setInclude(new String[] { "qc_mode"}); // 需要生成的表
+        strategy.setInclude(new String[] { "sys_task_cron"}); // 需要生成的表
 
         strategy.setSuperServiceClass(null);
         strategy.setSuperServiceImplClass(null);