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

添加站点政务同步接口

parent 9c64b0ca
......@@ -156,6 +156,28 @@
<artifactId>bcprov-jdk15on</artifactId>
<version>1.64</version>
</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>
......
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 {
*/
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";
}
......@@ -18,9 +18,11 @@ public class SyncDeptThread implements Runnable {
private DeptService deptService;
private String areaCode;
@Override
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 {
private MatterService matterService;
private String areaCode;
@Override
public void run() {
matterService.syncMatter(null);
matterService.syncMatter(areaCode, null);
}
}
......@@ -77,8 +77,6 @@ public class RequestDataController {
setting = Setting.create();
setting.putAll(sqclInfoMap);
setting.store("E://sqclinfo.setting");
return respPdu;
}
......@@ -89,7 +87,7 @@ public class RequestDataController {
*/
@GetMapping("/syncDept")
public Rest<String> syncDept() {
ThreadPool.getInstance().execute(new SyncDeptThread(deptService));
//ThreadPool.getInstance().execute(new SyncDeptThread(deptService));
return Rest.ok("接收同步部门成功");
}
......@@ -101,7 +99,7 @@ public class RequestDataController {
*/
@GetMapping("/syncMatter")
public Rest<String> syncMatter() {
ThreadPool.getInstance().execute(new SyncTreeMatterThread(matterService));
// ThreadPool.getInstance().execute(new SyncTreeMatterThread(matterService));
return Rest.ok("接收同步成功");
}
......
package com.mortals.xhx.module.dept.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.framework.service.ICRUDService;
......@@ -18,5 +19,11 @@ public interface DeptService extends ICRUDCacheService<DeptEntity,Long> {
* 同步政务网部门数据
* @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;
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.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.service.DeptService;
import com.mortals.xhx.module.matters.model.MattersDeptEntity;
import com.mortals.xhx.module.matters.model.MattersDeptQuery;
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.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.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.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.HashMap;
import java.util.List;
import java.util.Map;
/**
* DeptService
......@@ -39,7 +55,7 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE
private MattersDeptService mattersDeptService;
@Override
public void syncDept(Context context) {
public void syncDept(String areaCode, Context context) {
List<MattersDeptEntity> deptList = mattersDeptService.find(new MattersDeptQuery());
deptList.forEach(dept -> {
//根据区域查询当前区域下存在的站点
......@@ -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;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.OrderCol;
import com.mortals.framework.util.DataUtil;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.dept.model.DeptEntity;
import com.mortals.xhx.module.dept.service.DeptService;
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.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/**
......@@ -54,4 +60,28 @@ public class DeptController extends BaseCRUDJsonBodyMappingController<DeptServic
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 {
this.url = "";
this.haveGetMatterInfo = "";
this.haveGetMatterInfo = "false";
this.belongDept = "";
......
package com.mortals.xhx.module.matter.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.model.MatterAcceptEntity;
/**
* MatterAcceptService
*
......@@ -11,4 +14,6 @@ import com.mortals.xhx.module.matter.model.MatterAcceptEntity;
*/
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;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
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>{
void deleteByMatterId(Long matterId, Context context);
}
\ No newline at end of file
package com.mortals.xhx.module.matter.service;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.model.MatterDatumFileEntity;
import javax.naming.Context;
/**
* MatterDatumFileService
*
......@@ -11,4 +14,6 @@ import com.mortals.xhx.module.matter.model.MatterDatumFileEntity;
*/
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;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
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>{
void deleteByMatterId(Long matterId, Context context);
}
\ No newline at end of file
package com.mortals.xhx.module.matter.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.model.MatterIntermediaryEntity;
/**
......@@ -11,4 +12,5 @@ import com.mortals.xhx.module.matter.model.MatterIntermediaryEntity;
*/
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;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
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>{
void deleteByMatterId(Long matterId, Context context);
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.model.MatterEntity;
import org.w3c.dom.Document;
import java.util.Map;
......@@ -28,12 +29,31 @@ public interface MatterService extends ICRUDCacheService<MatterEntity,Long> {
/**
* 同步政务网事项数据
* @param areaCode
* @param context
*/
void syncMatter(Context context);
void syncMatter(String areaCode,Context context);
Map<String,String> getBaseInfoMap(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;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
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>{
void deleteByMatterId(Long matterId, Context context);
}
\ No newline at end of file
......@@ -11,6 +11,9 @@ import com.mortals.xhx.module.matter.model.MatterAcceptEntity;
import com.mortals.xhx.module.matter.service.MatterAcceptService;
import org.springframework.util.ObjectUtils;
import java.util.HashMap;
import java.util.Map;
/**
* MatterAcceptService
* 事项受理条件 service实现
......@@ -34,4 +37,11 @@ public class MatterAcceptServiceImpl extends AbstractCRUDServiceImpl<MatterAccep
}
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;
import com.mortals.framework.model.Context;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.matter.dao.MatterChargesDao;
import com.mortals.xhx.module.matter.model.MatterChargesEntity;
import com.mortals.xhx.module.matter.service.MatterChargesService;
import java.util.HashMap;
import java.util.Map;
/**
* MatterChargesService
* 事项收费标准 service实现
......@@ -14,4 +19,11 @@ import com.mortals.xhx.module.matter.service.MatterChargesService;
@Service("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;
import com.mortals.xhx.module.matter.dao.MatterDatumFileDao;
import com.mortals.xhx.module.matter.model.MatterDatumFileEntity;
import com.mortals.xhx.module.matter.service.MatterDatumFileService;
import javax.naming.Context;
import java.util.HashMap;
import java.util.Map;
/**
* MatterDatumFileService
* 材料附件 service实现
......@@ -14,4 +19,10 @@ import com.mortals.xhx.module.matter.service.MatterDatumFileService;
@Service("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;
import com.mortals.xhx.module.matter.service.MatterFlowlimitService;
import org.springframework.util.ObjectUtils;
import java.util.HashMap;
import java.util.Map;
/**
* MatterFlowlimitService
* 事项办理流程 service实现
......@@ -35,4 +38,11 @@ public class MatterFlowlimitServiceImpl extends AbstractCRUDServiceImpl<MatterFl
}
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;
import com.mortals.xhx.module.matter.service.MatterIntermediaryService;
import org.springframework.util.ObjectUtils;
import java.util.HashMap;
import java.util.Map;
/**
* MatterIntermediaryService
* 事项中介服务 service实现
......@@ -25,14 +28,19 @@ public class MatterIntermediaryServiceImpl extends AbstractCRUDServiceImpl<Matte
@Autowired
private MatterService matterService;
@Override
protected void saveBefore(MatterIntermediaryEntity entity, Context context) throws AppException {
if(!ObjectUtils.isEmpty(entity.getMatterId())){
MatterEntity matterEntity = matterService.get(entity.getMatterId());
entity.setMatterName(matterEntity==null?"":matterEntity.getMatterName());
}
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;
import com.mortals.xhx.module.matter.service.MatterQuestionService;
import org.springframework.util.ObjectUtils;
import java.util.HashMap;
import java.util.Map;
/**
* MatterQuestionService
* 事项常见问题 service实现
......@@ -35,4 +38,11 @@ public class MatterQuestionServiceImpl extends AbstractCRUDServiceImpl<MatterQue
}
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.MatterSetbaseEntity;
import com.mortals.xhx.module.matter.service.MatterSetbaseService;
import org.springframework.util.ObjectUtils;
import java.util.HashMap;
import java.util.Map;
/**
* MatterSetbaseService
* 事项设定依据 service实现
......@@ -35,4 +38,11 @@ public class MatterSetbaseServiceImpl extends AbstractCRUDServiceImpl<MatterSetb
}
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;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.area.model.AreaEntity;
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.SiteQuery;
import com.mortals.xhx.module.site.model.SiteTreeSelect;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
......@@ -64,6 +67,11 @@ public interface SiteService extends ICRUDCacheService<SiteEntity, Long> {
List<SiteEntity> getListAllInfoByQuery(SiteQuery query,Context context) throws AppException;
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
......@@ -7,8 +7,15 @@ import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
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.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.ModelQuery;
import com.mortals.xhx.module.model.service.ModelService;
......@@ -42,6 +49,14 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
private ParamService paramService;
@Autowired
private ModelService modelService;
@Autowired
private ICacheService cacheService;
@Autowired
private MatterService matterService;
@Autowired
private DeptService deptService;
@Autowired
private SiteService siteService;
public SiteController() {
super.setFormClass(SiteForm.class);
......@@ -159,7 +174,7 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
recordSysLog(request, busiDesc + " 【成功】");
jsonObject.put(KEY_RESULT_DATA, siteEntityList);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, busiDesc+"成功!");
jsonObject.put(KEY_RESULT_MSG, busiDesc + "成功!");
} catch (Exception e) {
log.error("获取异常", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
......@@ -177,6 +192,7 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
/**
* 条件查询,无分页信息
*
* @param query
* @return
*/
......@@ -187,14 +203,14 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "查询" + this.getModuleDesc();
int code=1;
int code = 1;
try {
if(CollectionUtils.isNotEmpty(query.getAreaCodeList())){
List<SiteEntity> siteEntityList= query.getAreaCodeList().parallelStream().flatMap(areaId ->
if (CollectionUtils.isNotEmpty(query.getAreaCodeList())) {
List<SiteEntity> siteEntityList = query.getAreaCodeList().parallelStream().flatMap(areaId ->
this.service.getFlatSitesByAreaCode(areaId, getContext()).stream()
).distinct().collect(Collectors.toList());
model.put("data", siteEntityList);
}else {
} else {
List<SiteEntity> result = this.getService().find(query, context);
model.put("data", result);
}
......@@ -214,6 +230,7 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
/**
* 包含站点下面的模块以及模块下面的数据统计
*
* @param query
* @return
*/
......@@ -225,7 +242,7 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
Context context = this.getContext();
String busiDesc = "查询" + this.getModuleDesc();
int code=1;
int code = 1;
try {
List<SiteEntity> result = this.getService().getListAllInfoByQuery(query, context);
model.put("data", result);
......@@ -242,4 +259,32 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
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 {
return "workflow:distributed:lock:";
}
/**
* @return 锁定事项同步抓取
*/
public static String getSyncMatterLockKey() {
return "sync:matter:lock:";
}
/**
* @return 锁定流程发起
......
This diff is collapsed.
......@@ -71,7 +71,7 @@ spring:
- Path=/logservice/**
# 样表服务服务
- id: sample-form-manager
# uri: http://127.0.0.1:17211
#uri: http://192.168.0.98:17002
uri: lb://sample-form-manager
predicates:
- 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