Commit 4f9d261c authored by 赵啸非's avatar 赵啸非

添加站点政务同步接口

parent 9c64b0ca
...@@ -156,6 +156,28 @@ ...@@ -156,6 +156,28 @@
<artifactId>bcprov-jdk15on</artifactId> <artifactId>bcprov-jdk15on</artifactId>
<version>1.64</version> <version>1.64</version>
</dependency> </dependency>
<!-- 网页解析 -->
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.15.3</version>
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxp-api</artifactId>
<version>1.4.5</version>
</dependency>
<dependency>
<groupId>net.sourceforge.htmlcleaner</groupId>
<artifactId>htmlcleaner</artifactId>
<version>2.26</version>
</dependency>
<!-- 虹软人脸解析 --> <!-- 虹软人脸解析 -->
<dependency> <dependency>
......
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 区域等级(1.省,2.地市州,3.区县,4.街道,5.社区)枚举类
*
* @author zxfei
*/
public enum AreaLevelDxTypeEnum {
(1, "21"),
地市州(2, "21"),
区县(3, "21"),
街道(4, "54"),
社区(5, "56");
private Integer value;
private String desc;
AreaLevelDxTypeEnum(Integer value, String desc) {
this.value = value;
this.desc = desc;
}
public Integer getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static AreaLevelDxTypeEnum getByValue(Integer value) {
for (AreaLevelDxTypeEnum areaLevelEnum : AreaLevelDxTypeEnum.values()) {
if (areaLevelEnum.getValue() == value) {
return areaLevelEnum;
}
}
return null;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public static Map<String, String> getEnumMap(Integer... eItem) {
Map<String, String> resultMap = new LinkedHashMap<>();
for (AreaLevelDxTypeEnum item : AreaLevelDxTypeEnum.values()) {
try {
boolean hasE = false;
for (Integer e : eItem) {
if (item.getValue() == e) {
hasE = true;
break;
}
}
if (!hasE) {
resultMap.put(item.getValue() + "", item.getDesc());
}
} catch (Exception ex) {
}
}
return resultMap;
}
}
\ No newline at end of file
...@@ -73,4 +73,20 @@ public final class Constant { ...@@ -73,4 +73,20 @@ public final class Constant {
*/ */
public static final String MYSQL_KEY = "xhx-85435158"; public static final String MYSQL_KEY = "xhx-85435158";
/**
* 政务网部门地址
*/
public static final String GOV_DEPT_URL = "gov_dept_url";
/**
* 政务网事项地址
*/
public static final String GOV_MATTER_URL = "gov_matter_url";
/**
* 政务网事项分页地址
*/
public static final String GOV_MATTER_PAGELIST_URL = "gov_matter_pagelist_url";
} }
package com.mortals.xhx.common.utils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.XmlUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.ibm.wsdl.util.xml.XPathUtils;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.code.FiletypeEnum;
import com.mortals.xhx.common.code.SourceEnum;
import com.mortals.xhx.module.matter.model.MatterDatumFileEntity;
import com.mortals.xhx.module.matter.model.MatterEntity;
import lombok.extern.slf4j.Slf4j;
import org.htmlcleaner.CleanerProperties;
import org.htmlcleaner.DomSerializer;
import org.htmlcleaner.HtmlCleaner;
import org.htmlcleaner.TagNode;
import org.jsoup.Jsoup;
import org.springframework.util.xml.SimpleNamespaceContext;
import org.w3c.dom.*;
import javax.xml.namespace.NamespaceContext;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
public class MatterDetailHtmlParseUtil {
public static Document getDomByHtml(String url) {
String html = null;
try {
html = Jsoup.connect(url).get().body().html();
// html = HttpUtil.get(url);
//System.out.println(html);
HtmlCleaner hc = new HtmlCleaner();
TagNode tn = hc.clean(html);
/* Object[] rs = tn.evaluateXPath("//div[@class='section10']//table[1]//tr[2]//td");
for (Integer i = 0; i < rs.length; i++) {
TagNode n = (TagNode) rs[i];
System.out.println(n.getText());
}*/
// System.out.println(tn.getText());
Document dom = new DomSerializer(new CleanerProperties()).createDOM(tn);
/*XPath xPath = XPathFactory.newInstance().newXPath();
String tklrExp = String.format("//div[@class=\"smltc9_bottom\"]//p");
Object result = xPath.evaluate(tklrExp, dom, XPathConstants.NODESET);
NodeList nodeList = (NodeList) result;
for (Integer i = 0; i < nodeList.getLength(); i++) {
System.out.println(nodeList.item(i).getTextContent());
System.out.println("===============");
}*/
//div[@class='section10']//table[1]//tr[%d]//td
return dom;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static Map<String, String> getbaseInfoMapByHtml(Document dom) {
Map<String, String> params = new HashMap<>();
String baseInfoExp = "//div[@class=\"section1\"]//table[1]//td";
String baseInfoExp1 = "//div[@class=\"section2\"]/table[1]//td";
String baseInfoExp2 = "//div[@class=\"section3\"]/table[1]//td";
String baseInfoExp3 = "//div[@class=\"section4\"]/table//td";
baseInfoExp += "|" + baseInfoExp1;
baseInfoExp += "|" + baseInfoExp2;
baseInfoExp += "|" + baseInfoExp3;
XPath xPath = XPathFactory.newInstance().newXPath();
Object result;
try {
result = xPath.evaluate(baseInfoExp, dom, XPathConstants.NODESET);
if (result instanceof NodeList) {
NodeList nodeList = (NodeList) result;
for (int i = 0; i < nodeList.getLength(); i++) {
if (i % 2 == 0) {
continue;
}
Node node = nodeList.item(i);
if (i > 0) {
Node prenode = nodeList.item(i - 1);
params.put(prenode.getTextContent().trim(), node.getTextContent().trim());
}
}
}
} catch (XPathExpressionException e) {
log.error("xpath解析异常:", e);
}
return params;
}
/**
* 申请材料表格解析
*
* @param dom
* @return [{"baseinfo":{...},"blankList":[...],,"sampleList":[...]},...]
*/
public static List<Map<String, Object>> getsqclInfoMapByHtml(Document dom) {
List<Map<String, Object>> mapList = new ArrayList<>();
String blankSampleExp = "//div[@id=\"zhezhao\"]//div[@class='zhezhao4']";
String sampleExp = "//div[@id=\"zhezhao\"]//div[@class='zhezhao2']";
String baseInfoExp = "//div[@id=\"zhezhao\"]//div[@class='zhezhao3']";
XPath xPath = XPathFactory.newInstance().newXPath();
Object result;
try {
result = xPath.evaluate(blankSampleExp, dom, XPathConstants.NODESET);
if (result instanceof NodeList) {
NodeList nodeList = (NodeList) result;
int rowNum = nodeList.getLength();
for (int i = 1; i <= rowNum; i++) {
HashMap<String, Object> map = new HashMap<>();
List<MatterDatumFileEntity> datumFileEntities = new ArrayList<>();
List<MatterDatumFileEntity> datumSampleFileEntities = new ArrayList<>();
//查询空白样表数量
String tempxPath = blankSampleExp + String.format("[%d]//table//tr[position()>1]//td", i);
Object evaluate = xPath.evaluate(tempxPath, dom, XPathConstants.NODESET);
if (evaluate instanceof NodeList) {
NodeList evaluateList = (NodeList) evaluate;
for (int j = 0; j < evaluateList.getLength(); j++) {
if (j % 2 == 0) {
continue;
}
Node node = evaluateList.item(j);
if (j > 0) {
Node prenode = evaluateList.item(j - 1);
MatterDatumFileEntity fileEntity = new MatterDatumFileEntity();
fileEntity.setCreateTime(new Date());
fileEntity.setCreateUser("system");
fileEntity.setSource(SourceEnum.政务网.getValue());
fileEntity.setFiletype(2);
fileEntity.setFileName(prenode.getTextContent().trim());
fileEntity.setFileUrl(node.getFirstChild().getAttributes().getNamedItem("href").getNodeValue().trim());
datumFileEntities.add(fileEntity);
}
}
map.put("blankList", datumFileEntities);
}
//查询样表
String tempxPath1 = sampleExp + String.format("[%d]//table//tr[position()>1]//td", i);
Object sample = xPath.evaluate(tempxPath1, dom, XPathConstants.NODESET);
if (sample instanceof NodeList) {
NodeList sampleList = (NodeList) sample;
for (int j = 0; j < sampleList.getLength(); j++) {
if (j % 2 == 0) {
continue;
}
Node node = sampleList.item(j);
if (j > 0) {
Node prenode = sampleList.item(j - 1);
MatterDatumFileEntity fileEntity = new MatterDatumFileEntity();
fileEntity.setCreateTime(new Date());
fileEntity.setCreateUser("system");
fileEntity.setSource(SourceEnum.政务网.getValue());
fileEntity.setFiletype(2);
fileEntity.setFileName(prenode.getTextContent().trim());
fileEntity.setFileUrl(node.getFirstChild().getAttributes().getNamedItem("href").getNodeValue().trim());
datumSampleFileEntities.add(fileEntity);
}
map.put("sampleList", datumSampleFileEntities);
}
}
//查询基本信息
String tempxPath2 = baseInfoExp + String.format("[%d]//table//tr//td", i);
Object baseinfo = xPath.evaluate(tempxPath2, dom, XPathConstants.NODESET);
HashMap<String, String> baseInfoMap = new HashMap<>();
if (baseinfo instanceof NodeList) {
NodeList baseinfoList = (NodeList) baseinfo;
for (int j = 0; j < baseinfoList.getLength(); j++) {
if (j % 2 == 0) {
continue;
}
Node node = baseinfoList.item(j);
if (j > 0) {
Node prenode = baseinfoList.item(j - 1);
System.out.println(prenode.getTextContent().trim() + "=" + node.getTextContent().trim());
baseInfoMap.put(prenode.getTextContent().trim(), node.getTextContent().trim());
}
}
}
map.put("baseinfo", baseInfoMap);
mapList.add(map);
}
}
} catch (Exception e) {
log.error("xpath解析异常:", e);
}
return mapList;
}
/**
* 受理条件
*
* @param dom
* @return {"sltj":"..."}
*/
public static Map<String, String> getSltjMapByHtml(Document dom) {
Map<String, String> resultMap = new HashMap<>();
String baseInfoExp = "//div[@class='section6']//p";
XPath xPath = XPathFactory.newInstance().newXPath();
Object result;
try {
result = xPath.evaluate(baseInfoExp, dom, XPathConstants.NODESET);
if (result instanceof NodeList) {
NodeList nodeList = (NodeList) result;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < nodeList.getLength(); i++) {
sb.append(nodeList.item(i).getTextContent());
}
resultMap.put("sltj", sb.toString());
}
} catch (XPathExpressionException e) {
log.error("xpath解析异常:", e);
}
return resultMap;
}
/**
* 办理流程
*
* @param dom
* @return [{key:vlaue},{key:value}....]
*/
public static List<Map<String, Object>> getbllcMapByHtml(Document dom) {
List<Map<String, Object>> resultListMap = new ArrayList<>();
String baseInfoExp = "//div[@class='section7']//table[1]//tr[1]//td";
String baseInfoExp1 = "//div[@class='section7']//table[1]//tr";
XPath xPath = XPathFactory.newInstance().newXPath();
Object result;
int rowNum = 1;
try {
result = xPath.evaluate(baseInfoExp1, dom, XPathConstants.NODESET);
if (result instanceof NodeList) {
NodeList nodeList = (NodeList) result;
rowNum = nodeList.getLength();
}
result = xPath.evaluate(baseInfoExp, dom, XPathConstants.NODESET);
if (result instanceof NodeList) {
NodeList nodeList = (NodeList) result;
// int num = nodeList.getLength();
for (int j = 1; j <= rowNum; j++) {
Map<String, Object> map = new HashMap<>();
String baseInfoTempExp = String.format("//div[@class='section7']//table[1]//tr[%d]//td", j + 1);
Object evaluate = xPath.evaluate(baseInfoTempExp, dom, XPathConstants.NODESET);
if (evaluate instanceof NodeList) {
NodeList evaluateList = (NodeList) evaluate;
for (int k = 0; k < evaluateList.getLength(); k++) {
map.put(nodeList.item(k).getTextContent(), evaluateList.item(k).getTextContent().trim());
map.put("sort", j);
}
}
resultListMap.add(map);
}
}
} catch (XPathExpressionException e) {
log.error("xpath解析异常:", e);
}
return resultListMap;
}
/**
* 收费标准
*
* @param dom
* @return {"sfbz":"..."}
*/
public static Map<String, String> getSfbzMapByHtml(Document dom) {
Map<String, String> resultMap = new HashMap<>();
String baseInfoExp = "//div[@class='section8']//p";
XPath xPath = XPathFactory.newInstance().newXPath();
Object result;
try {
result = xPath.evaluate(baseInfoExp, dom, XPathConstants.NODESET);
if (result instanceof NodeList) {
NodeList nodeList = (NodeList) result;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < nodeList.getLength(); i++) {
sb.append(nodeList.item(i).getTextContent());
}
resultMap.put("sfbz", sb.toString());
}
} catch (XPathExpressionException e) {
log.error("xpath解析异常:", e);
}
return resultMap;
}
/**
* 设定依据
*
* @param dom
* @return [{key:vlaue},{key:value}....]
*/
public static List<Map<String, Object>> getSdyjMapByHtml(Document dom) {
List<Map<String, Object>> resultListMap = new ArrayList<>();
String baseInfoExp = "//div[@class='section9']//table[1]//tr";
String baseInfoExp1 = "//div[@class='section9']//table[1]//tr[1]//td";
XPath xPath = XPathFactory.newInstance().newXPath();
int num = 0;
Object result;
try {
result = xPath.evaluate(baseInfoExp, dom, XPathConstants.NODESET);
NodeList nodeList = (NodeList) result;
num = nodeList.getLength();
result = xPath.evaluate(baseInfoExp1, dom, XPathConstants.NODESET);
nodeList = (NodeList) result;
for (int j = 1; j < num; j++) {
Map<String, Object> map = new HashMap<>();
String baseInfoTempExp = String.format("//div[@class='section9']//table[1]//tr[%d]//td", j + 1);
Object evaluate = xPath.evaluate(baseInfoTempExp, dom, XPathConstants.NODESET);
NodeList evaluateList = (NodeList) evaluate;
for (int k = 1; k < evaluateList.getLength(); k++) {
map.put(nodeList.item(k - 1).getTextContent(), evaluateList.item(k).getTextContent().trim());
if (nodeList.item(k - 1).getTextContent().trim().equalsIgnoreCase("条款内容")) {
//查找对应内容
String tklrExp = String.format("//div[@class=\"smltc9_bottom\"]//p");
Object tklr = xPath.evaluate(tklrExp, dom, XPathConstants.NODESET);
NodeList tklrList = (NodeList) tklr;
map.put(nodeList.item(k - 1).getTextContent(), tklrList.item(j - 1).getTextContent().trim());
}
}
map.put("sort", j);
resultListMap.add(map);
}
} catch (XPathExpressionException e) {
log.error("xpath解析异常:", e);
}
return resultListMap;
}
/**
* 中介服务
*
* @param dom
* @return [{key:vlaue},{key:value}....]
*/
public static Map<String, String> getZjfwMapByHtml(Document dom) {
Map<String, String> map = new HashMap<>();
String baseInfoExp = "//div[@class='section10']//table[1]//tr";
XPath xPath = XPathFactory.newInstance().newXPath();
int rownum = 0;
Object result;
try {
result = xPath.evaluate(baseInfoExp, dom, XPathConstants.NODESET);
NodeList nodeList = (NodeList) result;
rownum = nodeList.getLength();
for (int j = 1; j <= rownum; j++) {
String baseInfoTempExp = String.format("//div[@class='section10']//table[1]//tr[%d]//td", j);
Object evaluate = xPath.evaluate(baseInfoTempExp, dom, XPathConstants.NODESET);
NodeList evaluateList = (NodeList) evaluate;
if (evaluateList.getLength() > 1) {
map.put(evaluateList.item(evaluateList.getLength() - 2).getTextContent().trim(), evaluateList.item(evaluateList.getLength() - 1).getTextContent().trim());
}
}
} catch (XPathExpressionException e) {
log.error("xpath解析异常:", e);
}
return map;
}
/**
* 常见问题
*
* @param dom
* @return [{key:vlaue},{key:value}....]
*/
public static List<Map<String, Object>> getCjwtMapByHtml(Document dom) {
List<Map<String, Object>> resultListMap = new ArrayList<>();
String baseInfoExp = "//div[@class='section11']//table[1]//tr";
XPath xPath = XPathFactory.newInstance().newXPath();
int num = 0;
Object result;
try {
result = xPath.evaluate(baseInfoExp, dom, XPathConstants.NODESET);
NodeList nodeList = (NodeList) result;
num = nodeList.getLength();
for (int j = 1; j <= num; j++) {
Map<String, Object> map = new HashMap<>();
String baseInfoTempExp = String.format("//div[@class='section11']//table[1]//tr[%d]//td[2]", j );
Object evaluate = xPath.evaluate(baseInfoTempExp, dom, XPathConstants.NODESET);
NodeList evaluateList = (NodeList) evaluate;
for (int k = 0; k < evaluateList.getLength(); k++) {
map.put(evaluateList.item(k).getFirstChild().getTextContent().trim(),evaluateList.item(k).getLastChild().getTextContent().trim());
}
map.put("sort", j);
resultListMap.add(map);
}
} catch (XPathExpressionException e) {
log.error("常用问题xpath解析异常:", e);
}
return resultListMap;
}
public static void main(String[] args) {
// String url = "http://www.sczwfw.gov.cn/jiq/front/transition/ywTransToDetail?areaCode=510110006007&itemCode=512B0066400008-510110006007-000-54510116ME12555679-1-00&taskType=20&deptCode=1703381";
//String url = "http://www.sczwfw.gov.cn/jiq/front/transition/ywTransToDetail?areaCode=511102000000&itemCode=F-000088-001-511102000000-000-11511002008554411P-1-00&taskType=7&deptCode=11511002008554411P";
//String url = "http://www.sczwfw.gov.cn/jiq/front/transition/ywTransToDetail?areaCode=511102000000&itemCode=511A0116400001-511102000000-000-11511000008554251k-1-00&taskType=1&deptCode=1151124000008554251k_28064";
// String url = "http://www.sczwfw.gov.cn/jiq/front/transition/ywTransToDetail?areaCode=510110307000&itemCode=511E99406004-510110307000-000-11510110009212261X-1-00&taskType=9&deptCode=1703461";
String url = "http://www.sczwfw.gov.cn/jiq/front/transition/ywTransToDetail?areaCode=511102000000&itemCode=511A0099100005-511102000000-000-11511002735871990X-1-00&taskType=1&deptCode=11511002735871990X";
Document dom = MatterDetailHtmlParseUtil.getDomByHtml(url);
// Map<String, String> baseInfoMap = MatterDetailHtmlParseUtil.getbaseInfoMapByHtml(dom);
//
// // System.out.println(JSON.toJSONString(baseInfoMap));
// baseInfoMap.entrySet().stream().forEach(item->{
// System.out.println(item.getKey()+"="+item.getValue());
// });
// List<Map<String, Object>> mapList = MatterDetailHtmlParseUtil.getsqclInfoMapByHtml(dom);
//
// System.out.println(JSON.toJSONString(mapList));
// Map<String, String> sltjMapByHtml = MatterDetailHtmlParseUtil.getSltjMapByHtml(dom);
//
// System.out.println(JSON.toJSONString(sltjMapByHtml));
// List<Map<String, Object>> mapList = MatterDetailHtmlParseUtil.getbllcMapByHtml(dom);
// System.out.println(JSON.toJSONString(mapList));
// Map<String, String> sfbzMapByHtml = MatterDetailHtmlParseUtil.getSfbzMapByHtml(dom);
// System.out.println(JSON.toJSONString(sfbzMapByHtml));
// List<Map<String, Object>> mapList = MatterDetailHtmlParseUtil.getSdyjMapByHtml(dom);
// System.out.println(JSON.toJSONString(mapList));
// Map<String, String> zjfwMapByHtml = MatterDetailHtmlParseUtil.getZjfwMapByHtml(dom);
// System.out.println(JSON.toJSONString(zjfwMapByHtml));
List<Map<String, Object>> mapList = MatterDetailHtmlParseUtil.getCjwtMapByHtml(dom);
System.out.println(JSON.toJSONString(mapList));
}
}
package com.mortals.xhx.common.utils;
import cn.hutool.core.net.url.UrlBuilder;
import cn.hutool.core.util.CharsetUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.framework.util.DataUtil;
import com.mortals.framework.util.HttpUtil;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.matter.model.MatterEntity;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringEscapeUtils;
import org.htmlcleaner.CleanerProperties;
import org.htmlcleaner.DomSerializer;
import org.htmlcleaner.HtmlCleaner;
import org.htmlcleaner.TagNode;
import org.jsoup.Jsoup;
import org.springframework.util.ObjectUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
public class MatterHtmlParseUtil {
public static Rest<Map<String, Integer>> statSiteMatterCount(Map<String, String> params, String url) {
String matterTotalExp = "//input[@id=\"result_count\"]";
String matterPageExp = "//input[@id=\"pageNum\"]";
Map<String, Integer> resultMap = new HashMap<>();
String html;
Object result;
try {
html = HttpUtil.doGet(url, params);
HtmlCleaner hc = new HtmlCleaner();
TagNode tn = hc.clean(html);
Document dom = new DomSerializer(new CleanerProperties()).createDOM(tn);
XPath xPath = XPathFactory.newInstance().newXPath();
result = xPath.evaluate(matterTotalExp, dom, XPathConstants.NODESET);
if (result instanceof NodeList) {
NodeList nodeList = (NodeList) result;
if (nodeList.getLength() > 0) {
Integer total = nodeList.item(0) == null ? 0 : DataUtil.converStr2Int(nodeList.item(0).getAttributes().getNamedItem("value").getNodeValue(), 0);
resultMap.put("total", total);
}
}
result = xPath.evaluate(matterPageExp, dom, XPathConstants.NODESET);
if (result instanceof NodeList) {
NodeList nodeList = (NodeList) result;
if (nodeList.getLength() > 0) {
Integer pageNum = nodeList.item(0) == null ? 0 : DataUtil.converStr2Int(nodeList.item(0).getAttributes().getNamedItem("value").getNodeValue(), 0);
resultMap.put("pageNum", pageNum);
}
}
} catch (Exception e) {
log.error("获取事项数量异常!params:" + JSON.toJSONString(params), e);
return Rest.fail(e.getMessage());
}
return Rest.ok(resultMap);
}
public static Rest<List<MatterEntity>> getMatterList(Map<String, String> params, String url) {
// String url = GlobalSysInfo.getParamValue(Constant.GOV_MATTER_PAGELIST_URL, "http://www.sczwfw.gov.cn/jiq/interface/item/tags");
//String url = "http://www.sczwfw.gov.cn/jiq/interface/item/tags";
String matterListExp = "//div[@class=\"sx_list\"]//span[1]";
String matterListLiExp = "//div[@class=\"sx_list\"]//li/a[1]";
List<MatterEntity> matterEntityList = new ArrayList<>();
String html;
Object result;
try {
//html = HttpUtil.doGet(url, params);
html = Jsoup.connect(url).data(params).get().body().html();
// System.out.println(html);
HtmlCleaner hc = new HtmlCleaner();
TagNode tn = hc.clean(html);
Document dom = new DomSerializer(new CleanerProperties()).createDOM(tn);
XPath xPath = XPathFactory.newInstance().newXPath();
result = xPath.evaluate(matterListExp, dom, XPathConstants.NODESET);
if (result instanceof NodeList) {
NodeList nodeList = (NodeList) result;
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if (node == null) {
continue;
}
String title = StringEscapeUtils.unescapeHtml4(node.getAttributes().getNamedItem("title").getNodeValue());
String href = StringEscapeUtils.unescapeHtml4(node.getFirstChild().getAttributes().getNamedItem("href").getNodeValue());
if (href.equalsIgnoreCase("javascript:void(0)")) {
continue;
}
UrlBuilder builder = UrlBuilder.ofHttp(href, CharsetUtil.CHARSET_UTF_8);
String itemCode = builder.getQuery().get("itemCode").toString();
String taskType = builder.getQuery().get("taskType").toString();
String deptCode = builder.getQuery().get("deptCode").toString();
String areaCode = builder.getQuery().get("areaCode").toString();
MatterEntity matterEntity = new MatterEntity();
matterEntity.initAttrValue();
matterEntity.setTcode(itemCode);
matterEntity.setTname(title);
matterEntity.setDeptCode(deptCode);
matterEntity.setMatterNo(itemCode);
matterEntity.setMatterName(title);
matterEntity.setAreaCode(areaCode);
matterEntity.setUrl(href);
matterEntity.setHaveGetMatterInfo("false");
matterEntityList.add(matterEntity);
}
}
result = xPath.evaluate(matterListLiExp, dom, XPathConstants.NODESET);
if (result instanceof NodeList) {
NodeList nodeList = (NodeList) result;
for (int j = 0; j < nodeList.getLength(); j++) {
Node node = nodeList.item(j);
String title = StringEscapeUtils.unescapeHtml4(node.getAttributes().getNamedItem("title").getNodeValue());
String href = StringEscapeUtils.unescapeHtml4(node.getAttributes().getNamedItem("href").getNodeValue());
UrlBuilder builder = UrlBuilder.ofHttp(href, CharsetUtil.CHARSET_UTF_8);
String itemCode = builder.getQuery().get("itemCode").toString();
String taskType = builder.getQuery().get("taskType").toString();
String deptCode = builder.getQuery().get("deptCode").toString();
String areaCode = builder.getQuery().get("areaCode").toString();
MatterEntity matterEntity = new MatterEntity();
matterEntity.initAttrValue();
matterEntity.setTcode(itemCode);
matterEntity.setTname(title);
matterEntity.setDeptCode(deptCode);
matterEntity.setMatterNo(itemCode);
matterEntity.setAreaCode(areaCode);
matterEntity.setMatterName(title);
matterEntity.setUrl(href);
matterEntityList.add(matterEntity);
}
}
} catch (Exception e) {
log.error("获取列表异常!params:" + JSON.toJSONString(params), e);
return Rest.fail(e.getMessage());
}
return Rest.ok(matterEntityList);
}
/**
* 解析事项基本信息
*
* @param dom
* @return
*/
public static Map<String, String> getbaseInfoMapByHtml(Document dom) {
Map<String, String> params = new HashMap<>();
String baseInfoExp = "//div[@class=\"section1\"]//table[1]//td";
String baseInfoExp1 = "//div[@class=\"section2\"]/table[1]//td";
String baseInfoExp2 = "//div[@class=\"section3\"]/table[1]//td";
String baseInfoExp3 = "//div[@class=\"section4\"]/table//td";
baseInfoExp += "|" + baseInfoExp1;
baseInfoExp += "|" + baseInfoExp2;
baseInfoExp += "|" + baseInfoExp3;
XPath xPath = XPathFactory.newInstance().newXPath();
Object result;
try {
result = xPath.evaluate(baseInfoExp, dom, XPathConstants.NODESET);
if (result instanceof NodeList) {
NodeList nodeList = (NodeList) result;
for (int i = 0; i < nodeList.getLength(); i++) {
if (i % 2 == 0) {
continue;
}
Node node = nodeList.item(i);
if (i > 0) {
Node prenode = nodeList.item(i - 1);
params.put(prenode.getTextContent().trim(), node.getTextContent().trim());
}
}
}
} catch (XPathExpressionException e) {
log.error("xpath解析异常:", e);
}
return params;
}
public static Rest<String> syncDeptBySiteId(Map<String, String> params, String url) {
//String url = GlobalSysInfo.getParamValue(Constant.GOV_DEPT_URL, "http://www.sczwfw.gov.cn/jiq/front/channel/deptSwitch");
// String url = "http://www.sczwfw.gov.cn/jiq/front/channel/deptSwitch";
String exp = "//ul[@class='bm-list']//li";
String html;
Object result;
try {
html = HttpUtil.doGet(url, params);
HtmlCleaner hc = new HtmlCleaner();
TagNode tn = hc.clean(html);
Document dom = new DomSerializer(new CleanerProperties()).createDOM(tn);
XPath xPath = XPathFactory.newInstance().newXPath();
result = xPath.evaluate(exp, dom, XPathConstants.NODESET);
if (result instanceof NodeList) {
NodeList nodeList = (NodeList) result;
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
String deptName = node.getAttributes().getNamedItem("title").getNodeValue();
String href = node.getFirstChild().getAttributes().getNamedItem("href").getNodeValue();
UrlBuilder builder = UrlBuilder.ofHttp(href, CharsetUtil.CHARSET_UTF_8);
String deptCode = builder.getQuery().get("deptCode").toString();
System.out.println(href);
}
}
} catch (Exception e) {
return Rest.fail(e.getMessage());
}
return Rest.ok("当前站点同步添加部门成功!");
}
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));
}
}
...@@ -18,9 +18,11 @@ public class SyncDeptThread implements Runnable { ...@@ -18,9 +18,11 @@ public class SyncDeptThread implements Runnable {
private DeptService deptService; private DeptService deptService;
private String areaCode;
@Override @Override
public void run() { public void run() {
deptService.syncDept(null); deptService.syncDept(areaCode,null);
} }
} }
package com.mortals.xhx.common.utils;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.xhx.common.code.SourceEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.dept.service.DeptService;
import com.mortals.xhx.module.matter.model.MatterEntity;
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.service.SiteService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import javax.xml.transform.Source;
import java.util.List;
@AllArgsConstructor
@Slf4j
public class SyncGovMatterDetailThread implements Runnable {
private MatterService matterService;
private SiteService siteService;
private DeptService deptService;
private SiteEntity siteEntity;
private Context context;
@Override
public void run() {
Rest<String> deptRest = deptService.syncDeptBySiteId(siteEntity.getId(), context);
Rest<String> rest = siteService.syncMatterBySiteId(siteEntity.getId(), context);
if(rest.getCode()== YesNoEnum.YES.getValue()){
List<MatterEntity> matterEntityList = matterService.find(new MatterQuery().areaCode(siteEntity.getAreaCode()).haveGetMatterInfo("false").source(SourceEnum.政务网.getValue()));
matterEntityList.parallelStream().forEach(matterEntity -> {
matterService.buildMatterDetail(matterEntity, context);
});
}
}
}
...@@ -17,9 +17,11 @@ public class SyncTreeMatterThread implements Runnable { ...@@ -17,9 +17,11 @@ public class SyncTreeMatterThread implements Runnable {
private MatterService matterService; private MatterService matterService;
private String areaCode;
@Override @Override
public void run() { public void run() {
matterService.syncMatter(null); matterService.syncMatter(areaCode, null);
} }
} }
...@@ -77,8 +77,6 @@ public class RequestDataController { ...@@ -77,8 +77,6 @@ public class RequestDataController {
setting = Setting.create(); setting = Setting.create();
setting.putAll(sqclInfoMap); setting.putAll(sqclInfoMap);
setting.store("E://sqclinfo.setting"); setting.store("E://sqclinfo.setting");
return respPdu; return respPdu;
} }
...@@ -89,7 +87,7 @@ public class RequestDataController { ...@@ -89,7 +87,7 @@ public class RequestDataController {
*/ */
@GetMapping("/syncDept") @GetMapping("/syncDept")
public Rest<String> syncDept() { public Rest<String> syncDept() {
ThreadPool.getInstance().execute(new SyncDeptThread(deptService)); //ThreadPool.getInstance().execute(new SyncDeptThread(deptService));
return Rest.ok("接收同步部门成功"); return Rest.ok("接收同步部门成功");
} }
...@@ -101,7 +99,7 @@ public class RequestDataController { ...@@ -101,7 +99,7 @@ public class RequestDataController {
*/ */
@GetMapping("/syncMatter") @GetMapping("/syncMatter")
public Rest<String> syncMatter() { public Rest<String> syncMatter() {
ThreadPool.getInstance().execute(new SyncTreeMatterThread(matterService)); // ThreadPool.getInstance().execute(new SyncTreeMatterThread(matterService));
return Rest.ok("接收同步成功"); return Rest.ok("接收同步成功");
} }
......
package com.mortals.xhx.module.dept.service; package com.mortals.xhx.module.dept.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDCacheService; import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
...@@ -18,5 +19,11 @@ public interface DeptService extends ICRUDCacheService<DeptEntity,Long> { ...@@ -18,5 +19,11 @@ public interface DeptService extends ICRUDCacheService<DeptEntity,Long> {
* 同步政务网部门数据 * 同步政务网部门数据
* @param context * @param context
*/ */
void syncDept(Context context); void syncDept(String areaCode,Context context);
/**
* 同步政务网部门数据
* @param context
*/
Rest<String> syncDeptBySiteId(Long siteId, Context context);
} }
\ No newline at end of file
package com.mortals.xhx.module.dept.service.impl; package com.mortals.xhx.module.dept.service.impl;
import cn.hutool.core.net.url.UrlBuilder;
import cn.hutool.core.util.CharsetUtil;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.xhx.module.area.service.AreaService; import com.mortals.framework.util.HttpUtil;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.module.dept.dao.DeptDao;
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.matters.model.MattersDeptEntity; import com.mortals.xhx.module.matters.model.MattersDeptEntity;
import com.mortals.xhx.module.matters.model.MattersDeptQuery; import com.mortals.xhx.module.matters.model.MattersDeptQuery;
import com.mortals.xhx.module.matters.service.MattersDeptService; import com.mortals.xhx.module.matters.service.MattersDeptService;
import com.mortals.xhx.module.matters.service.MattersService;
import com.mortals.xhx.module.site.model.SiteEntity; import com.mortals.xhx.module.site.model.SiteEntity;
import com.mortals.xhx.module.site.service.SiteService; import com.mortals.xhx.module.site.service.SiteService;
import org.apache.commons.lang3.StringEscapeUtils;
import org.htmlcleaner.CleanerProperties;
import org.htmlcleaner.DomSerializer;
import org.htmlcleaner.HtmlCleaner;
import org.htmlcleaner.TagNode;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.dept.dao.DeptDao;
import com.mortals.xhx.module.dept.model.DeptEntity;
import com.mortals.xhx.module.dept.service.DeptService;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* DeptService * DeptService
...@@ -39,7 +55,7 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE ...@@ -39,7 +55,7 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE
private MattersDeptService mattersDeptService; private MattersDeptService mattersDeptService;
@Override @Override
public void syncDept(Context context) { public void syncDept(String areaCode, Context context) {
List<MattersDeptEntity> deptList = mattersDeptService.find(new MattersDeptQuery()); List<MattersDeptEntity> deptList = mattersDeptService.find(new MattersDeptQuery());
deptList.forEach(dept -> { deptList.forEach(dept -> {
//根据区域查询当前区域下存在的站点 //根据区域查询当前区域下存在的站点
...@@ -60,4 +76,57 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE ...@@ -60,4 +76,57 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE
}); });
}); });
} }
@Override
public Rest<String> syncDeptBySiteId(Long siteId, Context context) {
String url = GlobalSysInfo.getParamValue(Constant.GOV_DEPT_URL, "http://www.sczwfw.gov.cn/jiq/front/channel/deptSwitch");
SiteEntity siteEntity = siteService.get(siteId, context);
if (!ObjectUtils.isEmpty(siteEntity)) {
String areaCode = siteEntity.getAreaCode();
String exp = "//ul[@class='bm-list']//li";
Map<String, String> params = new HashMap<>();
params.put("areaCode",areaCode);
// url += "?areaCode=" + areaCode;
String html;
Object result;
try {
html = HttpUtil.doGet(url, params);
//html = HttpUtil.get(url);
HtmlCleaner hc = new HtmlCleaner();
TagNode tn = hc.clean(html);
Document dom = new DomSerializer(new CleanerProperties()).createDOM(tn);
XPath xPath = XPathFactory.newInstance().newXPath();
result = xPath.evaluate(exp, dom, XPathConstants.NODESET);
if (result instanceof NodeList) {
NodeList nodeList = (NodeList) result;
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
String deptName = node.getAttributes().getNamedItem("title").getNodeValue();
String href = StringEscapeUtils.unescapeHtml4(node.getFirstChild().getAttributes().getNamedItem("href").getNodeValue());
UrlBuilder builder = UrlBuilder.ofHttp(href, CharsetUtil.CHARSET_UTF_8);
String deptCode = builder.getQuery().get("deptCode").toString();
//根据站点添加部门信息,部门编号存在时候不添加
DeptEntity deptExistEntity = deptService.selectOne(new DeptQuery().siteId(siteId).deptNumber(deptCode), context);
if (ObjectUtils.isEmpty(deptExistEntity)) {
DeptEntity deptEntity = new DeptEntity();
deptEntity.initAttrValue();
deptEntity.setDeptNumber(deptCode);
deptEntity.setSiteId(siteId);
deptEntity.setName(deptName);
deptEntity.setCreateTime(new Date());
deptEntity.setCreateUserId(1L);
deptService.save(deptEntity, context);
}
}
}
}
catch (Exception e) {
log.error("同步部门异常!siteId:" + siteId, e);
return Rest.fail(e.getMessage());
}
}
return Rest.ok("当前站点同步添加部门成功!");
}
} }
\ No newline at end of file
package com.mortals.xhx.module.dept.web; package com.mortals.xhx.module.dept.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.model.OrderCol; import com.mortals.framework.model.OrderCol;
import com.mortals.framework.util.DataUtil;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.dept.model.DeptEntity; import com.mortals.xhx.module.dept.model.DeptEntity;
import com.mortals.xhx.module.dept.service.DeptService; import com.mortals.xhx.module.dept.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
...@@ -54,4 +60,28 @@ public class DeptController extends BaseCRUDJsonBodyMappingController<DeptServic ...@@ -54,4 +60,28 @@ public class DeptController extends BaseCRUDJsonBodyMappingController<DeptServic
super.init(model, context); super.init(model, context);
} }
/**
* 根据站点同步部门
*/
@PostMapping(value = "syncDeptBySiteId")
public String syncDeptBySiteId(Long siteId) {
JSONObject jsonObject = new JSONObject();
Map<String, Object> model = new HashMap<>();
try {
Rest<String> rest = this.service.syncDeptBySiteId(siteId, getContext());
jsonObject.put(KEY_RESULT_MSG, rest.getMsg());
jsonObject.put(KEY_RESULT_DATA, model);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
this.recordSysLog(this.request, rest.getMsg());
} catch (Exception e) {
log.error("获取异常", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
}
return jsonObject.toJSONString();
}
} }
\ No newline at end of file
...@@ -1733,7 +1733,7 @@ public class MatterEntity extends MatterVo { ...@@ -1733,7 +1733,7 @@ public class MatterEntity extends MatterVo {
this.url = ""; this.url = "";
this.haveGetMatterInfo = ""; this.haveGetMatterInfo = "false";
this.belongDept = ""; this.belongDept = "";
......
package com.mortals.xhx.module.matter.service; package com.mortals.xhx.module.matter.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.model.MatterAcceptEntity; import com.mortals.xhx.module.matter.model.MatterAcceptEntity;
/** /**
* MatterAcceptService * MatterAcceptService
* *
...@@ -11,4 +14,6 @@ import com.mortals.xhx.module.matter.model.MatterAcceptEntity; ...@@ -11,4 +14,6 @@ import com.mortals.xhx.module.matter.model.MatterAcceptEntity;
*/ */
public interface MatterAcceptService extends ICRUDService<MatterAcceptEntity,Long>{ public interface MatterAcceptService extends ICRUDService<MatterAcceptEntity,Long>{
void deleteByMatterId(Long matterId, Context context);
} }
\ No newline at end of file
package com.mortals.xhx.module.matter.service; package com.mortals.xhx.module.matter.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.model.MatterChargesEntity; import com.mortals.xhx.module.matter.model.MatterChargesEntity;
/** /**
...@@ -11,4 +12,6 @@ import com.mortals.xhx.module.matter.model.MatterChargesEntity; ...@@ -11,4 +12,6 @@ import com.mortals.xhx.module.matter.model.MatterChargesEntity;
*/ */
public interface MatterChargesService extends ICRUDService<MatterChargesEntity,Long>{ public interface MatterChargesService extends ICRUDService<MatterChargesEntity,Long>{
void deleteByMatterId(Long matterId, Context context);
} }
\ No newline at end of file
package com.mortals.xhx.module.matter.service; package com.mortals.xhx.module.matter.service;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.model.MatterDatumFileEntity; import com.mortals.xhx.module.matter.model.MatterDatumFileEntity;
import javax.naming.Context;
/** /**
* MatterDatumFileService * MatterDatumFileService
* *
...@@ -11,4 +14,6 @@ import com.mortals.xhx.module.matter.model.MatterDatumFileEntity; ...@@ -11,4 +14,6 @@ import com.mortals.xhx.module.matter.model.MatterDatumFileEntity;
*/ */
public interface MatterDatumFileService extends ICRUDService<MatterDatumFileEntity,Long>{ public interface MatterDatumFileService extends ICRUDService<MatterDatumFileEntity,Long>{
void deleteFileByDatumId(Long datumId, Context context);
} }
\ No newline at end of file
package com.mortals.xhx.module.matter.service; package com.mortals.xhx.module.matter.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.model.MatterFlowlimitEntity; import com.mortals.xhx.module.matter.model.MatterFlowlimitEntity;
/** /**
...@@ -11,4 +12,6 @@ import com.mortals.xhx.module.matter.model.MatterFlowlimitEntity; ...@@ -11,4 +12,6 @@ import com.mortals.xhx.module.matter.model.MatterFlowlimitEntity;
*/ */
public interface MatterFlowlimitService extends ICRUDService<MatterFlowlimitEntity,Long>{ public interface MatterFlowlimitService extends ICRUDService<MatterFlowlimitEntity,Long>{
void deleteByMatterId(Long matterId, Context context);
} }
\ No newline at end of file
package com.mortals.xhx.module.matter.service; package com.mortals.xhx.module.matter.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.model.MatterIntermediaryEntity; import com.mortals.xhx.module.matter.model.MatterIntermediaryEntity;
/** /**
...@@ -11,4 +12,5 @@ import com.mortals.xhx.module.matter.model.MatterIntermediaryEntity; ...@@ -11,4 +12,5 @@ import com.mortals.xhx.module.matter.model.MatterIntermediaryEntity;
*/ */
public interface MatterIntermediaryService extends ICRUDService<MatterIntermediaryEntity,Long>{ public interface MatterIntermediaryService extends ICRUDService<MatterIntermediaryEntity,Long>{
void deleteByMatterId(Long matterId, Context context);
} }
\ No newline at end of file
package com.mortals.xhx.module.matter.service; package com.mortals.xhx.module.matter.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.model.MatterQuestionEntity; import com.mortals.xhx.module.matter.model.MatterQuestionEntity;
/** /**
...@@ -11,4 +12,5 @@ import com.mortals.xhx.module.matter.model.MatterQuestionEntity; ...@@ -11,4 +12,5 @@ import com.mortals.xhx.module.matter.model.MatterQuestionEntity;
*/ */
public interface MatterQuestionService extends ICRUDService<MatterQuestionEntity,Long>{ public interface MatterQuestionService extends ICRUDService<MatterQuestionEntity,Long>{
void deleteByMatterId(Long matterId, Context context);
} }
\ No newline at end of file
...@@ -4,6 +4,7 @@ import com.mortals.framework.model.Context; ...@@ -4,6 +4,7 @@ import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDCacheService; import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.model.MatterEntity; import com.mortals.xhx.module.matter.model.MatterEntity;
import org.w3c.dom.Document;
import java.util.Map; import java.util.Map;
...@@ -28,12 +29,31 @@ public interface MatterService extends ICRUDCacheService<MatterEntity,Long> { ...@@ -28,12 +29,31 @@ public interface MatterService extends ICRUDCacheService<MatterEntity,Long> {
/** /**
* 同步政务网事项数据 * 同步政务网事项数据
* @param areaCode
* @param context * @param context
*/ */
void syncMatter(Context context); void syncMatter(String areaCode,Context context);
Map<String,String> getBaseInfoMap(Context context); Map<String,String> getBaseInfoMap(Context context);
Map<String,String> getSqclInfoMap(Context context); Map<String,String> getSqclInfoMap(Context context);
// /**
// * 解析事项材料信息
// * @param dom
// * @return
// */
// Map<String,String> getclxiInfoMapByHtml(Document dom);
/**
* 构建事项详细相关信息
* @param matterEntity
* @param context
*/
Rest<String> buildMatterDetail(MatterEntity matterEntity, Context context);
} }
\ No newline at end of file
package com.mortals.xhx.module.matter.service; package com.mortals.xhx.module.matter.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.model.MatterSetbaseEntity; import com.mortals.xhx.module.matter.model.MatterSetbaseEntity;
/** /**
...@@ -11,4 +12,6 @@ import com.mortals.xhx.module.matter.model.MatterSetbaseEntity; ...@@ -11,4 +12,6 @@ import com.mortals.xhx.module.matter.model.MatterSetbaseEntity;
*/ */
public interface MatterSetbaseService extends ICRUDService<MatterSetbaseEntity,Long>{ public interface MatterSetbaseService extends ICRUDService<MatterSetbaseEntity,Long>{
void deleteByMatterId(Long matterId, Context context);
} }
\ No newline at end of file
...@@ -11,6 +11,9 @@ import com.mortals.xhx.module.matter.model.MatterAcceptEntity; ...@@ -11,6 +11,9 @@ import com.mortals.xhx.module.matter.model.MatterAcceptEntity;
import com.mortals.xhx.module.matter.service.MatterAcceptService; import com.mortals.xhx.module.matter.service.MatterAcceptService;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.util.HashMap;
import java.util.Map;
/** /**
* MatterAcceptService * MatterAcceptService
* 事项受理条件 service实现 * 事项受理条件 service实现
...@@ -34,4 +37,11 @@ public class MatterAcceptServiceImpl extends AbstractCRUDServiceImpl<MatterAccep ...@@ -34,4 +37,11 @@ public class MatterAcceptServiceImpl extends AbstractCRUDServiceImpl<MatterAccep
} }
super.saveBefore(entity, context); super.saveBefore(entity, context);
} }
@Override
public void deleteByMatterId(Long matterId, Context context) {
Map<String, Object> condition = new HashMap<>();
condition.put("matterId", matterId);
this.dao.delete(condition);
}
} }
\ No newline at end of file
package com.mortals.xhx.module.matter.service.impl; package com.mortals.xhx.module.matter.service.impl;
import com.mortals.framework.model.Context;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.matter.dao.MatterChargesDao; import com.mortals.xhx.module.matter.dao.MatterChargesDao;
import com.mortals.xhx.module.matter.model.MatterChargesEntity; import com.mortals.xhx.module.matter.model.MatterChargesEntity;
import com.mortals.xhx.module.matter.service.MatterChargesService; import com.mortals.xhx.module.matter.service.MatterChargesService;
import java.util.HashMap;
import java.util.Map;
/** /**
* MatterChargesService * MatterChargesService
* 事项收费标准 service实现 * 事项收费标准 service实现
...@@ -13,5 +18,12 @@ import com.mortals.xhx.module.matter.service.MatterChargesService; ...@@ -13,5 +18,12 @@ import com.mortals.xhx.module.matter.service.MatterChargesService;
*/ */
@Service("matterChargesService") @Service("matterChargesService")
public class MatterChargesServiceImpl extends AbstractCRUDServiceImpl<MatterChargesDao, MatterChargesEntity, Long> implements MatterChargesService { public class MatterChargesServiceImpl extends AbstractCRUDServiceImpl<MatterChargesDao, MatterChargesEntity, Long> implements MatterChargesService {
@Override
public void deleteByMatterId(Long matterId, Context context) {
Map<String, Object> condition = new HashMap<>();
condition.put("matterId", matterId);
this.dao.delete(condition);
}
} }
\ No newline at end of file
...@@ -4,6 +4,11 @@ import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; ...@@ -4,6 +4,11 @@ import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.matter.dao.MatterDatumFileDao; import com.mortals.xhx.module.matter.dao.MatterDatumFileDao;
import com.mortals.xhx.module.matter.model.MatterDatumFileEntity; import com.mortals.xhx.module.matter.model.MatterDatumFileEntity;
import com.mortals.xhx.module.matter.service.MatterDatumFileService; import com.mortals.xhx.module.matter.service.MatterDatumFileService;
import javax.naming.Context;
import java.util.HashMap;
import java.util.Map;
/** /**
* MatterDatumFileService * MatterDatumFileService
* 材料附件 service实现 * 材料附件 service实现
...@@ -13,5 +18,11 @@ import com.mortals.xhx.module.matter.service.MatterDatumFileService; ...@@ -13,5 +18,11 @@ import com.mortals.xhx.module.matter.service.MatterDatumFileService;
*/ */
@Service("matterDatumFileService") @Service("matterDatumFileService")
public class MatterDatumFileServiceImpl extends AbstractCRUDServiceImpl<MatterDatumFileDao, MatterDatumFileEntity, Long> implements MatterDatumFileService { public class MatterDatumFileServiceImpl extends AbstractCRUDServiceImpl<MatterDatumFileDao, MatterDatumFileEntity, Long> implements MatterDatumFileService {
@Override
public void deleteFileByDatumId(Long datumId, Context context) {
Map<String, Object> condition = new HashMap<>();
condition.put("datumId", datumId);
this.dao.delete(condition);
}
} }
\ No newline at end of file
...@@ -12,6 +12,9 @@ import com.mortals.xhx.module.matter.model.MatterFlowlimitEntity; ...@@ -12,6 +12,9 @@ import com.mortals.xhx.module.matter.model.MatterFlowlimitEntity;
import com.mortals.xhx.module.matter.service.MatterFlowlimitService; import com.mortals.xhx.module.matter.service.MatterFlowlimitService;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.util.HashMap;
import java.util.Map;
/** /**
* MatterFlowlimitService * MatterFlowlimitService
* 事项办理流程 service实现 * 事项办理流程 service实现
...@@ -35,4 +38,11 @@ public class MatterFlowlimitServiceImpl extends AbstractCRUDServiceImpl<MatterFl ...@@ -35,4 +38,11 @@ public class MatterFlowlimitServiceImpl extends AbstractCRUDServiceImpl<MatterFl
} }
super.saveBefore(entity, context); super.saveBefore(entity, context);
} }
@Override
public void deleteByMatterId(Long matterId, Context context) {
Map<String, Object> condition = new HashMap<>();
condition.put("matterId", matterId);
this.dao.delete(condition);
}
} }
\ No newline at end of file
...@@ -12,6 +12,9 @@ import com.mortals.xhx.module.matter.model.MatterIntermediaryEntity; ...@@ -12,6 +12,9 @@ import com.mortals.xhx.module.matter.model.MatterIntermediaryEntity;
import com.mortals.xhx.module.matter.service.MatterIntermediaryService; import com.mortals.xhx.module.matter.service.MatterIntermediaryService;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.util.HashMap;
import java.util.Map;
/** /**
* MatterIntermediaryService * MatterIntermediaryService
* 事项中介服务 service实现 * 事项中介服务 service实现
...@@ -25,14 +28,19 @@ public class MatterIntermediaryServiceImpl extends AbstractCRUDServiceImpl<Matte ...@@ -25,14 +28,19 @@ public class MatterIntermediaryServiceImpl extends AbstractCRUDServiceImpl<Matte
@Autowired @Autowired
private MatterService matterService; private MatterService matterService;
@Override @Override
protected void saveBefore(MatterIntermediaryEntity entity, Context context) throws AppException { protected void saveBefore(MatterIntermediaryEntity entity, Context context) throws AppException {
if(!ObjectUtils.isEmpty(entity.getMatterId())){ if(!ObjectUtils.isEmpty(entity.getMatterId())){
MatterEntity matterEntity = matterService.get(entity.getMatterId()); MatterEntity matterEntity = matterService.get(entity.getMatterId());
entity.setMatterName(matterEntity==null?"":matterEntity.getMatterName()); entity.setMatterName(matterEntity==null?"":matterEntity.getMatterName());
} }
super.saveBefore(entity, context); super.saveBefore(entity, context);
} }
@Override
public void deleteByMatterId(Long matterId, Context context) {
Map<String, Object> condition = new HashMap<>();
condition.put("matterId", matterId);
this.dao.delete(condition);
}
} }
\ No newline at end of file
...@@ -12,6 +12,9 @@ import com.mortals.xhx.module.matter.model.MatterQuestionEntity; ...@@ -12,6 +12,9 @@ import com.mortals.xhx.module.matter.model.MatterQuestionEntity;
import com.mortals.xhx.module.matter.service.MatterQuestionService; import com.mortals.xhx.module.matter.service.MatterQuestionService;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.util.HashMap;
import java.util.Map;
/** /**
* MatterQuestionService * MatterQuestionService
* 事项常见问题 service实现 * 事项常见问题 service实现
...@@ -35,4 +38,11 @@ public class MatterQuestionServiceImpl extends AbstractCRUDServiceImpl<MatterQue ...@@ -35,4 +38,11 @@ public class MatterQuestionServiceImpl extends AbstractCRUDServiceImpl<MatterQue
} }
super.saveBefore(entity, context); super.saveBefore(entity, context);
} }
@Override
public void deleteByMatterId(Long matterId, Context context) {
Map<String, Object> condition = new HashMap<>();
condition.put("matterId", matterId);
this.dao.delete(condition);
}
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ package com.mortals.xhx.module.matter.service.impl; ...@@ -3,6 +3,7 @@ package com.mortals.xhx.module.matter.service.impl;
import cn.hutool.core.util.PageUtil; import cn.hutool.core.util.PageUtil;
import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.setting.Setting; import cn.hutool.setting.Setting;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
...@@ -15,6 +16,7 @@ import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl; ...@@ -15,6 +16,7 @@ import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.util.DataUtil; import com.mortals.framework.util.DataUtil;
import com.mortals.xhx.base.framework.config.InterceptorConfig; import com.mortals.xhx.base.framework.config.InterceptorConfig;
import com.mortals.xhx.common.code.SourceEnum; import com.mortals.xhx.common.code.SourceEnum;
import com.mortals.xhx.common.utils.MatterDetailHtmlParseUtil;
import com.mortals.xhx.module.matter.dao.MatterDao; import com.mortals.xhx.module.matter.dao.MatterDao;
import com.mortals.xhx.module.matter.model.*; import com.mortals.xhx.module.matter.model.*;
import com.mortals.xhx.module.matter.service.*; import com.mortals.xhx.module.matter.service.*;
...@@ -30,11 +32,24 @@ import com.mortals.xhx.module.site.model.SiteMatterEntity; ...@@ -30,11 +32,24 @@ import com.mortals.xhx.module.site.model.SiteMatterEntity;
import com.mortals.xhx.module.site.model.SiteMatterQuery; import com.mortals.xhx.module.site.model.SiteMatterQuery;
import com.mortals.xhx.module.site.service.SiteMatterService; import com.mortals.xhx.module.site.service.SiteMatterService;
import com.mortals.xhx.module.site.service.SiteService; import com.mortals.xhx.module.site.service.SiteService;
import lombok.extern.slf4j.Slf4j;
import org.htmlcleaner.CleanerProperties;
import org.htmlcleaner.DomSerializer;
import org.htmlcleaner.HtmlCleaner;
import org.htmlcleaner.TagNode;
import org.jsoup.Jsoup;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; 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 org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -47,6 +62,7 @@ import java.util.stream.Collectors; ...@@ -47,6 +62,7 @@ import java.util.stream.Collectors;
* @date 2022-01-12 * @date 2022-01-12
*/ */
@Service("matterService") @Service("matterService")
@Slf4j
public class MatterServiceImpl extends AbstractCRUDCacheServiceImpl<MatterDao, MatterEntity, Long> implements MatterService { public class MatterServiceImpl extends AbstractCRUDCacheServiceImpl<MatterDao, MatterEntity, Long> implements MatterService {
@Autowired @Autowired
private SiteMatterService siteMatterService; private SiteMatterService siteMatterService;
...@@ -168,7 +184,7 @@ public class MatterServiceImpl extends AbstractCRUDCacheServiceImpl<MatterDao, M ...@@ -168,7 +184,7 @@ public class MatterServiceImpl extends AbstractCRUDCacheServiceImpl<MatterDao, M
@Override @Override
public void syncMatter(Context context) { public void syncMatter(String areaCode, Context context) {
List<MatterEntity> list = this.find(new MatterQuery().source(SourceEnum.政务网.getValue())); List<MatterEntity> list = this.find(new MatterQuery().source(SourceEnum.政务网.getValue()));
if (!ObjectUtils.isEmpty(list)) { if (!ObjectUtils.isEmpty(list)) {
// TODO: 2022/3/30 查询本地数据,进行交叉更新对比 // TODO: 2022/3/30 查询本地数据,进行交叉更新对比
...@@ -178,13 +194,19 @@ public class MatterServiceImpl extends AbstractCRUDCacheServiceImpl<MatterDao, M ...@@ -178,13 +194,19 @@ public class MatterServiceImpl extends AbstractCRUDCacheServiceImpl<MatterDao, M
//读取区域数据 //读取区域数据
//mattersAreaService.find() //mattersAreaService.find()
//读取事项基础数据 //读取事项基础数据
Integer total = mattersService.count(new MattersQuery(), null);
MattersQuery mattersQuery = new MattersQuery();
if (!ObjectUtils.isEmpty(areaCode)) {
//查询区域与当前区域
}
Integer total = mattersService.count(mattersQuery, null);
int totalPage = PageUtil.totalPage(total, 1000); int totalPage = PageUtil.totalPage(total, 1000);
for (int i = 0; i < totalPage; i++) { for (int i = 0; i < totalPage; i++) {
PageInfo pageInfo = new PageInfo(); PageInfo pageInfo = new PageInfo();
pageInfo.setCurrPage(i); pageInfo.setCurrPage(i);
pageInfo.setPrePageResult(1000); pageInfo.setPrePageResult(1000);
List<MattersEntity> mattersEntities = mattersService.find(new MattersQuery(), pageInfo, null).getList(); List<MattersEntity> mattersEntities = mattersService.find(mattersQuery, pageInfo, null).getList();
for (MattersEntity item : mattersEntities) { for (MattersEntity item : mattersEntities) {
if ("true".equals(item.getHaveGetMatterInfo())) { if ("true".equals(item.getHaveGetMatterInfo())) {
MattersDetailEntity itemDetail = mattersDetailService.selectOne(new MattersDetailQuery().matterCode(item.getMatterCode())); MattersDetailEntity itemDetail = mattersDetailService.selectOne(new MattersDetailQuery().matterCode(item.getMatterCode()));
...@@ -640,7 +662,6 @@ public class MatterServiceImpl extends AbstractCRUDCacheServiceImpl<MatterDao, M ...@@ -640,7 +662,6 @@ public class MatterServiceImpl extends AbstractCRUDCacheServiceImpl<MatterDao, M
} }
List<MatterSetbaseEntity> setbaseEntityArrayList = new ArrayList<>(); List<MatterSetbaseEntity> setbaseEntityArrayList = new ArrayList<>();
for (int i = 0; i < jsonArray.size(); i++) { for (int i = 0; i < jsonArray.size(); i++) {
MatterSetbaseEntity matterSetbaseEntity = new MatterSetbaseEntity(); MatterSetbaseEntity matterSetbaseEntity = new MatterSetbaseEntity();
matterSetbaseEntity.setMatterId(matterEntity.getId()); matterSetbaseEntity.setMatterId(matterEntity.getId());
...@@ -868,4 +889,269 @@ public class MatterServiceImpl extends AbstractCRUDCacheServiceImpl<MatterDao, M ...@@ -868,4 +889,269 @@ public class MatterServiceImpl extends AbstractCRUDCacheServiceImpl<MatterDao, M
} }
} }
@Override
public Rest<String> buildMatterDetail(MatterEntity matterEntity, Context context) {
//根据事项url 获取事项详细信息,构建相关详细信息
String html = null;
try {
html = Jsoup.connect(matterEntity.getUrl()).get().body().html();
// html = HttpUtil.get(matterEntity.getUrl());
//System.out.println(html);
HtmlCleaner hc = new HtmlCleaner();
TagNode tn = hc.clean(html);
Document dom = new DomSerializer(new CleanerProperties()).createDOM(tn);
//设置基本属性值
Setting baseInfoSetting = interceptorConfig.getBaseInfoSetting();
Setting sqclInfoSetting = interceptorConfig.getSqclInfoSetting();
//构建基础信息参数
savebaseInfo(matterEntity, dom, baseInfoSetting);
//更新材料属性
saveDatumInfo(matterEntity, context, dom, sqclInfoSetting);
//更新受理条件
saveSltjInfo(matterEntity, context, dom);
//更新办理流程
saveBllcInfo(matterEntity, context, dom);
//更新收费标准
saveSfbzInfo(matterEntity, context, dom);
//设定依据
saveSdyjInfo(matterEntity, context, dom);
//中介服务
saveZjfwInfo(matterEntity, context, dom);
//常见问题
saveCjwtInfo(matterEntity, context, dom);
//更新事项更新标志
matterEntity.setHaveGetMatterInfo("true");
} catch (Exception e) {
log.error("获取详细异常! id:{},matterCode:{}", matterEntity.getId(), matterEntity.getMatterNo());
return Rest.fail("更新事项失败!" + e.getMessage());
}
return Rest.ok("更新详细成功!");
}
private void saveCjwtInfo(MatterEntity matterEntity, Context context, Document dom) {
matterQuestionService.deleteByMatterId(matterEntity.getId(), context);
List<Map<String, Object>> cjwtMapList = MatterDetailHtmlParseUtil.getCjwtMapByHtml(dom);
List<MatterQuestionEntity> questionEntityList =new ArrayList<>();
for (Map<String, Object> cjwtMap : cjwtMapList) {
List<MatterQuestionEntity> collect = cjwtMap.entrySet().stream().map(question -> {
MatterQuestionEntity questionEntity = new MatterQuestionEntity();
questionEntity.initAttrValue();
questionEntity.setQuestion(question.getKey());
questionEntity.setAnswer(question.getValue().toString());
questionEntity.setMatterId(matterEntity.getId());
questionEntity.setMatterName(matterEntity.getMatterName());
questionEntity.setSource(SourceEnum.政务网.getValue());
questionEntity.setCreateTime(new Date());
questionEntity.setCreateUser("system");
return questionEntity;
}).collect(Collectors.toList());
questionEntityList.addAll(collect);
}
matterQuestionService.save(questionEntityList);
}
private void saveZjfwInfo(MatterEntity matterEntity, Context context, Document dom) {
matterIntermediaryService.deleteByMatterId(matterEntity.getId(), context);
Map<String, String> zjfwMap = MatterDetailHtmlParseUtil.getZjfwMapByHtml(dom);
List<MatterIntermediaryEntity> intermediaryEntityArrayList = new ArrayList<>();
zjfwMap.entrySet().stream().forEach(m -> {
MatterIntermediaryEntity matterIntermediaryEntity = new MatterIntermediaryEntity();
matterIntermediaryEntity.initAttrValue();
matterIntermediaryEntity.setMatterId(matterEntity.getId());
matterIntermediaryEntity.setMatterName(matterEntity.getMatterName());
matterIntermediaryEntity.setSource(SourceEnum.政务网.getValue());
matterIntermediaryEntity.setCreateTime(new Date());
matterIntermediaryEntity.setCreateUser("system");
matterIntermediaryEntity.setCreateUserId(1L);
matterIntermediaryEntity.setTitle(m.getKey().trim());
matterIntermediaryEntity.setRemark(m.getValue());
intermediaryEntityArrayList.add(matterIntermediaryEntity);
});
matterIntermediaryService.save(intermediaryEntityArrayList);
}
private void saveSdyjInfo(MatterEntity matterEntity, Context context, Document dom) {
matterSetbaseService.deleteByMatterId(matterEntity.getId(), context);
List<MatterSetbaseEntity> setbaseEntityArrayList = new ArrayList<>();
List<Map<String, Object>> sdyjMapList = MatterDetailHtmlParseUtil.getSdyjMapByHtml(dom);
for (Map<String, Object> sdyjMap : sdyjMapList) {
MatterSetbaseEntity matterSetbaseEntity = new MatterSetbaseEntity();
matterSetbaseEntity.setMatterId(matterEntity.getId());
matterSetbaseEntity.setMatterName(matterEntity.getMatterName());
matterSetbaseEntity.setSource(SourceEnum.政务网.getValue());
matterSetbaseEntity.setCreateTime(new Date());
matterSetbaseEntity.setCreateUser("system");
matterSetbaseEntity.setCreateUserId(1L);
sdyjMap.entrySet().stream().forEach(m -> {
if ("法律法规名称".equals(m.getKey().trim())) {
matterSetbaseEntity.setPolicyName(m.getValue().toString());
}
if ("法规类型".equals(m.getKey().trim())) {
matterSetbaseEntity.setPolicyType(m.getValue().toString());
}
if ("条例".equals(m.getKey().trim())) {
matterSetbaseEntity.setPolicyitem(m.getValue().toString());
}
if ("条款内容".equals(m.getKey().trim())) {
matterSetbaseEntity.setContent(m.getValue().toString());
}
});
setbaseEntityArrayList.add(matterSetbaseEntity);
}
matterSetbaseService.save(setbaseEntityArrayList);
}
private void saveSfbzInfo(MatterEntity matterEntity, Context context, Document dom) {
Map<String, String> sfbzMap = MatterDetailHtmlParseUtil.getSfbzMapByHtml(dom);
matterChargesService.deleteByMatterId(matterEntity.getId(), context);
MatterChargesEntity matterChargesEntity = new MatterChargesEntity();
matterChargesEntity.initAttrValue();
matterChargesEntity.setContent(sfbzMap.getOrDefault("sfbz", ""));
matterChargesEntity.setMatterId(matterEntity.getId());
matterChargesEntity.setMatterName(matterEntity.getMatterName());
matterChargesEntity.setSource(SourceEnum.政务网.getValue());
matterChargesEntity.setCreateTime(new Date());
matterChargesEntity.setCreateUser("system");
matterChargesEntity.setCreateUserId(1L);
matterChargesService.save(matterChargesEntity);
}
private static void savebaseInfo(MatterEntity matterEntity, Document dom, Setting baseInfoSetting) {
Map<String, String> baseInfoMap = MatterDetailHtmlParseUtil.getbaseInfoMapByHtml(dom);
baseInfoMap.entrySet().stream()
.forEach(m -> {
String value = baseInfoSetting.getOrDefault(m.getKey(), "");
if (!ObjectUtils.isEmpty(value) && !"无".equals(m.getValue())) {
try {
ReflectUtil.setFieldValue(matterEntity, value, m.getValue());
} catch (Exception e) {
log.error(String.format("设置值异常!key:%s,value:%s", value, m.getValue()));
}
}
});
}
private void saveBllcInfo(MatterEntity matterEntity, Context context, Document dom) {
List<Map<String, Object>> bllcMapList = MatterDetailHtmlParseUtil.getbllcMapByHtml(dom);
matterFlowlimitService.deleteByMatterId(matterEntity.getId(), context);
List<MatterFlowlimitEntity> flowlimitEntityArrayList = new ArrayList<>();
for (Map<String, Object> bllcMap : bllcMapList) {
MatterFlowlimitEntity matterFlowlimitEntity = new MatterFlowlimitEntity();
matterFlowlimitEntity.initAttrValue();
matterFlowlimitEntity.setMatterId(matterEntity.getId());
matterFlowlimitEntity.setMatterName(matterEntity.getMatterName());
matterFlowlimitEntity.setSource(SourceEnum.政务网.getValue());
matterFlowlimitEntity.setCreateTime(new Date());
matterFlowlimitEntity.setCreateUser("system");
matterFlowlimitEntity.setCreateUserId(1L);
bllcMap.entrySet().stream().forEach(m -> {
if ("办理流程".equals(m.getKey().trim())) {
matterFlowlimitEntity.setFlowName(m.getValue().toString());
}
if ("办理时长".equals(m.getKey().trim())) {
matterFlowlimitEntity.setFlowTime(m.getValue().toString());
}
if ("转外时限".equals(m.getKey().trim())) {
matterFlowlimitEntity.setFlowLimit(m.getValue().toString());
}
if ("办理流程说明".equals(m.getKey().trim())) {
matterFlowlimitEntity.setFlowDesc(m.getValue().toString());
}
});
flowlimitEntityArrayList.add(matterFlowlimitEntity);
}
matterFlowlimitService.save(flowlimitEntityArrayList);
}
private void saveSltjInfo(MatterEntity matterEntity, Context context, Document dom) {
matterAcceptService.deleteByMatterId(matterEntity.getId(), context);
Map<String, String> sltjMap = MatterDetailHtmlParseUtil.getSltjMapByHtml(dom);
MatterAcceptEntity matterAcceptEntity = new MatterAcceptEntity();
matterAcceptEntity.initAttrValue();
matterAcceptEntity.setContent(sltjMap.getOrDefault("sltj", ""));
matterAcceptEntity.setMatterId(matterEntity.getId());
matterAcceptEntity.setMatterName(matterEntity.getMatterName());
matterAcceptEntity.setSource(SourceEnum.政务网.getValue());
matterAcceptEntity.setCreateTime(new Date());
matterAcceptEntity.setCreateUser("system");
matterAcceptEntity.setCreateUserId(1L);
matterAcceptService.save(matterAcceptEntity);
}
private void saveDatumInfo(MatterEntity matterEntity, Context context, Document dom, Setting sqclInfoSetting) {
Long[] datumIds = matterDatumService.find(new MatterDatumQuery().matterId(matterEntity.getId()).source(SourceEnum.政务网.getValue())).stream().map(item -> item.getId()).toArray(Long[]::new);
if (!ObjectUtils.isEmpty(datumIds)) {
matterDatumService.remove(datumIds, context);
}
Long[] datumFileIds = matterDatumFileService.find(new MatterDatumFileQuery().datumIdList(Arrays.asList(datumIds))).stream().map(item -> item.getId()).toArray(Long[]::new);
if (!ObjectUtils.isEmpty(datumFileIds)) {
matterDatumService.remove(datumFileIds, context);
}
List<Map<String, Object>> sqclList = MatterDetailHtmlParseUtil.getsqclInfoMapByHtml(dom);
for (Map<String, Object> sqclMap : sqclList) {
Map<String, String> baseinfoMap = (HashMap<String, String>) sqclMap.get("baseinfo");
List<MatterDatumFileEntity> blankList = (List<MatterDatumFileEntity>) sqclMap.get("blankList");
List<MatterDatumFileEntity> sampleList = (List<MatterDatumFileEntity>) sqclMap.get("sampleList");
MatterDatumEntity datumEntity = new MatterDatumEntity();
datumEntity.initAttrValue();
datumEntity.setMatterId(matterEntity.getId());
datumEntity.setMaterialName(matterEntity.getMatterName());
datumEntity.setSource(SourceEnum.政务网.getValue());
datumEntity.setCreateTime(new Date());
datumEntity.setCreateUser("system");
datumEntity.setCreateUserId(1L);
//材料详情
baseinfoMap.entrySet().stream().forEach(m -> {
String value = sqclInfoSetting.getOrDefault(m.getKey(), "");
if (!ObjectUtils.isEmpty(value)) {
try {
ReflectUtil.setFieldValue(datumEntity, value, m.getValue());
} catch (Exception e) {
log.error(String.format("设置值异常!key:%s,value:%s", value, m.getValue()));
}
}
});
matterDatumService.save(datumEntity);
//示例样表
if (!ObjectUtils.isEmpty(sampleList)) {
sampleList.forEach(fileEntity -> {
fileEntity.setDatumId(datumEntity.getId());
fileEntity.setMaterialName(datumEntity.getMaterialName());
});
}
matterDatumFileService.save(sampleList);
//空白样表
if (!ObjectUtils.isEmpty(blankList)) {
blankList.forEach(fileEntity -> {
fileEntity.setDatumId(datumEntity.getId());
fileEntity.setMaterialName(datumEntity.getMaterialName());
});
}
matterDatumFileService.save(blankList);
}
}
} }
\ No newline at end of file
...@@ -12,6 +12,9 @@ import com.mortals.xhx.module.matter.model.MatterSetbaseEntity; ...@@ -12,6 +12,9 @@ import com.mortals.xhx.module.matter.model.MatterSetbaseEntity;
import com.mortals.xhx.module.matter.service.MatterSetbaseService; import com.mortals.xhx.module.matter.service.MatterSetbaseService;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.util.HashMap;
import java.util.Map;
/** /**
* MatterSetbaseService * MatterSetbaseService
* 事项设定依据 service实现 * 事项设定依据 service实现
...@@ -35,4 +38,11 @@ public class MatterSetbaseServiceImpl extends AbstractCRUDServiceImpl<MatterSetb ...@@ -35,4 +38,11 @@ public class MatterSetbaseServiceImpl extends AbstractCRUDServiceImpl<MatterSetb
} }
super.saveBefore(entity, context); super.saveBefore(entity, context);
} }
@Override
public void deleteByMatterId(Long matterId, Context context) {
Map<String, Object> condition = new HashMap<>();
condition.put("matterId", matterId);
this.dao.delete(condition);
}
} }
\ No newline at end of file
package com.mortals.xhx.module.site.service; package com.mortals.xhx.module.site.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDCacheService; import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.area.model.AreaEntity; import com.mortals.xhx.module.area.model.AreaEntity;
import com.mortals.xhx.module.area.model.AreaTreeSelect; import com.mortals.xhx.module.area.model.AreaTreeSelect;
import com.mortals.xhx.module.matter.model.MatterEntity;
import com.mortals.xhx.module.site.model.SiteEntity; import com.mortals.xhx.module.site.model.SiteEntity;
import com.mortals.xhx.module.site.model.SiteQuery; import com.mortals.xhx.module.site.model.SiteQuery;
import com.mortals.xhx.module.site.model.SiteTreeSelect; import com.mortals.xhx.module.site.model.SiteTreeSelect;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
...@@ -64,6 +67,11 @@ public interface SiteService extends ICRUDCacheService<SiteEntity, Long> { ...@@ -64,6 +67,11 @@ public interface SiteService extends ICRUDCacheService<SiteEntity, Long> {
List<SiteEntity> getListAllInfoByQuery(SiteQuery query,Context context) throws AppException; List<SiteEntity> getListAllInfoByQuery(SiteQuery query,Context context) throws AppException;
void changeUrlPath(SiteEntity siteEntity); void changeUrlPath(SiteEntity siteEntity);
Rest<List<MatterEntity>> getMatterAllListByGOV(Map<String,String> params,Integer pageNum, Context context);
Rest<String> syncMatterBySiteId(Long siteId, Context context);
} }
\ No newline at end of file
package com.mortals.xhx.module.site.service.impl; package com.mortals.xhx.module.site.service.impl;
import cn.hutool.core.net.url.UrlBuilder;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.URLUtil; import cn.hutool.core.util.URLUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.mortals.framework.ap.GlobalSysInfo; import com.mortals.framework.ap.GlobalSysInfo;
...@@ -9,16 +11,28 @@ import com.mortals.framework.model.Context; ...@@ -9,16 +11,28 @@ import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.util.DataUtil; import com.mortals.framework.util.DataUtil;
import com.mortals.framework.util.HttpUtil;
import com.mortals.framework.util.StringUtils; import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.base.system.user.service.UserService; import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.code.AreaLevelDxTypeEnum;
import com.mortals.xhx.common.code.YesNoEnum; import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.key.Constant; import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.pdu.RespData; import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.user.UserPdu; import com.mortals.xhx.common.pdu.user.UserPdu;
import com.mortals.xhx.common.utils.MatterHtmlParseUtil;
import com.mortals.xhx.feign.user.IUserFeign; import com.mortals.xhx.feign.user.IUserFeign;
import com.mortals.xhx.module.area.model.AreaEntity; import com.mortals.xhx.module.area.model.AreaEntity;
import com.mortals.xhx.module.area.model.AreaQuery; import com.mortals.xhx.module.area.model.AreaQuery;
import com.mortals.xhx.module.area.service.AreaService; import com.mortals.xhx.module.area.service.AreaService;
import com.mortals.xhx.module.dept.model.DeptEntity;
import com.mortals.xhx.module.dept.model.DeptQuery;
import com.mortals.xhx.module.dept.service.DeptService;
import com.mortals.xhx.module.matter.model.MatterEntity;
import com.mortals.xhx.module.matter.model.MatterQuery;
import com.mortals.xhx.module.matter.service.MatterService;
import com.mortals.xhx.module.matters.model.MattersEntity;
import com.mortals.xhx.module.matters.model.MattersQuery;
import com.mortals.xhx.module.matters.service.MattersService;
import com.mortals.xhx.module.model.model.ModelEntity; import com.mortals.xhx.module.model.model.ModelEntity;
import com.mortals.xhx.module.model.model.ModelQuery; import com.mortals.xhx.module.model.model.ModelQuery;
import com.mortals.xhx.module.model.service.ModelService; import com.mortals.xhx.module.model.service.ModelService;
...@@ -29,12 +43,25 @@ import com.mortals.xhx.module.site.model.SiteTreeSelect; ...@@ -29,12 +43,25 @@ import com.mortals.xhx.module.site.model.SiteTreeSelect;
import com.mortals.xhx.module.site.service.SiteService; import com.mortals.xhx.module.site.service.SiteService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.ss.formula.functions.T;
import org.htmlcleaner.CleanerProperties;
import org.htmlcleaner.DomSerializer;
import org.htmlcleaner.HtmlCleaner;
import org.htmlcleaner.TagNode;
import org.springframework.beans.factory.annotation.Autowired; 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 org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_HTTP_IMAGE_URL; import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_HTTP_IMAGE_URL;
...@@ -63,6 +90,13 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -63,6 +90,13 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
private IUserFeign userFeign; private IUserFeign userFeign;
@Autowired @Autowired
private UserService userService; private UserService userService;
@Autowired
private DeptService deptService;
@Autowired
private MattersService mattersService;
@Autowired
private MatterService matterService;
@Override @Override
protected void validData(SiteEntity entity, Context context) throws AppException { protected void validData(SiteEntity entity, Context context) throws AppException {
...@@ -83,6 +117,27 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -83,6 +117,27 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
super.saveBefore(entity, context); super.saveBefore(entity, context);
} }
@Override
protected void saveAfter(SiteEntity entity, Context context) throws AppException {
//刷新站点树
//ThreadPool.getInstance().execute(new SyncTreeSiteThread(this,context));
Rest<String> rest = userFeign.synchSiteAuth();
if (rest.getCode().equals(YesNoEnum.YES.getValue())) {
UserPdu userPdu = new UserPdu();
userPdu.setPage(1);
userPdu.setSize(-1);
Rest<RespData<List<UserPdu>>> list = userFeign.list(userPdu);
userService.updateUserList(list.getData().getData());
}
//更新同步部门相关
deptService.syncDeptBySiteId(entity.getId(), context);
super.saveAfter(entity, context);
}
@Override @Override
public List<SiteTreeSelect> siteTree(Context context) { public List<SiteTreeSelect> siteTree(Context context) {
Map<String, AreaEntity> areaMap = new HashMap<>(); Map<String, AreaEntity> areaMap = new HashMap<>();
...@@ -99,7 +154,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -99,7 +154,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
log.info("siteQuery==>{}", JSON.toJSONString(siteQuery)); log.info("siteQuery==>{}", JSON.toJSONString(siteQuery));
List<SiteEntity> siteList = this.find(siteQuery); List<SiteEntity> siteList = this.find(siteQuery);
//如果是管理员 默认全部站点 //如果是管理员 默认全部站点
if(context.getUser().isAdmin()){ if (context.getUser().isAdmin()) {
log.info("user is admin !"); log.info("user is admin !");
siteList = this.find(new SiteQuery()); siteList = this.find(new SiteQuery());
} }
...@@ -194,7 +249,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -194,7 +249,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
protected void updateAfter(SiteEntity entity, Context context) throws AppException { protected void updateAfter(SiteEntity entity, Context context) throws AppException {
//刷新站点树 //刷新站点树
Rest<String> rest = userFeign.synchSiteAuth(); Rest<String> rest = userFeign.synchSiteAuth();
if(rest.getCode().equals(YesNoEnum.YES.getValue())){ if (rest.getCode().equals(YesNoEnum.YES.getValue())) {
UserPdu userPdu = new UserPdu(); UserPdu userPdu = new UserPdu();
userPdu.setPage(1); userPdu.setPage(1);
userPdu.setSize(-1); userPdu.setSize(-1);
...@@ -205,30 +260,12 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -205,30 +260,12 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
super.updateAfter(entity, context); super.updateAfter(entity, context);
} }
@Override
protected void saveAfter(SiteEntity entity, Context context) throws AppException {
//刷新站点树
//ThreadPool.getInstance().execute(new SyncTreeSiteThread(this,context));
Rest<String> rest = userFeign.synchSiteAuth();
if(rest.getCode().equals(YesNoEnum.YES.getValue())){
UserPdu userPdu = new UserPdu();
userPdu.setPage(1);
userPdu.setSize(-1);
Rest<RespData<List<UserPdu>>> list = userFeign.list(userPdu);
userService.updateUserList(list.getData().getData());
}
super.saveAfter(entity, context);
}
@Override @Override
protected void removeAfter(Long[] ids, Context context, int result) throws AppException { protected void removeAfter(Long[] ids, Context context, int result) throws AppException {
Rest<String> rest = userFeign.synchSiteAuth(); Rest<String> rest = userFeign.synchSiteAuth();
if(rest.getCode().equals(YesNoEnum.YES.getValue())){ if (rest.getCode().equals(YesNoEnum.YES.getValue())) {
UserPdu userPdu = new UserPdu(); UserPdu userPdu = new UserPdu();
userPdu.setPage(1); userPdu.setPage(1);
...@@ -262,7 +299,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -262,7 +299,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
} }
String matchCode = areaCode.replaceAll("(0)+$", ""); String matchCode = areaCode.replaceAll("(0)+$", "");
SiteQuery siteQuery = new SiteQuery(); SiteQuery siteQuery = new SiteQuery();
siteQuery.setAreaCode(matchCode+"%"); siteQuery.setAreaCode(matchCode + "%");
List<SiteEntity> siteEntities = this.find(siteQuery); List<SiteEntity> siteEntities = this.find(siteQuery);
return siteEntities; return siteEntities;
...@@ -286,10 +323,10 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -286,10 +323,10 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
String matchCode = siteCache.getAreaCode().replaceAll("(0)+$", ""); String matchCode = siteCache.getAreaCode().replaceAll("(0)+$", "");
SiteQuery siteQuery = new SiteQuery(); SiteQuery siteQuery = new SiteQuery();
siteQuery.setAreaCode(matchCode+"%"); siteQuery.setAreaCode(matchCode + "%");
List<SiteEntity> siteEntities = this.find(siteQuery); List<SiteEntity> siteEntities = this.find(siteQuery);
if(!ObjectUtils.isEmpty(siteEntities)){ if (!ObjectUtils.isEmpty(siteEntities)) {
siteList.addAll(siteEntities); siteList.addAll(siteEntities);
} }
return siteList; return siteList;
...@@ -359,4 +396,70 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -359,4 +396,70 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
siteEntity.setLogoFullPath(fullPath); siteEntity.setLogoFullPath(fullPath);
} }
} }
@Override
public Rest<List<MatterEntity>> getMatterAllListByGOV(Map<String, String> params, Integer pageNum, Context context) {
//分页获取所有事项列表
List<MatterEntity> allList = new ArrayList<>();
String url = GlobalSysInfo.getParamValue(Constant.GOV_MATTER_PAGELIST_URL, "http://www.sczwfw.gov.cn/jiq/interface/item/tags");
for (int i = 1; i <= pageNum; i++) {
params.put("pageno", String.valueOf(i));
Rest<List<MatterEntity>> rest = MatterHtmlParseUtil.getMatterList(params, url);
if (rest.getCode() == YesNoEnum.YES.getValue() && !ObjectUtils.isEmpty(rest.getData())) {
allList.addAll(rest.getData());
}
}
return Rest.ok(allList);
}
@Override
public Rest<String> syncMatterBySiteId(Long siteId, Context context) {
//根据站点中区域编码 查询当前是否已经存在事项
SiteEntity siteEntity = this.get(siteId, context);
if (!ObjectUtils.isEmpty(siteEntity)) {
//根据站点区域编码查询政务网事项列表
AreaEntity areaEntity = areaService.getCache(siteEntity.getAreaCode());
String dxType = AreaLevelDxTypeEnum.getByValue(areaEntity == null ? 2 : areaEntity.getAreaLevel()).getDesc();
String url = GlobalSysInfo.getParamValue(Constant.GOV_MATTER_PAGELIST_URL, "http://www.sczwfw.gov.cn/jiq/interface/item/tags");
HashMap<String, String> params = new HashMap<>();
params.put("dxType", dxType);
params.put("areaCode", siteEntity.getAreaCode());
params.put("deptCode", "");
params.put("searchtext", "");
params.put("taskType", "");
params.put("pageno", "1");
Rest<Map<String, Integer>> restStat = MatterHtmlParseUtil.statSiteMatterCount(params, url);
if (restStat.getCode() == YesNoEnum.YES.getValue()) {
Integer pageNum = restStat.getData().getOrDefault("pageNum", 0);
Integer total = restStat.getData().getOrDefault("total", 0);
//获取事项全列表
Rest<List<MatterEntity>> matterAllRest = this.getMatterAllListByGOV(params, pageNum, context);
if (total != matterAllRest.getData().size()) {
log.warn("抓取事项数量不一致,total:{} ,cursize:{}", total, matterAllRest.getData().size());
}
if (matterAllRest.getCode() == YesNoEnum.YES.getValue()) {
List<MatterEntity> govMatterList = matterAllRest.getData();
List<MatterEntity> localMatterList = matterService.find(new MatterQuery().areaCode(siteEntity.getAreaCode()));
List<MatterEntity> subList = this.subList(localMatterList, govMatterList);
//差集进行插入并更新详细数据
if (!ObjectUtils.isEmpty(subList)) {
log.info("insert subList size:" + subList.size());
matterService.save(subList, context);
}
}
}
}
return Rest.ok("同步事项条数成功!");
}
public List<MatterEntity> subList(List<MatterEntity> firstList, List<MatterEntity> secondList) {
return firstList.parallelStream()
.filter(item -> !secondList.parallelStream().map(e -> e.getMatterNo()).collect(Collectors.toList()).contains(item.getMatterNo()))
.collect(Collectors.toList());
}
} }
\ No newline at end of file
...@@ -7,8 +7,15 @@ import com.mortals.framework.exception.AppException; ...@@ -7,8 +7,15 @@ import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result; import com.mortals.framework.model.Result;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.util.ThreadPool;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.keys.RedisCacheKeys;
import com.mortals.xhx.common.utils.SyncDeptThread;
import com.mortals.xhx.common.utils.SyncGovMatterDetailThread;
import com.mortals.xhx.module.dept.service.DeptService;
import com.mortals.xhx.module.matter.service.MatterService;
import com.mortals.xhx.module.model.model.ModelEntity; import com.mortals.xhx.module.model.model.ModelEntity;
import com.mortals.xhx.module.model.model.ModelQuery; import com.mortals.xhx.module.model.model.ModelQuery;
import com.mortals.xhx.module.model.service.ModelService; import com.mortals.xhx.module.model.service.ModelService;
...@@ -42,6 +49,14 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic ...@@ -42,6 +49,14 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
private ParamService paramService; private ParamService paramService;
@Autowired @Autowired
private ModelService modelService; private ModelService modelService;
@Autowired
private ICacheService cacheService;
@Autowired
private MatterService matterService;
@Autowired
private DeptService deptService;
@Autowired
private SiteService siteService;
public SiteController() { public SiteController() {
super.setFormClass(SiteForm.class); super.setFormClass(SiteForm.class);
...@@ -159,7 +174,7 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic ...@@ -159,7 +174,7 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
recordSysLog(request, busiDesc + " 【成功】"); recordSysLog(request, busiDesc + " 【成功】");
jsonObject.put(KEY_RESULT_DATA, siteEntityList); jsonObject.put(KEY_RESULT_DATA, siteEntityList);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS); jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, busiDesc+"成功!"); jsonObject.put(KEY_RESULT_MSG, busiDesc + "成功!");
} catch (Exception e) { } catch (Exception e) {
log.error("获取异常", e); log.error("获取异常", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE); jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
...@@ -177,6 +192,7 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic ...@@ -177,6 +192,7 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
/** /**
* 条件查询,无分页信息 * 条件查询,无分页信息
*
* @param query * @param query
* @return * @return
*/ */
...@@ -187,14 +203,14 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic ...@@ -187,14 +203,14 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
Map<String, Object> model = new HashMap(); Map<String, Object> model = new HashMap();
Context context = this.getContext(); Context context = this.getContext();
String busiDesc = "查询" + this.getModuleDesc(); String busiDesc = "查询" + this.getModuleDesc();
int code=1; int code = 1;
try { try {
if(CollectionUtils.isNotEmpty(query.getAreaCodeList())){ if (CollectionUtils.isNotEmpty(query.getAreaCodeList())) {
List<SiteEntity> siteEntityList= query.getAreaCodeList().parallelStream().flatMap(areaId -> List<SiteEntity> siteEntityList = query.getAreaCodeList().parallelStream().flatMap(areaId ->
this.service.getFlatSitesByAreaCode(areaId, getContext()).stream() this.service.getFlatSitesByAreaCode(areaId, getContext()).stream()
).distinct().collect(Collectors.toList()); ).distinct().collect(Collectors.toList());
model.put("data", siteEntityList); model.put("data", siteEntityList);
}else { } else {
List<SiteEntity> result = this.getService().find(query, context); List<SiteEntity> result = this.getService().find(query, context);
model.put("data", result); model.put("data", result);
} }
...@@ -214,6 +230,7 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic ...@@ -214,6 +230,7 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
/** /**
* 包含站点下面的模块以及模块下面的数据统计 * 包含站点下面的模块以及模块下面的数据统计
*
* @param query * @param query
* @return * @return
*/ */
...@@ -225,7 +242,7 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic ...@@ -225,7 +242,7 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
Context context = this.getContext(); Context context = this.getContext();
String busiDesc = "查询" + this.getModuleDesc(); String busiDesc = "查询" + this.getModuleDesc();
int code=1; int code = 1;
try { try {
List<SiteEntity> result = this.getService().getListAllInfoByQuery(query, context); List<SiteEntity> result = this.getService().getListAllInfoByQuery(query, context);
model.put("data", result); model.put("data", result);
...@@ -242,4 +259,32 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic ...@@ -242,4 +259,32 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString()); ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret; return ret;
} }
/**
* 同步站点事项数据
*/
@PostMapping(value = "syncGovMatterBySiteId")
public String syncMatterBySiteId(@RequestBody SiteQuery site) {
JSONObject jsonObject = new JSONObject();
String busiDesc = "同步站点事项数据" + this.getModuleDesc();
try {
SiteEntity siteEntity = this.service.get(site.getId(), getContext());
//启动
boolean bool = cacheService.setnx(RedisCacheKeys.getFlowDistributedLockKey() + siteEntity.getAreaCode(), siteEntity.getAreaCode(), 60L);
if (!bool) {
throw new AppException("当前正在同步事项数据中,请勿重复提交!");
}
ThreadPool.getInstance().execute(new SyncGovMatterDetailThread(matterService, siteService, deptService, siteEntity, getContext()));
recordSysLog(request, busiDesc + " 【成功】");
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, "同步站点事项数据命令下发成功!");
} catch (Exception e) {
log.error("获取异常", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
}
return jsonObject.toJSONString();
}
} }
\ No newline at end of file
...@@ -28,6 +28,13 @@ public final class RedisCacheKeys { ...@@ -28,6 +28,13 @@ public final class RedisCacheKeys {
return "workflow:distributed:lock:"; return "workflow:distributed:lock:";
} }
/**
* @return 锁定事项同步抓取
*/
public static String getSyncMatterLockKey() {
return "sync:matter:lock:";
}
/** /**
* @return 锁定流程发起 * @return 锁定流程发起
......
...@@ -155,13 +155,13 @@ setup_java() { ...@@ -155,13 +155,13 @@ setup_java() {
mkdir -p ${JAVA_HOME} mkdir -p ${JAVA_HOME}
cpu_info=$(check_cpu) cpu_info=$(check_cpu)
if [[ ${cpu_info} == *${ARM_64}* ]]; then if [[ ${cpu_info} == *${ARM_64}* ]]; then
tar -zvxf ${BASEDIR}/soft/java/arm_64/${JAVA_ARM_FILENAME} -C ${JAVA_HOME} --strip-components 1 tar -zvx ${BASEDIR}/soft/java/arm_64/${JAVA_ARM_FILENAME} -C ${JAVA_HOME} --strip-components 1
echo "arm64" echo "arm64"
elif [[ ${cpu_info} == *${X86_64}* ]]; then elif [[ ${cpu_info} == *${X86_64}* ]]; then
tar -zvxf ${BASEDIR}/soft/java/x86_64/${JAVA_FILENAME} -C ${JAVA_HOME} --strip-components 1 tar -zvx ${BASEDIR}/soft/java/x86_64/${JAVA_FILENAME} -C ${JAVA_HOME} --strip-components 1
echo "x86_64" echo "x86_64"
else else
tar -zvxf ${BASEDIR}/soft/java/x86_64/${JAVA_FILENAME} -C ${JAVA_HOME} --strip-components 1 tar -zvx ${BASEDIR}/soft/java/x86_64/${JAVA_FILENAME} -C ${JAVA_HOME} --strip-components 1
echo "x86_64" echo "x86_64"
fi fi
...@@ -179,7 +179,7 @@ setup_redis() { ...@@ -179,7 +179,7 @@ setup_redis() {
writelog "setup redis start" writelog "setup redis start"
rm -rf ${REDIS_EXECPATH} rm -rf ${REDIS_EXECPATH}
mkdir -p ${REDIS_EXECPATH} mkdir -p ${REDIS_EXECPATH}
tar -zvxf ${BASEDIR}/soft/${REDIS}/${REDIS_FILENAME} -C ${REDIS_EXECPATH} --strip-components 1 tar -zvx ${BASEDIR}/soft/${REDIS}/${REDIS_FILENAME} -C ${REDIS_EXECPATH} --strip-components 1
cd ${REDIS_EXECPATH} cd ${REDIS_EXECPATH}
make make
make PREFIX=${REDIS_EXECPATH} install make PREFIX=${REDIS_EXECPATH} install
...@@ -223,7 +223,7 @@ setup_mysql() { ...@@ -223,7 +223,7 @@ setup_mysql() {
groupadd mysql groupadd mysql
useradd -r -g mysql mysql useradd -r -g mysql mysql
tar -zvxf ${BASEDIR}/soft/${MYSQL}/${MYSQL_CENTOS_FILENAME} -C ${MYSQL_EXECPATH} --strip-components 1 tar -zvx ${BASEDIR}/soft/${MYSQL}/${MYSQL_CENTOS_FILENAME} -C ${MYSQL_EXECPATH} --strip-components 1
cd ${MYSQL_EXECPATH} cd ${MYSQL_EXECPATH}
chown mysql:mysql mysql-files chown mysql:mysql mysql-files
chmod 750 mysql-file chmod 750 mysql-file
...@@ -283,9 +283,7 @@ setup_rabbitmq() { ...@@ -283,9 +283,7 @@ setup_rabbitmq() {
rabbitmqctl set_permissions -p / ${RABBITMQ_USER} ".*" ".*" ".*" # 为用户添加资源权限(授予访问虚拟机根节点的所有权限) rabbitmqctl set_permissions -p / ${RABBITMQ_USER} ".*" ".*" ".*" # 为用户添加资源权限(授予访问虚拟机根节点的所有权限)
else else
writelog "ubuntu erlang and rabbitmq clear" writelog "ubuntu erlang and rabbitmq clear"
fi fi
} }
...@@ -374,13 +372,14 @@ init_setup() { ...@@ -374,13 +372,14 @@ init_setup() {
} }
init_deploy() { init_deploy() {
writelog "init_deploy" writelog "init_deploy..."
mkdir -p ${PUBLISH_PATH} mkdir -p ${PUBLISH_PATH}
chmod -R 755 $PUBLISH_PATH chmod -R 755 $PUBLISH_PATH
mkdir -p /mortals/app/data mkdir -p /mortals/app/data
mkdir -p /mortals/app/logs mkdir -p /mortals/app/logs
chmod -R 755 /mortals chmod -R 755 /mortals
writelog "init_deploy finish"
} }
...@@ -416,53 +415,49 @@ start_service_and_nginx() { ...@@ -416,53 +415,49 @@ start_service_and_nginx() {
nginx -t nginx -t
nginx -s reload nginx -s reload
jcpid=$(ps -ef | grep -v "grep" | grep "${PROJECT_NAME} " | awk '{print $2}') jcpid=$(ps -ef | grep -v "grep" | grep "${PROJECT_NAME} " | awk '{print $2}')
writelog "${PROJECT_NAME}服务启动,PID is ${jcpid} ,status:${project_status}" writelog "${PROJECT_NAME}服务启动,PID is ${jcpid} ,status is ${project_status}"
} }
nacos_deploy() { nacos_deploy() {
writelog "${NACOS}_deploy" writelog "${NACOS}_deploy..."
rm -rf ${NACOS_SERVICE} rm -rf ${NACOS_SERVICE}
rm -rf ${NACOS_EXECPATH} rm -rf ${NACOS_EXECPATH}
mkdir -p ${NACOS_EXECPATH} mkdir -p ${NACOS_EXECPATH}
tar -zvxf $BASEDIR/release/nacos/${NACOS_FILENAME} -C ${NACOS_EXECPATH} --strip-components 1 tar -zvx $BASEDIR/release/nacos/${NACOS_FILENAME} -C ${NACOS_EXECPATH} --strip-components 1
writelog "${NACOS}_deploy init db..."
mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${NACOS_EXECPATH}/db/nacos.sql mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${NACOS_EXECPATH}/db/nacos.sql
if [ ! -f "$NACOS_SERVICE" ]; then
echo "" >$NACOS_SERVICE echo "" >$NACOS_SERVICE
echo "[Unit]" >>$NACOS_SERVICE echo "[Unit]" >>$NACOS_SERVICE
echo "Description=nacos" >>$NACOS_SERVICE echo "Description=nacos" >>$NACOS_SERVICE
echo "After=network.target" >>$NACOS_SERVICE echo "After=network.target" >>$NACOS_SERVICE
echo "" >>$NACOS_SERVICE echo "" >>$NACOS_SERVICE
echo "[Service]" >>$NACOS_SERVICE echo "[Service]" >>$NACOS_SERVICE
echo "Environment=\"JAVA_HOME=$JAVA_HOME\"" >>$NACOS_SERVICE echo "Environment=\"JAVA_HOME=$JAVA_HOME\"" >>$NACOS_SERVICE
echo "Type=forking" >>$NACOS_SERVICE echo "Type=forking" >>$NACOS_SERVICE
echo "ExecStart=${NACOS_EXECPATH}/bin/startup.sh -m standalone" >>$NACOS_SERVICE echo "ExecStart=${NACOS_EXECPATH}/bin/startup.sh -m standalone" >>$NACOS_SERVICE
echo "ExecStop=${NACOS_EXECPATH}/bin/shutdown.sh" >>$NACOS_SERVICE echo "ExecStop=${NACOS_EXECPATH}/bin/shutdown.sh" >>$NACOS_SERVICE
echo "PrivateTmp=true" >>$NACOS_SERVICE echo "PrivateTmp=true" >>$NACOS_SERVICE
echo "" >>$NACOS_SERVICE echo "" >>$NACOS_SERVICE
echo "[Install]" >>$NACOS_SERVICE echo "[Install]" >>$NACOS_SERVICE
echo "WantedBy=multi-user.target" >>$NACOS_SERVICE echo "WantedBy=multi-user.target" >>$NACOS_SERVICE
writelog "NACOS_SERVICE创建完成!" writelog "NACOS_SERVICE创建完成!"
else
writelog "NACOS_SERVICE文件已经存在"
fi
writelog "NACOS_SERVICE服务启动!"
systemctl enable ${NACOS} systemctl enable ${NACOS}
systemctl daemon-reload systemctl daemon-reload
systemctl stop ${NACOS} && systemctl start ${NACOS} systemctl stop ${NACOS} && systemctl start ${NACOS}
project_status=$(systemctl status "${PROJECT_NAME}" | grep Active | awk '{print $2}') project_status=$(systemctl status "${PROJECT_NAME}" | grep Active | awk '{print $2}')
jcpid=$(ps -ef | grep -v "grep" | grep "${NACOS} " | awk '{print $2}') jcpid=$(ps -ef | grep -v "grep" | grep "${NACOS} " | awk '{print $2}')
writelog "${NACOS}服务启动!pid=${jcpid}" writelog "${NACOS}服务启动!pid is ${jcpid},status is ${project_status}"
} }
smart_gateway_deploy() { smart_gateway_deploy() {
writelog "${SMART_GATEWAY}_deploy" writelog "${SMART_GATEWAY}_deploy"
clear_deploy ${SMART_GATEWAY} ${SMART_GATEWAY_SERVICE} ${SMART_GATEWAY_EXECPATH} clear_deploy ${SMART_GATEWAY} ${SMART_GATEWAY_SERVICE} ${SMART_GATEWAY_EXECPATH}
tar -zvxf ${BASEDIR}/release/${SMART_GATEWAY}/${SMART_GATEWAY_FILENAME} -C ${PUBLISH_PATH} tar -zvx ${BASEDIR}/release/${SMART_GATEWAY}/${SMART_GATEWAY_FILENAME} -C ${PUBLISH_PATH}
if [ ! -f "${SMART_GATEWAY_SERVICE}" ]; then
build_service ${SMART_GATEWAY} ${SMART_GATEWAY_SERVICE} ${SMART_GATEWAY_EXECPATH} build_service ${SMART_GATEWAY} ${SMART_GATEWAY_SERVICE} ${SMART_GATEWAY_EXECPATH}
else
writelog "${SMART_GATEWAY}服务文件已经存在!"
fi
start_service_and_nginx ${SMART_GATEWAY} start_service_and_nginx ${SMART_GATEWAY}
} }
...@@ -474,16 +469,14 @@ smart_portal_platform_deploy() { ...@@ -474,16 +469,14 @@ smart_portal_platform_deploy() {
clear_ui_deploy ${SMART_PORTAL_PLATFORM_UI_EXECPATH} clear_ui_deploy ${SMART_PORTAL_PLATFORM_UI_EXECPATH}
writelog "${SMART_PORTAL_PLATFORM_UI_EXECPATH}_clear_finish" writelog "${SMART_PORTAL_PLATFORM_UI_EXECPATH}_clear_finish"
tar -zvxf ${BASEDIR}/release/${SMART_PORTAL_PLATFORM}/${SMART_PORTAL_PLATFORM_FILENAME} -C ${PUBLISH_PATH} tar -zvx ${BASEDIR}/release/${SMART_PORTAL_PLATFORM}/${SMART_PORTAL_PLATFORM_FILENAME} -C ${PUBLISH_PATH}
tar -zvxf ${BASEDIR}/release/${SMART_PORTAL_PLATFORM}/${SMART_PORTAL_PLATFORM_UI_FILENAME} -C ${PUBLISH_PATH} tar -zvx ${BASEDIR}/release/${SMART_PORTAL_PLATFORM}/${SMART_PORTAL_PLATFORM_UI_FILENAME} -C ${PUBLISH_PATH}
mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${SMART_PORTAL_PLATFORM_EXECPATH}/db/db.sql mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${SMART_PORTAL_PLATFORM_EXECPATH}/db/db.sql
mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${SMART_PORTAL_PLATFORM_EXECPATH}/db/menu.sql mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${SMART_PORTAL_PLATFORM_EXECPATH}/db/menu.sql
if [ ! -f "${SMART_PORTAL_PLATFORM_SERVICE}" ]; then
build_service ${SMART_PORTAL_PLATFORM} ${SMART_PORTAL_PLATFORM_SERVICE} ${SMART_PORTAL_PLATFORM_EXECPATH} build_service ${SMART_PORTAL_PLATFORM} ${SMART_PORTAL_PLATFORM_SERVICE} ${SMART_PORTAL_PLATFORM_EXECPATH}
else
writelog "${SMART_PORTAL_PLATFORM}服务文件已经存在!"
fi
start_service_and_nginx ${SMART_PORTAL_PLATFORM} start_service_and_nginx ${SMART_PORTAL_PLATFORM}
} }
...@@ -494,8 +487,8 @@ smart_base_platform_deploy() { ...@@ -494,8 +487,8 @@ smart_base_platform_deploy() {
clear_ui_deploy ${SMART_BASE_PLATFORM_UI_EXECPATH} clear_ui_deploy ${SMART_BASE_PLATFORM_UI_EXECPATH}
writelog "${SMART_BASE_PLATFORM_UI_EXECPATH}_clear_finish" writelog "${SMART_BASE_PLATFORM_UI_EXECPATH}_clear_finish"
tar -zvxf ${BASEDIR}/release/${SMART_BASE_PLATFORM}/${SMART_BASE_PLATFORM_FILENAME} -C ${PUBLISH_PATH} tar -zvx ${BASEDIR}/release/${SMART_BASE_PLATFORM}/${SMART_BASE_PLATFORM_FILENAME} -C ${PUBLISH_PATH}
tar -zvxf ${BASEDIR}/release/${SMART_BASE_PLATFORM}/${SMART_BASE_PLATFORM_UI_FILENAME} -C ${PUBLISH_PATH} tar -zvx ${BASEDIR}/release/${SMART_BASE_PLATFORM}/${SMART_BASE_PLATFORM_UI_FILENAME} -C ${PUBLISH_PATH}
mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${SMART_BASE_PLATFORM_EXECPATH}/db/base.sql mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${SMART_BASE_PLATFORM_EXECPATH}/db/base.sql
mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${SMART_BASE_PLATFORM_EXECPATH}/db/base_modules.sql mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${SMART_BASE_PLATFORM_EXECPATH}/db/base_modules.sql
...@@ -503,11 +496,9 @@ smart_base_platform_deploy() { ...@@ -503,11 +496,9 @@ smart_base_platform_deploy() {
mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${SMART_BASE_PLATFORM_EXECPATH}/db/params.sql mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${SMART_BASE_PLATFORM_EXECPATH}/db/params.sql
mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${SMART_BASE_PLATFORM_EXECPATH}/db/init_area_data.sql mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${SMART_BASE_PLATFORM_EXECPATH}/db/init_area_data.sql
mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${SMART_BASE_PLATFORM_EXECPATH}/db/init_matter_data.sql mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${SMART_BASE_PLATFORM_EXECPATH}/db/init_matter_data.sql
if [ ! -f "${SMART_BASE_PLATFORM_SERVICE}" ]; then
build_service ${SMART_BASE_PLATFORM} ${SMART_BASE_PLATFORM_SERVICE} ${SMART_BASE_PLATFORM_EXECPATH} build_service ${SMART_BASE_PLATFORM} ${SMART_BASE_PLATFORM_SERVICE} ${SMART_BASE_PLATFORM_EXECPATH}
else
writelog "${SMART_BASE_PLATFORM}服务文件已经存在!"
fi
start_service_and_nginx ${SMART_BASE_PLATFORM} start_service_and_nginx ${SMART_BASE_PLATFORM}
} }
...@@ -518,19 +509,17 @@ device_platform_deploy() { ...@@ -518,19 +509,17 @@ device_platform_deploy() {
clear_ui_deploy ${DEVICE_PLATFORM_UI_EXECPATH} clear_ui_deploy ${DEVICE_PLATFORM_UI_EXECPATH}
writelog "${SMA_PLATFORM_UI_EXECPATH}_clear_finish" writelog "${SMA_PLATFORM_UI_EXECPATH}_clear_finish"
tar -zvxf ${BASEDIR}/release/${DEVICE_PLATFORM}/${DEVICE_PLATFORM_FILENAME} -C ${PUBLISH_PATH} tar -zvx ${BASEDIR}/release/${DEVICE_PLATFORM}/${DEVICE_PLATFORM_FILENAME} -C ${PUBLISH_PATH}
tar -zvxf ${BASEDIR}/release/${DEVICE_PLATFORM}/${DEVICE_PLATFORM_UI_FILENAME} -C ${PUBLISH_PATH} tar -zvx ${BASEDIR}/release/${DEVICE_PLATFORM}/${DEVICE_PLATFORM_UI_FILENAME} -C ${PUBLISH_PATH}
mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${DEVICE_PLATFORM_EXECPATH}/db/base.sql mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${DEVICE_PLATFORM_EXECPATH}/db/base.sql
mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${DEVICE_PLATFORM_EXECPATH}/db/module.sql mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${DEVICE_PLATFORM_EXECPATH}/db/module.sql
mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${DEVICE_PLATFORM_EXECPATH}/db/menu.sql mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${DEVICE_PLATFORM_EXECPATH}/db/menu.sql
mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${DEVICE_PLATFORM_EXECPATH}/db/params.sql mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${DEVICE_PLATFORM_EXECPATH}/db/params.sql
mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${DEVICE_PLATFORM_EXECPATH}/db/init_area.sql mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${DEVICE_PLATFORM_EXECPATH}/db/init_area.sql
if [ ! -f "${DEVICE_PLATFORM_SERVICE}" ]; then
build_service ${DEVICE_PLATFORM} ${DEVICE_PLATFORM_SERVICE} ${DEVICE_PLATFORM_EXECPATH} build_service ${DEVICE_PLATFORM} ${DEVICE_PLATFORM_SERVICE} ${DEVICE_PLATFORM_EXECPATH}
else
writelog "${DEVICE_PLATFORM}服务文件已经存在!"
fi
start_service_and_nginx ${DEVICE_PLATFORM} start_service_and_nginx ${DEVICE_PLATFORM}
} }
...@@ -541,17 +530,15 @@ log_platform_deploy() { ...@@ -541,17 +530,15 @@ log_platform_deploy() {
clear_ui_deploy ${LOG_PLATFORM_UI_EXECPATH} clear_ui_deploy ${LOG_PLATFORM_UI_EXECPATH}
writelog "${LOG_PLATFORM_UI_EXECPATH}_clear_finish" writelog "${LOG_PLATFORM_UI_EXECPATH}_clear_finish"
tar -zvxf ${BASEDIR}/release/${LOG_PLATFORM}/${LOG_PLATFORM_FILENAME} -C ${PUBLISH_PATH} tar -zvx ${BASEDIR}/release/${LOG_PLATFORM}/${LOG_PLATFORM_FILENAME} -C ${PUBLISH_PATH}
tar -zvxf ${BASEDIR}/release/${LOG_PLATFORM}/${LOG_PLATFORM_UI_FILENAME} -C ${PUBLISH_PATH} tar -zvx ${BASEDIR}/release/${LOG_PLATFORM}/${LOG_PLATFORM_UI_FILENAME} -C ${PUBLISH_PATH}
mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${LOG_PLATFORM_EXECPATH}/db/base.sql mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${LOG_PLATFORM_EXECPATH}/db/base.sql
mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${LOG_PLATFORM_EXECPATH}/db/module.sql mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${LOG_PLATFORM_EXECPATH}/db/module.sql
mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${LOG_PLATFORM_EXECPATH}/db/menu.sql mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${LOG_PLATFORM_EXECPATH}/db/menu.sql
if [ ! -f "${LOG_PLATFORM_SERVICE}" ]; then
build_service ${LOG_PLATFORM} ${LOG_PLATFORM_SERVICE} ${LOG_PLATFORM_EXECPATH} build_service ${LOG_PLATFORM} ${LOG_PLATFORM_SERVICE} ${LOG_PLATFORM_EXECPATH}
else
writelog "${LOG_PLATFORM}服务文件已经存在!"
fi
start_service_and_nginx ${LOG_PLATFORM} start_service_and_nginx ${LOG_PLATFORM}
} }
...@@ -559,22 +546,22 @@ stopApps() { ...@@ -559,22 +546,22 @@ stopApps() {
echo "停止服务开始!" echo "停止服务开始!"
echo "nacos stop..." echo "nacos stop..."
systemctl stop ${NACOS} systemctl stop ${NACOS}
echo "nacos finish..." echo "nacos stop finish..."
echo "smart-gateway stop..." echo "smart-gateway stop..."
systemctl stop ${SMART_GATEWAY} systemctl stop ${SMART_GATEWAY}
echo "smart-gateway finish..." echo "smart-gateway stop finish..."
echo "smart-portal-platform stop..." echo "smart-portal-platform stop..."
systemctl stop ${SMART_PORTAL_PLATFORM} systemctl stop ${SMART_PORTAL_PLATFORM}
echo "smart-portal-platform finish..." echo "smart-portal-platform stop finish..."
echo "smart-base-platform stop..." echo "smart-base-platform stop..."
systemctl stop ${SMART_BASE_PLATFORM} systemctl stop ${SMART_BASE_PLATFORM}
echo "smart-base-platform finish..." echo "smart-base-platform stop finish..."
echo "device-platform stop..." echo "device-platform stop..."
systemctl stop ${DEVICE_PLATFORM} systemctl stop ${DEVICE_PLATFORM}
echo "device-platform finish..." echo "device-platform stop finish..."
echo "log-platform stop..." echo "log-platform stop..."
systemctl stop ${LOG_PLATFORM} systemctl stop ${LOG_PLATFORM}
echo "log-platform finish..." echo "log-platform stop finish..."
echo "停止服务完成!" echo "停止服务完成!"
} }
......
...@@ -71,7 +71,7 @@ spring: ...@@ -71,7 +71,7 @@ spring:
- Path=/logservice/** - Path=/logservice/**
# 样表服务服务 # 样表服务服务
- id: sample-form-manager - id: sample-form-manager
# uri: http://127.0.0.1:17211 #uri: http://192.168.0.98:17002
uri: lb://sample-form-manager uri: lb://sample-form-manager
predicates: predicates:
- Path=/sampleform/** - Path=/sampleform/**
......
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