Commit b72afd8c authored by 赵啸非's avatar 赵啸非

修改域名获取逻辑

parent 176325cc
......@@ -39,6 +39,7 @@
<profiles.log.level>debug</profiles.log.level>
<package.environment>test</package.environment>
<skipUi>false</skipUi>
<showSql>false</showSql>
</properties>
</profile>
<profile>
......
......@@ -9,6 +9,7 @@ import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.util.ObjectUtils;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;
......@@ -286,13 +287,37 @@ public class MatterDetailHtmlParseUtil {
public static Map<String, String> getSfbzMapByHtml(Document dom) {
Map<String, String> resultMap = new HashMap<>();
String baseInfoExp = "//div[@class='section8']//p";
String baseInfoExp1 = "//div[@class='section8']/p";
String baseInfoExp2 = "//*[@class='section8']//div[@class='money cf']//p";
try {
Elements elements = dom.selectXpath(baseInfoExp);
StringBuilder sb = new StringBuilder();
Elements elements = dom.selectXpath(baseInfoExp1);
if (ObjectUtils.isEmpty(elements)) {
Elements elements2 = dom.selectXpath(baseInfoExp2);
for (int i = 0; i < elements2.size(); i++) {
// System.out.println(elements2.get(i).text().trim());
sb.append(elements2.get(i).text().trim());
sb.append(":");
Elements elements3 = dom.selectXpath(String.format("//*[@class='section8']/div[2]/div[4]/p[%s]", i + 1));
////*[@class="section8"]/div[2]/div[4]/p[1]
for (int j = 0; j < elements3.size(); j++) {
// System.out.println(elements3.get(j).text().trim());
sb.append(elements3.get(j).text().trim());
}
sb.append("</br>");
}
} else {
sb.append("该事项无收费标准!");
/* Elements elements4 = dom.selectXpath(baseInfoExp);
for (int i = 0; i < elements4.size(); i++) {
}*/
}
/* StringBuilder sb = new StringBuilder();
for (int i = 0; i < elements.size(); i++) {
sb.append(elements.get(i).text());
}
resultMap.put("sfbz", sb.toString());
}*/
// resultMap.put("sfbz", sb.toString());
/* result = xPath.evaluate(baseInfoExp, dom, XPathConstants.NODESET);
if (result instanceof NodeList) {
NodeList nodeList = (NodeList) result;
......@@ -302,6 +327,8 @@ public class MatterDetailHtmlParseUtil {
}
resultMap.put("sfbz", sb.toString());
}*/
resultMap.put("sfbz", sb.toString());
} catch (Exception e) {
log.error("收费标准xpath解析异常:", e);
}
......@@ -440,7 +467,8 @@ public class MatterDetailHtmlParseUtil {
//String url = "http://www.sczwfw.gov.cn/jiq/front/transition/ywTransToDetail?areaCode=511102000000&itemCode=511A0099100005-511102000000-000-11511002735871990X-1-00&taskType=1&deptCode=11511002735871990X";
//String url = "http://www.sczwfw.gov.cn/jiq/front/transition/ywTransToDetail?areaCode=513426000000&itemCode=511F3000300009-513426000000-000-11513426MB1541028A-1-00&taskType=7&deptCode=009075316";
String url = "http://www.sczwfw.gov.cn/jiq/front/transition/ywTransToDetail?areaCode=511500000000&itemCode=511A0152600000-511500000000-000-511501-7-1-00&taskType=1&deptCode=511501-7";
// String url = "http://www.sczwfw.gov.cn/jiq/front/transition/ywTransToDetail?areaCode=511500000000&itemCode=511A0151400000-511500000000-000-511501-7-1-00&taskType=1&deptCode=511501-7";
String url = "http://www.sczwfw.gov.cn/jiq/front/transition/ywTransToDetail?areaCode=511500000000&itemCode=511A0000400004-511500000000-000-1151120000870212XU-1-00&taskType=1&deptCode=3922757070285361152";
Document dom = MatterDetailHtmlParseUtil.getDomByHtml(url);
Map<String, String> baseInfoMap = MatterDetailHtmlParseUtil.getbaseInfoMapByHtml(dom);
......
......@@ -18,6 +18,7 @@ import com.mortals.xhx.module.matter.model.MatterQuery;
import com.mortals.xhx.module.matter.service.MatterService;
import com.mortals.xhx.module.site.model.SiteEntity;
import com.mortals.xhx.module.site.model.SiteMatterEntity;
import com.mortals.xhx.module.site.model.SiteMatterQuery;
import com.mortals.xhx.module.site.model.SiteQuery;
import com.mortals.xhx.module.site.service.SiteMatterService;
import com.mortals.xhx.module.site.service.SiteService;
......@@ -70,7 +71,7 @@ public class SyncGovMatterDetailThread implements Runnable {
@Override
public void run() {
log.info("同步站点事项开始.....");
// Rest<String> deptRest = deptService.syncDeptBySiteId(siteEntity, context);
Rest<String> deptRest = deptService.syncDeptBySiteId(siteEntity, context);
//log.info("同步站点部门:" + JSON.toJSONString(deptRest));
Rest<String> rest = siteService.syncMatterBySiteId(siteEntity, context);
//Rest<String> rest = Rest.ok();
......@@ -83,7 +84,7 @@ public class SyncGovMatterDetailThread implements Runnable {
List<MatterEntity> matterEntityList = matterService.find(new MatterQuery().areaCode(siteEntity.getAreaCode()).source(SourceEnum.政务网.getValue()));
log.info("查询事项列表结束");
List<MatterEntity> unSyncDetailMatterList = matterEntityList.stream()
.filter(f -> f.getHaveGetMatterInfo().equalsIgnoreCase("false"))
// .filter(f -> f.getHaveGetMatterInfo().equalsIgnoreCase("false"))
.collect(Collectors.toList());
//查询站点事项相关
......@@ -97,6 +98,11 @@ public class SyncGovMatterDetailThread implements Runnable {
if (!ObjectUtils.isEmpty(siteEntities)) {
log.info("同步站点事项到站点.....");
for (SiteEntity site : siteEntities) {
//判断是否已经有站点事项,如果有则不添加
int count = siteMatterService.count(new SiteMatterQuery().siteId(site.getId()), null);
if (count > 0) {
continue;
}
List<SiteMatterEntity> siteMatterList = matterEntityList.stream().map(item -> {
return matterService.switchMatterToSiteMatter(item, site, context).getData();
}).filter(f -> f != null).collect(Collectors.toList());
......
......@@ -19,6 +19,7 @@ import com.mortals.xhx.module.dept.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
......@@ -29,6 +30,7 @@ import java.util.List;
*/
@Slf4j
@Service("SyncUserTask")
@ConditionalOnExpression("'${spring.profiles.active}'!='develop'")
public class SyncUserTaskImpl implements ITaskExcuteService {
@Autowired
......
......@@ -3,10 +3,12 @@ package com.mortals.xhx.module.app.service.impl;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.net.url.UrlBuilder;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.ZipUtil;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.google.common.net.InternetDomainName;
import com.mortals.framework.model.DbMatchMode;
import com.google.common.collect.Maps;
......@@ -114,37 +116,46 @@ public class AppServiceImpl extends AbstractCRUDServiceImpl<AppDao, AppEntity, L
// String domainUrl = GlobalSysInfo.getParamValue(Constant.PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11078");
String domainUrl = "";
if (!ObjectUtils.isEmpty(params.getServerName()) && Validator.isIpv4(params.getServerName())) {
domainUrl = UrlBuilder.ofHttp(params.getServerName()).setPort(params.getServerPort() > 0 ? params.getServerPort() : 11078).build();
domainUrl = StrUtil.sub(domainUrl, 0, domainUrl.length() - 1);
//domainUrl = UrlBuilder.ofHttp(params.getServerName()).setPort(params.getServerPort() > 0 ? params.getServerPort() : 11078).build();
//domainUrl = StrUtil.sub(domainUrl, 0, domainUrl.length() - 1);
}else {
domainUrl= String.format("http://%s:%d",params.getServerName(), params.getServerPort() > 0 ? params.getServerPort() : 11078);
} else {
// domainUrl = GlobalSysInfo.getParamValue(Constant.PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11078");
domainUrl="";
boolean isDomain = ReUtil.isMatch("^[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})*\\.[a-zA-Z]{2,}$", params.getServerName());
if (isDomain) {
domainUrl = String.format("https://", params.getServerName());
} else {
domainUrl = "";
}
}
if (!ObjectUtils.isEmpty(siteEntity)) {
//请求地址 http://domian/app/siteCode/appcode/html
if(!ObjectUtils.isEmpty(domainUrl)){
item.setCustUrl(UrlBuilder.ofHttp(domainUrl)
.addPath(CUSTAPP_ROOT_PATH)
.addPath(siteEntity.getSiteCode())
.addPath(item.getAppCode())
.addPath(item.getVersion().toString())
.build());
}else{
item.setCustUrl(CUSTAPP_ROOT_PATH+"/"+siteEntity.getSiteCode()+"/"+item.getAppCode()+"/"+item.getVersion());
if (!ObjectUtils.isEmpty(domainUrl)) {
String custUrl = String.format("%s/%s/%s/%s/%s", domainUrl, CUSTAPP_ROOT_PATH, siteEntity.getSiteCode(), item.getAppCode(), item.getVersion().toString());
item.setCustUrl(custUrl);
// item.setCustUrl(UrlBuilder.ofHttp(domainUrl)
// .addPath(CUSTAPP_ROOT_PATH)
// .addPath(siteEntity.getSiteCode())
// .addPath(item.getAppCode())
// .addPath(item.getVersion().toString())
// .build());
} else {
item.setCustUrl(CUSTAPP_ROOT_PATH + "/" + siteEntity.getSiteCode() + "/" + item.getAppCode() + "/" + item.getVersion());
}
} else {
item.setCustUrl("");
}
//构建图标地址
if(!ObjectUtils.isEmpty(domainUrl)){
if (!ObjectUtils.isEmpty(domainUrl)) {
item.setAppIconUrl(UrlBuilder.ofHttp(domainUrl)
.addPath(item.getAppIconPath()).build());
}else{
} else {
item.setAppIconUrl(item.getAppIconPath());
}
......@@ -430,6 +441,11 @@ public class AppServiceImpl extends AbstractCRUDServiceImpl<AppDao, AppEntity, L
}
public static void main(String[] args) {
String domain = "www.example.com";
boolean isDomain = ReUtil.isMatch("^[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})*\\.[a-zA-Z]{2,}$", domain);
System.out.println(isDomain); // true
System.out.println(InternetDomainName.isValid(domain));
}
}
\ No newline at end of file
......@@ -126,7 +126,6 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE
String deptCode = item.getKey();
String deptName = item.getValue();
DeptEntity deptEntity = deptService.getExtCache(deptCode);
// DeptEntity deptEntity = deptService.selectOne(new DeptQuery().siteId(siteId).deptNumber(deptCode), context);
if (ObjectUtils.isEmpty(deptEntity)) {
deptEntity = new DeptEntity();
......@@ -139,14 +138,15 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE
deptEntity.setCreateTime(new Date());
deptEntity.setCreateUserId(1L);
deptService.save(deptEntity, context);
} else {
}
/* else {
//更新
deptEntity.setName(deptName);
deptEntity.setSource(SourceEnum.政务网.getValue());
deptEntity.setUpdateTime(new Date());
deptEntity.setUpdateUserId(1L);
deptService.update(deptEntity, context);
}
}*/
sortN++;
}
} else {
......
......@@ -63,7 +63,7 @@ public class DeptController extends BaseCRUDJsonBodyMappingController<DeptServic
if(!ObjectUtils.isEmpty(query.getFilter())&& YesNoEnum.YES.getValue()==query.getFilter()){
//过滤部门事项数据为0的部门
query.setTotalStart(0);
query.setTotalStart(1);
}
super.doListBefore(query, model, context);
}
......
package com.mortals.xhx.module.matter.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.dao.MatterAcceptDao;
import com.mortals.xhx.module.matter.dao.MatterExtDao;
import com.mortals.xhx.module.matter.model.MatterAcceptEntity;
......@@ -14,6 +16,8 @@ import com.mortals.xhx.module.matter.model.MatterAcceptEntity;
*/
public interface MatterAcceptService extends ICRUDService<MatterAcceptEntity,Long>{
MatterAcceptDao getDao();
void deleteByMatterId(Long matterId, Context context);
}
\ No newline at end of file
package com.mortals.xhx.module.matter.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.dao.MatterChargesDao;
import com.mortals.xhx.module.matter.dao.MatterExtDao;
import com.mortals.xhx.module.matter.model.MatterChargesEntity;
/**
* MatterChargesService
......@@ -12,6 +14,9 @@ import com.mortals.xhx.module.matter.model.MatterChargesEntity;
*/
public interface MatterChargesService extends ICRUDService<MatterChargesEntity,Long>{
MatterChargesDao getDao();
void deleteByMatterId(Long matterId, Context context);
}
\ No newline at end of file
package com.mortals.xhx.module.matter.service;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.dao.MatterDatumDao;
import com.mortals.xhx.module.matter.dao.MatterDatumFileDao;
import com.mortals.xhx.module.matter.dao.MatterExtDao;
import com.mortals.xhx.module.matter.model.MatterDatumFileEntity;
import javax.naming.Context;
......@@ -14,6 +17,8 @@ import javax.naming.Context;
*/
public interface MatterDatumFileService extends ICRUDService<MatterDatumFileEntity,Long>{
MatterDatumFileDao getDao();
void deleteFileByDatumId(Long datumId, Context context);
}
\ No newline at end of file
package com.mortals.xhx.module.matter.service;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.dao.MatterDatumDao;
import com.mortals.xhx.module.matter.dao.MatterExtDao;
import com.mortals.xhx.module.matter.model.MatterDatumEntity;
/**
* MatterDatumService
*
* 事项申请材料 service接口
*
* @author zxfei
* @date 2022-01-12
*/
public interface MatterDatumService extends ICRUDService<MatterDatumEntity,Long>{
* MatterDatumService
* <p>
* 事项申请材料 service接口
*
* @author zxfei
* @date 2022-01-12
*/
public interface MatterDatumService extends ICRUDService<MatterDatumEntity, Long> {
MatterDatumDao getDao();
}
\ No newline at end of file
package com.mortals.xhx.module.matter.service;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.dao.MatterExtDao;
import com.mortals.xhx.module.matter.model.MatterExtEntity;
/**
* MatterExtService
......@@ -11,4 +12,5 @@ import com.mortals.xhx.module.matter.model.MatterExtEntity;
*/
public interface MatterExtService extends ICRUDService<MatterExtEntity,Long>{
MatterExtDao getDao();
}
\ No newline at end of file
package com.mortals.xhx.module.matter.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.dao.MatterExtDao;
import com.mortals.xhx.module.matter.dao.MatterFlowlimitDao;
import com.mortals.xhx.module.matter.model.MatterFlowlimitEntity;
/**
* MatterFlowlimitService
......@@ -13,5 +15,7 @@ import com.mortals.xhx.module.matter.model.MatterFlowlimitEntity;
public interface MatterFlowlimitService extends ICRUDService<MatterFlowlimitEntity,Long>{
MatterFlowlimitDao getDao();
void deleteByMatterId(Long matterId, Context context);
}
\ No newline at end of file
package com.mortals.xhx.module.matter.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.dao.MatterExtDao;
import com.mortals.xhx.module.matter.dao.MatterIntermediaryDao;
import com.mortals.xhx.module.matter.model.MatterIntermediaryEntity;
/**
* MatterIntermediaryService
......@@ -12,5 +14,7 @@ import com.mortals.xhx.module.matter.model.MatterIntermediaryEntity;
*/
public interface MatterIntermediaryService extends ICRUDService<MatterIntermediaryEntity,Long>{
MatterIntermediaryDao getDao();
void deleteByMatterId(Long matterId, Context context);
}
\ No newline at end of file
package com.mortals.xhx.module.matter.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.dao.MatterExtDao;
import com.mortals.xhx.module.matter.dao.MatterQuestionDao;
import com.mortals.xhx.module.matter.model.MatterQuestionEntity;
/**
* MatterQuestionService
......@@ -12,5 +14,7 @@ import com.mortals.xhx.module.matter.model.MatterQuestionEntity;
*/
public interface MatterQuestionService extends ICRUDService<MatterQuestionEntity,Long>{
MatterQuestionDao getDao();
void deleteByMatterId(Long matterId, Context context);
}
\ No newline at end of file
package com.mortals.xhx.module.matter.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.dao.MatterExtDao;
import com.mortals.xhx.module.matter.dao.MatterSetbaseDao;
import com.mortals.xhx.module.matter.model.MatterSetbaseEntity;
import com.mortals.xhx.module.matter.model.MatterSetbaseQuery;
/**
* MatterSetbaseService
*
* 事项设定依据 service接口
*
* @author zxfei
* @date 2022-01-12
*/
public interface MatterSetbaseService extends ICRUDService<MatterSetbaseEntity,Long>{
* MatterSetbaseService
* <p>
* 事项设定依据 service接口
*
* @author zxfei
* @date 2022-01-12
*/
public interface MatterSetbaseService extends ICRUDService<MatterSetbaseEntity, Long> {
MatterSetbaseDao getDao();
void deleteByMatterId(Long matterId, Context context);
......
......@@ -1019,7 +1019,7 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
//根据事项url 获取事项详细信息,构建相关详细信息
String html = null;
try {
Document dom = Jsoup.connect(matterEntity.getUrl()).get();
Document dom = Jsoup.connect(matterEntity.getUrl()).timeout(30*1000).get();
// html = Jsoup.connect(matterEntity.getUrl()).get().body().html();
// html = HttpUtil.get(matterEntity.getUrl());
//System.out.println(html);
......@@ -1199,6 +1199,10 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
}
if (!ObjectUtils.isEmpty(matterExtEntities)) {
//先删除后添加
matterExtService.save(matterExtEntities, null);
}
......
......@@ -18,6 +18,8 @@
<property name="showSql" value="MySql" />
</plugin>
<plugin interceptor="com.mortals.framework.thirty.mybatis.LogInterceptor">
<property name="enableExecutorTime" value="true" />
<property name="showSql" value="@project.showSql@" />
</plugin>
</plugins>
</configuration>
\ No newline at end of file
......@@ -18,11 +18,8 @@ POST {{baseUrl}}/app/list
Content-Type: application/json
{
"siteId":1,
"type": 2,
"shelves": 1,
"page":1,
"size":-1
"size":1
}
......
......@@ -4,9 +4,11 @@ POST {{baseUrl}}/dept/list
Content-Type: application/json
{
"siteId": 1,
"isWorkGuide":1 ,
"filter":1 ,
"page":1,
"size":10
"size":-1
}
......
......@@ -22,6 +22,9 @@
"base-yibin-web": {
"baseUrl": "http://112.19.80.237:11078/base"
},
"base-yibin-web-https": {
"baseUrl": "https://ybswxxcx.zwfwhfgjjfzj.yibin.gov.cn/basics_api/base"
},
"base-yibin-php": {
"phpUrl": "http://112.19.80.237:8090"
......
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