123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- package com.dragoninfo.dcuc.authweb.restcontroller.audit;
- import com.dragoninfo.dcuc.authweb.restcontroller.audit.vo.MgeLogVo;
- import com.dragoninfo.dcuc.org.facade.IOrgInfoFacade;
- import com.dragoninfo.dcuc.user.admin.entity.MgeLog;
- import com.dragoninfo.dcuc.user.admin.enumresources.AdminObjectTypeEnum;
- import com.dragoninfo.dcuc.user.admin.facade.IMenuMtAuthFacade;
- import com.dragoninfo.dcuc.user.admin.facade.IMgeLogFacade;
- import com.dragoninfo.dcuc.user.user.vo.UserMgeLogRptVo;
- import com.dragoninfo.duceap.core.response.Result;
- import com.dragonsoft.duceap.base.entity.search.SearchDTO;
- import com.dragonsoft.duceap.commons.util.collections.CollectionUtils;
- import com.dragonsoft.duceap.commons.util.json.JsonUtils;
- import com.dragonsoft.duceap.commons.util.string.StringUtils;
- import com.dragonsoft.duceap.core.search.Searchable;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiImplicitParams;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.data.domain.Page;
- import org.springframework.data.domain.Sort;
- import org.springframework.web.bind.annotation.*;
- import java.util.*;
- @Api(tags = {"管理员审计报表"})
- @RestController
- @RequestMapping(value = "/auditsvr/manage/")
- public class MgeAuditRptController {
- @Autowired
- private IMgeLogFacade iMgeLogFacade;
- @Autowired
- private IOrgInfoFacade iOrgInfoFacade;
- @Autowired
- private IMenuMtAuthFacade iMenuMtAuthFacade;
- @ApiOperation(value = "查询管理员审计报表")
- @ApiImplicitParam(name = "SearchDTO", value = "查询条件")
- @PostMapping(value = "audits")
- public Result<List<UserMgeLogRptVo>> getMgeAuditRpt(SearchDTO searchDTO) {
- searchDTO.setSort("");
- Searchable searchable = Searchable.toSearchable(searchDTO);
- searchable.addSort(Sort.Direction.DESC, "operate_time");
- Page<com.dragoninfo.dcuc.user.user.vo.UserMgeLogRptVo> userMgeLogSummary = iMgeLogFacade.findUserMgeLogSummary(searchDTO);
- List<UserMgeLogRptVo> vos = new ArrayList<>();
- for (com.dragoninfo.dcuc.user.user.vo.UserMgeLogRptVo userMgeLogRptVo : userMgeLogSummary) {
- UserMgeLogRptVo vo = new UserMgeLogRptVo();
- BeanUtils.copyProperties(userMgeLogRptVo, vo);
- vos.add(vo);
- }
- Result result = Result.success(userMgeLogSummary.getTotalElements(), vos);
- return result;
- }
- @ApiOperation(value = "查询管理员审计详情")
- @ApiImplicitParams({@ApiImplicitParam(paramType = "path", name = "id", value = "审计详情ID", required = true
- , example = "40288a8b699fc2500169a33b20540000")})
- @GetMapping(value = "/detail/{id}")
- public Result<MgeLogVo> orgAuditDetail(@PathVariable("id") String id) {
- MgeLog mgeLog = iMgeLogFacade.getMgeLog(id);
- List<MgeLog> mgeLogList = new ArrayList<MgeLog>();
- mgeLogList.add(mgeLog);
- formatMgeLog(mgeLogList, "rpt");
- MgeLogVo mgeLogVo = new MgeLogVo();
- BeanUtils.copyProperties(mgeLog, mgeLogVo);
- return Result.success(mgeLogVo);
- }
- /**
- * 获取授权范围日志
- * -1:子节点未展开或无子节点,0:未勾选子节点,1:勾选部分子节点,2:勾选全部子节点
- * <p>
- * 操作业务类型 10:新增管理员 11:取消管理员
- * 20:新增平台菜单权限 21:取消平台菜单权限
- * 30:新增管理机构权限 31:取消管理机构权限
- * 40:新增管理人员权限 41:取消管理人员权限
- *
- * @param type 日志类型 10:管理员 20:平台菜单 30:机构管理 40:人员管理 50:授权管理 60:管理员管理
- * @param userId 用户ID
- * @return 授权范围日志
- */
- @ApiOperation(value = "获取授权范围日志")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "type", value = "日志类型 10:管理员 20:平台菜单 30:机构管理 40:人员管理 50:授权管理 60:管理员管理"),
- @ApiImplicitParam(name = "userId", value = "用户ID"),
- })
- @GetMapping(value = "auditList/{type}/{userId}")
- public Result<List<MgeLogVo>> auditList(@PathVariable("type") String type, @PathVariable("userId") String userId) {
- List<MgeLog> mgeLogList = iMgeLogFacade.queryList(type, userId);
- mgeLogList = formatMgeLog(mgeLogList, "list");
- List<MgeLogVo> vos = new ArrayList<>();
- for (MgeLog mgeLog : mgeLogList) {
- MgeLogVo vo = new MgeLogVo();
- BeanUtils.copyProperties(mgeLog, vo);
- vos.add(vo);
- }
- return Result.success(vos);
- }
- /**
- * 格式化审计Log
- *
- * @param mgeLogList
- * @return
- */
- private List<MgeLog> formatMgeLog(List<MgeLog> mgeLogList, String listOrRpt) {
- for (MgeLog mgeLog : mgeLogList) {
- String type = mgeLog.getObjectType();//操作对象类型
- String ids = mgeLog.getObjectId();
- ids = StringUtils.isEmpty(ids) ? "" : ids;
- if (!AdminObjectTypeEnum.GLY.getValue().equals(type) && !AdminObjectTypeEnum.PTCD.getValue().equals(type)) {
- if (AdminObjectTypeEnum.JGGL.getValue().equals(type) || AdminObjectTypeEnum.RYGL.getValue().equals(type) || AdminObjectTypeEnum.SQGL.getValue().equals(type) || AdminObjectTypeEnum.GLYGL.getValue().equals(type)) {
- ids = iOrgInfoFacade.changeIdsToNames(ids);
- if(StringUtils.isNotBlank(ids)) {
- ids = ids.replace(":-1", "(及其下属机构)").replace(":0", "").replace(":1", "").replace(":2", "(及其下属机构)");
- }
- mgeLog.setObjectName(ids);
- }
- } else if (type.equals(AdminObjectTypeEnum.PTCD.getValue())) {
- Map<String, MgeLog> resultMap = new TreeMap<String, MgeLog>(new Comparator<String>() {
- @Override
- public int compare(String o1, String o2) {
- return o2.compareTo(o1);
- }
- });
- List<MgeLog> mgeLogListTemp = new ArrayList<MgeLog>();
- mgeLogListTemp.add(mgeLog);
- String s = JsonUtils.toJSONString(mgeLogListTemp);
- Map<Object, Object> mgeLogMap = new HashMap<>();
- mgeLogMap.put("mgeLogMap", s);
- mgeLogListTemp = iMenuMtAuthFacade.convertIdsToNames(mgeLogMap);
- if (listOrRpt.equals("list")) {
- mgeLog = mgeLogListTemp.get(0);
- String key = mgeLog.getOperateTime().toString() + mgeLog.getOperateUserId();
- if (resultMap.containsKey(key)) {
- MgeLog mge = resultMap.get(key);
- String objectName = mge.getObjectName() + "," + mgeLog.getObjectName();
- mge.setObjectName(objectName);
- resultMap.put(key, mge);
- } else {
- resultMap.put(key, mgeLog);
- }
- mgeLogListTemp.clear();
- for (Map.Entry<String, MgeLog> entry : resultMap.entrySet()) {
- mgeLogListTemp.add(entry.getValue());
- }
- mgeLog = mgeLogListTemp.get(0);
- } else {
- if (CollectionUtils.isNotEmpty(mgeLogListTemp)) {
- mgeLog.setObjectName(mgeLogListTemp.get(0).getObjectName());
- }
- }
- }
- if (StringUtils.isNotEmpty(mgeLog.getOperateOrgId())) {
- String operateOrgName = iOrgInfoFacade.changeIdsToNames(mgeLog.getOperateOrgId().trim());
- mgeLog.setOperateOrgName(operateOrgName);
- }
- }
- return mgeLogList;
- }
- }
|