Commit 14a8ec15 authored by 赵啸非's avatar 赵啸非

添加同步删除事项接口

parent 74c41529
......@@ -23,4 +23,12 @@ public interface MatterExtService extends ICRUDService<MatterExtEntity,Long>{
void deleteByMatterId(Long matterId, Context context);
/**
* 同步删除 已经没有的站点事项
* @param siteEntity
* @param context
* @return
*/
Rest<String> syncDelMatterBySiteId(SiteEntity siteEntity, Context context);
}
\ No newline at end of file
......@@ -58,13 +58,11 @@ public class MatterExtServiceImpl extends AbstractCRUDServiceImpl<MatterExtDao,
@Autowired
private MatterService matterService;
@Autowired
private SiteService siteService;
@Autowired
private SiteMatterService siteMatterService;
@Autowired
private SiteThemeMatterService siteThemeMatterService;
@Autowired
private SiteThemeService siteThemeService;
@Autowired
private SiteMatterService siteMatterService;
/**
......@@ -76,30 +74,7 @@ public class MatterExtServiceImpl extends AbstractCRUDServiceImpl<MatterExtDao,
*/
@Override
public Rest<String> syncMatterBySiteId(SiteEntity siteEntity, Context context) {
AreaEntity areaEntity = areaService.getCache(siteEntity.getAreaCode());
List<DeptEntity> deptEntities = deptService.find(new DeptQuery().siteId(siteEntity.getId()).source(SourceEnum.政务网.getValue()));
List<MatterEntity> govMatterList = deptEntities.parallelStream().flatMap(deptEntity -> {
HashMap<String, String> params = new HashMap<>();
params.put("areaCode", areaEntity.getAreaCode());
params.put("dxType", "6");
params.put("deptCode", deptEntity.getDeptNumber());
params.put("searchtext", "");
params.put("taskType", "");
List<MatterEntity> deptMatterList = this.getMatters(params, context);
return deptMatterList.stream();
}).collect(Collectors.toList());
/* for (DeptEntity deptEntity : deptEntities) {
HashMap<String, String> params = new HashMap<>();
params.put("areaCode", areaEntity.getAreaCode());
params.put("dxType", "6");
params.put("deptCode", deptEntity.getDeptNumber());
params.put("searchtext", "");
params.put("taskType", "");
List<MatterEntity> deptMatterList = this.getMatters(params, context);
if (!ObjectUtils.isEmpty(deptMatterList)) {
govMatterList.addAll(deptMatterList);
}
}*/
List<MatterEntity> govMatterList = getMatterEntities(siteEntity, context);
//当前本地区事项全部事项
log.info("计算差集");
MatterQuery matterQuery = new MatterQuery();
......@@ -137,6 +112,22 @@ public class MatterExtServiceImpl extends AbstractCRUDServiceImpl<MatterExtDao,
return Rest.ok();
}
private List<MatterEntity> getMatterEntities(SiteEntity siteEntity, Context context) {
AreaEntity areaEntity = areaService.getCache(siteEntity.getAreaCode());
List<DeptEntity> deptEntities = deptService.find(new DeptQuery().siteId(siteEntity.getId()).source(SourceEnum.政务网.getValue()));
List<MatterEntity> govMatterList = deptEntities.parallelStream().flatMap(deptEntity -> {
HashMap<String, String> params = new HashMap<>();
params.put("areaCode", areaEntity.getAreaCode());
params.put("dxType", "6");
params.put("deptCode", deptEntity.getDeptNumber());
params.put("searchtext", "");
params.put("taskType", "");
List<MatterEntity> deptMatterList = this.getMatters(params, context);
return deptMatterList.stream();
}).collect(Collectors.toList());
return govMatterList;
}
/**
* 同步站点主题事项
*
......@@ -189,7 +180,6 @@ public class MatterExtServiceImpl extends AbstractCRUDServiceImpl<MatterExtDao,
return firstList.parallelStream().filter(item -> !secondSet.contains(item.getMatterNo())).collect(Collectors.toList());
}
private List<MatterEntity> getMatters(HashMap<String, String> params, Context context) {
String url = GlobalSysInfo.getParamValue(Constant.GOV_MATTER_PAGELIST_URL, "http://www.sczwfw.gov.cn/jiq/interface/item/tags");
Rest<Map<String, Integer>> restStat = MatterHtmlParseUtil.statSiteMatterCount(params, url);
......@@ -232,5 +222,41 @@ public class MatterExtServiceImpl extends AbstractCRUDServiceImpl<MatterExtDao,
this.dao.delete(condition);
}
/**
* @param siteEntity
* @param context
* @return
*/
@Override
public Rest<String> syncDelMatterBySiteId(SiteEntity siteEntity, Context context) {
//
List<MatterEntity> govMatterList = getMatterEntities(siteEntity, context);
log.info("计算差集");
MatterQuery matterQuery = new MatterQuery();
matterQuery.setAreaCode(siteEntity.getAreaCode());
matterQuery.setSource(SourceEnum.政务网.getValue());
//本地事项
List<MatterEntity> matterList = matterService.getDao().getMatterListByAreaCode(matterQuery);
log.info("本地事项总数:{}", matterList.size());
//政务网存在set
Set<String> matterExistSet = govMatterList.parallelStream().map(i -> i.getMatterNo()).collect(Collectors.toSet());
List<MatterEntity> delList = this.subListSet(matterList, matterExistSet);
log.info("抓取事项总数:{} ,需要删除事项数量:{}", govMatterList.size(), delList.size());
//删除matter 和siteMatter
if (!ObjectUtils.isEmpty(delList)) {
Long[] delMatterIds = delList.parallelStream().map(i -> i.getId()).toArray(Long[]::new);
matterService.remove(delMatterIds, context);
SiteMatterQuery siteMatterQuery = new SiteMatterQuery();
siteMatterQuery.setMatterIdList(Arrays.asList(delMatterIds));
List<SiteMatterEntity> delSiteMatterList = siteMatterService.find(siteMatterQuery);
if (!ObjectUtils.isEmpty(delSiteMatterList)) {
log.info("删除站点事项数量:{}", delSiteMatterList.size());
siteMatterService.removeList(delSiteMatterList, context);
}
}
return Rest.ok("同步删除成功!");
}
}
\ No newline at end of file
package com.mortals.xhx.module.matter.web;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.matter.model.MatterQuery;
import com.mortals.xhx.module.site.model.SiteQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -47,4 +51,28 @@ public class MatterExtController extends BaseCRUDJsonBodyMappingController<Matte
}
@GetMapping(value = "delMattersBySiteId")
public Rest<Object> delMattersBySiteId(@RequestParam(value = "siteId") Long siteId) {
Rest<Object> ret = new Rest<>();
Map<String, Object> model = new HashMap<>();
String busiDesc = "删除" + this.getModuleDesc();
int code = VALUE_RESULT_SUCCESS;
try {
SiteQuery siteQuery = new SiteQuery();
siteQuery.setId(siteId);
this.service.syncDelMatterBySiteId(siteQuery, getContext());
model.put(MESSAGE_INFO, busiDesc + "成功");
} catch (Exception e) {
code = VALUE_RESULT_FAILURE;
this.doException(request, busiDesc, model, e);
}
ret.setCode(code);
ret.setData(model);
ret.setMsg(model.get(MESSAGE_INFO) == null ? "" : model.remove(MESSAGE_INFO).toString());
return ret;
}
}
\ No newline at end of file
......@@ -27,14 +27,14 @@ POST {{baseUrl}}/app/dataset/list
Content-Type: application/json
{
"appId": 20,
"appId": 84,
"orConditionList": [
{
"fieldName": "制定机关",
"fieldValue": "%四川省人民政府%"
"fieldName": "部门",
"fieldValue": "市公安局"
},{
"fieldName": "标题",
"fieldValue": "%管理办法%"
"fieldName": "员工姓名",
"fieldValue": "%%"
}
],
"page": 1,
......
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