| | |
| | | package com.panzhihua.westcommittee.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.panzhihua.common.controller.BaseController; |
| | | import com.panzhihua.common.exceptions.ServiceException; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.west.SystemUserVo; |
| | | import com.panzhihua.westcommittee.model.entity.ComAct; |
| | | import com.panzhihua.westcommittee.model.entity.ComStreet; |
| | | import com.panzhihua.westcommittee.model.entity.Complaint; |
| | | import com.panzhihua.westcommittee.model.entity.SystemUser; |
| | | import com.panzhihua.westcommittee.model.query.AnalyticStatisticsQuery; |
| | | import com.panzhihua.westcommittee.model.query.AppStaticsQuery; |
| | | import com.panzhihua.westcommittee.model.vo.AnalyticStatisticsFourVo; |
| | | import com.panzhihua.westcommittee.model.vo.AnalyticStatisticsOneVo; |
| | | import com.panzhihua.westcommittee.model.vo.AnalyticStatisticsThreeVo; |
| | | import com.panzhihua.westcommittee.model.vo.AnalyticStatisticsTwoVo; |
| | | import com.panzhihua.westcommittee.model.vo.RegionVO; |
| | | import com.panzhihua.westcommittee.model.vo.*; |
| | | import com.panzhihua.westcommittee.service.IComActService; |
| | | import com.panzhihua.westcommittee.service.IComStreetService; |
| | | import com.panzhihua.westcommittee.service.IComplaintService; |
| | | import com.panzhihua.westcommittee.service.IdentityInformationService; |
| | | import com.panzhihua.westcommittee.service.impl.StaticsService; |
| | | import com.panzhihua.westcommittee.warpper.IdentityInformation; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author mitao |
| | |
| | | @RequiredArgsConstructor(onConstructor_ = {@Lazy}) |
| | | public class StaticsController extends BaseController { |
| | | private final StaticsService staticsService; |
| | | private final IdentityInformationService identityInformationService; |
| | | private final IComStreetService comStreetService; |
| | | private final IComActService comActService; |
| | | private final IComplaintService complaintService; |
| | | |
| | | @GetMapping("/region-tree") |
| | | @ApiOperation("获取区域树") |
| | |
| | | LoginUserInfoVO loginUserInfo = getLoginUserInfo(); |
| | | return R.ok(staticsService.queryStaticsPartFour(query,loginUserInfo)); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/data") |
| | | @ApiOperation(value = "分析统计", tags = {"西区纪委小程序-分析统计"}) |
| | | public R<AnalyticStatisticsDataVo> data(@Valid @RequestBody AnalyticStatisticsQuery query){ |
| | | LoginUserInfoVO loginUserInfo = getLoginUserInfo(); |
| | | IdentityInformation identityInformation = identityInformationService.getIdentityInformation(loginUserInfo); |
| | | SystemUser systemUser = identityInformation.getSystemUser(); |
| | | AnalyticStatisticsDataVo analyticStatisticsDataVo = new AnalyticStatisticsDataVo(); |
| | | if(systemUser==null || systemUser.getSystemRoleId()>2){ |
| | | return R.ok(analyticStatisticsDataVo); |
| | | } |
| | | Integer accountLevel = systemUser.getAccountLevel(); |
| | | LambdaQueryWrapper<Complaint> wrapper = new LambdaQueryWrapper<>(); |
| | | if(query.getDistrictCode()!=null){ |
| | | // 没有市权限 也没有该区权限 |
| | | if(accountLevel!=2){ |
| | | throw new ServiceException("没有该区县权限"); |
| | | } |
| | | wrapper.eq(Complaint::getSuperiorId, query.getDistrictCode()); |
| | | } |
| | | if(query.getStreetId()!=null){ |
| | | // 获取街道上一级查看是否有上级权限 |
| | | ComStreet comStreet = comStreetService.getById(query.getStreetId()); |
| | | if(comStreet==null){ |
| | | throw new ServiceException("没有该街道权限"); |
| | | } |
| | | // 没有市级 上级区县 本级街道权限 |
| | | if(accountLevel==2 || (accountLevel==3 && systemUser.getDistrictsCode().equals(query.getDistrictCode().toString()))){ |
| | | wrapper.eq(Complaint::getSuperiorId, query.getStreetId()); |
| | | }else { |
| | | throw new ServiceException("没有该街道权限"); |
| | | } |
| | | } |
| | | |
| | | if(query.getCommunityId()!=null){ |
| | | |
| | | ComAct comAct = comActService.getById(query.getCommunityId()); |
| | | if (comAct == null) { |
| | | throw new ServiceException("没有该社区权限"); |
| | | } |
| | | |
| | | // 判断是否有上面的4个权限 |
| | | if(accountLevel==2 || (accountLevel==3 && systemUser.getDistrictsCode().equals(comAct.getStreetId().toString()) || accountLevel==4 && systemUser.getCommunityId().equals(comAct.getCommunityId()))){ |
| | | wrapper.eq(Complaint::getSuperiorId, query.getCommunityId()); |
| | | }else { |
| | | throw new ServiceException("没有该社区权限"); |
| | | } |
| | | } |
| | | |
| | | // 都为空 查他有的 |
| | | if(query.getCityCode()==null && query.getDistrictCode()==null && query.getStreetId()==null && query.getCommunityId()==null){ |
| | | if(systemUser.getSystemRoleId()==1 || systemUser.getSystemRoleId()==2){ |
| | | if(systemUser.getSystemRoleId()==1){ |
| | | wrapper.ne(Complaint::getProblemType,"检举"); |
| | | } |
| | | if(accountLevel==3){ |
| | | String streetId = systemUser.getStreetId(); |
| | | List<Long> ids = comActService.list(new LambdaQueryWrapper<ComAct>().eq(ComAct::getStreetId, streetId)).stream().map(ComAct::getCommunityId).collect(Collectors.toList()); |
| | | wrapper.eq(Complaint::getNowLevel,systemUser.getAccountLevel()).or(wrapper1 ->wrapper1.in(Complaint::getSuperiorId,ids).eq(Complaint::getNowLevel,4)); |
| | | } |
| | | if(accountLevel==4){ |
| | | wrapper.eq(Complaint::getNowLevel,systemUser.getAccountLevel()); |
| | | } |
| | | }else { |
| | | wrapper.eq(Complaint::getNowLevel,systemUser.getAccountLevel()) |
| | | .eq(Complaint::getAssignPersonId,systemUser.getOneDepartmentId()); |
| | | } |
| | | } |
| | | |
| | | |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | List<Complaint> complaints =complaintService.list(wrapper); |
| | | // 第一部分数据 |
| | | AnalyticStatisticsOneVo analyticStatisticsOneVo = complaintService.analyticStatisticsOne(query,complaints,simpleDateFormat,systemUser.getAccountLevel()); |
| | | |
| | | // 第二部分数据 |
| | | List<AnalyticStatisticsTwoVo> analyticStatisticsTwoVos =complaintService.analyticStatisticsTwo(query.getTime(),complaints,simpleDateFormat); |
| | | |
| | | // 第三部分数据 |
| | | List<AnalyticStatisticsThreeVo> analyticStatisticsThreeVos =complaintService.analyticStatisticsThree(query.getRank(), complaints); |
| | | |
| | | // 第四部分数据 |
| | | AnalyticStatisticsFourVo analyticStatisticsFourVos =complaintService.analyticStatisticsFour(complaints); |
| | | |
| | | |
| | | analyticStatisticsDataVo.setAnalyticStatisticsOneVo(analyticStatisticsOneVo); |
| | | analyticStatisticsDataVo.setAnalyticStatisticsTwoVos(analyticStatisticsTwoVos); |
| | | analyticStatisticsDataVo.setAnalyticStatisticsThreeVos(analyticStatisticsThreeVos); |
| | | analyticStatisticsDataVo.setAnalyticStatisticsFourVo(analyticStatisticsFourVos); |
| | | return R.ok(analyticStatisticsDataVo); |
| | | } |
| | | |
| | | |
| | | } |