Browse Source

白马项目同步bug

liuyc 1 year ago
parent
commit
1fe6e73567

+ 1 - 14
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/SaveUserInfoByProjectClientImpl.java

@@ -54,20 +54,7 @@ public class SaveUserInfoByProjectClientImpl implements SaveUserInfoByProjectCli
         obj.setContractId(String.valueOf(contractId));
         obj.setRoleId(String.valueOf(roleId));
         obj.setStatus(1);
-
-        List<SaveUserInfoByProjectDTO> saveUserInfozList = saveUserInfoByProjectService.getBaseMapper().selectList(Wrappers.<SaveUserInfoByProjectDTO>query().lambda()
-                .eq(SaveUserInfoByProjectDTO::getUserId, userId)
-                .isNull(SaveUserInfoByProjectDTO::getPostId)
-                .eq(SaveUserInfoByProjectDTO::getContractId, contractId));
-
-        if(saveUserInfozList ==null && saveUserInfozList.size()==0){
-            saveUserInfoByProjectService.getBaseMapper().delete(Wrappers.<SaveUserInfoByProjectDTO>query().lambda()
-                    .eq(SaveUserInfoByProjectDTO::getUserId, userId)
-                    .isNull(SaveUserInfoByProjectDTO::getPostId)
-                    .eq(SaveUserInfoByProjectDTO::getContractId, contractId));
-            saveUserInfoByProjectService.save(obj);
-        }
-
+        saveUserInfoByProjectService.save(obj);
     }
 
 

+ 15 - 9
blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java

@@ -62,6 +62,7 @@ import org.springblade.system.user.service.IUserService;
 import org.springblade.system.user.util.AesInfoUtil;
 import org.springblade.system.user.vo.UserVO;
 import org.springblade.system.user.wrapper.UserWrapper;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -94,6 +95,7 @@ public class UserController {
     private final IUserService userService;
     private final BladeRedis bladeRedis;
     private final SaveUserInfoByProjectClient saveUserInfoByProjectClient;
+    private final JdbcTemplate jdbcTemplate;
 
     /**
      * 查询单条
@@ -447,7 +449,7 @@ public class UserController {
             }
             QueryWrapper<User> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("account", tokenAccount);
-           // queryWrapper.eq("password", tokenPw);
+            // queryWrapper.eq("password", tokenPw);
             queryWrapper.eq("sys_type", 2);
             User userInfo = userService.getOne(queryWrapper);
             if (userInfo == null) {
@@ -491,7 +493,7 @@ public class UserController {
      * 定时同步白马项目用户信息
      */
     @Scheduled(cron = "0 0 4 * * ?")
-  //  @Scheduled(cron = "0 */5 * * * ?")
+    //@Scheduled(cron = "0 * * * * ?")
     public void syncProjectUserInfo() throws ParseException, IOException {
         JSONObject json = new JSONObject();
         json.put("fn", "all");
@@ -521,14 +523,14 @@ public class UserController {
                         String projectName = jsonObject.getString("projectName") + ""; //公司名称
                         String status = jsonObject.getString("status"); //状态(1:启用  2:冻结  3:删除)
                         User newUser = new User();
-                        if(projectName.indexOf("白马项目") >= 0
+                        if (projectName.contains("白马项目")
                                 || constructionCompany.equals("重庆白马航运发展有限公司")
                                 || constructionCompany.equals("中国水利水电第八工程局有限公司")
                                 || constructionCompany.equals("中国水利水电第四工程局中电建路桥集团联合体")
                                 || companyName.equals("重庆白马航运发展有限公司")
                                 || companyName.equals("中国水利水电第八工程局有限公司")
                                 || companyName.equals("中国水利水电第四工程局中电建路桥集团联合体")
-                        )  {
+                        ) {
                             User sysUser = userService.getOne(Wrappers.<User>lambdaQuery().eq(User::getSysId, id).eq(User::getSysType, 2));
                             if (sysUser != null) {
                                 newUser = sysUser;
@@ -553,13 +555,17 @@ public class UserController {
                             newUser.setStatus(Integer.parseInt(status));
                             newUser.setIdNumber(idCard);
                             newUser.setCompanyName(companyName);
-                            newUser.setRoleId("1537249581371707394"); //角色施工-资料员id:1537249581371707394
-                            userService.saveOrUpdate(newUser);
-                            userService.submitUserDept(newUser);
 
-                            //绑定项目,设置默认角色信息 白马项目id:1612329251049537537;第二期合同段id:1612335077269143554;角色施工-资料员id:1537249581371707394
-                            saveUserInfoByProjectClient.saveInfoRelation(newUser.getId(), 1612329251049537537L, 1612335077269143554L, 1537249581371707394L);
+                            Long count = jdbcTemplate.queryForObject("select count(1) from m_project_assignment_user where user_id = " + newUser.getId() + " and  project_id = 1612329251049537537 and contract_id = 1612335077269143554 and post_id is null and status = 1 and is_deleted = 0", Long.class);
+                            if (count == null || count == 0L) {
+                                //绑定项目,设置默认角色信息 白马项目id:1612329251049537537;第二期合同段id:1612335077269143554;角色施工-资料员id:1537249581371707394
+                                saveUserInfoByProjectClient.saveInfoRelation(newUser.getId(), 1612329251049537537L, 1612335077269143554L, 1537249581371707394L);
+
+                                newUser.setRoleId("1537249581371707394"); //角色施工-资料员id:1537249581371707394
+                            }
 
+                            userService.saveOrUpdate(newUser);
+                            userService.submitUserDept(newUser);
                         }
                     }
                 }