소스 검색

工程维修三字段

qingzhangyin 2 년 전
부모
커밋
56b42d0f95

+ 24 - 0
src/main/java/com/palmnest/application/dto/output/RepairBillStateStatisticsDto.java

@@ -1,6 +1,7 @@
 package com.palmnest.application.dto.output;
 
 import java.math.BigDecimal;
+import java.util.Date;
 
 /**
  * 服务之窗1L- RepairBillStateStatisticsDto
@@ -31,6 +32,12 @@ public class RepairBillStateStatisticsDto {
     private int billStatus5Total; //转单中
     private int billStatus8Total; //已完成
     private int billStatus10Total; //已取消
+
+
+    private int billSingleTotal; //已抢单 数量
+    private Date singleTime; //抢单时间
+
+
     
     private int billTodayEndTotal; //今日完成数
     private BigDecimal fillTodayEndRate; //今日完成率
@@ -250,4 +257,21 @@ public class RepairBillStateStatisticsDto {
     public void setAvgStar(String avgStar) {
         this.avgStar = avgStar;
     }
+
+
+    public int getBillSingleTotal() {
+        return billSingleTotal;
+    }
+
+    public void setBillSingleTotal(int billSingleTotal) {
+        this.billSingleTotal = billSingleTotal;
+    }
+
+    public Date getSingleTime() {
+        return singleTime;
+    }
+
+    public void setSingleTime(Date singleTime) {
+        this.singleTime = singleTime;
+    }
 }

+ 10 - 0
src/main/java/com/palmnest/model/repair/RepairBill.java

@@ -68,6 +68,7 @@ public class RepairBill implements Serializable {
 	private Integer    version;//版本号
 	private Set<User>  supportUsers;
 	private Date       meetingTime;        //预约时间
+	private Date       singleTime;  //抢单时间 用于支撑报表 减少查询耗时
 	private Integer    orgId;
 	private Integer    userId;
 
@@ -361,4 +362,13 @@ public class RepairBill implements Serializable {
 	public void setCompletePhotoUrl(String completePhotoUrl) {
 		this.completePhotoUrl = completePhotoUrl;
 	}
+
+	@Column(name = "orgId")
+	public Date getSingleTime() {
+		return singleTime;
+	}
+
+	public void setSingleTime(Date singleTime) {
+		this.singleTime = singleTime;
+	}
 }

+ 60 - 2
src/main/java/com/palmnest/service/repair/impl/RepairBillStatisticsManagerImpl.java

@@ -20,6 +20,7 @@ import com.palmnest.model.User;
 import com.palmnest.model.property.TbOrganization;
 import com.palmnest.model.repair.RepairBill;
 import com.palmnest.model.repair.RepairBillComment;
+import com.palmnest.model.repair.RepairReturnVisit;
 import com.palmnest.service.ElementGroupManager;
 import com.palmnest.service.dinner.service.OrderDinnerService;
 import com.palmnest.service.repair.*;
@@ -59,6 +60,11 @@ public class RepairBillStatisticsManagerImpl implements RepairBillStatisticsMana
     private OrganizationDao organizationDao;
     @Autowired
     private RepairBillCommentManager repairBillCommentManager;
+
+
+    @Autowired
+    private RepairReturnVisitManager repairReturnVisitManager;
+
     @Autowired
     private UserRepairTypeManager userRepairTypeManager;
     @Autowired
@@ -180,6 +186,8 @@ public class RepairBillStatisticsManagerImpl implements RepairBillStatisticsMana
             Long billRepairType = repairBills.get(0).getRepairType();
 
             int hours = 0;
+            int singleMinutes = 0; //抢单总分钟数
+            int completedMinutes = 0; //完成总分钟数
             int commentTotal = 0; //总评价数
             int allCommentStars = 0; //总评星数
             
@@ -236,9 +244,16 @@ public class RepairBillStatisticsManagerImpl implements RepairBillStatisticsMana
                     dto.setBillStatus8Total(dto.getBillStatus8Total() + 1);
                     //已完成的总耗时
                     hours += DateHelper.getHoursBetween(repairBill.getCreateTime(), repairBill.getEndTime());
+                    completedMinutes += DateHelper.getMinutesBetween(repairBill.getCreateTime(), repairBill.getEndTime());
 
                 }
 
+                //已抢单-数量
+                if(null != dto.getSingleTime()){
+                    dto.setBillSingleTotal(dto.getBillSingleTotal() + 1);
+                    singleMinutes += DateHelper.getMinutesBetween(repairBill.getCreateTime(), repairBill.getSingleTime());
+                }
+
                 if (status == CodeConstants.UNAUDIT || status == CodeConstants.CANCEL) {
                     //已取消 包括已取消、审核未通过订单
                     dto.setBillStatus10Total(dto.getBillStatus10Total() + 1);
@@ -266,14 +281,57 @@ public class RepairBillStatisticsManagerImpl implements RepairBillStatisticsMana
 
                 //平均评星 总评星数/总评价单数
                 RepairBillComment repairBillComment = repairBillCommentManager.findBy(repairBill.getId());
+
+                RepairReturnVisit repairReturnVisit = repairReturnVisitManager.findBy(repairBill.getId());
+
+
+                int commentStar = 0 ; //评价星级
                 if (null != repairBillComment) {
+                    //commentTotal++;
+                    //allCommentStars += repairBillComment.getStar() == null ?
+                    //        5 : repairBillComment.getStar().intValue(); //默认5星
+
+                    commentStar = repairBillComment.getStar() == null ? 5 : repairBillComment.getStar().intValue();
+                }
+
+                int returnVisitStar = 0 ; //回访星级
+                if(null != repairReturnVisit){
+                    returnVisitStar = repairReturnVisit.getStar() == null ? 5 : repairReturnVisit.getStar().intValue();
+                }
+
+                if(commentStar != 0 || returnVisitStar != 0){
                     commentTotal++;
-                    allCommentStars += repairBillComment.getStar() == null ?
-                            5 : repairBillComment.getStar().intValue(); //默认5星
+
+                    Integer returnStar = commentStar >  returnVisitStar ? commentStar : returnVisitStar;
+                    allCommentStars += returnStar; //工单星级
+
                 }
 
             }
 
+            //平均接单耗时 -1
+            if(dto.getBillSingleTotal() > 0){
+
+                BigDecimal avgBillTime = new BigDecimal(dto.getBillSingleTotal()).divide(new BigDecimal(60))
+                        .divide(new BigDecimal(singleMinutes),2, BigDecimal.ROUND_HALF_UP);
+
+                dto.setAvgBillTime(avgBillTime);
+            }else{
+                dto.setAvgBillTime(BigDecimal.ZERO);
+            }
+
+            //平均完成耗时 -2
+            if(dto.getBillStatus8Total() > 0){
+
+                BigDecimal avgCompleteTime =new BigDecimal(completedMinutes).
+                        divide(new BigDecimal(dto.getBillStatus8Total()),2, BigDecimal.ROUND_HALF_UP);
+
+                dto.setAvgCompleteTime(avgCompleteTime);
+            }else{
+                dto.setAvgCompleteTime(BigDecimal.ZERO);
+            }
+
+
             //完成率  已完成/总工单 X 100
             if (dto.getAllBillTotal() > 0) {