Sfoglia il codice sorgente

批量导入账号过期时间

lyhzzz 1 anno fa
parent
commit
6210947daf

+ 1 - 0
src/main/java/com/fdkankan/manage/controller/ExcelController.java

@@ -41,6 +41,7 @@ public class ExcelController {
             case 2 : fileName = "cameraCompany.xlsx"; break;
             case 3 : fileName = "rtkDevice.xlsx"; break;
             case 4 : fileName = "rtkAccount.xlsx"; break;
+            case 5 : fileName = "rtkAccountFailureTime.xlsx"; break;
             default: throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
         }
         InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("template/"+fileName);

+ 4 - 0
src/main/java/com/fdkankan/manage/mapper/IRtkAccountMapper.java

@@ -4,6 +4,8 @@ import com.fdkankan.manage.entity.RtkAccount;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.List;
+
 /**
  * <p>
  *  Mapper 接口
@@ -15,4 +17,6 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface IRtkAccountMapper extends BaseMapper<RtkAccount> {
 
+    List<RtkAccount> getByNotUseList();
+    List<RtkAccount> getByCanUseList();
 }

+ 3 - 2
src/main/java/com/fdkankan/manage/service/IRtkAccountService.java

@@ -32,10 +32,11 @@ public interface IRtkAccountService extends IService<RtkAccount> {
 
     RtkAccount getByUserName(String userName);
 
-    List<RtkAccount> getByNotFailure();
-    Long getCanUseCount();
 
     Integer insExcelList(List<HashMap<Integer, String>> excelRowList);
 
     Integer insFailureTimeExcelList(List<HashMap<Integer, String>> excelRowList);
+
+    List<RtkAccount> getByNotUseList();
+    List<RtkAccount> getByCanUseList();
 }

+ 19 - 25
src/main/java/com/fdkankan/manage/service/impl/RtkAccountServiceImpl.java

@@ -92,18 +92,13 @@ public class RtkAccountServiceImpl extends ServiceImpl<IRtkAccountMapper, RtkAcc
             }
         }
 
-        LambdaQueryWrapper<RtkAccount> wrapper = new LambdaQueryWrapper<>();
-        wrapper.in(RtkAccount::getStatus,0,1);
-        wrapper.eq(RtkAccount::getUseStatus,0);
-        wrapper.orderByAsc(RtkAccount::getUpdateTime);
-        wrapper.orderByAsc(RtkAccount::getId);
-        List<RtkAccount> list = this.list(wrapper);
+        List<RtkAccount> list = this.getByNotUseList();
         if(list == null || list.isEmpty()){
             //账号库存不足,钉钉通知
             dingdingService.sendDingDingMsg(0);
             throw new BusinessException(ResultCode.RTK_ACCOUNT_NOT_EXIT);
         }
-        dingdingService.modelThreshold(list.size() -1,this.getCanUseCount());
+        dingdingService.modelThreshold(list.size() -1,this.getByCanUseList().size());
 
         RtkAccount rtkAccount = null;
         RtkUseLog rtkUseLog = rtkUseLogService.getByRtkSn(rtkSnCode);
@@ -122,16 +117,10 @@ public class RtkAccountServiceImpl extends ServiceImpl<IRtkAccountMapper, RtkAcc
         return rtkAccount;
     }
 
-    @Override
-    public Long getCanUseCount() {
-        LambdaQueryWrapper<RtkAccount> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(RtkAccount::getUseStatus,0);
-        return this.count(wrapper);
-    }
 
     private Boolean checkAccountFailureTime(Integer accountId) {
         RtkAccount dbRtkAccount = this.getById(accountId);
-        if(dbRtkAccount == null || dbRtkAccount.getStatus() == 3 || dbRtkAccount.getUseStatus() == 1){
+        if(dbRtkAccount == null  || dbRtkAccount.getUseStatus() == 1){
             return false;
         }
         if(dbRtkAccount.getFailureTime() != null &&  dbRtkAccount.getFailureTime().getTime() <= new Date().getTime() ){
@@ -232,14 +221,6 @@ public class RtkAccountServiceImpl extends ServiceImpl<IRtkAccountMapper, RtkAcc
         return this.getOne(wrapper);
     }
 
-    @Override
-    public List<RtkAccount> getByNotFailure() {
-        LambdaQueryWrapper<RtkAccount> wrapper = new LambdaQueryWrapper<>();
-        wrapper.ne(RtkAccount::getStatus,3);
-        wrapper.isNotNull(RtkAccount::getFailureTime);
-        wrapper.le(RtkAccount::getFailureTime,new Date());
-        return this.list(wrapper);
-    }
 
     @Override
     public Integer insExcelList(List<HashMap<Integer, String>> excelRowList) {
@@ -348,8 +329,7 @@ public class RtkAccountServiceImpl extends ServiceImpl<IRtkAccountMapper, RtkAcc
                 continue;
             }
             RtkAccount rtkAccount = this.getByUserName(userName);
-            if(rtkAccount ==null){
-                errorIndex.add(index -3);
+            if(rtkAccount == null){
                 continue;
             }
             Date failureTime = null;
@@ -374,7 +354,21 @@ public class RtkAccountServiceImpl extends ServiceImpl<IRtkAccountMapper, RtkAcc
     }
 
     private Integer updateFailureTime(List<RtkAccountInParam> params) {
-
+        for (RtkAccountInParam param : params) {
+            LambdaUpdateWrapper<RtkAccount> wrapper = new LambdaUpdateWrapper<>();
+            wrapper.eq(RtkAccount::getUserName,param.getUserName());
+            wrapper.set(RtkAccount::getFailureTime,param.getFailureTime());
+            this.update(wrapper);
+        }
         return params.size();
     }
+
+    @Override
+    public List<RtkAccount> getByNotUseList() {
+        return this.getBaseMapper().getByNotUseList();
+    }
+    @Override
+    public List<RtkAccount> getByCanUseList() {
+        return this.getBaseMapper().getByCanUseList();
+    }
 }

+ 2 - 15
src/main/java/com/fdkankan/manage/task/TaskService.java

@@ -74,15 +74,6 @@ public class TaskService {
             rtkAccountService.updateAccountStatus(rtkAccount.getId(),1);
         }
 
-        List<RtkAccount> rtkAccounts = rtkAccountService.getByNotFailure();
-        for (RtkAccount rtkAccount : rtkAccounts) {
-            rtkAccount.setStatus(3);
-            rtkAccountService.updateAccountStatus(rtkAccount.getId(),3);
-            if(map.containsKey(rtkAccount.getUserName())){
-                redisUtil.del(map.get(rtkAccount.getUserName()));
-            }
-        }
-
     }
 
 
@@ -90,16 +81,12 @@ public class TaskService {
      * 检查账号   账号库存不足,钉钉通知
      */
     public void checkAccountDb() {
-        LambdaQueryWrapper<RtkAccount> wrapper = new LambdaQueryWrapper<>();
-        wrapper.in(RtkAccount::getStatus,0,1);
-        wrapper.eq(RtkAccount::getUseStatus,0);
-        wrapper.orderByAsc(RtkAccount::getUpdateTime);
-        List<RtkAccount> list = rtkAccountService.list(wrapper);
+        List<RtkAccount> list = rtkAccountService.getByNotUseList();
         if(list == null || list.isEmpty()){
             dingdingService.sendDingDingMsg(0);
             return;
         }
-        dingdingService.modelThreshold(list.size(),rtkAccountService.getCanUseCount());
+        dingdingService.modelThreshold(list.size(),rtkAccountService.getByCanUseList().size());
     }
 
 

+ 8 - 0
src/main/resources/mapper/manage/RtkAccountMapper.xml

@@ -2,4 +2,12 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fdkankan.manage.mapper.IRtkAccountMapper">
 
+    <select id="getByNotUseList" resultType="com.fdkankan.manage.entity.RtkAccount">
+        SELECT * FROM t_rtk_account WHERE rec_status = 'A' and `status` in (0,1) and use_status = 0 and (failure_time is  null or failure_time &gt; NOW())
+        order by update_time asc,id asc
+    </select>
+
+    <select id="getByCanUseList" resultType="com.fdkankan.manage.entity.RtkAccount">
+        SELECT * FROM t_rtk_account WHERE rec_status = 'A'  and use_status = 0 and (failure_time is  null or failure_time &gt; NOW())
+    </select>
 </mapper>

BIN
src/main/resources/template/rtkAccountFailureTime.xlsx