|
|
@@ -1,6 +1,7 @@
|
|
|
package com.template.controller;
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.template.api.UnlockingCustomControllerAPI;
|
|
|
import com.template.common.utils.PasswordChecker;
|
|
|
@@ -12,14 +13,18 @@ import com.template.model.pojo.*;
|
|
|
import com.template.model.result.CommonResult;
|
|
|
import com.template.services.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
- * 前端控制器
|
|
|
+ * 前端控制器
|
|
|
* </p>
|
|
|
*
|
|
|
* @author ceshi
|
|
|
@@ -46,6 +51,9 @@ public class UnlockingCustomController implements UnlockingCustomControllerAPI {
|
|
|
@Autowired
|
|
|
OperatingRecordService operatingRecordService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ UnlockingEmployeeService unlockingEmployeeService;
|
|
|
+
|
|
|
@Override
|
|
|
public CommonResult saveCustomPassWord(CustomKeyPassWordDto dto) {
|
|
|
String permissionSettingId = dto.getPermissionSettingId();
|
|
|
@@ -104,10 +112,10 @@ public class UnlockingCustomController implements UnlockingCustomControllerAPI {
|
|
|
unlockingCustomService.save(unlockingAdmin);
|
|
|
operatingRecordService.save(operatingRecord);
|
|
|
return CommonResult.ok();
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
// 删除锁
|
|
|
- passwordIssController.deleteLockUser(unlockingAdmin.getLuid(),unlockingAdmin.getLockUserId());
|
|
|
+ passwordIssController.deleteLockUser(unlockingAdmin.getLuid(), unlockingAdmin.getLockUserId());
|
|
|
return CommonResult.fail();
|
|
|
}
|
|
|
|
|
|
@@ -161,10 +169,10 @@ public class UnlockingCustomController implements UnlockingCustomControllerAPI {
|
|
|
operatingRecordService.save(operatingRecord);
|
|
|
return CommonResult.ok();
|
|
|
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
// 删除锁
|
|
|
- passwordIssController.deleteLockUser(unlockingAdmin.getLuid(),unlockingAdmin.getLockUserId());
|
|
|
+ passwordIssController.deleteLockUser(unlockingAdmin.getLuid(), unlockingAdmin.getLockUserId());
|
|
|
return CommonResult.fail();
|
|
|
}
|
|
|
}
|
|
|
@@ -216,10 +224,10 @@ public class UnlockingCustomController implements UnlockingCustomControllerAPI {
|
|
|
operatingRecordService.save(operatingRecord);
|
|
|
return CommonResult.ok();
|
|
|
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
// 删除锁
|
|
|
- passwordIssController.deleteLockUser(unlockingAdmin.getLuid(),unlockingAdmin.getLockUserId());
|
|
|
+ passwordIssController.deleteLockUser(unlockingAdmin.getLuid(), unlockingAdmin.getLockUserId());
|
|
|
return CommonResult.fail();
|
|
|
}
|
|
|
}
|
|
|
@@ -234,7 +242,7 @@ public class UnlockingCustomController implements UnlockingCustomControllerAPI {
|
|
|
String lockUserId = byId.getLockUserId();
|
|
|
String luid = byId.getLuid();
|
|
|
|
|
|
- passwordIssController.deleteLockUser(luid,lockUserId);
|
|
|
+ passwordIssController.deleteLockUser(luid, lockUserId);
|
|
|
|
|
|
unlockingCustomService.removeById(unlockingAdminId);
|
|
|
|
|
|
@@ -257,7 +265,7 @@ public class UnlockingCustomController implements UnlockingCustomControllerAPI {
|
|
|
String startTime = updateLockDto.getStartTime();
|
|
|
String endTime = updateLockDto.getEndTime();
|
|
|
|
|
|
- passwordIssController.updateLock(lockUserId,luid,startTime,endTime);
|
|
|
+ passwordIssController.updateLock(lockUserId, luid, startTime, endTime);
|
|
|
|
|
|
byId.setStartTime(startTime);
|
|
|
byId.setEndTime(endTime);
|
|
|
@@ -267,5 +275,43 @@ public class UnlockingCustomController implements UnlockingCustomControllerAPI {
|
|
|
return CommonResult.ok();
|
|
|
}
|
|
|
|
|
|
+ // 定时删除过期用户
|
|
|
+ @Scheduled(cron = "0 0 0/2 * * ? ")
|
|
|
+// @Scheduled(cron = "0 0/1 * * * ?")
|
|
|
+ public void deleteUnlocking() {
|
|
|
+// 先查询已过期的自定义的锁
|
|
|
+ LambdaQueryWrapper<UnlockingCustom> wrapperUC = new LambdaQueryWrapper<>();
|
|
|
+ wrapperUC.le(UnlockingCustom::getEndTime, new Date());
|
|
|
+ List<UnlockingCustom> list = unlockingCustomService.list(wrapperUC);
|
|
|
+ if (list.size() > 0) {
|
|
|
+ ArrayList<Integer> idUCs = new ArrayList<>();
|
|
|
+ for (UnlockingCustom unlockingCustom : list) {
|
|
|
+ String luid = unlockingCustom.getLuid();
|
|
|
+ String lockUserId = unlockingCustom.getLockUserId();
|
|
|
+ passwordIssController.deleteLockUser(luid, lockUserId);
|
|
|
+ idUCs.add(unlockingCustom.getId());
|
|
|
+ }
|
|
|
+ unlockingCustomService.removeByIds(idUCs);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+// 查询员工已过期的锁
|
|
|
+ LambdaQueryWrapper<UnlockingEmployee> wrapperUE = new LambdaQueryWrapper<>();
|
|
|
+ wrapperUE.le(UnlockingEmployee::getEndTime, new Date());
|
|
|
+ List<UnlockingEmployee> list2 = unlockingEmployeeService.list(wrapperUE);
|
|
|
+ if (list2.size() > 0) {
|
|
|
+ ArrayList<Integer> idUEs = new ArrayList<>();
|
|
|
+ for (UnlockingEmployee unlockingEmployee : list2) {
|
|
|
+ String luid = unlockingEmployee.getLuid();
|
|
|
+ String lockUserId = unlockingEmployee.getLockUserId();
|
|
|
+ passwordIssController.deleteLockUser(luid, lockUserId);
|
|
|
+ idUEs.add(unlockingEmployee.getId());
|
|
|
+ }
|
|
|
+ unlockingEmployeeService.removeByIds(idUEs);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|