ct 2 дней назад
Родитель
Сommit
68727107f2

+ 8 - 1
fs-admin/src/main/java/com/fs/web/controller/common/CommonController.java

@@ -12,12 +12,12 @@ import com.fs.framework.config.ServerConfig;
 import com.fs.his.domain.FsExportTask;
 import com.fs.his.service.IFsExportTaskService;
 import com.fs.im.service.OpenIMService;
+import com.fs.qw.service.IQwUserService;
 import com.fs.system.oss.CloudStorageService;
 import com.fs.system.oss.OSSFactory;
 
 import com.fs.web.vo.WangUploadVO;
 
-import com.huaweicloud.sdk.vod.v1.model.BaseInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -72,6 +72,9 @@ public class CommonController
     public RedisTemplate redisTemplate;
 
     org.slf4j.Logger logger= LoggerFactory.getLogger(getClass());
+    @Autowired
+    private IQwUserService qwUserService;
+
     @GetMapping(value = "common/getTask/{taskId}")
     public R getTask(@PathVariable("taskId") Long taskId)
     {
@@ -305,4 +308,8 @@ public class CommonController
 
     }
 
+    @PostMapping("/common/unbindQwUserByServerIds")
+    public R unbindQwUserByServerIds(@RequestBody List<String> serverIds){
+        return qwUserService.unbindQwUserByServerIds(serverIds);
+    }
 }

+ 1 - 0
fs-framework/src/main/java/com/fs/framework/config/SecurityConfig.java

@@ -137,6 +137,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 .antMatchers("/common/uploadWang**").anonymous()
                 .antMatchers("/common/download**").anonymous()
                 .antMatchers("/common/download/resource**").anonymous()
+                .antMatchers("/common/unbindQwUserByServerIds").anonymous()
                 .antMatchers("/swagger-ui.html").anonymous()
                 .antMatchers("/swagger-resources/**").anonymous()
                 .antMatchers("/webjars/**").anonymous()

+ 2 - 0
fs-service/src/main/java/com/fs/qw/mapper/QwIpadServerUserMapper.java

@@ -5,6 +5,7 @@ import com.fs.qw.domain.QwIpadServerUser;
 import com.fs.qw.param.IPadServerUserParam;
 import com.fs.qw.vo.QwIPadServerUserVO;
 import org.apache.ibatis.annotations.Delete;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -73,4 +74,5 @@ public interface QwIpadServerUserMapper extends BaseMapper<QwIpadServerUser>{
     @Delete("DELETE FROM qw_ipad_server_user WHERE qw_user_id = #{id}")
     void deleteQwIpadServerUserByQwUserId(Long id);
 
+    void deleteQwIpadServerUserByQwUserIds(@Param("ids") List<Long> ids);
 }

+ 4 - 0
fs-service/src/main/java/com/fs/qw/mapper/QwUserMapper.java

@@ -499,4 +499,8 @@ public interface QwUserMapper extends BaseMapper<QwUser>
             "            </if>" +
             "</script>")
     List<Long> selectQwUserListByCompanyUserIdS(@Param("userIds") List<String> userIds);
+
+    List<QwUser> selectQwUserByServerIds(@Param("serverIds")List<String> serverIds);
+
+    int batchUpdateUnbind(@Param("ids")List<Long> ids);
 }

+ 2 - 0
fs-service/src/main/java/com/fs/qw/service/IQwIpadServerUserService.java

@@ -71,4 +71,6 @@ public interface IQwIpadServerUserService extends IService<QwIpadServerUser>{
     int deleteQwIpadServerUserById(Long id);
 
     void deleteQwIpadServerUserByQwUserId(Long id);
+
+    void deleteQwIpadServerUserByQwUserIds(List<Long> ids);
 }

+ 3 - 0
fs-service/src/main/java/com/fs/qw/service/IQwUserService.java

@@ -205,4 +205,7 @@ public interface IQwUserService
 
     List<QwUser> selectQwUserByIds(List<Long> qwUserIdList);
     List<Long> selectQwUserListByCompanyUserIdS(List<String> userIds);
+
+    R unbindQwUserByServerIds(List<String> serverIds);
+
 }

+ 5 - 0
fs-service/src/main/java/com/fs/qw/service/impl/QwIpadServerUserServiceImpl.java

@@ -106,4 +106,9 @@ public class QwIpadServerUserServiceImpl extends ServiceImpl<QwIpadServerUserMap
     public void deleteQwIpadServerUserByQwUserId(Long id) {
         qwIpadServerUserMapper.deleteQwIpadServerUserByQwUserId(id);
     }
+
+    @Override
+    public void deleteQwIpadServerUserByQwUserIds(List<Long> ids) {
+        qwIpadServerUserMapper.deleteQwIpadServerUserByQwUserIds(ids);
+    }
 }

+ 52 - 0
fs-service/src/main/java/com/fs/qw/service/impl/QwUserServiceImpl.java

@@ -58,6 +58,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.io.*;
 import java.net.URL;
@@ -1569,6 +1570,57 @@ public class QwUserServiceImpl implements IQwUserService
         return qwUserMapper.selectQwUserListByCompanyUserIdS(userIds);
     }
 
+    @Override
+    @Transactional
+    public R unbindQwUserByServerIds(List<String> serverIds) {
+        if (serverIds!= null && !serverIds.isEmpty()) {
+            serverIds = serverIds.stream().distinct().collect(Collectors.toList()); //去重
+            //查询所有状态为 绑定了AI主机的
+            List<QwUser> list = qwUserMapper.selectQwUserByServerIds(serverIds);
+            if (list != null && !list.isEmpty()) {
+                for (QwUser qwUser : list) {
+
+                    try {
+                        QwIpadServerLog qwIpadServerLog = new QwIpadServerLog();
+                        qwIpadServerLog.setType(2);
+                        qwIpadServerLog.setTilie("退订解绑");
+                        qwIpadServerLog.setServerId(qwUser.getServerId());
+                        qwIpadServerLog.setQwUserId(qwUser.getId());
+                        qwIpadServerLog.setCompanyUserId(qwUser.getCompanyUserId());
+                        qwIpadServerLog.setCompanyId(qwUser.getCompanyId());
+                        qwIpadServerLog.setCreateTime(new Date());
+                        qwIpadServerLogService.insertQwIpadServerLog(qwIpadServerLog);
+//                        WxWorkGetQrCodeDTO wxWorkGetQrCodeDTO = new WxWorkGetQrCodeDTO();
+//                        wxWorkGetQrCodeDTO.setUuid(qwUser.getUid());
+//                        wxWorkService.LoginOut(wxWorkGetQrCodeDTO,qwUser.getServerId());
+                    } catch (Exception e) {
+                        log.error("企微用户:{},解绑ipad报错:{}", JSON.toJSONString(qwUser), e);
+                    }
+                }
+                List<Long> ids = list.stream().map(QwUser::getId).collect(Collectors.toList());
+                qwUserMapper.batchUpdateUnbind(ids); //修改qwUser的serverId和绑定状态
+//                ipadServerService.addServers(serverIds); // ipad数量退订归100
+                qwIpadServerUserService.deleteQwIpadServerUserByQwUserIds(ids); //删除 qwIpadServerUser
+                Long[] array = serverIds.stream()
+                        .map(str -> {
+                            if (str != null && !str.trim().isEmpty()) {
+                                try {
+                                    return Long.valueOf(str.trim());
+                                } catch (NumberFormatException e) {
+                                    return null; // 或抛出异常
+                                }
+                            }
+                            return null;
+                        })
+                        .toArray(Long[]::new);
+                ipadServerService.deleteQwIpadServerByIds(array); // 删除ipad
+            }
+
+
+        }
+        return R.ok();
+    }
+
     /**
      * 根据销售公司和企微ID查询企微用户
      */

+ 6 - 0
fs-service/src/main/resources/mapper/qw/QwIpadServerUserMapper.xml

@@ -88,4 +88,10 @@
             #{id}
         </foreach>
     </delete>
+    <delete id="deleteQwIpadServerUserByQwUserIds">
+        delete from qw_ipad_server_user where qw_user_id in
+        <foreach item="id" collection="ids" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
 </mapper>

+ 13 - 0
fs-service/src/main/resources/mapper/qw/QwUserMapper.xml

@@ -257,6 +257,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <update id="updateSendType">
         update qw_user set send_msg_type = #{type} where id in <foreach collection="ids" open="(" close=")" separator="," item="item">#{item}</foreach>
     </update>
+    <update id="batchUpdateUnbind">
+        update qw_user set server_id = null and server_status = 0 and ipad_status = 0 where id in
+        <foreach collection="ids" open="(" close=")" separator="," item="id">
+            #{id}
+        </foreach>
+    </update>
 
     <select id="selectOfflineUser" resultType="com.fs.qw.domain.QwUser">
         select * from qw_user where send_msg_type = 2 and server_id is not null and server_status = 1 and ipad_status = 1 limit 1
@@ -309,5 +315,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectQwUserVo"/>
         where  server_status = 1
     </select>
+    <select id="selectQwUserByServerIds" resultType="com.fs.qw.domain.QwUser">
+        <include refid="selectQwUserVo"/>
+        where  server_id in
+         <foreach collection="serverIds" item="serverId" open="(" close=")" separator=",">
+             #{serverId}
+         </foreach>
+    </select>
 
 </mapper>