Commit 23fe5823 authored by “yiyousong”'s avatar “yiyousong”
parents 85afb842 653ee3a9
......@@ -89,6 +89,11 @@ public final class Constant {
*/
public static final String GOV_FR_URL = "gov_fr_url";
/**
* 政务网乡镇主题服务地址
*/
public static final String GOV_TOWN_URL = "gov_town_url";
/**
* 政务网公共服务地址
*/
......
......@@ -2,6 +2,7 @@ package com.mortals.xhx.common.utils;
import cn.hutool.core.net.url.UrlBuilder;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
......@@ -61,6 +62,40 @@ public class MatterTypeHtmlParseUtil {
return Rest.ok(resultMap);
}
/**
* 获取主题页码极总条数
*
* @param params
* @param url
* @return
*/
public static Rest<Map<String, Integer>> getTownThemeMatterPage(Map<String, String> params, String url) {
String matterTotalExp = "//input[@id=\"result_count\"]";
String matterPageExp = "//input[@id=\"pageNum\"]";
Map<String, Integer> resultMap = new HashMap<>();
try {
Document dom = Jsoup.connect(url).data(params).get();
Elements elements = dom.selectXpath(matterTotalExp);
if (elements.size() > 0) {
Integer total = elements.get(0) == null ? 0 : DataUtil.converStr2Int(elements.get(0).attr("value"), 0);
resultMap.put("total", total);
}
elements = dom.selectXpath(matterPageExp);
if (elements.size() > 0) {
Integer pageNum = elements.get(0) == null ? 0 : DataUtil.converStr2Int(elements.get(0).attr("value"), 0);
resultMap.put("pageNum", pageNum);
}
} catch (Exception e) {
log.error("获取事项数量异常!params:" + JSON.toJSONString(params), e);
return Rest.fail(e.getMessage());
}
return Rest.ok(resultMap);
}
/**
* 获取主题列表
*
......@@ -101,7 +136,7 @@ public class MatterTypeHtmlParseUtil {
* @return
*/
public static Rest<Map<String, String>> getTownThemeList(Map<String, String> params, String url) {
String ThemeListExp = "//div[@class='mainLeft fl']//ul[@class=\"fwlx_list cf\"]//li";
String ThemeListExp = "//ul[@class='fwlx_list cf']//li";
Map<String, String> map = new HashMap<>();
try {
Document dom = Jsoup.connect(url).data(params).get();
......@@ -116,9 +151,16 @@ public class MatterTypeHtmlParseUtil {
String title = element.attr("title");
//changeTheme('005', '1');
String onclick = element.attr("onclick");
List<String> list = ReUtil.findAllGroup0("'(.*?)'", onclick);
if (list.size() > 1) {
String themeCode = StrUtil.subBetween(list.get(0), "'", "'");
//1 个人服务 2 法人服务
String type = StrUtil.subBetween(list.get(1), "'", "'");
if (!"".equals(themeCode)) {
map.put(themeCode + "&" + type, title);
}
}
String themeCode = StrUtil.subBetween(onclick, "changeTheme('", "',");
map.put(themeCode, title);
}
} catch (Exception e) {
......@@ -232,6 +274,65 @@ public class MatterTypeHtmlParseUtil {
return Rest.ok(matterEntityList);
}
/**
* 乡镇服务主题获取事项列表
*
* @param params
* @param url
* @return
*/
public static Rest<List<MatterEntity>> getTownThemeMatterList(Map<String, String> params, String url) {
String matterListExp = "//div[@class=\"sx_list\"]//span[1]";
String matterListLiExp = "//div[@class=\"sx_list\"]//li/a[1]";
List<MatterEntity> matterEntityList = new ArrayList<>();
try {
Document dom = Jsoup.connect(url).data(params).get();
Elements elements = dom.selectXpath(matterListExp);
for (int i = 0; i < elements.size(); i++) {
Element element = elements.get(i);
if (element == null) {
continue;
}
String title = element.attr("title");
String href = element.firstElementChild().attr("href");
if (href.equalsIgnoreCase("javascript:void(0)")) {
continue;
}
/* String onclick = element.firstElementChild().attr("onclick");
href = StrUtil.subBetween(onclick, "ywblurl('", "',");
if (ObjectUtils.isEmpty(href)) {
continue;
}*/
buildMatter(matterEntityList, title, href);
}
elements = dom.selectXpath(matterListLiExp);
for (int i = 0; i < elements.size(); i++) {
Element element = elements.get(i);
if (element == null) {
continue;
}
String title = element.attr("title");
String href = element.attr("href");
/* String onclick = element.attr("onclick");
String href = StrUtil.subBetween(onclick, "ywblurl('", "',");
if (ObjectUtils.isEmpty(href)) {
System.out.println("子项 href is empty!,dom:" + dom.html());
continue;
}*/
buildMatter(matterEntityList, title, href);
}
} catch (Exception e) {
log.error("获取列表异常!params:" + JSON.toJSONString(params), e);
return Rest.fail(e.getMessage());
}
return Rest.ok(matterEntityList);
}
private static void buildMatter(List<MatterEntity> matterEntityList, String title, String href) {
UrlBuilder builder = UrlBuilder.ofHttp(href, CharsetUtil.CHARSET_UTF_8);
String itemCode = builder.getQuery().get("itemCode").toString();
......@@ -253,133 +354,9 @@ public class MatterTypeHtmlParseUtil {
}
public static Rest<Map<String, String>> syncThemeBySiteId(Map<String, String> params, String url) {
String deptListExp = "//ul[@class='bm-list']//li";
Map<String, String> map = new HashMap<>();
try {
Document dom = Jsoup.connect(url).data(params).get();
Elements elements = dom.selectXpath(deptListExp);
for (int i = 0; i < elements.size(); i++) {
Element element = elements.get(i);
if (element == null) {
continue;
}
String deptName = element.attr("title");
String href = element.firstElementChild().attr("href");
UrlBuilder builder = UrlBuilder.ofHttp(href, CharsetUtil.CHARSET_UTF_8);
String deptCode = builder.getQuery().get("deptCode").toString();
map.put(deptCode, deptName);
}
} catch (Exception e) {
return Rest.fail(e.getMessage());
}
return Rest.ok("当前站点同步添加部门成功!", map);
}
public static void main(String[] args) {
/* String url = "http://www.sczwfw.gov.cn/jiq/interface/item/tags";
HashMap<String, String> params = new HashMap<>();
params.put("dxType", "21");
params.put("areaCode", "510107000000");
params.put("deptCode", "");
params.put("searchtext", "");
params.put("pageno", "5");
params.put("taskType", "");
Rest<List<MatterEntity>> rest = MatterHtmlParseUtil.getMatterList(params, url);
System.out.println(rest.getData().size());*/
/* HashMap<String, String> params = new HashMap<>();
params.put("areaCode", "510116000000");
MatterHtmlParseUtil.syncDeptBySiteId(params);*/
// String url = "http://www.sczwfw.gov.cn/jiq/front/item/qlqd";
/* String url = "http://www.sczwfw.gov.cn/jiq/interface/item/tags";
HashMap<String, String> params = new HashMap<>();
params.put("areaCode", "510110006007");
params.put("dxType", "56");
params.put("deptCode", "");
params.put("searchtext", "");
params.put("taskType", "");
params.put("pageno", "1");
Rest<Map<String, Integer>> rest = MatterHtmlParseUtil.statSiteMatterCount(params, url);
System.out.println(JSON.toJSONString(rest));
List<MatterEntity> allList = new ArrayList<>();
String url1 = "http://www.sczwfw.gov.cn/jiq/interface/item/tags";
HashMap<String, String> params1 = new HashMap<>();
params1.put("dxType", "56");
params1.put("areaCode", "510110006007");
params1.put("deptCode", "");
params1.put("searchtext", "");
params1.put("taskType", "");
for (int i = 1; i <= rest.getData().get("pageNum"); i++) {
params1.put("pageno", String.valueOf(i));
//System.out.println("params:" + JSON.toJSONString(params1));
Rest<List<MatterEntity>> restList = MatterHtmlParseUtil.getMatterList(params1, url1);
if (restList.getCode() == YesNoEnum.YES.getValue() && !ObjectUtils.isEmpty(restList.getData())) {
// System.out.println("pageno:" + i + " res size:" + restList.getData().size());
allList.addAll(restList.getData());
}
}
// System.out.println("--------------------------------------------project size" + rest.getData().get("total") + "----------" + allList.size());
for (int i = 0; i < allList.size(); i++) {
System.out.println(i + " " + allList.get(i).getMatterName());
}*/
// System.out.println(JSON.toJSONString(allList));
/* String url = "http://www.sczwfw.gov.cn/jiq/interface/item/tags";
HashMap<String, String> params = new HashMap<>();
params.put("areaCode", "510110006007");
params.put("dxType", "56");
params.put("deptCode", "");
params.put("searchtext", "");
params.put("taskType", "");
params.put("pageno", "1");
Rest<Map<String, Integer>> rest = MatterTypeHtmlParseUtil.statSiteMatterCount(params, url);
System.out.println(JSON.toJSONString(rest));
List<MatterEntity> allList = new ArrayList<>();
String url1 = "http://www.sczwfw.gov.cn/jiq/interface/item/tags";
HashMap<String, String> params1 = new HashMap<>();
params1.put("dxType", "56");
params1.put("areaCode", "510110006007");
params1.put("deptCode", "");
params1.put("searchtext", "");
params1.put("taskType", "");
for (int i = 1; i <= rest.getData().get("pageNum"); i++) {
params1.put("pageno", String.valueOf(i));
Rest<List<MatterEntity>> restList = MatterTypeHtmlParseUtil.getMatterList(params1, url1);
if (restList.getCode() == YesNoEnum.YES.getValue() && !ObjectUtils.isEmpty(restList.getData())) {
allList.addAll(restList.getData());
}
}*/
// for (int i = 0; i < allList.size(); i++) {
// System.out.println(i + " " + allList.get(i).getMatterName());
// }
/* url = "http://www.sczwfw.gov.cn/jiq/front/channel/deptSwitch";
params = new HashMap<>();
params.put("areaCode", "510110006007");*/
//Rest<Map<String, String>> rest1 = MatterTypeHtmlParseUtil.syncDeptBySiteId(params, url);
//System.out.println(JSON.toJSONString(rest1));
//个人主题服务
String url = "http://www.sczwfw.gov.cn/jiq/front/item/gr_index";
/* String url = "http://www.sczwfw.gov.cn/jiq/front/item/gr_index";
HashMap<String, String> params = new HashMap<>();
params.put("areaCode", "510107000000");
Rest<Map<String, String>> grThemeRest = MatterTypeHtmlParseUtil.getThemeList(params, url);
......@@ -423,7 +400,7 @@ public class MatterTypeHtmlParseUtil {
log.info(String.format("获取数量异常,count:%s,total:%s,theme:%s", count, total, item.getKey()));
}
}
});
});*/
//System.out.println(JSON.toJSONString(allList));
......@@ -436,6 +413,46 @@ public class MatterTypeHtmlParseUtil {
}
}*/
//http://www.sczwfw.gov.cn/jiq/front/item/town?areaCode=510105521000
//村镇主题服务
String url3 = "http://www.sczwfw.gov.cn/jiq/front/item/town";
Map params3 = new HashMap<>();
params3.put("areaCode", "510105521000");
Rest<Map<String, String>> townThemeRest = MatterTypeHtmlParseUtil.getTownThemeList(params3, url3);
//System.out.println(JSON.toJSONString(townThemeRest));
HashMap<String, String> params1 = new HashMap<>();
params1.put("dxType", "54");
params1.put("areaCode", "510105521000");
params1.put("type", "1");
List<MatterEntity> allList = new ArrayList<>();
townThemeRest.getData().entrySet().stream().forEach(item -> {
String[] vals = item.getKey().split("&");
params1.put("theme", vals[0]);
params1.put("userType", vals[1]);
//http://www.sczwfw.gov.cn/jiq/interface/item/tags?dxType=54&areaCode=510105521000&theme=085&userType=1&pageno=2
String url1 = "http://www.sczwfw.gov.cn/jiq/interface/item/tags";
Rest<Map<String, Integer>> themeMatterPageRest = MatterTypeHtmlParseUtil.getTownThemeMatterPage(params1, url1);
//System.out.println("themePageRest:"+JSON.toJSONString(themeMatterPageRest));
Integer pageNum = themeMatterPageRest.getData().get("pageNum");
Integer total = themeMatterPageRest.getData().get("total");
if (pageNum > 0 && total > 0) {
int count = 0;
for (int i = 1; i <= pageNum; i++) {
params1.put("pageno", String.valueOf(i));
Rest<List<MatterEntity>> restList = MatterTypeHtmlParseUtil.getTownThemeMatterList(params1, url1);
if (restList.getCode() == YesNoEnum.YES.getValue()) {
allList.addAll(restList.getData());
count += restList.getData().size();
}
}
if (count != total) {
log.info(String.format("获取数量异常,count:%s,total:%s,theme:%s", count, total, item.getKey()));
}
}
});
}
}
......@@ -70,9 +70,7 @@ public class SyncGovMatterDetailThread implements Runnable {
Rest<String> deptRest = deptService.syncDeptBySiteId(siteEntity, context);
log.info("同步站点部门:" + JSON.toJSONString(deptRest));
Rest<String> rest = siteService.syncMatterBySiteId(siteEntity, context);
AreaEntity areaEntity = areaService.getCache(siteEntity.getAreaCode());
log.info("同步事项列表:" + JSON.toJSONString(rest));
if (rest.getCode() == YesNoEnum.YES.getValue()) {
List<MatterEntity> matterEntityList = matterService.find(new MatterQuery().areaCode(siteEntity.getAreaCode()).source(SourceEnum.政务网.getValue()));
......@@ -110,7 +108,6 @@ public class SyncGovMatterDetailThread implements Runnable {
//省,市,区
Rest<String> themeRest = siteThemeService.syncThemeBySiteId(siteEntity, context);
log.info("同步站点主题:" + JSON.toJSONString(themeRest));
log.info("同步站点个人主题事项开始.....");
siteThemeMatterService.deleteGovBySiteId(siteEntity.getId(), context);
Rest<String> grRest = siteThemeMatterService.syncThemeMatterBySiteId(siteEntity.getId(), "2", context);
......@@ -120,6 +117,8 @@ public class SyncGovMatterDetailThread implements Runnable {
log.info("同步站点主题法人事项:" + JSON.toJSONString(frRest));
}else if(areaEntity.getAreaLevel()>3){
//街道,镇,乡
Rest<String> themeTownRest = siteThemeService.syncTownThemeBySiteId(siteEntity, context);
log.info("同步乡镇站点主题:" + JSON.toJSONString(themeTownRest));
}
......
......@@ -204,8 +204,23 @@ public class AppServiceImpl extends AbstractCRUDServiceImpl<AppDao, AppEntity, L
}
@Override
protected void validData(AppEntity entity, Context context) throws AppException {
if (ObjectUtils.isEmpty(entity.getAppCode())) {
throw new AppException("应用编码不能为空!");
}
super.validData(entity, context);
}
@Override
protected void saveBefore(AppEntity entity, Context context) throws AppException {
//校验appCode是否唯一
Long siteId = entity.getSiteId();
String appCode = entity.getAppCode();
int count = this.count(new AppQuery().siteId(siteId).appCode(appCode), context);
if (count > 0) {
throw new AppException("当前站点已存在应用编码");
}
super.saveBefore(entity, context);
}
......@@ -217,7 +232,7 @@ public class AppServiceImpl extends AbstractCRUDServiceImpl<AppDao, AppEntity, L
versionEntity.setAppId(entity.getId());
versionEntity.setAppName(entity.getAppName());
versionEntity.setVersion(entity.getVersion());
versionEntity.setNotes("应用初始创建!");
versionEntity.setNotes("".equals(entity.getNotes()) ? "应用初始创建!" : entity.getNotes());
versionEntity.setFileName(entity.getFileName());
versionEntity.setFilePath(entity.getFilePath());
versionEntity.setDistributeFilePath(entity.getDistributeFilePath());
......
......@@ -16,6 +16,14 @@ public interface SiteThemeService extends ICRUDService<SiteThemeEntity,Long>{
Rest<String> syncThemeBySiteId(SiteEntity siteEntity, Context context);
/**
* 乡镇主题同步
* @param siteEntity
* @param context
* @return
*/
Rest<String> syncTownThemeBySiteId(SiteEntity siteEntity, Context context);
void deleteGovBySiteId(Long siteId, Context context);
}
\ No newline at end of file
......@@ -65,6 +65,23 @@ public class SiteThemeServiceImpl extends AbstractCRUDServiceImpl<SiteThemeDao,
return Rest.ok("当前站点同步添加主题成功!");
}
@Override
public Rest<String> syncTownThemeBySiteId(SiteEntity siteEntity, Context context) {
String url = GlobalSysInfo.getParamValue(Constant.GOV_TOWN_URL, "http://www.sczwfw.gov.cn/jiq/front/item/town");
Long siteId = siteEntity.getId();
this.deleteGovBySiteId(siteId, context);
String areaCode = siteEntity.getAreaCode();
Map<String, String> params = new HashMap<>();
params.put("areaCode", areaCode);
Rest<String> townRest = buildTwonTheme(siteId, url, params, context);
if (townRest.getCode() != YesNoEnum.YES.getValue() ) {
log.info("服务结果:" + JSON.toJSONString(townRest));
return Rest.fail("同步乡镇主题失败!");
}
return Rest.ok("当前站点同步乡镇添加主题成功!");
}
private Rest<String> buildTheme(Long siteId, String userType, String url, Map<String, String> params, Context context) {
Rest<Map<String, String>> rest = MatterTypeHtmlParseUtil.getThemeList(params, url);
if (rest.getCode() == YesNoEnum.YES.getValue() && rest.getData().keySet().size() > 0) {
......@@ -96,6 +113,35 @@ public class SiteThemeServiceImpl extends AbstractCRUDServiceImpl<SiteThemeDao,
return Rest.ok(rest.getMsg());
}
private Rest<String> buildTwonTheme(Long siteId, String url, Map<String, String> params, Context context) {
Rest<Map<String, String>> rest = MatterTypeHtmlParseUtil.getTownThemeList(params, url);
if (rest.getCode() == YesNoEnum.YES.getValue() && rest.getData().keySet().size() > 0) {
Map<String, String> data = rest.getData();
for (Map.Entry<String, String> item : data.entrySet()) {
String[] vals = item.getKey().split("&");
String themeCode = vals[0];
String userType = vals[1];
String themeName = item.getValue();
int count = this.count(new SiteThemeQuery().siteId(siteId).userType(userType).themeCode(themeCode), context);
if (count == 0) {
SiteThemeEntity siteThemeEntity = new SiteThemeEntity();
siteThemeEntity.initAttrValue();
siteThemeEntity.setSiteId(siteId);
siteThemeEntity.setUserType(userType);
siteThemeEntity.setThemeCode(themeCode);
siteThemeEntity.setThemeName(themeName);
siteThemeEntity.setCreateTime(new Date());
siteThemeEntity.setCreateUserId(getContextUserId(context));
this.save(siteThemeEntity, context);
}
}
} else {
return Rest.fail(rest.getMsg());
}
return Rest.ok(rest.getMsg());
}
@Override
public void deleteGovBySiteId(Long siteId, Context context) {
Map<String, Object> condition = new HashMap<>();
......@@ -105,14 +151,14 @@ public class SiteThemeServiceImpl extends AbstractCRUDServiceImpl<SiteThemeDao,
public static void main(String[] args) {
String str="changeTheme('005', '1')";
String str = "changeTheme('005', '1')";
String reg="'.*?'";
String reg = "'.*?'";
Pattern compile = Pattern.compile(reg);
List<String> allGroups = ReUtil.findAllGroup0(compile, str);
allGroups.forEach(item->{
allGroups.forEach(item -> {
System.out.println(item);
});
......
......@@ -41,7 +41,7 @@ Content-Type: application/json
"type":1,
"downDevCount":0,
"shelves":0,
"fileName":"窗口屏.zip",
"fileName":"窗口屏3.zip",
"filePath":"/file/uploadfile/1661928678354.zip",
"summary":"vyk2sq"
}
......@@ -66,7 +66,7 @@ Content-Type: application/json
"type":1,
"downDevCount":0,
"shelves":0,
"fileName":"窗口屏1.zip",
"fileName":"窗口屏2.zip",
"filePath":"/file/uploadfile/1664180492089.zip",
"summary":"vyk2sq"
}
......
......@@ -62,12 +62,12 @@ Accept: application/json
###自助终端应用版本使用
POST {{baseUrl}}/app/version/used?appVersionId=4
POST {{baseUrl}}/app/version/used?appVersionId=7
Authorization: {{authToken}}
Accept: application/json
###自助终端应用版本预览
GET {{baseUrl}}/app/version/preview?appVersionId=4
GET {{baseUrl}}/app/version/preview?appVersionId=5
Authorization: {{authToken}}
Accept: application/json
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