diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java index e9c7314437..c7244b019a 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java @@ -7,7 +7,6 @@ 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; @@ -29,7 +28,6 @@ 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; @@ -37,8 +35,8 @@ 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.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -647,22 +645,20 @@ public class GovOrgServiceImpl implements GovOrgService { //活跃网格数、普通网格数、僵尸网格数 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) + "%"); + int gridLazyNum = sub.getGridSumNum() - gridLivelyNum - gridOrdinaryNum; + sub.setGridLazyNum(gridLazyNum < 0 ? 0 : gridLazyNum); + sub.setGridLazyRatio((sub.getGridSumNum() == 0 || gridLazyNum < 0) ? "0%" : numberFormat.format(((float) gridLazyNum / (float) sub.getGridSumNum()) * 100) + "%"); }); return subList; @@ -677,7 +673,7 @@ public class GovOrgServiceImpl implements GovOrgService { ExcelWriter excelWriter = null; try { excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel("网格活跃度统计表.xlsx", response)).build(); - WriteSheet writeSheet = EasyExcel.writerSheet("sheet").build(); + WriteSheet writeSheet = EasyExcel.writerSheet(excelSheetName(formDTO)).build(); writeSheet.setClazz(GridLivelyExcel.class); List data = ConvertUtils.sourceToTarget(grdiLively(formDTO), GridLivelyExcel.class); excelWriter.write(data, writeSheet); @@ -690,5 +686,16 @@ public class GovOrgServiceImpl implements GovOrgService { } } + private String excelSheetName(GridLivelyFormDTO formDTO){ + StringBuilder name = new StringBuilder(); + SimpleDateFormat format1 = new SimpleDateFormat("yyyyMMdd"); + SimpleDateFormat format2 = new SimpleDateFormat("yyyy年MM月dd日"); + try{ + name.append(format2.format(format1.parse(formDTO.getStartTime()))).append("至").append(format2.format(format1.parse(formDTO.getEndTime()))).append("网格活跃度统计"); + } catch (Exception e) { + e.printStackTrace(); + } + return name.toString(); + } }