Commit 51a6aa49 authored by 张森's avatar 张森

中心卡片公司树

parent 04cff5bc
...@@ -28,7 +28,8 @@ public class OrgMenuDto { ...@@ -28,7 +28,8 @@ public class OrgMenuDto {
private String bizOrgCode; private String bizOrgCode;
private Long total; private Long total;
private String code; private String code;
private Boolean isOnline = true;
public Boolean getLeaf() { public Boolean getLeaf() {
return ObjectUtils.isEmpty(children); return ObjectUtils.isEmpty(children);
} }
...@@ -56,6 +57,18 @@ public class OrgMenuDto { ...@@ -56,6 +57,18 @@ public class OrgMenuDto {
this.code = code; this.code = code;
} }
public OrgMenuDto(Long key, String title, Long parentId, String bizOrgType, boolean leaf, String bizOrgCode, String code, Boolean isOnline) {
super();
this.key = key;
this.title = title;
this.parentId = parentId;
this.bizOrgType = bizOrgType;
this.leaf = leaf;
this.bizOrgCode = bizOrgCode;
this.code = code;
this.isOnline = isOnline;
}
public OrgMenuDto(Long key, String title, Long parentId, String bizOrgType, boolean leaf, String bizOrgCode) { public OrgMenuDto(Long key, String title, Long parentId, String bizOrgType, boolean leaf, String bizOrgCode) {
super(); super();
this.key = key; this.key = key;
......
...@@ -123,6 +123,8 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> { ...@@ -123,6 +123,8 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> {
List<OrgUsr> companyDeptListWithPersonCount(Map<String, Object> param); List<OrgUsr> companyDeptListWithPersonCount(Map<String, Object> param);
List<OrgUsr> companyListWithPersonCount(Map<String, Object> param);
List<OrgUsr> companyDeptListWithPersonCountNew(Map<String, Object> param); List<OrgUsr> companyDeptListWithPersonCountNew(Map<String, Object> param);
List<OrgUsr> companyTreeByUser(String bizOrgCode); List<OrgUsr> companyTreeByUser(String bizOrgCode);
......
...@@ -3,9 +3,11 @@ package com.yeejoin.amos.boot.module.common.api.mapper; ...@@ -3,9 +3,11 @@ package com.yeejoin.amos.boot.module.common.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map; import java.util.Map;
public interface StationInfoMapper extends BaseMapper { public interface StationInfoMapper extends BaseMapper {
Long count(@Param("stationType") String stationType); Long count(@Param("stationType") String stationType);
Map<String, String> selectStationInfo(@Param("bizOrgCode") String bizOrgCode); Map<String, String> selectStationInfo(@Param("bizOrgCode") String bizOrgCode);
List<Map<String, Object>> selectStationInfoList();
} }
...@@ -1038,6 +1038,19 @@ ...@@ -1038,6 +1038,19 @@
and usr.is_delete = false and usr.is_delete = false
</select> </select>
<select id="companyListWithPersonCount"
resultType="com.yeejoin.amos.boot.module.common.api.entity.OrgUsr">
SELECT usr.*,
(select count(1)
from cb_org_usr u
where u.biz_org_type = 'PERSON'
and u.is_delete = false
and u.biz_org_code like CONCAT(usr.biz_org_code, '%')) as total
FROM cb_org_usr usr
where usr.biz_org_type = 'COMPANY'
and usr.is_delete = false
</select>
<select id="companyDeptListWithPersonCountNew" <select id="companyDeptListWithPersonCountNew"
resultType="com.yeejoin.amos.boot.module.common.api.entity.OrgUsr"> resultType="com.yeejoin.amos.boot.module.common.api.entity.OrgUsr">
SELECT usr.*, SELECT usr.*,
......
...@@ -23,4 +23,11 @@ ...@@ -23,4 +23,11 @@
</where> </where>
LIMIT 1 LIMIT 1
</select> </select>
<select id="selectStationInfoList" resultType="java.util.Map">
SELECT
*
FROM
idx_biz_station_info
</select>
</mapper> </mapper>
...@@ -562,6 +562,17 @@ public class OrgUsrController extends BaseController { ...@@ -562,6 +562,17 @@ public class OrgUsrController extends BaseController {
@PersonIdentify @PersonIdentify
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/companyTreeIsOnline", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据登录人及类型获取公司树", notes = "根据登录人及类型获取公司树")
public ResponseModel<List<OrgMenuDto>> companyTreeIsOnline() {
// 获取登陆人角色
ReginParams reginParams = getSelectedOrgInfo();
List<OrgMenuDto> menus = iOrgUsrService.companyTreeByUserNumber2(reginParams);
return ResponseHelper.buildResponse(menus);
}
@PersonIdentify
@TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/companyTreeByUserToPatrolRoute", method = RequestMethod.GET) @RequestMapping(value = "/companyTreeByUserToPatrolRoute", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据登录人获取公司部门树【部门账号登录可查看上级单位】", notes = "根据登录人获取公司部门树") @ApiOperation(httpMethod = "GET", value = "根据登录人获取公司部门树【部门账号登录可查看上级单位】", notes = "根据登录人获取公司部门树")
public ResponseModel<List<OrgMenuDto>> companyTreeByUserToPatrolRoute() { public ResponseModel<List<OrgMenuDto>> companyTreeByUserToPatrolRoute() {
......
...@@ -55,6 +55,7 @@ import org.typroject.tyboot.core.foundation.context.RequestContext; ...@@ -55,6 +55,7 @@ import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.Serializable; import java.io.Serializable;
...@@ -227,6 +228,59 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp ...@@ -227,6 +228,59 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
return result; return result;
} }
public List<OrgMenuDto> buildTreeParallel2(List<OrgUsr> list) {
List<Map<String, Object>> stationInfoOnline = stationInfoMapper.selectStationInfoList();
List<String> bizOrgCodeList = stationInfoOnline.stream().map(item -> item.get("biz_org_code").toString()).collect(Collectors.toList());
List<OrgMenuDto> menuList = list.stream()
.map(o -> new OrgMenuDto(o.getSequenceNbr(), o.getBizOrgName(),
ObjectUtils.isEmpty(o.getParentId()) ? 0L : Long.parseLong(o.getParentId()), o.getBizOrgType(),
false, o.getBizOrgCode(), o.getCode(), o.getBizOrgCode().length() == 18 && bizOrgCodeList.contains(o.getBizOrgCode()) ? Boolean.TRUE : Boolean.FALSE).setTotal(o.getTotal()))
.collect(Collectors.toList());
List<OrgMenuDto> result = new ArrayList<>();
Map<Long, OrgMenuDto> map = new HashMap<>(menuList.size());
menuList.forEach(e -> map.put(e.getKey(), e));
Set<? extends Map.Entry<Long, ? extends OrgMenuDto>> entries = map.entrySet();
// 此处多线程,会value 出现null 的情况
entries.forEach(entry -> {
OrgMenuDto value = entry.getValue();
if (value != null) {
OrgMenuDto treeDto = map.get(value.getParentId());
if (treeDto != null) {
List<OrgMenuDto> children = treeDto.getChildren();
if (children == null) {
children = new ArrayList<>();
treeDto.setChildren(children);
}
children.add(value);
} else {
result.add(value);
}
}
});
List<OrgMenuDto> orgMenuDtos = doIsOnlineData(result);
return orgMenuDtos;
}
private List<OrgMenuDto> doIsOnlineData(List<OrgMenuDto> list) {
if (CollectionUtils.isNotEmpty(list)) {
for (OrgMenuDto orgMenuDto : list) {
orgMenuDto.setIsOnline(Boolean.TRUE);
if (orgMenuDto.getBizOrgCode().length() == 12 && CollectionUtils.isNotEmpty(orgMenuDto.getChildren())) {
Set<Boolean> collect = orgMenuDto.getChildren().stream().map(OrgMenuDto::getIsOnline).collect(Collectors.toSet());
if (CollectionUtils.isEmpty(collect) || (collect.contains(Boolean.FALSE) && !collect.contains(Boolean.TRUE))) {
orgMenuDto.setIsOnline(Boolean.FALSE);
}
} else if (CollectionUtils.isEmpty(orgMenuDto.getChildren())) {
orgMenuDto.setIsOnline(Boolean.FALSE);
}
doIsOnlineData(orgMenuDto.getChildren());
}
}
return list;
}
public static String getOrgCodeStr() { public static String getOrgCodeStr() {
return TreeParser.genTreeCode(); return TreeParser.genTreeCode();
} }
...@@ -2939,6 +2993,24 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp ...@@ -2939,6 +2993,24 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
return buildTreeParallel(list); return buildTreeParallel(list);
} }
public List<OrgMenuDto> companyTreeByUserNumber2(ReginParams reginParams) {
Map<String, Object> param = new HashMap<>();
String bizOrgCode = reginParams.getPersonIdentity().getBizOrgCode();
// 权限处理
if (!logic){
OrgUsr orgUsr = orgUsrMapper.selectById(reginParams.getPersonIdentity().getCompanyId());
//判断登陆人是否已经是顶级节点单位
if (!ObjectUtils.isEmpty(orgUsr) && orgUsr.getParentId() != null) {
orgUsr = this.selectParentOrgUsr(orgUsr);
bizOrgCode = orgUsr.getBizOrgCode() != null? orgUsr.getBizOrgCode():bizOrgCode;
}
}
PermissionInterceptorContext.setDataAuthRule(authKey);
param.put("bizOrgCode",bizOrgCode);
List<OrgUsr> list = orgUsrMapper.companyListWithPersonCount(param);
return buildTreeParallel2(list);
}
public List<OrgMenuDto> companyTreeByUserNumberNew(ReginParams reginParams) { public List<OrgMenuDto> companyTreeByUserNumberNew(ReginParams reginParams) {
Map<String, Object> param = new HashMap<>(); Map<String, Object> param = new HashMap<>();
// 权限处理 // 权限处理
......
...@@ -7157,28 +7157,31 @@ ...@@ -7157,28 +7157,31 @@
* *
FROM FROM
( (
(SELECT count( 1 ) AS indexNum FROM wl_equipment_specific_index a LEFT JOIN wl_equipment_index b ON a.equipment_index_id = b.id WHERE b.is_iot = 1 (SELECT
and equipment_specific_id IN sum( n.num )
(SELECT FROM
id (
FROM SELECT
wl_equipment_specific a.id,
<where> count( 1 ) AS num
<if test="bizOrgCode!=null and bizOrgCode!=''"> FROM
AND biz_org_code LIKE CONCAT(#{bizOrgCode},'%') wl_equipment_specific a
</if> LEFT JOIN (select m.* from wl_equipment_specific_index m left join wl_equipment_index e on e.id = m.equipment_index_id where e.is_iot = 1) b ON a.id = b.equipment_specific_id
</where>) <where>
<if test="bizOrgCode!=null and bizOrgCode!=''">
AND a.biz_org_code LIKE CONCAT(#{bizOrgCode},'%')
</if>
</where>
GROUP BY
a.id
) n
)
) AS indexNum, ) AS indexNum,
(SELECT count( 1 ) AS equipNum FROM wl_equipment_specific es LEFT JOIN wl_equipment e ON e.`code` = es.equipment_code WHERE e.is_iot = 1 (SELECT count( 1 ) AS equipNum FROM wl_equipment_specific es LEFT JOIN wl_equipment e ON e.`code` = es.equipment_code WHERE e.is_iot = 1
<if test="bizOrgCode!=null and bizOrgCode!=''"> <if test="bizOrgCode!=null and bizOrgCode!=''">
AND es.biz_org_code LIKE CONCAT(#{bizOrgCode},'%') AND es.biz_org_code LIKE CONCAT(#{bizOrgCode},'%')
</if> </if>
) AS equipNum, ) AS equipNum
(SELECT count(1) AS indexMonitorNum FROM wl_equipment_specific_index wesi LEFT JOIN wl_equipment_specific wes on wesi.equipment_specific_id = wes.id WHERE DATE_FORMAT(wesi.update_date, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
<if test="bizOrgCode!=null and bizOrgCode!=''">
AND wes.biz_org_code LIKE CONCAT(#{bizOrgCode},'%')
</if>
) AS indexMonitorNum
) )
</select> </select>
......
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