12 changed files with 523 additions and 1 deletions
			
			
		@ -0,0 +1,45 @@ | 
				
			|||||||
 | 
					package com.hnac.hzims.ticket.twoTicket.controller; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.hnac.hzims.ticket.twoTicket.service.TicketCountService; | 
				
			||||||
 | 
					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 java.time.YearMonth; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * 两票统计分析模块 | 
				
			||||||
 | 
					 * | 
				
			||||||
 | 
					 * @Author WL | 
				
			||||||
 | 
					 * @Version v1.0 | 
				
			||||||
 | 
					 * @Serial 1.0 | 
				
			||||||
 | 
					 * @Date 2023/7/3 13:41 | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					@RestController | 
				
			||||||
 | 
					@RequiredArgsConstructor | 
				
			||||||
 | 
					@RequestMapping("/ticket-count") | 
				
			||||||
 | 
					public class TicketCountController { | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final TicketCountService ticketCountService; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     *  两票生成月报统计 | 
				
			||||||
 | 
					     * @param dateTime 月份 | 
				
			||||||
 | 
					     * @return | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    @PostMapping("/loadMonthReport/{dateTime}") | 
				
			||||||
 | 
					    public R loadMonthReport(@PathVariable String dateTime) { | 
				
			||||||
 | 
					        ticketCountService.loadMonthReport(dateTime); | 
				
			||||||
 | 
					        return R.success("生成两票月报成功"); | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,112 @@ | 
				
			|||||||
 | 
					package com.hnac.hzims.ticket.twoTicket.entity; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.baomidou.mybatisplus.annotation.TableField; | 
				
			||||||
 | 
					import com.baomidou.mybatisplus.annotation.TableLogic; | 
				
			||||||
 | 
					import com.baomidou.mybatisplus.annotation.TableName; | 
				
			||||||
 | 
					import lombok.Data; | 
				
			||||||
 | 
					import lombok.EqualsAndHashCode; | 
				
			||||||
 | 
					import lombok.experimental.Accessors; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.Serializable; | 
				
			||||||
 | 
					import java.time.LocalDateTime; | 
				
			||||||
 | 
					import java.time.YearMonth; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * @Author WL | 
				
			||||||
 | 
					 * @Version v1.0 | 
				
			||||||
 | 
					 * @Serial 1.0 | 
				
			||||||
 | 
					 * @Date 2023/7/3 11:45 | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					@Data | 
				
			||||||
 | 
					@Accessors(chain = true) | 
				
			||||||
 | 
					@EqualsAndHashCode | 
				
			||||||
 | 
					@TableName("hzims_ticket_count") | 
				
			||||||
 | 
					public class TicketCount implements Serializable { | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 编号 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private Long id; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 站点id | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private Long deptId; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 日期 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private String dateTime; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 站点名称 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private String deptName; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 票据类型 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private String ticketType; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 开票数量 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private Integer ticketNumber; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 完成数量 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private Integer ticketCompleteNum; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 延期数量 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private Integer ticketDelayNum; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 合格数量 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    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; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,14 @@ | 
				
			|||||||
 | 
					package com.hnac.hzims.ticket.twoTicket.mapper; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.hnac.hzims.ticket.twoTicket.entity.TicketCount; | 
				
			||||||
 | 
					import com.hnac.hzims.ticket.workTicket.entity.SecondTicketInfoEntity; | 
				
			||||||
 | 
					import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * @Author WL | 
				
			||||||
 | 
					 * @Version v1.0 | 
				
			||||||
 | 
					 * @Serial 1.0 | 
				
			||||||
 | 
					 * @Date 2023/7/3 13:36 | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					public interface TicketCountMapper extends UserDataScopeBaseMapper<TicketCount> { | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,5 @@ | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?> | 
				
			||||||
 | 
					<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 
				
			||||||
 | 
					<mapper namespace="com.hnac.hzims.ticket.twoTicket.mapper.TicketCountMapper"> | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</mapper> | 
				
			||||||
@ -0,0 +1,23 @@ | 
				
			|||||||
 | 
					package com.hnac.hzims.ticket.twoTicket.service; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.baomidou.mybatisplus.extension.service.IService; | 
				
			||||||
 | 
					import com.hnac.hzims.ticket.twoTicket.entity.TicketCount; | 
				
			||||||
 | 
					import com.hnac.hzims.ticket.twoTicket.entity.TicketInfoDanger; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.time.YearMonth; | 
				
			||||||
 | 
					import java.util.List; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * @Author WL | 
				
			||||||
 | 
					 * @Version v1.0 | 
				
			||||||
 | 
					 * @Serial 1.0 | 
				
			||||||
 | 
					 * @Date 2023/7/3 13:37 | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					public interface TicketCountService extends IService<TicketCount> { | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 两票生成月报统计 | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    void loadMonthReport(String dateTime); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,254 @@ | 
				
			|||||||
 | 
					package com.hnac.hzims.ticket.twoTicket.service.impl; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
				
			||||||
 | 
					import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
				
			||||||
 | 
					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.mapper.TicketCountMapper; | 
				
			||||||
 | 
					import com.hnac.hzims.ticket.twoTicket.service.TicketCountService; | 
				
			||||||
 | 
					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.springblade.core.mp.base.BaseEntity; | 
				
			||||||
 | 
					import org.springblade.core.secure.BladeUser; | 
				
			||||||
 | 
					import org.springblade.core.secure.utils.AuthUtil; | 
				
			||||||
 | 
					import org.springblade.core.tool.api.R; | 
				
			||||||
 | 
					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 java.util.concurrent.CompletableFuture; | 
				
			||||||
 | 
					import java.util.concurrent.ThreadPoolExecutor; | 
				
			||||||
 | 
					import java.util.stream.Collectors; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					 * @Author WL | 
				
			||||||
 | 
					 * @Version v1.0 | 
				
			||||||
 | 
					 * @Serial 1.0 | 
				
			||||||
 | 
					 * @Date 2023/7/3 13:38 | 
				
			||||||
 | 
					 */ | 
				
			||||||
 | 
					@Slf4j | 
				
			||||||
 | 
					@Service | 
				
			||||||
 | 
					@RequiredArgsConstructor | 
				
			||||||
 | 
					public class TicketCountServiceImpl extends ServiceImpl<TicketCountMapper, TicketCount> implements TicketCountService { | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final ThreadPoolExecutor executor; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final IWorkTicketInfoService workTicketInfoService; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final IUserClient userClient; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final ISysClient systemClient; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final TicketInfoEvaluateService ticketInfoEvaluateService; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final IStandardTicketInfoService standardTicketInfoService; | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 两票生成月报统计 | 
				
			||||||
 | 
					     * | 
				
			||||||
 | 
					     * @param dateTime | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    @SneakyThrows | 
				
			||||||
 | 
					    @Override | 
				
			||||||
 | 
					    public void loadMonthReport(String dateTime) { | 
				
			||||||
 | 
					        //根据登录人查询所属机构及下属机构
 | 
				
			||||||
 | 
					        BladeUser user = AuthUtil.getUser(); | 
				
			||||||
 | 
					        List<Long> createDept = userClient.getDataScope(user.getUserId()); | 
				
			||||||
 | 
					        System.out.println("createDept = " + createDept); | 
				
			||||||
 | 
					        //根据月份查询统计的数据
 | 
				
			||||||
 | 
					        CompletableFuture<List<TicketCount>> ticketCountsCompletableFuture = CompletableFuture.supplyAsync(() -> { | 
				
			||||||
 | 
					            LambdaQueryWrapper<TicketCount> queryWrapper = new LambdaQueryWrapper<>(); | 
				
			||||||
 | 
					            queryWrapper.eq(TicketCount::getDateTime, dateTime); | 
				
			||||||
 | 
					            List<TicketCount> ticketCounts = baseMapper.selectList(queryWrapper); | 
				
			||||||
 | 
					            return ticketCounts; | 
				
			||||||
 | 
					        }, executor); | 
				
			||||||
 | 
					        //第一种工作票
 | 
				
			||||||
 | 
					        CompletableFuture<Void> oneTicketCompletableFuture = ticketCountsCompletableFuture.thenAcceptAsync((items) -> { | 
				
			||||||
 | 
					            //查询第一种工作票
 | 
				
			||||||
 | 
					            List<TicketCount> ticketCountList = getTicketCountList(createDept, items, "6", dateTime,user); | 
				
			||||||
 | 
					            if (CollectionUtils.isNotEmpty(ticketCountList)) { | 
				
			||||||
 | 
					                this.saveBatch(ticketCountList); | 
				
			||||||
 | 
					            } | 
				
			||||||
 | 
					        }, executor); | 
				
			||||||
 | 
					        //第二种工作票
 | 
				
			||||||
 | 
					        CompletableFuture<Void> twoTicketCompletableFuture = ticketCountsCompletableFuture.thenAcceptAsync((items) -> { | 
				
			||||||
 | 
					            //查询第一种工作票
 | 
				
			||||||
 | 
					            List<TicketCount> ticketCountList = getTicketCountList(createDept, items, "7", dateTime,user); | 
				
			||||||
 | 
					            if (CollectionUtils.isNotEmpty(ticketCountList)) { | 
				
			||||||
 | 
					                this.saveBatch(ticketCountList); | 
				
			||||||
 | 
					            } | 
				
			||||||
 | 
					        }, executor); | 
				
			||||||
 | 
					        //水力机械工作票
 | 
				
			||||||
 | 
					        CompletableFuture<Void> threeTicketCompletableFuture = ticketCountsCompletableFuture.thenAcceptAsync((items) -> { | 
				
			||||||
 | 
					            //查询第一种工作票
 | 
				
			||||||
 | 
					            List<TicketCount> ticketCountList = getTicketCountList(createDept, items, "8", dateTime,user); | 
				
			||||||
 | 
					            if (CollectionUtils.isNotEmpty(ticketCountList)) { | 
				
			||||||
 | 
					                this.saveBatch(ticketCountList); | 
				
			||||||
 | 
					            } | 
				
			||||||
 | 
					        }, executor); | 
				
			||||||
 | 
					        //操作票
 | 
				
			||||||
 | 
					        CompletableFuture<Void> standardCompletableFuture = ticketCountsCompletableFuture.thenAcceptAsync((items) -> { | 
				
			||||||
 | 
					            //操作票
 | 
				
			||||||
 | 
					            List<TicketCount> ticketCountList = getStandardTicketCountList(createDept, items, "3", dateTime,user); | 
				
			||||||
 | 
					            if (CollectionUtils.isNotEmpty(ticketCountList)) { | 
				
			||||||
 | 
					                this.saveBatch(ticketCountList); | 
				
			||||||
 | 
					            } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }, executor); | 
				
			||||||
 | 
					        //执行线程操作
 | 
				
			||||||
 | 
					        CompletableFuture.allOf(ticketCountsCompletableFuture, | 
				
			||||||
 | 
					                        oneTicketCompletableFuture, | 
				
			||||||
 | 
					                        twoTicketCompletableFuture, | 
				
			||||||
 | 
					                        threeTicketCompletableFuture, | 
				
			||||||
 | 
					                        standardCompletableFuture) | 
				
			||||||
 | 
					                .get(); | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 统计操作票功能 | 
				
			||||||
 | 
					     * | 
				
			||||||
 | 
					     * @param createDept 所属机构及下属机构 | 
				
			||||||
 | 
					     * @param items      两票统计对象 | 
				
			||||||
 | 
					     * @param ticketType 两票状态 | 
				
			||||||
 | 
					     * @param dateTime | 
				
			||||||
 | 
					     * @param user | 
				
			||||||
 | 
					     * @return | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private List<TicketCount> getStandardTicketCountList(List<Long> createDept, List<TicketCount> items, String ticketType, String dateTime, BladeUser user) { | 
				
			||||||
 | 
					        List<StandardTicketInfoEntity> ticketInfoEntities = | 
				
			||||||
 | 
					                standardTicketInfoService.selectStandardTicketByDeptIdWithTicketType(createDept, ticketType); | 
				
			||||||
 | 
					        if (CollectionUtils.isEmpty(ticketInfoEntities)) { | 
				
			||||||
 | 
					            return null; | 
				
			||||||
 | 
					        } | 
				
			||||||
 | 
					        //根据站点分组
 | 
				
			||||||
 | 
					        Map<Long, List<StandardTicketInfoEntity>> createDeptTickets = | 
				
			||||||
 | 
					                ticketInfoEntities.stream().collect(Collectors.groupingBy(StandardTicketInfoEntity::getCreateDept)); | 
				
			||||||
 | 
					        //获取 操作票的id,删除
 | 
				
			||||||
 | 
					        if (CollectionUtils.isNotEmpty(items)) { | 
				
			||||||
 | 
					            List<Long> collect = items.stream().filter(item -> ticketType.equals(item.getTicketType())).map(TicketCount::getId).collect(Collectors.toList()); | 
				
			||||||
 | 
					            if (CollectionUtils.isNotEmpty(collect)) { | 
				
			||||||
 | 
					                baseMapper.deleteBatchIds(collect); | 
				
			||||||
 | 
					            } | 
				
			||||||
 | 
					        } | 
				
			||||||
 | 
					        Set<Map.Entry<Long, List<StandardTicketInfoEntity>>> entries = createDeptTickets.entrySet(); | 
				
			||||||
 | 
					        List<TicketCount> ticketCountList = new ArrayList<>(); | 
				
			||||||
 | 
					        for (Map.Entry<Long, List<StandardTicketInfoEntity>> entry : entries) { | 
				
			||||||
 | 
					            TicketCount ticketCount = new TicketCount(); | 
				
			||||||
 | 
					            ticketCount.setDateTime(dateTime); | 
				
			||||||
 | 
					            ticketCount.setDeptId(entry.getKey()); | 
				
			||||||
 | 
					            ticketCount.setTenantId(user.getTenantId()); | 
				
			||||||
 | 
					            ticketCount.setCreateDept(user.getDeptId()); | 
				
			||||||
 | 
					            //根据id获取部门名称
 | 
				
			||||||
 | 
					            R<String> deptName = systemClient.getDeptName(entry.getKey()); | 
				
			||||||
 | 
					            if (deptName.isSuccess()) { | 
				
			||||||
 | 
					                ticketCount.setDeptName(deptName.getData()); | 
				
			||||||
 | 
					            } | 
				
			||||||
 | 
					            List<StandardTicketInfoEntity> values = entry.getValue(); | 
				
			||||||
 | 
					            ticketCount.setTicketType(CollectionUtils.isNotEmpty(values) ? values.get(0).getTicketType() : ticketType); | 
				
			||||||
 | 
					            //1. 开票数量
 | 
				
			||||||
 | 
					            List<StandardTicketInfoEntity> ticketNumbers = | 
				
			||||||
 | 
					                    values.stream().filter(item -> item.getFlowTaskName() != null).collect(Collectors.toList()); | 
				
			||||||
 | 
					            ticketCount.setTicketNumber(ticketNumbers.size()); | 
				
			||||||
 | 
					            //2. 完成数量
 | 
				
			||||||
 | 
					            List<StandardTicketInfoEntity> ticketCompleteNums = | 
				
			||||||
 | 
					                    values.stream().filter(item -> "结束".equals(item.getFlowTaskName())).collect(Collectors.toList()); | 
				
			||||||
 | 
					            ticketCount.setTicketCompleteNum(ticketCompleteNums.size()); | 
				
			||||||
 | 
					            //3. 延期数据量
 | 
				
			||||||
 | 
					            ticketCount.setTicketDelayNum(0); | 
				
			||||||
 | 
					            //4. 合格数量
 | 
				
			||||||
 | 
					            List<Long> ticketIdList = values.stream().map(item -> item.getId()).collect(Collectors.toList()); | 
				
			||||||
 | 
					            LambdaQueryWrapper<TicketInfoEvaluateEntity> evaluateEntityLambdaQueryWrapper = | 
				
			||||||
 | 
					                    new LambdaQueryWrapper<>(); | 
				
			||||||
 | 
					            evaluateEntityLambdaQueryWrapper.in(TicketInfoEvaluateEntity::getTicketId, ticketIdList); | 
				
			||||||
 | 
					            evaluateEntityLambdaQueryWrapper.eq(BaseEntity::getStatus, 1); | 
				
			||||||
 | 
					            List<TicketInfoEvaluateEntity> evaluateEntities = ticketInfoEvaluateService.list(evaluateEntityLambdaQueryWrapper); | 
				
			||||||
 | 
					            ticketCount.setTicketProportionNum(evaluateEntities.size()); | 
				
			||||||
 | 
					            ticketCountList.add(ticketCount); | 
				
			||||||
 | 
					        } | 
				
			||||||
 | 
					        return ticketCountList; | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** | 
				
			||||||
 | 
					     * 统计第一种工作票,第二种工作功能,机械工作票功能 | 
				
			||||||
 | 
					     * | 
				
			||||||
 | 
					     * @param createDept 所属机构及下属机构 | 
				
			||||||
 | 
					     * @param items      两票统计对象 | 
				
			||||||
 | 
					     * @param ticketType 两票状态 | 
				
			||||||
 | 
					     * @param dateTime | 
				
			||||||
 | 
					     * @param user | 
				
			||||||
 | 
					     * @return | 
				
			||||||
 | 
					     */ | 
				
			||||||
 | 
					    private List<TicketCount> getTicketCountList(List<Long> createDept, List<TicketCount> items, String ticketType, String dateTime, BladeUser user) { | 
				
			||||||
 | 
					        List<WorkTicketInfoEntity> ticketInfoEntities = | 
				
			||||||
 | 
					                workTicketInfoService.selectTicketByDeptIdWithTicketType(createDept, ticketType); | 
				
			||||||
 | 
					        if (CollectionUtils.isEmpty(ticketInfoEntities)) { | 
				
			||||||
 | 
					            return null; | 
				
			||||||
 | 
					        } | 
				
			||||||
 | 
					        //根据站点分组
 | 
				
			||||||
 | 
					        Map<Long, List<WorkTicketInfoEntity>> createDeptTickets = ticketInfoEntities.stream().collect(Collectors.groupingBy(BaseEntity::getCreateDept)); | 
				
			||||||
 | 
					        if (CollectionUtils.isNotEmpty(items)) { | 
				
			||||||
 | 
					            //获取工作票的id,删除
 | 
				
			||||||
 | 
					            List<Long> collect = items.stream().filter(item -> ticketType.equals(item.getTicketType())).map(TicketCount::getId).collect(Collectors.toList()); | 
				
			||||||
 | 
					           if (CollectionUtils.isNotEmpty(collect)) { | 
				
			||||||
 | 
					               baseMapper.deleteBatchIds(collect); | 
				
			||||||
 | 
					           } | 
				
			||||||
 | 
					        } | 
				
			||||||
 | 
					        Set<Map.Entry<Long, List<WorkTicketInfoEntity>>> entries = createDeptTickets.entrySet(); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        List<TicketCount> ticketCountList = new ArrayList<>(); | 
				
			||||||
 | 
					        for (Map.Entry<Long, List<WorkTicketInfoEntity>> entry : entries) { | 
				
			||||||
 | 
					            TicketCount ticketCount = new TicketCount(); | 
				
			||||||
 | 
					            ticketCount.setDeptId(entry.getKey()); | 
				
			||||||
 | 
					            ticketCount.setDateTime(dateTime); | 
				
			||||||
 | 
					            //根据id获取部门名称
 | 
				
			||||||
 | 
					            R<String> deptName = systemClient.getDeptName(entry.getKey()); | 
				
			||||||
 | 
					            if (deptName.isSuccess()) { | 
				
			||||||
 | 
					                ticketCount.setDeptName(deptName.getData()); | 
				
			||||||
 | 
					            } | 
				
			||||||
 | 
					            List<WorkTicketInfoEntity> values = entry.getValue(); | 
				
			||||||
 | 
					            ticketCount.setTicketType(CollectionUtils.isNotEmpty(values) ? values.get(0).getType() : ticketType); | 
				
			||||||
 | 
					            //1. 开票数量
 | 
				
			||||||
 | 
					            List<WorkTicketInfoEntity> ticketNumbers = | 
				
			||||||
 | 
					                    values.stream().filter(item -> item.getFlowTaskName() != null).collect(Collectors.toList()); | 
				
			||||||
 | 
					            ticketCount.setTicketNumber(ticketNumbers.size()); | 
				
			||||||
 | 
					            //2. 完成数量
 | 
				
			||||||
 | 
					            List<WorkTicketInfoEntity> ticketCompleteNums = | 
				
			||||||
 | 
					                    values.stream().filter(item -> "结束".equals(item.getFlowTaskName())).collect(Collectors.toList()); | 
				
			||||||
 | 
					            ticketCount.setTicketCompleteNum(ticketCompleteNums.size()); | 
				
			||||||
 | 
					            ticketCount.setTenantId(user.getTenantId()); | 
				
			||||||
 | 
					            ticketCount.setCreateDept(user.getDeptId()); | 
				
			||||||
 | 
					            //3. 延期数据量
 | 
				
			||||||
 | 
					            List<WorkTicketInfoEntity> ticketDelayNums = | 
				
			||||||
 | 
					                    values.stream().filter(item -> "延期".equals(item.getInput())).collect(Collectors.toList()); | 
				
			||||||
 | 
					            ticketCount.setTicketDelayNum(ticketDelayNums.size()); | 
				
			||||||
 | 
					            //4. 合格数量
 | 
				
			||||||
 | 
					            List<Long> ticketIdList = values.stream().map(item -> item.getId()).collect(Collectors.toList()); | 
				
			||||||
 | 
					            LambdaQueryWrapper<TicketInfoEvaluateEntity> evaluateEntityLambdaQueryWrapper = | 
				
			||||||
 | 
					                    new LambdaQueryWrapper<>(); | 
				
			||||||
 | 
					            evaluateEntityLambdaQueryWrapper.in(TicketInfoEvaluateEntity::getTicketId, ticketIdList); | 
				
			||||||
 | 
					            evaluateEntityLambdaQueryWrapper.eq(BaseEntity::getStatus, 1); | 
				
			||||||
 | 
					            List<TicketInfoEvaluateEntity> evaluateEntities = ticketInfoEvaluateService.list(evaluateEntityLambdaQueryWrapper); | 
				
			||||||
 | 
					            ticketCount.setTicketProportionNum(evaluateEntities.size()); | 
				
			||||||
 | 
					            ticketCountList.add(ticketCount); | 
				
			||||||
 | 
					        } | 
				
			||||||
 | 
					        return ticketCountList; | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,21 @@ | 
				
			|||||||
 | 
					-- auto-generated definition | 
				
			||||||
 | 
					create table hzims_ticket_count | 
				
			||||||
 | 
					( | 
				
			||||||
 | 
					    id                    bigint auto_increment comment '主键ID' | 
				
			||||||
 | 
					        primary key, | 
				
			||||||
 | 
					    date_time             varchar(20)                          null comment '日期', | 
				
			||||||
 | 
					    dept_id               bigint                               null comment '站点Id', | 
				
			||||||
 | 
					    dept_name             varchar(100)                         null comment '站点名称', | 
				
			||||||
 | 
					    ticket_type           varchar(255)                         null comment '票据类型', | 
				
			||||||
 | 
					    ticket_number         int                                  null comment '开票数量', | 
				
			||||||
 | 
					    ticket_complete_num   int                                  null comment '完成数量', | 
				
			||||||
 | 
					    ticket_delay_num      int                                  null comment '延期数量', | 
				
			||||||
 | 
					    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', | 
				
			||||||
 | 
					    tenant_id             varchar(12)                          null comment '租户ID', | 
				
			||||||
 | 
					    create_dept           varchar(30)                          null comment '创建部门' | 
				
			||||||
 | 
					) | 
				
			||||||
 | 
					    comment '两票统计分析' row_format = DYNAMIC; | 
				
			||||||
 | 
					
 | 
				
			||||||
					Loading…
					
					
				
		Reference in new issue