Merge branch 'fix_foton_20230613' into 'master'
Fix foton 20230613 See merge request laws-foton-slrs/foton-slrs-system-rest!122
This commit is contained in:
@@ -50,7 +50,7 @@ public class DataSyncController {
|
|||||||
@ApiOperation("同步组织机构")
|
@ApiOperation("同步组织机构")
|
||||||
@PostMapping("/importOrgData")
|
@PostMapping("/importOrgData")
|
||||||
public String importOrgData() throws Exception {
|
public String importOrgData() throws Exception {
|
||||||
return iDataSyncService.orgDataSync();
|
return iDataSyncService.orgDataSync2();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("同步组织机构,添加参数")
|
@ApiOperation("同步组织机构,添加参数")
|
||||||
|
|||||||
@@ -8,8 +8,10 @@ public interface IDataSyncService {
|
|||||||
public String dataSync();
|
public String dataSync();
|
||||||
|
|
||||||
public String dataSync2(Long chuo);
|
public String dataSync2(Long chuo);
|
||||||
|
// 定时增量同步
|
||||||
public String orgDataSync();
|
public String orgDataSync();
|
||||||
|
// 手动全量同步
|
||||||
|
public String orgDataSync2();
|
||||||
|
|
||||||
public String updateByOrgs();
|
public String updateByOrgs();
|
||||||
}
|
}
|
||||||
|
|||||||
+95
-2
@@ -469,7 +469,7 @@ public class DataSyncServiceImpl implements IDataSyncService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 增量同步部门数据
|
||||||
@Transactional(rollbackFor = {RuntimeException.class,Exception.class})
|
@Transactional(rollbackFor = {RuntimeException.class,Exception.class})
|
||||||
public String orgDataSync(){
|
public String orgDataSync(){
|
||||||
try{
|
try{
|
||||||
@@ -532,7 +532,7 @@ public class DataSyncServiceImpl implements IDataSyncService {
|
|||||||
tsInstitutionService.updateBatchById(updateTsInstitutionList);
|
tsInstitutionService.updateBatchById(updateTsInstitutionList);
|
||||||
}
|
}
|
||||||
//需要删除的数据
|
//需要删除的数据
|
||||||
// 先行注释,会删除所有部门
|
// 增量同步,不作删除
|
||||||
// if(!delTsInstitutionList.isEmpty()){
|
// if(!delTsInstitutionList.isEmpty()){
|
||||||
// logger.debug("本次删除的组织机构为:"+JSONObject.toJSONString(delTsInstitutionList));
|
// logger.debug("本次删除的组织机构为:"+JSONObject.toJSONString(delTsInstitutionList));
|
||||||
// List<String> delIdList = new ArrayList<>();
|
// List<String> delIdList = new ArrayList<>();
|
||||||
@@ -562,6 +562,99 @@ public class DataSyncServiceImpl implements IDataSyncService {
|
|||||||
return "1";
|
return "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 手动全量同步部门信息
|
||||||
|
@Transactional(rollbackFor = {RuntimeException.class,Exception.class})
|
||||||
|
public String orgDataSync2(){
|
||||||
|
try{
|
||||||
|
SyncUserService syncUserService = new SyncUserService();
|
||||||
|
List<String> res = syncUserService.syncFotonOrg2();
|
||||||
|
if(res!=null && !res.isEmpty()){
|
||||||
|
res.forEach(each -> logger.info("同步部门数据:"+each));
|
||||||
|
//获取到所有用户数据
|
||||||
|
List<String> strings=new ArrayList<>();
|
||||||
|
//tsInstitutionService.clearData();
|
||||||
|
for (String s : res) {
|
||||||
|
JSONArray jsonArray = JSONArray.parseArray(JSONObject.parseObject(s.toString()).getString("results"));
|
||||||
|
jsonArray.forEach(object -> {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(object.toString());
|
||||||
|
strings.add(jsonObject.getString("parentOrgNumber"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
List<TsInstitution> allTsInstitutionList = tsInstitutionService.list();
|
||||||
|
List<TsInstitution> addTsInstitutionList = new ArrayList<>();
|
||||||
|
List<TsInstitution> updateTsInstitutionList = new ArrayList<>();
|
||||||
|
List<TsInstitution> delTsInstitutionList = new ArrayList<>();
|
||||||
|
Set<String> syncAllIdList = new HashSet<>();
|
||||||
|
for (String s : res) {
|
||||||
|
JSONArray jsonArray = JSONArray.parseArray(JSONObject.parseObject(s.toString()).getString("results"));
|
||||||
|
if(jsonArray!=null){
|
||||||
|
jsonArray.forEach(object -> {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(object.toString());
|
||||||
|
TsInstitution tsInstitution=new TsInstitution();
|
||||||
|
tsInstitution.setId(jsonObject.getString("orgNumber"));
|
||||||
|
tsInstitution.setName(jsonObject.getString("orgName"));
|
||||||
|
tsInstitution.setHasChild(strings.contains(jsonObject.getString("orgNumber"))?"1":"0");
|
||||||
|
tsInstitution.setParentId(jsonObject.getString("parentOrgNumber"));
|
||||||
|
//部门为"null"的数据不保存
|
||||||
|
if (!"null".equals(jsonObject.getString("orgName"))){
|
||||||
|
TsInstitution institution = tsInstitutionService.getById(tsInstitution.getId());
|
||||||
|
if(institution!=null){
|
||||||
|
updateTsInstitutionList.add(tsInstitution);
|
||||||
|
}else{
|
||||||
|
addTsInstitutionList.add(tsInstitution);
|
||||||
|
}
|
||||||
|
syncAllIdList.add(tsInstitution.getId());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//遍历出来需要删除的数据
|
||||||
|
for(TsInstitution data :allTsInstitutionList){
|
||||||
|
if(!syncAllIdList.contains(data.getId())){
|
||||||
|
delTsInstitutionList.add(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//需要新增的数据
|
||||||
|
if(!addTsInstitutionList.isEmpty()){
|
||||||
|
logger.debug("本次新增的组织机构为:"+JSONObject.toJSONString(addTsInstitutionList));
|
||||||
|
tsInstitutionService.saveBatch(addTsInstitutionList);
|
||||||
|
}
|
||||||
|
//需要更新的数据
|
||||||
|
if(!updateTsInstitutionList.isEmpty()){
|
||||||
|
logger.debug("本次更新的组织机构为:"+JSONObject.toJSONString(updateTsInstitutionList));
|
||||||
|
tsInstitutionService.updateBatchById(updateTsInstitutionList);
|
||||||
|
}
|
||||||
|
//需要删除的数据
|
||||||
|
// 先行注释,会删除所有部门
|
||||||
|
if(!delTsInstitutionList.isEmpty()){
|
||||||
|
logger.debug("本次删除的组织机构为:"+JSONObject.toJSONString(delTsInstitutionList));
|
||||||
|
List<String> delIdList = new ArrayList<>();
|
||||||
|
for(TsInstitution data : delTsInstitutionList){
|
||||||
|
delIdList.add(data.getId());
|
||||||
|
}
|
||||||
|
tsInstitutionService.removeByIds(delIdList);
|
||||||
|
}
|
||||||
|
//全部部门
|
||||||
|
List<TsInstitution> allTsInstitutionListForPids = new ArrayList<>(addTsInstitutionList);
|
||||||
|
allTsInstitutionListForPids.addAll(updateTsInstitutionList);
|
||||||
|
for (TsInstitution tsInstitution : allTsInstitutionListForPids){
|
||||||
|
List<String> parentIds = new ArrayList<>();
|
||||||
|
getParentTaxCompanyIds(allTsInstitutionListForPids, tsInstitution.getId(), parentIds);
|
||||||
|
tsInstitution.setParentIds(String.join(",",parentIds));
|
||||||
|
}
|
||||||
|
if (! allTsInstitutionListForPids.isEmpty()) {
|
||||||
|
tsInstitutionService.updateBatchById(allTsInstitutionListForPids);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
logger.info("本次获取组织机构的数据为空,原因有2种:1、没有同步数据 2、请求接口报错");
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error(e.getMessage(),e);
|
||||||
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
|
}
|
||||||
|
return "1";
|
||||||
|
}
|
||||||
|
|
||||||
public String updateByOrgs(){
|
public String updateByOrgs(){
|
||||||
QueryWrapper<TsInstitution> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<TsInstitution> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.ne("id","");
|
queryWrapper.ne("id","");
|
||||||
|
|||||||
+26
-18
@@ -5029,27 +5029,35 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
|
|||||||
QueryWrapper<OnlineFileLog> onlineFileLogWrapper = new QueryWrapper<>();
|
QueryWrapper<OnlineFileLog> onlineFileLogWrapper = new QueryWrapper<>();
|
||||||
onlineFileLogWrapper.eq("ATT_FILE_ID",sarBussStandFiles.get(0).getOriAttId());
|
onlineFileLogWrapper.eq("ATT_FILE_ID",sarBussStandFiles.get(0).getOriAttId());
|
||||||
List<OnlineFileLog> onlineFileLogs = onlineFileLogDao.selectList(onlineFileLogWrapper);
|
List<OnlineFileLog> onlineFileLogs = onlineFileLogDao.selectList(onlineFileLogWrapper);
|
||||||
|
QueryWrapper<SarBussStandFile> webFileWrapper = new QueryWrapper<>();
|
||||||
|
webFileWrapper.eq("ORI_ATT_ID", sarBussStandFiles.get(0).getAttId());
|
||||||
|
webFileWrapper.eq("USE_MODEL", "WEB_FILE");
|
||||||
|
webFileWrapper.eq("VALID_FLAG","0");
|
||||||
|
List<SarBussStandFile> webFile = sarBussStandFileEODao.selectList(webFileWrapper);
|
||||||
|
if (!webFile.isEmpty()){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if(!onlineFileLogs.isEmpty()){
|
if(!onlineFileLogs.isEmpty()){
|
||||||
//在线编辑的情况下,判断是否有web
|
//在线编辑的情况下,判断是否有web
|
||||||
QueryWrapper<SarBussStandFile> objectQueryWrapperSarBussStandFile = new QueryWrapper<>();
|
// QueryWrapper<SarBussStandFile> objectQueryWrapperSarBussStandFile = new QueryWrapper<>();
|
||||||
objectQueryWrapperSarBussStandFile.eq("ORI_ATT_ID", sarBussStandFiles.get(0).getOriAttId());
|
// objectQueryWrapperSarBussStandFile.eq("ORI_ATT_ID", sarBussStandFiles.get(0).getAttId());
|
||||||
objectQueryWrapperSarBussStandFile.eq("USE_MODEL", "WEB_FILE");
|
// objectQueryWrapperSarBussStandFile.eq("USE_MODEL", "WEB_FILE");
|
||||||
List<SarBussStandFile> sarBussStandFilesList = sarBussStandFileEODao.selectList(objectQueryWrapperSarBussStandFile);
|
// List<SarBussStandFile> sarBussStandFilesList = sarBussStandFileEODao.selectList(objectQueryWrapperSarBussStandFile);
|
||||||
if(!sarBussStandFilesList.isEmpty()){
|
// if(!sarBussStandFilesList.isEmpty()){
|
||||||
//删除当前pdf文件
|
//删除当前pdf文件
|
||||||
AttFileEO fileInfo = attFileEOService.getFileInfo(sarBussStandFilesList.get(0).getAttId());
|
// AttFileEO fileInfo = attFileEOService.getFileInfo(sarBussStandFilesList.get(0).getAttId());
|
||||||
logger.info("要删除的文件ID:{},文件名:{},文件路径:{}",fileInfo.getId(),fileInfo.getFileName(),fileInfo.getFilePath());
|
// logger.info("要删除的文件ID:{},文件名:{},文件路径:{}",fileInfo.getId(),fileInfo.getFileName(),fileInfo.getFilePath());
|
||||||
if(fileInfo!=null) {
|
// if(fileInfo!=null) {
|
||||||
File file = new File(filePath + fileInfo.getFilePath() + fileInfo.getFileName());
|
// File file = new File(filePath + fileInfo.getFilePath() + fileInfo.getFileName());
|
||||||
if(file.exists()){
|
// if(file.exists()){
|
||||||
logger.info("删除PDF文件,文件路径:" + file.getAbsolutePath());
|
// logger.info("删除PDF文件,文件路径:" + file.getAbsolutePath());
|
||||||
boolean deleted = file.delete();
|
// boolean deleted = file.delete();
|
||||||
logger.info("删除结果:{}", deleted);
|
// logger.info("删除结果:{}", deleted);
|
||||||
}
|
// }
|
||||||
attFileEOService.deleteById(sarBussStandFilesList.get(0).getAttId());
|
// attFileEOService.deleteById(sarBussStandFilesList.get(0).getAttId());
|
||||||
sarBussStandFileEODao.deleteById(sarBussStandFilesList.get(0).getId());
|
// sarBussStandFileEODao.deleteById(sarBussStandFilesList.get(0).getId());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if(StringUtils.isNotBlank(onlineFileLogs.get(0).getOLdFileName()) && StringUtils.isNotBlank(onlineFileLogs.get(0).getFilekey()) && StringUtils.isNotBlank(onlineFileLogs.get(0).getFilePath())){
|
if(StringUtils.isNotBlank(onlineFileLogs.get(0).getOLdFileName()) && StringUtils.isNotBlank(onlineFileLogs.get(0).getFilekey()) && StringUtils.isNotBlank(onlineFileLogs.get(0).getFilePath())){
|
||||||
try {
|
try {
|
||||||
logger.info("======================================远程调用转换开始启动=================================");
|
logger.info("======================================远程调用转换开始启动=================================");
|
||||||
|
|||||||
@@ -131,7 +131,6 @@ public class SyncUserService {
|
|||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
String timestamp = sdf.format(calendar.getTime());
|
String timestamp = sdf.format(calendar.getTime());
|
||||||
params.put("timestamp", timestamp);
|
params.put("timestamp", timestamp);
|
||||||
|
|
||||||
// 组织参数
|
// 组织参数
|
||||||
params.put("filter", "(orgNumber=*)");
|
params.put("filter", "(orgNumber=*)");
|
||||||
params.put("basedn", "ou=Organizations,o=foton.com.cn,o=isp");
|
params.put("basedn", "ou=Organizations,o=foton.com.cn,o=isp");
|
||||||
@@ -162,4 +161,47 @@ public class SyncUserService {
|
|||||||
} while (cookie != null);
|
} while (cookie != null);
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
// 不添加时间戳,全量同步部门信息
|
||||||
|
public List<String> syncFotonOrg2()throws Exception{
|
||||||
|
String appuser = "app_slrs";
|
||||||
|
String appkey = "Fxi5LHbI5yGbQQDpVp86GcCdXeC5Bjfe";
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss'Z'");
|
||||||
|
AuthUtils util = new AuthUtils(appuser, appkey, null);
|
||||||
|
|
||||||
|
byte[] cookie = null;
|
||||||
|
List<String> json=new ArrayList<>();
|
||||||
|
do {
|
||||||
|
Map<String, Object> params = new HashMap<String, Object>();
|
||||||
|
params.put("cookie", Base64.encodeBase64String(cookie));
|
||||||
|
params.put("timestamp","");
|
||||||
|
// 组织参数
|
||||||
|
params.put("filter", "(orgNumber=*)");
|
||||||
|
params.put("basedn", "ou=Organizations,o=foton.com.cn,o=isp");
|
||||||
|
// 组织测试
|
||||||
|
String rs = util.getResponseFromServer("http://idmsync.foton.com.cn/rest/orgs/getOrgList", params);
|
||||||
|
log.info("远程调用同步的部门数据:"+rs);
|
||||||
|
JSONObject responseStr = JSONObject.parseObject(rs);
|
||||||
|
if(responseStr.containsKey("status") && responseStr.getBoolean("status")){
|
||||||
|
json.add(rs);
|
||||||
|
}
|
||||||
|
if (responseStr.containsKey("cookie")) {
|
||||||
|
try {
|
||||||
|
JSONArray entries = responseStr.getJSONArray("cookie");
|
||||||
|
if(entries==null){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cookie = new byte[entries.size()];
|
||||||
|
for (int i = 0; i < entries.size(); i++) {
|
||||||
|
cookie[i] = (byte) entries.getByte(i);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
if (e.getMessage().contains("is not a JSONArray")) {
|
||||||
|
cookie = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (cookie != null);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user