09-22-提交
This commit is contained in:
@ -6,6 +6,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.dromara.inspection.domain.vo.OpsInspectionReportRecordVo;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
@ -109,7 +110,8 @@ public class OpsInspectionReportController extends BaseController {
|
||||
* 生成纪录
|
||||
*/
|
||||
@SaCheckPermission("inspection:report:record")
|
||||
public R<Object> record(){
|
||||
@GetMapping("/record")
|
||||
public R<OpsInspectionReportRecordVo> record(@RequestParam Long projectId){
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 运维-巡检-报修对象 ops_inspection_report
|
||||
@ -87,5 +88,8 @@ public class OpsInspectionReport extends BaseEntity {
|
||||
*/
|
||||
private String reportPhone;
|
||||
|
||||
private String reportFinal;
|
||||
|
||||
private Date reportFinishTime;
|
||||
|
||||
}
|
||||
|
||||
@ -9,6 +9,8 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 运维-巡检-报修业务对象 ops_inspection_report
|
||||
*
|
||||
@ -95,5 +97,8 @@ public class OpsInspectionReportBo extends BaseEntity {
|
||||
@NotBlank(message = "电话不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String reportPhone;
|
||||
|
||||
private String reportFinal;
|
||||
|
||||
private Date reportFinishTime;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
package org.dromara.inspection.domain.vo;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class OpsInspectionReportRecordVo {
|
||||
|
||||
//本月总报修数
|
||||
private String byzbxs;
|
||||
|
||||
//报修数较上周增长率
|
||||
private String bxsjszzzl;
|
||||
|
||||
//平均处理时长
|
||||
private String pjclsc;
|
||||
|
||||
//处理时长较上周增长率
|
||||
private String clscjszzzl;
|
||||
|
||||
//待处理报修
|
||||
private String dclbx;
|
||||
|
||||
//完成率
|
||||
private String wcl;
|
||||
|
||||
//完成率较上周增长率
|
||||
private String wcljszzzl;
|
||||
|
||||
}
|
||||
@ -9,6 +9,7 @@ import org.dromara.personnel.domain.vo.OpsUserVo;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
@ -107,5 +108,12 @@ public class OpsInspectionReportVo implements Serializable {
|
||||
@ExcelProperty(value = "报修人联系电话")
|
||||
private String reportPhone;
|
||||
|
||||
@ExcelProperty(value = "维修结果")
|
||||
private String reportFinal;
|
||||
|
||||
@ExcelProperty(value = "完成时间")
|
||||
private Date reportFinishTime;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package org.dromara.inspection.service.impl;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.apache.seata.spring.annotation.GlobalTransactional;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
@ -12,6 +13,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.inspection.domain.vo.OpsInspectionReportRecordVo;
|
||||
import org.dromara.personnel.domain.vo.OpsUserVo;
|
||||
import org.dromara.personnel.service.impl.OpsUserServiceImpl;
|
||||
import org.dromara.resource.api.RemoteFileService;
|
||||
@ -24,7 +26,12 @@ import org.dromara.inspection.mapper.OpsInspectionReportMapper;
|
||||
import org.dromara.inspection.service.IOpsInspectionReportService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 运维-巡检-报修Service业务层处理
|
||||
@ -219,4 +226,90 @@ public class OpsInspectionReportServiceImpl implements IOpsInspectionReportServi
|
||||
}
|
||||
}
|
||||
|
||||
public R<OpsInspectionReportRecordVo> record(Long projectId) {
|
||||
//变量初始化
|
||||
OpsInspectionReportRecordVo recordVo = new OpsInspectionReportRecordVo();
|
||||
OpsInspectionReportBo bo = new OpsInspectionReportBo();
|
||||
bo.setProjectId(projectId);
|
||||
//日期初始化
|
||||
LocalDate firstDay = LocalDate.now().withDayOfMonth(1);
|
||||
LocalDate lastDay = firstDay.plusMonths(1).minusDays(1);
|
||||
Date startDate = Date.from(firstDay.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
||||
Date endDate = Date.from(lastDay.atTime(23, 59, 59).atZone(ZoneId.systemDefault()).toInstant());
|
||||
//查询当前项目的报修数据
|
||||
List<OpsInspectionReportVo> opsInspectionReportVos = queryList(bo);
|
||||
|
||||
//过滤本月数据
|
||||
List<OpsInspectionReportVo> thisMonth = opsInspectionReportVos.stream()
|
||||
.filter(vo -> vo.getCreateTime().after(startDate))
|
||||
.filter(vo -> vo.getCreateTime().before(endDate))
|
||||
.toList();
|
||||
//本月总报修数
|
||||
recordVo.setByzbxs(String.valueOf(thisMonth.size()));
|
||||
|
||||
//平均处理时长 完成时间-创建时间 转为 分钟 / 总报
|
||||
Long time = 0L;//总共完成时间
|
||||
for (OpsInspectionReportVo vo : thisMonth) {
|
||||
if (vo.getStatus().equals("3")){
|
||||
time += vo.getReportFinishTime().getTime() - vo.getCreateTime().getTime();
|
||||
}
|
||||
}
|
||||
time = TimeUnit.MILLISECONDS.toMinutes(time);
|
||||
BigDecimal divide1 = BigDecimal.valueOf(time).divide(BigDecimal.valueOf(thisMonth.size()), 2, RoundingMode.HALF_UP);
|
||||
long hours = TimeUnit.MINUTES.toHours(Long.parseLong(divide1.toString()));
|
||||
|
||||
//平均处理时长
|
||||
recordVo.setPjclsc(Long.toString(hours));
|
||||
|
||||
//待处理报修
|
||||
int size = thisMonth.stream().filter(vo -> vo.getStatus().equals("1")).toList().size();
|
||||
recordVo.setDclbx(String.valueOf(size));
|
||||
|
||||
//完成率
|
||||
//完成数
|
||||
int finishCount = thisMonth.stream().filter(vo -> vo.getStatus().equals("3")).toList().size();
|
||||
BigDecimal divide = BigDecimal.valueOf(finishCount).divide(BigDecimal.valueOf(thisMonth.size()), 2, RoundingMode.HALF_UP);
|
||||
recordVo.setWcl(divide.multiply(new BigDecimal("100")).toString());
|
||||
|
||||
//统计上一月的数据
|
||||
firstDay = LocalDate.now().minusMonths(1).withDayOfMonth(1);
|
||||
lastDay = firstDay.plusMonths(1).minusDays(1);
|
||||
Date finalStartDate = Date.from(firstDay.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
||||
Date finalEndDate = Date.from(lastDay.atTime(23, 59, 59).atZone(ZoneId.systemDefault()).toInstant());
|
||||
|
||||
|
||||
thisMonth = opsInspectionReportVos.stream()
|
||||
.filter(vo -> vo.getCreateTime().after(finalStartDate))
|
||||
.filter(vo -> vo.getCreateTime().before(finalEndDate))
|
||||
.toList();
|
||||
|
||||
//上一月总报修数
|
||||
Long lastMonth = (long) thisMonth.size();
|
||||
//上一月平均处理时长
|
||||
BigDecimal avg = BigDecimal.ZERO;
|
||||
time = 0L;
|
||||
for (OpsInspectionReportVo vo : thisMonth) {
|
||||
if (vo.getStatus().equals("3")){
|
||||
time += vo.getReportFinishTime().getTime() - vo.getCreateTime().getTime();
|
||||
}
|
||||
}
|
||||
time = TimeUnit.MILLISECONDS.toMinutes(time);
|
||||
avg = BigDecimal.valueOf(time).divide(BigDecimal.valueOf(thisMonth.size()),2, RoundingMode.HALF_UP);
|
||||
//上一月完成率
|
||||
finishCount = thisMonth.stream().filter(vo -> vo.getStatus().equals("3")).toList().size();
|
||||
divide = BigDecimal.valueOf(finishCount).divide(BigDecimal.valueOf(thisMonth.size()), 2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100.00));
|
||||
|
||||
//总报修数增长率
|
||||
BigDecimal multiply = BigDecimal.valueOf(Long.parseLong(recordVo.getByzbxs())).divide(BigDecimal.valueOf(lastMonth), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"));
|
||||
recordVo.setBxsjszzzl(multiply.toString());
|
||||
|
||||
//平均处理时长增长率 本月 / 上月 * 100
|
||||
recordVo.setClscjszzzl(BigDecimal.valueOf(Long.parseLong(recordVo.getPjclsc())).divide(avg,2, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).toString());
|
||||
|
||||
//完成率增长率 本月 / 上月 * 100
|
||||
recordVo.getWcl();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user