Merge branch 'develop_master' of http://101.36.229.190:90/LiuChao/foton-slrs-system-rest into develop_2
Conflicts: adc-da-main/src/main/resources/application-dev.properties
This commit is contained in:
@@ -13,7 +13,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@FeignClient(value = "bat-wkflow")
|
||||
@FeignClient(value = "bat-wkflow-zqazqazqa")
|
||||
public interface workFlowFeignClient {
|
||||
|
||||
@RequestMapping(value = "/bat-wkflow/activiti_define_start_user",method = RequestMethod.GET)
|
||||
|
||||
@@ -15,7 +15,8 @@ public class ActDefineStartMap {
|
||||
|
||||
Map<String,String> map = new TreeMap<>();
|
||||
map.put("1","standardLibraryWkflow");
|
||||
map.put("2","standardSurveyWorkFlow");
|
||||
|
||||
return map.get(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@@ -9,7 +9,7 @@ spring.datasource.password = root
|
||||
|
||||
#==============================================
|
||||
# 应用设置
|
||||
spring.application.name=FotonLAWSSystem
|
||||
spring.application.name=FotonLAWSSystem-zqazqazqa
|
||||
application.code=20200101
|
||||
application.center=1
|
||||
#==============================================
|
||||
@@ -35,11 +35,11 @@ spring.mail.port=587
|
||||
# ==============================================
|
||||
# rabbitMQ
|
||||
# ==============================================
|
||||
#spring.rabbitmq.host=rabbitmq-cluster-01.vs.test.geely.svc
|
||||
#spring.rabbitmq.port=5672
|
||||
#spring.rabbitmq.virtual-host=uat_pcms
|
||||
#spring.rabbitmq.username=uat_pcms
|
||||
#spring.rabbitmq.password=VxsBLL5bJruwzXfS
|
||||
spring.rabbitmq.host=rabbitmq-cluster-01.vs.test.geely.svc
|
||||
spring.rabbitmq.port=5672
|
||||
spring.rabbitmq.virtual-host=uat_pcms
|
||||
spring.rabbitmq.username=uat_pcms
|
||||
spring.rabbitmq.password=VxsBLL5bJruwzXfS
|
||||
# spring.rabbitmq.publisher-confirms=true
|
||||
|
||||
# ==============================================
|
||||
|
||||
@@ -30,14 +30,17 @@ restPath=/api
|
||||
#server.servlet.context-path=/api
|
||||
|
||||
#是否将自己注册到Eureka Server上,默认为true
|
||||
eureka.client.register-with-eureka=false
|
||||
eureka.client.register-with-eureka=true
|
||||
##是否从Eureka Server上获取注册信息,默认为true
|
||||
eureka.client.fetch-registry=false
|
||||
eureka.client.fetch-registry=true
|
||||
|
||||
|
||||
#eureka.client.service-url.defaultZone=http://10.5.116.172:8672/eureka/
|
||||
#eureka.client.service-url.defaultZone=http://127.0.0.1:8671/eureka/
|
||||
#eureka.client.service-url.defaultZone=http://10.5.116.172:8672/eureka/
|
||||
eureka.client.service-url.defaultZone=http://127.0.0.1:8761/eureka/
|
||||
|
||||
eureka.client.service-url.defaultZone=http://192.168.10.47:8761/eureka/
|
||||
|
||||
# 请求连接的超时时间 默认的时间为 1 秒
|
||||
ribbon.ConnectTimeout=500000
|
||||
# 请求处理的超时时间
|
||||
|
||||
@@ -33,6 +33,27 @@
|
||||
<artifactId>adc-da-base</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.json-lib</groupId>
|
||||
<artifactId>json-lib</artifactId>
|
||||
<version>2.4</version>
|
||||
<classifier>jdk15</classifier>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.adc.da.sync.controller;
|
||||
|
||||
import com.adc.da.sync.service.SyncUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/${restPath}/sync")
|
||||
@Api(tags = "数据同步管理")
|
||||
public class TestSyncController {
|
||||
|
||||
@Autowired
|
||||
private SyncUserService syncUserService;
|
||||
|
||||
@ApiOperation(value = "福田IDM用户数据同步")
|
||||
@GetMapping("/syncUser")
|
||||
public void syncUser() throws Exception {
|
||||
syncUserService.syncFotonUser();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "福田IDM组织数据同步")
|
||||
@GetMapping("/syncOrg")
|
||||
public void syncOrg() throws Exception {
|
||||
syncUserService.syncFotonOrg();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.adc.da.sync.service;
|
||||
|
||||
import com.adc.da.sync.util.AuthUtils;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.sf.json.JSONSerializer;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service("syncUserService")
|
||||
@Slf4j
|
||||
public class SyncUserService {
|
||||
|
||||
|
||||
/**
|
||||
* 同步福田IDM数据
|
||||
* @throws Exception
|
||||
*/
|
||||
public void syncFotonUser()throws Exception{
|
||||
String appuser = "wsuser";
|
||||
String appkey = "o1bnrph3pe6i63txm3z5l3cnka2a82pi";
|
||||
AuthUtils util = new AuthUtils(appuser, appkey, null);
|
||||
|
||||
byte[] cookie = null;
|
||||
do {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("cookie", Base64.encodeBase64String(cookie));
|
||||
params.put("timestamp", "20141125065609Z");
|
||||
|
||||
// 用户参数
|
||||
params.put("filter", "(userid=*)");
|
||||
params.put("basedn", "ou=People,o=foton.com.cn,o=isp");
|
||||
System.out.println("RequestBody:" + params.toString());
|
||||
// 用户测试
|
||||
String rs = util.getResponseFromServer("http://172.24.224.42:82/rest/users/getUserList", params);
|
||||
System.err.println(rs);
|
||||
|
||||
JSONObject responseStr = (JSONObject) JSONSerializer.toJSON(rs);
|
||||
|
||||
if (responseStr.containsKey("cookie")) {
|
||||
try {
|
||||
JSONArray entries = responseStr.getJSONArray("cookie");
|
||||
cookie = new byte[entries.size()];
|
||||
for (int i = 0; i < entries.size(); i++) {
|
||||
cookie[i] = (byte) entries.getByte(i);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (e.getMessage().contains("is not a JSONArray")) {
|
||||
cookie = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} while (cookie != null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void syncFotonOrg()throws Exception{
|
||||
String appuser = "wsuser";
|
||||
String appkey = "o1bnrph3pe6i63txm3z5l3cnka2a82pi";
|
||||
AuthUtils util = new AuthUtils(appuser, appkey, null);
|
||||
|
||||
byte[] cookie = null;
|
||||
do {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("cookie", Base64.encodeBase64String(cookie));
|
||||
params.put("timestamp", "20141125065609Z");
|
||||
|
||||
// 组织参数
|
||||
params.put("filter", "(orgNumber=*)");
|
||||
params.put("basedn", "ou=Organizations,o=foton.com.cn,o=isp");
|
||||
// 组织测试
|
||||
String rs = util.getResponseFromServer("http://172.24.224.42:82/rest/orgs/getOrgList", params);
|
||||
System.err.println(rs);
|
||||
|
||||
|
||||
JSONObject responseStr = (JSONObject) JSONSerializer.toJSON(rs);
|
||||
|
||||
if (responseStr.containsKey("cookie")) {
|
||||
try {
|
||||
JSONArray entries = responseStr.getJSONArray("cookie");
|
||||
cookie = new byte[entries.size()];
|
||||
for (int i = 0; i < entries.size(); i++) {
|
||||
cookie[i] = (byte) entries.getByte(i);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (e.getMessage().contains("is not a JSONArray")) {
|
||||
cookie = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} while (cookie != null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.adc.da.sync.util;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.client.utils.HttpClientUtils;
|
||||
import org.apache.http.entity.ByteArrayEntity;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
|
||||
public class AuthUtils {
|
||||
|
||||
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss'Z'");
|
||||
|
||||
private final String appuser;
|
||||
private final String appkey;
|
||||
private final String appinfo;
|
||||
|
||||
public AuthUtils(String appuser, String appkey, String appinfo) {
|
||||
this.appuser = appuser;
|
||||
this.appkey = appkey;
|
||||
this.appinfo = appinfo;
|
||||
}
|
||||
|
||||
public String getResponseFromServer(String url, Map<String, Object> params) throws Exception {
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
createSignHeader(httpPost, params);
|
||||
JSONObject object = JSONObject.fromObject(params);
|
||||
httpPost.setEntity(new ByteArrayEntity(object.toString().getBytes(), ContentType.APPLICATION_JSON));
|
||||
return execute(httpPost);
|
||||
}
|
||||
|
||||
private String execute(HttpUriRequest request) throws Exception {
|
||||
CloseableHttpClient client = null;
|
||||
CloseableHttpResponse resp = null;
|
||||
try {
|
||||
client = HttpClientBuilder.create().build();
|
||||
resp = client.execute(request);
|
||||
return EntityUtils.toString(resp.getEntity());
|
||||
} finally {
|
||||
HttpClientUtils.closeQuietly(resp);
|
||||
HttpClientUtils.closeQuietly(client);
|
||||
}
|
||||
}
|
||||
|
||||
private void createSignHeader(HttpUriRequest request, Map<String, Object> params) throws Exception {
|
||||
request.addHeader("appuser", appuser);
|
||||
|
||||
String randomcode = RandomStringUtils.random(10, true, true);
|
||||
request.addHeader("randomcode", randomcode);
|
||||
|
||||
Calendar now = Calendar.getInstance();
|
||||
String timestamp = sdf.format(now.getTime());
|
||||
request.addHeader("timestamp", timestamp);
|
||||
|
||||
String data = StringUtils.join(appuser, randomcode, timestamp);
|
||||
String encodekey = DigestUtils.sha256Hex(StringUtils.join(data, "{", appkey, "}"));
|
||||
request.addHeader("encodekey", encodekey);
|
||||
|
||||
JSONObject object = JSONObject.fromObject(params);
|
||||
String paramData = StringUtils.join(object.toString(), "&", appkey);
|
||||
String signature = DigestUtils.md5Hex(paramData);
|
||||
request.addHeader("sign", signature);
|
||||
|
||||
request.addHeader("appinfo", appinfo);
|
||||
request.addHeader("Content-Type", "application/json");
|
||||
}
|
||||
}
|
||||
@@ -421,7 +421,7 @@
|
||||
</select>
|
||||
|
||||
<!-- 根据角色ID获取所有用户 -->
|
||||
<select id="get" resultMap="BaseResultMap" parameterType="java.lang.Integer">
|
||||
<select id="get" resultMap="BaseResultMap" parameterType="java.lang.String">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from TS_USER u
|
||||
|
||||
Reference in New Issue
Block a user