Merge branch 'develop_master' into FOTON

This commit is contained in:
super_liu
2022-06-08 11:43:23 +08:00
36 changed files with 1497 additions and 223 deletions
@@ -16,6 +16,7 @@ import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -48,6 +49,13 @@ public class ProcessTimer {
@Autowired @Autowired
private WorkFlowController workFlowController; private WorkFlowController workFlowController;
/**
* 根据配置文件设置是否开启定时器
*/
@Value("${isNotScheduled}")
private boolean isNotScheduled; //是否开启定时器
/*** /***
* @Description: 自动催办,任务截至时间前3天开始每天催办 * @Description: 自动催办,任务截至时间前3天开始每天催办
* @Author: yangxuenan * @Author: yangxuenan
@@ -59,44 +67,48 @@ public class ProcessTimer {
// @Scheduled(cron = "*/5 * * * * ?")//每5秒执行一次 // @Scheduled(cron = "*/5 * * * * ?")//每5秒执行一次
// @Scheduled(cron = "0/20 * * * * ?") // @Scheduled(cron = "0/20 * * * * ?")
public void urging() { public void urging() {
List<BusProcessName> busProcessNames = workFlowFeignClient.queryBusProcessNameForEnd(null); if(isNotScheduled){
if (null != busProcessNames && 0 < busProcessNames.size()) { log.info("=================================自动催办定时任务启动=====================================");
for (BusProcessName busProcessName : busProcessNames) { List<BusProcessName> busProcessNames = workFlowFeignClient.queryBusProcessNameForEnd(null);
String type = busProcessName.getPrcType(); if (null != busProcessNames && 0 < busProcessNames.size()) {
Integer typeInt = 99; for (BusProcessName busProcessName : busProcessNames) {
if (StringUtils.isNotEmpty(type)) { String type = busProcessName.getPrcType();
typeInt = Integer.valueOf(type); Integer typeInt = 99;
} if (StringUtils.isNotEmpty(type)) {
type = chooseType(typeInt, type); typeInt = Integer.valueOf(type);
}
type = chooseType(typeInt, type);
UserEO userEO = userEOService.selectByPrimaryKey(busProcessName.getCreatUserName()); UserEO userEO = userEOService.selectByPrimaryKey(busProcessName.getCreatUserName());
String[] array = userEO.getEmail().split(","); String[] array = userEO.getEmail().split(",");
String overTime = busProcessName.getOverTime(); String overTime = busProcessName.getOverTime();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date dateTime = null; Date dateTime = null;
Integer num = 3; Integer num = 3;
try {
dateTime = simpleDateFormat.parse(overTime);
Date now = new Date();
long daysBetween = (dateTime.getTime() - now.getTime() + 1000000) / (60 * 60 * 24 * 1000);
num = Integer.valueOf(String.valueOf(daysBetween));
} catch (ParseException e) {
SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'");
try { try {
dateTime = simpleDateFormat1.parse(overTime); dateTime = simpleDateFormat.parse(overTime);
Date now = new Date(); Date now = new Date();
long daysBetween = (dateTime.getTime() - now.getTime() + 1000000) / (60 * 60 * 24 * 1000); long daysBetween = (dateTime.getTime() - now.getTime() + 1000000) / (60 * 60 * 24 * 1000);
num = Integer.valueOf(String.valueOf(daysBetween)); num = Integer.valueOf(String.valueOf(daysBetween));
} catch (ParseException e1) { } catch (ParseException e) {
e.getMessage(); SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'");
try {
dateTime = simpleDateFormat1.parse(overTime);
Date now = new Date();
long daysBetween = (dateTime.getTime() - now.getTime() + 1000000) / (60 * 60 * 24 * 1000);
num = Integer.valueOf(String.valueOf(daysBetween));
} catch (ParseException e1) {
e.getMessage();
}
} }
}
String msg = "您好,[" + busProcessName.getPrcNum() + "]-[" + busProcessName.getPrcName() + "] 您有待办任务未及时办理,距离截至日期还有[" + String.valueOf(num) + "]天 请及时办理,请登录全球标准法规管理系统 ( http://39.98.140.126:10005/#/login ) 办理:链接 ( http://39.98.140.126:10005/#/processCenter?tabsName=ProcessCenter ) 。\n" + String msg = "您好,[" + busProcessName.getPrcNum() + "]-[" + busProcessName.getPrcName() + "] 您有待办任务未及时办理,距离截至日期还有[" + String.valueOf(num) + "]天 请及时办理,请登录全球标准法规管理系统 ( http://39.98.140.126:10005/#/login ) 办理:链接 ( http://39.98.140.126:10005/#/processCenter?tabsName=ProcessCenter ) 。\n" +
" ——来自 全球标准法规管理系统"; " ——来自 全球标准法规管理系统";
String title = "GSRM——【待办任务】[" + type + "] 您有未完成的待办任务"; String title = "GSRM——【待办任务】[" + type + "] 您有未完成的待办任务";
mailUtil.sendMsgFeign(array, title, msg); mailUtil.sendMsgFeign(array, title, msg);
}
} }
log.info("=================================自动催办定时任务结束=====================================");
} }
} }
@@ -169,20 +181,24 @@ public class ProcessTimer {
@Scheduled(cron = "0 0 10 * * ? ")//每天十点执行 @Scheduled(cron = "0 0 10 * * ? ")//每天十点执行
// @Scheduled(cron = "*/20 * * * * ? ")//每天十点执行 // @Scheduled(cron = "*/20 * * * * ? ")//每天十点执行
public void everyDayTenOlockScan() { public void everyDayTenOlockScan() {
List<BusProcessNew> busProcessNews=new ArrayList<>(); if(isNotScheduled){
busProcessNews=workFlowFeignClient.everyDayTenOlock(); log.info("=================================政策课题组会后流程定时任务启动=====================================");
if (!busProcessNews.isEmpty()){ List<BusProcessNew> busProcessNews=new ArrayList<>();
for (BusProcessNew bus:busProcessNews) { busProcessNews=workFlowFeignClient.everyDayTenOlock();
JSONObject jsonObject= JSON.parseObject(bus.getMesg()); if (!busProcessNews.isEmpty()){
jsonObject.put("auto","1"); for (BusProcessNew bus:busProcessNews) {
ResponseMessage responseMessage = workFlowController.startProcessNew("19",jsonObject.getString("revisionId"),null); JSONObject jsonObject= JSON.parseObject(bus.getMesg());
BusMes busMes=new BusMes(); jsonObject.put("auto","1");
busMes.setTaskIds(String.valueOf(responseMessage.getData())); ResponseMessage responseMessage = workFlowController.startProcessNew("19",jsonObject.getString("revisionId"),null);
busMes.setJson(jsonObject.toJSONString()); BusMes busMes=new BusMes();
busMes.setUserId(jsonObject.getString("revisionId")); busMes.setTaskIds(String.valueOf(responseMessage.getData()));
Wrapper<String> wrapper=workFlowFeignClient.completeTaskByUserId(busMes); busMes.setJson(jsonObject.toJSONString());
log.info("政策课题组会后流程已发起"); busMes.setUserId(jsonObject.getString("revisionId"));
Wrapper<String> wrapper=workFlowFeignClient.completeTaskByUserId(busMes);
log.info("政策课题组会后流程已发起");
}
} }
log.info("=================================政策课题组会后流程定时任务启动=====================================");
} }
} }
@@ -190,36 +206,33 @@ public class ProcessTimer {
// @Scheduled(cron = "0 0 0/1 * * ? ")//每天十点执行 // @Scheduled(cron = "0 0 0/1 * * ? ")//每天十点执行
// @Scheduled(cron = "*/40 * * * * ? ")//20s // @Scheduled(cron = "*/40 * * * * ? ")//20s
public void everyDayTenOlockScanSAM() { public void everyDayTenOlockScanSAM() {
List<BusProcessNew> busProcessNews=new ArrayList<>(); if(isNotScheduled){
busProcessNews=workFlowFeignClient.everyDayTenOlockSAM(); log.info("=================================标准化活动参会流程定时任务启动=====================================");
if (!busProcessNews.isEmpty()){ List<BusProcessNew> busProcessNews=new ArrayList<>();
for (BusProcessNew bus:busProcessNews) { busProcessNews=workFlowFeignClient.everyDayTenOlockSAM();
JSONObject jsonObject= JSON.parseObject(bus.getMesg()); if (!busProcessNews.isEmpty()){
String taskInfo = bus.getTaskInfo(); for (BusProcessNew bus:busProcessNews) {
String result = jsonObject.getJSONObject("roleList").getString("dockUser"); JSONObject jsonObject= JSON.parseObject(bus.getMesg());
result = result.split(",")[0]; String taskInfo = bus.getTaskInfo();
jsonObject.put("member",result); String result = jsonObject.getJSONObject("roleList").getString("dockUser");
if(taskInfo.equals("标准化活动参会流程-流程结束")){ result = result.split(",")[0];
jsonObject.put("auto","1"); jsonObject.put("member",result);
ResponseMessage responseMessage = workFlowController.startProcessNew("22",result,null); if(taskInfo.equals("标准化活动参会流程-流程结束")){
BusMes busMes=new BusMes(); jsonObject.put("auto","1");
busMes.setTaskIds(String.valueOf(responseMessage.getData())); ResponseMessage responseMessage = workFlowController.startProcessNew("22",result,null);
busMes.setJson(jsonObject.toJSONString()); BusMes busMes=new BusMes();
busMes.setUserId(result); busMes.setTaskIds(String.valueOf(responseMessage.getData()));
busMes.setJson(jsonObject.toJSONString());
busMes.setUserId(result);
Wrapper<String> wrapper=workFlowFeignClient.completeTaskByUserId(busMes);
System.out.println("标准化活动会后流程自动发起");
}
Wrapper<String> wrapper=workFlowFeignClient.completeTaskByUserId(busMes);
System.out.println("标准化活动会后流程自动发起");
} }
} }
log.info("=================================标准化活动参会流程定时任务启动=====================================");
} }
} }
public static void main(String[]args){
ProcessTimer processTimer = new ProcessTimer();
processTimer.everyDayTenOlockScan();
processTimer.everyDayTenOlockScanSAM();
}
} }
@@ -32,6 +32,7 @@ import org.elasticsearch.search.aggregations.bucket.terms.StringTerms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder; import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightField; import org.elasticsearch.search.fetch.subphase.highlight.HighlightField;
import org.elasticsearch.search.sort.ScoreSortBuilder;
import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.search.sort.SortOrder;
import org.json.JSONTokener; import org.json.JSONTokener;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -58,6 +59,12 @@ public class SearchCenterServiceImpl implements SearchCenterService {
private TransportClient client; private TransportClient client;
// 函数式接口,获取next数组
@FunctionalInterface
public interface NextArray {
int[] getNext(String target);
}
@Autowired @Autowired
private DicTypeEODao dicTypeEODao; private DicTypeEODao dicTypeEODao;
@@ -1346,22 +1353,27 @@ public class SearchCenterServiceImpl implements SearchCenterService {
QueryBuilder multiQueryBuilder1; QueryBuilder multiQueryBuilder1;
QueryBuilder queryBuilder1 = QueryBuilders.multiMatchQuery(""); QueryBuilder queryBuilder1 = QueryBuilders.multiMatchQuery("");
if(StringUtils.isNotBlank(searchInfoEO.getSelectValue())){ if(StringUtils.isNotBlank(searchInfoEO.getSelectValue())){
if(searchInfoEO.getSelectValue().length() > 1){ // if(searchInfoEO.getSelectValue().length() > 1){
String str0 = searchInfoEO.getSelectValue().substring(0,1); // String str0 = searchInfoEO.getSelectValue().substring(0,1);
String Str1 = searchInfoEO.getSelectValue().substring(1,2); // String Str1 = searchInfoEO.getSelectValue().substring(1,2);
String reg = ".*[0-9].*"; // String reg = ".*[0-9].*";
Pattern pattern = Pattern.compile("^[a-zA-Z\\/]+$"); // Pattern pattern = Pattern.compile("^[a-zA-Z\\/]+$");
if (pattern.matcher(str0).matches() && Str1.matches(reg)) { // if (pattern.matcher(str0).matches() && Str1.matches(reg)) {
String value = searchInfoEO.getSelectValue().replace(str0,str0+" "); // String value = searchInfoEO.getSelectValue().replace(str0,str0+" ");
searchInfoEO.setSelectValue(value); // searchInfoEO.setSelectValue(value);
} // }
} // }
boolQueryShould
.should(QueryBuilders.wildcardQuery("sortTitle.keyword", searchInfoEO.getSelectValue().toUpperCase() + "*").boost(1005f))
queryBuilder1 = QueryBuilders.multiMatchQuery(searchInfoEO.getSelectValue(), .should(QueryBuilders.wildcardQuery("numberTitle.keyword", searchInfoEO.getSelectValue().toUpperCase() + "*").boost(1004f))
"title" .should(QueryBuilders.wildcardQuery("yearOrder.keyword", searchInfoEO.getSelectValue().toUpperCase() + "*").boost(1003f))
).minimumShouldMatch("100%").field("title",1000f); .should(QueryBuilders.wildcardQuery("nameTitle.keyword", "*" + searchInfoEO.getSelectValue().toUpperCase() + "*").boost(1002f))
boolQueryBuilder.must(queryBuilder1); .should(QueryBuilders.wildcardQuery("title.keyword", "*" + searchInfoEO.getSelectValue().toUpperCase() + "*").boost(1000f));
// queryBuilder1 = QueryBuilders.wildcardQuery("title.keyword","*" + searchInfoEO.getSelectValue() + "*");
// queryBuilder1 = QueryBuilders.multiMatchQuery(searchInfoEO.getSelectValue(),
// "title"
// ).minimumShouldMatch("100%").field("title",1000f);
boolQueryBuilder.must(boolQueryShould);
} }
@@ -1384,7 +1396,7 @@ public class SearchCenterServiceImpl implements SearchCenterService {
//在结果中检索 //在结果中检索
HighlightBuilder hiBuilder=new HighlightBuilder(); HighlightBuilder hiBuilder=new HighlightBuilder();
HighlightBuilder.Field highlightTitle = new HighlightBuilder.Field("title"); HighlightBuilder.Field highlightTitle = new HighlightBuilder.Field("title.keyword");
hiBuilder.field(highlightTitle); hiBuilder.field(highlightTitle);
hiBuilder.preTags("<span class='highlight-Es-class'>"); hiBuilder.preTags("<span class='highlight-Es-class'>");
hiBuilder.postTags("</span>"); hiBuilder.postTags("</span>");
@@ -1396,9 +1408,10 @@ public class SearchCenterServiceImpl implements SearchCenterService {
searchRequestBuilder = client.prepareSearch("fulltextserch") searchRequestBuilder = client.prepareSearch("fulltextserch")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH) .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.highlighter(hiBuilder) .highlighter(hiBuilder)
// .addSort(new ScoreSortBuilder().order(SortOrder.DESC))
.addSort("standTypeOrder",SortOrder.ASC) .addSort("standTypeOrder",SortOrder.ASC)
.addSort("standSortOrder",SortOrder.ASC) .addSort("standSortOrder",SortOrder.ASC)
.addSort("numberTitle",SortOrder.ASC) .addSort("numberTitle.keyword",SortOrder.ASC)
.addSort("yearOrder",SortOrder.DESC) .addSort("yearOrder",SortOrder.DESC)
.addSort("sortTitle.keyword",SortOrder.ASC) .addSort("sortTitle.keyword",SortOrder.ASC)
.setFrom((searchInfoEO.getPage()-1)*searchInfoEO.getPageSize()) .setFrom((searchInfoEO.getPage()-1)*searchInfoEO.getPageSize())
@@ -1409,37 +1422,124 @@ public class SearchCenterServiceImpl implements SearchCenterService {
for (SearchHit searchHit : response.getHits().getHits()) { for (SearchHit searchHit : response.getHits().getHits()) {
searchHit.getSourceAsMap().put("id", searchHit.getId()); searchHit.getSourceAsMap().put("id", searchHit.getId());
Map<String, Object> sourceAsMap = searchHit.getSourceAsMap(); Map<String, Object> sourceAsMap = searchHit.getSourceAsMap();
// String textContent = sourceAsMap.getOrDefault("textContent","").toString();
String textStatusColor = ""; String textStatusColor = "";
if(StringUtils.isNotBlank(sourceAsMap.getOrDefault("textStatusFull","").toString())){ // if(StringUtils.isNotBlank(textContent) && StringUtils.isNotBlank(searchInfoEO.getSelectValue())){
String textStatus = sourceAsMap.getOrDefault("textStatusFull","").toString(); // String[] standStr = new String[]{"废止","被代替","作废","参考"};
if("废止".equals(textStatus) || "被代替".equals(textStatus) || "作废".equals(textStatus) ){ // for (String textStatus : standStr) {
textStatusColor = "redClass"; // int i = indexOfToKMP(textContent, "文本状态:"+textStatus, 0, getNextValInstance());
}else if("参考".equals(textStatus)){ // if(i > 0 && ("废止".equals(textStatus) || "被代替".equals(textStatus) || "作废".equals(textStatus) )){
textStatusColor = "yellowClass"; // textStatusColor = "redClass";
// break;
// }else if("参考".equals(textStatus)){
// textStatusColor = "yellowClass";
// break;
// }
// }
//
// }
if(StringUtils.isNotBlank(searchInfoEO.getSelectValue())){
if(StringUtils.isNotBlank(sourceAsMap.getOrDefault("textStatusFull","").toString())){
String textStatus = sourceAsMap.getOrDefault("textStatusFull","").toString();
if("废止".equals(textStatus) || "被代替".equals(textStatus) || "作废".equals(textStatus) ){
textStatusColor = "redClass";
}else if("参考".equals(textStatus)){
textStatusColor = "yellowClass";
}
}
//高亮标题覆盖原标题
String titleStr = sourceAsMap.get("title").toString();
titleStr = titleStr.replace(searchInfoEO.getSelectValue(),"<span class='highlight-Es-class'>"+searchInfoEO.getSelectValue()+"</span>");
if(StringUtils.isNotBlank(textStatusColor)){
sourceAsMap.put("title", "<span class='"+textStatusColor+"'>"+titleStr+"</span>");
}else {
sourceAsMap.put("title", titleStr);
} }
} }
//解析高亮字段 //解析高亮字段
Map<String, HighlightField> highlightFields = searchHit.getHighlightFields(); // Map<String, HighlightField> highlightFields = searchHit.getHighlightFields();
HighlightField field= highlightFields.get("title"); // HighlightField field= highlightFields.get("title.keyword");
if(field!= null){ // if(field!= null){
Text[] fragments = field.fragments(); // Text[] fragments = field.fragments();
StringBuilder n_field = new StringBuilder(); // StringBuilder n_field = new StringBuilder();
for (Text fragment : fragments) { // for (Text fragment : fragments) {
n_field.append(fragment); // n_field.append(fragment);
} // }
//高亮标题覆盖原标题 // //高亮标题覆盖原标题
if(StringUtils.isNotBlank(textStatusColor)){ // if(StringUtils.isNotBlank(textStatusColor)){
sourceAsMap.put("title", "<span class='"+textStatusColor+"'>"+n_field.toString()+"</span>"); // sourceAsMap.put("title", "<span class='"+textStatusColor+"'>"+n_field.toString()+"</span>");
}else { // }else {
sourceAsMap.put("title", n_field.toString()); // sourceAsMap.put("title", n_field.toString());
} // }
} // }
result.add(sourceAsMap); result.add(sourceAsMap);
} }
searchInfoEO.getPager().setRowCount((int) response.getHits().getTotalHits().value); searchInfoEO.getPager().setRowCount((int) response.getHits().getTotalHits().value);
return result; return result;
} }
// 改进版的nextVal数组
public NextArray getNextValInstance() {
return target -> {
// 初始化数组大小
int[] nextVal = new int[target.length()];
// 0 位置默认为-1
nextVal[0] = -1;
// 遍历字符串每一位,计算每个位置上的值
for (int i = 0, k = -1; i < target.length() - 1; ) {
if (k == -1 || target.charAt(i) == target.charAt(k)) {
i++;
k++;
// 判断当前字符和求的k位置的字符是否相等
if (target.charAt(i) == target.charAt(k)) {
// 若相等,则继承k位置的值
nextVal[i] = nextVal[k];
} else {
// 不等,则还是使用原来next数组的值
nextVal[i] = k;
}
} else {
k = nextVal[k];
}
}
return nextVal;
};
}
/**
* 采用KMP算法,查找字符串子串的位置
*
* @param source 源字符串
* @param target 目标(子)字符串
* @param pos 源字符串的起始索引
* @param nextArray 函数式接口,传入获取next数组的方法(因为next数组上面定义了两种获取方式)
* @return 目标字符串在源字符串中第一次出现的索引位置
*/
public int indexOfToKMP(String source, String target, int pos, NextArray nextArray) {
int i, j;
// 调用接口中的方法,获取next数组
int[] next = nextArray.getNext(target);
// 初始化遍历
i = pos;
j = 0;
// 判断i和j的索引都不能大于等于字符串长度,否则说明比较完成
while (i < source.length() && j < target.length()) {
// 如果j==-1,说明需要从头开始比较;或者由公共元素相等,继续比较
if (j == -1 || source.charAt(i) == target.charAt(j)) {
i++;
j++;
} else {
// 需要按照数组回溯j
j = next[j];
}
}
// 判断子字符的索引是否大于等于子字符串,如果为true说明查找成功,返回源字符串当前位置-子字符串长度
return j >= target.length() ? i - target.length() : -1;
}
@Override @Override
public List<Map<String, Object>> searchSarBykeyAndHighLightNumber(SeniorSearchInfoEO searchInfoEO) throws Exception { public List<Map<String, Object>> searchSarBykeyAndHighLightNumber(SeniorSearchInfoEO searchInfoEO) throws Exception {
String real = searchInfoEO.getSelectValue(); String real = searchInfoEO.getSelectValue();
@@ -26,6 +26,7 @@ public class ConvertMqEO extends BaseEntity {
private String mqCode; private String mqCode;
private String id; private String id;
private String addOrUp; private String addOrUp;
private String name;
//向文件表添加信息 //向文件表添加信息
private String lawsId; private String lawsId;
@@ -220,4 +221,12 @@ public class ConvertMqEO extends BaseEntity {
public void setLawsFileClassify(String lawsFileClassify) { public void setLawsFileClassify(String lawsFileClassify) {
this.lawsFileClassify = lawsFileClassify; this.lawsFileClassify = lawsFileClassify;
} }
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
} }
@@ -5,6 +5,7 @@ import com.adc.da.slrs.DataSync.service.IDataSyncService;
import com.sun.org.apache.bcel.internal.generic.NEW; import com.sun.org.apache.bcel.internal.generic.NEW;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
@@ -22,13 +23,22 @@ public class ScheduledSync {
@Autowired @Autowired
private IDataSyncService iDataSyncService; private IDataSyncService iDataSyncService;
/**
* 根据配置文件设置是否开启定时器
*/
@Value("${isNotScheduled}")
private boolean isNotScheduled; //是否开启定时器
//每天凌晨两点执行 //每天凌晨两点执行
@Scheduled(cron="0 0 2 * * ?") @Scheduled(cron="0 0 2 * * ?")
@Async @Async
public void syncSchedulingTasks() { public void syncSchedulingTasks() {
iDataSyncService.orgDataSync(); //时间短 if(isNotScheduled){
iDataSyncService.dataSync(); //时间长 log.info("======================================开始同步基础数据========================================");
iDataSyncService.orgDataSync(); //时间短
iDataSyncService.dataSync(); //时间长
log.info("======================================结束同步基础数据========================================");
}
} }
} }
@@ -14,6 +14,7 @@ import com.adc.da.slrs.sarStandItems.dao.SarStandItemsDao;
import com.adc.da.sys.dao.DicTypeEODao; import com.adc.da.sys.dao.DicTypeEODao;
import com.adc.da.utils.util.FieldConvertUtil; import com.adc.da.utils.util.FieldConvertUtil;
import com.adc.da.utils.util.InitStandAttrUtil; import com.adc.da.utils.util.InitStandAttrUtil;
import com.adc.da.utils.util.Utils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -179,7 +180,10 @@ public class UpdateStateBussSyncFz implements Runnable {
List<String> valArr = new ArrayList<>(); List<String> valArr = new ArrayList<>();
if (entry.getValue() != null && InitStandAttrUtil.selectionFieldListBuss != null && InitStandAttrUtil.selectionFieldListBuss.size() > 0 && InitStandAttrUtil.selectionFieldListBuss.contains(name)) { if (entry.getValue() != null && InitStandAttrUtil.selectionFieldListBuss != null && InitStandAttrUtil.selectionFieldListBuss.size() > 0 && InitStandAttrUtil.selectionFieldListBuss.contains(name)) {
if(org.apache.commons.lang.StringUtils.isNotBlank(entry.getValue().toString())){ if(org.apache.commons.lang.StringUtils.isNotBlank(entry.getValue().toString())){
Object json= new JSONTokener(entry.getValue().toString()).nextValue(); Object json = null;
if(Utils.isJson(entry.getValue().toString())){
json = new JSONTokener(entry.getValue().toString()).nextValue();
}
if(json instanceof org.json.JSONArray){ if(json instanceof org.json.JSONArray){
valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(),String.class); valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(),String.class);
}else { }else {
@@ -14,6 +14,7 @@ import com.adc.da.slrs.sarStandItems.dao.SarStandItemsDao;
import com.adc.da.sys.dao.DicTypeEODao; import com.adc.da.sys.dao.DicTypeEODao;
import com.adc.da.utils.util.FieldConvertUtil; import com.adc.da.utils.util.FieldConvertUtil;
import com.adc.da.utils.util.InitStandAttrUtil; import com.adc.da.utils.util.InitStandAttrUtil;
import com.adc.da.utils.util.Utils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -204,7 +205,10 @@ public class UpdateStateBussSyncSsAndYx implements Runnable {
List<String> valArr = new ArrayList<>(); List<String> valArr = new ArrayList<>();
if (entry.getValue() != null && InitStandAttrUtil.selectionFieldListBuss != null && InitStandAttrUtil.selectionFieldListBuss.size() > 0 && InitStandAttrUtil.selectionFieldListBuss.contains(name)) { if (entry.getValue() != null && InitStandAttrUtil.selectionFieldListBuss != null && InitStandAttrUtil.selectionFieldListBuss.size() > 0 && InitStandAttrUtil.selectionFieldListBuss.contains(name)) {
if(org.apache.commons.lang.StringUtils.isNotBlank(entry.getValue().toString())){ if(org.apache.commons.lang.StringUtils.isNotBlank(entry.getValue().toString())){
Object json= new JSONTokener(entry.getValue().toString()).nextValue(); Object json = null;
if(Utils.isJson(entry.getValue().toString())){
json = new JSONTokener(entry.getValue().toString()).nextValue();
}
if(json instanceof org.json.JSONArray){ if(json instanceof org.json.JSONArray){
valArr = JSONObject.parseArray(entry.getValue().toString(),String.class); valArr = JSONObject.parseArray(entry.getValue().toString(),String.class);
}else { }else {
@@ -16,6 +16,7 @@ import com.adc.da.slrs.sarStandardsInfo.service.ISarStandardsInfoService;
import com.adc.da.sys.dao.DicTypeEODao; import com.adc.da.sys.dao.DicTypeEODao;
import com.adc.da.utils.util.FieldConvertUtil; import com.adc.da.utils.util.FieldConvertUtil;
import com.adc.da.utils.util.InitStandAttrUtil; import com.adc.da.utils.util.InitStandAttrUtil;
import com.adc.da.utils.util.Utils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -289,7 +290,10 @@ public class UpdateStateStandSyncFz implements Runnable {
List<String> valArr = new ArrayList<>(); List<String> valArr = new ArrayList<>();
if (entry.getValue() != null && InitStandAttrUtil.selectionFieldList != null && InitStandAttrUtil.selectionFieldList.size() > 0 && InitStandAttrUtil.selectionFieldList.contains(name)) { if (entry.getValue() != null && InitStandAttrUtil.selectionFieldList != null && InitStandAttrUtil.selectionFieldList.size() > 0 && InitStandAttrUtil.selectionFieldList.contains(name)) {
if (StringUtils.isNotBlank(entry.getValue().toString())) { if (StringUtils.isNotBlank(entry.getValue().toString())) {
Object json = new JSONTokener(entry.getValue().toString()).nextValue(); Object json = null;
if(Utils.isJson(entry.getValue().toString())){
json = new JSONTokener(entry.getValue().toString()).nextValue();
}
if (json instanceof org.json.JSONArray) { if (json instanceof org.json.JSONArray) {
valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(), String.class); valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(), String.class);
} else { } else {
@@ -16,6 +16,7 @@ import com.adc.da.slrs.sarStandardsInfo.service.ISarStandardsInfoService;
import com.adc.da.sys.dao.DicTypeEODao; import com.adc.da.sys.dao.DicTypeEODao;
import com.adc.da.utils.util.FieldConvertUtil; import com.adc.da.utils.util.FieldConvertUtil;
import com.adc.da.utils.util.InitStandAttrUtil; import com.adc.da.utils.util.InitStandAttrUtil;
import com.adc.da.utils.util.Utils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -238,7 +239,10 @@ public class UpdateStateStandSyncSsAndYx implements Runnable {
List<String> valArr = new ArrayList<>(); List<String> valArr = new ArrayList<>();
if (entry.getValue() != null && InitStandAttrUtil.selectionFieldList != null && InitStandAttrUtil.selectionFieldList.size() > 0 && InitStandAttrUtil.selectionFieldList.contains(name)) { if (entry.getValue() != null && InitStandAttrUtil.selectionFieldList != null && InitStandAttrUtil.selectionFieldList.size() > 0 && InitStandAttrUtil.selectionFieldList.contains(name)) {
if (StringUtils.isNotBlank(entry.getValue().toString())) { if (StringUtils.isNotBlank(entry.getValue().toString())) {
Object json = new JSONTokener(entry.getValue().toString()).nextValue(); Object json = null;
if(Utils.isJson(entry.getValue().toString())){
json = new JSONTokener(entry.getValue().toString()).nextValue();
}
if (json instanceof org.json.JSONArray) { if (json instanceof org.json.JSONArray) {
valArr = JSONObject.parseArray(entry.getValue().toString(), String.class); valArr = JSONObject.parseArray(entry.getValue().toString(), String.class);
} else { } else {
@@ -31,8 +31,10 @@ import com.adc.da.util.http.Result;
import com.adc.da.utils.util.DateUtil; import com.adc.da.utils.util.DateUtil;
import com.adc.da.utils.util.FieldConvertUtil; import com.adc.da.utils.util.FieldConvertUtil;
import com.adc.da.utils.util.InitStandAttrUtil; import com.adc.da.utils.util.InitStandAttrUtil;
import com.adc.da.utils.util.Utils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.client.transport.TransportClient;
import org.json.JSONTokener; import org.json.JSONTokener;
@@ -504,7 +506,10 @@ public class ResetSearchCenterService {
List<String> valArr = new ArrayList<>(); List<String> valArr = new ArrayList<>();
if (entry.getValue() != null && InitStandAttrUtil.selectionFieldList != null && InitStandAttrUtil.selectionFieldList.size() > 0 && InitStandAttrUtil.selectionFieldList.contains(name)) { if (entry.getValue() != null && InitStandAttrUtil.selectionFieldList != null && InitStandAttrUtil.selectionFieldList.size() > 0 && InitStandAttrUtil.selectionFieldList.contains(name)) {
if (StringUtils.isNotBlank(entry.getValue().toString())) { if (StringUtils.isNotBlank(entry.getValue().toString())) {
Object json = new JSONTokener(entry.getValue().toString()).nextValue(); Object json = null;
if(Utils.isJson(entry.getValue().toString())){
json = new JSONTokener(entry.getValue().toString()).nextValue();
}
if (json instanceof org.json.JSONArray) { if (json instanceof org.json.JSONArray) {
valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(), String.class); valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(), String.class);
} else { } else {
@@ -825,7 +830,10 @@ public class ResetSearchCenterService {
List<String> valArr = new ArrayList<>(); List<String> valArr = new ArrayList<>();
if (entry.getValue() != null && InitStandAttrUtil.selectionFieldListLaws != null && InitStandAttrUtil.selectionFieldListLaws.size() > 0 && InitStandAttrUtil.selectionFieldListLaws.contains(name)) { if (entry.getValue() != null && InitStandAttrUtil.selectionFieldListLaws != null && InitStandAttrUtil.selectionFieldListLaws.size() > 0 && InitStandAttrUtil.selectionFieldListLaws.contains(name)) {
if(org.apache.commons.lang.StringUtils.isNotBlank(entry.getValue().toString())){ if(org.apache.commons.lang.StringUtils.isNotBlank(entry.getValue().toString())){
Object json= new JSONTokener(entry.getValue().toString()).nextValue(); Object json = null;
if(Utils.isJson(entry.getValue().toString())){
json = new JSONTokener(entry.getValue().toString()).nextValue();
}
if(json instanceof org.json.JSONArray){ if(json instanceof org.json.JSONArray){
valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(),String.class); valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(),String.class);
}else { }else {
@@ -1071,7 +1079,10 @@ public class ResetSearchCenterService {
List<String> valArr = new ArrayList<>(); List<String> valArr = new ArrayList<>();
if (entry.getValue() != null && InitStandAttrUtil.selectionFieldListBuss != null && InitStandAttrUtil.selectionFieldListBuss.size() > 0 && InitStandAttrUtil.selectionFieldListBuss.contains(name)) { if (entry.getValue() != null && InitStandAttrUtil.selectionFieldListBuss != null && InitStandAttrUtil.selectionFieldListBuss.size() > 0 && InitStandAttrUtil.selectionFieldListBuss.contains(name)) {
if(org.apache.commons.lang.StringUtils.isNotBlank(entry.getValue().toString())){ if(org.apache.commons.lang.StringUtils.isNotBlank(entry.getValue().toString())){
Object json= new JSONTokener(entry.getValue().toString()).nextValue(); Object json = null;
if(Utils.isJson(entry.getValue().toString())){
json = new JSONTokener(entry.getValue().toString()).nextValue();
}
if(json instanceof org.json.JSONArray){ if(json instanceof org.json.JSONArray){
valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(),String.class); valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(),String.class);
}else { }else {
@@ -9,11 +9,14 @@ import com.adc.da.slrs.sarPosition.service.ITsPositionService;
import com.adc.da.slrs.sarUser.entity.TsUser; import com.adc.da.slrs.sarUser.entity.TsUser;
import com.adc.da.slrs.sarUser.service.ITsUserService; import com.adc.da.slrs.sarUser.service.ITsUserService;
import com.adc.da.sync.service.SyncUserService; import com.adc.da.sync.service.SyncUserService;
import com.adc.da.sys.constant.ValidFlagEnum;
import com.adc.da.sys.entity.UserOrgEO; import com.adc.da.sys.entity.UserOrgEO;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.log4j.Log4j; import lombok.extern.log4j.Log4j;
import org.apache.ibatis.jdbc.Null;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -40,14 +43,12 @@ public class DataSyncServiceImpl implements IDataSyncService {
@Transactional(rollbackFor = {RuntimeException.class,Exception.class}) @Transactional(rollbackFor = {RuntimeException.class,Exception.class})
@Override
public String dataSync(){ public String dataSync(){
try{ try{
SyncUserService syncUserService = new SyncUserService(); SyncUserService syncUserService = new SyncUserService();
List<String> res = syncUserService.syncFotonUser(); List<String> res = syncUserService.syncFotonUser();
//存放岗位信息 //存放岗位信息
Map<String, String> positionMap = new HashMap<>(); Map<String, String> positionMap = new HashMap<>();
Map<String, String> useDistinct = new HashMap<>();
TsPosition position = new TsPosition(); TsPosition position = new TsPosition();
position.setCurrent(1); position.setCurrent(1);
position.setPageSize(100000); position.setPageSize(100000);
@@ -58,90 +59,78 @@ public class DataSyncServiceImpl implements IDataSyncService {
positionMap.put(tsPosition.getName(), tsPosition.getId()); positionMap.put(tsPosition.getName(), tsPosition.getId());
}); });
} }
List<TsUser> addUserList = new ArrayList<>();
/** List<TsUser> upUserList = new ArrayList<>();
* 得到数据时,删除系统表中所有用户信息
*/
if (res.size()>0){
tsUserService.deleteUser();
}
for (String s : res) { for (String s : res) {
//获取到所有用户数据 JSONObject userData = JSONObject.parseObject(s);
List<TsUser> tsUsers = new ArrayList<>(); if(userData.containsKey("results")){
JSONArray jsonArray = userData.getJSONArray("results");
JSONArray jsonArray = JSONArray.parseArray(JSONObject.parseObject(s.toString()).getString("results")); jsonArray.forEach(object -> {
jsonArray.forEach(object -> { JSONObject jsonObject = JSONObject.parseObject(object.toString());
JSONObject jsonObject = JSONObject.parseObject(object.toString()); String userid = jsonObject.getString("userid");
//先获取岗位以及岗位id TsUser userEO = tsUserService.getById(userid);
TsUser tsUser = new TsUser(); String userState = "";
UserOrgEO userOrgEO = new UserOrgEO(); if(userEO != null){
//设置岗位 userState = "UPDATE";
if (null != jsonObject.getString("title")) { }else{
//通过岗位名称查询系统表中是否有岗位,有则设定用户的岗位为系统中的岗位,否则新增 userState = "ADD";
if (null == positionMap.get(jsonObject.getString("title"))) { userEO = new TsUser();
TsPosition tsPosition = new TsPosition();
tsPosition.setId(String.valueOf(UUID.randomUUID()));
tsPosition.setName(jsonObject.getString("title"));
tsPositionService.addPosition(tsPosition);
//放入岗位的map集合中
positionMap.put(tsPosition.getName(), tsPosition.getId());
//放入类中
tsUser.setPositionName(tsPosition.getName());
tsUser.setPositionId(tsPosition.getId());
} else {
tsUser.setPositionName(jsonObject.getString("title").trim());
tsUser.setPositionId(positionMap.get(jsonObject.getString("title").trim()));
} }
} //先获取岗位以及岗位id
//设置其他数据 //设置岗位
Timestamp createTime = new Timestamp(new Date().getTime()); if (null != jsonObject.getString("title")) {
tsUser.setState(jsonObject.getString("userStatus")); //通过岗位名称查询系统表中是否有岗位,有则设定用户的岗位为系统中的岗位,否则新增
tsUser.setUname(null!=jsonObject.getString("name")?jsonObject.getString("name"):""); if (null == positionMap.get(jsonObject.getString("title"))) {
tsUser.setValidFlag("0"); TsPosition tsPosition = new TsPosition();
tsUser.setDisableFlag("0"); tsPosition.setId(String.valueOf(UUID.randomUUID()));
tsUser.setCreationTime(createTime); tsPosition.setName(jsonObject.getString("title"));
tsUser.setUserId(jsonObject.getString("userid")); tsPositionService.addPosition(tsPosition);
tsUser.setAccount(jsonObject.getString("userid")); //放入岗位的map集合中
tsUser.setInstitutionId(null!=jsonObject.getString("orgNumber")?jsonObject.getString("orgNumber"):"" ); positionMap.put(tsPosition.getName(), tsPosition.getId());
tsUser.setInstitutionName(null!=jsonObject.getString("orgName")?jsonObject.getString("orgName"):"" ); //放入类中
//2022-05-23:用户同步增加状态标识,将停用的用户过滤掉 userEO.setPositionName(tsPosition.getName());
if (null == useDistinct.get(jsonObject.getString("userid")) && "1".equals(jsonObject.getString("userStatus"))) { userEO.setPositionId(tsPosition.getId());
tsUsers.add(tsUser); } else {
userEO.setPositionName(jsonObject.getString("title").trim());
} userEO.setPositionId(positionMap.get(jsonObject.getString("title").trim()));
}
// //测试数据删除 }else{
// if (! "anbin".equals(jsonObject.getString("userid"))){ userEO.setPositionId(null);
// userEO.setPositionName(null);
// //测试数据修改 }
// if ("anbing".equals(jsonObject.getString("userid"))){ //设置其他数据
// tsUser.setUname("DDDDDD"); Timestamp createTime = new Timestamp(new Date().getTime());
// tsUsers.add(tsUser); userEO.setState(jsonObject.getString("userStatus"));
// } else if (null == useDistinct.get(jsonObject.getString("userid"))) { userEO.setUname(null!=jsonObject.getString("name")?jsonObject.getString("name"):"");
// tsUsers.add(tsUser); userEO.setCreationTime(createTime);
// userEO.setUserId(jsonObject.getString("userid"));
// } userEO.setAccount(jsonObject.getString("userid"));
// } userEO.setInstitutionId(null!=jsonObject.getString("orgNumber")?jsonObject.getString("orgNumber"):"" );
useDistinct.put(tsUser.getUserId(),tsUser.getUserId()); userEO.setInstitutionName(null!=jsonObject.getString("orgName")?jsonObject.getString("orgName"):"" );
}); //2022-05-23:用户同步增加状态标识,将停用的用户过滤掉
tsUserService.saveBatch(tsUsers); if("1".equals(jsonObject.getString("userStatus"))){
userEO.setValidFlag(ValidFlagEnum.VALID_FALSE.getValue()+"");
userEO.setDisableFlag(ValidFlagEnum.VALID_FALSE.getValue()+"");
}else{
userEO.setValidFlag(ValidFlagEnum.VALID_TRUE.getValue()+"");
userEO.setDisableFlag(ValidFlagEnum.VALID_TRUE.getValue()+"");
}
if("ADD".equals(userState)){
addUserList.add(userEO);
}else {
upUserList.add(userEO);
}
});
}
}
if(!addUserList.isEmpty()){
logger.debug("本次新增的用户为:"+JSONObject.toJSONString(addUserList));
tsUserService.saveBatch(addUserList);
}
if(!upUserList.isEmpty()){
logger.debug("本次更新的用户为:"+JSONObject.toJSONString(upUserList));
tsUserService.updateBatchById(upUserList);
} }
//测试数据添加
// TsUser addUser = new TsUser();
// addUser.setState("FFFFFFF");
// addUser.setUname("zhaokaiyao");
// addUser.setValidFlag("0");
// addUser.setDisableFlag("0");
// addUser.setCreationTime(new Timestamp(new Date().getTime()));
// addUser.setUserId("FFFFFFF");
// addUser.setAccount("zhaokaiyao");
// addUser.setInstitutionId("10022745");
// addUser.setInstitutionName("福田营销其他");
//
// List<TsUser> addUserList = Arrays.asList(addUser);
// tsUserService.saveBatch(addUserList);
}catch(Exception e){ }catch(Exception e){
logger.error(e.getMessage(),e); logger.error(e.getMessage(),e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -202,15 +191,22 @@ public class DataSyncServiceImpl implements IDataSyncService {
} }
//需要新增的数据 //需要新增的数据
if(!addTsInstitutionList.isEmpty()){ if(!addTsInstitutionList.isEmpty()){
logger.debug("本次新增的组织机构为:"+JSONObject.toJSONString(addTsInstitutionList));
tsInstitutionService.saveBatch(addTsInstitutionList); tsInstitutionService.saveBatch(addTsInstitutionList);
} }
//需要更新的数据 //需要更新的数据
if(!updateTsInstitutionList.isEmpty()){ if(!updateTsInstitutionList.isEmpty()){
logger.debug("本次更新的组织机构为:"+JSONObject.toJSONString(updateTsInstitutionList));
tsInstitutionService.updateBatchById(updateTsInstitutionList); tsInstitutionService.updateBatchById(updateTsInstitutionList);
} }
//需要删除的数据 //需要删除的数据
if(!delTsInstitutionList.isEmpty()){ if(!delTsInstitutionList.isEmpty()){
tsInstitutionService.updateBatchById(delTsInstitutionList); logger.debug("本次删除的组织机构为:"+JSONObject.toJSONString(delTsInstitutionList));
List<String> delIdList = new ArrayList<>();
for(TsInstitution data : delTsInstitutionList){
delIdList.add(data.getId());
}
tsInstitutionService.removeByIds(delIdList);
} }
}catch(Exception e){ }catch(Exception e){
logger.error(e.getMessage(),e); logger.error(e.getMessage(),e);
@@ -0,0 +1,211 @@
package com.adc.da.slrs.StandardQA.controller;
import com.adc.da.base.web.BaseController;
import com.adc.da.slrs.NewsFeed.entity.NewsFeed;
import com.adc.da.slrs.StandardQA.dao.AskQuestionsDao;
import com.adc.da.slrs.StandardQA.entity.AskQuestions;
import com.adc.da.slrs.StandardQA.entity.AskUser;
import com.adc.da.slrs.StandardQA.entity.Reply;
import com.adc.da.slrs.StandardQA.entity.Subscription;
import com.adc.da.slrs.StandardQA.service.Impl.AskQuestionsServiceImpl;
import com.adc.da.slrs.StandardQA.service.Impl.AskUserServiceImpl;
import com.adc.da.util.UUIDUtils;
import com.adc.da.util.http.ResponseMessage;
import com.adc.da.util.http.Result;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* @Author: qk
* @Date: 2022/5/31 0031 9:18
* @Version 1.0
*/
@RestController
@RequestMapping("/${restPath}/lawss/AskQuestions")
@Api(description = "|AskQuestions|")
public class AskQuestionsController extends BaseController<AskQuestions> {
@Autowired
private AskQuestionsServiceImpl askQuestionsService;
@Autowired
private AskQuestionsDao askQuestionsDao;
@Autowired
private AskUserServiceImpl askUserService;
/**
* 查询问题列表
* @return
*/
@GetMapping("/getAskQuestions")
public ResponseMessage getAskQuestions(){
QueryWrapper<AskQuestions> queryWrapper = new QueryWrapper<>();
queryWrapper.orderByDesc("QUESTION_TIME");
List<AskQuestions> askQuestionsList=askQuestionsService.list(queryWrapper);
return Result.success(askQuestionsList);
}
/**
* 查看我的问题详情
* @param askQuestions
* @return
*/
@GetMapping("/getAskQuestionsDetails")
public ResponseMessage getAskQuestionsDetails(AskQuestions askQuestions){
List<AskQuestions> askQuestionsList = askQuestionsService.getAskQuestions(askQuestions);
return Result.success(askQuestionsList);
}
/**
* 查看我回答的问题
* @param askQuestions
* @return
*/
@GetMapping("/getReplyDetails")
public ResponseMessage getReplyDetails(AskQuestions askQuestions){
List<AskQuestions> askQuestionsList = askQuestionsService.getReplyDetails(askQuestions);
return Result.success(askQuestionsList);
}
/**
* 根据标准查询问题
* @param askQuestions
* @return
*/
@GetMapping("/getReplyDetailsByStandId")
public ResponseMessage getReplyDetailsByStandId(AskQuestions askQuestions){
List<AskQuestions> askQuestionsList = askQuestionsService.getReplyDetailsByStandId(askQuestions);
return Result.success(askQuestionsList);
}
/**
* 根据标准编号查询我的回答
* @param standardId
* @return
*/
@GetMapping("/getAskQuestionsByStandardId")
public ResponseMessage getAskQuestionsByStandardId(String standardId){
List<AskQuestions> askQuestionsList = askQuestionsService.getAskQuestionsByStandardId(standardId);
return Result.success(askQuestionsList);
}
/**
* 根据问题ID查询回答***
* @param id
* @return
*/
@GetMapping("/getAskQuestionsByakId")
public ResponseMessage getAskQuestionsByakId(String id){
List<Reply> askQuestionsList = askQuestionsService.getAskQuestionsByakId(id);
return Result.success(askQuestionsList);
}
/**
* 添加问题
* @param askQuestions
* @return
*/
@PostMapping("/insertAskQuestions")
public ResponseMessage insertAskQuestions(@RequestBody AskQuestions askQuestions){
askQuestions.setId(UUIDUtils.randomUUID20());
askQuestions.setAppendixId(askQuestions.getFileList().get(0).getAttId());
askQuestions.setAppendixName(askQuestions.getFileList().get(0).getName());
askQuestions.setQuestionTime(new Date());
List<String> uId = askQuestionsDao.getUId();
List<AskUser> askUserList = new ArrayList<>();
for (String id:uId) {
AskUser askUser = new AskUser();
askUser.setAsdId(askQuestions.getId());
askUser.setUsid(id);
askUserList.add(askUser);
}
//添加问题分配人员
askUserService.saveBatch(askUserList);
if(askQuestionsService.save(askQuestions)){
return Result.success("200","添加成功");
}else {
return Result.error("-1","添加失败");
}
}
/**
* 查询订阅问题
* @param askQuestions
* @return
*/
@GetMapping("/getAskQuestionsBySubscription")
public ResponseMessage getAskQuestionsBySubscription(AskQuestions askQuestions){
List<AskQuestions> askQuestionsList = askQuestionsService.getAskQuestionsBySubscription(askQuestions);
return Result.success(askQuestionsList);
}
/**
* 根据标准id查询订阅
* @param askQuestions
* @return
*/
@GetMapping("/getSubscriptionByStandId")
public ResponseMessage getSubscriptionByStandId(AskQuestions askQuestions){
List<AskQuestions> askQuestionsList = askQuestionsService.getSubscriptionByStandId(askQuestions);
return Result.success(askQuestionsList);
}
/**
* 相似查询
* @param problemDescription
* @return
*/
@GetMapping("/resemblance")
public ResponseMessage resemblance(String problemDescription){
List<String> askQuestions = Arrays.asList(problemDescription.split(""));
List<AskQuestions> askQuestionsList = askQuestionsService.resemblance(askQuestions);
return Result.success(askQuestionsList);
}
/**
* 根据分类查询问题
* @param classification
* @return
*/
@GetMapping("/getAskQuestionsReply")
public ResponseMessage getAskQuestionsReply(String classification){
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.select("DISTINCT STANDARD_ID");
queryWrapper.select("STANDARD_NAME");
queryWrapper.select("STANDARD_ENCDOING");
queryWrapper.eq("CLASSIFICATION",classification);
List<AskQuestions> askQuestionsList = askQuestionsService.list(queryWrapper);
return Result.success(askQuestionsList);
}
/**
* 问答库的根据标准ID查询问题
* @param id
* @return
*/
@GetMapping("/getSubscription")
public ResponseMessage getArchiveAskQuestions(String id){
List<AskQuestions> askQuestionsList = askQuestionsService.getArchiveAskQuestions(id);
return Result.success(askQuestionsList);
}
@GetMapping("/retrieve")
public ResponseMessage retrieve(AskQuestions askQuestions){
List<AskQuestions> askQuestionsList = askQuestionsService.retrieve(askQuestions);
return Result.success(askQuestionsList);
}
}
@@ -0,0 +1,37 @@
package com.adc.da.slrs.StandardQA.controller;
import com.adc.da.base.web.BaseController;
import com.adc.da.slrs.StandardQA.entity.AskQuestions;
import com.adc.da.slrs.StandardQA.entity.AskUser;
import com.adc.da.slrs.StandardQA.service.Impl.AskQuestionsServiceImpl;
import com.adc.da.slrs.StandardQA.service.Impl.AskUserServiceImpl;
import com.adc.da.util.http.ResponseMessage;
import com.adc.da.util.http.Result;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author: qk
* @Date: 2022/6/2 0002 8:44
* @Version 1.0
*/
@RestController
@RequestMapping("/${restPath}/lawss/AskUser")
@Api(description = "|AskUser|")
public class AskUserController extends BaseController<AskUser> {
@Autowired
private AskUserServiceImpl askUserService;
@PostMapping("/insertAskUser")
public ResponseMessage insertAskUser(@RequestBody AskUser askUser){
if(askUserService.save(askUser)){
return Result.success("200","邀请成功");
}else {
return Result.error("-1","添加失败");
}
}
}
@@ -0,0 +1,61 @@
package com.adc.da.slrs.StandardQA.controller;
import com.adc.da.base.web.BaseController;
import com.adc.da.slrs.StandardQA.entity.AskQuestions;
import com.adc.da.slrs.StandardQA.entity.Reply;
import com.adc.da.slrs.StandardQA.service.Impl.ReplyServiceImpl;
import com.adc.da.util.UUIDUtils;
import com.adc.da.util.http.ResponseMessage;
import com.adc.da.util.http.Result;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* @Author: qk
* @Date: 2022/5/31 0031 10:55
* @Version 1.0
*/
@RestController
@RequestMapping("/${restPath}/lawss/Reply")
@Api(description = "| Reply|")
public class ReplyController extends BaseController<Reply> {
@Autowired
private ReplyServiceImpl replyService;
@PostMapping("/insertReply")
public ResponseMessage insertReply(@RequestBody Reply reply){
reply.setAppendixId(reply.getFileList().get(0).getAttId());
reply.setAppendixName(reply.getFileList().get(0).getName());
reply.setReplyTime(new Date());
reply.setId(UUIDUtils.randomUUID20());
if(replyService.save(reply)){
return Result.success("200","添加成功");
}else {
return Result.error("200","添加失败");
}
}
@PostMapping("/updateReply")
public ResponseMessage updateReply(String id){
List<String> list = Arrays.asList(id.split(","));
for (String s: list) {
UpdateWrapper updateWrapper = new UpdateWrapper();
updateWrapper.set("STATE","yes");
updateWrapper.eq("ID",s);
replyService.update(updateWrapper);
}
return Result.success("200","归档成功");
}
}
@@ -0,0 +1,44 @@
package com.adc.da.slrs.StandardQA.controller;
import com.adc.da.base.web.BaseController;
import com.adc.da.slrs.StandardQA.entity.Subscription;
import com.adc.da.slrs.StandardQA.service.Impl.SubscriptionServiceImpl;
import com.adc.da.util.http.ResponseMessage;
import com.adc.da.util.http.Result;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author: qk
* @Date: 2022/6/7 0007 11:18
* @Version 1.0
*/
@RestController
@RequestMapping("/${restPath}/lawss/Subscription")
@Api(description = "|Subscription|")
public class SubscriptionController extends BaseController<Subscription> {
@Autowired
private SubscriptionServiceImpl subscriptionService;
@PostMapping("/insertSubscription")
public ResponseMessage updateReply(@RequestBody Subscription subscription){
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("ASK_ID",subscription.getAskId());
queryWrapper.eq("USID",subscription.getUsId());
int number = subscriptionService.count(queryWrapper);
if(number>0){
return Result.success("200","此问题已订阅");
}
if(subscriptionService.save(subscription)){
return Result.success("200","订阅成功");
}else {
return Result.success("-1","订阅失败");
}
}
}
@@ -0,0 +1,40 @@
package com.adc.da.slrs.StandardQA.dao;
import com.adc.da.slrs.StandardQA.entity.AskQuestions;
import com.adc.da.slrs.StandardQA.entity.Reply;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @Author: qk
* @Date: 2022/5/31 0031 9:26
* @Version 1.0
*/
@Repository
public interface AskQuestionsDao extends BaseMapper<AskQuestions> {
List<AskQuestions> getAskQuestions (@Param("askQuestions") AskQuestions askQuestions);
List<AskQuestions> getReplyDetails (@Param("askQuestions") AskQuestions askQuestions);
List<AskQuestions> getReplyDetailsByStandId (@Param("askQuestions") AskQuestions askQuestions);
List<AskQuestions> getAskQuestionsBySubscription (@Param("askQuestions") AskQuestions askQuestions);
List<AskQuestions> retrieve (@Param("askQuestions") AskQuestions askQuestions);
List<AskQuestions> getSubscriptionByStandId (@Param("askQuestions") AskQuestions askQuestions);
List<AskQuestions> resemblance (@Param("chars") List<String> askQuestions);
List<AskQuestions> getAskQuestionsByStandardId (String standardId);
List<AskQuestions> getArchiveAskQuestions (String id);
List<Reply> getAskQuestionsByakId (String id);
List<String> getUId();
}
@@ -0,0 +1,15 @@
package com.adc.da.slrs.StandardQA.dao;
import com.adc.da.slrs.StandardQA.entity.AskQuestions;
import com.adc.da.slrs.StandardQA.entity.AskUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
/**
* @Author: qk
* @Date: 2022/6/2 0002 8:47
* @Version 1.0
*/
@Repository
public interface AskUserDao extends BaseMapper<AskUser> {
}
@@ -0,0 +1,15 @@
package com.adc.da.slrs.StandardQA.dao;
import com.adc.da.slrs.StandardQA.entity.AskQuestions;
import com.adc.da.slrs.StandardQA.entity.Reply;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
/**
* @Author: qk
* @Date: 2022/5/31 0031 11:02
* @Version 1.0
*/
@Repository
public interface ReplyDao extends BaseMapper<Reply> {
}
@@ -0,0 +1,15 @@
package com.adc.da.slrs.StandardQA.dao;
import com.adc.da.slrs.StandardQA.entity.Reply;
import com.adc.da.slrs.StandardQA.entity.Subscription;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
/**
* @Author: qk
* @Date: 2022/6/7 0007 11:19
* @Version 1.0
*/
@Repository
public interface SubscriptionDao extends BaseMapper<Subscription> {
}
@@ -0,0 +1,104 @@
package com.adc.da.slrs.StandardQA.entity;
import com.adc.da.base.entity.BaseEntity;
import com.adc.da.common.ConvertMqEO;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
/**
* @Author: qk
* @Date: 2022/5/31 0031 9:19
* @Version 1.0
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="AskQuestions对象", description="")
public class AskQuestions extends BaseEntity {
private static final long serialVersionUID = 1L;
@TableId
@ApiModelProperty(value = "主键")
private String id;
@TableField("CLASSIFICATION")
@ApiModelProperty(value = "分类")
private String classification;
@TableField("PROBLEM_DESCRIPTION")
@ApiModelProperty(value = "问题描述")
private String problemDescription;
@TableField("QUESTIONER")
@ApiModelProperty(value = "提问人")
private String questioner;
@TableField("QUESTION_TIME")
@ApiModelProperty(value = "提问时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date questionTime;
@TableField("STANDARD_ENCDOING")
@ApiModelProperty(value = "标准编号")
private String standardEncdoing;
@TableField("STANDARD_NAME")
@ApiModelProperty(value = "标准名称")
private String standardName;
@TableField("STANDARD_ID")
@ApiModelProperty(value = "标准ID")
private String standardId;
@TableField("APPENDIX_ID")
@ApiModelProperty(value = "标准ID")
private String appendixId;
@TableField("APPENDIX_NAME")
@ApiModelProperty(value = "标准ID")
private String appendixName;
/**
* 回答人
*/
@TableField(exist = false)
private String answerer;
/**
* 回答
*/
@TableField(exist = false)
private String reply;
/**
* 回答时间
*/
@TableField(exist = false)
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date replyTime;
/**
*附件路径
*/
@TableField(exist = false)
private String appendix;
@TableField(exist = false)
private List<ConvertMqEO> fileList;
@TableField(exist = false)
private String type;
@TableField(exist = false)
private String subscription;
}
@@ -0,0 +1,32 @@
package com.adc.da.slrs.StandardQA.entity;
import com.adc.da.base.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Author: qk
* @Date: 2022/6/2 0002 8:44
* @Version 1.0
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="AskUser对象", description="")
public class AskUser extends BaseEntity {
@TableField("ASK_ID")
@ApiModelProperty(value = "问题ID")
private String asdId;
@TableField("USID")
@ApiModelProperty(value = "用户ID")
private String usid;
}
@@ -0,0 +1,71 @@
package com.adc.da.slrs.StandardQA.entity;
import com.adc.da.base.entity.BaseEntity;
import com.adc.da.common.ConvertMqEO;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
/**
* @Author: qk
* @Date: 2022/5/31 0031 9:20
* @Version 1.0
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="Reply对象", description="")
public class Reply extends BaseEntity {
private static final long serialVersionUID = 1L;
@TableId
@ApiModelProperty(value = "主键")
private String id;
@TableField("REPLY")
@ApiModelProperty(value = "回答")
private String reply;
@TableField("STATE")
@ApiModelProperty(value = "状态(0:显示,1:不显示)")
private String state;
@TableField("REPLY_TIME")
@ApiModelProperty(value = "回答时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date replyTime;
@TableField("APPENDIX")
@ApiModelProperty(value = "附件")
private String appendix;
@TableField("ANSWERER")
@ApiModelProperty(value = "回答人")
private String answerer;
@TableField("ASK_ID")
@ApiModelProperty(value = "问题ID")
private String askId;
@TableField("APPENDIX_ID")
@ApiModelProperty(value = "附件ID")
private String appendixId;
@TableField("APPENDIX_NAME")
@ApiModelProperty(value = "附件名称")
private String appendixName;
@TableField(exist = false)
private List<ConvertMqEO> fileList;
}
@@ -0,0 +1,31 @@
package com.adc.da.slrs.StandardQA.entity;
import com.adc.da.base.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Author: qk
* @Date: 2022/6/7 0007 11:16
* @Version 1.0
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="Subscription对象", description="")
public class Subscription extends BaseEntity {
@TableField("ASK_ID")
@ApiModelProperty(value = "问题ID")
private String askId;
@TableField("USID")
@ApiModelProperty(value = "用户ID")
private String usId;
}
@@ -0,0 +1,31 @@
package com.adc.da.slrs.StandardQA.service;
import com.adc.da.slrs.NewsFeed.entity.NewsFeed;
import com.adc.da.slrs.StandardQA.entity.AskQuestions;
import com.adc.da.slrs.StandardQA.entity.Reply;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* @Author: qk
* @Date: 2022/5/31 0031 9:22
* @Version 1.0
*/
public interface AskQuestionsService extends IService<AskQuestions> {
List<AskQuestions> getAskQuestions(AskQuestions askQuestions);
List<AskQuestions> getReplyDetails(AskQuestions askQuestions);
List<AskQuestions> getReplyDetailsByStandId(AskQuestions askQuestions);
List<AskQuestions> getAskQuestionsBySubscription(AskQuestions askQuestions);
List<AskQuestions> retrieve(AskQuestions askQuestions);
List<AskQuestions> getSubscriptionByStandId(AskQuestions askQuestions);
List<AskQuestions> resemblance(List<String> askQuestions);
List<AskQuestions> getAskQuestionsByStandardId(String standardId);
List<AskQuestions> getArchiveAskQuestions(String id);
List<Reply> getAskQuestionsByakId(String id);
}
@@ -0,0 +1,13 @@
package com.adc.da.slrs.StandardQA.service;
import com.adc.da.slrs.StandardQA.entity.AskQuestions;
import com.adc.da.slrs.StandardQA.entity.AskUser;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Author: qk
* @Date: 2022/6/2 0002 8:47
* @Version 1.0
*/
public interface AskUserService extends IService<AskUser> {
}
@@ -0,0 +1,79 @@
package com.adc.da.slrs.StandardQA.service.Impl;
import com.adc.da.slrs.StandardQA.dao.AskQuestionsDao;
import com.adc.da.slrs.StandardQA.entity.AskQuestions;
import com.adc.da.slrs.StandardQA.entity.Reply;
import com.adc.da.slrs.StandardQA.service.AskQuestionsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @Author: qk
* @Date: 2022/5/31 0031 9:23
* @Version 1.0
*/
@Service
@Transactional(value = "transactionManager", readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
public class AskQuestionsServiceImpl extends ServiceImpl<AskQuestionsDao, AskQuestions> implements AskQuestionsService {
@Autowired
private AskQuestionsDao askQuestionsDao;
@Override
public List<AskQuestions> getAskQuestions(AskQuestions askQuestions) {
return askQuestionsDao.getAskQuestions(askQuestions);
}
@Override
public List<AskQuestions> getReplyDetails(AskQuestions askQuestions) {
return askQuestionsDao.getReplyDetails(askQuestions);
}
@Override
public List<AskQuestions> getReplyDetailsByStandId(AskQuestions askQuestions) {
return askQuestionsDao.getReplyDetailsByStandId(askQuestions);
}
@Override
public List<AskQuestions> getAskQuestionsBySubscription(AskQuestions askQuestions) {
return askQuestionsDao.getAskQuestionsBySubscription(askQuestions);
}
@Override
public List<AskQuestions> retrieve(AskQuestions askQuestions) {
return askQuestionsDao.retrieve(askQuestions);
}
@Override
public List<AskQuestions> getSubscriptionByStandId(AskQuestions askQuestions) {
return askQuestionsDao.getSubscriptionByStandId(askQuestions);
}
@Override
public List<AskQuestions> resemblance(List<String> askQuestions) {
return askQuestionsDao.resemblance(askQuestions);
}
@Override
public List<AskQuestions> getAskQuestionsByStandardId(String standardId) {
return askQuestionsDao.getAskQuestionsByStandardId(standardId);
}
@Override
public List<AskQuestions> getArchiveAskQuestions(String id) {
return askQuestionsDao.getArchiveAskQuestions(id);
}
@Override
public List<Reply> getAskQuestionsByakId(String id) {
return askQuestionsDao.getAskQuestionsByakId(id);
}
}
@@ -0,0 +1,22 @@
package com.adc.da.slrs.StandardQA.service.Impl;
import com.adc.da.slrs.StandardQA.dao.AskUserDao;
import com.adc.da.slrs.StandardQA.entity.AskUser;
import com.adc.da.slrs.StandardQA.service.AskUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
/**
* @Author: qk
* @Date: 2022/6/2 0002 8:47
* @Version 1.0
*/
@Service
@Transactional(value = "transactionManager", readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
public class AskUserServiceImpl extends ServiceImpl<AskUserDao, AskUser> implements AskUserService {
}
@@ -0,0 +1,19 @@
package com.adc.da.slrs.StandardQA.service.Impl;
import com.adc.da.slrs.StandardQA.dao.ReplyDao;
import com.adc.da.slrs.StandardQA.entity.Reply;
import com.adc.da.slrs.StandardQA.service.ReplyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
/**
* @Author: qk
* @Date: 2022/5/31 0031 11:03
* @Version 1.0
*/
@Service
@Transactional(value = "transactionManager", readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
public class ReplyServiceImpl extends ServiceImpl<ReplyDao, Reply> implements ReplyService {
}
@@ -0,0 +1,20 @@
package com.adc.da.slrs.StandardQA.service.Impl;
import com.adc.da.slrs.StandardQA.dao.SubscriptionDao;
import com.adc.da.slrs.StandardQA.entity.Subscription;
import com.adc.da.slrs.StandardQA.service.SubscriptionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
/**
* @Author: qk
* @Date: 2022/6/7 0007 11:20
* @Version 1.0
*/
@Service
@Transactional(value = "transactionManager", readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
public class SubscriptionServiceImpl extends ServiceImpl<SubscriptionDao, Subscription> implements SubscriptionService {
}
@@ -0,0 +1,13 @@
package com.adc.da.slrs.StandardQA.service;
import com.adc.da.slrs.StandardQA.entity.AskQuestions;
import com.adc.da.slrs.StandardQA.entity.Reply;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Author: qk
* @Date: 2022/5/31 0031 11:02
* @Version 1.0
*/
public interface ReplyService extends IService<Reply> {
}
@@ -0,0 +1,13 @@
package com.adc.da.slrs.StandardQA.service;
import com.adc.da.slrs.StandardQA.entity.Reply;
import com.adc.da.slrs.StandardQA.entity.Subscription;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Author: qk
* @Date: 2022/6/7 0007 11:20
* @Version 1.0
*/
public interface SubscriptionService extends IService<Subscription> {
}
@@ -54,6 +54,7 @@ import com.adc.da.util.UUIDUtils;
import com.adc.da.utils.util.FieldConvertUtil; import com.adc.da.utils.util.FieldConvertUtil;
import com.adc.da.utils.util.InitStandAttrUtil; import com.adc.da.utils.util.InitStandAttrUtil;
import com.adc.da.utils.util.SarAdvanceSearchUtil; import com.adc.da.utils.util.SarAdvanceSearchUtil;
import com.adc.da.utils.util.Utils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
@@ -1466,7 +1467,10 @@ public class SarBussionessStandServiceImpl extends ServiceImpl<SarBussionessStan
List<String> valArr = new ArrayList<>(); List<String> valArr = new ArrayList<>();
if (entry.getValue() != null && InitStandAttrUtil.selectionFieldListBuss != null && InitStandAttrUtil.selectionFieldListBuss.size() > 0 && InitStandAttrUtil.selectionFieldListBuss.contains(name)) { if (entry.getValue() != null && InitStandAttrUtil.selectionFieldListBuss != null && InitStandAttrUtil.selectionFieldListBuss.size() > 0 && InitStandAttrUtil.selectionFieldListBuss.contains(name)) {
if(StringUtils.isNotBlank(entry.getValue().toString())){ if(StringUtils.isNotBlank(entry.getValue().toString())){
Object json= new JSONTokener(entry.getValue().toString()).nextValue(); Object json = null;
if(Utils.isJson(entry.getValue().toString())){
json = new JSONTokener(entry.getValue().toString()).nextValue();
}
if(json instanceof org.json.JSONArray){ if(json instanceof org.json.JSONArray){
valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(),String.class); valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(),String.class);
}else { }else {
@@ -58,6 +58,7 @@ import com.adc.da.util.UUIDUtils;
import com.adc.da.utils.util.FieldConvertUtil; import com.adc.da.utils.util.FieldConvertUtil;
import com.adc.da.utils.util.InitStandAttrUtil; import com.adc.da.utils.util.InitStandAttrUtil;
import com.adc.da.utils.util.SarAdvanceSearchUtil; import com.adc.da.utils.util.SarAdvanceSearchUtil;
import com.adc.da.utils.util.Utils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
@@ -769,7 +770,10 @@ public class SarLawsStandInfoServiceImpl extends ServiceImpl<SarLawsStandInfoDao
List<String> valArr = new ArrayList<>(); List<String> valArr = new ArrayList<>();
if (entry.getValue() != null && InitStandAttrUtil.selectionFieldListLaws != null && InitStandAttrUtil.selectionFieldListLaws.size() > 0 && InitStandAttrUtil.selectionFieldListLaws.contains(name)) { if (entry.getValue() != null && InitStandAttrUtil.selectionFieldListLaws != null && InitStandAttrUtil.selectionFieldListLaws.size() > 0 && InitStandAttrUtil.selectionFieldListLaws.contains(name)) {
if(StringUtils.isNotBlank(entry.getValue().toString())){ if(StringUtils.isNotBlank(entry.getValue().toString())){
Object json= new JSONTokener(entry.getValue().toString()).nextValue(); Object json = null;
if(Utils.isJson(entry.getValue().toString())){
json = new JSONTokener(entry.getValue().toString()).nextValue();
}
if(json instanceof org.json.JSONArray){ if(json instanceof org.json.JSONArray){
valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(),String.class); valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(),String.class);
}else { }else {
@@ -1025,7 +1025,10 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
List<String> valArr = new ArrayList<>(); List<String> valArr = new ArrayList<>();
if (entry.getValue() != null && InitStandAttrUtil.selectionFieldList != null && InitStandAttrUtil.selectionFieldList.size() > 0 && InitStandAttrUtil.selectionFieldList.contains(name)) { if (entry.getValue() != null && InitStandAttrUtil.selectionFieldList != null && InitStandAttrUtil.selectionFieldList.size() > 0 && InitStandAttrUtil.selectionFieldList.contains(name)) {
if (StringUtils.isNotBlank(entry.getValue().toString())) { if (StringUtils.isNotBlank(entry.getValue().toString())) {
Object json = new JSONTokener(entry.getValue().toString()).nextValue(); Object json = null;
if(Utils.isJson(entry.getValue().toString())){
json = new JSONTokener(entry.getValue().toString()).nextValue();
}
if (json instanceof JSONArray) { if (json instanceof JSONArray) {
valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(), String.class); valArr = com.alibaba.fastjson.JSONObject.parseArray(entry.getValue().toString(), String.class);
} else { } else {
@@ -1,5 +1,6 @@
package com.adc.da.utils.util; package com.adc.da.utils.util;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.CellType;
@@ -18,6 +19,16 @@ public class Utils {
return MessageFormat.format(value, paras); return MessageFormat.format(value, paras);
} }
public static boolean isJson(String string) {
try {
JSONObject.parseObject(string);
return true;
} catch (Exception e) {
return false;
}
}
//判断row是否为空 空返回true //判断row是否为空 空返回true
public static boolean isRowEmpty(Row row) { public static boolean isRowEmpty(Row row) {
if (null == row) { if (null == row) {
@@ -0,0 +1,219 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.adc.da.slrs.StandardQA.dao.AskQuestionsDao">
<select id="getAskQuestions" resultType="com.adc.da.slrs.StandardQA.entity.AskQuestions">
SELECT
DISTINCT
aq.STANDARD_ID,aq.CLASSIFICATION,aq.STANDARD_ENCDOING,
aq.STANDARD_NAME
FROM ask_questions aq
LEFT JOIN reply ON aq.ID = reply.ASK_ID
LEFT JOIN ts_user t1 ON t1.USID = aq.QUESTIONER
LEFT JOIN ts_user t2 ON t2.USID = reply.ANSWERER
<where>
<if test="askQuestions.questioner != null and askQuestions.questioner != ''">
AND aq.QUESTIONER =#{askQuestions.questioner}
</if>
<if test="askQuestions.id != null and askQuestions.id != ''">
AND aq.ID = #{askQuestions.id}
</if>
<if test="askQuestions.standardId !=null and askQuestions.standardId !=''">
AND aq.STANDARD_ID = #{askQuestions.standardId}
</if>
<if test="askQuestions.classification != null and askQuestions.classification != ''">
AND aq.CLASSIFICATION = #{askQuestions.classification}
</if>
<if test="askQuestions.standardEncdoing != null and askQuestions.standardEncdoing != ''">
AND aq.STANDARD_ENCDOING LIKE concat(concat('%',#{askQuestions.standardEncdoing}),'%')
</if>
<if test="askQuestions.standardName != null and askQuestions.standardName !=''">
AND aq.STANDARD_NAME LIKE concat(concat('%',#{askQuestions.standardName}),'%')
</if>
<if test="askQuestions.problemDescription != null and askQuestions.problemDescription != ''">
AND aq.PROBLEM_DESCRIPTION LIKE concat(concat('%',#{askQuestions.problemDescription}),'%')
</if>
<if test="askQuestions.answerer !=null and askQuestions.answerer !=''">
AND reply.ANSWERER = #{askQuestions.answerer}
</if>
</where>
</select>
<select id="getAskQuestionsByStandardId" resultType="com.adc.da.slrs.StandardQA.entity.AskQuestions">
SELECT aq.ID,aq.CLASSIFICATION,aq.PROBLEM_DESCRIPTION,t1.UNAME QUESTIONER,aq.QUESTION_TIME,aq.STANDARD_ENCDOING,
aq.STANDARD_NAME,aq.STANDARD_ID
FROM ask_questions aq
LEFT JOIN ts_user t1 ON t1.USID = aq.QUESTIONER
<where>
<if test="standardId !=null and standardId !=''">
AND aq.STANDARD_ID = #{standardId}
</if>
</where>
</select>
<select id="getArchiveAskQuestions" resultType="com.adc.da.slrs.StandardQA.entity.AskQuestions">
SELECT reply.REPLY,reply.REPLY_TIME,t2.UNAME ANSWERER,
reply.APPENDIX,reply.APPENDIX_ID,reply.APPENDIX_NAME
FROM reply
LEFT JOIN ts_user t2 ON t2.USID = reply.ANSWERER
<where>
reply.STATE = 'yes'
<if test="id != nll and id !=''">
AND reply.ASK_ID = #{id}
</if>
</where>
</select>
<select id="getAskQuestionsByakId" resultType="com.adc.da.slrs.StandardQA.entity.Reply">
SELECT reply.ID, reply.REPLY,reply.REPLY_TIME,t2.UNAME ANSWERER,reply.APPENDIX_ID,APPENDIX_NAME
FROM reply
LEFT JOIN ts_user t2 ON t2.USID = reply.ANSWERER
<where>
<if test="id !=null and id !=''">
AND reply.ASK_ID = #{id}
</if>
</where>
</select>
<select id="getReplyDetails" resultType="com.adc.da.slrs.StandardQA.entity.AskQuestions">
SELECT aq.ID,aq.CLASSIFICATION,aq.PROBLEM_DESCRIPTION,t1.UNAME QUESTIONER,aq.QUESTION_TIME,aq.STANDARD_ENCDOING,
aq.STANDARD_NAME,aq.STANDARD_ID,reply.REPLY,reply.REPLY_TIME,t2.UNAME ANSWERER,
reply.APPENDIX,reply.APPENDIX_ID,reply.APPENDIX_NAME
FROM ask_questions aq
LEFT JOIN reply ON aq.ID = reply.ASK_ID AND reply.STATE = '0'
LEFT JOIN ts_user t1 ON t1.USID = aq.QUESTIONER
LEFT JOIN ts_user t2 ON t2.USID = reply.ANSWERER
LEFT JOIN ask_user au ON au.ASK_ID = aq.ID
<where>
<if test="askQuestions.answerer != null and askQuestions.answerer != ''">
AND au.USID = #{askQuestions.answerer}
</if>
<if test="askQuestions.classification !=null and askQuestions.classification !=''">
AND aq.CLASSIFICATION = #{askQuestions.classification}
</if>
</where>
</select>
<select id="getReplyDetailsByStandId" resultType="com.adc.da.slrs.StandardQA.entity.AskQuestions">
SELECT aq.ID,aq.CLASSIFICATION,aq.PROBLEM_DESCRIPTION,t1.UNAME QUESTIONER,aq.QUESTION_TIME,aq.STANDARD_ENCDOING,
aq.STANDARD_NAME,aq.STANDARD_ID,reply.REPLY,reply.REPLY_TIME,t2.UNAME ANSWERER,
reply.APPENDIX,reply.APPENDIX_ID,reply.APPENDIX_NAME
FROM ask_questions aq
LEFT JOIN reply ON aq.ID = reply.ASK_ID AND reply.STATE = '0'
LEFT JOIN ts_user t1 ON t1.USID = aq.QUESTIONER
LEFT JOIN ts_user t2 ON t2.USID = reply.ANSWERER
LEFT JOIN ask_user au ON au.ASK_ID = aq.ID
<where>
<if test="askQuestions.standardId !=null and askQuestions.standardId !=''">
AND aq.STANDARD_ID = #{askQuestions.standardId}
</if>
</where>
</select>
<select id="getAskQuestionsBySubscription" resultType="com.adc.da.slrs.StandardQA.entity.AskQuestions">
SELECT
DISTINCT
aq.STANDARD_ID,aq.CLASSIFICATION,aq.STANDARD_ENCDOING,aq.STANDARD_NAME
FROM ask_questions aq
LEFT JOIN reply ON aq.ID = reply.ASK_ID
LEFT JOIN ts_user t1 ON t1.USID = aq.QUESTIONER
LEFT JOIN ts_user t2 ON t2.USID = reply.ANSWERER
LEFT JOIN subscription su ON su.ASK_ID = aq.ID
<where>
<if test="askQuestions.answerer !=null and askQuestions.answerer !=''">
AND su.USID = #{askQuestions.answerer}
</if>
<if test="askQuestions.classification !=null and askQuestions.classification !=''">
AND aq.CLASSIFICATION = #{askQuestions.classification}
</if>
</where>
</select>
<select id="retrieve" resultType="com.adc.da.slrs.StandardQA.entity.AskQuestions">
SELECT
DISTINCT
aq.STANDARD_ID,aq.CLASSIFICATION,aq.STANDARD_ENCDOING,aq.STANDARD_NAME
FROM ask_questions aq
LEFT JOIN reply ON aq.ID = reply.ASK_ID
LEFT JOIN ts_user t1 ON t1.USID = aq.QUESTIONER
LEFT JOIN ts_user t2 ON t2.USID = reply.ANSWERER
<if test="askQuestions.type == 'myAns'">
LEFT JOIN ask_user au ON au.ASK_ID = aq.ID
</if>
<if test="askQuestions.type == 'mySub'">
LEFT JOIN subscription su ON su.ASK_ID = aq.ID
</if>
<where>
<if test="askQuestions.questioner != null and askQuestions.questioner != ''">
AND aq.QUESTIONER =#{askQuestions.questioner}
</if>
<if test="askQuestions.id != null and askQuestions.id != ''">
AND aq.ID = #{askQuestions.id}
</if>
<if test="askQuestions.standardId !=null and askQuestions.standardId !=''">
AND aq.STANDARD_ID = #{askQuestions.standardId}
</if>
<if test="askQuestions.classification != null and askQuestions.classification != ''">
AND aq.CLASSIFICATION = #{askQuestions.classification}
</if>
<if test="askQuestions.standardEncdoing != null and askQuestions.standardEncdoing != ''">
AND aq.STANDARD_ENCDOING LIKE concat(concat('%',#{askQuestions.standardEncdoing}),'%')
</if>
<if test="askQuestions.standardName != null and askQuestions.standardName !=''">
AND aq.STANDARD_NAME LIKE concat(concat('%',#{askQuestions.standardName}),'%')
</if>
<if test="askQuestions.subscription !=null and askQuestions.subscription !=''">
AND su.USID = #{askQuestions.subscription}
</if>
<if test="askQuestions.answerer != null and askQuestions.answerer != ''">
AND au.USID = #{askQuestions.answerer}
</if>
<if test="askQuestions.problemDescription != null and askQuestions.problemDescription != ''">
AND aq.PROBLEM_DESCRIPTION LIKE concat(concat('%',#{askQuestions.problemDescription}),'%')
</if>
<if test="askQuestions.answerer !=null and askQuestions.answerer !=''">
AND reply.ANSWERER = #{askQuestions.answerer}
</if>
</where>
</select>
<select id="getSubscriptionByStandId" resultType="com.adc.da.slrs.StandardQA.entity.AskQuestions">
SELECT aq.ID,aq.CLASSIFICATION,aq.PROBLEM_DESCRIPTION,t1.UNAME QUESTIONER,aq.QUESTION_TIME,aq.STANDARD_ENCDOING,
aq.STANDARD_NAME,aq.STANDARD_ID,reply.REPLY,reply.REPLY_TIME,t2.UNAME ANSWERER,
reply.APPENDIX,reply.APPENDIX_ID,reply.APPENDIX_NAME
FROM ask_questions aq
LEFT JOIN reply ON aq.ID = reply.ASK_ID AND reply.STATE = '0'
LEFT JOIN ts_user t1 ON t1.USID = aq.QUESTIONER
LEFT JOIN ts_user t2 ON t2.USID = reply.ANSWERER
LEFT JOIN subscription su ON su.ASK_ID = aq.ID
<where>
<if test="askQuestions.answerer !=null and askQuestions.answerer !=''">
AND su.USID = #{askQuestions.answerer}
</if>
<if test="askQuestions.classification !=null and askQuestions.classification !=''">
AND aq.CLASSIFICATION = #{askQuestions.classification}
</if>
<if test="askQuestions.standardId !=null and askQuestions.standardId !=''">
AND aq.STANDARD_ID = #{askQuestions.standardId}
</if>
</where>
</select>
<select id="resemblance" resultType="com.adc.da.slrs.StandardQA.entity.AskQuestions">
SELECT *,
<foreach item="item" collection="chars" separator="+" open="(" close=")" index="">
(case when PROBLEM_DESCRIPTION like CONCAT('%',#{item},'%') then 1 else 0 end)
</foreach>
as num from ask_questions having num >1 order by num DESC
</select>
<select id="getUId" resultType="java.lang.String">
SELECT tu.USID
FROM ts_user tu
LEFT JOIN ts_institution ti ON ti.id = tu.INSTITUTION_ID
WHERE
ti.`name`='标准法规部'
</select>
</mapper>
@@ -19,10 +19,6 @@ import java.util.Map;
@Slf4j @Slf4j
public class SyncUserService { public class SyncUserService {
public static void main(String[] args) throws Exception {
SyncUserService syncUserService=new SyncUserService();
syncUserService.syncFotonUser();
}
/** /**
* 同步福田IDM数据 * 同步福田IDM数据
@@ -46,12 +42,11 @@ public class SyncUserService {
System.out.println("RequestBody:" + params.toString()); System.out.println("RequestBody:" + params.toString());
// 用户测试 // 用户测试
String rs = util.getResponseFromServer("http://idmsync.foton.com.cn/rest/users/getUserList", params); String rs = util.getResponseFromServer("http://idmsync.foton.com.cn/rest/users/getUserList", params);
log.debug(rs);
json.add(rs);
JSONObject responseStr = JSON.parseObject(rs); JSONObject responseStr = JSON.parseObject(rs);
System.out.println(rs); if(responseStr.containsKey("status") && responseStr.getBoolean("status")){
log.info(rs); json.add(rs);
}
if (responseStr.containsKey("cookie")) { if (responseStr.containsKey("cookie")) {
try { try {
JSONArray entries = responseStr.getJSONArray("cookie"); JSONArray entries = responseStr.getJSONArray("cookie");
@@ -63,6 +58,7 @@ public class SyncUserService {
cookie[i] = (byte) entries.getByte(i); cookie[i] = (byte) entries.getByte(i);
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(),e);
if (e.getMessage().contains("is not a JSONArray")) { if (e.getMessage().contains("is not a JSONArray")) {
cookie = null; cookie = null;
} }
@@ -92,13 +88,11 @@ public class SyncUserService {
params.put("basedn", "ou=Organizations,o=foton.com.cn,o=isp"); params.put("basedn", "ou=Organizations,o=foton.com.cn,o=isp");
// 组织测试 // 组织测试
String rs = util.getResponseFromServer("http://idmsync.foton.com.cn/rest/orgs/getOrgList", params); String rs = util.getResponseFromServer("http://idmsync.foton.com.cn/rest/orgs/getOrgList", params);
json.add(rs);
JSONObject responseStr = JSONObject.parseObject(rs);
System.out.println(responseStr);
log.info(rs); log.info(rs);
JSONObject responseStr = JSONObject.parseObject(rs);
if(responseStr.containsKey("status") && responseStr.getBoolean("status")){
json.add(rs);
}
if (responseStr.containsKey("cookie")) { if (responseStr.containsKey("cookie")) {
try { try {
JSONArray entries = responseStr.getJSONArray("cookie"); JSONArray entries = responseStr.getJSONArray("cookie");
@@ -110,14 +104,12 @@ public class SyncUserService {
cookie[i] = (byte) entries.getByte(i); cookie[i] = (byte) entries.getByte(i);
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println(e); log.error(e.getMessage(),e);
e.printStackTrace();
if (e.getMessage().contains("is not a JSONArray")) { if (e.getMessage().contains("is not a JSONArray")) {
cookie = null; cookie = null;
} }
} }
} }
} while (cookie != null); } while (cookie != null);
return json; return json;
} }