Commit 1b1cb771 by huangjinxin

fix:已改约,已延误,已超时处理

1 parent 5c7e33b8
......@@ -77,4 +77,29 @@ public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long>, JpaS
" WHERE si.skill_group_code = :skillGroupCode AND oi.expect_time_begin >= :dateTime AND oi.is_multiple = 0 " +
" AND (appointment_status = 'INIT' AND order_status != 'CANCELED') AND oi.reason_for_failure IS NULL ", nativeQuery = true)
List<OrderInfoEntity> getSkillGroupOrder(String skillGroupCode, LocalDateTime dateTime);
@Query(value = "SELECT count(*) from order_info WHERE dt =:dt and (service_status ='INIT' or service_status ='CONTACTED') " +
"and DATE_ADD(NOW(), INTERVAL 10 MINUTE) > expect_time_begin and org_cluster_id = :orgCusterId", nativeQuery = true)
long countDelayByDtAndOrgClusterId(LocalDate dt, String orgCusterId);
@Query(value = "SELECT count(*) from order_info WHERE dt =:dt and (service_status ='INIT' or service_status ='CONTACTED') " +
"and DATE_ADD(NOW(), INTERVAL 10 MINUTE) > expect_time_begin and org_group_id = :orgGroupId", nativeQuery = true)
long countDelayByDtAndOrgGroupId(LocalDate dt, String orgGroupId);
@Query(value = "SELECT count(*) from order_info WHERE dt =:dt and (service_status ='INIT' or service_status ='CONTACTED') " +
"and DATE_ADD(NOW(), INTERVAL 10 MINUTE) > expect_time_begin and org_branch_id = :orgBranchId", nativeQuery = true)
long countDelayByDtAndOrgBranchId(LocalDate dt, String orgBranchId);
@Query(value = "SELECT count(*) from order_info WHERE dt =:dt and service_status ='STARTED' and actual_end_time is null " +
"and DATE_ADD(NOW(), INTERVAL 10 MINUTE) > plan_end_time and org_cluster_id = :orgCusterId", nativeQuery = true)
long countOvertimeByDtAndOrgClusterId(LocalDate dt, String orgCusterId);
@Query(value = "SELECT count(*) from order_info WHERE dt =:dt and service_status ='STARTED' and actual_end_time is null " +
"and DATE_ADD(NOW(), INTERVAL 10 MINUTE) > plan_end_time and org_group_id = :orgGroupId", nativeQuery = true)
long countOvertimeByDtAndOrgGroupId(LocalDate dt, String orgGroupId);
@Query(value = "SELECT count(*) from order_info WHERE dt =:dt and service_status ='STARTED' and actual_end_time is null " +
"and DATE_ADD(NOW(), INTERVAL 10 MINUTE) > plan_end_time and org_branch_id = :orgBranchId", nativeQuery = true)
long countOvertimeByDtAndOrgBranchId(LocalDate dt, String orgBranchId);
}
......@@ -6,6 +6,7 @@ public enum ServiceStatusEnum {
PENDING("PENDING", "待服务"),
CONTACTED("CONTACTED", "已排期"),
STARTED("STARTED", "已开始"),
CANCELED("CANCELED", "已取消"),
FINISHED("FINISHED", "已完成"),
UNFINISHED("UNFINISHED", "已上门未完成");
......
package com.dituhui.pea.order.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.common.DateUtils;
......@@ -91,7 +92,16 @@ public class WorkbenchServiceImpl implements WorkbenchService {
HashMap<String, Long> statusSummary = this.transOrderStatus(this.queryCountByOrderStatus(levelType, levelValue, dt));
WorkbenchSummaryResp.ItemDTO statusItem = new WorkbenchSummaryResp.ItemDTO();
statusItem.setType("order");
statusItem.setRows(this.packValueOrderStatus(statusSummary));
List<WorkbenchSummaryResp.ValueDTO> valueDTOS = this.packValueOrderStatus(statusSummary);
// - 已改约:预约单状态为“已改约”的工单.
HashMap<String, List<String>> p5 = this.packParams("appointmentStatus", "RESCHEDULED");
valueDTOS.add(new WorkbenchSummaryResp.ValueDTO("已改约", queryRescheduledNum(levelType, levelValue, dt), null, null, "", p5));
// - 已延误:已到开始时间,TARO没有反馈开始的工单.
valueDTOS.add(new WorkbenchSummaryResp.ValueDTO("已延误", queryDelayNum(levelType, levelValue, dt), null, "#FF3D44", "", new HashMap<>()));
statusItem.setRows(valueDTOS);
// - 已超时:已到开始时间,TARO没有反馈开始的工单.
valueDTOS.add(new WorkbenchSummaryResp.ValueDTO("已超时", queryOvertimeNum(levelType, levelValue, dt), null, "#FF3D44", "", new HashMap<>()));
statusItem.setRows(valueDTOS);
items.add(statusItem);
WorkbenchSummaryResp res = new WorkbenchSummaryResp();
......@@ -99,6 +109,83 @@ public class WorkbenchServiceImpl implements WorkbenchService {
return Result.success(res);
}
private String queryOvertimeNum(String levelType, String levelValue, LocalDate dt) {
if ("cluster".equals(levelType)) {
long clusterCount = orderInfoDao.countOvertimeByDtAndOrgClusterId(dt, levelValue);
return String.valueOf(clusterCount);
} else if ("branch".equals(levelType)) {
long branchCount = orderInfoDao.countOvertimeByDtAndOrgBranchId(dt, levelValue);
return String.valueOf(branchCount);
} else if ("group".equals(levelType)) {
long groupCount = orderInfoDao.countOvertimeByDtAndOrgGroupId(dt, levelValue);
return String.valueOf(groupCount);
}
return "0";
}
/**
* 查询延误工单数据
*
* @param levelType
* @param levelValue
* @param dt
* @return
*/
private String queryDelayNum(String levelType, String levelValue, LocalDate dt) {
if ("cluster".equals(levelType)) {
long clusterCount = orderInfoDao.countDelayByDtAndOrgClusterId(dt, levelValue);
return String.valueOf(clusterCount);
} else if ("branch".equals(levelType)) {
long branchCount = orderInfoDao.countDelayByDtAndOrgBranchId(dt, levelValue);
return String.valueOf(branchCount);
} else if ("group".equals(levelType)) {
long groupCount = orderInfoDao.countDelayByDtAndOrgGroupId(dt, levelValue);
return String.valueOf(groupCount);
}
return "0";
}
/**
* 查询改约工单数据
*
* @param levelType
* @param levelValue
* @param dt
* @return
*/
private String queryRescheduledNum(String levelType, String levelValue, LocalDate dt) {
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Object[]> criteriaQuery = criteriaBuilder.createQuery(Object[].class);
Root<OrderInfoEntity> root = criteriaQuery.from(OrderInfoEntity.class);
criteriaQuery.multiselect(
criteriaBuilder.count(root).alias("count")
);
Predicate datePredicate = criteriaBuilder.equal(root.get("dt"), dt);
Predicate orderStatusPredicate = criteriaBuilder.equal(root.get("orderStatus"), "RESCHEDULED");
Predicate levelPredicate = null;
if ("cluster".equals(levelType)) {
levelPredicate = criteriaBuilder.equal(root.get("orgClusterId"), levelValue);
} else if ("branch".equals(levelType)) {
levelPredicate = criteriaBuilder.equal(root.get("orgBranchId"), levelValue);
} else if ("group".equals(levelType)) {
levelPredicate = criteriaBuilder.equal(root.get("orgGroupId"), levelValue);
}
if (levelPredicate != null) {
criteriaQuery.where(orderStatusPredicate, datePredicate, levelPredicate);
} else {
criteriaQuery.where(orderStatusPredicate, datePredicate);
}
TypedQuery<Object[]> typedQuery = entityManager.createQuery(criteriaQuery);
List<Object[]> results = typedQuery.getResultList();
String rescheduledNum = String.valueOf(ObjectUtil.isNull(results.get(0)) ? "0" : results.get(0));
return rescheduledNum;
}
private List<Map<String, Object>> queryCountByAppointmentMethod(String levelType, String levelValue, LocalDate dt) {
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Object[]> criteriaQuery = criteriaBuilder.createQuery(Object[].class);
......@@ -262,31 +349,27 @@ public class WorkbenchServiceImpl implements WorkbenchService {
String urlName = ""; // 不返回,前端就不跳转了
Long assigned = summary.getOrDefault("INIT", 0L);
Long contacted = summary.getOrDefault("CONTACTED", 0L);
Long pending = summary.getOrDefault("PENDING", 0L);
Long dealing = assigned + pending;
Long dealing = contacted + pending;
Long started = summary.getOrDefault("STARTED", 0L);
Long finished = summary.getOrDefault("FINISHED", 0L) + summary.getOrDefault("UNFINISHED", 0L);
Long cancel = 0L;
HashMap<String, List<String>> p1 = this.packParams("appointmentStatus", "ASSIGNED", "CONTACTED", "DEPARTED");
Long cancel = summary.getOrDefault("1", 0L);
// 服务状态:INIT-初始化/PENDING待服务/CONTACTED已排期/STARTED-已开始/FINISHED已完成/UNFINISHED-已上门未完成
// - 待上门:服务状态为“待服务、已排期”的工单.
HashMap<String, List<String>> p1 = this.packParams("appointmentStatus", "CONTACTED", "PENDING");
items.add(new WorkbenchSummaryResp.ValueDTO("待上门", dealing.toString(), null, "#469967", urlName, p1));
// - 服务中:服务状态为“已开始”的工单.
HashMap<String, List<String>> p2 = this.packParams("appointmentStatus", "STARTED");
items.add(new WorkbenchSummaryResp.ValueDTO("服务中", started.toString(), null, "#016FFF", urlName, p2));
// - 已完成:服务状态为“已完成”的工单.
HashMap<String, List<String>> p3 = this.packParams("appointmentStatus", "FINISHED");
items.add(new WorkbenchSummaryResp.ValueDTO("已完成", finished.toString(), null, null, urlName, p3));
// - 已取消:预约单状态为“已取消”的工单.
HashMap<String, List<String>> p4 = this.packParams("appointmentStatus", "CANCELED");
items.add(new WorkbenchSummaryResp.ValueDTO("已取消", cancel.toString(), null, null, urlName, p4));
HashMap<String, List<String>> p5 = this.packParams("appointmentStatus", "RESCHEDULED");
items.add(new WorkbenchSummaryResp.ValueDTO("已改约", "0", null, null, urlName, p5));
items.add(new WorkbenchSummaryResp.ValueDTO("已延误", "0", null, "#FF3D44", urlName, new HashMap<>()));
return items;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!