Commit a1a48388 authored by 赵啸非's avatar 赵啸非

修改刷新用户树

parent 6d018c9b
......@@ -395,23 +395,6 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
siteService.updateAllSiteTree(null);
/* //单独更新全站点
UserEntity userEntity = new UserEntity();
userEntity.initAttrValue();
userEntity.setId(0L);
Context contextTemp = new Context();
contextTemp.setUser(userEntity);
SyncTreeSiteThread syncTreeSiteThread = new SyncTreeSiteThread(contextTemp);
ThreadPool.getInstance().execute(syncTreeSiteThread);
userEntity = new UserEntity();
userEntity.initAttrValue();
userEntity.setId(1L);
contextTemp = new Context();
contextTemp.setUser(userEntity);
syncTreeSiteThread = new SyncTreeSiteThread(contextTemp);
ThreadPool.getInstance().execute(syncTreeSiteThread);
*/
}
......@@ -429,7 +412,7 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
List<UserEntity> newUserList = userPduList.stream().map(newUser -> {
UserEntity userEntity = new UserEntity();
userEntity.initAttrValue();
BeanUtils.copyProperties(newUser, userEntity, new String[]{ "lastLoginTime", "lastLoginAddress"});
BeanUtils.copyProperties(newUser, userEntity, new String[]{"lastLoginTime", "lastLoginAddress"});
return userEntity;
}).collect(Collectors.toList());
......
......@@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import static com.mortals.xhx.common.key.Constant.USER_SITE_TREE;
......@@ -22,6 +23,8 @@ public class DemoStartedService implements IApplicationStartedService {
private ICacheService cacheService;
@Autowired
private SiteService siteService;
@Autowired
private UserService userService;
@Override
public void start() {
......@@ -29,7 +32,9 @@ public class DemoStartedService implements IApplicationStartedService {
log.info("开始服务..[初始化用户站点树]");
//删除redis 中的 站点树
cacheService.del(USER_SITE_TREE);
siteService.updateAllSiteTree(null);
//从门户获取所有站点用户
userService.refreshUser();
}
@Override
......
......@@ -213,27 +213,11 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
super.saveBefore(entity, context);
}
@Override
protected void saveAfter(SiteEntity entity, Context context) throws AppException {
super.saveAfter(entity, context);
//刷新站点树
//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());
}*/
this.updateAllSiteTree(context);
//新加的站点 只需要更新全树
//更新同步部门相关
//deptService.syncDeptBySiteId(entity, context);
//通知php系统更新
String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://127.0.0.1:11078/zwfw_api");
HashMap<String, String> paramsMap = new HashMap<>();
......@@ -374,14 +358,6 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
protected void updateAfter(SiteEntity entity, Context context) throws AppException {
super.updateAfter(entity, 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());
}*/
if (refresh) {
//通知设备更新站点信息
DevicePdu devicePdu = new DevicePdu();
......@@ -389,8 +365,6 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
Rest<Void> rest1 = deviceFeign.refreshMessage(devicePdu);
log.info("调用刷新结果:{}", JSON.toJSONString(rest1));
refresh = false;
//刷新站点树
cacheService.del(USER_SITE_TREE);
this.updateAllSiteTree(context);
......@@ -742,13 +716,11 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
Integer total = restStat.getData().getOrDefault("total", 0);
//获取事项全列表
Rest<List<MatterEntity>> matterAllRest = this.getMatterAllListByGOV(params, pageNum, context);
if (matterAllRest.getCode() == YesNoEnum.YES.getValue()) {
return matterAllRest.getData();
}
}
return new ArrayList<MatterEntity>();
}
......@@ -777,56 +749,8 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
}
}
log.info("抓取事项结束");
/* 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");
params.put("type", "2");
List<MatterEntity> govMatterList = this.getMatters(params, context);
dxType = "3";
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");
params.put("type", "2");
List<MatterEntity> mattersTwo = this.getMatters(params, context);
govMatterList.addAll(mattersTwo);*/
// new MatterQuery().setMatterNoNotList();
// List<MatterEntity> localMatterList = matterService.find(new MatterQuery().areaCode(siteEntity.getAreaCode()));
//HashSet<String> matterNoSet = new HashSet<>();
Set<String> matterNoSet = matterService.getDao().getMatterListByAreaCode(new MatterQuery().areaCode(siteEntity.getAreaCode())).parallelStream().map(i -> i.getMatterNo()).collect(Collectors.toSet());
/* Integer page = 1;
Integer size = 200;
PageInfo pageInfo = new PageInfo();
pageInfo.setCountPage(false);
while (true) {
pageInfo.setCurrPage(page);
pageInfo.setPrePageResult(size);
Result<MatterEntity> matterEntityResult = matterService.find(new MatterQuery().areaCode(siteEntity.getAreaCode()), pageInfo, context);
if (ObjectUtils.isEmpty(matterEntityResult.getList())) {
break;
}
Set<String> collect = matterEntityResult.getList().parallelStream().map(i -> i.getMatterNo()).collect(Collectors.toSet());
matterNoSet.addAll(collect);
page++;
log.info("page:{},size:{}", page, collect.size());
}*/
log.info("计算差集");
// List<MatterEntity> subList = this.subList(govMatterList, localMatterList);
List<MatterEntity> subList = this.subListSet(govMatterList, matterNoSet);
......@@ -842,47 +766,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
matterEntity.setCreateTime(new Date());
matterService.save(matterEntity, context);
}
/* List<List<MatterEntity>> partition = ListUtil.partition(subList, 100);
for (List<MatterEntity> matterEntityList : partition) {
log.info("insert subList size:" + matterEntityList.size());
int count = matterService.save(matterEntityList, context);
log.info("insert subList size success:" + count);
}*/
}
/* Rest<Map<String, Integer>> restStat = MatterHtmlParseUtil.statSiteMatterDeptCount(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 (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(govMatterList, localMatterList);
log.info("需要添加事项数量====" + subList.size());
//差集进行插入并更新详细数据
if (!ObjectUtils.isEmpty(subList)) {
for (MatterEntity matterEntity : subList) {
DeptEntity deptCache = deptService.getExtCache(matterEntity.getDeptCode());
matterEntity.setDeptName(deptCache == null ? "" : deptCache.getName());
matterService.save(matterEntity, context);
}
List<List<MatterEntity>> partition = ListUtil.partition(subList, 100);
for (List<MatterEntity> matterEntityList : partition) {
log.info("insert subList size:" + matterEntityList.size());
int count = matterService.save(matterEntityList, context);
log.info("insert subList size success:" + count);
}
}
}
}
*/
return Rest.ok("同步事项条数成功!");
}
......
......@@ -17,8 +17,12 @@ import com.mortals.xhx.common.code.AreaLevelEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.keys.RedisCacheKeys;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.user.UserPdu;
import com.mortals.xhx.common.utils.SyncDeptThread;
import com.mortals.xhx.common.utils.SyncGovMatterDetailThread;
import com.mortals.xhx.common.utils.SyncTreeSiteThread;
import com.mortals.xhx.feign.user.IUserFeign;
import com.mortals.xhx.module.area.model.AreaEntity;
import com.mortals.xhx.module.area.model.AreaQuery;
import com.mortals.xhx.module.area.service.AreaService;
......@@ -36,6 +40,7 @@ import com.mortals.xhx.module.site.service.SiteService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
......@@ -63,6 +68,9 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
private SiteService siteService;
@Autowired
private AreaService areaService;
@Autowired
@Lazy
private IUserFeign userFeign;
public SiteController() {
super.setModuleDesc("站点");
......@@ -571,6 +579,20 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
List<SiteEntity> siteEntities = this.service.find(new SiteQuery().areaCode(siteEntity.getAreaCode()));
siteEntity.setSiteCode(siteEntity.getAreaCode() + Constant.SITE_SPLIT_MARK + StringUtils.lpad(siteEntities.size() + 1, Constant.SITE_CODE_NUM));
this.service.getDao().update(siteEntity);
//todo 更新用户站点树
/* 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);
this.service.updateUserList(list.getData().getData());
// ThreadPool.getInstance().execute(new SyncTreeSiteThread(this,context));
this.service.updateAllSiteTree(null);*/
} else {
this.service.save(siteEntity, getContext());
}
......
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