Commit 25a92094 authored by “yiyousong”'s avatar “yiyousong”
parents 5e59d933 0ee29257
...@@ -7,9 +7,11 @@ import com.mortals.framework.annotation.UnAuth; ...@@ -7,9 +7,11 @@ import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
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.ParamDto;
import com.mortals.framework.model.Result; import com.mortals.framework.model.Result;
import com.mortals.framework.web.BaseJsonBodyController; import com.mortals.framework.web.BaseJsonBodyController;
import com.mortals.xhx.common.code.DxTypeEnum; import com.mortals.xhx.common.code.DxTypeEnum;
import com.mortals.xhx.common.code.SourceEnum;
import com.mortals.xhx.common.code.YesNoEnum; import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.keys.RedisCacheKeys; import com.mortals.xhx.common.keys.RedisCacheKeys;
import com.mortals.xhx.module.dept.model.DeptEntity; import com.mortals.xhx.module.dept.model.DeptEntity;
...@@ -40,15 +42,13 @@ import org.apache.http.impl.client.HttpClientBuilder; ...@@ -40,15 +42,13 @@ import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StopWatch;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; 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.Arrays; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.mortals.framework.ap.SysConstains.MESSAGE_INFO; import static com.mortals.framework.ap.SysConstains.MESSAGE_INFO;
...@@ -205,13 +205,68 @@ public class DemoWebApiController { ...@@ -205,13 +205,68 @@ public class DemoWebApiController {
return Rest.ok(); return Rest.ok();
} }
@PostMapping(value = "testAllMatter")
@UnAuth
public Rest<String> testAllMatter(@RequestBody SiteEntity siteEntity) {
StopWatch stopWatch = new StopWatch("stopwatch syncmatter");
log.info("开始查询事项==");
stopWatch.start("开始同步事项方法");
MatterQuery matterQuery = new MatterQuery();
matterQuery.setAreaCode(siteEntity.getAreaCode());
matterQuery.setSource(SourceEnum.政务网.getValue());
List<MatterEntity> matterList = matterService.getDao().getMatterListByAreaCode(matterQuery);
stopWatch.stop();
log.info("本地事项总数:{},{}s", matterList.size(), stopWatch.getLastTaskTimeMillis() / 1000);
return Rest.ok();
}
@PostMapping(value = "testAllMatterPage")
@UnAuth
public Rest<String> testAllMatterPage(@RequestBody SiteEntity siteEntity) {
StopWatch stopWatch = new StopWatch("stopwatch syncmatter");
log.info("开始查询事项==");
stopWatch.start("开始同步事项方法");
MatterQuery matterQuery = new MatterQuery();
matterQuery.setAreaCode(siteEntity.getAreaCode());
matterQuery.setSource(SourceEnum.政务网.getValue());
ParamDto param = new ParamDto();
param.getCondition().put("areaCode", matterQuery.getAreaCode());
if (!ObjectUtils.isEmpty(matterQuery.getSource())) {
param.getCondition().put("source", matterQuery.getSource());
}
int count = matterService.getDao().getMatterListByAreaCodeCount(param);
ArrayList<MatterEntity> allList = new ArrayList<>();
if (count > 0) {
//分页获取
int pages = count / 500+1;
for (int i = 1; i <= pages; i++) {
PageInfo pageInfo = new PageInfo();
pageInfo.setCurrPage(i);
pageInfo.setPrePageResult(500);
Result<MatterEntity> rest = matterService.getDao().getMatterListByAreaCodePage(matterQuery, pageInfo);
allList.addAll(rest.getList());
}
stopWatch.stop();
log.info("本地事项总数:{},{}s", allList.size(), stopWatch.getLastTaskTimeMillis() / 1000);
}
return Rest.ok();
}
public static void main(String[] args) { public static void main(String[] args) {
HttpClient http = null; System.out.println(1001/500);
/* HttpClient http = null;
CookieStore httpCookieStore = new BasicCookieStore(); CookieStore httpCookieStore = new BasicCookieStore();
http = HttpClientBuilder.create().setDefaultCookieStore(httpCookieStore).build(); http = HttpClientBuilder.create().setDefaultCookieStore(httpCookieStore).build();
/* do stuff */ *//* do stuff *//*
HttpGet httpRequest = new HttpGet("http://zxbl.sczwfw.gov.cn/app/account/imageCode"); HttpGet httpRequest = new HttpGet("http://zxbl.sczwfw.gov.cn/app/account/imageCode");
HttpResponse httpResponse = null; HttpResponse httpResponse = null;
try { try {
...@@ -228,9 +283,9 @@ public class DemoWebApiController { ...@@ -228,9 +283,9 @@ public class DemoWebApiController {
} catch (Exception e) { } catch (Exception e) {
log.error("异常", e); log.error("异常", e);
} }
/* check cookies */ *//* check cookies *//*
String cookieStr = Arrays.asList(httpCookieStore.getCookies()).stream().map(item -> JSON.toJSONString(item)).collect(Collectors.joining("|")); String cookieStr = Arrays.asList(httpCookieStore.getCookies()).stream().map(item -> JSON.toJSONString(item)).collect(Collectors.joining("|"));
// log.info("cookies:{}", cookieStr); // log.info("cookies:{}", cookieStr);*/
} }
......
...@@ -17,6 +17,7 @@ import com.mortals.xhx.module.area.service.AreaService; ...@@ -17,6 +17,7 @@ import com.mortals.xhx.module.area.service.AreaService;
import com.mortals.xhx.module.dept.service.DeptService; import com.mortals.xhx.module.dept.service.DeptService;
import com.mortals.xhx.module.matter.model.MatterEntity; import com.mortals.xhx.module.matter.model.MatterEntity;
import com.mortals.xhx.module.matter.model.MatterQuery; import com.mortals.xhx.module.matter.model.MatterQuery;
import com.mortals.xhx.module.matter.service.MatterExtService;
import com.mortals.xhx.module.matter.service.MatterService; import com.mortals.xhx.module.matter.service.MatterService;
import com.mortals.xhx.module.site.model.SiteEntity; import com.mortals.xhx.module.site.model.SiteEntity;
import com.mortals.xhx.module.site.model.SiteMatterEntity; import com.mortals.xhx.module.site.model.SiteMatterEntity;
...@@ -30,6 +31,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -30,6 +31,7 @@ import lombok.extern.slf4j.Slf4j;
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.springframework.util.StopWatch;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -64,13 +66,28 @@ public class SyncMatterTaskImpl implements ITaskExcuteService { ...@@ -64,13 +66,28 @@ public class SyncMatterTaskImpl implements ITaskExcuteService {
@Autowired @Autowired
private ICacheService cacheService; private ICacheService cacheService;
@Autowired
private MatterExtService matterExtService;
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
log.info("开始同步事项!"); log.info("开始同步事项!");
List<SiteEntity> siteEntities = siteService.find(new SiteEntity()); List<SiteEntity> siteEntities = siteService.find(new SiteEntity());
for (SiteEntity siteEntity : siteEntities) { for (SiteEntity siteEntity : siteEntities) {
syncMatter(siteEntity); StopWatch stopWatch = new StopWatch("stopwatch syncmatter");
log.info("开始同步事项==》{}",siteEntity.getSiteName());
stopWatch.start("开始同步事项方法");
matterExtService.doMatterBySiteId(siteEntity,null);
stopWatch.stop();
log.info("同步事项完成,耗时:{}s", stopWatch.getLastTaskTimeMillis()/1000);
log.info("开始添加站点事项==》{}",siteEntity.getSiteName());
stopWatch.start("开始添加站点事项");
siteMatterService.doSyncSiteMatter(siteEntity, null);
stopWatch.stop();
log.info("开始添加站点事项,耗时:{} s", stopWatch.getLastTaskTimeMillis()/1000);
// syncMatter(siteEntity);
} }
// syncDevice(); // syncDevice();
log.info("结束同步事项!"); log.info("结束同步事项!");
...@@ -82,8 +99,9 @@ public class SyncMatterTaskImpl implements ITaskExcuteService { ...@@ -82,8 +99,9 @@ public class SyncMatterTaskImpl implements ITaskExcuteService {
Rest<String> deptRest = deptService.syncDeptBySiteId(siteEntity, null); Rest<String> deptRest = deptService.syncDeptBySiteId(siteEntity, null);
log.info("同步站点部门结果:" + JSON.toJSONString(deptRest)); log.info("同步站点部门结果:" + JSON.toJSONString(deptRest));
Rest<String> rest = siteService.syncMatterBySiteId(siteEntity, null); Rest<String> rest = siteService.syncMatterBySiteId(siteEntity, null);
log.info("同步事项列表:" + JSON.toJSONString(rest)); //log.info("同步事项列表:" + JSON.toJSONString(rest));
if (rest.getCode() == YesNoEnum.YES.getValue()) { if (rest.getCode() == YesNoEnum.YES.getValue()) {
List<MatterEntity> matterEntityList = matterService.find(new MatterQuery().areaCode(siteEntity.getAreaCode()).source(SourceEnum.政务网.getValue())); List<MatterEntity> matterEntityList = matterService.find(new MatterQuery().areaCode(siteEntity.getAreaCode()).source(SourceEnum.政务网.getValue()));
log.info("查询本地事项列表,size:{}",matterEntityList.size()); log.info("查询本地事项列表,size:{}",matterEntityList.size());
List<MatterEntity> unSyncDetailMatterList = matterEntityList.stream() List<MatterEntity> unSyncDetailMatterList = matterEntityList.stream()
......
...@@ -2,6 +2,7 @@ package com.mortals.xhx.module.matter.dao; ...@@ -2,6 +2,7 @@ package com.mortals.xhx.module.matter.dao;
import com.mortals.framework.dao.ICRUDDao; import com.mortals.framework.dao.ICRUDDao;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.ParamDto;
import com.mortals.framework.model.Result; import com.mortals.framework.model.Result;
import com.mortals.xhx.module.matter.model.MatterEntity; import com.mortals.xhx.module.matter.model.MatterEntity;
import org.apache.poi.ss.formula.functions.T; import org.apache.poi.ss.formula.functions.T;
...@@ -21,7 +22,19 @@ public interface MatterDao extends ICRUDDao<MatterEntity, Long> { ...@@ -21,7 +22,19 @@ public interface MatterDao extends ICRUDDao<MatterEntity, Long> {
String SQLID_SUB_COUNT = "getSubListCount"; String SQLID_SUB_COUNT = "getSubListCount";
String SQLID_MATTERLIST_AREACODE = "getMatterListByAreaCode";
String SQLID_MATTERLIST_AREACODE_COUNT = "getMatterListByAreaCodeCount";
Result<MatterEntity> getSubList(MatterEntity matterQuery, PageInfo pageInfo); Result<MatterEntity> getSubList(MatterEntity matterQuery, PageInfo pageInfo);
List<MatterEntity> getMatterListByAreaCode(MatterEntity matterQuery); List<MatterEntity> getMatterListByAreaCode(MatterEntity matterQuery);
Result<MatterEntity> getMatterListByAreaCodePage(MatterEntity matterQuery, PageInfo pageInfo);
int getMatterListByAreaCodeCount(ParamDto paramDto);
} }
...@@ -13,6 +13,7 @@ import java.util.ArrayList; ...@@ -13,6 +13,7 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis; import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import org.springframework.util.ObjectUtils;
import java.util.List; import java.util.List;
...@@ -50,13 +51,45 @@ public class MatterDaoImpl extends BaseCRUDDaoMybatis<MatterEntity, Long> implem ...@@ -50,13 +51,45 @@ public class MatterDaoImpl extends BaseCRUDDaoMybatis<MatterEntity, Long> implem
public int getSubCount(ParamDto paramDto) { public int getSubCount(ParamDto paramDto) {
return this.getSqlSession().selectOne(this.getSqlId(SQLID_SUB_COUNT), this.cpyQueryParamDto(paramDto)); return this.getSqlSession().selectOne(this.getSqlId(SQLID_SUB_COUNT), this.cpyQueryParamDto(paramDto));
} }
@Override
public int getMatterListByAreaCodeCount(ParamDto paramDto) {
return this.getSqlSession().selectOne(this.getSqlId(SQLID_MATTERLIST_AREACODE_COUNT), this.cpyQueryParamDto(paramDto));
}
@Override @Override
public List<MatterEntity> getMatterListByAreaCode(MatterEntity matterQuery) { public List<MatterEntity> getMatterListByAreaCode(MatterEntity matterQuery) {
ParamDto param = new ParamDto(); ParamDto param = new ParamDto();
param.getCondition().put("areaCode", matterQuery.getAreaCode()); param.getCondition().put("areaCode", matterQuery.getAreaCode());
if(!ObjectUtils.isEmpty(matterQuery.getSource())){
param.getCondition().put("source", matterQuery.getSource());
}
return this.getSqlSession().selectList(this.getSqlId("getMatterListByAreaCode"), param); return this.getSqlSession().selectList(this.getSqlId("getMatterListByAreaCode"), param);
} }
/**
* @param matterQuery
* @param pageInfo
* @return
*/
@Override
public Result<MatterEntity> getMatterListByAreaCodePage(MatterEntity matterQuery, PageInfo pageInfo) {
Result<MatterEntity> result = new Result();
ParamDto paramDto = this.getQueryParam(matterQuery);
int count = this.getMatterListByAreaCodeCount(paramDto);
List list = null;
if (count == 0) {
list = new ArrayList();
} else if (pageInfo.getPrePageResult() == -1) {
list = this.getSqlSession().selectList(this.getSqlId(SQLID_MATTERLIST_AREACODE), paramDto);
} else {
RowBounds rowBounds = new RowBounds(pageInfo.getBeginIndex(), pageInfo.getPrePageResult());
list = this.getSqlSession().selectList(this.getSqlId(SQLID_MATTERLIST_AREACODE), this.cpyQueryParamDto(paramDto), rowBounds);
}
pageInfo.setTotalResult(count);
result.setPageInfo(pageInfo);
result.setList(list);
return result;
}
} }
package com.mortals.xhx.module.matter.service; package com.mortals.xhx.module.matter.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.dao.MatterExtDao; import com.mortals.xhx.module.matter.dao.MatterExtDao;
import com.mortals.xhx.module.matter.model.MatterExtEntity; import com.mortals.xhx.module.matter.model.MatterExtEntity;
import com.mortals.xhx.module.site.model.SiteEntity;
/** /**
* MatterExtService * MatterExtService
* *
...@@ -12,5 +16,12 @@ import com.mortals.xhx.module.matter.model.MatterExtEntity; ...@@ -12,5 +16,12 @@ import com.mortals.xhx.module.matter.model.MatterExtEntity;
*/ */
public interface MatterExtService extends ICRUDService<MatterExtEntity,Long>{ public interface MatterExtService extends ICRUDService<MatterExtEntity,Long>{
MatterExtDao getDao();
Rest<String> doMatterBySiteId(SiteEntity siteEntity, Context context);
Rest<String> doMatterThemeBySiteId(SiteEntity siteEntity, Context context);
void deleteByMatterId(Long matterId, Context context);
} }
\ No newline at end of file
...@@ -267,11 +267,11 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter ...@@ -267,11 +267,11 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
siteMatterEntity.setMatterId(item.getId()); siteMatterEntity.setMatterId(item.getId());
siteMatterEntity.setMatterCode(item.getMatterNo()); siteMatterEntity.setMatterCode(item.getMatterNo());
siteMatterEntity.setMatterName(item.getMatterName()); siteMatterEntity.setMatterName(item.getMatterName());
siteMatterEntity.setDeptCode(item.getDeptCode());
siteMatterEntity.setSource(item.getSource()); siteMatterEntity.setSource(item.getSource());
siteMatterEntity.setEventTypeShow(item.getEventTypeShow()); siteMatterEntity.setEventTypeShow(item.getEventTypeShow());
siteMatterEntity.setDeptName(deptEntity == null ? "" : deptEntity.getName()); siteMatterEntity.setDeptName(deptEntity == null ? "" : deptEntity.getName());
siteMatterEntity.setDeptId(deptEntity == null ? -1L : deptEntity.getId()); siteMatterEntity.setDeptId(deptEntity == null ? -1L : deptEntity.getId());
siteMatterEntity.setDeptCode(deptEntity == null ? "" : deptEntity.getDeptNumber());
siteMatterEntity.setCreateUserId(context == null ? 1L : context.getUser() == null ? 1L : context.getUser().getId()); siteMatterEntity.setCreateUserId(context == null ? 1L : context.getUser() == null ? 1L : context.getUser().getId());
siteMatterEntity.setCreateTime(new Date()); siteMatterEntity.setCreateTime(new Date());
return Rest.ok(siteMatterEntity); return Rest.ok(siteMatterEntity);
...@@ -286,7 +286,8 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter ...@@ -286,7 +286,8 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
public Result<MatterEntity> findSubList(MatterEntity matterQuery, PageInfo pageInfo, Context context) throws AppException { public Result<MatterEntity> findSubList(MatterEntity matterQuery, PageInfo pageInfo, Context context) throws AppException {
// SiteEntity siteCache = siteService.getCache(matterQuery.getSiteId().toString()); // SiteEntity siteCache = siteService.getCache(matterQuery.getSiteId().toString());
SiteEntity siteCache = siteService.get(matterQuery.getSiteId()); SiteEntity siteCache = siteService.get(matterQuery.getSiteId());
if(ObjectUtils.isEmpty(siteCache)) throw new AppException("查询站点id不能为空!siteId:"+matterQuery.getSiteId()); if (ObjectUtils.isEmpty(siteCache))
throw new AppException("查询站点id不能为空!siteId:" + matterQuery.getSiteId());
if (ObjectUtils.isEmpty(matterQuery.getAreaCode())) { if (ObjectUtils.isEmpty(matterQuery.getAreaCode())) {
matterQuery.setAreaCode(siteCache == null ? null : siteCache.getAreaCode()); matterQuery.setAreaCode(siteCache == null ? null : siteCache.getAreaCode());
} }
...@@ -1021,7 +1022,11 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter ...@@ -1021,7 +1022,11 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
//根据事项url 获取事项详细信息,构建相关详细信息 //根据事项url 获取事项详细信息,构建相关详细信息
String html = null; String html = null;
try { try {
Document dom = Jsoup.connect(matterEntity.getUrl()).timeout(30*1000).get(); if (ObjectUtils.isEmpty(matterEntity.getUrl())) {
return Rest.fail("事项url不能为空!");
}
Document dom = Jsoup.connect(matterEntity.getUrl()).timeout(60 * 1000).get();
// html = Jsoup.connect(matterEntity.getUrl()).get().body().html(); // html = Jsoup.connect(matterEntity.getUrl()).get().body().html();
// html = HttpUtil.get(matterEntity.getUrl()); // html = HttpUtil.get(matterEntity.getUrl());
//System.out.println(html); //System.out.println(html);
...@@ -1030,16 +1035,25 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter ...@@ -1030,16 +1035,25 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
Setting baseInfoSetting = interceptorConfig.getBaseInfoSetting(); Setting baseInfoSetting = interceptorConfig.getBaseInfoSetting();
Setting sqclInfoSetting = interceptorConfig.getSqclInfoSetting(); Setting sqclInfoSetting = interceptorConfig.getSqclInfoSetting();
//更新部门信息
DeptEntity extCache = deptService.getExtCache(matterEntity.getDeptCode());
matterEntity.setDeptName(extCache == null ? "" : extCache.getName());
/* if(!ObjectUtils.isEmpty(matterEntity.getDeptCode())&&ObjectUtils.isEmpty(matterEntity.getDeptName())){ /* if(!ObjectUtils.isEmpty(matterEntity.getDeptCode())&&ObjectUtils.isEmpty(matterEntity.getDeptName())){
DeptEntity extCache = deptService.getExtCache(matterEntity.getDeptCode()); DeptEntity extCache = deptService.getExtCache(matterEntity.getDeptCode());
matterEntity.setDeptName(extCache==null?"":extCache.getName()); matterEntity.setDeptName(extCache==null?"":extCache.getName());
}*/ }*/
//根据本地与远端事项版本觉得是否更新或者新增
Integer matterEditionLocal = DataUtil.converStr2Int(matterEntity.getMatterEdition(), 0);
Map<String, String> baseInfoMap = MatterDetailHtmlParseUtil.getbaseInfoMapByHtml(dom);
Integer matterEditionRemote = DataUtil.converStr2Int(baseInfoMap.getOrDefault("事项版本", "0"), 0);
if (matterEditionLocal >= matterEditionRemote) {
return Rest.fail("本地事项版本大于等于远端,不需要更新!");
}
//更新部门信息
DeptEntity extCache = deptService.getExtCache(matterEntity.getDeptCode());
matterEntity.setDeptName(extCache == null ? "" : extCache.getName());
//构建基础信息参数 //构建基础信息参数
savebaseInfo(matterEntity, dom, baseInfoSetting); savebaseInfo(matterEntity, baseInfoMap, baseInfoSetting);
//更新材料属性 //更新材料属性
saveDatumInfo(matterEntity, context, dom, sqclInfoSetting); saveDatumInfo(matterEntity, context, dom, sqclInfoSetting);
...@@ -1168,8 +1182,8 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter ...@@ -1168,8 +1182,8 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
matterChargesService.save(matterChargesEntity); matterChargesService.save(matterChargesEntity);
} }
private void savebaseInfo(MatterEntity matterEntity, Document dom, Setting baseInfoSetting) { private void savebaseInfo(MatterEntity matterEntity, Map<String, String> baseInfoMap, Setting baseInfoSetting) {
Map<String, String> baseInfoMap = MatterDetailHtmlParseUtil.getbaseInfoMapByHtml(dom); //Map<String, String> baseInfoMap = MatterDetailHtmlParseUtil.getbaseInfoMapByHtml(dom);
List<MatterExtEntity> matterExtEntities = new ArrayList<>(); List<MatterExtEntity> matterExtEntities = new ArrayList<>();
long sortN = 1; long sortN = 1;
for (Map.Entry<String, String> m : baseInfoMap.entrySet()) { for (Map.Entry<String, String> m : baseInfoMap.entrySet()) {
...@@ -1202,6 +1216,7 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter ...@@ -1202,6 +1216,7 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
if (!ObjectUtils.isEmpty(matterExtEntities)) { if (!ObjectUtils.isEmpty(matterExtEntities)) {
//先删除后添加 //先删除后添加
matterExtService.deleteByMatterId(matterEntity.getId(), null);
matterExtService.save(matterExtEntities, null); matterExtService.save(matterExtEntities, null);
} }
...@@ -1209,7 +1224,7 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter ...@@ -1209,7 +1224,7 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
private void saveBllcInfo(MatterEntity matterEntity, Context context, Document dom) { private void saveBllcInfo(MatterEntity matterEntity, Context context, Document dom) {
List<Map<String, Object>> bllcMapList = MatterDetailHtmlParseUtil.getbllcMapByHtml(dom); List<Map<String, Object>> bllcMapList = MatterDetailHtmlParseUtil.getbllcMapByHtml(dom);
matterFlowlimitService.deleteByMatterId(matterEntity.getId(), context);
List<MatterFlowlimitEntity> flowlimitEntityArrayList = new ArrayList<>(); List<MatterFlowlimitEntity> flowlimitEntityArrayList = new ArrayList<>();
for (Map<String, Object> bllcMap : bllcMapList) { for (Map<String, Object> bllcMap : bllcMapList) {
MatterFlowlimitEntity matterFlowlimitEntity = new MatterFlowlimitEntity(); MatterFlowlimitEntity matterFlowlimitEntity = new MatterFlowlimitEntity();
...@@ -1238,9 +1253,14 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter ...@@ -1238,9 +1253,14 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
}); });
flowlimitEntityArrayList.add(matterFlowlimitEntity); flowlimitEntityArrayList.add(matterFlowlimitEntity);
} }
if (!ObjectUtils.isEmpty(flowlimitEntityArrayList)) {
matterFlowlimitService.deleteByMatterId(matterEntity.getId(), context);
matterFlowlimitService.save(flowlimitEntityArrayList); matterFlowlimitService.save(flowlimitEntityArrayList);
} }
}
private void saveSltjInfo(MatterEntity matterEntity, Context context, Document dom) { private void saveSltjInfo(MatterEntity matterEntity, Context context, Document dom) {
matterAcceptService.deleteByMatterId(matterEntity.getId(), context); matterAcceptService.deleteByMatterId(matterEntity.getId(), context);
Map<String, String> sltjMap = MatterDetailHtmlParseUtil.getSltjMapByHtml(dom); Map<String, String> sltjMap = MatterDetailHtmlParseUtil.getSltjMapByHtml(dom);
......
package com.mortals.xhx.module.site.service; package com.mortals.xhx.module.site.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.site.dao.SiteMatterDao; import com.mortals.xhx.module.site.dao.SiteMatterDao;
import com.mortals.xhx.module.site.model.SiteEntity;
import com.mortals.xhx.module.site.model.SiteMatterEntity; import com.mortals.xhx.module.site.model.SiteMatterEntity;
/** /**
...@@ -17,5 +19,8 @@ public interface SiteMatterService extends ICRUDService<SiteMatterEntity, Long> ...@@ -17,5 +19,8 @@ public interface SiteMatterService extends ICRUDService<SiteMatterEntity, Long>
SiteMatterDao getDao(); SiteMatterDao getDao();
Rest<String> doSyncSiteMatter(SiteEntity siteEntity,Context context);
void deleteBysiteIdAndSource(Long siteId, Integer source, Context context); void deleteBysiteIdAndSource(Long siteId, Integer source, 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 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.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.common.code.SourceEnum;
import com.mortals.xhx.module.matter.model.MatterEntity; import com.mortals.xhx.module.matter.model.MatterEntity;
import com.mortals.xhx.module.matter.model.MatterQuery; import com.mortals.xhx.module.matter.model.MatterQuery;
import com.mortals.xhx.module.matter.service.MatterService; import com.mortals.xhx.module.matter.service.MatterService;
import com.mortals.xhx.module.site.model.SiteThemeMatterEntity; import com.mortals.xhx.module.site.model.*;
import com.mortals.xhx.module.site.model.SiteThemeMatterQuery; import com.mortals.xhx.module.site.service.SiteService;
import com.mortals.xhx.module.site.service.SiteThemeMatterService; import com.mortals.xhx.module.site.service.SiteThemeMatterService;
import com.mortals.xhx.module.site.service.SiteThemeService; import com.mortals.xhx.module.site.service.SiteThemeService;
import lombok.extern.slf4j.Slf4j;
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.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.site.dao.SiteMatterDao; import com.mortals.xhx.module.site.dao.SiteMatterDao;
import com.mortals.xhx.module.site.model.SiteMatterEntity;
import com.mortals.xhx.module.site.service.SiteMatterService; import com.mortals.xhx.module.site.service.SiteMatterService;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.util.HashMap; 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.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -31,12 +34,15 @@ import java.util.stream.Collectors; ...@@ -31,12 +34,15 @@ import java.util.stream.Collectors;
* @date 2022-01-12 * @date 2022-01-12
*/ */
@Service("siteMatterService") @Service("siteMatterService")
@Slf4j
public class SiteMatterServiceImpl extends AbstractCRUDServiceImpl<SiteMatterDao, SiteMatterEntity, Long> implements SiteMatterService { public class SiteMatterServiceImpl extends AbstractCRUDServiceImpl<SiteMatterDao, SiteMatterEntity, Long> implements SiteMatterService {
@Autowired @Autowired
private MatterService matterService; private MatterService matterService;
@Autowired @Autowired
private SiteThemeMatterService siteThemeMatterService; private SiteThemeMatterService siteThemeMatterService;
@Autowired
private SiteService siteService;
@Override @Override
protected void findAfter(SiteMatterEntity params, PageInfo pageInfo, Context context, List<SiteMatterEntity> list) throws AppException { protected void findAfter(SiteMatterEntity params, PageInfo pageInfo, Context context, List<SiteMatterEntity> list) throws AppException {
...@@ -109,4 +115,54 @@ public class SiteMatterServiceImpl extends AbstractCRUDServiceImpl<SiteMatterDao ...@@ -109,4 +115,54 @@ public class SiteMatterServiceImpl extends AbstractCRUDServiceImpl<SiteMatterDao
condition.put("source", source); condition.put("source", source);
this.dao.delete(condition); this.dao.delete(condition);
} }
/**
* @param siteEntity
* @param context
* @return
*/
@Override
public Rest<String> doSyncSiteMatter(SiteEntity siteEntity, Context context) {
List<MatterEntity> matterList = matterService.getDao().getMatterListByAreaCode(new MatterQuery().areaCode(siteEntity.getAreaCode()).source(SourceEnum.政务网.getValue()));
//查询站点事项相关
SiteEntity site = siteService.selectOne(new SiteQuery().areaCode(siteEntity.getAreaCode()));
if (!ObjectUtils.isEmpty(site)) {
log.info("同步站点事项到站点.....");
SiteMatterQuery siteMatterQuery = new SiteMatterQuery();
siteMatterQuery.setSiteId(site.getId());
siteMatterQuery.setSource(SourceEnum.政务网.getValue());
List<SiteMatterEntity> localList = this.getDao().getList(siteMatterQuery);
log.info("本地站点事项数量.....{}",localList.size());
//找到差集 然后添加
Set<Long> existSiteMatterIdSet = localList.parallelStream().map(i -> i.getMatterId()).collect(Collectors.toSet());
List<MatterEntity> subList = matterList.parallelStream().filter(f -> !existSiteMatterIdSet.contains(f.getId())).collect(Collectors.toList());
if(!ObjectUtils.isEmpty(subList)){
//需要新增的站点事项
log.info("需要新增的站点事项数量.....{}",subList.size());
List<SiteMatterEntity> siteMatterList = subList
.parallelStream()
.map(item ->matterService.switchMatterToSiteMatter(item, site, null).getData())
.filter(f -> f != null)
.collect(Collectors.toList());
this.save(siteMatterList);
}
/*
//判断是否已经有站点事项,如果有则不添加
Boolean bool = checkSiteMatter(site);
if (!bool) {
//添加站点事项 批量添加
List<SiteMatterEntity> siteMatterList = matterList.stream().map(item -> {
return matterService.switchMatterToSiteMatter(item, site, null).getData();
}).filter(f -> f != null).collect(Collectors.toList());
this.save(siteMatterList);
}
*/
log.info("同步站点事项到站点完成.....");
}
return Rest.ok();
}
} }
\ No newline at end of file
...@@ -65,9 +65,37 @@ ...@@ -65,9 +65,37 @@
</trim> </trim>
</select> </select>
<select id="getMatterListByAreaCodeCount" parameterType="paramDto" resultType="int">
select
count( 1 )
FROM
mortals_sys_matter AS a
where
<trim prefixOverrides="and" prefix="">
<if test="condition.areaCode!=null and condition.areaCode!=''">
and a.areaCode = #{condition.areaCode,jdbcType=VARCHAR}
</if>
</trim>
<if test="condition.source!=null and condition.source!=''">
and a.source = #{condition.source,jdbcType=INTEGER}
</if>
</select>
<select id="getMatterListByAreaCode" parameterType="paramDto" resultMap="MatterEntity-Map"> <select id="getMatterListByAreaCode" parameterType="paramDto" resultMap="MatterEntity-Map">
select select
a.matterNo a.id,
a.matterNo,
a.matterName,
a.deptCode,
a.source,
a.url,
a.matterEdition,
a.eventTypeShow
FROM FROM
mortals_sys_matter AS a mortals_sys_matter AS a
where where
...@@ -76,6 +104,11 @@ ...@@ -76,6 +104,11 @@
and a.areaCode = #{condition.areaCode,jdbcType=VARCHAR} and a.areaCode = #{condition.areaCode,jdbcType=VARCHAR}
</if> </if>
</trim> </trim>
<if test="condition.source!=null and condition.source!=''">
and a.source = #{condition.source,jdbcType=INTEGER}
</if>
</select> </select>
</mapper> </mapper>
\ No newline at end of file
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