Prechádzať zdrojové kódy

导出openId 可添加项目

wangxy 2 týždňov pred
rodič
commit
78067a10ce

+ 3 - 10
fs-admin/src/main/java/com/fs/his/controller/FsUserController.java

@@ -42,14 +42,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import com.fs.common.annotation.Log;
 import com.fs.common.core.controller.BaseController;
 import com.fs.common.core.domain.AjaxResult;
@@ -165,7 +158,7 @@ public class FsUserController extends BaseController
 
     @PreAuthorize("@ss.hasPermi('his:user:exportOpenId')")
     @PostMapping("/exportOpenId")
-    public  void exportOpenIdList(HttpServletResponse response) throws IOException {
+    public  void exportOpenIdList(HttpServletResponse response,  @RequestParam(required = false) Long projectId) throws IOException {
         int batchSize = 10000; // 每批处理1000条
         long lastId = 0; // 从0开始
         boolean hasMore = true;
@@ -184,7 +177,7 @@ public class FsUserController extends BaseController
             int rowNum = 1;
 
             while (hasMore) {
-                List<UserOpenIdVO> batchList = fsUserService.selectOpenIdList(lastId, batchSize);
+                List<UserOpenIdVO> batchList = fsUserService.selectOpenIdList(lastId, batchSize, projectId);
 
                 if (batchList.isEmpty()) {
                     hasMore = false;

+ 16 - 2
fs-service/src/main/java/com/fs/his/mapper/FsUserMapper.java

@@ -260,8 +260,22 @@ public interface FsUserMapper
             "</script>"})
     Long selectFsUserExportListVOCount(FsUserParam fsUser);
 
-    @Select("SELECT user_id as userId, mp_open_id as openId FROM fs_user WHERE user_id > #{lastId} AND mp_open_id IS NOT NULL ORDER BY user_id LIMIT #{limit}")
-    List<UserOpenIdVO> selectOpenIdList(@Param("lastId") long lastId, @Param("limit") int limit);
+    @Select({"<script> " +
+            "SELECT DISTINCT fu.user_id as userId, fu.mp_open_id as openId " +
+            "FROM fs_user fu " +
+            "<if test=\"projectId != null\"> " +
+            "INNER JOIN fs_user_company_user fucu ON fu.user_id = fucu.user_id " +
+            "</if> " +
+            "WHERE fu.mp_open_id IS NOT NULL " +
+            "AND fu.is_del = 0 " +
+            "AND fu.user_id > #{lastId} " +
+            "<if test=\"projectId != null\"> " +
+            "AND fucu.project_id = #{projectId} " +
+            "</if> " +
+            "ORDER BY fu.user_id ASC " +
+            "LIMIT #{limit} " +
+            "</script>"})
+    List<UserOpenIdVO> selectOpenIdList(@Param("lastId") long lastId, @Param("limit") int limit,@Param("projectId") Long projectId);
 
     @Select("select * from fs_user where phone=#{phone}")
     FsUser selectFsUserByMpOpenId(@Param("phone") String phone);

+ 1 - 1
fs-service/src/main/java/com/fs/his/service/IFsUserService.java

@@ -143,7 +143,7 @@ public interface IFsUserService
      * 获取所有用户openId
      * @return
      */
-    List<UserOpenIdVO> selectOpenIdList(long lastId, int limit);
+    List<UserOpenIdVO> selectOpenIdList(long lastId, int limit,Long projectId);
 
     FsUser selectFsUserByMpOpenId(String openId);
 

+ 2 - 2
fs-service/src/main/java/com/fs/his/service/impl/FsUserServiceImpl.java

@@ -570,8 +570,8 @@ public class FsUserServiceImpl implements IFsUserService {
     }
 
     @Override
-    public List<UserOpenIdVO> selectOpenIdList(long lastId, int limit) {
-        return fsUserMapper.selectOpenIdList(lastId, limit);
+    public List<UserOpenIdVO> selectOpenIdList(long lastId, int limit,Long projectId) {
+        return fsUserMapper.selectOpenIdList(lastId, limit, projectId);
     }