Commit 20bfcbd5 authored by 赵啸非's avatar 赵啸非

添加查询通用字典接口

parent 2e0a8ac7
......@@ -49,8 +49,7 @@ public class ParamController extends BaseCRUDJsonBodyMappingController<ParamServ
}
@RequestMapping(method = {RequestMethod.GET,RequestMethod.POST},value = "key")
@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, value = "key")
@UnAuth
public String getValueByKey(@RequestParam(name = "key") String key) {
JSONObject jsonObject = new JSONObject();
......@@ -70,6 +69,27 @@ public class ParamController extends BaseCRUDJsonBodyMappingController<ParamServ
}
@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, value = "dict")
@UnAuth
public String getDict(@RequestParam(name = "first") String first, @RequestParam(name = "second") String second) {
JSONObject jsonObject = new JSONObject();
String busiDesc = "通过key查询字典参数值" + this.getModuleDesc();
try {
Map<String, String> dict = this.service.getParamBySecondOrganize(first, second);
// String value = this.service.getValueByKey(key);
jsonObject.put(KEY_RESULT_DATA, dict);
recordSysLog(request, busiDesc + " 【成功】");
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, busiDesc + "成功!");
} 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();
}
private Map<String, Object> getPageDisplayType() {
PageDisplayType[] pageDisplayTypes = PageDisplayType.values();
Map<String, Object> result = new HashMap<>(pageDisplayTypes.length);
......
......@@ -2,17 +2,35 @@ package com.mortals.xhx.common.utils;
import cn.hutool.core.util.StrUtil;
import com.mortals.xhx.common.code.AreaLevelEnum;
import com.mortals.xhx.common.code.SourceType;
public class AreaMatchCodeUtil {
/**
* 遂宁市 510900000000
* 蓬溪县 510921000000
* 普安街 510921174000
*
* @param matchCode
* @param areaLevel
* @return
*/
public static String getMatchCode(String matchCode, Integer areaLevel) {
if (AreaLevelEnum.地市州.getValue() == areaLevel) {
return StrUtil.padAfter(matchCode, 4, "0");
matchCode=StrUtil.sub(matchCode, 0, 3);
return StrUtil.padAfter(matchCode, 3, "0");
} else if (AreaLevelEnum.区县.getValue() == areaLevel) {
return StrUtil.padAfter(matchCode, 7, "0");
//510921174000
matchCode=StrUtil.sub(matchCode, 0, 6);
return StrUtil.padAfter(matchCode, 6, "0");
} else if (AreaLevelEnum.街道.getValue() == areaLevel) {
return StrUtil.padAfter(matchCode, 10, "0");
//510921174000
//510921100249
matchCode=StrUtil.sub(matchCode, 0, 9);
return StrUtil.padAfter(matchCode, 9, "0");
} else if (AreaLevelEnum.社区.getValue() == areaLevel) {
return StrUtil.padAfter(matchCode, 12, "0");
} else {
......@@ -20,4 +38,10 @@ public class AreaMatchCodeUtil {
}
}
public static void main(String[] args) {
System.out.println(getMatchCode("510921000000", 3));
System.out.println(getMatchCode("510921174000", 4));
// System.out.println(getMatchCode("510921100249", 5));
}
}
......@@ -505,7 +505,7 @@ public class MatterDetailHtmlParseUtil {
// String url = "http://www.sczwfw.gov.cn/jiq/front/transition/ywTransToDetail?areaCode=511500000000&itemCode=511A0151400000-511500000000-000-511501-7-1-00&taskType=1&deptCode=511501-7";
// String url = "http://www.sczwfw.gov.cn/jiq/front/transition/ywTransToDetail?areaCode=511500000000&itemCode=511A0000400004-511500000000-000-1151120000870212XU-1-00&taskType=1&deptCode=3922757070285361152";
String url = "https://www.sczwfw.gov.cn/jiq/front/transition/ywTransToDetail?areaCode=511500000000&itemCode=512036008003-511500000000-000-11511200MB1503849K-1-00&taskType=20&deptCode=3907787168696946688";
String url = "http://www.sczwfw.gov.cn/jiq/front/transition/ywTransToDetail?areaCode=511500000000&itemCode=512036008003-511500000000-000-11511200MB1503849K-1-00&taskType=20&deptCode=3907787168696946688";
Document dom = MatterDetailHtmlParseUtil.getDomByHtml(url);
Map<String, String> baseInfoMap = MatterDetailHtmlParseUtil.getbaseInfoMapByHtml(dom);
......
package com.mortals.xhx.daemon.task;
import cn.hutool.core.collection.ListUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
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.keys.RedisCacheKeys;
import com.mortals.xhx.module.area.model.AreaEntity;
import com.mortals.xhx.module.area.service.AreaService;
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.model.SiteMatterEntity;
import com.mortals.xhx.module.site.model.SiteMatterQuery;
import com.mortals.xhx.module.site.model.SiteQuery;
import com.mortals.xhx.module.site.service.SiteMatterService;
import com.mortals.xhx.module.site.service.SiteService;
import com.mortals.xhx.module.site.service.SiteThemeMatterService;
import com.mortals.xhx.module.site.service.SiteThemeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 同步全部站点事项
*
* @author: zxfei
* @date: 2024/2/27 15:34
*/
@Slf4j
@Service("SyncMatterTask")
public class SyncMatterTaskImpl implements ITaskExcuteService {
@Autowired
private SiteService siteService;
private MatterService matterService;
private AreaService areaService;
private DeptService deptService;
private SiteMatterService siteMatterService;
private SiteThemeService siteThemeService;
private SiteThemeMatterService siteThemeMatterService;
private SiteEntity siteEntity;
private Context context;
private ICacheService cacheService;
@Override
public void excuteTask(ITask task) throws AppException {
log.info("开始同步事项!");
List<SiteEntity> siteEntities = siteService.find(new SiteEntity());
for (SiteEntity siteEntity : siteEntities) {
syncMatter(siteEntity);
}
// syncDevice();
log.info("结束同步事项!");
}
private void syncMatter(SiteEntity siteEntity) throws AppException {
AreaEntity areaEntity = areaService.getCache(siteEntity.getAreaCode());
log.info("同步站点事项开始.....");
Rest<String> deptRest = deptService.syncDeptBySiteId(siteEntity, context);
log.info("同步站点部门结果:" + JSON.toJSONString(deptRest));
Rest<String> rest = siteService.syncMatterBySiteId(siteEntity, context);
log.info("同步事项列表:" + JSON.toJSONString(rest));
if (rest.getCode() == YesNoEnum.YES.getValue()) {
List<MatterEntity> matterEntityList = matterService.find(new MatterQuery().areaCode(siteEntity.getAreaCode()).source(SourceEnum.政务网.getValue()));
log.info("查询本地事项列表,size:{}",matterEntityList.size());
List<MatterEntity> unSyncDetailMatterList = matterEntityList.stream()
// .filter(f -> f.getHaveGetMatterInfo().equalsIgnoreCase("false"))
.collect(Collectors.toList());
//查询站点事项相关
List<SiteEntity> siteEntities = siteService.find(new SiteQuery().areaCode(siteEntity.getAreaCode()));
//删除站点与政务事项相关项
/* for (SiteEntity site : siteEntities) {
siteMatterService.deleteBysiteIdAndSource(site.getId(), SourceEnum.政务网.getValue(), context);
}*/
//重新添加
if (!ObjectUtils.isEmpty(siteEntities)) {
log.info("同步站点事项到站点.....");
for (SiteEntity site : siteEntities) {
//判断是否已经有站点事项,如果有则不添加
SiteMatterQuery siteMatterQuery = new SiteMatterQuery();
siteMatterQuery.setSiteId(site.getId());
siteMatterQuery.setSource(SourceEnum.政务网.getValue());
int count = siteMatterService.count(siteMatterQuery, null);
if (count > 0) {
continue;
}
List<SiteMatterEntity> siteMatterList = matterEntityList.stream().map(item -> {
return matterService.switchMatterToSiteMatter(item, site, context).getData();
}).filter(f -> f != null).collect(Collectors.toList());
List<List<SiteMatterEntity>> partition = ListUtil.partition(siteMatterList, 100);
for (List<SiteMatterEntity> rests : partition) {
siteMatterService.save(rests);
}
}
log.info("同步站点事项到站点完成.....");
}
log.info("同步站点事项详细条数....." + unSyncDetailMatterList.size());
unSyncDetailMatterList.parallelStream().forEach(matterEntity -> {
matterService.buildMatterDetail(matterEntity, context);
matterEntity.setUpdateTime(new Date());
matterService.update(matterEntity, context);
});
}
log.info("同步站点主题事项开始.....");
//判断站点区域乡镇情况
if (areaEntity.getAreaLevel() <= 3) {
//省,市,区
Rest<String> themeRest = siteThemeService.syncThemeBySiteId(siteEntity, context);
log.info("同步站点主题:" + JSON.toJSONString(themeRest));
log.info("同步站点个人主题事项开始.....");
siteThemeMatterService.deleteGovBySiteId(siteEntity.getId(), context);
Rest<String> grRest = siteThemeMatterService.syncThemeMatterBySiteId(siteEntity.getId(), "2", context);
log.info("同步站点主题个人事项:" + JSON.toJSONString(grRest));
log.info("同步站点法人主题事项开始.....");
Rest<String> frRest = siteThemeMatterService.syncThemeMatterBySiteId(siteEntity.getId(), "3", context);
log.info("同步站点主题法人事项:" + JSON.toJSONString(frRest));
} else if (areaEntity.getAreaLevel() > 3) {
//街道,镇,乡
Rest<String> themeTownRest = siteThemeService.syncTownThemeBySiteId(siteEntity, context);
log.info("同步乡镇站点主题:" + JSON.toJSONString(themeTownRest));
if (themeTownRest.getCode() == YesNoEnum.YES.getValue()) {
siteThemeMatterService.deleteGovBySiteId(siteEntity.getId(), context);
String dxType = DxTypeEnum.街道镇服务.getValue();
if (areaEntity.getAreaLevel() == 5) {
dxType = DxTypeEnum.乡村服务.getValue();
}
Rest<String> townThemeRest = siteThemeMatterService.syncTownThemeMatterBySiteId(siteEntity, dxType, context);
log.info("同步站点乡镇主题事项:" + JSON.toJSONString(townThemeRest));
} else {
try {
cacheService.del(RedisCacheKeys.getSyncMatterLockKey() + siteEntity.getAreaCode(), siteEntity.getAreaCode());
log.info("同步站点乡镇主题事项失败:" + themeTownRest.getData());
}catch (Exception e){
log.error("同步站点乡镇主题事项失败",e);
}
}
}
log.info("同步站点事项结束.....");
}
@Override
public void stopTask(ITask task) throws AppException {
}
}
......@@ -136,7 +136,6 @@ public class DeptServiceImpl extends AbstractCRUDCacheServiceImpl<DeptDao, DeptE
String deptCode = item.getKey();
String deptName = item.getValue();
DeptEntity deptEntity = deptService.getExtCache(deptCode);
// DeptEntity deptEntity = deptService.selectOne(new DeptQuery().siteId(siteId).deptNumber(deptCode), context);
if (ObjectUtils.isEmpty(deptEntity)) {
deptEntity = new DeptEntity();
deptEntity.initAttrValue();
......
......@@ -1202,8 +1202,6 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
if (!ObjectUtils.isEmpty(matterExtEntities)) {
//先删除后添加
matterExtService.save(matterExtEntities, null);
}
......
......@@ -22,6 +22,7 @@ import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.code.AreaLevelDxTypeEnum;
import com.mortals.xhx.common.code.AreaLevelEnum;
import com.mortals.xhx.common.code.SourceEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.pdu.RespData;
......@@ -702,7 +703,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
//String dxType = "3";
log.info("抓取事项开始");
List<MatterEntity> govMatterList = new ArrayList<>();
List<DeptEntity> deptEntities = deptService.find(new DeptQuery().siteId(siteEntity.getId()).source(0));
List<DeptEntity> deptEntities = deptService.find(new DeptQuery().siteId(siteEntity.getId()).source(SourceEnum.政务网.getValue()));
for (DeptEntity deptEntity : deptEntities) {
HashMap<String, String> params = new HashMap<>();
params.put("areaCode", areaEntity.getAreaCode());
......
......@@ -54,7 +54,7 @@ POST {{baseUrl}}/base/area/genSubAreaByAreaName
Content-Type: application/json
{
"areaCode": "513232000000"
"areaCode": "510921000000"
}
......
......@@ -20,12 +20,8 @@ POST {{baseUrl}}/matter/list
Content-Type: application/json
{
"siteId": 1,
"matterName": "%%",
"page": 1,
"size": 10,
"deptCode":"zyl",
"source": ""
"siteId": 1
}
###基础事项列表
......
......@@ -115,7 +115,7 @@ POST {{baseUrl}}/site/syncGovMatterBySiteId
Content-Type: application/json
{
"id":24
"id":22
}
......@@ -124,7 +124,7 @@ POST {{baseUrl}}/site/getFlatSitesBySiteId
Content-Type: application/json
{
"id":1
"id":22
}
......
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