From ab71acd750061280d88af6ce08038140657d6b90 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 22 Dec 2023 14:47:36 +0800 Subject: [PATCH] =?UTF-8?q?#=E5=8F=8C=E7=A5=A8=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ticket/standardTicket/vo/CensParamVo.java | 5 +- .../hzims/ticket/standardTicket/vo/CensVo.java | 9 +- .../ticket/standardTicket/vo/CensYearParamVo.java | 12 ++ .../hzims/ticket/standardTicket/vo/CensYearVo.java | 3 - .../twoTicket/service/impl/CensServiceImpl.java | 153 ++++++++++++++++++++- 5 files changed, 172 insertions(+), 10 deletions(-) diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/vo/CensParamVo.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/vo/CensParamVo.java index 43deace..ebc35d5 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/vo/CensParamVo.java +++ b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/vo/CensParamVo.java @@ -18,6 +18,9 @@ public class CensParamVo { @ApiModelProperty("结束时间: yyyy-MM-dd HH:mm:ss") private String endTime; - @ApiModelProperty("状态 : 0-未完成 1-完成") + @ApiModelProperty("状态 : 0-全部 1-完成") private Integer state; + + @ApiModelProperty("结束") + private String flowTaskName; } diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/vo/CensVo.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/vo/CensVo.java index 040e8d7..6f32da5 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/vo/CensVo.java +++ b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/vo/CensVo.java @@ -15,12 +15,15 @@ public class CensVo { @ApiModelProperty("机构名称") private String deptName; + @ApiModelProperty("月份") + private Integer mon; + @ApiModelProperty("工作票数量") - private Integer workCount; + private Long workCount; @ApiModelProperty("操作票数量") - private Integer operateCount; + private Long operateCount; @ApiModelProperty("工作任务数量") - private Integer workTaskCount; + private Long workTaskCount; } diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/vo/CensYearParamVo.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/vo/CensYearParamVo.java index 285e251..00a6f25 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/vo/CensYearParamVo.java +++ b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/vo/CensYearParamVo.java @@ -14,4 +14,16 @@ public class CensYearParamVo { @ApiModelProperty("年度 : yyyy") private String year; + + @ApiModelProperty("状态 : 0-全部 1-完成") + private Integer state; + + @ApiModelProperty("流程描述") + private String flowTaskName; + + @ApiModelProperty("开始时间 : yyyy-MM-dd HH:mm:ss") + private String startTime; + + @ApiModelProperty("结束时间: yyyy-MM-dd HH:mm:ss") + private String endTime; } diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/vo/CensYearVo.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/vo/CensYearVo.java index 6789d12..80fd614 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/vo/CensYearVo.java +++ b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/standardTicket/vo/CensYearVo.java @@ -17,9 +17,6 @@ public class CensYearVo { @ApiModelProperty("机构名称") private String deptName; - @ApiModelProperty("月份") - private Integer mon; - @ApiModelProperty("统计数量") private List censs; } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/CensServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/CensServiceImpl.java index e4d3923..93df9d2 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/CensServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/CensServiceImpl.java @@ -1,15 +1,29 @@ package com.hnac.hzims.ticket.twoTicket.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.operational.main.constant.HomePageConstant; +import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketInfoEntity; +import com.hnac.hzims.ticket.standardTicket.service.IStandardTicketInfoService; import com.hnac.hzims.ticket.standardTicket.vo.CensParamVo; import com.hnac.hzims.ticket.standardTicket.vo.CensVo; import com.hnac.hzims.ticket.standardTicket.vo.CensYearParamVo; import com.hnac.hzims.ticket.standardTicket.vo.CensYearVo; import com.hnac.hzims.ticket.twoTicket.service.CensService; +import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; +import com.hnac.hzims.ticket.workTicket.service.IWorkTicketInfoService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.StringUtil; +import org.springblade.system.entity.Dept; +import org.springblade.system.feign.ISysClient; import org.springframework.stereotype.Service; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; /** @@ -20,14 +34,147 @@ import java.util.List; @RequiredArgsConstructor public class CensServiceImpl implements CensService { + private final IStandardTicketInfoService operateTicketService; + + private final IWorkTicketInfoService workTicketInfoService; + + private final ISysClient sysClient; + @Override public List cens(CensParamVo param) { - return null; + if(StringUtil.isEmpty(param.getStartTime())){ + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + calendar.add(Calendar.DAY_OF_MONTH,-calendar.get(Calendar.DAY_OF_MONTH)); + calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY)); + calendar.add(Calendar.MINUTE,-calendar.get(Calendar.MINUTE)); + calendar.add(Calendar.SECOND,-calendar.get(Calendar.SECOND)); + param.setStartTime(DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME)); + } + if(StringUtil.isEmpty(param.getEndTime())){ + param.setStartTime(DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME)); + } + if(!StringUtil.isEmpty(param.getState()) && param.getState().equals(1)){ + param.setFlowTaskName("结束"); + } + + // 获取权限区域机构 + List depts = this.authArea(); + if(CollectionUtil.isEmpty(depts)){ + return new ArrayList<>(); + } + // 操作票查询 + LambdaQueryWrapper operateWrapper = Wrappers.lambdaQuery() + .between(StandardTicketInfoEntity::getCreateTime,param.getStartTime(),param.getEndTime()) + .in(StandardTicketInfoEntity::getCreateDept,depts); + if(!StringUtil.isEmpty(param.getFlowTaskName())){ + operateWrapper.eq("FLOW_TASK_NAME",param.getFlowTaskName()); + } + List operates = operateTicketService.list(operateWrapper); + // 工作票查询 + LambdaQueryWrapper workWrapper = Wrappers.lambdaQuery() + .between(StandardTicketInfoEntity::getCreateTime,param.getStartTime(),param.getEndTime()) + .in(StandardTicketInfoEntity::getCreateDept,depts); + if(!StringUtil.isEmpty(param.getFlowTaskName())){ + workWrapper.eq("FLOW_TASK_NAME",param.getFlowTaskName()); + } + List works = workTicketInfoService.list(workWrapper); + // 工作任务单 + return depts.stream().map(dept->{ + CensVo cens = new CensVo(); + cens.setDeptId(dept.getId()); + cens.setDeptName(dept.getDeptName()); + if(CollectionUtil.isEmpty(operates)){ + cens.setOperateCount(0L); + }else{ + cens.setOperateCount(operates.stream().filter(operate->operate.getCreateDept().equals(dept.getId())).count()); + } + if(CollectionUtil.isEmpty(works)){ + cens.setWorkCount(0L); + }else{ + cens.setOperateCount(works.stream().filter(work->work.getCreateDept().equals(dept.getId())).count()); + } + cens.setWorkTaskCount((long)new Random().nextInt(10)); + return cens; + }).collect(Collectors.toList()); + } + + /** + * 获取权限区域机构 + * @return + */ + private List authArea() { + R> resut = sysClient.getDeptByCurrentUser(); + if(!resut.isSuccess() || CollectionUtil.isEmpty(resut.getData())){ + return new ArrayList<>(); + } + return resut.getData().stream().filter(dept->dept.getDeptCategory().equals(HomePageConstant.AREA)).collect(Collectors.toList()); } @Override public List censYear(CensYearParamVo param) { - return null; + if(StringUtil.isEmpty(param.getYear())){ + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH,-calendar.get(Calendar.MONTH)); + calendar.add(Calendar.DAY_OF_MONTH,-calendar.get(Calendar.DAY_OF_MONTH)); + calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY)); + calendar.add(Calendar.MINUTE,-calendar.get(Calendar.MINUTE)); + calendar.add(Calendar.SECOND,-calendar.get(Calendar.SECOND)); + param.setStartTime(DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME)); + param.setEndTime(DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME)); + }else{ + param.setStartTime(param.getYear() + "-01-01 00:00:00"); + param.setEndTime(param.getYear() + "-12-31 23:59:59"); + } + + if(!StringUtil.isEmpty(param.getState()) && param.getState().equals(1)){ + param.setFlowTaskName("结束"); + } + + // 获取权限区域机构 + List depts = this.authArea(); + if(CollectionUtil.isEmpty(depts)){ + return new ArrayList<>(); + } + + // 操作票查询 + LambdaQueryWrapper operateWrapper = Wrappers.lambdaQuery() + .between(StandardTicketInfoEntity::getCreateTime,param.getStartTime(),param.getEndTime()) + .in(StandardTicketInfoEntity::getCreateDept,depts); + if(!StringUtil.isEmpty(param.getFlowTaskName())){ + operateWrapper.eq("FLOW_TASK_NAME",param.getFlowTaskName()); + } + List operates = operateTicketService.list(operateWrapper); + // 工作票查询 + LambdaQueryWrapper workWrapper = Wrappers.lambdaQuery() + .between(StandardTicketInfoEntity::getCreateTime,param.getStartTime(),param.getEndTime()) + .in(StandardTicketInfoEntity::getCreateDept,depts); + if(!StringUtil.isEmpty(param.getFlowTaskName())){ + workWrapper.eq("FLOW_TASK_NAME",param.getFlowTaskName()); + } + List works = workTicketInfoService.list(workWrapper); + return depts.stream().map(dept -> { + CensYearVo censYear = new CensYearVo(); + censYear.setDeptId(dept.getId()); + censYear.setDeptName(dept.getDeptName()); + for(int mon = 1 ; mon <= 12 ;mon++){ + String strMon = param.getYear() + "-" + (mon > 9 ? mon : "0" + mon); + CensVo cens = new CensVo(); + cens.setMon(mon); + if(CollectionUtil.isEmpty(operates)){ + cens.setOperateCount(0L); + }else{ + cens.setOperateCount(operates.stream().filter(operate->operate.getCreateDept().equals(dept.getId()) && DateUtil.format(operate.getCreateTime(),"yyyy-MM").equals(strMon)).count()); + } + if(CollectionUtil.isEmpty(works)){ + cens.setWorkCount(0L); + }else{ + cens.setOperateCount(works.stream().filter(work->work.getCreateDept().equals(dept.getId()) && DateUtil.format(work.getCreateTime(),"yyyy-MM").equals(strMon)).count()); + } + cens.setWorkTaskCount((long)new Random().nextInt(10)); + } + return censYear; + }).collect(Collectors.toList()); } } \ No newline at end of file