package com.ruoyi.web.controller.api; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.system.model.*; import com.ruoyi.system.query.StoryListQuery; import com.ruoyi.system.service.*; import com.ruoyi.system.vo.ScreenUserVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.HashMap; import java.util.List; /** * 数据统计面板 前端控制器 * * @author xiaochen * @since 2025-12-23 */ @RestController @RequestMapping("/dashboard-statistics") @Api(tags = "数据统计面板") @RequiredArgsConstructor(onConstructor_ = @Lazy) public class DashboardStatisticsController { @Autowired private ScreenAccountService screenAccountService; @Autowired private TokenService tokenService; @Autowired private ClientService clientService; @Autowired private ClientParamService clientParamService; @Autowired private ProjectService projectService; @Autowired private AccidentBriefService accidentBriefService; @ApiOperation("获取当前登录信息") @GetMapping("/getLoginInfo") public R getLoginInfo(Integer type, Integer id) { ScreenUserVo screenUserVo = new ScreenUserVo(); screenUserVo.setType(type); if(type!=null && id !=null){ if(type==1){ Client client = clientService.getById(id); if(client==null){ return R.fail("委托方不存在"); } ClientParam param = clientParamService.getOne(new LambdaQueryWrapper().eq(ClientParam::getClientId, client.getId())); if(param!=null){ screenUserVo.setLogo(param.getLogo()); screenUserVo.setName(param.getName()); screenUserVo.setPermissionClient(param.getPermissionClient()); screenUserVo.setPermissionProject(param.getPermissionProject()); } }else if(type==2){ Project project = projectService.getById(id); if(project==null){ return R.fail("项目不存在"); } screenUserVo.setName(project.getName()); screenUserVo.setPermissionProject(project.getPermission()); } } return R.ok(screenUserVo); } @ApiOperation(value = "获取故事简讯列表",response = AccidentBrief.class) @PostMapping("/getStoryList") public R> getStoryList(@RequestBody StoryListQuery query) { Page page = new Page<>(query.getPageNum(), query.getPageSize()); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(AccidentBrief::getState,1); if(query.getCity()!=null && !query.getCity().isEmpty()){ wrapper.eq(AccidentBrief::getCity, query.getCity()); } if(query.getClassifyId()!=null){ wrapper.eq(AccidentBrief::getClassifyId, query.getClassifyId()); } if(query.getTime()!=null && !query.getTime().isEmpty()){ String sTime = query.getTime().split(" - ")[0]+" 00:00:00"; String eTime = query.getTime().split(" - ")[1]+" 23:59:59"; wrapper.between(AccidentBrief::getTime,sTime,eTime); } if(query.getContent()!=null && !query.getContent().isEmpty()){ wrapper.like(AccidentBrief::getContent, query.getContent()); } wrapper.orderByDesc(AccidentBrief::getTime); Page accidentBriefPage = accidentBriefService.page(page, wrapper); return R.ok(accidentBriefPage); } @ApiOperation(value = "获取故事简讯详情",response = AccidentBrief.class) @GetMapping("/getStoryDetail/{id}") public R getStoryDetail(@PathVariable Integer id) { AccidentBrief accidentBrief = accidentBriefService.getById(id); return R.ok(accidentBrief); } }