Commit 7c02d3b7 authored by “yiyousong”'s avatar “yiyousong”
parents e3049ec2 51addda5
...@@ -296,8 +296,59 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity ...@@ -296,8 +296,59 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
@Override @Override
public void updateUserList(List<UserPdu> list) { public void updateUserList(List<UserPdu> list) {
//更新本地用户信息,并且更新用户站点树 //更新本地用户信息,并且更新用户站点树 //todo 将站点分组后 分组同步更新
List<String> loginNames = list.parallelStream().map(user -> user.getLoginName()).collect(Collectors.toList());
UserQuery userQuery = new UserQuery();
userQuery.setLoginNameList(loginNames);
List<UserEntity> existUsers = this.find(userQuery);
Map<String, UserEntity> existUserMap = existUsers.parallelStream().collect(Collectors.toMap(x -> x.getLoginName(), y -> y, (o, n) -> n));
//分组查找存在的与不存在的用户
Map<Boolean, List<UserPdu>> collect = list.parallelStream().collect(Collectors.partitioningBy(x -> existUserMap.containsKey(x.getLoginName())));
List<UserPdu> userPdusUpdate = collect.get(true);//更新
List<UserEntity> userEntityUpdate = new ArrayList<>();
List<UserPdu> userPdusSave = collect.get(false);//新增
List<UserEntity> userEntitySave = new ArrayList<>();
for (UserPdu user : userPdusSave) {
//新增
UserEntity entity = new UserEntity();
entity.initAttrValue();
BeanUtils.copyProperties(user, entity, BeanUtil.getNullPropertyNames(user));
this.save(entity);
if (!ObjectUtils.isEmpty(entity.getSiteIds())) {
userEntitySave.add(entity);
}
}
for (UserPdu user : userPdusUpdate) {
//更新
UserEntity userEntity = new UserEntity();
BeanUtils.copyProperties(user, userEntity, new String[]{"loginPwd", "loginName", "userType", "status", "lastLoginTime", "lastLoginAddress"});
userEntity.setId(existUserMap.get(user.getLoginName()).getId());
this.updateWidthDao(userEntity);
if (!ObjectUtils.isEmpty(userEntity.getSiteIds())) {
userEntitySave.add(userEntity);
}
}
//分组刷新节点 新增
Map<String, List<UserEntity>> saveSitesCollect = userEntitySave.stream().collect(Collectors.groupingBy(x -> x.getSiteIds()));
// Map<String, List<UserEntity>> updateSitesCollect = userEntityUpdate.stream().collect(Collectors.groupingBy(x -> x.getSiteIds()));
saveSitesCollect.entrySet().stream().forEach(item -> {
String siteIds = item.getKey();
List<UserEntity> userEntities = item.getValue();
if (!ObjectUtils.isEmpty(userEntities)) {
Context context = new Context();
context.setUser(userEntities.get(0));
ThreadPool.getInstance().execute(new SyncTreeSiteThread(context, userEntities));
}
});
/*
//如果用户未有所属站点 则不更新 //如果用户未有所属站点 则不更新
for (UserPdu user : list) { for (UserPdu user : list) {
UserEntity tempUser = this.selectOne(new UserQuery().loginName(user.getLoginName())); UserEntity tempUser = this.selectOne(new UserQuery().loginName(user.getLoginName()));
...@@ -324,7 +375,7 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity ...@@ -324,7 +375,7 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
ThreadPool.getInstance().execute(new SyncTreeSiteThread(context)); ThreadPool.getInstance().execute(new SyncTreeSiteThread(context));
} }
} }
} }*/
} }
......
...@@ -2,10 +2,13 @@ package com.mortals.xhx.common.utils; ...@@ -2,10 +2,13 @@ package com.mortals.xhx.common.utils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.module.site.model.SiteTreeSelect; import com.mortals.xhx.module.site.model.SiteTreeSelect;
import com.mortals.xhx.module.site.service.SiteService; import com.mortals.xhx.module.site.service.SiteService;
import com.mortals.xhx.utils.SpringUtils; import com.mortals.xhx.utils.SpringUtils;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.apachecommons.CommonsLog; import lombok.extern.apachecommons.CommonsLog;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -18,17 +21,31 @@ import java.util.List; ...@@ -18,17 +21,31 @@ import java.util.List;
* @description: * @description:
**/ **/
@AllArgsConstructor @AllArgsConstructor
@RequiredArgsConstructor
@Slf4j @Slf4j
public class SyncTreeSiteThread implements Runnable { public class SyncTreeSiteThread implements Runnable {
@NonNull
private Context context; private Context context;
private List<UserEntity> userEntities;
@Override @Override
public void run() { public void run() {
SiteService siteService = SpringUtils.getBean(SiteService.class); SiteService siteService = SpringUtils.getBean(SiteService.class);
List<SiteTreeSelect> siteTreeSelects = siteService.siteTree(context); List<SiteTreeSelect> siteTreeSelects = siteService.siteTree(context);
siteService.setSiteTree(siteTreeSelects, context);
log.info("刷新用户站点树=》userID:{} siteIds:{} siteTree:{}",context.getUser().getId(),context.getUser().getSiteIds(), JSON.toJSONString(siteService.getSiteTree(context))); if(ObjectUtils.isEmpty(userEntities)){
siteService.setSiteTree(siteTreeSelects, context);
}else{
for (UserEntity userEntity : userEntities) {
Context contextTemp = new Context();
contextTemp.setUser(userEntity);
siteService.setSiteTree(siteTreeSelects, contextTemp);
}
}
// log.info("刷新用户站点树=》userID:{} siteIds:{} siteTree:{}",context.getUser().getId(),context.getUser().getSiteIds(), JSON.toJSONString(siteService.getSiteTree(context)));
} }
} }
...@@ -114,7 +114,6 @@ public class AppServiceImpl extends AbstractCRUDServiceImpl<AppDao, AppEntity, L ...@@ -114,7 +114,6 @@ public class AppServiceImpl extends AbstractCRUDServiceImpl<AppDao, AppEntity, L
} else { } else {
item.setAppIconUrl(item.getAppIconPath()); item.setAppIconUrl(item.getAppIconPath());
} }
}; };
super.findAfter(params, pageInfo, context, list); super.findAfter(params, pageInfo, context, list);
} }
......
...@@ -208,7 +208,6 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -208,7 +208,6 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
public List<SiteTreeSelect> siteTree(Context context) { public List<SiteTreeSelect> siteTree(Context context) {
Map<String, AreaEntity> areaMap = new HashMap<>(); Map<String, AreaEntity> areaMap = new HashMap<>();
SiteQuery siteQuery = new SiteQuery(); SiteQuery siteQuery = new SiteQuery();
//如果站点为空 或者用户为空 返回空数组 //如果站点为空 或者用户为空 返回空数组
if (context.getUser() == null) { if (context.getUser() == null) {
return new ArrayList<>(); return new ArrayList<>();
...@@ -224,7 +223,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -224,7 +223,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
} }
} }
//查詢指定的站點ids //查詢指定的站點ids
log.info(String.format("siteQuery==>%s", JSON.toJSONString(siteQuery))); // log.info(String.format("siteQuery==>%s", JSON.toJSONString(siteQuery)));
siteList = this.find(siteQuery); siteList = this.find(siteQuery);
} }
//如果是管理员 默认全部站点 //如果是管理员 默认全部站点
...@@ -325,15 +324,18 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -325,15 +324,18 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
@Override @Override
protected void updateAfter(SiteEntity entity, Context context) throws AppException { protected void updateAfter(SiteEntity entity, Context context) throws AppException {
super.updateAfter(entity, context);
//刷新站点树 //刷新站点树
log.info("update1");
Rest<String> rest = userFeign.synchSiteAuth(); Rest<String> rest = userFeign.synchSiteAuth();
if (rest.getCode().equals(YesNoEnum.YES.getValue())) { if (rest.getCode().equals(YesNoEnum.YES.getValue())) {
log.info("update2");
UserPdu userPdu = new UserPdu(); UserPdu userPdu = new UserPdu();
userPdu.setPage(1); userPdu.setPage(1);
userPdu.setSize(-1); userPdu.setSize(-1);
Rest<RespData<List<UserPdu>>> list = userFeign.list(userPdu); Rest<RespData<List<UserPdu>>> list = userFeign.list(userPdu);
log.info("update21");
userService.updateUserList(list.getData().getData()); userService.updateUserList(list.getData().getData());
log.info("update22");
} }
if (refresh) { if (refresh) {
//通知设备更新站点信息 //通知设备更新站点信息
......
...@@ -20,6 +20,7 @@ Content-Type: application/json ...@@ -20,6 +20,7 @@ Content-Type: application/json
{ {
"page":1, "page":1,
"size":1 "size":1
} }
......
...@@ -122,7 +122,7 @@ Content-Type: application/json ...@@ -122,7 +122,7 @@ Content-Type: application/json
{ {
"method":"post", "method":"post",
"type": 2, "type": 1,
"path":"/api/edge-service-agent/1.0/46ce3be3269e8894/cxyhbhsfz_", "path":"/api/edge-service-agent/1.0/46ce3be3269e8894/cxyhbhsfz_",
"body":"{\"idCardNo\":\"41010229611620007X\",\"orgNo\":\"10080000\"}" "body":"{\"idCardNo\":\"41010229611620007X\",\"orgNo\":\"10080000\"}"
} }
...@@ -133,7 +133,7 @@ Content-Type: application/json ...@@ -133,7 +133,7 @@ Content-Type: application/json
{ {
"method":"post", "method":"post",
"type": 2, "type": 1,
"path":"/api/edge-service-agent/1.0/8d0b663762f8bba6/cxbzlb_", "path":"/api/edge-service-agent/1.0/8d0b663762f8bba6/cxbzlb_",
"body":"{\"accountId\":\"1018145\"}" "body":"{\"accountId\":\"1018145\"}"
} }
......
...@@ -66,6 +66,15 @@ ...@@ -66,6 +66,15 @@
<template slot="calltime" slot-scope="text"> <template slot="calltime" slot-scope="text">
{{ text.calltime ? text.calltime : "--" }} {{ text.calltime ? text.calltime : "--" }}
</template> </template>
<template slot="all_time" slot-scope="text">
{{ text.all_time ? text.all_time : "--" }}
</template>
<template slot="run_time" slot-scope="text">
{{ text.run_time ? text.run_time : "--" }}
</template>
<template slot="wait_time" slot-scope="text">
{{ text.wait_time ? text.wait_time : "--" }}
</template>
<!-- 办理窗口 --> <!-- 办理窗口 -->
<template slot="window_name" slot-scope="text"> <template slot="window_name" slot-scope="text">
{{ {{
...@@ -207,6 +216,30 @@ export default { ...@@ -207,6 +216,30 @@ export default {
customRender: "endtime", customRender: "endtime",
}, },
}, },
{
title: "当前排号总时长",
width: "8%",
align: "center",
scopedSlots: {
customRender: "all_time",
},
},
{
title: "业务平均办理时长",
width: "8%",
align: "center",
scopedSlots: {
customRender: "run_time",
},
},
{
title: "业务平均等待时长",
width: "8%",
align: "center",
scopedSlots: {
customRender: "wait_time",
},
},
{ {
title: "状态", title: "状态",
...@@ -276,6 +309,9 @@ export default { ...@@ -276,6 +309,9 @@ export default {
"window_name", "window_name",
"workman_name", "workman_name",
"endtime", "endtime",
"all_time",
"run_time",
"wait_time",
"style", "style",
], ],
btnLoading: false, btnLoading: false,
......
...@@ -97,6 +97,15 @@ ...@@ -97,6 +97,15 @@
<template slot="endtime" slot-scope="text"> <template slot="endtime" slot-scope="text">
{{ text.endtime ? text.endtime : "--" }} {{ text.endtime ? text.endtime : "--" }}
</template> </template>
<template slot="all_time" slot-scope="text">
{{ text.all_time ? text.all_time : "--" }}
</template>
<template slot="run_time" slot-scope="text">
{{ text.run_time ? text.run_time : "--" }}
</template>
<template slot="wait_time" slot-scope="text">
{{ text.wait_time ? text.wait_time : "--" }}
</template>
<!-- 操作 --> <!-- 操作 -->
<template slot="action" slot-scope="text"> <template slot="action" slot-scope="text">
<a @click="openHandlingDetails(text.id)">详细信息</a> <a @click="openHandlingDetails(text.id)">详细信息</a>
...@@ -224,6 +233,30 @@ export default { ...@@ -224,6 +233,30 @@ export default {
customRender: "endtime", customRender: "endtime",
}, },
}, },
{
title: "当前排号总时长",
width: "8%",
align: "center",
scopedSlots: {
customRender: "all_time",
},
},
{
title: "业务平均办理时长",
width: "8%",
align: "center",
scopedSlots: {
customRender: "run_time",
},
},
{
title: "业务平均等待时长",
width: "8%",
align: "center",
scopedSlots: {
customRender: "wait_time",
},
},
{ {
title: "状态", title: "状态",
...@@ -268,6 +301,9 @@ export default { ...@@ -268,6 +301,9 @@ export default {
"window_name", "window_name",
"workman_name", "workman_name",
"endtime", "endtime",
"all_time",
"run_time",
"wait_time",
"style", "style",
], ],
//设备数据 //设备数据
......
...@@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil; ...@@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.ap.SysConstains; import com.mortals.framework.ap.SysConstains;
import com.mortals.framework.common.Rest;
import com.mortals.framework.common.code.UserType; import com.mortals.framework.common.code.UserType;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
...@@ -268,9 +269,37 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity ...@@ -268,9 +269,37 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
@Override @Override
public void synchSitesAuth() throws AppException { public void synchSitesAuth() throws AppException {
//todo 批量更新 用户太多 该接口查询非常缓慢 用户根据所属区域分组查询后更新
UserEntity query = new UserEntity(); UserEntity query = new UserEntity();
List<UserEntity> all = this.find(query); List<UserEntity> allUsers = this.find(query);
all.forEach(item -> {
//区域分组编码
allUsers.stream().collect(Collectors.groupingBy(x -> x.getAreaCodes())).entrySet().forEach(item -> {
String areaCodes = item.getKey();
if (!ObjectUtils.isEmpty(areaCodes)) {
List<String> areaCodeList = Arrays.asList(areaCodes.split(","));
String resp = areaService.getFlatSitesByAreaCodes(new AreaQuery().areaCodeList(areaCodeList), null);
JSONObject apiResp = JSON.parseObject(resp);
if (apiResp.getInteger("code") == YesNoEnum.YES.getValue()) {
String siteIds = apiResp.getString("data");
//更新用户站点
List<UserEntity> userEntityList = item.getValue();
if (!ObjectUtils.isEmpty(userEntityList)) {
userEntityList.stream().forEach(userEntity -> {
userEntity.setSiteIds(siteIds);
this.dao.update(userEntity);
updateRedisUserSession(userEntity);
});
//this.dao.updateBatch(userEntityList);
}
} else {
log.info("获取用户站点列表树数据失败:" + apiResp.getString("msg"));
}
}
});
/* all.forEach(item -> {
if (StringUtils.isNotEmpty(item.getAreaCodes())) { if (StringUtils.isNotEmpty(item.getAreaCodes())) {
List<String> areaCodeList = Arrays.asList(item.getAreaCodes().split(",")); List<String> areaCodeList = Arrays.asList(item.getAreaCodes().split(","));
String resp = areaService.getFlatSitesByAreaCodes(new AreaQuery().areaCodeList(areaCodeList), null); String resp = areaService.getFlatSitesByAreaCodes(new AreaQuery().areaCodeList(areaCodeList), null);
...@@ -286,7 +315,7 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity ...@@ -286,7 +315,7 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
updateRedisUserSession(userEntity); updateRedisUserSession(userEntity);
} }
}); });*/
} }
@Override @Override
...@@ -352,7 +381,7 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity ...@@ -352,7 +381,7 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
entity.setCreateTime(new Date()); entity.setCreateTime(new Date());
entity.setLoginPwd(SecurityUtil.md5DoubleEncoding(entity.getLoginPwd())); entity.setLoginPwd(SecurityUtil.md5DoubleEncoding(entity.getLoginPwd()));
int insert = this.getDao().insert(entity); int insert = this.getDao().insert(entity);
if (insert >0) { if (insert > 0) {
successNum++; successNum++;
RoleUserQuery roleUserQuery = new RoleUserQuery(); RoleUserQuery roleUserQuery = new RoleUserQuery();
roleUserQuery.setUserId(entity.getId()); roleUserQuery.setUserId(entity.getId());
......
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