LIVE_YE 2 år sedan
förälder
incheckning
e9e9fccd62

+ 36 - 19
ruoyi-admin/src/main/java/com/ruoyi/web/controller/info/UserInfoController.java

@@ -69,6 +69,22 @@ public class UserInfoController extends BaseController {
         return userInfoService.oneDate(userInfo);
     }
 
+    /***
+     * 信息对比
+     */
+    @GetMapping("/date")
+    public AjaxResult date(UserInfo userInfo) throws Exception {
+
+        if (StringUtils.isEmpty(userInfo.getStartTime()) || StringUtils.isEmpty(userInfo.getEndTime()) ||
+                StringUtils.isEmpty(userInfo.getDetectionNumber()) || StringUtils.isEmpty(userInfo.getJobStyle()) ||
+                StringUtils.isEmpty(userInfo.getFocusCrowdStyle())) {
+            return AjaxResult.error("请将对比参数填写完整后查询(开始时间,结束时间,检测频次(次数),职业类别,重点人群分类)");
+        }
+
+        userInfoService.date(userInfo);
+        return AjaxResult.success("正在处理中,请稍后刷新页面");
+    }
+
 
     /**
      * 导出导入人员信息列表
@@ -104,25 +120,6 @@ public class UserInfoController extends BaseController {
         ExcelUtil<UserInfo> util = new ExcelUtil<UserInfo>(UserInfo.class);
         List<UserInfo> userList = util.importExcel(file.getInputStream());
         SysUser user = SecurityUtils.getLoginUser().getUser();
-        if (userList == null) {
-            return AjaxResult.error("表格格式错误,请按照表格模板格式上传人员名单");
-        }
-
-        System.out.println("接口开始========");
-        StringBuilder sb = new StringBuilder();
-        for (UserInfo userInfo : userList) {
-            if (userInfo == null) {
-                return AjaxResult.error("表格格式错误,请按照表格模板格式上传人员名单");
-            }
-
-            if (userInfo.getIdCard().length() != 18) {
-                sb.append(userInfo.getName()).append(",");
-            }
-        }
-
-        if (StringUtils.isNotEmpty(sb.toString())) {
-            return AjaxResult.error("操作失败,以下人员身份证格式错误【" + sb.toString() + "】");
-        }
         //String operName = getUsername();
         userInfoService.importUser(userList, jobStyle, focusCrowdStyle, detectionNumber, detectionScope, startTime, endTime, user);
 
@@ -145,6 +142,7 @@ public class UserInfoController extends BaseController {
         return AjaxResult.success("正在处理中,请稍后刷新页面");
     }
 
+
     /**
      * 获取导入人员信息详细信息
      */
@@ -179,4 +177,23 @@ public class UserInfoController extends BaseController {
     public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(userInfoService.deleteUserInfoByIds(ids));
     }
+
+    /**
+     * 删除导入人员信息
+     */
+    @Log(title = "导入人员信息", businessType = BusinessType.DELETE)
+    @DeleteMapping("/one/{ids}")
+    public AjaxResult removeOne(@PathVariable Long[] ids) {
+        return toAjax(userInfoService.deleteUserInfoOneByIds(ids));
+    }
+
+    /**
+     * 删除导入人员信息
+     */
+    /*@Log(title = "导入人员信息", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{id}")
+    public AjaxResult remove(@PathVariable Long id) {
+        return toAjax(userInfoService.deleteUserInfoById(id));
+    }*/
+
 }

+ 18 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/test.java

@@ -0,0 +1,18 @@
+package com.ruoyi.web;
+
+
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.extra.mail.MailUtil;
+
+public class test {
+
+    /*public static void main(String[] args) {
+        //发送普通文本邮件,最后一个参数可选是否添加多个附件
+
+        //无附件
+        //MailUtil.send("276795936@qq.com", "测试标题", "测试内容", false);
+        //有附件
+        MailUtil.send("276795936@qq.com", "测试标题", "测试内容", true,
+                FileUtil.file("D:/git-project/qianshanNucleicContrast/data20220927.xlsx"));
+    }*/
+}

+ 10 - 0
ruoyi-admin/src/main/resources/config/mail.setting

@@ -0,0 +1,10 @@
+# 邮件服务器的SMTP地址,可选,默认为smtp.<发件人邮箱后缀>
+host = smtp.qq.com
+# 邮件服务器的SMTP端口,可选,默认25
+port = 25
+# 发件人(必须正确,否则发送失败)
+from = 3031401046@qq.com
+# 用户名,默认为发件人邮箱前缀
+user = 3031401046
+# 密码(注意,某些邮箱需要为SMTP服务单独设置授权码,详情查看相关帮助)
+pass = ayhccfubtlfgdfdh

+ 10 - 0
ruoyi-admin/src/main/resources/config/ww

@@ -0,0 +1,10 @@
+# 邮件服务器的SMTP地址,可选,默认为smtp.<发件人邮箱后缀>
+host = smtp.qq.com
+# 邮件服务器的SMTP端口,可选,默认25
+port = 25
+# 发件人(必须正确,否则发送失败)
+from = 1434899932@qq.com
+# 用户名,默认为发件人邮箱前缀
+user = 1434899932
+# 密码(注意,某些邮箱需要为SMTP服务单独设置授权码,详情查看相关帮助)
+pass = jpwxirwdegawbaff

+ 30 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java

@@ -8,6 +8,7 @@ import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.GregorianCalendar;
@@ -271,4 +272,33 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
 
     }
 
+    public static String formatString(Date date) {
+        SimpleDateFormat format = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
+        return format.format(date);
+    }
+
+    /**
+     * 根据时间加减时间(时间可为负)
+     *
+     * @return
+     */
+    public static String plusSeconds(String dateTime, int seconds) {
+        LocalDateTime parse = parse(dateTime, "yyyy-MM-dd HH:mm:ss");
+        LocalDateTime localDateTime = parse.plusMinutes(seconds);
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        return localDateTime.format(formatter);
+    }
+
+    /**
+     * String转LocalDateTime
+     *
+     * @param str
+     * @param format
+     * @return
+     */
+    public static LocalDateTime parse(String str, String format) {
+        DateTimeFormatter df = DateTimeFormatter.ofPattern(format);
+        return LocalDateTime.parse(str, df);
+    }
+
 }

+ 12 - 0
ruoyi-system/pom.xml

@@ -23,6 +23,18 @@
             <artifactId>ruoyi-common</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.8.7</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.sun.mail</groupId>
+            <artifactId>javax.mail</artifactId>
+            <version>1.6.2</version>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 4 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/IUserInfoService.java

@@ -68,4 +68,8 @@ public interface IUserInfoService
     AjaxResult oneDate(UserInfo userInfo) throws Exception;
 
     List<UserInfoOne> oneDateList(UserInfoOne userInfoOne);
+
+    int deleteUserInfoOneByIds(Long[] ids);
+
+    String date(UserInfo userInfo) throws Exception;
 }

+ 228 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/Task.java

@@ -0,0 +1,228 @@
+package com.ruoyi.system.service;
+
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.extra.mail.MailUtil;
+import com.ruoyi.common.core.domain.entity.SysDept;
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.system.domain.KeyPeopleInfo;
+import com.ruoyi.system.domain.OdsQssHsjcxx;
+import com.ruoyi.system.domain.UserInfo;
+import com.ruoyi.system.domain.UserNucleicTime;
+import com.ruoyi.system.mapper.KeyPeopleInfoMapper;
+import com.ruoyi.system.mapper.SysDeptMapper;
+import com.ruoyi.system.utils.ExcelUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Component
+public class Task {
+
+    @Resource
+    private OdsQssHsjcxxService qdsQssHsjcxxService;
+    @Resource
+    private SysDeptMapper deptMapper;
+    @Resource
+    private KeyPeopleInfoMapper keyPeopleInfoMapper;
+
+    /***
+     * 邮件发送(定时比对数据后发送邮件)
+     */
+    //@Scheduled(cron = "0 0 * * * ? ")
+    public void thirdNucleicAcid() {
+        try {
+            SysDept dept = new SysDept();
+            dept.setDeptName("定时任务");
+            List<SysDept> depts = deptMapper.selectDeptList(dept);
+            if(depts==null && depts.size()<=0){
+                System.out.println("定时任务: 部门名字错误");
+                return;
+            }
+            //获取人员信息
+            KeyPeopleInfo keyPeopleInfo = new KeyPeopleInfo();
+            keyPeopleInfo.setDeptId(depts.get(0).getDeptId().toString());
+            List<KeyPeopleInfo> keyPeopleInfoList = keyPeopleInfoMapper.selectKeyPeopleInfoList(keyPeopleInfo);
+
+            //获取当前时间
+            Date data = DateUtils.getNowDate();
+            String endTime = DateUtils.formatString(data);
+            //往前推1个小时
+            String startTime = DateUtils.plusSeconds(endTime, -60);
+
+            //SysUser user = SecurityUtils.getLoginUser().getUser();
+            //UserInfo userInfo = new UserInfo();
+            // startTime = "2022-09-20 00:00:00";
+            //String endTime = "2022-09-27 00:00:00";
+            String detectionNumber = "1";
+
+            //计算开始时间结束时间相隔天数
+            String detectionScope = "1H";
+
+            List<String> idCardList = keyPeopleInfoList.stream().map(KeyPeopleInfo::getIdCard).collect(Collectors.toList());
+            //从第三方数据库查询人员核酸计录
+            List<OdsQssHsjcxx> OdsQssHsjcxxList = qdsQssHsjcxxService.thirdNucleicAcid(startTime, endTime, idCardList);
+
+            Map<String, List<OdsQssHsjcxx>> OdsQssHsjcxxMapSorted = new HashMap<>();
+            if (OdsQssHsjcxxList != null && OdsQssHsjcxxList.size() > 0) {
+                OdsQssHsjcxxMapSorted = OdsQssHsjcxxList.stream().sorted(Comparator.comparing(OdsQssHsjcxx::getCjsj).reversed()).collect(Collectors.groupingBy(OdsQssHsjcxx::getSfzhm));
+            }
+            //把采集时间降序
+            List<UserNucleicTime> UserNucleicTimeList = new ArrayList<>();
+
+
+            int index = 0;
+            int count = 0;
+            List<UserInfo> userList = new ArrayList<>();
+
+            for (KeyPeopleInfo peopleInfo : keyPeopleInfoList) {
+                UserInfo userInfo = new UserInfo();
+                userInfo.setDeptId(depts.get(0).getDeptId().toString());
+                userInfo.setPhoneNum(peopleInfo.getPhoneNum());
+                userInfo.setName(peopleInfo.getName());
+                userInfo.setIdCard(peopleInfo.getIdCard());
+
+                //采集地点
+                StringBuilder collectPlace = new StringBuilder();
+                //核酸采集时间
+                StringBuilder nucleicCollectTime = new StringBuilder();
+                //核酸结果时间
+                StringBuilder nucleicResultsTime = new StringBuilder();
+                //核酸结果
+                StringBuilder nucleicResults = new StringBuilder();
+
+
+                userInfo.setJobStyle("重点人群");
+                userInfo.setFocusCrowdStyle("重点人群");
+                userInfo.setDetectionFrequency(detectionNumber + "/" + detectionScope);
+                userInfo.setDetectionNumber(detectionNumber);
+                userInfo.setDetectionScope(detectionScope);
+                userInfo.setStartTime(startTime);
+                userInfo.setEndTime(endTime);
+                //判断结果是否合格,默认合格
+                Boolean bl = true;
+
+                index = 0;
+                count = 0;
+                if (OdsQssHsjcxxMapSorted.size() > 0) {
+                    //身份证号码
+                    String idCard = userInfo.getIdCard();
+                    List<OdsQssHsjcxx> odsQssHsjcxxes = OdsQssHsjcxxMapSorted.get(idCard);
+                    if (odsQssHsjcxxes != null && odsQssHsjcxxes.size() > 0) {
+                        //String time = null;
+
+                        for (OdsQssHsjcxx odsQssHsjcxx : odsQssHsjcxxes) {
+
+                            if (StringUtils.isNotEmpty(collectPlace.toString())) {
+                                collectPlace.append("<br>");
+                            }
+                            collectPlace.append(odsQssHsjcxx.getJcdd());
+
+                            if (StringUtils.isNotEmpty(nucleicCollectTime.toString())) {
+                                nucleicCollectTime.append("<br>");
+                            }
+                            nucleicCollectTime.append(odsQssHsjcxx.getCjsj());
+
+                            if (StringUtils.isNotEmpty(nucleicResultsTime.toString())) {
+                                nucleicResultsTime.append("<br>");
+                            }
+                            nucleicResultsTime.append(odsQssHsjcxx.getJgcjss());
+
+                            if (StringUtils.isNotEmpty(nucleicResults.toString())) {
+                                nucleicResults.append("<br>");
+                            }
+                            if(StringUtils.isEmpty(odsQssHsjcxx.getJcjg())){
+                                nucleicResults.append(odsQssHsjcxx.getJcjg());
+                            }else if("0".equals(odsQssHsjcxx.getJcjg()) || "negative".equals(odsQssHsjcxx.getJcjg())){
+                                nucleicResults.append("阴性");
+                            }else if("1".equals(odsQssHsjcxx.getJcjg()) || "positive".equals(odsQssHsjcxx.getJcjg())){
+                                nucleicResults.append("阳性");
+                            }else{
+                                nucleicResults.append(odsQssHsjcxx.getJcjg());
+                            }
+
+                        }
+                        index = odsQssHsjcxxes.size();
+                    }
+
+
+                }
+                if (index < Integer.parseInt(detectionNumber)) {
+                    bl = false;
+                }
+                userInfo.setCollectPlace(collectPlace.toString());
+                userInfo.setNucleicCollectTime(nucleicCollectTime.toString());
+                userInfo.setNucleicResultsTime(nucleicResultsTime.toString());
+                userInfo.setNucleicResults(nucleicResults.toString());
+                userInfo.setDetectionProgress(index + "/" + detectionNumber);
+
+                if (bl) {
+                    userInfo.setDetectionResult("正常");
+                } else {
+                    userInfo.setDetectionResult("异常");
+                }
+
+                userList.add(userInfo);
+            }
+
+            /*if (OdsQssHsjcxxList != null && OdsQssHsjcxxList.size() > 0) {
+                for (OdsQssHsjcxx odsQssHsjcxx : OdsQssHsjcxxList) {
+                    for (UserInfo userInfo : userList) {
+                        if (userInfo.getIdCard().equals(odsQssHsjcxx.getSfzhm())) {
+                            UserNucleicTime userNucleicTime = new UserNucleicTime();
+                            userNucleicTime.setInfoId(userInfo.getId());
+                            userNucleicTime.setIdCard(odsQssHsjcxx.getSfzhm());
+                            userNucleicTime.setCollectPlace(odsQssHsjcxx.getJcdd());
+                            userNucleicTime.setNucleicCollectTime(odsQssHsjcxx.getCjsj());
+                            userNucleicTime.setNucleicResultsTime(odsQssHsjcxx.getJgcjss());
+                            userNucleicTime.setJobStyle(jobStyle);
+                            userNucleicTime.setFocusCrowdStyle(focusCrowdStyle);
+                            userNucleicTime.setName(userInfo.getName());
+                            userNucleicTime.setPhoneNum(userInfo.getPhoneNum());
+                            userNucleicTime.setDeptId(user.getDeptId().toString());
+                            UserNucleicTimeList.add(userNucleicTime);
+                            userNucleicTime.setDateSource("批量导入");
+                        }
+                    }
+                }
+            }*/
+
+            List<Map<String, Object>> mapList = new ArrayList<>();
+
+            for (UserInfo info : userList) {
+                Map<String, Object> map = new HashMap<>();
+                map.put("姓名", info.getName());
+                map.put("身份证号码", info.getIdCard());
+                map.put("联系号码", info.getPhoneNum());
+                map.put("核酸采集时间", info.getNucleicCollectTime());
+                map.put("核酸结果时间", info.getNucleicResultsTime());
+                map.put("采集地点", info.getCollectPlace());
+                map.put("采集结果", info.getNucleicResults());
+                map.put("职业类别", info.getJobStyle());
+                map.put("重点人群分类", info.getFocusCrowdStyle());
+                map.put("监测频次(次/天)", info.getDetectionFrequency());
+                map.put("比对开始时间", info.getStartTime());
+                map.put("比对结束时间", info.getEndTime());
+                map.put("进度(已做核酸次数/频次)", info.getDetectionProgress());
+                map.put("是否异常", info.getDetectionResult());
+                mapList.add(map);
+            }
+            String path = ExcelUtils.getInstance().createExcel(mapList, "核酸对比数据", "对比数据");
+            MailUtil.send("1434745622@qq.com", "重点人群定时对比数据", "时间:"+startTime+"--"+endTime, true,
+                    FileUtil.file(path));
+            MailUtil.send("1434899932@qq.com", "重点人群定时对比数据", "时间:"+startTime+"--"+endTime, true,
+                    FileUtil.file(path));
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+}

+ 16 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/KeyPeopleInfoServiceImpl.java

@@ -3,7 +3,10 @@ package com.ruoyi.system.service.impl;
 import java.util.List;
 
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.SysRole;
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
@@ -12,6 +15,8 @@ import com.ruoyi.system.domain.KeyPeopleInfo;
 import com.ruoyi.system.service.IKeyPeopleInfoService;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.management.relation.Role;
+
 /**
  * 重点人群信息Service业务层处理
  * 
@@ -45,6 +50,17 @@ public class KeyPeopleInfoServiceImpl implements IKeyPeopleInfoService
     @Override
     public List<KeyPeopleInfo> selectKeyPeopleInfoList(KeyPeopleInfo keyPeopleInfo)
     {
+        //权限控制
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        List<SysRole> roles = user.getRoles();
+        String deptId = user.getDeptId().toString();
+        for (SysRole role : roles) {
+            if("超级管理员".equals(role.getRoleName())){
+                deptId = "";
+                break;
+            }
+        }
+        keyPeopleInfo.setDeptId(deptId);
         return keyPeopleInfoMapper.selectKeyPeopleInfoList(keyPeopleInfo);
     }
 

+ 193 - 8
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserInfoServiceImpl.java

@@ -6,6 +6,7 @@ import com.alibaba.fastjson2.JSONObject;
 import com.alibaba.fastjson2.TypeReference;
 import com.ruoyi.common.annotation.DataSource;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.enums.DataSourceType;
 import com.ruoyi.common.utils.DateUtils;
@@ -13,14 +14,8 @@ import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.http.HttpClientUtils;
 import com.ruoyi.common.utils.http.HttpUtils;
-import com.ruoyi.system.domain.OdsQssHsjcxx;
-import com.ruoyi.system.domain.UserInfo;
-import com.ruoyi.system.domain.UserInfoOne;
-import com.ruoyi.system.domain.UserNucleicTime;
-import com.ruoyi.system.mapper.SysDictTypeMapper;
-import com.ruoyi.system.mapper.UserInfoMapper;
-import com.ruoyi.system.mapper.UserInfoOneMapper;
-import com.ruoyi.system.mapper.UserNucleicTimeMapper;
+import com.ruoyi.system.domain.*;
+import com.ruoyi.system.mapper.*;
 import com.ruoyi.system.service.IUserInfoService;
 import com.ruoyi.system.service.OdsQssHsjcxxService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -28,6 +23,7 @@ import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
 import java.io.IOException;
 import java.net.URLDecoder;
 import java.text.ParseException;
@@ -52,6 +48,8 @@ public class UserInfoServiceImpl implements IUserInfoService {
     private UserNucleicTimeMapper userNucleicTimeMapper;
     @Autowired
     private UserInfoOneMapper userInfoOneMapper;
+    @Autowired
+    private KeyPeopleInfoMapper keyPeopleInfoMapper;
 
     /**
      * 查询导入人员信息
@@ -124,6 +122,180 @@ public class UserInfoServiceImpl implements IUserInfoService {
         return userInfoMapper.deleteUserInfoById(id);
     }
 
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    @Async
+    public String date(UserInfo userInfoP) throws Exception {
+
+
+        System.out.println("接口开始========");
+        long start1 = System.currentTimeMillis();
+
+
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        //获取人员信息
+        KeyPeopleInfo keyPeopleInfo = new KeyPeopleInfo();
+        keyPeopleInfo.setDeptId(user.getDeptId().toString());
+        List<KeyPeopleInfo> keyPeopleInfoList = keyPeopleInfoMapper.selectKeyPeopleInfoList(keyPeopleInfo);
+
+        String startTime = userInfoP.getStartTime();
+        String endTime = userInfoP.getEndTime();
+        String detectionNumber = userInfoP.getDetectionNumber();
+
+        //计算开始时间结束时间相隔天数
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date date1 = simpleDateFormat.parse(startTime);
+        Date date2 = simpleDateFormat.parse(endTime);
+        String detectionScope = String.valueOf(DateUtils.differentDaysByMillisecond(date1, date2));
+        userInfoP.setDetectionScope(detectionScope);
+
+        List<String> idCardList = keyPeopleInfoList.stream().map(KeyPeopleInfo::getIdCard).collect(Collectors.toList());
+        //从第三方数据库查询人员核酸计录
+        List<OdsQssHsjcxx> OdsQssHsjcxxList = qdsQssHsjcxxService.thirdNucleicAcid(startTime, endTime, idCardList);
+
+        Map<String, List<OdsQssHsjcxx>> OdsQssHsjcxxMapSorted = new HashMap<>();
+        if (OdsQssHsjcxxList != null && OdsQssHsjcxxList.size() > 0) {
+            OdsQssHsjcxxMapSorted = OdsQssHsjcxxList.stream().sorted(Comparator.comparing(OdsQssHsjcxx::getCjsj).reversed()).collect(Collectors.groupingBy(OdsQssHsjcxx::getSfzhm));
+        }
+        //把采集时间降序
+        List<UserNucleicTime> UserNucleicTimeList = new ArrayList<>();
+
+
+        int index = 0;
+        int count = 0;
+        List<UserInfo> userList = new ArrayList<>();
+
+        for (KeyPeopleInfo peopleInfo : keyPeopleInfoList) {
+            UserInfo userInfo = new UserInfo();
+            userInfo.setDeptId(user.getDeptId().toString());
+            userInfo.setPhoneNum(peopleInfo.getPhoneNum());
+            userInfo.setName(peopleInfo.getName());
+            userInfo.setIdCard(peopleInfo.getIdCard());
+
+            //采集地点
+            StringBuilder collectPlace = new StringBuilder();
+            //核酸采集时间
+            StringBuilder nucleicCollectTime = new StringBuilder();
+            //核酸结果时间
+            StringBuilder nucleicResultsTime = new StringBuilder();
+            //核酸结果
+            StringBuilder nucleicResults = new StringBuilder();
+
+
+            userInfo.setJobStyle(userInfoP.getJobStyle());
+            userInfo.setFocusCrowdStyle(userInfoP.getFocusCrowdStyle());
+            userInfo.setDetectionFrequency(detectionNumber + "/" + detectionScope);
+            userInfo.setDetectionNumber(detectionNumber);
+            userInfo.setDetectionScope(detectionScope);
+            userInfo.setStartTime(startTime);
+            userInfo.setEndTime(endTime);
+            //判断结果是否合格,默认合格
+            Boolean bl = true;
+
+            index = 0;
+            count = 0;
+            String PhoneNum = "";
+            if (OdsQssHsjcxxMapSorted.size() > 0) {
+                //身份证号码
+                String idCard = userInfo.getIdCard();
+                List<OdsQssHsjcxx> odsQssHsjcxxes = OdsQssHsjcxxMapSorted.get(idCard);
+                if (odsQssHsjcxxes != null && odsQssHsjcxxes.size() > 0) {
+                    //String time = null;
+
+                    for (OdsQssHsjcxx odsQssHsjcxx : odsQssHsjcxxes) {
+
+
+                        if(StringUtils.isEmpty(PhoneNum)){
+                            PhoneNum = odsQssHsjcxx.getSjhm();
+                        }
+
+                        if (StringUtils.isNotEmpty(collectPlace.toString())) {
+                            collectPlace.append("<br>");
+                        }
+                        collectPlace.append(odsQssHsjcxx.getJcdd());
+
+                        if (StringUtils.isNotEmpty(nucleicCollectTime.toString())) {
+                            nucleicCollectTime.append("<br>");
+                        }
+                        nucleicCollectTime.append(odsQssHsjcxx.getCjsj());
+
+                        if (StringUtils.isNotEmpty(nucleicResultsTime.toString())) {
+                            nucleicResultsTime.append("<br>");
+                        }
+                        nucleicResultsTime.append(odsQssHsjcxx.getJgcjss());
+
+                        if (StringUtils.isNotEmpty(nucleicResults.toString())) {
+                            nucleicResults.append("<br>");
+                        }
+                        if(StringUtils.isEmpty(odsQssHsjcxx.getJcjg())){
+                            nucleicResults.append(odsQssHsjcxx.getJcjg());
+                        }else if("0".equals(odsQssHsjcxx.getJcjg()) || "negative".equals(odsQssHsjcxx.getJcjg())){
+                            nucleicResults.append("阴性");
+                        }else if("1".equals(odsQssHsjcxx.getJcjg()) || "positive".equals(odsQssHsjcxx.getJcjg())){
+                            nucleicResults.append("阳性");
+                        }else{
+                            nucleicResults.append(odsQssHsjcxx.getJcjg());
+                        }
+
+                    }
+                    index = odsQssHsjcxxes.size();
+                }
+
+
+            }
+            if (index < Integer.parseInt(detectionNumber)) {
+                bl = false;
+            }
+
+            userInfo.setPhoneNum(PhoneNum);
+            userInfo.setCollectPlace(collectPlace.toString());
+            userInfo.setNucleicCollectTime(nucleicCollectTime.toString());
+            userInfo.setNucleicResultsTime(nucleicResultsTime.toString());
+            userInfo.setNucleicResults(nucleicResults.toString());
+            userInfo.setDetectionProgress(index + "/" + detectionNumber);
+            PhoneNum = "";
+            if (bl) {
+                userInfo.setDetectionResult("正常");
+            } else {
+                userInfo.setDetectionResult("异常");
+            }
+
+            userList.add(userInfo);
+        }
+        if (OdsQssHsjcxxList != null && OdsQssHsjcxxList.size() > 0) {
+            for (OdsQssHsjcxx odsQssHsjcxx : OdsQssHsjcxxList) {
+                for (UserInfo userInfo : userList) {
+                    if (userInfo.getIdCard().equals(odsQssHsjcxx.getSfzhm())) {
+                        UserNucleicTime userNucleicTime = new UserNucleicTime();
+                        userNucleicTime.setInfoId(userInfo.getId());
+                        userNucleicTime.setIdCard(odsQssHsjcxx.getSfzhm());
+                        userNucleicTime.setCollectPlace(odsQssHsjcxx.getJcdd());
+                        userNucleicTime.setNucleicCollectTime(odsQssHsjcxx.getCjsj());
+                        userNucleicTime.setNucleicResultsTime(odsQssHsjcxx.getJgcjss());
+                        userNucleicTime.setJobStyle(userInfoP.getJobStyle());
+                        userNucleicTime.setFocusCrowdStyle(userInfoP.getFocusCrowdStyle());
+                        userNucleicTime.setName(userInfo.getName());
+                        userNucleicTime.setPhoneNum(userInfo.getPhoneNum());
+                        userNucleicTime.setDeptId(user.getDeptId().toString());
+                        UserNucleicTimeList.add(userNucleicTime);
+                        userNucleicTime.setDateSource("批量导入");
+                    }
+                }
+            }
+        }
+
+        //批量保存
+        userInfoMapper.insertUserInfoList(userList);
+        userNucleicTimeMapper.insertUserNucleicTimeList(UserNucleicTimeList);
+
+        long end1 = System.currentTimeMillis();
+        System.out.println("---------------接口耗时" + (end1 - start1) + "---------------");
+
+        return "操作成功";
+    }
+
+
     /**
      * 核酸比对人员导入
      *
@@ -141,6 +313,12 @@ public class UserInfoServiceImpl implements IUserInfoService {
     @Async
     public String importUser(List<UserInfo> userList, String jobStyle, String focusCrowdStyle, String detectionNumber,
                              String detectionScope, String startTime, String endTime, SysUser user) throws Exception {
+
+        if (userList == null) {
+            return "表格格式错误,请按照表格模板格式上传人员名单";
+        }
+
+        System.out.println("接口开始========");
         long start1 = System.currentTimeMillis();
 
         StringBuilder sb = new StringBuilder();
@@ -185,6 +363,8 @@ public class UserInfoServiceImpl implements IUserInfoService {
         int count = 0;
         String PhoneNum = "";
         for (UserInfo userInfo : userList) {
+
+            System.out.println("我在循环");
             userInfo.setDeptId(user.getDeptId().toString());
             //采集地点
             StringBuilder collectPlace = new StringBuilder();
@@ -459,5 +639,10 @@ public class UserInfoServiceImpl implements IUserInfoService {
         return userInfoOneMapper.selectUserInfoOneList(userInfoOne);
     }
 
+    @Override
+    public int deleteUserInfoOneByIds(Long[] ids) {
+        return userInfoOneMapper.deleteUserInfoOneByIds(ids);
+    }
+
 
 }

+ 131 - 0
ruoyi-system/src/main/java/com/ruoyi/system/utils/ExcelUtils.java

@@ -0,0 +1,131 @@
+package com.ruoyi.system.utils;
+
+import com.ruoyi.common.utils.StringUtils;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.*;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * @author river
+ * @date 2021/4/29
+ */
+public class ExcelUtils {
+
+    private static ExcelUtils instance = new ExcelUtils();
+
+    private ExcelUtils(){}
+
+    public static ExcelUtils getInstance(){
+        return instance;
+    }
+
+    /**
+     * 将 List<Map<String,Object>> 类型的数据导出为 Excel
+     * 默认 Excel 文件的输出路径为 项目根目录下
+     * 文件名为 filename + 时间戳 + .xlsx
+     *
+     * @param mapList 数据源(通常为数据库查询数据)
+     * @param filename   文件名前缀, 实际文件名后会加上日期
+     * @param title   表格首行标题
+     * @return  文件输出路径
+     */
+    public String  createExcel(List<Map<String, Object>> mapList,String filename, String title) {
+        //获取数据源的 key, 用于获取列数及设置标题
+        Map<String, Object> map = mapList.get(0);
+        Set<String> stringSet = map.keySet();
+        ArrayList<String> headList = new ArrayList<>(stringSet);
+
+        //定义一个新的工作簿
+        XSSFWorkbook wb = new XSSFWorkbook();
+        //创建一个Sheet页
+        XSSFSheet sheet = wb.createSheet(title);
+        //设置行高
+        sheet.setDefaultRowHeight((short) (2 * 256));
+        //为有数据的每列设置列宽
+        for (int i = 0; i < headList.size(); i++) {
+            sheet.setColumnWidth(i, 8000);
+        }
+        //设置单元格字体样式
+        XSSFFont font = wb.createFont();
+        font.setFontName("等线");
+        font.setFontHeightInPoints((short) 16);
+
+        //在sheet里创建第一行,并设置单元格内容为 title (标题)
+        XSSFRow titleRow = sheet.createRow(0);
+        XSSFCell titleCell = titleRow.createCell(0);
+        titleCell.setCellValue(title);
+        //合并单元格CellRangeAddress构造参数依次表示起始行,截至行,起始列, 截至列
+        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, headList.size() - 1));
+        // 创建单元格文字居中样式并设置标题单元格居中
+        XSSFCellStyle cellStyle = wb.createCellStyle();
+        cellStyle.setAlignment(HorizontalAlignment.CENTER);
+        titleCell.setCellStyle(cellStyle);
+
+        //获得表格第二行
+        XSSFRow row = sheet.createRow(1);
+        //根据数据源信息给第二行每一列设置标题
+        for (int i = 0; i < headList.size(); i++) {
+            XSSFCell cell = row.createCell(i);
+            cell.setCellValue(headList.get(i));
+        }
+
+        XSSFRow rows;
+        XSSFCell cells;
+        //循环拿到的数据给所有行每一列设置对应的值
+        for (int i = 0; i < mapList.size(); i++) {
+            //在这个sheet页里创建一行
+            rows = sheet.createRow(i + 2);
+            //给该行数据赋值
+            for (int j = 0; j < headList.size(); j++) {
+                String value = "";
+                if(StringUtils.isEmpty((String) mapList.get(i).get(headList.get(j)))){
+
+                }else{
+                    value = mapList.get(i).get(headList.get(j)).toString();
+                }
+                cells = rows.createCell(j);
+                cells.setCellValue(value);
+            }
+        }
+
+        Date date = new Date();
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
+        // 使用项目根目录, 文件名加上时间戳
+        String path = System.getProperty("user.dir") + "\\" + filename + dateFormat.format(date) + ".xlsx";
+        System.out.println("Excel文件输出路径: "+path);
+        try {
+            File file = new File(path);
+            FileOutputStream fileOutputStream = new FileOutputStream(file);
+            wb.write(fileOutputStream);
+
+            fileOutputStream.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return path;
+    }
+
+
+   /* public static void main(String[] args) {
+        System.out.println("start...");
+        List<Map<String, Object>> mapArrayList = new ArrayList<>();
+        for (int i = 0; i < 3; i++) {
+            Map<String, Object> map = new HashMap<>();
+            map.put("队列", i);
+            map.put("生产者", i);
+            map.put("消费者", i);
+            mapArrayList.add(map);
+        }
+        System.out.println("end...");
+        ExcelUtils.getInstance().createExcel(mapArrayList,"data","数据");
+
+    }*/
+
+}
+

+ 1 - 0
ruoyi-system/src/main/resources/mapper/system/KeyPeopleInfoMapper.xml

@@ -27,6 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
             <if test="idCard != null  and idCard != ''"> and id_card = #{idCard}</if>
             <if test="phoneNum != null  and phoneNum != ''"> and phone_num = #{phoneNum}</if>
+            <if test="deptId != null  and deptId != ''"> and dept_id = #{deptId}</if>
         </where>
     </select>
     

+ 0 - 2
ruoyi-system/src/main/resources/mapper/system/UserInfoMapper.xml

@@ -253,8 +253,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         from ( select sfzhm,xm,sjhm,cjsj,jgcjss,jcdd,jcjg,sjly
         from ods_qss_hsjcxx_all
         where cjsj > #{startTime}  and #{endTime}>=cjsj
-        from ods_qss_hsjcxx
-        where cjsj BETWEEN  #{startTime}  and #{endTime}
         and sfzhm in
         <foreach item="idCard" collection="idCardList" open="(" separator="," close=")">
             #{idCard}