|
|
@ -1,35 +1,44 @@ |
|
|
|
package com.epmet.dataaggre.service.govorg.impl; |
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
import com.epmet.commons.tools.dto.result.OptionDataResultDTO; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.ExcelUtils; |
|
|
|
import com.epmet.dataaggre.constant.DataSourceConstant; |
|
|
|
import com.epmet.dataaggre.dao.govorg.*; |
|
|
|
import com.epmet.dataaggre.dto.epmetuser.result.ListStaffResultDTO; |
|
|
|
import com.epmet.dataaggre.dto.epmetuser.result.StaffRoleListResultDTO; |
|
|
|
import com.epmet.dataaggre.dto.govorg.*; |
|
|
|
import com.epmet.dataaggre.dto.govorg.form.NextAreaCodeFormDTO; |
|
|
|
import com.epmet.dataaggre.dto.govorg.form.OrgStaffListFormDTO; |
|
|
|
import com.epmet.dataaggre.dto.govorg.form.StaffDetailV2FormDTO; |
|
|
|
import com.epmet.dataaggre.dto.govorg.form.SubOrgFormDTO; |
|
|
|
import com.epmet.dataaggre.dto.govorg.form.*; |
|
|
|
import com.epmet.dataaggre.dto.govorg.result.*; |
|
|
|
import com.epmet.dataaggre.dto.resigroup.result.OrgInfoCommonDTO; |
|
|
|
import com.epmet.dataaggre.entity.govorg.CustomerAgencyEntity; |
|
|
|
import com.epmet.dataaggre.excel.GridLivelyExcel; |
|
|
|
import com.epmet.dataaggre.service.commonservice.AreaCodeService; |
|
|
|
import com.epmet.dataaggre.service.datastats.DataStatsService; |
|
|
|
import com.epmet.dataaggre.service.epmetuser.EpmetUserService; |
|
|
|
import com.epmet.dataaggre.service.govorg.GovOrgService; |
|
|
|
import com.epmet.dataaggre.service.opercrm.CustomerRelation; |
|
|
|
import com.epmet.dto.result.PcworkRecordListResultDTO; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.text.NumberFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
@ -58,6 +67,8 @@ public class GovOrgServiceImpl implements GovOrgService { |
|
|
|
private CustomerStaffGridDao customerStaffGridDao; |
|
|
|
@Autowired |
|
|
|
private EpmetUserService epmetUserService; |
|
|
|
@Autowired |
|
|
|
private DataStatsService dataStatsService; |
|
|
|
|
|
|
|
/** |
|
|
|
* @param staffId |
|
|
@ -590,5 +601,94 @@ public class GovOrgServiceImpl implements GovOrgService { |
|
|
|
return customerGridDao.getGridInfo(gridId); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 查询组织的直属下级组织下网格活跃度统计【查平阴实际是查的下边八个街道的活跃程度】 |
|
|
|
* @author sun |
|
|
|
* 网格按运行情况分为活跃网格、正常运行网格和僵尸网格三个类别, |
|
|
|
* 以自然周为计量单位对末级网格运行情况进行考核。 |
|
|
|
* 1周内每个末级网格有5天及5天以上上传事件或开展例行工作的为活跃网格; |
|
|
|
* 有2天及2天以上,5天以下上传事件或开展例行工作的为正常运行网格; |
|
|
|
* 只有1天上传事件或开展例行工作的为僵尸网格。 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<GridLivelyResultDTO> grdiLively(GridLivelyFormDTO formDTO) { |
|
|
|
//1.查询当前组织的直属下级组织列表及组织下的网格总数
|
|
|
|
LinkedList<GridLivelyResultDTO> subList = customerAgencyDao.subAgencyListAndGridSumNum(formDTO.getAgencyId()); |
|
|
|
//2.查询直属下级组织下网格在查询时间段内存在例行工作次数的网格,一天一条
|
|
|
|
List<GridDateIdResultDTO> workList = epmetUserService.getGridDateRoutineWorkList(formDTO); |
|
|
|
//3.查询直属下级组织下网格在查询时间段内存在上报事件(直接立项)数的网格,一天一条
|
|
|
|
List<GridDateIdResultDTO> projectList = dataStatsService.getGridDateProjectIncrList(formDTO); |
|
|
|
//4.汇总数据,一个网格一天只记录一条数据,这条数据可能是例行工作的也可能是上报事件的,也可能某一天两个数都有,但只记录一条
|
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
|
workList.forEach(w -> { |
|
|
|
map.put(w.getGridId() + w.getDateId(), w.getDateId()); |
|
|
|
}); |
|
|
|
//projectList.stream().filter(pro -> !map.containsKey(pro.getGridId() + pro.getDateId())).forEach(p -> workList.add(p));
|
|
|
|
projectList.forEach(pro -> { |
|
|
|
if (!map.containsKey(pro.getGridId() + pro.getDateId())) { |
|
|
|
workList.add(pro); |
|
|
|
} |
|
|
|
}); |
|
|
|
//5.按组织封装数据
|
|
|
|
//计算百分比使用,保留小数点后两位
|
|
|
|
NumberFormat numberFormat = NumberFormat.getInstance(); |
|
|
|
numberFormat.setMaximumFractionDigits(NumConstant.TWO); |
|
|
|
subList.forEach(sub -> { |
|
|
|
Map<String, Integer> hash = new HashMap<>(); |
|
|
|
workList.forEach(w -> { |
|
|
|
if (w.getPids().contains(sub.getAgencyId())) { |
|
|
|
if (hash.containsKey(w.getGridId())) { |
|
|
|
hash.put(w.getGridId(), hash.get(w.getGridId()) + NumConstant.ONE); |
|
|
|
} else { |
|
|
|
hash.put(w.getGridId(), NumConstant.ONE); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
//活跃网格数、普通网格数、僵尸网格数
|
|
|
|
int gridLivelyNum = 0; |
|
|
|
int gridOrdinaryNum = 0; |
|
|
|
int gridLazyNum = 0; |
|
|
|
for (Integer val : hash.values()) { |
|
|
|
if (val >= NumConstant.FIVE) { |
|
|
|
gridLivelyNum++; |
|
|
|
} else if (val >= NumConstant.TWO && val < NumConstant.FIVE) { |
|
|
|
gridOrdinaryNum++; |
|
|
|
} else { |
|
|
|
gridLazyNum++; |
|
|
|
} |
|
|
|
} |
|
|
|
sub.setGridLivelyNum(gridLivelyNum); |
|
|
|
sub.setGridLivelyRatio((sub.getGridSumNum() == 0 || gridLivelyNum > sub.getGridSumNum()) ? "0%" : numberFormat.format(((float) gridLivelyNum / (float) sub.getGridSumNum()) * 100) + "%"); |
|
|
|
sub.setGridOrdinaryNum(gridOrdinaryNum); |
|
|
|
sub.setGridOrdinaryRatio((sub.getGridSumNum() == 0 || gridOrdinaryNum > sub.getGridSumNum()) ? "0%" : numberFormat.format(((float) gridOrdinaryNum / (float) sub.getGridSumNum()) * 100) + "%"); |
|
|
|
sub.setGridLazyNum(gridLazyNum); |
|
|
|
sub.setGridLazyRatio((sub.getGridSumNum() == 0 || gridLazyNum > sub.getGridSumNum()) ? "0%" : numberFormat.format(((float) gridLazyNum / (float) sub.getGridSumNum()) * 100) + "%"); |
|
|
|
}); |
|
|
|
|
|
|
|
return subList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author sun |
|
|
|
* @Description 查询组织的直属下级组织下网格活跃度统计--文件导出 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public void grdiLivelyExport(HttpServletResponse response, GridLivelyFormDTO formDTO) { |
|
|
|
ExcelWriter excelWriter = null; |
|
|
|
try { |
|
|
|
excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel("网格活跃度统计表.xlsx", response)).build(); |
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet("sheet").build(); |
|
|
|
writeSheet.setClazz(GridLivelyExcel.class); |
|
|
|
List<GridLivelyExcel> data = ConvertUtils.sourceToTarget(grdiLively(formDTO), GridLivelyExcel.class); |
|
|
|
excelWriter.write(data, writeSheet); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} finally { |
|
|
|
if (excelWriter != null) { |
|
|
|
excelWriter.finish(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|