add:添加日志输出,修改部门同步请求的参数:时间戳

This commit is contained in:
wxyclub
2023-07-20 17:45:41 +08:00
parent 9320f2bfc5
commit bce2d3dc56
4 changed files with 26 additions and 13 deletions
@@ -532,14 +532,15 @@ public class DataSyncServiceImpl implements IDataSyncService {
tsInstitutionService.updateBatchById(updateTsInstitutionList); tsInstitutionService.updateBatchById(updateTsInstitutionList);
} }
//需要删除的数据 //需要删除的数据
if(!delTsInstitutionList.isEmpty()){ // 先行注释,会删除所有部门
logger.debug("本次删除的组织机构为:"+JSONObject.toJSONString(delTsInstitutionList)); // if(!delTsInstitutionList.isEmpty()){
List<String> delIdList = new ArrayList<>(); // logger.debug("本次删除的组织机构为:"+JSONObject.toJSONString(delTsInstitutionList));
for(TsInstitution data : delTsInstitutionList){ // List<String> delIdList = new ArrayList<>();
delIdList.add(data.getId()); // for(TsInstitution data : delTsInstitutionList){
} // delIdList.add(data.getId());
tsInstitutionService.removeByIds(delIdList); // }
} // tsInstitutionService.removeByIds(delIdList);
// }
//全部部门 //全部部门
List<TsInstitution> allTsInstitutionListForPids = new ArrayList<>(addTsInstitutionList); List<TsInstitution> allTsInstitutionListForPids = new ArrayList<>(addTsInstitutionList);
allTsInstitutionListForPids.addAll(updateTsInstitutionList); allTsInstitutionListForPids.addAll(updateTsInstitutionList);
@@ -5021,6 +5021,7 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
QueryWrapper<SarBussStandFile> objectQueryWrapper = new QueryWrapper<>(); QueryWrapper<SarBussStandFile> objectQueryWrapper = new QueryWrapper<>();
objectQueryWrapper.eq("ORI_ATT_ID",fileId); objectQueryWrapper.eq("ORI_ATT_ID",fileId);
objectQueryWrapper.eq("USE_MODEL","SOURCE_FILE"); objectQueryWrapper.eq("USE_MODEL","SOURCE_FILE");
objectQueryWrapper.eq("VALID_FLAG","0");
//objectQueryWrapper.ne("FILE_SUFFIX","docx"); //objectQueryWrapper.ne("FILE_SUFFIX","docx");
List<SarBussStandFile> sarBussStandFiles = sarBussStandFileEODao.selectList(objectQueryWrapper); List<SarBussStandFile> sarBussStandFiles = sarBussStandFileEODao.selectList(objectQueryWrapper);
if(!sarBussStandFiles.isEmpty()) { if(!sarBussStandFiles.isEmpty()) {
@@ -10,10 +10,8 @@ import net.sf.json.JSONSerializer;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.text.SimpleDateFormat;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.Map;
@Service("syncUserService") @Service("syncUserService")
@Slf4j @Slf4j
@@ -121,6 +119,7 @@ public class SyncUserService {
public List<String> syncFotonOrg()throws Exception{ public List<String> syncFotonOrg()throws Exception{
String appuser = "app_slrs"; String appuser = "app_slrs";
String appkey = "Fxi5LHbI5yGbQQDpVp86GcCdXeC5Bjfe"; String appkey = "Fxi5LHbI5yGbQQDpVp86GcCdXeC5Bjfe";
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss'Z'");
AuthUtils util = new AuthUtils(appuser, appkey, null); AuthUtils util = new AuthUtils(appuser, appkey, null);
byte[] cookie = null; byte[] cookie = null;
@@ -128,7 +127,10 @@ public class SyncUserService {
do { do {
Map<String, Object> params = new HashMap<String, Object>(); Map<String, Object> params = new HashMap<String, Object>();
params.put("cookie", Base64.encodeBase64String(cookie)); params.put("cookie", Base64.encodeBase64String(cookie));
params.put("timestamp", System.currentTimeMillis()); // params.put("timestamp", System.currentTimeMillis());
Calendar calendar = Calendar.getInstance();
String timestamp = sdf.format(calendar.getTime());
params.put("timestamp", timestamp);
// 组织参数 // 组织参数
params.put("filter", "(orgNumber=*)"); params.put("filter", "(orgNumber=*)");
@@ -4,6 +4,7 @@ import net.sf.json.JSONObject;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.Header;
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.client.methods.HttpUriRequest;
@@ -13,12 +14,15 @@ import org.apache.http.entity.ContentType;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Map; import java.util.Map;
public class AuthUtils { public class AuthUtils {
Logger logger = LoggerFactory.getLogger(AuthUtils.class);
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss'Z'"); private static SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss'Z'");
@@ -36,6 +40,7 @@ public class AuthUtils {
HttpPost httpPost = new HttpPost(url); HttpPost httpPost = new HttpPost(url);
createSignHeader(httpPost, params); createSignHeader(httpPost, params);
JSONObject object = JSONObject.fromObject(params); JSONObject object = JSONObject.fromObject(params);
params.forEach((key,value) -> logger.info("请求参数:{}{}",key,value));
httpPost.setEntity(new ByteArrayEntity(object.toString().getBytes(), ContentType.APPLICATION_JSON)); httpPost.setEntity(new ByteArrayEntity(object.toString().getBytes(), ContentType.APPLICATION_JSON));
return execute(httpPost); return execute(httpPost);
} }
@@ -45,6 +50,10 @@ public class AuthUtils {
CloseableHttpResponse resp = null; CloseableHttpResponse resp = null;
try { try {
client = HttpClientBuilder.create().build(); client = HttpClientBuilder.create().build();
logger.info("请求地址:"+request.getURI().toString());
for (Header header : request.getAllHeaders()) {
logger.info("请求头:"+header.toString());
}
resp = client.execute(request); resp = client.execute(request);
return EntityUtils.toString(resp.getEntity()); return EntityUtils.toString(resp.getEntity());
} finally { } finally {