|
@@ -72,6 +72,7 @@ import javax.validation.Valid;
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLDecoder;
|
|
|
import java.text.ParseException;
|
|
|
import java.util.*;
|
|
@@ -433,7 +434,7 @@ public class UserController {
|
|
|
}
|
|
|
|
|
|
//解析tokne
|
|
|
- String tokenInfo = AesInfoUtil.decrypt(URLDecoder.decode(token), null);
|
|
|
+ String tokenInfo = AesInfoUtil.decrypt(token, null);
|
|
|
if (tokenInfo != null && tokenInfo.length() >= 20) {
|
|
|
JSONObject tokenUser = JSON.parseObject(tokenInfo);
|
|
|
String tokenPw = tokenUser.getString("password");
|
|
@@ -446,24 +447,26 @@ 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) {
|
|
|
return R.fail("用户名或密码错误");
|
|
|
}
|
|
|
//获取用户list
|
|
|
HttpClient httpClient = HttpClientBuilder.create().build();
|
|
|
- HttpPost httpPost = new HttpPost("http://testmanger.hcxxy.com/api/blade-auth/oauth/token");
|
|
|
- httpPost.setHeader("Authorization", "Basic c2FiZXI6c2FiZXJfc2VjcmV0");
|
|
|
+ HttpPost httpPost = new HttpPost("http://localhost:8090/blade-auth/oauth/token");
|
|
|
+ httpPost.setHeader("Authorization", "Basic Y2xpZW50OmNsaWVudF9zZWNyZXQ="); //这个需要 client:
|
|
|
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", userInfo.getAccount()));
|
|
|
- params.add(new BasicNameValuePair("password", userInfo.getPassword()));
|
|
|
+ params.add(new BasicNameValuePair("password", "e10adc3949ba59abbe56e057f20f883e"));
|
|
|
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();
|
|
@@ -473,6 +476,7 @@ public class UserController {
|
|
|
while ((index = inputStream.read(buffer)) != -1) {
|
|
|
outputStream.write(buffer, 0, index);
|
|
|
}
|
|
|
+ System.out.println(JSON.parseObject(outputStream.toString()));
|
|
|
return R.data(JSON.parseObject(outputStream.toString()));
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
@@ -487,19 +491,11 @@ public class UserController {
|
|
|
* 定时同步白马项目用户信息
|
|
|
*/
|
|
|
@Scheduled(cron = "0 0 4 * * ?")
|
|
|
+ //@Scheduled(cron = "0 */5 * * * ?")
|
|
|
public void syncProjectUserInfo() throws ParseException, IOException {
|
|
|
- List<User> userList = userService.list(Wrappers.<User>lambdaQuery().in(User::getSysType, 2));
|
|
|
JSONObject json = new JSONObject();
|
|
|
+ json.put("fn", "all");
|
|
|
|
|
|
- if (userList != null && !userList.isEmpty()) {
|
|
|
- Date maxTime = userList.stream().max(Comparator.comparing(User::getUpdateTime)).get().getUpdateTime();
|
|
|
- json.put("fn", "time");
|
|
|
- json.put("timestamp", maxTime.getTime());
|
|
|
- //System.out.println("1670255453504");
|
|
|
- //System.out.println(maxTime.getTime());
|
|
|
- } else {
|
|
|
- json.put("fn", "all");
|
|
|
- }
|
|
|
// 测试数据
|
|
|
String url = "http://js.cegc.com.cn:13426/login/japi/synUser";
|
|
|
String encoding = "utf-8";
|
|
@@ -518,26 +514,29 @@ public class UserController {
|
|
|
String password = jsonObject.getString("password"); //MD5加密后的密码
|
|
|
String name = jsonObject.getString("name"); //人员姓名
|
|
|
String idCard = jsonObject.getString("idcard"); //身份证号
|
|
|
- //String salt = jsonObject.getString("salt"); //md5密码盐
|
|
|
- //String factDeptName = jsonObject.getString("factDeptName"); //部门名称
|
|
|
+
|
|
|
String companyName = jsonObject.getString("companyName"); //公司名称
|
|
|
- //String updateTime = jsonObject.getString("updateTime"); //更新时间
|
|
|
+ String constructionCompany = jsonObject.getString("constructionCompany"); //公司名称
|
|
|
+ String projectName = jsonObject.getString("projectName") + ""; //公司名称
|
|
|
String status = jsonObject.getString("status"); //状态(1:启用 2:冻结 3:删除)
|
|
|
User newUser = new User();
|
|
|
- User sysUser = userService.getOne(Wrappers.<User>lambdaQuery().eq(User::getSysId, id).eq(User::getSysType, 2));
|
|
|
- if (sysUser != null) {
|
|
|
- newUser = sysUser;
|
|
|
- } else {
|
|
|
- newUser.setDeptId("1588069957940674562"); //白马部门
|
|
|
- newUser.setSysType(2);
|
|
|
- newUser.setIsDeleted(0);
|
|
|
- newUser.setCreateUser(Long.parseLong("1541381503819694081"));
|
|
|
- newUser.setUpdateUser(Long.parseLong("1541381503819694081"));
|
|
|
- newUser.setTenantId("000000");
|
|
|
- newUser.setSysId(id);
|
|
|
- }
|
|
|
- if (companyName.contains("白马")) {
|
|
|
- newUser.setUserType(1);
|
|
|
+ if(projectName.indexOf("白马项目") >= 0 || constructionCompany.equals("重庆白马航运发展有限公司") || companyName.equals("重庆白马航运发展有限公司")) {
|
|
|
+ User sysUser = userService.getOne(Wrappers.<User>lambdaQuery().eq(User::getSysId, id).eq(User::getSysType, 2));
|
|
|
+ if (sysUser != null) {
|
|
|
+ newUser = sysUser;
|
|
|
+ } else {
|
|
|
+ newUser.setDeptId("1588069957940674562"); //白马部门
|
|
|
+ newUser.setSysType(2);
|
|
|
+ newUser.setIsDeleted(0);
|
|
|
+ newUser.setCreateUser(Long.parseLong("1541381503819694081"));
|
|
|
+ newUser.setUpdateUser(Long.parseLong("1541381503819694081"));
|
|
|
+ newUser.setTenantId("000000");
|
|
|
+ newUser.setSysId(id);
|
|
|
+ newUser.setUpdateTime(new Date());
|
|
|
+ newUser.setCreateTime(new Date());
|
|
|
+ }
|
|
|
+
|
|
|
+ newUser.setUserType(2);
|
|
|
newUser.setAccount(account);
|
|
|
newUser.setRealName(name);
|
|
|
newUser.setName(name);
|
|
@@ -545,11 +544,10 @@ public class UserController {
|
|
|
newUser.setName(name);
|
|
|
newUser.setStatus(Integer.parseInt(status));
|
|
|
newUser.setIdNumber(idCard);
|
|
|
- newUser.setUpdateTime(new Date());
|
|
|
- newUser.setCreateTime(new Date());
|
|
|
newUser.setCompanyName(companyName);
|
|
|
newUser.setRoleId("1537249581371707394"); //角色施工-资料员id:1537249581371707394
|
|
|
- userService.submit(newUser);
|
|
|
+ userService.saveOrUpdate(newUser);
|
|
|
+ userService.submitUserDept(newUser);
|
|
|
|
|
|
//绑定项目,设置默认角色信息 白马项目id:1578599210897772545;第二期合同段id:1579773037233184770;角色施工-资料员id:1537249581371707394
|
|
|
saveUserInfoByProjectClient.saveInfoRelation(newUser.getId(), 1578599210897772545L, 1579773037233184770L, 1537249581371707394L);
|
|
@@ -560,6 +558,4 @@ public class UserController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|