浏览代码

异步处理导入接口

Administrator 2 年之前
父节点
当前提交
80af44d33f

+ 20 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/info/UserInfoController.java

@@ -5,6 +5,7 @@ import javax.servlet.http.HttpServletResponse;
 
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.system.domain.UserInfo;
 import com.ruoyi.system.service.IUserInfoService;
 import org.springframework.scheduling.annotation.EnableAsync;
@@ -93,6 +94,25 @@ 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);
         return AjaxResult.success("正在处理中,请稍后刷新页面");

+ 0 - 22
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserInfoServiceImpl.java

@@ -137,29 +137,7 @@ 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();
-        for (UserInfo userInfo : userList) {
-            if (userInfo == null) {
-                return "表格格式错误,请按照表格模板格式上传人员名单";
-            }
-
-            if (userInfo.getIdCard().length() != 18) {
-                sb.append(userInfo.getName()).append(",");
-            }
-        }
-
-        if (StringUtils.isNotEmpty(sb.toString())) {
-            return "操作失败,以下人员身份证格式错误【" + sb.toString() + "】";
-        }
-
         //计算开始时间结束时间相隔天数
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
         Date date1 = simpleDateFormat.parse(startTime);

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

@@ -197,12 +197,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="thirdNucleicAcid" resultType="com.ruoyi.system.domain.OdsQssHsjcxx">
         select sfzhm,xm,sjhm,cjsj,jgcjss,jcdd,jcjg,sjly
         from ods_qss_hsjcxx
-        where cjsj > #{startTime}  and #{endTime}>=cjsj
+        where cjsj BETWEEN  #{startTime}  and #{endTime}
         and sfzhm in
         <foreach item="idCard" collection="idCardList" open="(" separator="," close=")">
             #{idCard}
         </foreach>
-        order by cjsj desc
     </select>
 
 </mapper>