Parcourir la source

白马合同的同步人员问题

liuyc il y a 2 ans
Parent
commit
a2bd3cf957

+ 5 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ContractInfoController.java

@@ -165,6 +165,11 @@ public class ContractInfoController extends BladeController {
     @ApiOperationSupport(order = 7)
     @ApiOperation(value = "逻辑删除", notes = "传入ids")
     public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+        //白马合同段不允许删除,syncProjectUserInfo合同段同步白马人员接口使用中
+        List<String> baiMaList = Arrays.asList("1612335077269143554", "1613022750656921601", "1613823243083792385", "1687370014959017986", "1687370619295309826");
+        if (baiMaList.contains(ids)) {
+            return R.fail("该项目合同段不允许删除,请联系管理员");
+        }
         if (wbsTreeContractService.findWbsTreeContract(ids).size() > 0) {
             return R.fail("合同段存在关联的WBS树,删除失败");
         }

+ 70 - 12
blade-service/blade-user/src/main/java/org/springblade/system/user/controller/UserController.java

@@ -35,6 +35,7 @@ import org.apache.http.client.methods.HttpPost;
 import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.message.BasicNameValuePair;
 import org.springblade.common.cache.CacheNames;
+import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.cache.utils.CacheUtil;
 import org.springblade.core.excel.util.ExcelUtil;
 import org.springblade.core.mp.support.Condition;
@@ -49,6 +50,7 @@ import org.springblade.core.tool.constant.BladeConstant;
 import org.springblade.core.tool.constant.RoleConstant;
 import org.springblade.core.tool.utils.*;
 import org.springblade.manager.dto.SaveUserInfoByProjectDTO;
+import org.springblade.manager.entity.ContractInfo;
 import org.springblade.manager.entity.TextdictInfo;
 import org.springblade.manager.entity.WbsTreeContract;
 import org.springblade.manager.entity.WbsTreePrivate;
@@ -63,6 +65,7 @@ import org.springblade.system.user.util.AesInfoUtil;
 import org.springblade.system.user.vo.DeptUserVO;
 import org.springblade.system.user.vo.UserVO;
 import org.springblade.system.user.wrapper.UserWrapper;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.web.bind.annotation.*;
@@ -495,8 +498,8 @@ public class UserController {
     /**
      * 定时同步白马项目用户信息
      */
-    @Scheduled(cron = "0 0 4 * * ?")
-    //@Scheduled(cron = "0 * * * * ?")
+    //@Scheduled(cron = "0 0 4 * * ?")
+    @Scheduled(cron = "0 */5 * * * ?")
     public void syncProjectUserInfo() throws ParseException, IOException {
         JSONObject json = new JSONObject();
         json.put("fn", "all");
@@ -507,37 +510,48 @@ public class UserController {
         String da = AesInfoUtil.sendPost(url, json, encoding);
         if (da != null) {
             JSONObject userInfo = JSONObject.parseObject(da);
-            System.out.println(userInfo);
+            //System.out.println(userInfo);
             int code = userInfo.getInteger("status");
             if (code == 200) {
                 JSONArray list = userInfo.getJSONArray("list");
-
                 if (list != null && list.size() >= 1) {
                     for (int i = 0; i < list.size(); i++) {
                         JSONObject jsonObject = list.getJSONObject(i);
                         String id = jsonObject.getString("id"); //人员唯一编码
                         String account = jsonObject.getString("account"); //账号
-                        String password = jsonObject.getString("password"); //MD5加密后的密码
+                        //String password = jsonObject.getString("password"); //MD5加密后的密码
                         String name = jsonObject.getString("name"); //人员姓名
                         String idCard = jsonObject.getString("idcard"); //身份证号
 
+                        /*这里实际接口返回的数据都是companyName对应的公司名称*/
                         String companyName = jsonObject.getString("companyName"); //公司名称
-                        String constructionCompany = jsonObject.getString("constructionCompany"); //公司名称
-                        String projectName = jsonObject.getString("projectName") + ""; //公司名称
+                        /*String constructionCompany = jsonObject.getString("constructionCompany"); //公司名称
+                        String projectName = jsonObject.getString("projectName") + ""; //公司名称*/
+
                         String status = jsonObject.getString("status"); //状态(1:启用  2:冻结  3:删除)
                         User newUser = new User();
-                        if (projectName.contains("白马项目")
+
+                        /*修改需求前*/
+                        /*if (projectName.contains("白马项目")
                                 || constructionCompany.equals("重庆白马航运发展有限公司")
                                 || constructionCompany.equals("中国水利水电第八工程局有限公司") //二期
                                 || constructionCompany.equals("中国水利水电第四工程局中电建路桥集团联合体")//一期
                                 || companyName.equals("重庆白马航运发展有限公司")//二期一期(业主)
                                 || companyName.equals("中国水利水电第八工程局有限公司")
                                 || companyName.equals("中国水利水电第四工程局中电建路桥集团联合体")
-                        ) {
+                        ) */
+
+                        /*2023年8月4日16:29:14,修改需求,匹配到对应合同段中去*/
+                        if (companyName.contains("重庆白马航运发展有限公司")
+                                || companyName.contains("四川二滩国际工程咨询有限责任公司")
+                                || companyName.contains("中国水利水电第四工程局中电建路桥集团联合体")
+                                || companyName.contains("中铁长江交通设计集团有限公司")
+                                || companyName.contains("中铁八局集团有限公司")) {
                             User sysUser = userService.getOne(Wrappers.<User>lambdaQuery().eq(User::getSysId, id).eq(User::getSysType, 2));
                             if (sysUser != null) {
                                 newUser = sysUser;
                             } else {
+                                newUser.setId(SnowFlakeUtil.getId());
                                 newUser.setDeptId("1588069957940674562"); //白马部门
                                 newUser.setSysType(2);
                                 newUser.setIsDeleted(0);
@@ -548,7 +562,6 @@ public class UserController {
                                 newUser.setUpdateTime(new Date());
                                 newUser.setCreateTime(new Date());
                             }
-
                             newUser.setUserType("1,2");
                             newUser.setAccount(account);
                             newUser.setRealName(name);
@@ -559,12 +572,57 @@ public class UserController {
                             newUser.setIdNumber(idCard);
                             newUser.setCompanyName(companyName);
 
-                            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);
+                            /*2023年8月4日16:29:14,修改需求,匹配到对应合同段中去*/
+                            //所有合同段(白马)
+                            if (companyName.contains("重庆白马航运发展有限公司")) {
+                                List<ContractInfo> contractInfos = jdbcTemplate.query("select id from m_contract_info where p_id = 1612329251049537537 and is_deleted = 0 and status = 1", new BeanPropertyRowMapper<>(ContractInfo.class));
+                                for (ContractInfo contractInfo : contractInfos) {
+                                    Long count = jdbcTemplate.queryForObject("select count(1) from m_project_assignment_user where user_id = " + newUser.getId() + " and project_id = 1612329251049537537 " + " and contract_id = " + contractInfo.getId() + " and post_id is null " + " and status = 1 and is_deleted = 0", Long.class);
+                                    if (count == null || count == 0L) {
+                                        //绑定项目,设置默认角色信息 白马项目id:1612329251049537537;所有合同段id:contractInfo.getId();角色施工-资料员id:1537249581371707394
+                                        saveUserInfoByProjectClient.saveInfoRelation(newUser.getId(), 1612329251049537537L, contractInfo.getId(), 1537249581371707394L);
+                                        newUser.setRoleId("1537249581371707394");
+                                    }
+                                }
+                            }
+
+                            //二期合同段(八局、二滩、长江设计单位)
+                            if (companyName.contains("中铁八局集团有限公司") || companyName.contains("四川二滩国际工程咨询有限责任公司") || companyName.contains("中铁长江交通设计集团有限公司")) {
+                                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");
+                                }
+                            }
+
+                            //一期合同段(四局、长江设计单位)
+                            if (companyName.contains("中国水利水电第四工程局中电建路桥集团联合体") || companyName.contains("中铁长江交通设计集团有限公司")) {
+                                Long count = jdbcTemplate.queryForObject("select count(1) from m_project_assignment_user where user_id = " + newUser.getId() + " and  project_id = 1612329251049537537 and contract_id = 1613022750656921601 and post_id is null and status = 1 and is_deleted = 0", Long.class);
+                                if (count == null || count == 0L) {
+                                    //绑定项目,设置默认角色信息 白马项目id:1612329251049537537;第一期合同段id:1613022750656921601;角色施工-资料员id:1537249581371707394
+                                    saveUserInfoByProjectClient.saveInfoRelation(newUser.getId(), 1612329251049537537L, 1613022750656921601L, 1537249581371707394L);
+                                    newUser.setRoleId("1537249581371707394");
+                                }
+                            }
+
+                            //二监办合同段(二滩)
+                            if (companyName.contains("四川二滩国际工程咨询有限责任公司")) {
+                                Long count = jdbcTemplate.queryForObject("select count(1) from m_project_assignment_user where user_id = " + newUser.getId() + " and  project_id = 1612329251049537537 and contract_id = 1687370619295309826 and post_id is null and status = 1 and is_deleted = 0", Long.class);
+                                if (count == null || count == 0L) {
+                                    //绑定项目,设置默认角色信息 白马项目id:1612329251049537537;二监办合同段id:1687370619295309826;角色施工-资料员id:1537249581371707394
+                                    saveUserInfoByProjectClient.saveInfoRelation(newUser.getId(), 1612329251049537537L, 1687370619295309826L, 1537249581371707394L);
+                                    newUser.setRoleId("1537249581371707394");
+                                }
+                            }
+
+                            /*修改需求前*/
+                            /*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);