shiqian 3 лет назад
Родитель
Сommit
259f680a56
16 измененных файлов с 286 добавлено и 0 удалено
  1. 3 0
      boman-api/boman-api-system/src/main/java/com/boman/system/api/RemoteDeptService.java
  2. 24 0
      boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/DateUtils.java
  3. 21 0
      boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/number/NumberUtils.java
  4. 8 0
      boman-modules/boman-system/src/main/java/com/boman/system/controller/SysDeptController.java
  5. 3 0
      boman-modules/boman-system/src/main/java/com/boman/system/mapper/SysDeptMapper.java
  6. 2 0
      boman-modules/boman-system/src/main/java/com/boman/system/service/ISysDeptService.java
  7. 10 0
      boman-modules/boman-system/src/main/java/com/boman/system/service/impl/SysDeptServiceImpl.java
  8. 4 0
      boman-modules/boman-system/src/main/resources/mapper/system/SysDeptMapper.xml
  9. 34 0
      boman-web-core/src/main/java/com/boman/web/core/controller/VaccinationController.java
  10. 2 0
      boman-web-core/src/main/java/com/boman/web/core/mapper/VaccineInfoMapper.java
  11. 6 0
      boman-web-core/src/main/java/com/boman/web/core/mapper/VaccineInfoUserMapper.java
  12. 8 0
      boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/IVaccineInfoService.java
  13. 96 0
      boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/impl/VaccineInfoServiceImpl.java
  14. 29 0
      boman-web-core/src/main/java/com/boman/web/core/utils/VaccineUtils.java
  15. 13 0
      boman-web-core/src/main/resources/mapper/VaccineInfoMapper.xml
  16. 23 0
      boman-web-core/src/main/resources/mapper/VaccineInfoUserMapper.xml

+ 3 - 0
boman-api/boman-api-system/src/main/java/com/boman/system/api/RemoteDeptService.java

@@ -32,5 +32,8 @@ public interface RemoteDeptService {
      */
     @GetMapping("/dept/list/children/depts/{deptId}")
     List<SysDept> listChildrenDepts(@PathVariable(value = "deptId") Long deptId);
+
+    @GetMapping("/dept/parentId/{parentId}")
+    List<SysDept> getByParentId(@PathVariable("parentId") Long parentId);
 }
 

+ 24 - 0
boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/DateUtils.java

@@ -64,6 +64,30 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
         return strToDate(time, YYYY_MM_DD_HH_MM_SS);
     }
 
+    /**
+     * 当天的开始时间
+     */
+    public static String getTodayStartStr() {
+        return getDate() + " 00:00:00";
+    }
+
+
+    /**
+     * 当天的开始时间
+     */
+    public static String getTodayEndStr() {
+        return getDate() + " 23:59:59";
+    }
+
+    public static Date addDay(Date date, int day) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.DATE, day);
+        return calendar.getTime();
+    }
+
+
+
     /**
      * 指定日期的的开始时间
      */

+ 21 - 0
boman-common/boman-common-core/src/main/java/com/boman/common/core/utils/number/NumberUtils.java

@@ -3,6 +3,8 @@ package com.boman.common.core.utils.number;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.text.NumberFormat;
+
 import static com.boman.common.core.utils.obj.ObjectUtils.*;
 
 /**
@@ -25,4 +27,23 @@ public class NumberUtils {
         return input == 0;
     }
 
+    /**
+     * 功能描述: 两个int相除,取百分比
+     *
+     * @param one one
+     * @param another another
+     * @return java.lang.String
+     */
+    public static String percent(Number one, Number another) {
+        if (another == null || another.intValue() == 0) {
+            return "0.00%";
+        }
+
+        double result = (double) one.longValue() / another.longValue();
+        NumberFormat numberFormat = NumberFormat.getPercentInstance();
+        //设置百分数精确度2即保留两位小数
+        numberFormat.setMinimumFractionDigits(2);
+        return numberFormat.format(result);
+    }
+
 }

+ 8 - 0
boman-modules/boman-system/src/main/java/com/boman/system/controller/SysDeptController.java

@@ -236,4 +236,12 @@ public class SysDeptController extends BaseController
         }
         return "循环了 " + moveData + " 条";
     }
+
+    /**
+     * 查找子部门,不递归
+     */
+    @GetMapping("/parentId/{parentId}")
+    public List<SysDept> getByParentId(@PathVariable("parentId") Long parentId) {
+        return deptService.getByParentId(parentId);
+    }
 }

+ 3 - 0
boman-modules/boman-system/src/main/java/com/boman/system/mapper/SysDeptMapper.java

@@ -49,6 +49,9 @@ public interface SysDeptMapper
      */
     public List<SysDept> selectChildrenDeptById(Long id);
 
+
+    List<SysDept> getByParentId(Long id);
+
     /**
      * 根据ID查询所有子部门(正常状态)
      * 

+ 2 - 0
boman-modules/boman-system/src/main/java/com/boman/system/service/ISysDeptService.java

@@ -125,5 +125,7 @@ public interface ISysDeptService
      */
     List<SysDept> listChildrenDepts(Long deptId);
 
+    List<SysDept> getByParentId(Long deptId);
+
     public List<JSONObject> syncData() throws Exception;
 }

+ 10 - 0
boman-modules/boman-system/src/main/java/com/boman/system/service/impl/SysDeptServiceImpl.java

@@ -3,10 +3,12 @@ package com.boman.system.service.impl;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import com.boman.common.core.utils.number.NumberUtils;
 import com.alibaba.fastjson.JSONObject;
 import com.boman.common.core.utils.obj.ObjectUtils;
 import com.boman.system.mapper.SyncMapper;
 import com.google.common.collect.Lists;
+import com.sun.org.apache.regexp.internal.RE;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.boman.domain.constant.UserConstants;
@@ -498,4 +500,12 @@ public class SysDeptServiceImpl implements ISysDeptService
         return null;
 
     }
+    @Override
+    public List<SysDept> getByParentId(Long deptId) {
+        if (null == deptId || deptId <= 0) {
+            return null;
+        }
+
+        return deptMapper.getByParentId(deptId);
+    }
 }

+ 4 - 0
boman-modules/boman-system/src/main/resources/mapper/system/SysDeptMapper.xml

@@ -84,6 +84,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	<select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">
 		select * from sys_dept where find_in_set(#{id}, ancestors)
 	</select>
+
+	<select id="getByParentId"  resultMap="SysDeptResult">
+		select * from sys_dept where parent_id = #{parentId}
+	</select>
 	
 	<select id="selectNormalChildrenDeptById" parameterType="Long" resultType="java.lang.Integer">
 		select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{id}, ancestors)

+ 34 - 0
boman-web-core/src/main/java/com/boman/web/core/controller/VaccinationController.java

@@ -0,0 +1,34 @@
+package com.boman.web.core.controller;
+
+import com.boman.domain.dto.AjaxResult;
+import com.boman.web.core.service.vaccineInfo.IVaccineInfoService;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+/**
+ * @author shiqian
+ * @date 2021年09月16日 15:13
+ * @description 统计分析
+ **/
+@RestController
+@RequestMapping("/vaccination")
+public class VaccinationController {
+
+    @Resource
+    private IVaccineInfoService service;
+
+    /**
+     * 功能描述: 统计 todo 后期可能会单独查某一个乡镇
+     *
+     * @return java.util.List<com.alibaba.fastjson.JSONObject>
+     */
+    @GetMapping("/statistic")
+    public AjaxResult statistic() {
+        return service.statistic();
+    }
+
+
+}

+ 2 - 0
boman-web-core/src/main/java/com/boman/web/core/mapper/VaccineInfoMapper.java

@@ -88,4 +88,6 @@ public interface VaccineInfoMapper
      * @return
      */
     public String selectSysDictDataByDictLabel(String vaccineName);
+
+    List<VaccineInfoOperation> listByTotalTaskCnt();
 }

+ 6 - 0
boman-web-core/src/main/java/com/boman/web/core/mapper/VaccineInfoUserMapper.java

@@ -1,9 +1,11 @@
 package com.boman.web.core.mapper;
 
+import com.alibaba.fastjson.JSONObject;
 import com.boman.web.core.domain.VaccineInfoOperation;
 import com.boman.web.core.domain.VaccineInfoUser;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -60,4 +62,8 @@ public interface VaccineInfoUserMapper {
      * @return
      */
     public List<String> selectIdCardList(VaccineInfoUser vaccineInfoUser);
+
+    int listBy1jici();
+
+    List<JSONObject> todayCnt(@Param("todayStart") String todayStart, @Param("todayEnd") String todayEnd);
 }

+ 8 - 0
boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/IVaccineInfoService.java

@@ -1,5 +1,6 @@
 package com.boman.web.core.service.vaccineInfo;
 
+import com.alibaba.fastjson.JSONObject;
 import com.boman.domain.dto.AjaxResult;
 import com.boman.web.core.domain.VaccineInfoOperation;
 
@@ -67,4 +68,11 @@ public interface IVaccineInfoService
      * @return
      */
     public VaccineInfoOperation  findHjInfo(VaccineInfoOperation vaccineInfo);
+
+    /**
+     * 功能描述: 统计
+     *
+     * @return java.util.List<com.alibaba.fastjson.JSONObject>
+     */
+    AjaxResult statistic();
 }

+ 96 - 0
boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/impl/VaccineInfoServiceImpl.java

@@ -1,8 +1,11 @@
 package com.boman.web.core.service.vaccineInfo.impl;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.boman.common.core.utils.DateUtils;
 import com.boman.common.core.utils.SecurityUtils;
 import com.boman.common.core.utils.StringUtils;
+import com.boman.common.core.utils.number.NumberUtils;
 import com.boman.common.core.utils.obj.ObjectUtils;
 import com.boman.domain.SysDept;
 import com.boman.domain.dto.AjaxResult;
@@ -14,7 +17,11 @@ import com.boman.web.core.mapper.VaccineInfoMapper;
 import com.boman.web.core.mapper.VaccineInfoOperationMapper;
 import com.boman.web.core.mapper.VaccineInfoUserMapper;
 import com.boman.web.core.service.vaccineInfo.IVaccineInfoService;
+import com.boman.web.core.service.vaccineInfo.IVaccineInfoUserService;
 import com.boman.web.core.utils.AuthUtils;
+import com.boman.web.core.utils.VaccineUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
@@ -26,6 +33,8 @@ import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import static com.boman.common.core.utils.StringUtils.isNotEmpty;
+
 /**
  * 疫苗信息Service业务层处理
  *
@@ -35,6 +44,8 @@ import java.util.regex.Pattern;
 @Service
 public class VaccineInfoServiceImpl implements IVaccineInfoService {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(VaccineInfoServiceImpl.class);
+
     private static final String INSERT = "insert";
     private static final String EDIT = "edit";
     private static final String DELETE = "delete";
@@ -870,4 +881,89 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
         String domic = vaccineInfo.getVillageTowns() + vaccineInfo.getVillage() + vaccineInfo.getVillagerGroup() + vaccineInfo.getDomicile();
         vaccineInfo.setDomicile(domic);
     }
+
+    /**
+     * 功能描述: 统计
+     *
+     * @return java.util.List<com.alibaba.fastjson.JSONObject>
+     */
+    @Override
+    public AjaxResult statistic() {
+        List<JSONObject> result = new ArrayList<>(17);
+        List<SysDept> allTowns = remoteDeptService.getByParentId(1L);
+        List<String> townNameList = ObjectUtils.map(allTowns, SysDept::getDeptName);
+
+        LOGGER.info("开始查询");
+        long l = System.currentTimeMillis();
+        List<VaccineInfoOperation> infoList = vaccineInfoMapper.listByTotalTaskCnt();
+        LOGGER.info("查询用时: {} s", (System.currentTimeMillis() - l) / 1000);
+
+        Date todayStart = DateUtils.getTodayStart(), todayEnd = DateUtils.getTodayEnd();
+        for (String townName : townNameList) {
+            int zrws = 0, zjzs = 0, drrws = 0, drjzs = 0, dez = 0, dsz = 0;
+            JSONObject jsonObject = new JSONObject(10);
+            jsonObject.put("xz", townName);
+            for (VaccineInfoOperation info : infoList) {
+                if (!townName.equals(info.getVillageTowns())) {
+                    continue;
+                }
+                // 总任务数
+                zrws++;
+
+
+                // 总接种数
+                if (isNotEmpty(info.getJici())) {
+                    if ("加强针".equals(info.getJici())) {
+                        zjzs++;
+                    } else if (Integer.parseInt(info.getJici()) >= 1) {
+                        zjzs++;
+                    }
+                }
+
+                Date vaccinationTime = info.getVaccinationTime();
+                if (null != vaccinationTime && vaccinationTime.after(todayStart) && vaccinationTime.before(todayEnd)) {
+                    drjzs++;
+                    if ("2".equals(info.getJici())) {
+                        dez++;
+                    } else  if ("3".equals(info.getJici())) {
+                        dsz++;
+                    }
+                }
+
+                // 接种时间和接种疫苗种类判断 当日任务数
+                if (null != vaccinationTime){
+                    String vaccineName = info.getVaccineName();
+                    judgeTodayTask(vaccineName, vaccinationTime, drrws, todayStart, todayEnd);
+                }
+            }
+
+            jsonObject.put("zrws", zrws);
+            jsonObject.put("zjzs", zjzs);
+            jsonObject.put("wcl1", NumberUtils.percent(zjzs, zrws));
+            jsonObject.put("wwcs", zrws - zjzs);
+
+            jsonObject.put("drjzs", drjzs);
+            jsonObject.put("drrws", drrws);
+            jsonObject.put("dez", dez);
+            jsonObject.put("dsz", dsz);
+            jsonObject.put("hj", dez + dsz);
+            jsonObject.put("wcl2", NumberUtils.percent(dez + dsz, drjzs));
+            LOGGER.info("疫苗接种统计数据为: {}", JSON.toJSONString(jsonObject));
+            result.add(jsonObject);
+        }
+
+        return AjaxResult.success("成功", result);
+    }
+
+    private void judgeTodayTask(String vaccineName, Date vaccinationTime, int drrws, Date todayStart, Date todayEnd) {
+        Date nextTime = VaccineUtils.getNextTime(vaccineName, vaccinationTime);
+        if (nextTime == null) {
+            return;
+        }
+
+        if (nextTime.before(todayEnd) && nextTime.after(todayStart)) {
+            drrws++;
+        }
+    }
+
 }

+ 29 - 0
boman-web-core/src/main/java/com/boman/web/core/utils/VaccineUtils.java

@@ -0,0 +1,29 @@
+package com.boman.web.core.utils;
+
+import com.boman.common.core.utils.DateUtils;
+
+import java.util.Date;
+
+/**
+ * @author shiqian
+ * @date 2021年09月17日 16:08
+ **/
+public class VaccineUtils {
+
+    public static Date getNextTime(String vaccineName, Date preDate) {
+        switch (vaccineName) {
+            case "北京科兴中维":
+                return DateUtils.addDay(preDate, 14);
+            case "北京生物":
+            case "兰州生物":
+                return DateUtils.addDay(preDate, 21);
+            case "深圳康泰":
+            case "安徽智飞":
+                return DateUtils.addDay(preDate, 28);
+            default:
+                return null;
+        }
+    }
+
+
+}

+ 13 - 0
boman-web-core/src/main/resources/mapper/VaccineInfoMapper.xml

@@ -40,6 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="manufacturer"    column="manufacturer"    />
         <result property="nowIn"    column="now_in"    />
         <result property="url"    column="url"    />
+        <result property="jici"     column="jici"      />
         <result property="suspendUrl"    column="suspend_url"    />
         <result property="otherUrl"    column="other_url"    />
         <result property="shouldSlow"    column="should_slow"    />
@@ -313,4 +314,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select dict_value  from sys_dict_data where dict_label = #{vaccineName} and  status = '0'
     </select>
 
+    <select id="listByTotalTaskCnt" resultMap="VaccineInfoResult">
+        SELECT id_card, village_towns, vaccination_time, age, jici, vaccine_name
+        FROM vaccine_info
+        WHERE age > 18
+          AND (
+                contraindication IS NULL
+                OR suspend IS NULL
+                OR other IS NULL
+            );
+    </select>
+
+
 </mapper>

+ 23 - 0
boman-web-core/src/main/resources/mapper/VaccineInfoUserMapper.xml

@@ -99,4 +99,27 @@
             #{id}
         </foreach>
     </delete>
+
+    <select id="listBy1jici" resultType="int">
+        SELECT count(1) FROM vaccine_info_user where is_del = 'N' and jici = '1';
+    </select>
+
+    <select id="todayCnt" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT count(1) one FROM vaccine_info_user WHERE is_del = 'N' AND jici = '1'
+            AND vaccination_time &gt;= #{todayStart}
+            AND vaccination_time &lt;= #{todayEnd}
+
+        UNION ALL
+
+        SELECT count(1) FROM vaccine_info_user WHERE is_del = 'N' AND jici = '2'
+            AND vaccination_time &gt;= #{todayStart}
+            AND vaccination_time &lt;= #{todayEnd}
+
+        UNION ALL
+
+        SELECT count(1) FROM vaccine_info_user WHERE is_del = 'N'
+            AND vaccination_time &gt;= #{todayStart}
+            AND vaccination_time &lt;= #{todayEnd}
+    </select>
+
 </mapper>