diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/poi/excel/handler/CustomMergeStrategy.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/poi/excel/handler/CustomMergeStrategy.java new file mode 100644 index 0000000000..bbe8cafbca --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/poi/excel/handler/CustomMergeStrategy.java @@ -0,0 +1,91 @@ +package com.epmet.commons.tools.utils.poi.excel.handler;/** + * @author ZhaoQiFeng + * @date 2022/12/14 + * @apiNote + */ + +import com.alibaba.excel.metadata.Head; +import com.alibaba.excel.write.merge.AbstractMergeStrategy; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.util.CellRangeAddress; + +import java.util.ArrayList; +import java.util.List; + +/** + * 自定义合并策略 该类继承了AbstractMergeStrategy抽象合并策略,需要重写merge()方法 + * @Author zhaoqifeng + * @Date 2022/12/14 15:10 + */ +public class CustomMergeStrategy extends AbstractMergeStrategy { + + /** + * 分组,每几行合并一次 + */ + private List exportFieldGroupCountList; + + /** + * 目标合并列index + */ + private Integer targetColumnIndex; + + // 需要开始合并单元格的首行index + private Integer rowIndex; + + // exportDataList为待合并目标列的值 + public CustomMergeStrategy(List exportDataList, Integer targetColumnIndex) { + this.exportFieldGroupCountList = getGroupCountList(exportDataList); + this.targetColumnIndex = targetColumnIndex; + } + + + @Override + protected void merge(Sheet sheet, Cell cell, Head head, Integer relativeRowIndex) { + + if (null == rowIndex) { + rowIndex = cell.getRowIndex(); + } + // 仅从首行以及目标列的单元格开始合并,忽略其他 + if (cell.getRowIndex() == rowIndex && cell.getColumnIndex() == targetColumnIndex) { + mergeGroupColumn(sheet); + } + } + + private void mergeGroupColumn(Sheet sheet) { + int rowCount = rowIndex; + for (Integer count : exportFieldGroupCountList) { + if(count == 1) { + rowCount += count; + continue ; + } + // 合并单元格 + CellRangeAddress cellRangeAddress = new CellRangeAddress(rowCount, rowCount + count - 1, targetColumnIndex, targetColumnIndex); + sheet.addMergedRegionUnsafe(cellRangeAddress); + rowCount += count; + } + } + + // 该方法将目标列根据值是否相同连续可合并,存储可合并的行数 + private List getGroupCountList(List exportDataList){ + if (CollectionUtils.isEmpty(exportDataList)) { + return new ArrayList<>(); + } + + List groupCountList = new ArrayList<>(); + int count = 1; + + for (int i = 1; i < exportDataList.size(); i++) { + if (exportDataList.get(i).equals(exportDataList.get(i - 1))) { + count++; + } else { + groupCountList.add(count); + count = 1; + } + } + // 处理完最后一条后 + groupCountList.add(count); + return groupCountList; + } +} diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/constant/EventConstant.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/constant/EventConstant.java new file mode 100644 index 0000000000..ad8948fa23 --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/constant/EventConstant.java @@ -0,0 +1,10 @@ +package com.epmet.dataaggre.constant; + +/** + * @Author zxc + * @DateTime 2020/12/25 上午10:47 + */ +public interface EventConstant { + String PROJECT = "project"; + String WORK = "work"; +} diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/form/EventCategoryFormDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/form/EventCategoryFormDTO.java index 5d848e185e..f9cd88c5e5 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/form/EventCategoryFormDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/form/EventCategoryFormDTO.java @@ -44,4 +44,7 @@ public class EventCategoryFormDTO implements Serializable { */ @NotBlank(message = "组织名称不能为空",groups = CategoryEventExportForm.class) private String orgName; + + private String name; + private String mobile; } diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/form/EventCategoryListFormDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/form/EventCategoryListFormDTO.java new file mode 100644 index 0000000000..58bf30b26d --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/form/EventCategoryListFormDTO.java @@ -0,0 +1,65 @@ +package com.epmet.dataaggre.dto.evaluationindex.form; + +import com.epmet.commons.tools.dto.form.PageFormDTO; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * @author Administrator + */ +@Data +public class EventCategoryListFormDTO extends PageFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + public interface EventCategoryForm{} + public interface CategoryEventExportForm {} + public interface CategoryEventListExportForm {} + /** + * 组织ID + */ + private String customerId; + + /** + * 组织ID + */ + private String orgId; + + /** + * 组织类型 组织:agency,网格:grid + */ + private String orgType; + + @NotBlank(message = "结束时间不能为空",groups = {EventCategoryForm.class,CategoryEventExportForm.class}) + private String endTime; + + /** + * 类型,project:事件, work:例行工作 + */ + @NotNull(message = "事件类型不能为空",groups = CategoryEventListExportForm.class) + private String eventType; + + /** + * 开始时间 + */ + private String startTime; + + /** + * 组织名称 + */ + @NotBlank(message = "组织名称不能为空",groups = CategoryEventExportForm.class) + private String orgName; + + @NotNull(message = "categoryCode不能为空",groups = {EventCategoryForm.class, CategoryEventListExportForm.class}) + private String categoryCode; + + @NotNull(message = "categoryName不能为空",groups = CategoryEventListExportForm.class) + private String categoryName; + private String parentCategoryName; + + private String name; + private String mobile; +} diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/result/EventCategoryListResultDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/result/EventCategoryListResultDTO.java new file mode 100644 index 0000000000..6836682946 --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/result/EventCategoryListResultDTO.java @@ -0,0 +1,59 @@ +package com.epmet.dataaggre.dto.evaluationindex.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author Administrator + */ +@Data +public class EventCategoryListResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 事件ID + */ + private String eventId; + + /** + * 事件类型 项目:project,例行工作:work + */ + private String eventType; + + /** + * 标题 + */ + private String title; + + /** + * 类别 + */ + private String category; + + /** + * 项目状态:待处理 pending,结案closed + */ + private String status; + + /** + * 项目状态:待处理 pending,结案closed + */ + private String statusDesc; + + /** + * 所属网格 + */ + private String gridName; + private String gridId; + /** + * 项目创建时间 + */ + private String createTime; + + private String staffName; + + private Integer score; + +} diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/result/EventScoreTotalResultDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/result/EventScoreTotalResultDTO.java new file mode 100644 index 0000000000..419efe119a --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/evaluationindex/result/EventScoreTotalResultDTO.java @@ -0,0 +1,33 @@ +package com.epmet.dataaggre.dto.evaluationindex.result;/** + * @author ZhaoQiFeng + * @date 2022/12/14 + * @apiNote + */ + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description + * @Author zhaoqifeng + * @Date 2022/12/14 13:39 + */ +@Data +public class EventScoreTotalResultDTO implements Serializable { + private static final long serialVersionUID = 2570384890580378137L; + private String orgName; + private String date; + /** + * 总分 + */ + private String totalScore; + /** + * 网格员数量 + */ + private String memberCount; + /** + * 考核得分 + */ + private String aveScore; +} diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/PingYinEventController.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/PingYinEventController.java index 50531e28b1..8ec1f0089b 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/PingYinEventController.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/PingYinEventController.java @@ -1,20 +1,43 @@ package com.epmet.dataaggre.controller; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.alibaba.excel.write.metadata.fill.FillConfig; +import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.poi.excel.handler.CustomMergeStrategy; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dataaggre.dto.evaluationindex.EventCategoryResultDTO; import com.epmet.dataaggre.dto.evaluationindex.form.EventCategoryFormDTO; +import com.epmet.dataaggre.dto.evaluationindex.form.EventCategoryListFormDTO; +import com.epmet.dataaggre.dto.evaluationindex.result.EventCategoryListResultDTO; +import com.epmet.dataaggre.dto.evaluationindex.result.EventScoreTotalResultDTO; import com.epmet.dataaggre.service.evaluationindex.PingYinEventService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.core.io.ClassPathResource; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.List; +import java.util.stream.Collectors; /** @@ -41,5 +64,114 @@ public class PingYinEventController { return new Result>().ok(pingYinEventService.getEventCategorySore(tokenDto, formDTO)); } + /** + * 事件分类列表 + * + * @Param tokenDto + * @Param formDTO + * @Return {@link Result< PageData< EventCategoryListResultDTO>>} + * @Author zhaoqifeng + * @Date 2022/12/13 9:55 + */ + @PostMapping("getEventCategoryList") + public Result> getEventCategoryList(@LoginUser TokenDto tokenDto, @RequestBody EventCategoryListFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO, EventCategoryListFormDTO.EventCategoryForm.class); + formDTO.setCustomerId(tokenDto.getCustomerId()); + return new Result>().ok(pingYinEventService.getEventCategoryList(formDTO)); + } + + /** + * 事件赋值得分总计 + * + * @Param tokenDto + * @Param formDTO + * @Return {@link Result< EventScoreTotalResultDTO>} + * @Author zhaoqifeng + * @Date 2022/12/14 13:46 + */ + @PostMapping("getEventScoreTotal") + public Result getEventScoreTotal(@LoginUser TokenDto tokenDto, @RequestBody EventCategoryFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO, EventCategoryListFormDTO.EventCategoryForm.class); + formDTO.setCustomerId(tokenDto.getCustomerId()); + return new Result().ok(pingYinEventService.getEventScoreTotal(formDTO)); + } + + /** + * 事件赋值得分导出 + * @Param tokenDto + * @Param formDTO + * @Param response + * @Return + * @Author zhaoqifeng + * @Date 2022/12/14 16:08 + */ + @PostMapping("eventScoreExport") + public void eventScoreExport(@LoginUser TokenDto tokenDto, + @RequestBody EventCategoryFormDTO formDTO, HttpServletResponse response) throws Exception{ + ValidatorUtils.validateEntity(formDTO, EventCategoryListFormDTO.EventCategoryForm.class); + formDTO.setCustomerId(tokenDto.getCustomerId()); + String fileName = formDTO.getOrgName() + "事件赋值得分.xlsx"; + ExcelWriter excelWriter = null; + //获取模板 + ClassPathResource classPathResource = new ClassPathResource("excel/eventScore.xlsx"); + InputStream inputStream = classPathResource.getInputStream(); + try { + + try { + fileName = URLEncoder.encode("事件赋值得分.xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + response.setHeader("Content-disposition", "attachment; filename=" + fileName); + response.setContentType("application/msexcel;charset=UTF-8"); + response.setHeader("Pragma", "No-cache"); + response.setHeader("Cache-Control", "no-cache"); + response.setDateHeader("Expires", 0); + ServletOutputStream outputStream = response.getOutputStream(); + //总计 + EventScoreTotalResultDTO scoreTotal = pingYinEventService.getEventScoreTotal(formDTO); + scoreTotal.setOrgName(formDTO.getOrgName()); + String endTime =DateUtils.format(DateUtils.parse(formDTO.getEndTime(), DateUtils.DATE_PATTERN_YYYYMMDD), DateUtils.DATE_NAME_PATTERN); + if (StringUtils.isNotEmpty(formDTO.getStartTime())) { + String startTime =DateUtils.format(DateUtils.parse(formDTO.getStartTime(), DateUtils.DATE_PATTERN_YYYYMMDD), DateUtils.DATE_NAME_PATTERN); + scoreTotal.setDate(startTime.concat("—").concat(endTime)); + } else { + scoreTotal.setDate("截止到" + endTime); + } + //分类统计 + List categoryList = pingYinEventService.getEventCategorySoreExport(tokenDto, formDTO); + //设置输出流和模板信息 + excelWriter = EasyExcel.write(outputStream).withTemplate(inputStream).build(); + WriteSheet writeSheet = EasyExcel.writerSheet(0) + .registerWriteHandler(new CustomMergeStrategy(categoryList.stream().map(EventCategoryResultDTO::getEventType).collect(Collectors.toList()), 0)) + .registerWriteHandler(new CustomMergeStrategy(categoryList.stream().map(EventCategoryResultDTO::getParentCategoryName).collect(Collectors.toList()), 1)) + .build(); + //开启自动换行,自动换行表示每次写入一条list数据是都会重新生成一行空行,此选项默认是关闭的,需要提前设置为true + FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build(); + excelWriter.fill(categoryList, fillConfig, writeSheet); + excelWriter.fill(scoreTotal, writeSheet); + } catch (EpmetException e) { + response.reset(); + response.setCharacterEncoding("UTF-8"); + response.setHeader("content-type", "application/json; charset=UTF-8"); + PrintWriter printWriter = response.getWriter(); + Result result = new Result<>().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),e.getMsg()); + printWriter.write(JSON.toJSONString(result)); + printWriter.close(); + } catch (Exception e) { + log.error("export exception", e); + } finally { + if (excelWriter != null) { + excelWriter.finish(); + } + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/evaluationindex/PingYinEventDao.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/evaluationindex/PingYinEventDao.java index 86ddcb8590..66f9962f37 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/evaluationindex/PingYinEventDao.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/evaluationindex/PingYinEventDao.java @@ -19,6 +19,8 @@ package com.epmet.dataaggre.dao.evaluationindex; import com.epmet.dataaggre.dto.evaluationindex.EventCategoryResultDTO; import com.epmet.dataaggre.dto.evaluationindex.form.EventCategoryFormDTO; +import com.epmet.dataaggre.dto.evaluationindex.form.EventCategoryListFormDTO; +import com.epmet.dataaggre.dto.evaluationindex.result.EventCategoryListResultDTO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -67,4 +69,74 @@ public interface PingYinEventDao { * @Date 2022/12/9 11:00 */ List selectWorkCategoryScoreList(EventCategoryFormDTO formDTO); + + /** + * 项目分类列表 + * + * @Param formDTO + * @Return {@link List< EventCategoryListResultDTO>} + * @Author zhaoqifeng + * @Date 2022/12/13 10:12 + */ + List getProjectCategoryList(EventCategoryListFormDTO formDTO); + + /** + * 例行工作 + * + * @Param formDTO + * @Return {@link List< EventCategoryListResultDTO>} + * @Author zhaoqifeng + * @Date 2022/12/13 10:12 + */ + List getWorkCategoryList(EventCategoryListFormDTO formDTO); + + /** + * 上报事件总分 + * + * @Param formDTO + * @Return {@link Long} + * @Author zhaoqifeng + * @Date 2022/12/14 13:56 + */ + Long getProjectTotalScore(EventCategoryFormDTO formDTO); + + /** + * 例行工作总分 + * + * @Param formDTO + * @Return {@link Long} + * @Author zhaoqifeng + * @Date 2022/12/14 13:56 + */ + Long getWorkTotalScore(EventCategoryFormDTO formDTO); + + /** + * 网格员数 + * + * @Param formDTO + * @Return {@link Long} + * @Author zhaoqifeng + * @Date 2022/12/14 13:56 + */ + Long getMemberCount(EventCategoryFormDTO formDTO); + + /** + * 获取项目分类 + * + * @Param customerId + * @Return {@link List< EventCategoryResultDTO>} + * @Author zhaoqifeng + * @Date 2022/12/9 13:40 + */ + List selectProjectCategoryForExport(@Param("customerId")String customerId); + + /** + * 获取例行工作分类 + * + * @Param + * @Return {@link List< EventCategoryResultDTO>} + * @Author zhaoqifeng + * @Date 2022/12/9 13:41 + */ + List selectWorkCategoryForExport(); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/PingYinEventService.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/PingYinEventService.java index 9e93890ad2..1e4bb50c07 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/PingYinEventService.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/PingYinEventService.java @@ -1,8 +1,12 @@ package com.epmet.dataaggre.service.evaluationindex; +import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.dataaggre.dto.evaluationindex.EventCategoryResultDTO; import com.epmet.dataaggre.dto.evaluationindex.form.EventCategoryFormDTO; +import com.epmet.dataaggre.dto.evaluationindex.form.EventCategoryListFormDTO; +import com.epmet.dataaggre.dto.evaluationindex.result.EventCategoryListResultDTO; +import com.epmet.dataaggre.dto.evaluationindex.result.EventScoreTotalResultDTO; import java.util.List; @@ -21,4 +25,35 @@ public interface PingYinEventService { * @Date 2022/12/9 9:55 */ List getEventCategorySore (TokenDto tokenDto, EventCategoryFormDTO formDTO); + + /** + * 事件分类列表 + * + * @Param formDTO + * @Return {@link PageData< EventCategoryListResultDTO>} + * @Author zhaoqifeng + * @Date 2022/12/13 9:55 + */ + PageData getEventCategoryList(EventCategoryListFormDTO formDTO); + + /** + * 事件赋值得分总计 + * + * @Param formDTO + * @Return {@link EventScoreTotalResultDTO} + * @Author zhaoqifeng + * @Date 2022/12/14 13:46 + */ + EventScoreTotalResultDTO getEventScoreTotal(EventCategoryFormDTO formDTO); + + /** + * 事件赋值得分导出 + * + * @Param tokenDto + * @Param formDTO + * @Return {@link List} + * @Author zhaoqifeng + * @Date 2022/12/9 9:55 + */ + List getEventCategorySoreExport (TokenDto tokenDto, EventCategoryFormDTO formDTO); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/PingYinEventServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/PingYinEventServiceImpl.java index d2b3180459..2ac0e78511 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/PingYinEventServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/evaluationindex/impl/PingYinEventServiceImpl.java @@ -4,20 +4,30 @@ 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.exception.EpmetException; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; +import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; -import com.epmet.commons.tools.utils.DateUtils; import com.epmet.dataaggre.constant.DataSourceConstant; +import com.epmet.dataaggre.constant.EventConstant; import com.epmet.dataaggre.dao.evaluationindex.PingYinEventDao; import com.epmet.dataaggre.dto.evaluationindex.EventCategoryResultDTO; import com.epmet.dataaggre.dto.evaluationindex.form.EventCategoryFormDTO; +import com.epmet.dataaggre.dto.evaluationindex.form.EventCategoryListFormDTO; +import com.epmet.dataaggre.dto.evaluationindex.result.EventCategoryListResultDTO; +import com.epmet.dataaggre.dto.evaluationindex.result.EventScoreTotalResultDTO; import com.epmet.dataaggre.service.evaluationindex.PingYinEventService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.ArrayList; import java.util.List; @@ -47,9 +57,6 @@ public class PingYinEventServiceImpl implements PingYinEventService { @Override public List getEventCategorySore(TokenDto tokenDto, EventCategoryFormDTO formDTO) { List result = new ArrayList<>(); - if (StringUtils.isNotBlank(formDTO.getStartTime())){ - formDTO.setStartTime(DateUtils.getBeforeNDay(formDTO.getStartTime(), NumConstant.ONE)); - } if (StringUtils.isBlank(formDTO.getOrgId())){ CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); if (null == staffInfo){ @@ -95,4 +102,122 @@ public class PingYinEventServiceImpl implements PingYinEventService { result.addAll(workCategoryList); return result; } + + /** + * 事件分类列表 + * + * @param formDTO + * @Param formDTO + * @Return {@link PageData < EventCategoryListResultDTO >} + * @Author zhaoqifeng + * @Date 2022/12/13 9:55 + */ + @Override + public PageData getEventCategoryList(EventCategoryListFormDTO formDTO) { + PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()); + List list; + if (EventConstant.PROJECT.equals(formDTO.getEventType())) { + //项目分类列表 + list = pingYinEventDao.getProjectCategoryList(formDTO); + } else { + //例行工作分类列表 + list = pingYinEventDao.getWorkCategoryList(formDTO); + } + PageInfo pageInfo = new PageInfo<>(list); + if(CollectionUtils.isNotEmpty(list)) { + list.forEach(item -> { + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(item.getGridId()); + if (null == gridInfo) { + log.error("获取网格信息失败"); + return; + } + item.setGridName(gridInfo.getGridNamePath()); + if (EventConstant.PROJECT.equals(item.getEventType())) { + item.setStatusDesc("pending".equals(item.getStatus())?"处理中":"已结案"); + } + }); + } + return new PageData<>(list, pageInfo.getTotal()); + } + + /** + * 事件赋值得分总计 + * + * @param formDTO + * @Param formDTO + * @Return {@link EventScoreTotalResultDTO} + * @Author zhaoqifeng + * @Date 2022/12/14 13:46 + */ + @Override + public EventScoreTotalResultDTO getEventScoreTotal(EventCategoryFormDTO formDTO) { + formDTO.setCustomerId("6f203e30de1a65aab7e69c058826cd80"); + EventScoreTotalResultDTO result = new EventScoreTotalResultDTO(); + Long projectScore = pingYinEventDao.getProjectTotalScore(formDTO); + Long workScore = pingYinEventDao.getWorkTotalScore(formDTO); + Long memberCount = pingYinEventDao.getMemberCount(formDTO); + Long totalScore = projectScore + workScore; + result.setTotalScore(totalScore.toString()); + result.setMemberCount(memberCount.toString()); + result.setAveScore("0.00"); + if (memberCount != 0L) { + BigDecimal total = new BigDecimal(totalScore); + BigDecimal count = new BigDecimal(memberCount); + BigDecimal ave = total.divide(count, NumConstant.TWO, RoundingMode.HALF_UP); + result.setAveScore(ave.toString()); + } + return result; + } + + /** + * 事件赋值得分导出 + * + * @param tokenDto + * @param formDTO + * @Param tokenDto + * @Param formDTO + * @Return {@link List} + * @Author zhaoqifeng + * @Date 2022/12/9 9:55 + */ + @Override + public List getEventCategorySoreExport(TokenDto tokenDto, EventCategoryFormDTO formDTO) { + if (StringUtils.isBlank(formDTO.getOrgId())){ + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); + if (null == staffInfo){ + throw new EpmetException("未查询到此工作人员的所属组织信息..."); + } + formDTO.setOrgId(staffInfo.getAgencyId()); + formDTO.setOrgType("agency"); + } + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setCustomerId("6f203e30de1a65aab7e69c058826cd80"); + //获取项目分类 + List projectCategoryList = pingYinEventDao.selectProjectCategoryForExport(formDTO.getCustomerId()); + //获取项目赋值得分统计 + List projectScoreList = pingYinEventDao.selectProjectCategoryScoreList(formDTO); + if (CollectionUtils.isNotEmpty(projectScoreList)) { + projectCategoryList.forEach(item -> { + projectScoreList.stream().filter(e -> item.getCategoryCode().equals(e.getCategoryCode())).forEach(e -> { + item.setEventTotal(e.getEventTotal()); + item.setTotalScore(e.getTotalScore()); + }); + }); + } + List result = new ArrayList<>(projectCategoryList); + //获取例行工作分类 + List workCategoryList = pingYinEventDao.selectWorkCategoryForExport(); + //获取例行工作赋值得分统计 + List workScoreList = pingYinEventDao.selectWorkCategoryScoreList(formDTO); + if (CollectionUtils.isNotEmpty(workScoreList)) { + workCategoryList.forEach(item -> { + workScoreList.stream().filter(e -> item.getCategoryCode().equals(e.getCategoryCode())).forEach(e -> { + item.setEventTotal(e.getEventTotal()); + item.setTotalScore(e.getTotalScore()); + }); + }); + } + result.addAll(workCategoryList); + return result; + } } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/excel/eventScore.xlsx b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/excel/eventScore.xlsx new file mode 100644 index 0000000000..4966fd5e32 Binary files /dev/null and b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/excel/eventScore.xlsx differ diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/PingYinEventDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/PingYinEventDao.xml index db627975ae..54c52e5095 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/PingYinEventDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/evaluationindex/PingYinEventDao.xml @@ -76,8 +76,6 @@ SUM( c.SCORE ) AS totalScore FROM screen_py_event_data a - INNER JOIN screen_project_data b ON a.EVENT_ID = b.PROJECT_ID - AND b.DEL_FLAG = '0' INNER JOIN customer_project_category_dict c ON a.CATEGORY_CODE = c.CATEGORY_CODE AND c.DEL_FLAG = '0' AND c.CUSTOMER_ID = #{customerId} @@ -86,17 +84,24 @@ a.DEL_FLAG = '0' AND a.EVENT_TYPE = 'project' - AND DATE_FORMAT( a.EVENT_CREATE_TIME, '%Y-%m-%d' ) >= #{startTime} + AND DATE_FORMAT( a.EVENT_CREATE_TIME, '%Y%m%d' ) >= #{startTime} - AND DATE_FORMAT( a.EVENT_CREATE_TIME, '%Y-%m-%d' ) <= #{endTime} + AND DATE_FORMAT( a.EVENT_CREATE_TIME, '%Y%m%d' ) <= #{endTime} - AND b.ORG_ID = #{orgId} + AND a.ORG_ID = #{orgId} - AND b.ALL_PARENT_IDS LIKE CONCAT('%', #{orgId}, '%') + AND a.PIDS LIKE CONCAT('%', #{orgId}, '%') + + + AND a.STAFF_NAME LIKE CONCAT('%', #{name}, '%') + + AND a.MOBILE LIKE CONCAT('%', #{mobile}, '%') + + GROUP BY a.CATEGORY_CODE ) a WHERE CATEGORY_CODE IS NOT NULL @@ -113,27 +118,234 @@ SUM( c.SCORE ) AS totalScore FROM screen_py_event_data a - INNER JOIN epmet_user.patrol_routine_work b ON a.EVENT_ID = b.ID - AND b.DEL_FLAG = '0' INNER JOIN customer_patrol_work_type_dict c ON a.CATEGORY_CODE = c.CATEGORY_CODE AND c.IS_DISABLE = 'enable' WHERE a.DEL_FLAG = '0' AND a.EVENT_TYPE = 'work' - AND DATE_FORMAT( a.EVENT_CREATE_TIME, '%Y-%m-%d' ) >= #{startTime} + AND DATE_FORMAT( a.EVENT_CREATE_TIME, '%Y%m%d' ) >= #{startTime} - AND DATE_FORMAT( a.EVENT_CREATE_TIME, '%Y-%m-%d' ) <= #{endTime} + AND DATE_FORMAT( a.EVENT_CREATE_TIME, '%Y%m%d' ) <= #{endTime} - AND b.GRID_ID = #{orgId} + AND a.ORG_ID = #{orgId} - AND b.PIDS LIKE CONCAT('%', #{orgId}, '%') + AND a.PIDS LIKE CONCAT('%', #{orgId}, '%') + + + AND a.STAFF_NAME LIKE CONCAT('%', #{name}, '%') + + + AND a.MOBILE LIKE CONCAT('%', #{mobile}, '%') + GROUP BY a.CATEGORY_CODE ) a WHERE CATEGORY_CODE IS NOT NULL + + + + + + + + + diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/GridstaffWorkInfoPingyinDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/GridstaffWorkInfoPingyinDTO.java index 161a63e263..b277c2bee9 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/GridstaffWorkInfoPingyinDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/GridstaffWorkInfoPingyinDTO.java @@ -84,4 +84,10 @@ public class GridstaffWorkInfoPingyinDTO { private String happenTimeString; + private String title; + private String staffName; + private String mobile; + private String orgId; + private String pids; + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenPyEventDataEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenPyEventDataEntity.java index 8039234f00..2b31ed2fed 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenPyEventDataEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenPyEventDataEntity.java @@ -25,16 +25,16 @@ public class ScreenPyEventDataEntity extends BaseEpmetEntity { // * 客户Id // */ //private String customerId; - // - ///** - // * 上级组织Id - // */ - //private String parentId; - // - ///** - // * 所有上级ID,用英文逗号分开 - // */ - //private String allParentIds; + + /** + * 上级组织Id + */ + private String orgId; + + /** + * 所有上级ID,用英文逗号分开 + */ + private String pids; /** * 事件Id @@ -56,6 +56,12 @@ public class ScreenPyEventDataEntity extends BaseEpmetEntity { */ private String categoryCode; + private String title; + + private String staffName; + + private String mobile; + ///** // * 父类事件分类编码 // */ diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenPyEventDataServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenPyEventDataServiceImpl.java index 01e9dbda03..b916f891a7 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenPyEventDataServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenPyEventDataServiceImpl.java @@ -4,14 +4,18 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.constant.DataSourceConstant; +import com.epmet.dao.evaluationindex.screen.ScreenProjectDataDao; import com.epmet.dao.evaluationindex.screen.ScreenPyEventDataDao; import com.epmet.dto.screen.form.SavePyEventDataFormDTO; +import com.epmet.entity.evaluationindex.screen.ScreenProjectDataEntity; import com.epmet.entity.evaluationindex.screen.ScreenPyEventDataEntity; import com.epmet.service.evaluationindex.screen.ScreenPyEventDataService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; +import javax.annotation.Resource; + /** * 上报到市平台中间库的事件 * @@ -23,6 +27,8 @@ import org.springframework.stereotype.Service; @DataSource(DataSourceConstant.EVALUATION_INDEX) public class ScreenPyEventDataServiceImpl extends BaseServiceImpl implements ScreenPyEventDataService { + @Resource + private ScreenProjectDataDao screenProjectDataDao; /** * 保存同步到中间库的数据 * @@ -41,6 +47,14 @@ public class ScreenPyEventDataServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); wrapper.eq(ScreenPyEventDataEntity::getEventId, entity.getEventId()); wrapper.eq(ScreenPyEventDataEntity::getEventType, entity.getEventType()); @@ -60,6 +74,11 @@ public class ScreenPyEventDataServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); wrapper.eq(ScreenPyEventDataEntity::getEventId, entity.getEventId()); wrapper.eq(ScreenPyEventDataEntity::getEventType, entity.getEventType()); diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/GridstaffWorkInfoPingyinServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/GridstaffWorkInfoPingyinServiceImpl.java index 3577f3311d..5c554f218d 100755 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/GridstaffWorkInfoPingyinServiceImpl.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/GridstaffWorkInfoPingyinServiceImpl.java @@ -114,6 +114,8 @@ public class GridstaffWorkInfoPingyinServiceImpl extends BaseServiceImpl data; @@ -144,6 +146,11 @@ public class GridstaffWorkInfoPingyinServiceImpl extends BaseServiceImpl SELECT m.*, + cs.REAL_NAME AS staffName, + cs.MOBILE, prwt.WORK_TYPE_CODE AS workTypeSecondCode, substring_index(prwt.ALL_P_CODE,':',1) AS workTypeFirstCode FROM epmet_user.patrol_routine_work m + INNER JOIN customer_staff cs ON m.USER_ID = cs.USER_ID LEFT JOIN patrol_routine_work_type prwt ON m.ID = prwt.ROUTINE_WORK_ID WHERE m.CUSTOMER_ID = #{customerId} AND m.ID = #{id} + + AND DATE_FORMAT( HAPPEN_TIME, '%Y-%m-%d' ) >= #{startTime} + + + AND DATE_FORMAT( HAPPEN_TIME, '%Y-%m-%d' ) <= #{endTime} + AND m.DEL_FLAG = '0'