Commit 6d6be053 authored by 赵啸非's avatar 赵啸非

修改同步事项

parent 680464c1
...@@ -14,6 +14,9 @@ import com.mortals.xhx.common.code.DxTypeEnum; ...@@ -14,6 +14,9 @@ import com.mortals.xhx.common.code.DxTypeEnum;
import com.mortals.xhx.common.code.SourceEnum; import com.mortals.xhx.common.code.SourceEnum;
import com.mortals.xhx.common.code.YesNoEnum; import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.keys.RedisCacheKeys; import com.mortals.xhx.common.keys.RedisCacheKeys;
import com.mortals.xhx.module.business.model.BusinessMatterEntity;
import com.mortals.xhx.module.business.model.BusinessMatterQuery;
import com.mortals.xhx.module.business.service.BusinessMatterService;
import com.mortals.xhx.module.dept.model.DeptEntity; import com.mortals.xhx.module.dept.model.DeptEntity;
import com.mortals.xhx.module.dept.model.DeptQuery; import com.mortals.xhx.module.dept.model.DeptQuery;
import com.mortals.xhx.module.dept.service.DeptService; import com.mortals.xhx.module.dept.service.DeptService;
...@@ -79,6 +82,8 @@ public class DemoWebApiController { ...@@ -79,6 +82,8 @@ public class DemoWebApiController {
private SiteThemeService siteThemeService; private SiteThemeService siteThemeService;
@Autowired @Autowired
private SiteThemeMatterService siteThemeMatterService; private SiteThemeMatterService siteThemeMatterService;
@Autowired
private BusinessMatterService businessMatterService;
@PostMapping(value = "testGov") @PostMapping(value = "testGov")
...@@ -240,7 +245,7 @@ public class DemoWebApiController { ...@@ -240,7 +245,7 @@ public class DemoWebApiController {
ArrayList<MatterEntity> allList = new ArrayList<>(); ArrayList<MatterEntity> allList = new ArrayList<>();
if (count > 0) { if (count > 0) {
//分页获取 //分页获取
int pages = count / 500+1; int pages = count / 500 + 1;
for (int i = 1; i <= pages; i++) { for (int i = 1; i <= pages; i++) {
stopWatch.start("开始同步事项方法"); stopWatch.start("开始同步事项方法");
PageInfo pageInfo = new PageInfo(); PageInfo pageInfo = new PageInfo();
...@@ -282,8 +287,45 @@ public class DemoWebApiController { ...@@ -282,8 +287,45 @@ public class DemoWebApiController {
} }
@PostMapping(value = "saveWinMatters")
@UnAuth
public Rest<String> saveWinMatters(@RequestBody WindowMatterQuery windowMatterQuery) {
log.info("保存窗口站点==");
BusinessMatterQuery businessMatterQuery = new BusinessMatterQuery();
businessMatterQuery.setSiteBusinessId(17L);
List<BusinessMatterEntity> businessMatterEntities = businessMatterService.find(businessMatterQuery);
List<Long> windowIdList = windowMatterQuery.getWindowIdList();
for (Long windowId : windowIdList) {
List<WindowMatterEntity> windowMatterEntities = businessMatterEntities.stream().map(item -> {
WindowMatterEntity windowMatterEntity = new WindowMatterEntity();
WindowEntity cache = windowService.getCache(windowId.toString());
windowMatterEntity.setWindowId(cache.getId());
windowMatterEntity.setWindowName(cache.getName());
windowMatterEntity.setSiteMatterId(item.getMatterId());
windowMatterEntity.setMatterName(item.getMatterName());
windowMatterEntity.setDeptId(50L);
windowMatterEntity.setDeptCode("3890499118653034496");
windowMatterEntity.setDeptName("县行政审批局");
windowMatterEntity.setCreateTime(new Date());
windowMatterEntity.setCreateUserId(1L);
return windowMatterEntity;
}).collect(Collectors.toList());
windowMatterService.getDao().insertBatch(windowMatterEntities);
}
return Rest.ok();
}
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(1001/500); System.out.println(1001 / 500);
/* HttpClient http = null; /* HttpClient http = null;
CookieStore httpCookieStore = new BasicCookieStore(); CookieStore httpCookieStore = new BasicCookieStore();
......
...@@ -28,6 +28,10 @@ public final class Constant { ...@@ -28,6 +28,10 @@ public final class Constant {
* 站点编号补零位数 * 站点编号补零位数
*/ */
public static final Integer SITE_CODE_NUM = 4; public static final Integer SITE_CODE_NUM = 4;
/**
* 最大重试次数
*/
public static final Integer MAX_RETRY_COUNT = 5;
/** /**
...@@ -61,7 +65,9 @@ public final class Constant { ...@@ -61,7 +65,9 @@ public final class Constant {
*/ */
public static final String DOMAIN = "domain"; public static final String DOMAIN = "domain";
/** 基础代码版本 Z-BASE.MANAGER-S1.0.0 */ /**
* 基础代码版本 Z-BASE.MANAGER-S1.0.0
*/
public final static String BASEMANAGER_VERSION = "Z-BASE.MANAGER-S1.0.0"; public final static String BASEMANAGER_VERSION = "Z-BASE.MANAGER-S1.0.0";
...@@ -118,7 +124,6 @@ public final class Constant { ...@@ -118,7 +124,6 @@ public final class Constant {
public static final String APP_BASE_DISTRIBUTE_PATH = "app_base_distribute_path"; public static final String APP_BASE_DISTRIBUTE_PATH = "app_base_distribute_path";
/** /**
* 版本前缀 * 版本前缀
*/ */
...@@ -137,7 +142,6 @@ public final class Constant { ...@@ -137,7 +142,6 @@ public final class Constant {
public final static String CUSTAPP_ROOT_PATH = "app"; public final static String CUSTAPP_ROOT_PATH = "app";
public final static String USER_SITE_TREE = "user:site:tree"; public final static String USER_SITE_TREE = "user:site:tree";
......
...@@ -39,6 +39,7 @@ import com.mortals.xhx.module.site.service.SiteThemeMatterService; ...@@ -39,6 +39,7 @@ import com.mortals.xhx.module.site.service.SiteThemeMatterService;
import com.mortals.xhx.module.site.service.SiteThemeService; import com.mortals.xhx.module.site.service.SiteThemeService;
import com.mortals.xhx.module.window.model.WindowMatterQuery; import com.mortals.xhx.module.window.model.WindowMatterQuery;
import com.mortals.xhx.module.window.service.WindowMatterService; import com.mortals.xhx.module.window.service.WindowMatterService;
import io.netty.handler.timeout.ReadTimeoutException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
...@@ -49,9 +50,13 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -49,9 +50,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.mortals.xhx.common.key.Constant.MAX_RETRY_COUNT;
/** /**
* MatterService * MatterService
* 基础事项 service实现 * 基础事项 service实现
...@@ -1020,10 +1025,17 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter ...@@ -1020,10 +1025,17 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
@Override @Override
public Rest<String> buildMatterDetail(MatterEntity matterEntity, Context context) { public Rest<String> buildMatterDetail(MatterEntity matterEntity, Context context) {
//根据事项url 获取事项详细信息,构建相关详细信息 //根据事项url 获取事项详细信息,构建相关详细信息
String html = null; // String html = null;
Boolean bool = false;
String msg = "";
int reCount = 0;
while (reCount < MAX_RETRY_COUNT) {
try { try {
if (ObjectUtils.isEmpty(matterEntity.getUrl())) { if (ObjectUtils.isEmpty(matterEntity.getUrl())) {
return Rest.fail("事项url不能为空!"); bool = true;
msg = "事项url不能为空!";
break;
//return Rest.fail("事项url不能为空!");
} }
Document dom = Jsoup.connect(matterEntity.getUrl()).timeout(60 * 1000).get(); Document dom = Jsoup.connect(matterEntity.getUrl()).timeout(60 * 1000).get();
// html = Jsoup.connect(matterEntity.getUrl()).get().body().html(); // html = Jsoup.connect(matterEntity.getUrl()).get().body().html();
...@@ -1045,10 +1057,13 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter ...@@ -1045,10 +1057,13 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
Integer matterEditionRemote = DataUtil.converStr2Int(baseInfoMap.getOrDefault("事项版本", "0"), 0); Integer matterEditionRemote = DataUtil.converStr2Int(baseInfoMap.getOrDefault("事项版本", "0"), 0);
if (matterEditionLocal >= matterEditionRemote) { if (matterEditionLocal >= matterEditionRemote) {
return Rest.fail("本地事项版本大于等于远端,不需要更新!"); bool = true;
msg = "本地事项版本大于等于远端,不需要更新!!";
break;
// return Rest.fail("本地事项版本大于等于远端,不需要更新!");
} }
log.info("更新详细事项==>{},version==>{}",matterEntity.getMatterName(),matterEditionRemote); log.info("更新详细事项==>{},version==>{}", matterEntity.getMatterName(), matterEditionRemote);
//更新部门信息 //更新部门信息
DeptEntity extCache = deptService.getExtCache(matterEntity.getDeptCode()); DeptEntity extCache = deptService.getExtCache(matterEntity.getDeptCode());
matterEntity.setDeptName(extCache == null ? "" : extCache.getName()); matterEntity.setDeptName(extCache == null ? "" : extCache.getName());
...@@ -1080,13 +1095,36 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter ...@@ -1080,13 +1095,36 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
//更新事项更新标志 //更新事项更新标志
matterEntity.setHaveGetMatterInfo("true"); matterEntity.setHaveGetMatterInfo("true");
} catch (SocketTimeoutException readTimeoutException) {
log.info("请求超时,休眠后重试");
reCount++;
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
}
} catch (ConnectException connectException) {
log.info("链接拒绝,休眠后重试");
reCount++;
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
}
} catch (Exception e) { } catch (Exception e) {
log.error(String.format("获取详细异常! id:%s,matterCode:%s,url:%s", matterEntity.getId(), matterEntity.getMatterNo(), matterEntity.getUrl()), e); log.error(String.format("获取详细异常! id:%s,matterCode:%s,url:%s", matterEntity.getId(), matterEntity.getMatterNo(), matterEntity.getUrl()), e);
return Rest.fail("更新事项失败!" + e.getMessage()); bool = true;
msg = e.getMessage();
break;
// return Rest.fail("更新事项失败!" + e.getMessage());
}
} }
if (bool) {
return Rest.fail(msg);
} else {
return Rest.ok("更新详细成功!"); return Rest.ok("更新详细成功!");
} }
}
private void saveCjwtInfo(MatterEntity matterEntity, Context context, Document dom) { private void saveCjwtInfo(MatterEntity matterEntity, Context context, Document dom) {
matterQuestionService.deleteByMatterId(matterEntity.getId(), context); matterQuestionService.deleteByMatterId(matterEntity.getId(), context);
......
...@@ -130,6 +130,14 @@ Content-Type: application/json ...@@ -130,6 +130,14 @@ Content-Type: application/json
"areaCode":"511500000000" "areaCode":"511500000000"
} }
###test saveWinMatters
POST {{baseUrl}}/test/saveWinMatters
Content-Type: application/json
{
"windowIdList":[11,12,13,14,15,16]
}
###testre ###testre
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment