Commit 58bef5fe authored by 高建强's avatar 高建强

item:视频监控新增所属机构树,函数脚本维护。

parent 8a0a5b00
......@@ -26,6 +26,7 @@ public class ReginParams implements Serializable {
private String personName;
private String companyId;
private String companyName;
private String bizOrgCode;
}
public PersonIdentity getPersonIdentity() {
......
......@@ -97,4 +97,8 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> {
List<Map<String,Object>> queryCompanyIdNew(String bizOrgName);
OrgUsr queryByUserId(@Param("userId")Long userId);
List<OrgUsr> companyTreeByUserAndType(@Param("userId") String userId, @Param("type") String type);
OrgUsr queryBySequenceNbr(@Param("parentId") String parentId);
}
......@@ -201,6 +201,15 @@ public interface IOrgUsrService {
*/
List<OrgMenuDto> companyTreeByUser(AgencyUserModel user);
/**
* 根据登录人及类型获取公司部门树
* @param user
* @param type 默认查询公司及部门,公司:COMPANY,部门:DEPARTMENT
* @return
*/
List<OrgMenuDto> companyTreeByUserAndType(AgencyUserModel user, String type);
/**
* 根据登陆人获取公司列表(关联重点部位)
*/
......@@ -283,4 +292,6 @@ public interface IOrgUsrService {
void updateByIdOrgPersonFlc(OrgPersonDto OrgPersonVo, Long id) throws Exception;
JSONObject selectPersonByUserId(Long userId) throws Exception;
UserDto getUserParentInfo(String userId);
}
......@@ -737,4 +737,24 @@ LEFT JOIN (
AND amos_org_id = #{userId}
</if>
</select>
<select id="queryBySequenceNbr" resultType="com.yeejoin.amos.boot.module.common.api.entity.OrgUsr">
SELECT *
FROM cb_org_usr
WHERE is_delete = 0
<if test="parentId != null and parentId != ''">
AND sequence_nbr = #{parentId}
</if>
</select>
<select id="companyTreeByUserAndType" resultType="com.yeejoin.amos.boot.module.common.api.entity.OrgUsr">
SELECT
*
FROM
cb_org_usr usr
<where>
usr.sequence_nbr IN ( SELECT getOrgUsrTreeById ( ( SELECT parent_id FROM cb_org_usr WHERE amos_org_id = #{userId} ) ) )
<if test="type != null and type != ''">
AND usr.biz_org_type = #{type}
</if>
</where>
</select>
</mapper>
......@@ -1387,7 +1387,15 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
return gettTreeByUser(user, companyDepartmentMsgList);
}
;
@Override
public List<OrgMenuDto> companyTreeByUserAndType(AgencyUserModel user, String type) {
String userId = user.getUserId();
if (StringUtils.isNotBlank(userId)) {
List<OrgUsr> list = orgUsrMapper.companyTreeByUserAndType(userId, type);
return buildTreeParallel(list);
}
return Lists.newArrayList();
}
@Override
public List<CheckObjectDto> companyListByUser(AgencyUserModel user) {
......@@ -2062,6 +2070,27 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
return jsonObject;
}
@Override
public UserDto getUserParentInfo(String userId) {
UserDto userDto = new UserDto();
if (StringUtils.isNotEmpty(userId)) {
OrgUsr orgUsr = orgUsrMapper.queryByUserId(Long.parseLong(userId));
if (!ObjectUtils.isEmpty(orgUsr)) {
String parentId = orgUsr.getParentId();
userDto.setPersonSeq(String.valueOf(orgUsr.getSequenceNbr()));
userDto.setPersonName(orgUsr.getBizOrgName());
OrgUsr bizOrg = orgUsrMapper.queryBySequenceNbr(parentId);
if (!ObjectUtils.isEmpty(bizOrg)) {
userDto.setBizOrgType(bizOrg.getBizOrgType());
userDto.setBizOrgCode(bizOrg.getBizOrgCode());
userDto.setCompanyId(String.valueOf(bizOrg.getSequenceNbr()));
userDto.setCompanyName(bizOrg.getBizOrgName());
}
}
}
return userDto;
}
public Object getOrgUserByAmosUserId(String amosUserId) throws Exception{
LambdaQueryWrapper<OrgUsr> wrapper = new LambdaQueryWrapper<OrgUsr>();
wrapper.eq(OrgUsr::getIsDelete, false);
......
package com.yeejoin.equipmanage.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.api.dto.OrgMenuDto;
import com.yeejoin.amos.boot.module.common.api.service.IOrgUsrService;
import com.yeejoin.equipmanage.common.entity.Video;
import com.yeejoin.equipmanage.common.entity.dto.VideoDTO;
import com.yeejoin.equipmanage.common.entity.dto.VideoSaveDto;
......@@ -33,14 +12,26 @@ import com.yeejoin.equipmanage.common.entity.vo.PageVideoVO;
import com.yeejoin.equipmanage.common.entity.vo.VideoListVo;
import com.yeejoin.equipmanage.common.enums.ExcelEnums;
import com.yeejoin.equipmanage.common.utils.CommonResponseUtil;
import com.yeejoin.equipmanage.core.framework.PersonIdentify;
import com.yeejoin.equipmanage.dto.ExcelDto;
import com.yeejoin.equipmanage.service.IExcelService;
import com.yeejoin.equipmanage.service.IVideoService;
import com.yeejoin.equipmanage.utils.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* @author ZeHua Li
......@@ -58,6 +49,9 @@ public class VideoController extends AbstractBaseController {
@Autowired
private IExcelService excelService;
@Autowired
private IOrgUsrService orgUsrService;
/**
* 新增
*
......@@ -284,4 +278,11 @@ public class VideoController extends AbstractBaseController {
return flvUrl;
}
@PersonIdentify
@TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/companyTreeByUserAndType", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据登录人及类型获取公司部门树", notes = "根据登录人及类型获取公司部门树")
public List<OrgMenuDto> companyTreeByUserAndType(@RequestParam(required = false) String type) {
return orgUsrService.companyTreeByUserAndType(getUserInfo(), type);
}
}
package com.yeejoin.equipmanage.core.framework;
import java.lang.annotation.*;
/**
* @author DELL
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface PersonIdentify {
/**
* 是否进行人员校验
* @return boolean
*/
boolean isNeedIdentity() default true;
}
package com.yeejoin.equipmanage.core.framework;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.api.dto.UserDto;
import com.yeejoin.amos.boot.module.common.api.service.IOrgUsrService;
import com.yeejoin.equipmanage.exception.PermissionException;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.ResponseBody;
import org.typroject.tyboot.core.foundation.context.RequestContext;
/**
* @author DELL
*/
@Aspect
@Component
@ResponseBody
@Order(value = 1)
public class PersonIdentifyAspect {
@Autowired
RedisUtils redisUtils;
@Autowired
private IOrgUsrService orgUsrService;
@Before(value = "@annotation(com.yeejoin.equipmanage.core.framework.PersonIdentify) && @annotation(permission)")
public void personIdentity(JoinPoint joinPoint, PersonIdentify permission) throws PermissionException {
ReginParams reginParam = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
if (permission.isNeedIdentity() && reginParam != null) {
String userId = reginParam.getUserModel().getUserId();
UserDto userDto = orgUsrService.getUserParentInfo(userId);
if (!ObjectUtils.isEmpty(userDto)) {
ReginParams.PersonIdentity personIdentity = new ReginParams.PersonIdentity();
personIdentity.setBizOrgCode(userDto.getBizOrgCode());
personIdentity.setCompanyId(userDto.getCompanyId());
personIdentity.setCompanyName(userDto.getCompanyName());
personIdentity.setPersonSeq(userDto.getPersonSeq());
personIdentity.setPersonName(userDto.getPersonName());
personIdentity.setIdentityType(userDto.getIdentityType());
reginParam.setPersonIdentity(personIdentity);
redisUtils.set(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken()), JSONObject.toJSONString(reginParam));
} else {
throw new RuntimeException("人员未绑定!");
}
}
}
}
package com.yeejoin.equipmanage.exception;
import org.springframework.http.HttpStatus;
public class PermissionException extends RuntimeException{
private static final long serialVersionUID = -6126611364667754200L;
public PermissionException(String message) {
super(message);
}
public PermissionException(String message, Throwable cause) {
super(message, cause);
}
public HttpStatus getStatus() {
return HttpStatus.FORBIDDEN; // 403
}
}
......@@ -2068,4 +2068,29 @@
INSERT INTO `wl_form_group_column`(`id`, `field_name`, `field_label`, `data_type`, `group_id`, `query_strategy`, `not_null`, `group_code`, `creator_id`, `create_date`) VALUES (133000000252, 'bizOrgName', '机构/部门名称', 'String', 132828674810, 'eq', b'0', 'building', 2581805, '2021-12-15 17:34:04');
</sql>
</changeSet>
<changeSet author="gaojianqiang" id="1639540630-20211217-01">
<comment>`getOrgUsrTreeById`</comment>
<sql endDelimiter="#">
DROP FUNCTION IF EXISTS `getOrgUsrTreeById`#
CREATE DEFINER = `root` @`%` FUNCTION `getOrgUsrTreeById` ( `rootId` BIGINT ) RETURNS VARCHAR ( 1000 ) CHARSET utf8 BEGIN
DECLARE
sTemp TEXT;
DECLARE
sTempChd VARCHAR ( 4000 );
SET sTemp = '$';
SET sTempChd = CAST( rootId AS CHAR );
WHILE
sTempChd IS NOT NULL DO
SET sTemp = CONCAT( sTemp, ',', sTempChd );
SELECT
GROUP_CONCAT( DISTINCT sequence_nbr ) INTO sTempChd
FROM
cb_org_usr
WHERE
FIND_IN_SET( parent_id, sTempChd ) > 0;
END WHILE;
RETURN substring( sTemp, 3 );
END#
</sql>
</changeSet>
</databaseChangeLog>
\ No newline at end of file
......@@ -231,8 +231,8 @@
AND par.field_name = 'parentId'
LEFT JOIN wl_form_instance AS cd ON cd.instance_id = ins.instance_id
AND cd.field_name = 'code'
LEFT JOIN wl_form_instance AS bzc ON cd.instance_id = ins.instance_id
AND cd.field_name = 'bizOrgCode'
LEFT JOIN wl_form_instance AS bzc ON bzc.instance_id = ins.instance_id
AND bzc.field_name = 'bizOrgCode'
GROUP BY
ins.instance_id
ORDER BY
......
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