|
|
@@ -4,6 +4,7 @@ import com.fs.course.service.IFsUserCourseService;
|
|
|
import com.fs.qw.domain.QwIpadServerLog;
|
|
|
import com.fs.qw.domain.QwUser;
|
|
|
import com.fs.qw.mapper.QwUserMapper;
|
|
|
+import com.fs.qw.param.QwMandatoryRegistrParam;
|
|
|
import com.fs.qw.service.*;
|
|
|
import com.fs.sop.service.impl.QwSopLogsServiceImpl;
|
|
|
import com.fs.sop.service.impl.QwSopServiceImpl;
|
|
|
@@ -15,10 +16,14 @@ import com.fs.wxwork.service.WxWorkService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.time.Duration;
|
|
|
import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneId;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
@Component("qwTask")
|
|
|
public class qwTask {
|
|
|
@@ -73,6 +78,10 @@ public class qwTask {
|
|
|
private WxWorkService wxWorkService;
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IQwCompanyService iQwCompanyService;
|
|
|
+
|
|
|
+
|
|
|
//正在使用
|
|
|
public void qwExternalContact()
|
|
|
{
|
|
|
@@ -240,37 +249,41 @@ public class qwTask {
|
|
|
* 定时清除 占着茅坑不拉屎的ipad 账号
|
|
|
*/
|
|
|
public void selectQwUserByUnbindIpad(){
|
|
|
+
|
|
|
+ //查询所有状态为 绑定了AI主机的
|
|
|
List<QwUser> list = qwUserMapper.selectQwUserByTest();
|
|
|
for (QwUser qwUser : list) {
|
|
|
try {
|
|
|
- Integer serverStatus = qwUser.getServerStatus();
|
|
|
+
|
|
|
Long serverId = qwUser.getServerId();
|
|
|
- if (serverStatus==0){
|
|
|
- System.out.println("不需要解绑");
|
|
|
- }
|
|
|
+
|
|
|
if (serverId==null){
|
|
|
System.out.println("serverId不存在");
|
|
|
+ }else {
|
|
|
+ //没绑定销售 或者 已经离职
|
|
|
+ if (qwUser.getStatus()==0 || qwUser.getIsDel()==2){
|
|
|
+
|
|
|
+ updateIpadStatus(qwUser,serverId);
|
|
|
+ }
|
|
|
+
|
|
|
+ //绑定了销售-也绑定了ipad,但是长时间离线的(离线状态,无操作超过2天的,也自动解绑)
|
|
|
+ if(qwUser.getCreateTime()!=null){
|
|
|
+ Date createTime = qwUser.getCreateTime();
|
|
|
+ Integer serverStatus = qwUser.getServerStatus();
|
|
|
+ Integer ipadStatus = qwUser.getIpadStatus();
|
|
|
+
|
|
|
+ boolean result = isCreateTimeMoreThanDaysWithOptional(createTime, 2);
|
|
|
+ //大于2天 ,绑定了ipad,离线
|
|
|
+ if(result && serverStatus==1 && ipadStatus==0){
|
|
|
+ updateIpadStatus(qwUser,serverId);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
- QwUser u = new QwUser();
|
|
|
- u.setId(qwUser.getId());
|
|
|
- u.setServerId(null);
|
|
|
- u.setServerStatus(0);
|
|
|
- qwUserMapper.updateQwUser(u);
|
|
|
- ipadServerService.addServer(serverId);
|
|
|
- QwIpadServerLog qwIpadServerLog = new QwIpadServerLog();
|
|
|
- qwIpadServerLog.setType(2);
|
|
|
- qwIpadServerLog.setTilie("解绑");
|
|
|
- qwIpadServerLog.setServerId(serverId);
|
|
|
- qwIpadServerLog.setQwUserId(qwUser.getId());
|
|
|
- qwIpadServerLog.setCompanyUserId(qwUser.getCompanyUserId());
|
|
|
- qwIpadServerLog.setCompanyId(qwUser.getCompanyId());
|
|
|
- qwIpadServerLog.setCreateTime(new Date());
|
|
|
- qwIpadServerLogService.insertQwIpadServerLog(qwIpadServerLog);
|
|
|
- qwIpadServerUserService.deleteQwIpadServerUserByQwUserId(qwUser.getId());
|
|
|
- WxWorkGetQrCodeDTO wxWorkGetQrCodeDTO = new WxWorkGetQrCodeDTO();
|
|
|
- wxWorkGetQrCodeDTO.setUuid(qwUser.getUid());
|
|
|
- wxWorkService.LoginOut(wxWorkGetQrCodeDTO,qwUser.getServerId());
|
|
|
- updateIpadStatus(qwUser.getId(),0);
|
|
|
+
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
System.out.println("解绑ipad报错"+e);
|
|
|
|
|
|
@@ -278,6 +291,41 @@ public class qwTask {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void updateIpadStatus(QwUser qwUser,Long serverId){
|
|
|
+ QwUser u = new QwUser();
|
|
|
+ u.setId(qwUser.getId());
|
|
|
+ u.setServerId(null);
|
|
|
+ u.setServerStatus(0);
|
|
|
+ qwUserMapper.updateQwUser(u);
|
|
|
+ ipadServerService.addServer(serverId);
|
|
|
+ QwIpadServerLog qwIpadServerLog = new QwIpadServerLog();
|
|
|
+ qwIpadServerLog.setType(2);
|
|
|
+ qwIpadServerLog.setTilie("解绑");
|
|
|
+ qwIpadServerLog.setServerId(serverId);
|
|
|
+ qwIpadServerLog.setQwUserId(qwUser.getId());
|
|
|
+ qwIpadServerLog.setCompanyUserId(qwUser.getCompanyUserId());
|
|
|
+ qwIpadServerLog.setCompanyId(qwUser.getCompanyId());
|
|
|
+ qwIpadServerLog.setCreateTime(new Date());
|
|
|
+ qwIpadServerLogService.insertQwIpadServerLog(qwIpadServerLog);
|
|
|
+ qwIpadServerUserService.deleteQwIpadServerUserByQwUserId(qwUser.getId());
|
|
|
+ WxWorkGetQrCodeDTO wxWorkGetQrCodeDTO = new WxWorkGetQrCodeDTO();
|
|
|
+ wxWorkGetQrCodeDTO.setUuid(qwUser.getUid());
|
|
|
+ wxWorkService.LoginOut(wxWorkGetQrCodeDTO,qwUser.getServerId());
|
|
|
+ updateIpadStatus(qwUser.getId(),0);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static boolean isCreateTimeMoreThanDaysWithOptional(Date createTime, int days) {
|
|
|
+ return Optional.ofNullable(createTime)
|
|
|
+ .map(time -> {
|
|
|
+ LocalDateTime createDateTime = time.toInstant()
|
|
|
+ .atZone(ZoneId.systemDefault())
|
|
|
+ .toLocalDateTime();
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ Duration duration = Duration.between(createDateTime, now);
|
|
|
+ return duration.toDays() > days;
|
|
|
+ })
|
|
|
+ .orElse(false); // 为null时返回false,可根据需求调整
|
|
|
+ }
|
|
|
|
|
|
void updateIpadStatus(Long id ,Integer status){
|
|
|
QwUser u = new QwUser();
|
|
|
@@ -286,4 +334,39 @@ public class qwTask {
|
|
|
qwUserMapper.updateQwUser(u);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 强制注册-2025-11-12 之后的 更新
|
|
|
+ */
|
|
|
+ public void QwExternalContactMandatoryRegistration(){
|
|
|
+ try {
|
|
|
+// List<String> longs = qwExternalContactService.selectQwExternalContactMandatoryRegistration();
|
|
|
+ List<String> longs = iQwCompanyService.selectQwCompanyListFormCorpId();
|
|
|
+ longs.forEach(item->{
|
|
|
+ List<QwMandatoryRegistrParam> registrParamList = qwExternalContactService.selectQwExternalContactMandatoryRegistrationByIds(String.valueOf(item));
|
|
|
+
|
|
|
+ batchUpdateQwExternalContactMandatoryRegistration(registrParamList);
|
|
|
+
|
|
|
+ });
|
|
|
+ }catch (Exception e){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void batchUpdateQwExternalContactMandatoryRegistration(List<QwMandatoryRegistrParam> registrParamList) {
|
|
|
+ // 定义批量插入的大小
|
|
|
+ int batchSize = 300;
|
|
|
+
|
|
|
+ // 循环处理外部用户 ID,每次处理批量大小的子集
|
|
|
+ for (int i = 0; i < registrParamList.size(); i += batchSize) {
|
|
|
+
|
|
|
+ int endIndex = Math.min(i + batchSize, registrParamList.size());
|
|
|
+ List<QwMandatoryRegistrParam> batchList = registrParamList.subList(i, endIndex); // 获取当前批次的子集
|
|
|
+
|
|
|
+ qwExternalContactService.batchUpdateQwExternalContactMandatoryRegistration(batchList);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|