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();
...@@ -251,7 +256,7 @@ public class DemoWebApiController { ...@@ -251,7 +256,7 @@ public class DemoWebApiController {
stopWatch.stop(); stopWatch.stop();
log.info("本地事项总数:{},{}s", allList.size(), stopWatch.getLastTaskTimeMillis() / 1000); log.info("本地事项总数:{},{}s", allList.size(), stopWatch.getLastTaskTimeMillis() / 1000);
} }
// stopWatch.stop(); // stopWatch.stop();
log.info("本地事项总数:{},{}s", allList.size(), stopWatch.getLastTaskTimeMillis() / 1000); log.info("本地事项总数:{},{}s", allList.size(), stopWatch.getLastTaskTimeMillis() / 1000);
} }
...@@ -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();
......
...@@ -4,141 +4,145 @@ import com.mortals.framework.ap.GlobalSysInfo; ...@@ -4,141 +4,145 @@ import com.mortals.framework.ap.GlobalSysInfo;
public final class Constant { public final class Constant {
/** /**
* UTF-8 字符集 * UTF-8 字符集
*/ */
public static final String UTF8 = "UTF-8"; public static final String UTF8 = "UTF-8";
/** /**
* GBK 字符集 * GBK 字符集
*/ */
public static final String GBK = "GBK"; public static final String GBK = "GBK";
/** /**
* http请求 * http请求
*/ */
public static final String HTTP = "http://"; public static final String HTTP = "http://";
/**
* 站点编号分隔符
*/
public static final String SITE_SPLIT_MARK = "-";
/**
* 站点编号补零位数
*/
public static final Integer SITE_CODE_NUM = 4;
/**
* 最大重试次数
*/
public static final Integer MAX_RETRY_COUNT = 5;
/**
* 验证码有效期(分钟)
*/
public static final Integer CAPTCHA_EXPIRATION = 2;
/**
* 登录设备 redis key
*/
public static final String LOGIN_TOKEN_KEY = "user:login:tokens:";
/**
* 令牌
*/
public static final String TOKEN = "token";
/**
* 令牌前缀
*/
public static final String TOKEN_PREFIX = "Bearer ";
/**
* 令牌前缀
*/
public static final String LOGIN_USER_KEY = "login_user_key";
/**
* domain
*/
public static final String DOMAIN = "domain";
/**
* 基础代码版本 Z-BASE.MANAGER-S1.0.0
*/
public final static String BASEMANAGER_VERSION = "Z-BASE.MANAGER-S1.0.0";
/**
* 服务器http
*/
public final static String PARAM_SERVER_HTTP_IMAGE_URL = "server_http_image_url";
/**
* 身份证加密key
*/
public static final String MYSQL_KEY = "xhx-85435158";
/**
* 政务网部门地址
*/
public static final String GOV_DEPT_URL = "gov_dept_url";
/**
* 政务网个人服务地址
*/
public static final String GOV_GR_URL = "gov_gr_url";
/**
* 政务网法人服务地址
*/
public static final String GOV_FR_URL = "gov_fr_url";
/**
* 政务网乡镇主题服务地址
*/
public static final String GOV_TOWN_URL = "gov_town_url";
/**
* 政务网公共服务地址
*/
public static final String GOV_PUB_URL = "gov_pub_url";
/**
* 政务网事项地址
*/
public static final String GOV_MATTER_URL = "gov_matter_url";
/**
* 政务网事项分页地址
*/
public static final String GOV_MATTER_PAGELIST_URL = "gov_matter_pagelist_url";
/**
* 站点编号分隔符
*/
public static final String SITE_SPLIT_MARK = "-";
/** /**
* 站点编号补零位数 * app不是基础地址
*/ */
public static final Integer SITE_CODE_NUM = 4; public static final String APP_BASE_DISTRIBUTE_PATH = "app_base_distribute_path";
/** /**
* 验证码有效期(分钟) * 版本前缀
*/ */
public static final Integer CAPTCHA_EXPIRATION = 2; public static final String VERSION_PREFIX = "V";
/**
* 登录设备 redis key
*/
public static final String LOGIN_TOKEN_KEY = "user:login:tokens:";
/** /**
* 令牌 * 服务器http
*/ */
public static final String TOKEN = "token"; public final static String PARAM_SERVER_HTTP_URL = "server_http_url";
/**
* 服务器http
*/
public final static String PARAM_SERVER_PHP_HTTP_URL = "server_php_http_url";
/** public final static String CUSTAPP_ROOT_PATH = "app";
* 令牌前缀
*/
public static final String TOKEN_PREFIX = "Bearer ";
/**
* 令牌前缀
*/
public static final String LOGIN_USER_KEY = "login_user_key";
public final static String USER_SITE_TREE = "user:site:tree";
/**
* domain
*/
public static final String DOMAIN = "domain";
/** 基础代码版本 Z-BASE.MANAGER-S1.0.0 */
public final static String BASEMANAGER_VERSION = "Z-BASE.MANAGER-S1.0.0";
/**
* 服务器http
*/
public final static String PARAM_SERVER_HTTP_IMAGE_URL = "server_http_image_url";
/**
* 身份证加密key
*/
public static final String MYSQL_KEY = "xhx-85435158";
/**
* 政务网部门地址
*/
public static final String GOV_DEPT_URL = "gov_dept_url";
/**
* 政务网个人服务地址
*/
public static final String GOV_GR_URL = "gov_gr_url";
/**
* 政务网法人服务地址
*/
public static final String GOV_FR_URL = "gov_fr_url";
/**
* 政务网乡镇主题服务地址
*/
public static final String GOV_TOWN_URL = "gov_town_url";
/**
* 政务网公共服务地址
*/
public static final String GOV_PUB_URL = "gov_pub_url";
/**
* 政务网事项地址
*/
public static final String GOV_MATTER_URL = "gov_matter_url";
/**
* 政务网事项分页地址
*/
public static final String GOV_MATTER_PAGELIST_URL = "gov_matter_pagelist_url";
/**
* app不是基础地址
*/
public static final String APP_BASE_DISTRIBUTE_PATH = "app_base_distribute_path";
/**
* 版本前缀
*/
public static final String VERSION_PREFIX = "V";
/**
* 服务器http
*/
public final static String PARAM_SERVER_HTTP_URL = "server_http_url";
/**
* 服务器http
*/
public final static String PARAM_SERVER_PHP_HTTP_URL = "server_php_http_url";
public final static String CUSTAPP_ROOT_PATH = "app";
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,71 +1025,104 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter ...@@ -1020,71 +1025,104 @@ 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;
try { Boolean bool = false;
if (ObjectUtils.isEmpty(matterEntity.getUrl())) { String msg = "";
return Rest.fail("事项url不能为空!"); int reCount = 0;
} while (reCount < MAX_RETRY_COUNT) {
Document dom = Jsoup.connect(matterEntity.getUrl()).timeout(60 * 1000).get(); try {
// html = Jsoup.connect(matterEntity.getUrl()).get().body().html(); if (ObjectUtils.isEmpty(matterEntity.getUrl())) {
// html = HttpUtil.get(matterEntity.getUrl()); bool = true;
//System.out.println(html); msg = "事项url不能为空!";
// log.info("build detail:" + matterEntity.getMatterNo()); break;
//设置基本属性值 //return Rest.fail("事项url不能为空!");
Setting baseInfoSetting = interceptorConfig.getBaseInfoSetting(); }
Setting sqclInfoSetting = interceptorConfig.getSqclInfoSetting(); Document dom = Jsoup.connect(matterEntity.getUrl()).timeout(60 * 1000).get();
// html = Jsoup.connect(matterEntity.getUrl()).get().body().html();
// html = HttpUtil.get(matterEntity.getUrl());
//System.out.println(html);
// log.info("build detail:" + matterEntity.getMatterNo());
//设置基本属性值
Setting baseInfoSetting = interceptorConfig.getBaseInfoSetting();
Setting sqclInfoSetting = interceptorConfig.getSqclInfoSetting();
/* if(!ObjectUtils.isEmpty(matterEntity.getDeptCode())&&ObjectUtils.isEmpty(matterEntity.getDeptName())){ /* if(!ObjectUtils.isEmpty(matterEntity.getDeptCode())&&ObjectUtils.isEmpty(matterEntity.getDeptName())){
DeptEntity extCache = deptService.getExtCache(matterEntity.getDeptCode()); DeptEntity extCache = deptService.getExtCache(matterEntity.getDeptCode());
matterEntity.setDeptName(extCache==null?"":extCache.getName()); matterEntity.setDeptName(extCache==null?"":extCache.getName());
}*/ }*/
//根据本地与远端事项版本觉得是否更新或者新增 //根据本地与远端事项版本觉得是否更新或者新增
Integer matterEditionLocal = DataUtil.converStr2Int(matterEntity.getMatterEdition(), 0); Integer matterEditionLocal = DataUtil.converStr2Int(matterEntity.getMatterEdition(), 0);
Map<String, String> baseInfoMap = MatterDetailHtmlParseUtil.getbaseInfoMapByHtml(dom); Map<String, String> baseInfoMap = MatterDetailHtmlParseUtil.getbaseInfoMapByHtml(dom);
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());
//构建基础信息参数 //构建基础信息参数
savebaseInfo(matterEntity, baseInfoMap, baseInfoSetting); savebaseInfo(matterEntity, baseInfoMap, baseInfoSetting);
//更新材料属性 //更新材料属性
saveDatumInfo(matterEntity, context, dom, sqclInfoSetting); saveDatumInfo(matterEntity, context, dom, sqclInfoSetting);
//更新受理条件 //更新受理条件
saveSltjInfo(matterEntity, context, dom); saveSltjInfo(matterEntity, context, dom);
//更新办理流程 //更新办理流程
saveBllcInfo(matterEntity, context, dom); saveBllcInfo(matterEntity, context, dom);
//更新收费标准 //更新收费标准
saveSfbzInfo(matterEntity, context, dom); saveSfbzInfo(matterEntity, context, dom);
//设定依据 //设定依据
saveSdyjInfo(matterEntity, context, dom); saveSdyjInfo(matterEntity, context, dom);
//中介服务 //中介服务
saveZjfwInfo(matterEntity, context, dom); saveZjfwInfo(matterEntity, context, dom);
//常见问题 //常见问题
saveCjwtInfo(matterEntity, context, dom); saveCjwtInfo(matterEntity, context, dom);
//更新事项更新标志 //更新事项更新标志
matterEntity.setHaveGetMatterInfo("true"); matterEntity.setHaveGetMatterInfo("true");
} catch (Exception e) { } catch (SocketTimeoutException readTimeoutException) {
log.error(String.format("获取详细异常! id:%s,matterCode:%s,url:%s", matterEntity.getId(), matterEntity.getMatterNo(), matterEntity.getUrl()), e); log.info("请求超时,休眠后重试");
return Rest.fail("更新事项失败!" + e.getMessage()); reCount++;
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
}
} catch (ConnectException connectException) {
log.info("链接拒绝,休眠后重试");
reCount++;
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
}
} catch (Exception e) {
log.error(String.format("获取详细异常! id:%s,matterCode:%s,url:%s", matterEntity.getId(), matterEntity.getMatterNo(), matterEntity.getUrl()), e);
bool = true;
msg = e.getMessage();
break;
// return Rest.fail("更新事项失败!" + e.getMessage());
}
} }
return Rest.ok("更新详细成功!"); if (bool) {
return Rest.fail(msg);
} else {
return Rest.ok("更新详细成功!");
}
} }
......
...@@ -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