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

修改同步事项

parent 680464c1
......@@ -14,6 +14,9 @@ import com.mortals.xhx.common.code.DxTypeEnum;
import com.mortals.xhx.common.code.SourceEnum;
import com.mortals.xhx.common.code.YesNoEnum;
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.DeptQuery;
import com.mortals.xhx.module.dept.service.DeptService;
......@@ -79,6 +82,8 @@ public class DemoWebApiController {
private SiteThemeService siteThemeService;
@Autowired
private SiteThemeMatterService siteThemeMatterService;
@Autowired
private BusinessMatterService businessMatterService;
@PostMapping(value = "testGov")
......@@ -240,7 +245,7 @@ public class DemoWebApiController {
ArrayList<MatterEntity> allList = new ArrayList<>();
if (count > 0) {
//分页获取
int pages = count / 500+1;
int pages = count / 500 + 1;
for (int i = 1; i <= pages; i++) {
stopWatch.start("开始同步事项方法");
PageInfo pageInfo = new PageInfo();
......@@ -251,7 +256,7 @@ public class DemoWebApiController {
stopWatch.stop();
log.info("本地事项总数:{},{}s", allList.size(), stopWatch.getLastTaskTimeMillis() / 1000);
}
// stopWatch.stop();
// stopWatch.stop();
log.info("本地事项总数:{},{}s", allList.size(), stopWatch.getLastTaskTimeMillis() / 1000);
}
......@@ -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) {
System.out.println(1001/500);
System.out.println(1001 / 500);
/* HttpClient http = null;
CookieStore httpCookieStore = new BasicCookieStore();
......
......@@ -4,141 +4,145 @@ import com.mortals.framework.ap.GlobalSysInfo;
public final class Constant {
/**
* UTF-8 字符集
*/
public static final String UTF8 = "UTF-8";
/**
* GBK 字符集
*/
public static final String GBK = "GBK";
/**
* http请求
*/
public static final String HTTP = "http://";
/**
* UTF-8 字符集
*/
public static final String UTF8 = "UTF-8";
/**
* GBK 字符集
*/
public static final String GBK = "GBK";
/**
* 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 = "-";
/**
* 站点编号补零位数
*/
public static final Integer SITE_CODE_NUM = 4;
/**
* app不是基础地址
*/
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:";
/**
* 令牌
*/
public static final String TOKEN = "token";
/**
* 服务器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 static final String TOKEN_PREFIX = "Bearer ";
public final static String CUSTAPP_ROOT_PATH = "app";
/**
* 令牌前缀
*/
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";
/**
* 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";
public final static String USER_SITE_TREE = "user:site:tree";
}
......@@ -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.window.model.WindowMatterQuery;
import com.mortals.xhx.module.window.service.WindowMatterService;
import io.netty.handler.timeout.ReadTimeoutException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
......@@ -49,9 +50,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.util.*;
import java.util.stream.Collectors;
import static com.mortals.xhx.common.key.Constant.MAX_RETRY_COUNT;
/**
* MatterService
* 基础事项 service实现
......@@ -1020,71 +1025,104 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
@Override
public Rest<String> buildMatterDetail(MatterEntity matterEntity, Context context) {
//根据事项url 获取事项详细信息,构建相关详细信息
String html = null;
try {
if (ObjectUtils.isEmpty(matterEntity.getUrl())) {
return Rest.fail("事项url不能为空!");
}
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();
// String html = null;
Boolean bool = false;
String msg = "";
int reCount = 0;
while (reCount < MAX_RETRY_COUNT) {
try {
if (ObjectUtils.isEmpty(matterEntity.getUrl())) {
bool = true;
msg = "事项url不能为空!";
break;
//return Rest.fail("事项url不能为空!");
}
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())){
DeptEntity extCache = deptService.getExtCache(matterEntity.getDeptCode());
matterEntity.setDeptName(extCache==null?"":extCache.getName());
}*/
//根据本地与远端事项版本觉得是否更新或者新增
Integer matterEditionLocal = DataUtil.converStr2Int(matterEntity.getMatterEdition(), 0);
Map<String, String> baseInfoMap = MatterDetailHtmlParseUtil.getbaseInfoMapByHtml(dom);
Integer matterEditionRemote = DataUtil.converStr2Int(baseInfoMap.getOrDefault("事项版本", "0"), 0);
//根据本地与远端事项版本觉得是否更新或者新增
Integer matterEditionLocal = DataUtil.converStr2Int(matterEntity.getMatterEdition(), 0);
Map<String, String> baseInfoMap = MatterDetailHtmlParseUtil.getbaseInfoMapByHtml(dom);
Integer matterEditionRemote = DataUtil.converStr2Int(baseInfoMap.getOrDefault("事项版本", "0"), 0);
if (matterEditionLocal >= matterEditionRemote) {
return Rest.fail("本地事项版本大于等于远端,不需要更新!");
}
if (matterEditionLocal >= matterEditionRemote) {
bool = true;
msg = "本地事项版本大于等于远端,不需要更新!!";
break;
// return Rest.fail("本地事项版本大于等于远端,不需要更新!");
}
log.info("更新详细事项==>{},version==>{}",matterEntity.getMatterName(),matterEditionRemote);
//更新部门信息
DeptEntity extCache = deptService.getExtCache(matterEntity.getDeptCode());
matterEntity.setDeptName(extCache == null ? "" : extCache.getName());
log.info("更新详细事项==>{},version==>{}", matterEntity.getMatterName(), matterEditionRemote);
//更新部门信息
DeptEntity extCache = deptService.getExtCache(matterEntity.getDeptCode());
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) {
log.error(String.format("获取详细异常! id:%s,matterCode:%s,url:%s", matterEntity.getId(), matterEntity.getMatterNo(), matterEntity.getUrl()), e);
return Rest.fail("更新事项失败!" + e.getMessage());
} 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) {
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
"areaCode":"511500000000"
}
###test saveWinMatters
POST {{baseUrl}}/test/saveWinMatters
Content-Type: application/json
{
"windowIdList":[11,12,13,14,15,16]
}
###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