From 8b39ab9aee19cfb3bd1d3b08cbb2cbc96f2a100f Mon Sep 17 00:00:00 2001 From: tyty Date: Thu, 6 Jul 2023 14:18:43 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B6=88=E7=BC=BA?= =?UTF-8?q?=E6=B5=81=E7=A8=8Bbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../defect/service/impl/OperDefectStatisticsServiceImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectStatisticsServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectStatisticsServiceImpl.java index eae8585..aeaf591 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectStatisticsServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectStatisticsServiceImpl.java @@ -60,16 +60,16 @@ public class OperDefectStatisticsServiceImpl extends BaseServiceImpl Date: Thu, 6 Jul 2023 15:32:04 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=B8=A4=E7=A5=A8=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=9C=88=E6=8A=A5=E5=88=97=E8=A1=A8=E4=B8=8E=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TicketCountController.java | 30 ++- .../hzims/ticket/twoTicket/entity/TicketCount.java | 42 +--- .../handler/TicketCountSheetWriteHandler.java | 153 +++++++++++++ .../twoTicket/service/TicketCountService.java | 20 +- .../service/impl/TicketCountServiceImpl.java | 246 +++++++++++++++++---- .../twoTicket/vo/ticket/TicketCountResponseVo.java | 157 +++++++++++++ .../ticket/twoTicket/vo/ticket/TicketCountVo.java | 16 ++ .../ticket/src/main/resources/db/2.0.0.sql | 7 +- 8 files changed, 581 insertions(+), 90 deletions(-) create mode 100644 hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/handler/TicketCountSheetWriteHandler.java create mode 100644 hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/ticket/TicketCountResponseVo.java create mode 100644 hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/ticket/TicketCountVo.java diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketCountController.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketCountController.java index 913e112..a52367b 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketCountController.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketCountController.java @@ -1,14 +1,15 @@ package com.hnac.hzims.ticket.twoTicket.controller; +import cn.hutool.http.server.HttpServerResponse; import com.hnac.hzims.ticket.twoTicket.service.TicketCountService; +import com.hnac.hzims.ticket.twoTicket.vo.ticket.TicketCountResponseVo; +import com.hnac.hzims.ticket.twoTicket.vo.ticket.TicketCountVo; import lombok.RequiredArgsConstructor; import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; -import java.time.YearMonth; +import javax.servlet.http.HttpServletResponse; +import java.util.List; /** * 两票统计分析模块 @@ -27,7 +28,8 @@ public class TicketCountController { /** - * 两票生成月报统计 + * 两票生成月报统计 + * * @param dateTime 月份 * @return */ @@ -38,8 +40,24 @@ public class TicketCountController { } + /** + * 两票统计分析列表 + */ + @GetMapping("/list") + public R list(TicketCountVo ticketCountVo) { + List result = ticketCountService.selectTicketCountLlist(ticketCountVo); + return R.data(result); + } + /** + * 两票统计分析导出 + */ + @GetMapping("/export") + public R export(HttpServletResponse response) { + ticketCountService.exportTicketCount(response); + return R.success("导出成功"); + } } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/entity/TicketCount.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/entity/TicketCount.java index 1e5cbd0..ca2f54c 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/entity/TicketCount.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/entity/TicketCount.java @@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; +import org.springblade.core.mp.base.BaseEntity; +import org.springblade.core.tenant.mp.TenantEntity; import java.io.Serializable; import java.time.LocalDateTime; @@ -21,13 +23,7 @@ import java.time.YearMonth; @Accessors(chain = true) @EqualsAndHashCode @TableName("hzims_ticket_count") -public class TicketCount implements Serializable { - - - /** - * 编号 - */ - private Long id; +public class TicketCount extends TenantEntity implements Serializable { /** @@ -77,36 +73,4 @@ public class TicketCount implements Serializable { */ private Integer ticketProportionNum; - - /** - * 创建时间 - */ - private LocalDateTime createTime; - - /** - * 更新时间 - */ - private LocalDateTime updateTime; - - - /** - * 逻辑删除 - */ - @TableField(value = "is_deleted") - @TableLogic(value = "0", delval = "1") - private Boolean deleted; - - - /** - * 创建部门 - */ - private String createDept; - - - /** - * 租户Id - */ - private String tenantId; - - } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/handler/TicketCountSheetWriteHandler.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/handler/TicketCountSheetWriteHandler.java new file mode 100644 index 0000000..5490e80 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/handler/TicketCountSheetWriteHandler.java @@ -0,0 +1,153 @@ +package com.hnac.hzims.ticket.twoTicket.handler; + +import com.alibaba.excel.write.handler.SheetWriteHandler; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; +import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFFont; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.aspectj.bridge.MessageWriter; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/7/6 11:08 + */ +public class TicketCountSheetWriteHandler implements SheetWriteHandler { + + /** + * Called before create the sheet + * + * @param writeWorkbookHolder + * @param writeSheetHolder + */ + @Override + public void beforeSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) { + + } + + /** + * Called after the sheet is created + * + * @param writeWorkbookHolder + * @param writeSheetHolder + */ + @Override + public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) { + Workbook workbook = writeWorkbookHolder.getWorkbook(); + CellStyle headerStyle = createHeadCellStyle(workbook); + Sheet sheet = workbook.getSheetAt(0); + sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0)); + sheet.addMergedRegion(new CellRangeAddress(0, 0, 1, 4)); + sheet.addMergedRegion(new CellRangeAddress(0, 0, 5, 8)); + sheet.addMergedRegion(new CellRangeAddress(0, 0, 9, 12)); + sheet.addMergedRegion(new CellRangeAddress(0, 0, 13, 15)); + sheet.setHorizontallyCenter(true); + sheet.setVerticallyCenter(true); + sheet.setDefaultRowHeight((short) 20); + //设置填表日期,填报人,联系方式 + Row row1 = sheet.createRow(0); + row1.setHeightInPoints((short) 35); + Cell row1Cell = row1.createCell(0); + row1Cell.setCellValue("站点"); + row1Cell.setCellStyle(headerStyle); + + // row1.setHeight((short) 500); + Cell cell = row1.createCell(1); + cell.setCellValue("第一种工作票"); + cell.setCellStyle(headerStyle); + + + Cell cell1 = row1.createCell(5); + cell1.setCellValue("第二种工作票"); + cell1.setCellStyle(headerStyle); + + + Cell cell2 = row1.createCell(9); + cell2.setCellValue("机械工作票"); + cell2.setCellStyle(headerStyle); + + Cell cell3 = row1.createCell(13); + cell3.setCellValue("倒闸操作票"); + cell3.setCellStyle(headerStyle); + } + + + /** + * 创建表头样式 + * @param wb + * @return + */ + private static CellStyle createHeadCellStyle(Workbook wb) { + CellStyle cellStyle = wb.createCellStyle(); + cellStyle.setWrapText(true);// 设置自动换行 + cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景颜色 + cellStyle.setAlignment(HorizontalAlignment.CENTER); //水平居中 + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); //垂直对齐 + cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + cellStyle.setBottomBorderColor(IndexedColors.BLACK.index); + cellStyle.setBorderBottom(BorderStyle.THIN); //下边框 + cellStyle.setBorderLeft(BorderStyle.THIN); //左边框 + cellStyle.setBorderRight(BorderStyle.THIN); //右边框 + cellStyle.setBorderTop(BorderStyle.THIN); //上边框 + + Font headerFont = wb.createFont(); // 创建字体样式 + headerFont.setBold(true); //字体加粗 + headerFont.setFontName("黑体"); // 设置字体类型 + headerFont.setFontHeightInPoints((short) 12); // 设置字体大小 + cellStyle.setFont(headerFont); // 为标题样式设置字体样式 + + return cellStyle; + } + + + + /** + * 创建内容样式 + * @param wb + * @return + */ + private static CellStyle createContentCellStyle(Workbook wb) { + CellStyle cellStyle = wb.createCellStyle(); + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 垂直居中 + cellStyle.setAlignment(HorizontalAlignment.CENTER);// 水平居中 + cellStyle.setWrapText(true);// 设置自动换行 + cellStyle.setBorderBottom(BorderStyle.THIN); //下边框 + cellStyle.setBorderLeft(BorderStyle.THIN); //左边框 + cellStyle.setBorderRight(BorderStyle.THIN); //右边框 + cellStyle.setBorderTop(BorderStyle.THIN); //上边框 + + // 生成12号字体 + Font font = wb.createFont(); + font.setColor((short)8); + font.setFontHeightInPoints((short) 12); + cellStyle.setFont(font); + return cellStyle; + } + + + /** + * 创建标题样式 + * @param wb + * @return + */ + private static CellStyle createTitleCellStyle(Workbook wb) { + CellStyle cellStyle = wb.createCellStyle(); + cellStyle.setAlignment(HorizontalAlignment.CENTER);//水平居中 + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直对齐 + cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + cellStyle.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.getIndex());//背景颜色 + + Font headerFont1 = wb.createFont(); // 创建字体样式 + headerFont1.setBold(true); //字体加粗 + headerFont1.setFontName("黑体"); // 设置字体类型 + headerFont1.setFontHeightInPoints((short) 15); // 设置字体大小 + cellStyle.setFont(headerFont1); // 为标题样式设置字体样式 + + return cellStyle; + } +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketCountService.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketCountService.java index baafdb9..5838b40 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketCountService.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketCountService.java @@ -1,9 +1,14 @@ package com.hnac.hzims.ticket.twoTicket.service; +import cn.hutool.http.server.HttpServerResponse; import com.baomidou.mybatisplus.extension.service.IService; import com.hnac.hzims.ticket.twoTicket.entity.TicketCount; import com.hnac.hzims.ticket.twoTicket.entity.TicketInfoDanger; +import com.hnac.hzims.ticket.twoTicket.vo.ticket.TicketCountResponseVo; +import com.hnac.hzims.ticket.twoTicket.vo.ticket.TicketCountVo; +import org.springblade.core.mp.base.BaseService; +import javax.servlet.http.HttpServletResponse; import java.time.YearMonth; import java.util.List; @@ -13,11 +18,24 @@ import java.util.List; * @Serial 1.0 * @Date 2023/7/3 13:37 */ -public interface TicketCountService extends IService { +public interface TicketCountService extends BaseService { /** * 两票生成月报统计 */ void loadMonthReport(String dateTime); + + /** + * 两票统计分析列表 + * @param ticketCountVo + * @return + */ + List selectTicketCountLlist(TicketCountVo ticketCountVo); + + /** + * 两票统计分析导出 + * @param response + */ + void exportTicketCount(HttpServletResponse response); } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketCountServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketCountServiceImpl.java index 9101b20..66ac476 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketCountServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketCountServiceImpl.java @@ -1,21 +1,38 @@ package com.hnac.hzims.ticket.twoTicket.service.impl; +import cn.hutool.http.server.HttpServerResponse; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.support.ExcelTypeEnum; +import com.alibaba.excel.write.metadata.style.WriteCellStyle; +import com.alibaba.excel.write.metadata.style.WriteFont; +import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.ticket.allTicket.entity.TicketInfoEvaluateEntity; import com.hnac.hzims.ticket.allTicket.service.TicketInfoEvaluateService; import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketInfoEntity; import com.hnac.hzims.ticket.standardTicket.service.IStandardTicketInfoService; import com.hnac.hzims.ticket.twoTicket.entity.TicketCount; +import com.hnac.hzims.ticket.twoTicket.handler.TicketCountSheetWriteHandler; import com.hnac.hzims.ticket.twoTicket.mapper.TicketCountMapper; import com.hnac.hzims.ticket.twoTicket.service.TicketCountService; +import com.hnac.hzims.ticket.twoTicket.vo.ticket.TicketCountResponseVo; +import com.hnac.hzims.ticket.twoTicket.vo.ticket.TicketCountVo; import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; import com.hnac.hzims.ticket.workTicket.service.IWorkTicketInfoService; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.apache.poi.ss.usermodel.BorderStyle; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.VerticalAlignment; import org.springblade.core.mp.base.BaseEntity; +import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.secure.BladeUser; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; @@ -23,10 +40,12 @@ import org.springblade.system.feign.ISysClient; import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import javax.servlet.http.HttpServletResponse; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.net.URLEncoder; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ThreadPoolExecutor; import java.util.stream.Collectors; @@ -40,7 +59,7 @@ import java.util.stream.Collectors; @Slf4j @Service @RequiredArgsConstructor -public class TicketCountServiceImpl extends ServiceImpl implements TicketCountService { +public class TicketCountServiceImpl extends BaseServiceImpl implements TicketCountService { private final ThreadPoolExecutor executor; @@ -82,7 +101,7 @@ public class TicketCountServiceImpl extends ServiceImpl oneTicketCompletableFuture = ticketCountsCompletableFuture.thenAcceptAsync((items) -> { //查询第一种工作票 - List ticketCountList = getTicketCountList(createDept, items, "6", dateTime,user); + List ticketCountList = getTicketCountList(createDept, items, "6", dateTime, user); if (CollectionUtils.isNotEmpty(ticketCountList)) { this.saveBatch(ticketCountList); } @@ -90,7 +109,7 @@ public class TicketCountServiceImpl extends ServiceImpl twoTicketCompletableFuture = ticketCountsCompletableFuture.thenAcceptAsync((items) -> { //查询第一种工作票 - List ticketCountList = getTicketCountList(createDept, items, "7", dateTime,user); + List ticketCountList = getTicketCountList(createDept, items, "7", dateTime, user); if (CollectionUtils.isNotEmpty(ticketCountList)) { this.saveBatch(ticketCountList); } @@ -98,7 +117,7 @@ public class TicketCountServiceImpl extends ServiceImpl threeTicketCompletableFuture = ticketCountsCompletableFuture.thenAcceptAsync((items) -> { //查询第一种工作票 - List ticketCountList = getTicketCountList(createDept, items, "8", dateTime,user); + List ticketCountList = getTicketCountList(createDept, items, "8", dateTime, user); if (CollectionUtils.isNotEmpty(ticketCountList)) { this.saveBatch(ticketCountList); } @@ -106,22 +125,171 @@ public class TicketCountServiceImpl extends ServiceImpl standardCompletableFuture = ticketCountsCompletableFuture.thenAcceptAsync((items) -> { //操作票 - List ticketCountList = getStandardTicketCountList(createDept, items, "3", dateTime,user); + List ticketCountList = getStandardTicketCountList(createDept, items, "3", dateTime, user); if (CollectionUtils.isNotEmpty(ticketCountList)) { this.saveBatch(ticketCountList); } }, executor); //执行线程操作 - CompletableFuture.allOf(ticketCountsCompletableFuture, - oneTicketCompletableFuture, - twoTicketCompletableFuture, - threeTicketCompletableFuture, - standardCompletableFuture) - .get(); + CompletableFuture.allOf(ticketCountsCompletableFuture, oneTicketCompletableFuture, twoTicketCompletableFuture, threeTicketCompletableFuture, standardCompletableFuture).get(); } /** + * 两票统计分析列表 + * + * @param ticketCountVo + * @return + */ + @Override + public List selectTicketCountLlist(TicketCountVo ticketCountVo) { + //获取keyword + String keyword = ticketCountVo.getKeyword(); + QueryWrapper ticketCountQueryWrapper = new QueryWrapper<>(); + ticketCountQueryWrapper.like(StringUtils.isNotBlank(keyword), "dept_name", keyword); + List ticketCounts = baseMapper.selectList(ticketCountQueryWrapper); + List result = getTicketCountResponseList(ticketCounts); + return result; + } + + /** + * 两票统计分析导出 + * + * @param response + */ + @Override + public void exportTicketCount(HttpServletResponse response) { + String fileName = URLEncoder.encode("两票月报分析统计报表.xlsx"); + response.setHeader("Content-Disposition", "attachment; filename=" + fileName); + response.setContentType("application/vnd.ms-excel;charset=utf-8"); + response.setCharacterEncoding("utf-8"); + List ticketCounts = baseMapper.selectList(null); + List countResponseList = getTicketCountResponseList(ticketCounts); + //导出 + //内容样式策略 + WriteCellStyle contentWriteCellStyle = new WriteCellStyle(); + // //垂直居中,水平居中 + contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); + contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER); + contentWriteCellStyle.setBorderLeft(BorderStyle.THIN); + contentWriteCellStyle.setBorderTop(BorderStyle.THIN); + contentWriteCellStyle.setBorderRight(BorderStyle.THIN); + contentWriteCellStyle.setBorderBottom(BorderStyle.THIN); + // //设置 自动换行 + contentWriteCellStyle.setWrapped(true); + // // 字体策略 + // WriteFont contentWriteFont = new WriteFont(); + // // 字体大小 + // contentWriteFont.setFontHeightInPoints((short) 12); + // contentWriteCellStyle.setWriteFont(contentWriteFont); + // //头策略使用默认 + WriteCellStyle headWriteCellStyle = new WriteCellStyle(); + + //excel如需下载到本地,只需要将response.getOutputStream()换成File即可(注释掉以上response代码) + try { + EasyExcel.write(response.getOutputStream(), TicketCountResponseVo.class) + //设置输出excel版本,不设置默认为xlsx + .excelType(ExcelTypeEnum.XLSX).head(TicketCountResponseVo.class) + //设置拦截器或自定义样式 + .registerWriteHandler(new TicketCountSheetWriteHandler()) + .registerWriteHandler(new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle)) + .sheet("两票月报分析统计报表") + //设置默认样式及写入头信息开始的行数 + .useDefaultStyle(true).relativeHeadRowIndex(1) + //这里的addsumColomn方法是个添加合计的方法,可删除 + .doWrite(countResponseList); + } catch (IOException e) { + e.printStackTrace(); + } + } + + + /** + * 列表封装 + * + * @param ticketCounts + * @return + */ + private List getTicketCountResponseList(List ticketCounts) { + //先判断在存储 + Map map = new HashMap<>(); + for (TicketCount ticketCount : ticketCounts) { + String deptName = ticketCount.getDeptName(); + if (map.containsKey(deptName)) { + TicketCountResponseVo ticketCountResponseVo = map.get(deptName); + isExistsTicket(ticketCount, ticketCountResponseVo); + map.put(deptName, ticketCountResponseVo); + } else { + TicketCountResponseVo ticketCountResponseVo = new TicketCountResponseVo(); + isExistsTicket(ticketCount, ticketCountResponseVo); + map.put(deptName, ticketCountResponseVo); + } + } + //map遍历 + List result = new ArrayList<>(); + if (MapUtils.isNotEmpty(map)) { + Set> entries = map.entrySet(); + for (Map.Entry entry : entries) { + TicketCountResponseVo value = entry.getValue(); + value.setDeptName(entry.getKey()); + result.add(value); + } + + } + return result; + } + + + /** + * 验证是否是是这几种牌局类型 + * + * @param ticketCount + * @param ticketCountResponseVo + */ + private void isExistsTicket(TicketCount ticketCount, TicketCountResponseVo ticketCountResponseVo) { + String deptName = ticketCount.getDeptName(); + ticketCountResponseVo.setDeptName(deptName); + if ("3".equals(ticketCount.getTicketType())) { + ticketCountResponseVo.setFourTicketNumber(this.getCount(ticketCount.getTicketNumber())); + ticketCountResponseVo.setFourTicketProportionNum(this.getCount(ticketCount.getTicketProportionNum())); + ticketCountResponseVo.setFourTicketCompleteNum(this.getCount(ticketCount.getTicketCompleteNum())); + ticketCountResponseVo.setFourTicketDelayNum(this.getCount(ticketCount.getTicketDelayNum())); + } + + if ("6".equals(ticketCount.getTicketType())) { + ticketCountResponseVo.setOneTicketNumber(this.getCount(ticketCount.getTicketNumber())); + ticketCountResponseVo.setOneTicketProportionNum(this.getCount(ticketCount.getTicketProportionNum())); + ticketCountResponseVo.setOneTicketCompleteNum(this.getCount(ticketCount.getTicketCompleteNum())); + ticketCountResponseVo.setOneTicketDelayNum(this.getCount(ticketCount.getTicketDelayNum())); + } + + + if ("7".equals(ticketCount.getTicketType())) { + ticketCountResponseVo.setTwoTicketNumber(this.getCount(ticketCount.getTicketNumber())); + ticketCountResponseVo.setTwoTicketProportionNum(this.getCount(ticketCount.getTicketProportionNum())); + ticketCountResponseVo.setTwoTicketCompleteNum(this.getCount(ticketCount.getTicketCompleteNum())); + ticketCountResponseVo.setTwoTicketDelayNum(this.getCount(ticketCount.getTicketDelayNum())); + } + + + if ("8".equals(ticketCount.getTicketType())) { + ticketCountResponseVo.setThreeTicketNumber(this.getCount(ticketCount.getTicketNumber())); + ticketCountResponseVo.setThreeTicketProportionNum(this.getCount(ticketCount.getTicketProportionNum())); + ticketCountResponseVo.setThreeTicketCompleteNum(this.getCount(ticketCount.getTicketCompleteNum())); + ticketCountResponseVo.setThreeTicketDelayNum(this.getCount(ticketCount.getTicketDelayNum())); + } + } + + + /** + * 验证是否为null + */ + private int getCount(Integer count) { + return count == null ? 0 : count; + } + + + /** * 统计操作票功能 * * @param createDept 所属机构及下属机构 @@ -132,17 +300,16 @@ public class TicketCountServiceImpl extends ServiceImpl getStandardTicketCountList(List createDept, List items, String ticketType, String dateTime, BladeUser user) { - List ticketInfoEntities = - standardTicketInfoService.selectStandardTicketByDeptIdWithTicketType(createDept, ticketType); + List ticketInfoEntities = standardTicketInfoService.selectStandardTicketByDeptIdWithTicketType(createDept, ticketType); if (CollectionUtils.isEmpty(ticketInfoEntities)) { return null; } //根据站点分组 - Map> createDeptTickets = - ticketInfoEntities.stream().collect(Collectors.groupingBy(StandardTicketInfoEntity::getCreateDept)); + Map> createDeptTickets = ticketInfoEntities.stream().collect(Collectors.groupingBy(StandardTicketInfoEntity::getCreateDept)); //获取 操作票的id,删除 if (CollectionUtils.isNotEmpty(items)) { - List collect = items.stream().filter(item -> ticketType.equals(item.getTicketType())).map(TicketCount::getId).collect(Collectors.toList()); + List collect = + items.stream().filter(item -> ticketType.equals(item.getTicketType()) && user.getUserId().equals(item.getCreateUser())).map(TicketCount::getId).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(collect)) { baseMapper.deleteBatchIds(collect); } @@ -154,7 +321,8 @@ public class TicketCountServiceImpl extends ServiceImpl deptName = systemClient.getDeptName(entry.getKey()); if (deptName.isSuccess()) { @@ -163,19 +331,16 @@ public class TicketCountServiceImpl extends ServiceImpl values = entry.getValue(); ticketCount.setTicketType(CollectionUtils.isNotEmpty(values) ? values.get(0).getTicketType() : ticketType); //1. 开票数量 - List ticketNumbers = - values.stream().filter(item -> item.getFlowTaskName() != null).collect(Collectors.toList()); + List ticketNumbers = values.stream().filter(item -> item.getFlowTaskName() != null).collect(Collectors.toList()); ticketCount.setTicketNumber(ticketNumbers.size()); //2. 完成数量 - List ticketCompleteNums = - values.stream().filter(item -> "结束".equals(item.getFlowTaskName())).collect(Collectors.toList()); + List ticketCompleteNums = values.stream().filter(item -> "结束".equals(item.getFlowTaskName())).collect(Collectors.toList()); ticketCount.setTicketCompleteNum(ticketCompleteNums.size()); //3. 延期数据量 ticketCount.setTicketDelayNum(0); //4. 合格数量 List ticketIdList = values.stream().map(item -> item.getId()).collect(Collectors.toList()); - LambdaQueryWrapper evaluateEntityLambdaQueryWrapper = - new LambdaQueryWrapper<>(); + LambdaQueryWrapper evaluateEntityLambdaQueryWrapper = new LambdaQueryWrapper<>(); evaluateEntityLambdaQueryWrapper.in(TicketInfoEvaluateEntity::getTicketId, ticketIdList); evaluateEntityLambdaQueryWrapper.eq(BaseEntity::getStatus, 1); List evaluateEntities = ticketInfoEvaluateService.list(evaluateEntityLambdaQueryWrapper); @@ -197,8 +362,7 @@ public class TicketCountServiceImpl extends ServiceImpl getTicketCountList(List createDept, List items, String ticketType, String dateTime, BladeUser user) { - List ticketInfoEntities = - workTicketInfoService.selectTicketByDeptIdWithTicketType(createDept, ticketType); + List ticketInfoEntities = workTicketInfoService.selectTicketByDeptIdWithTicketType(createDept, ticketType); if (CollectionUtils.isEmpty(ticketInfoEntities)) { return null; } @@ -206,10 +370,11 @@ public class TicketCountServiceImpl extends ServiceImpl> createDeptTickets = ticketInfoEntities.stream().collect(Collectors.groupingBy(BaseEntity::getCreateDept)); if (CollectionUtils.isNotEmpty(items)) { //获取工作票的id,删除 - List collect = items.stream().filter(item -> ticketType.equals(item.getTicketType())).map(TicketCount::getId).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(collect)) { - baseMapper.deleteBatchIds(collect); - } + List collect = + items.stream().filter(item -> (ticketType.equals(item.getTicketType()) && user.getUserId().equals(item.getCreateUser()))).map(TicketCount::getId).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(collect)) { + baseMapper.deleteBatchIds(collect); + } } Set>> entries = createDeptTickets.entrySet(); @@ -226,23 +391,20 @@ public class TicketCountServiceImpl extends ServiceImpl values = entry.getValue(); ticketCount.setTicketType(CollectionUtils.isNotEmpty(values) ? values.get(0).getType() : ticketType); //1. 开票数量 - List ticketNumbers = - values.stream().filter(item -> item.getFlowTaskName() != null).collect(Collectors.toList()); + List ticketNumbers = values.stream().filter(item -> item.getFlowTaskName() != null).collect(Collectors.toList()); ticketCount.setTicketNumber(ticketNumbers.size()); //2. 完成数量 - List ticketCompleteNums = - values.stream().filter(item -> "结束".equals(item.getFlowTaskName())).collect(Collectors.toList()); + List ticketCompleteNums = values.stream().filter(item -> "结束".equals(item.getFlowTaskName())).collect(Collectors.toList()); ticketCount.setTicketCompleteNum(ticketCompleteNums.size()); ticketCount.setTenantId(user.getTenantId()); - ticketCount.setCreateDept(user.getDeptId()); + ticketCount.setCreateDept(Long.valueOf(user.getDeptId())); + ticketCount.setCreateUser(user.getUserId()); //3. 延期数据量 - List ticketDelayNums = - values.stream().filter(item -> "延期".equals(item.getInput())).collect(Collectors.toList()); + List ticketDelayNums = values.stream().filter(item -> "延期".equals(item.getInput())).collect(Collectors.toList()); ticketCount.setTicketDelayNum(ticketDelayNums.size()); //4. 合格数量 List ticketIdList = values.stream().map(item -> item.getId()).collect(Collectors.toList()); - LambdaQueryWrapper evaluateEntityLambdaQueryWrapper = - new LambdaQueryWrapper<>(); + LambdaQueryWrapper evaluateEntityLambdaQueryWrapper = new LambdaQueryWrapper<>(); evaluateEntityLambdaQueryWrapper.in(TicketInfoEvaluateEntity::getTicketId, ticketIdList); evaluateEntityLambdaQueryWrapper.eq(BaseEntity::getStatus, 1); List evaluateEntities = ticketInfoEvaluateService.list(evaluateEntityLambdaQueryWrapper); diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/ticket/TicketCountResponseVo.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/ticket/TicketCountResponseVo.java new file mode 100644 index 0000000..c9c1b8e --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/ticket/TicketCountResponseVo.java @@ -0,0 +1,157 @@ +package com.hnac.hzims.ticket.twoTicket.vo.ticket; + +import com.alibaba.excel.annotation.ExcelIgnore; +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.alibaba.excel.annotation.write.style.ContentRowHeight; +import com.alibaba.excel.annotation.write.style.HeadRowHeight; +import lombok.Data; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/7/6 8:02 + */ +@Data +@ContentRowHeight(30) +@HeadRowHeight(30) +public class TicketCountResponseVo { + + + /** + * 站点名称 + */ + @ColumnWidth(20) + @ExcelProperty(value = "站点",index = 0) + private String deptName; + + + /** + * 第一种工作票开票数量 + */ + @ColumnWidth(14) + @ExcelProperty(value = "开票数量",index = 1) + private Integer oneTicketNumber = 0; + + + /** + * 第一种工作票完成数量 + */ + @ColumnWidth(14) + @ExcelProperty(value = "完成数量",index = 2) + private Integer oneTicketCompleteNum = 0; + + + /** + * 第一种工作票延期数量 + */ + @ColumnWidth(14) + @ExcelProperty(value = "延期数量",index = 3) + private Integer oneTicketDelayNum = 0; + + + /** + * 第一种工作票合格数量 + */ + @ColumnWidth(14) + @ExcelProperty(value = "合格数量",index = 4) + private Integer oneTicketProportionNum = 0; + + + /** + * 第二种工作票开票数量 + */ + @ColumnWidth(14) + @ExcelProperty(value = "开票数量",index = 5) + private Integer twoTicketNumber = 0; + + + /** + * 第二种工作票完成数量 + */ + @ColumnWidth(14) + @ExcelProperty(value = "完成数量",index = 6) + private Integer twoTicketCompleteNum = 0; + + + /** + * 第二种工作票延期数量 + */ + @ColumnWidth(14) + @ExcelProperty(value = "延期数量",index = 7) + private Integer twoTicketDelayNum = 0; + + + /** + * 第二种工作票合格数量 + */ + @ColumnWidth(14) + @ExcelProperty(value = "合格数量",index = 8) + private Integer twoTicketProportionNum = 0; + + + /** + * 水力机械工作票开票数量 + */ + @ColumnWidth(14) + @ExcelProperty(value = "开票数量",index = 9) + private Integer threeTicketNumber = 0; + + + /** + * 水力机械工作票完成数量 + */ + @ColumnWidth(14) + @ExcelProperty(value = "完成数量",index = 10) + private Integer threeTicketCompleteNum = 0; + + + /** + * 水力机械工作票延期数量 + */ + @ColumnWidth(14) + @ExcelProperty(value = "延期数量",index = 11) + private Integer threeTicketDelayNum = 0; + + + /** + * 水力机械工作票合格数量 + */ + @ColumnWidth(14) + @ExcelProperty(value = "合格数量",index = 12) + private Integer threeTicketProportionNum = 0; + + + /** + * 操作票开票数量 + */ + @ColumnWidth(14) + @ExcelProperty(value = "开票数量",index = 13) + private Integer fourTicketNumber = 0; + + + /** + * 操作票开票完成数量 + */ + @ColumnWidth(14) + @ExcelProperty(value = "完成数量",index = 14) + private Integer fourTicketCompleteNum = 0; + + + /** + * 操作票延期数量 + */ + @ExcelIgnore + private Integer fourTicketDelayNum = 0; + + + /** + * 操作票作票合格数量 + */ + @ColumnWidth(14) + @ExcelProperty(value = "合格数量",index = 15) + private Integer fourTicketProportionNum = 0; + + +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/ticket/TicketCountVo.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/ticket/TicketCountVo.java new file mode 100644 index 0000000..a04e031 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/ticket/TicketCountVo.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.ticket.twoTicket.vo.ticket; + +import lombok.Data; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/7/6 8:04 + */ +@Data +public class TicketCountVo { + + + private String keyword; +} diff --git a/hzims-service/ticket/src/main/resources/db/2.0.0.sql b/hzims-service/ticket/src/main/resources/db/2.0.0.sql index 9d3c495..cc3d285 100644 --- a/hzims-service/ticket/src/main/resources/db/2.0.0.sql +++ b/hzims-service/ticket/src/main/resources/db/2.0.0.sql @@ -13,9 +13,12 @@ create table hzims_ticket_count ticket_proportion_num int null comment '合格数量', create_time datetime default CURRENT_TIMESTAMP null comment '创建时间', update_time datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间', - is_deleted tinyint(1) default 0 null comment '0', + is_deleted tinyint(1) default 0 null comment '逻辑删除', tenant_id varchar(12) null comment '租户ID', - create_dept varchar(30) null comment '创建部门' + create_dept varchar(30) null comment '创建部门', + status tinyint null, + create_user bigint not null comment '创建人', + update_user bigint null ) comment '两票统计分析' row_format = DYNAMIC; From bfca190b867776b40afa53237c341c0522fd3f10 Mon Sep 17 00:00:00 2001 From: tyty Date: Thu, 6 Jul 2023 16:23:44 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B6=88=E7=BC=BA?= =?UTF-8?q?=E6=B5=81=E7=A8=8Bbug-=E6=B6=88=E7=BC=BA=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/operational/defect/service/impl/DefectCheckServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java index 4b57310..49dbdc9 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java @@ -326,6 +326,7 @@ public class DefectCheckServiceImpl extends BaseServiceImpl Date: Fri, 7 Jul 2023 09:57:36 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B6=88=E7=BC=BA?= =?UTF-8?q?=E6=B5=81=E7=A8=8Bbug-=E6=B6=88=E7=BC=BA=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/duty/service/impl/ImsDutyMainServiceImpl.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java index 9d2de73..3e66a8a 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java @@ -3,7 +3,6 @@ package com.hnac.hzims.operational.duty.service.impl; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.serializer.SerializerFeature; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.Query; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.hnac.hzims.monitor.utils.DateUtils; @@ -31,7 +30,6 @@ import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.format.annotation.DateTimeFormat; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ObjectUtils; @@ -39,7 +37,6 @@ import org.springframework.util.ObjectUtils; import javax.annotation.Resource; import java.sql.Time; import java.text.DateFormat; -import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.LocalDateTime; @@ -1226,7 +1223,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl> allUserList = userClient.userListByDeptId(deptId); + R> allUserList = userClient.userList("200000",deptId); return allUserList; } @@ -1394,7 +1391,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl deptDutyClassMap = deptDutyClassList.stream().collect(Collectors.toMap(ImsDutyClassEntity::getId, Function.identity())); // 获取部门的所有组员 - List allUserList = userClient.userListByDeptId(deptId).getData(); + List allUserList = userClient.userList("200000",deptId).getData(); Map deptUserMap = allUserList.stream().collect(Collectors.toMap(User::getId, User::getName)); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); @@ -1419,7 +1416,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl restUserList = userClient.userListByDeptId(deptId).getData(); + List restUserList = userClient.userList("200000",deptId).getData(); // 获取一天的排班 List dutyMainDayList = dutyMainList.stream().filter(var -> dateFormat.format(var.getDutyDate()).equals(dateStr)).collect(Collectors.toList());