| | |
| | | package com.project.report.service.impl; |
| | | |
| | | import com.project.common.core.domain.entity.SysDept; |
| | | import com.project.common.core.domain.entity.SysDictData; |
| | | import com.project.common.core.domain.entity.SysUser; |
| | | import com.project.common.vo.KeyVal; |
| | | import com.project.enforce.domain.EnforceOrder; |
| | | import com.project.enforce.service.IEnforceComplaintLogService; |
| | | import com.project.enforce.service.IEnforceOrderService; |
| | | import com.project.report.domain.bo.query.ReportQueryBo; |
| | | import com.project.report.mapper.ReportMapper; |
| | | import com.project.report.service.IReportService; |
| | | import com.project.system.domain.SysCompany; |
| | | import com.project.system.domain.SysDoc; |
| | | import com.project.system.service.ISysCompanyService; |
| | | import com.project.system.service.ISysDeptService; |
| | | import com.project.system.service.ISysDocService; |
| | | import com.project.system.service.ISysUserService; |
| | | import com.project.system.service.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.jetbrains.annotations.NotNull; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.*; |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | private final ISysDeptService deptService; |
| | | private final ISysUserService userService; |
| | | private final ISysDocService docService; |
| | | private final ISysDictDataService dictDataService; |
| | | private final IEnforceOrderService orderService; |
| | | private final IEnforceComplaintLogService complaintLogService; |
| | | private final ReportMapper reportMapper; |
| | | |
| | | |
| | | private final String[] months = {"1","2","3","4","5","6","7","8","9","10","11","12"}; |
| | | private final String[] complaintStatus = {"-1","0","1","2"}; |
| | | |
| | | @Override//汇总 |
| | | public Map<String, Object> getTotalInfo() |
| | | { |
| | | |
| | | int companyNum = companyService.count(companyService.lq().eq(SysCompany::getCompanyStatus, 0)); |
| | | int enforceCompanyNum = orderService.count(orderService.lq().groupBy(EnforceOrder::getCompanyId)); |
| | | int enforceDeptNum = deptService.count(deptService.lq().eq(SysDept::getParentId,100)); |
| | | int enforceUserNum = userService.count(userService.lq().ne(SysUser::getUserType,"02")); |
| | | int enforceOrderNum = orderService.count(); |
| | | int enforceOrderCheckedNum = orderService.count(orderService.lq().eq(EnforceOrder::getOrderStatus,2)); |
| | | int enforceOrderCompleteNum = orderService.count(orderService.lq().eq(EnforceOrder::getOrderStatus,4)); |
| | | int complaintNum = complaintLogService.count(); |
| | | int docNum = docService.count(docService.lq().eq(SysDoc::getDocStatus,0)); |
| | | |
| | | Map<String, Object> result = new HashMap<>(7); |
| | | result.put("companyNum", companyNum); |
| | | result.put("enforceCompanyNum", enforceCompanyNum); |
| | | result.put("enforceDeptNum", enforceDeptNum); |
| | | result.put("enforceUserNum", enforceUserNum); |
| | | result.put("enforceOrderNum", enforceOrderNum); |
| | | result.put("enforceOrderCheckedNum", enforceOrderCheckedNum); |
| | | result.put("enforceOrderCompleteNum", enforceOrderCompleteNum); |
| | | result.put("complaintNum", complaintNum); |
| | | result.put("docNum", docNum); |
| | | return result; |
| | | } |
| | | |
| | | @Override//执法单位执法次数月度分布 |
| | | public List<KeyVal> getMonthCount(Long deptId) |
| | | public List<KeyVal> getMonthCount(ReportQueryBo bo) |
| | | { |
| | | List<KeyVal> list = orderService.getMonthCount(deptId); |
| | | Map<String, Object> resultMap = list.stream().collect(Collectors.toMap(KeyVal::getK,KeyVal::getV)); |
| | | List<KeyVal> list = reportMapper.getMonthCount(bo); |
| | | return getKeyVal(list, months); |
| | | } |
| | | |
| | | return Arrays.stream(months).map(e -> { |
| | | @Override//执法单位执法次数部门分布 |
| | | public List<KeyVal> getDeptCount(ReportQueryBo bo) |
| | | { |
| | | List<KeyVal> list = reportMapper.getDeptCount(bo); |
| | | Map<String, Object> resultMap = list.stream().collect(Collectors.toMap(KeyVal::getK,KeyVal::getV)); |
| | | List<SysDept> deptList = deptService.list(deptService.lq().eq(SysDept::getParentId, 100)); |
| | | return deptList.stream().map(e -> { |
| | | KeyVal keyVal; |
| | | if (resultMap.get(e.getDeptId().toString()) == null) { |
| | | keyVal = new KeyVal(e.getDeptName(), 0); |
| | | } else { |
| | | keyVal = new KeyVal(e.getDeptName(), resultMap.get(e.getDeptId().toString())); |
| | | } |
| | | return keyVal; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override//企业被执法次数分布 |
| | | public List<KeyVal> getCompanyCount(ReportQueryBo bo) |
| | | { |
| | | List<KeyVal> list = reportMapper.getCompanyCount(bo); |
| | | Map<String, Object> resultMap = list.stream().collect(Collectors.toMap(KeyVal::getK, KeyVal::getV)); |
| | | |
| | | List<SysCompany> companies = companyService.list(companyService.lq().eq(SysCompany::getCompanyStatus, 0)); |
| | | |
| | | return companies.stream().map(e -> { |
| | | KeyVal keyVal; |
| | | if (resultMap.get(e.getCompanyId().toString()) == null) { |
| | | keyVal = new KeyVal(e.getCompanyName(), 0); |
| | | } else { |
| | | keyVal = new KeyVal(e.getCompanyName(), resultMap.get(e.getCompanyId().toString())); |
| | | } |
| | | return keyVal; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override//执法类型 |
| | | public List<KeyVal> getEnforceTypeCount(ReportQueryBo bo) |
| | | { |
| | | List<KeyVal> list = reportMapper.getEnforceTypeCount(bo); |
| | | Map<String, Object> resultMap = list.stream().collect(Collectors.toMap(KeyVal::getK, KeyVal::getV)); |
| | | List<SysDictData> dictDataList = dictDataService.list(dictDataService.lq().eq(SysDictData::getDictType,"enforce_type")); |
| | | return getKeyVal(resultMap, dictDataList); |
| | | } |
| | | |
| | | |
| | | @Override//投诉处理状态 |
| | | public List<KeyVal> getComplaintStatusCount(ReportQueryBo bo) |
| | | { |
| | | List<KeyVal> list = reportMapper.getComplaintStatusCount(bo); |
| | | return getKeyVal(list, complaintStatus); |
| | | } |
| | | |
| | | |
| | | @Override//投诉类型 |
| | | public List<KeyVal> getComplaintTypeCount(ReportQueryBo bo) |
| | | { |
| | | List<KeyVal> list = reportMapper.getComplaintTypeCount(bo); |
| | | Map<String, Object> resultMap = list.stream().collect(Collectors.toMap(KeyVal::getK, KeyVal::getV)); |
| | | List<SysDictData> dictDataList = dictDataService.list(dictDataService.lq().eq(SysDictData::getDictType,"complaint_type")); |
| | | return getKeyVal(resultMap, dictDataList); |
| | | } |
| | | |
| | | |
| | | //----------------------------------------------------------------------------- |
| | | |
| | | /** |
| | | * 通过数组获取返回数据 |
| | | * @param list 结果 |
| | | * @param array 数组 |
| | | * @return 结果 |
| | | */ |
| | | @NotNull |
| | | private List<KeyVal> getKeyVal(List<KeyVal> list, String[] array) |
| | | { |
| | | Map<String, Object> resultMap = list.stream().collect(Collectors.toMap(KeyVal::getK,KeyVal::getV)); |
| | | return Arrays.stream(array).map(e -> { |
| | | KeyVal keyVal; |
| | | if (resultMap.get(e) == null) { |
| | | keyVal = new KeyVal(e, 0); |
| | |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override//执法单位执法次数部门分布 |
| | | public List<KeyVal> getDeptCount(String yearMonth) |
| | | /** |
| | | * 通过字典获取返回数据 |
| | | * @param resultMap 结果 |
| | | * @param dictDataList 字典 |
| | | * @return 结果 |
| | | */ |
| | | @NotNull |
| | | private List<KeyVal> getKeyVal(Map<String, Object> resultMap, List<SysDictData> dictDataList) |
| | | { |
| | | List<KeyVal> list = orderService.getDeptCount(yearMonth); |
| | | Map<String, Object> resultMap = list.stream().collect(Collectors.toMap(KeyVal::getK,KeyVal::getV)); |
| | | |
| | | List<SysDept> depts = deptService.list(deptService.lq().eq(SysDept::getParentId, 100)); |
| | | |
| | | return depts.stream().map(e -> { |
| | | return dictDataList.stream().map(e -> { |
| | | KeyVal keyVal; |
| | | if (resultMap.get(e.getDeptId().toString()) == null) { |
| | | keyVal = new KeyVal(e.getDeptName(), 0); |
| | | if (resultMap.get(e.getDictValue()) == null) { |
| | | keyVal = new KeyVal(e.getDictLabel(), 0); |
| | | } else { |
| | | keyVal = new KeyVal(e.getDeptName(), resultMap.get(e.getDeptId().toString())); |
| | | keyVal = new KeyVal(e.getDictLabel(), resultMap.get(e.getDictValue())); |
| | | } |
| | | return keyVal; |
| | | }).collect(Collectors.toList()); |