|
@@ -0,0 +1,478 @@
|
|
|
+package org.springblade.system.user.thirdparty;
|
|
|
+
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.http.Consts;
|
|
|
+import org.apache.http.HttpResponse;
|
|
|
+import org.apache.http.NameValuePair;
|
|
|
+import org.apache.http.client.HttpClient;
|
|
|
+import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
|
+import org.apache.http.client.methods.HttpPost;
|
|
|
+import org.apache.http.impl.client.HttpClientBuilder;
|
|
|
+import org.apache.http.message.BasicNameValuePair;
|
|
|
+import org.springblade.common.constant.CommonConstant;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.DigestUtil;
|
|
|
+import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
+import org.springblade.manager.entity.ContractInfo;
|
|
|
+import org.springblade.manager.feign.SaveUserInfoByProjectClient;
|
|
|
+import org.springblade.system.entity.AuthClient;
|
|
|
+import org.springblade.system.user.bean.GetBMTokenDTO;
|
|
|
+import org.springblade.system.user.bean.GetTokenDTO;
|
|
|
+import org.springblade.system.user.entity.User;
|
|
|
+import org.springblade.system.user.service.IUserService;
|
|
|
+import org.springblade.system.user.util.AesInfoUtil;
|
|
|
+import org.springblade.system.user.util.HttpClientUtil;
|
|
|
+import org.springblade.system.user.util.RsaUtilToken;
|
|
|
+import org.springblade.system.user.util.RsaUtils;
|
|
|
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
+
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.time.Duration;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 白马三方接口相关
|
|
|
+ *
|
|
|
+ * @author liuyc
|
|
|
+ * @date 2023年11月14日15:15:42
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@AllArgsConstructor
|
|
|
+@RequestMapping("/bm")
|
|
|
+public class ThirdPartySystemApi {
|
|
|
+
|
|
|
+ private final JdbcTemplate jdbcTemplate;
|
|
|
+ private final RedisTemplate<String, String> redisTemplate;
|
|
|
+ private final IUserService userService;
|
|
|
+ private final SaveUserInfoByProjectClient saveUserInfoByProjectClient;
|
|
|
+
|
|
|
+ /*白马相关常量*/
|
|
|
+ private final static String IP_PORT = "http://219.152.86.38:13427";
|
|
|
+ private final static String PK_URL = IP_PORT + "/prod-api/auth/touch";
|
|
|
+ private final static String TOKEN_URL = IP_PORT + "/prod-api/auth/login";
|
|
|
+ private final static String USER_LIST_URL = IP_PORT + "/prod-api/openapi/biz-v1/user/list";
|
|
|
+ private final static String USERNAME = "白马质检";
|
|
|
+ private final static String PASSWORD = "Bmzj@654321";
|
|
|
+ private final static String SOURCE = "HongChuangBm";
|
|
|
+ private final static String APP_KEY = "9F3C78FC22D07EAB2AEB4DD6CA9644DB";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据appKey获取本系统的公钥信息
|
|
|
+ *
|
|
|
+ * @param appKey = blade_client id
|
|
|
+ */
|
|
|
+ @GetMapping("/auth/public-key")
|
|
|
+ public Map<String, Object> getPublicKey(@RequestParam String appKey) {
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ if (StringUtils.isEmpty(appKey)) {
|
|
|
+ resultMap.put("uuid", null);
|
|
|
+ resultMap.put("pk", null);
|
|
|
+ resultMap.put("code", 500);
|
|
|
+ resultMap.put("msg", "param cannot be null");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*Redis加锁,10秒过期*/
|
|
|
+ String lockRedisKey = "bm-secret-key-request-limit:" + appKey;
|
|
|
+ Long currentTime = System.currentTimeMillis();
|
|
|
+ Boolean isAbsent = redisTemplate.opsForValue().setIfAbsent(lockRedisKey, String.valueOf(currentTime), Duration.ofSeconds(10));
|
|
|
+
|
|
|
+ if (isAbsent != null && isAbsent) {
|
|
|
+ if (!isValidAppKey(appKey)) {
|
|
|
+ resultMap.put("uuid", null);
|
|
|
+ resultMap.put("pk", null);
|
|
|
+ resultMap.put("code", 500);
|
|
|
+ resultMap.put("msg", "appKey authentication failed");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*创建秘钥对*/
|
|
|
+ Map<String, String> keyPair = RsaUtils.createKeyPair();
|
|
|
+ String pk = keyPair.get("pk");
|
|
|
+ String sk = keyPair.get("sk");
|
|
|
+ Long uuid = SnowFlakeUtil.getId();
|
|
|
+
|
|
|
+ try {
|
|
|
+ /*存储到Redis,2分钟过期*/
|
|
|
+ String redisKey = "bm-secret-key:" + uuid;
|
|
|
+ redisTemplate.opsForValue().set(redisKey + ":pk", pk, 2, TimeUnit.MINUTES);
|
|
|
+ redisTemplate.opsForValue().set(redisKey + ":sk", sk, 2, TimeUnit.MINUTES);
|
|
|
+
|
|
|
+ resultMap.put("uuid", uuid);
|
|
|
+ resultMap.put("pk", pk);
|
|
|
+ resultMap.put("code", 200);
|
|
|
+ resultMap.put("msg", "操作成功");
|
|
|
+ return resultMap;
|
|
|
+ } catch (Exception e) {
|
|
|
+ resultMap.put("uuid", null);
|
|
|
+ resultMap.put("pk", null);
|
|
|
+ resultMap.put("code", 500);
|
|
|
+ resultMap.put("msg", e.getMessage());
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ resultMap.put("uuid", null);
|
|
|
+ resultMap.put("pk", null);
|
|
|
+ resultMap.put("code", 500);
|
|
|
+ resultMap.put("msg", "try again in 10 seconds");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isValidAppKey(String appKey) {
|
|
|
+ List<AuthClient> bladeClients = jdbcTemplate.query(
|
|
|
+ "SELECT (1) FROM blade_client WHERE id = ? AND status = 1 AND is_deleted = 0",
|
|
|
+ new Object[]{appKey},
|
|
|
+ new BeanPropertyRowMapper<>(AuthClient.class)
|
|
|
+ );
|
|
|
+ return !bladeClients.isEmpty();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据idcard获取本系统的token信息
|
|
|
+ *
|
|
|
+ * @param dto
|
|
|
+ */
|
|
|
+ @PostMapping("/auth/token")
|
|
|
+ public R<Object> getToken(@RequestBody GetTokenDTO dto) {
|
|
|
+ if (dto.getUuid().isEmpty() || dto.getIdcard().isEmpty()) {
|
|
|
+ throw new ServiceException("入参不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ /*从Redis中获取私钥*/
|
|
|
+ String redisKey = "bm-secret-key:" + dto.getUuid();
|
|
|
+ String privateKey = redisTemplate.opsForValue().get(redisKey + ":sk");
|
|
|
+
|
|
|
+ if (privateKey != null) {
|
|
|
+ /*解密入参密钥对获取身份证信息*/
|
|
|
+ String decryptedIdCard = RsaUtils.decryptWithSk(dto.getIdcard(), privateKey);
|
|
|
+
|
|
|
+ /*根据身份证获取用户token*/
|
|
|
+ if (StringUtils.isNotEmpty(decryptedIdCard)) {
|
|
|
+ List<User> users = jdbcTemplate.query(
|
|
|
+ "SELECT account, plaintext_password FROM blade_user WHERE is_deleted = 0 AND status = 1 AND id_number = ?",
|
|
|
+ new Object[]{decryptedIdCard},
|
|
|
+ new BeanPropertyRowMapper<>(User.class)
|
|
|
+ );
|
|
|
+
|
|
|
+ if (users.size() > 0 && users.size() != 1) {
|
|
|
+ throw new ServiceException("获取用户信息异常");
|
|
|
+ } else if (users.size() == 1) {
|
|
|
+ User user = users.get(0);
|
|
|
+ HttpClient httpClient = HttpClientBuilder.create().build();
|
|
|
+ HttpPost httpPost = new HttpPost("http://127.0.0.1:8090/blade-auth/oauth/token");
|
|
|
+ httpPost.setHeader("Authorization", "Basic Y2xpZW50OmNsaWVudF9zZWNyZXQ=");
|
|
|
+ httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
|
+ httpPost.setHeader("Tenant-Id", "000000");
|
|
|
+ List<NameValuePair> params = new ArrayList<NameValuePair>();
|
|
|
+ params.add(new BasicNameValuePair("grant_type", "password"));
|
|
|
+ params.add(new BasicNameValuePair("username", user.getAccount()));
|
|
|
+
|
|
|
+ /*密码加密*/
|
|
|
+ String plaintextPassword = user.getPlaintextPassword();
|
|
|
+ String hex = DigestUtil.md5Hex(plaintextPassword);
|
|
|
+
|
|
|
+ params.add(new BasicNameValuePair("password", hex));
|
|
|
+ params.add(new BasicNameValuePair("scope", "all"));
|
|
|
+ params.add(new BasicNameValuePair("tenantId", "000000"));
|
|
|
+ httpPost.setEntity(new UrlEncodedFormEntity(params, Consts.UTF_8));
|
|
|
+
|
|
|
+ try {
|
|
|
+ HttpResponse httpResponse = httpClient.execute(httpPost);
|
|
|
+ InputStream inputStream = httpResponse.getEntity().getContent();
|
|
|
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
|
+ byte[] buffer = new byte[1024];
|
|
|
+ int index;
|
|
|
+ while ((index = inputStream.read(buffer)) != -1) {
|
|
|
+ outputStream.write(buffer, 0, index);
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject jsonObject = JSON.parseObject(outputStream.toString());
|
|
|
+ Object accessToken = jsonObject.get("access_token");
|
|
|
+ if (accessToken != null) {
|
|
|
+ Object expiresIn = jsonObject.get("expires_in");
|
|
|
+ int minutes = 0;
|
|
|
+ if (expiresIn instanceof Integer) {
|
|
|
+ int seconds = (Integer) expiresIn;
|
|
|
+ minutes = seconds / 60;
|
|
|
+ }
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("access_token", accessToken);
|
|
|
+ resultMap.put("expires_in", minutes);
|
|
|
+ return R.data(200, resultMap, "操作成功");
|
|
|
+
|
|
|
+ } else {
|
|
|
+ return R.data(400, null, "解析异常,token为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return R.data(500, null, e.getMessage());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return R.data(400, null, "未获取到对应的用户信息");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(451, null, "未获取到对应的私钥信息");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /*public static void main(String[] args) {
|
|
|
+ //公钥
|
|
|
+ String pk = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJnZ0kMi0AG9sR97sdRD0/kqX9a7kSsVM56DUwmEbxf9n5SW0aRwxYcoyZQUC7ZW2MrXSNbzwbtmdD0RfQ4TJI0CAwEAAQ==";
|
|
|
+
|
|
|
+ //字符串
|
|
|
+ String idcard = "100136199809011400";
|
|
|
+
|
|
|
+ //使用公钥加密
|
|
|
+ String encryptedIdCard = RsaUtils.encryptWithPk(idcard, pk);
|
|
|
+
|
|
|
+ System.out.println("Encrypted Id Card: " + encryptedIdCard);
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取白马系统token
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static R<Object> getBMToken() {
|
|
|
+ /*获取uuid与公钥*/
|
|
|
+ Map<String, String> param = new HashMap<>();
|
|
|
+ param.put("appKey", APP_KEY);
|
|
|
+ String pkAndUuid = HttpClientUtil.doGet(PK_URL, param);
|
|
|
+ JSONObject jsonObject = JSON.parseObject(pkAndUuid);
|
|
|
+ String pk = jsonObject.getString("pk");
|
|
|
+ String uuid = jsonObject.getString("uuid");
|
|
|
+ String code = jsonObject.getString("code");
|
|
|
+ /*获取token*/
|
|
|
+ if (StringUtils.isNotEmpty(pk) && StringUtils.isNotEmpty(uuid) && ("200").equals(code)) {
|
|
|
+ String username = RsaUtilToken.encryptWithPk(USERNAME, pk);
|
|
|
+ String password = RsaUtilToken.encryptWithPk(PASSWORD, pk);
|
|
|
+ //移除换行符
|
|
|
+ String usernameRe = username.replaceAll("\\r|\\n", "");
|
|
|
+ String passwordRe = password.replaceAll("\\r|\\n", "");
|
|
|
+
|
|
|
+ String result = HttpClientUtil.doPostJson(TOKEN_URL, JSON.toJSONString(new GetBMTokenDTO(uuid, usernameRe, passwordRe, SOURCE)));
|
|
|
+ return R.data(result);
|
|
|
+ } else {
|
|
|
+ return R.data(jsonObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /*public static void main(String[] args) {
|
|
|
+ *//*Object data = getBMToken().getData();
|
|
|
+ System.out.println(data);*//*
|
|
|
+
|
|
|
+ syncBMUserInfosToSystemProject();
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 同步白马用户信息到系统项目中
|
|
|
+ */
|
|
|
+ /*@Scheduled(cron = "0 0 4 * * ?")*/
|
|
|
+ @PostMapping("/auth/test666")
|
|
|
+ public void syncBMUserInfosToSystemProject() {
|
|
|
+ /*获取token*/
|
|
|
+ Object dataR = getBMToken().getData();
|
|
|
+ JSONObject jsonObject = JSON.parseObject(String.valueOf(dataR));
|
|
|
+ String code = jsonObject.getString("code");
|
|
|
+ String dataToken = jsonObject.getString("data");
|
|
|
+ JSONObject jsonObjectToken = JSON.parseObject(dataToken);
|
|
|
+ String token = jsonObjectToken.getString("access_token");
|
|
|
+
|
|
|
+ if (("200").equals(code) && StringUtils.isNotEmpty(token)) {
|
|
|
+ /*获取白马公司ids*/
|
|
|
+ //String bmCompanyIds = CommonConstant.BM_COMPANY_IDS;
|
|
|
+
|
|
|
+ /*测试公司id*/
|
|
|
+ String bmCompanyIds = "1722072427562467328";
|
|
|
+
|
|
|
+ String[] bmCompanyIdsArr = bmCompanyIds.split(",");
|
|
|
+ for (String companyId : bmCompanyIdsArr) {
|
|
|
+ /*获取用户信息*/
|
|
|
+ Map<String, String> param = new HashMap<>();
|
|
|
+ param.put("pid", companyId);
|
|
|
+ String responseData = HttpClientUtil.doGet(USER_LIST_URL, param, token);
|
|
|
+
|
|
|
+ /*解析响应数据*/
|
|
|
+ JSONObject jsonObjectResponse = JSONObject.parseObject(responseData);
|
|
|
+ String responseStringCode = jsonObjectResponse.getString("code");
|
|
|
+ if (("200").equals(responseStringCode)) {
|
|
|
+ JSONArray userList = jsonObjectResponse.getJSONArray("data");
|
|
|
+ if (userList != null && userList.size() >= 1) {
|
|
|
+ for (int i = 0; i < userList.size(); i++) {
|
|
|
+ JSONObject jsonUser = userList.getJSONObject(i);
|
|
|
+ String userid = jsonUser.getString("userid");
|
|
|
+ //String username = jsonUser.getString("username");
|
|
|
+ String nickname = jsonUser.getString("nickname");
|
|
|
+ String idCard = jsonUser.getString("idcard");
|
|
|
+ String phone = jsonUser.getString("phonenumber");
|
|
|
+ String status = jsonUser.getString("status");
|
|
|
+
|
|
|
+ JSONArray companies = jsonUser.getJSONArray("companies");
|
|
|
+ if (companies != null && companies.size() >= 1) {
|
|
|
+ for (int j = 0; j < companies.size(); j++) {
|
|
|
+ JSONObject companiesJSONObject = companies.getJSONObject(j);
|
|
|
+ //String companiesId = companiesJSONObject.getString("id");
|
|
|
+ String companyName = companiesJSONObject.getString("name");
|
|
|
+
|
|
|
+ if (companyName.contains("重庆白马航运发展有限公司")
|
|
|
+ || companyName.contains("四川二滩国际工程咨询有限责任公司")
|
|
|
+ || companyName.contains("中国水利水电第四工程局中电建路桥集团联合体")
|
|
|
+ || companyName.contains("中国水利水电第八工程局有限公司")
|
|
|
+ || companyName.contains("重庆市交通工程监理咨询有限责任公司")
|
|
|
+ || companyName.contains("中铁长江交通设计集团有限公司")
|
|
|
+ || companyName.contains("中铁八局集团有限公司")) {
|
|
|
+ List<User> sysUser = userService.getBaseMapper().selectList(Wrappers.<User>lambdaQuery().eq(User::getSysType, 2).apply("(sys_id = '" + userid + "' OR id_number = '" + idCard + "')"));
|
|
|
+
|
|
|
+ /*修改电话号码*/
|
|
|
+ if (sysUser.size() > 0 && ObjectUtil.isNotEmpty(phone) && phone.length() == 11) {
|
|
|
+ for (User user : sysUser) {
|
|
|
+ if (ObjectUtil.isEmpty(user.getPhone())) {
|
|
|
+ userService.lambdaUpdate()
|
|
|
+ .set(User::getPhone, phone)
|
|
|
+ .eq(User::getId, user.getId())
|
|
|
+ .update();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*只有本系统不存在时才去新增*/
|
|
|
+ if (sysUser.size() == 0L) {
|
|
|
+ User newUser = new User();
|
|
|
+ newUser.setId(SnowFlakeUtil.getId());
|
|
|
+ newUser.setDeptId("1588069957940674562"); //白马部门
|
|
|
+
|
|
|
+ newUser.setSysType(9); //之前=2是表示同步,现在由于修改了接口,改为9,以便处理数据
|
|
|
+
|
|
|
+ newUser.setIsDeleted(0);
|
|
|
+ newUser.setCreateUser(Long.parseLong("1541381503819694081"));
|
|
|
+ newUser.setUpdateUser(Long.parseLong("1541381503819694081"));
|
|
|
+ newUser.setTenantId("000000");
|
|
|
+ newUser.setSysId(userid);
|
|
|
+ newUser.setUpdateTime(new Date());
|
|
|
+ newUser.setCreateTime(new Date());
|
|
|
+ newUser.setUserType("1,2");
|
|
|
+ newUser.setAccount(idCard);
|
|
|
+ newUser.setRealName(nickname);
|
|
|
+ newUser.setName(nickname);
|
|
|
+ newUser.setPassword("10470c3b4b1fed12c3baac014be15fac67c6e815");
|
|
|
+ newUser.setPlaintextPassword("123456");
|
|
|
+ newUser.setName(nickname);
|
|
|
+ newUser.setStatus(Integer.parseInt(status));
|
|
|
+ newUser.setIdNumber(idCard);
|
|
|
+ newUser.setCompanyName(companyName);
|
|
|
+ newUser.setPhone(ObjectUtil.isNotEmpty(phone) && phone.length() == 11 ? phone : null);
|
|
|
+
|
|
|
+ /*所有合同段(白马)*/
|
|
|
+ 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("中铁长江交通设计集团有限公司") || 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");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*一监办合同段(重庆市交通工程监理咨询有限责任公司)*/
|
|
|
+ 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 = 1687370014959017986 and post_id is null and status = 1 and is_deleted = 0", Long.class);
|
|
|
+ if (count == null || count == 0L) {
|
|
|
+ /*绑定项目,设置默认角色信息 白马项目id:1612329251049537537;一监办合同段id:1687370014959017986;角色施工-资料员id:1537249581371707394*/
|
|
|
+ saveUserInfoByProjectClient.saveInfoRelation(newUser.getId(), 1612329251049537537L, 1687370014959017986L, 1537249581371707394L);
|
|
|
+ newUser.setRoleId("1537249581371707394");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*入库*/
|
|
|
+ userService.save(newUser);
|
|
|
+ userService.submitUserDept(newUser);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*JSONArray projects = jsonUser.getJSONArray("projects");
|
|
|
+ if (projects != null && projects.size() >= 1) {
|
|
|
+ for (int k = 0; k < projects.size(); k++) {
|
|
|
+ JSONObject projectsJSONObject = projects.getJSONObject(k);
|
|
|
+ String projectId = projectsJSONObject.getString("projectid");
|
|
|
+ String projectName = projectsJSONObject.getString("projectname");
|
|
|
+ String subprojectId = projectsJSONObject.getString("subprojectid");
|
|
|
+ String subprojectName = projectsJSONObject.getString("subprojectname");
|
|
|
+ String contractId = projectsJSONObject.getString("contractid");
|
|
|
+ String contractName = projectsJSONObject.getString("contractname");
|
|
|
+ String sectionId = projectsJSONObject.getString("sectionid");
|
|
|
+ String sectionName = projectsJSONObject.getString("sectionname");
|
|
|
+
|
|
|
+ //TODO
|
|
|
+
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|