|
@ -37,6 +37,8 @@ import java.time.LocalDateTime; |
|
|
import java.time.ZoneId; |
|
|
import java.time.ZoneId; |
|
|
import java.time.format.DateTimeFormatter; |
|
|
import java.time.format.DateTimeFormatter; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
import java.util.regex.Matcher; |
|
|
|
|
|
import java.util.regex.Pattern; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -307,7 +309,7 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService { |
|
|
|
|
|
|
|
|
return flag; |
|
|
return flag; |
|
|
} |
|
|
} |
|
|
|
|
|
// 规范格式,如:01时02分03秒
|
|
|
public static String formatDuration(int seconds) { |
|
|
public static String formatDuration(int seconds) { |
|
|
int hours = seconds / 3600; |
|
|
int hours = seconds / 3600; |
|
|
int minutes = (seconds % 3600) / 60; |
|
|
int minutes = (seconds % 3600) / 60; |
|
@ -483,6 +485,22 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService { |
|
|
// 如果没有找到接单记录或没有接单时间,可以设为默认值
|
|
|
// 如果没有找到接单记录或没有接单时间,可以设为默认值
|
|
|
record.setRestTime("暂无接单信息"); |
|
|
record.setRestTime("暂无接单信息"); |
|
|
} |
|
|
} |
|
|
|
|
|
// 二次派遣不会重新计算时间 还是按照第一次接单时间来计算
|
|
|
|
|
|
if (record.getStatus() == 9) { |
|
|
|
|
|
// 处理时间不会重置
|
|
|
|
|
|
LambdaQueryWrapper<WorkOrderProcess> qw = new LambdaQueryWrapper<>(); |
|
|
|
|
|
qw.eq(WorkOrderProcess::getWorkOrderId, workOrderId); |
|
|
|
|
|
qw.eq(WorkOrderProcess::getStage, "故障接单"); |
|
|
|
|
|
// 按照时间降序排,最新的记录在最前面
|
|
|
|
|
|
qw.orderByAsc(WorkOrderProcess::getCreateTime); |
|
|
|
|
|
qw.last("LIMIT 1"); |
|
|
|
|
|
WorkOrderProcess latest = workOrderProcessMapper.selectOne(qw); |
|
|
|
|
|
Date operationTime = latest.getOperationTime(); |
|
|
|
|
|
// 单位:小时
|
|
|
|
|
|
Long responseTime = record.getResponseTime(); |
|
|
|
|
|
record.setRestTime(getTimeLeft(operationTime, responseTime)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 设置延期信息
|
|
|
// 设置延期信息
|
|
|
if (record.getStatus() == 7){ |
|
|
if (record.getStatus() == 7){ |
|
|
WorkOrderDelayVo delayVo = workOrderDelayService.queryById(Long.valueOf(workOrderId)); |
|
|
WorkOrderDelayVo delayVo = workOrderDelayService.queryById(Long.valueOf(workOrderId)); |
|
@ -1383,4 +1401,156 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService { |
|
|
return TableDataInfo.build(result); |
|
|
return TableDataInfo.build(result); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<WorkOrderInfoVo> queryListForExport(WorkOrderInfoBo bo) { |
|
|
|
|
|
LambdaQueryWrapper<WorkOrderInfo> lqw = buildQueryWrapper(bo); |
|
|
|
|
|
List<WorkOrderInfoVo> orderInfoVoList = baseMapper.selectVoList(lqw); |
|
|
|
|
|
|
|
|
|
|
|
for (WorkOrderInfoVo record : orderInfoVoList) { |
|
|
|
|
|
String handleTimeOutSituation = ""; |
|
|
|
|
|
String orderAcceptTimeOutSituation = ""; |
|
|
|
|
|
String workOrderId = record.getId(); |
|
|
|
|
|
String projectName = record.getProjectName(); |
|
|
|
|
|
// 根据项目名称获取接单超期信息
|
|
|
|
|
|
LambdaQueryWrapper<ProjectInfo> projectQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
projectQueryWrapper.eq(ProjectInfo::getProjectName, projectName); |
|
|
|
|
|
projectQueryWrapper.last("LIMIT 1"); |
|
|
|
|
|
ProjectInfo projectInfo = projectInfoMapper.selectOne(projectQueryWrapper); |
|
|
|
|
|
String orderTakingOverTime = projectInfo.getOrderTakingOverTime(); |
|
|
|
|
|
String orderTakingCost = projectInfo.getOrderTakingCost(); |
|
|
|
|
|
String handleTimeOutCost = projectInfo.getHandleCost(); |
|
|
|
|
|
|
|
|
|
|
|
// 1.接单超时 --> 参考时间:事件转派 故障派遣
|
|
|
|
|
|
LambdaQueryWrapper<WorkOrderProcess> takeOrderQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
takeOrderQueryWrapper.eq(WorkOrderProcess::getWorkOrderId, workOrderId); |
|
|
|
|
|
takeOrderQueryWrapper.in(WorkOrderProcess::getStage, "故障派遣", "事件转派"); |
|
|
|
|
|
takeOrderQueryWrapper.orderByDesc(WorkOrderProcess::getCreateTime); |
|
|
|
|
|
takeOrderQueryWrapper.last("LIMIT 1"); |
|
|
|
|
|
WorkOrderProcess takeOrderProcess = workOrderProcessMapper.selectOne(takeOrderQueryWrapper); |
|
|
|
|
|
if (takeOrderProcess != null && takeOrderProcess.getOperationTime() != null) { |
|
|
|
|
|
orderAcceptTimeOutSituation = getTimeLeft(takeOrderProcess.getOperationTime(),Long.valueOf(orderTakingOverTime)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 2.响应超时(处理超时) --> 参考时间: 故障接单
|
|
|
|
|
|
LambdaQueryWrapper<WorkOrderProcess> dealQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
dealQueryWrapper.eq(WorkOrderProcess::getWorkOrderId, workOrderId); |
|
|
|
|
|
dealQueryWrapper.eq(WorkOrderProcess::getStage, "故障接单"); |
|
|
|
|
|
dealQueryWrapper.orderByDesc(WorkOrderProcess::getCreateTime); |
|
|
|
|
|
dealQueryWrapper.last("LIMIT 1"); |
|
|
|
|
|
WorkOrderProcess dealProcess = workOrderProcessMapper.selectOne(dealQueryWrapper); |
|
|
|
|
|
if (dealProcess != null && dealProcess.getOperationTime() != null) { |
|
|
|
|
|
handleTimeOutSituation = getTimeLeft(dealProcess.getOperationTime(),record.getResponseTime() ); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (handleTimeOutSituation.startsWith("超时")) { |
|
|
|
|
|
int timeoutHours = calculateTotalTimeoutHours(handleTimeOutSituation); |
|
|
|
|
|
record.setHandleTimeOutCount(timeoutHours); |
|
|
|
|
|
record.setHandleTimeOutCost(timeoutHours * Double.valueOf(handleTimeOutCost)); |
|
|
|
|
|
} |
|
|
|
|
|
if (orderAcceptTimeOutSituation.startsWith("超时")) { |
|
|
|
|
|
int timeoutHours = calculateTotalTimeoutHours(orderAcceptTimeOutSituation); |
|
|
|
|
|
record.setOrderAcceptTimeOutCount(timeoutHours); |
|
|
|
|
|
record.setHandleTimeOutCost(timeoutHours * Double.valueOf(orderTakingCost)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return orderInfoVoList; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public WorkOrderInfoVo getOverTimeCost(String workOrderId) { |
|
|
|
|
|
WorkOrderInfoVo record = baseMapper.selectVoById(workOrderId); |
|
|
|
|
|
String handleTimeOutSituation = ""; |
|
|
|
|
|
String orderAcceptTimeOutSituation = ""; |
|
|
|
|
|
String projectName = record.getProjectName(); |
|
|
|
|
|
// 根据项目名称获取接单超期信息
|
|
|
|
|
|
LambdaQueryWrapper<ProjectInfo> projectQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
projectQueryWrapper.eq(ProjectInfo::getProjectName, projectName); |
|
|
|
|
|
projectQueryWrapper.last("LIMIT 1"); |
|
|
|
|
|
ProjectInfo projectInfo = projectInfoMapper.selectOne(projectQueryWrapper); |
|
|
|
|
|
String orderTakingOverTime = projectInfo.getOrderTakingOverTime(); |
|
|
|
|
|
String orderTakingCost = projectInfo.getOrderTakingCost(); |
|
|
|
|
|
String handleTimeOutCost = projectInfo.getHandleCost(); |
|
|
|
|
|
|
|
|
|
|
|
// 1.接单超时 --> 参考时间:事件转派 故障派遣
|
|
|
|
|
|
LambdaQueryWrapper<WorkOrderProcess> takeOrderQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
takeOrderQueryWrapper.eq(WorkOrderProcess::getWorkOrderId, workOrderId); |
|
|
|
|
|
takeOrderQueryWrapper.in(WorkOrderProcess::getStage, "故障派遣", "事件转派"); |
|
|
|
|
|
takeOrderQueryWrapper.orderByDesc(WorkOrderProcess::getCreateTime); |
|
|
|
|
|
takeOrderQueryWrapper.last("LIMIT 1"); |
|
|
|
|
|
WorkOrderProcess takeOrderProcess = workOrderProcessMapper.selectOne(takeOrderQueryWrapper); |
|
|
|
|
|
if (takeOrderProcess != null && takeOrderProcess.getOperationTime() != null) { |
|
|
|
|
|
orderAcceptTimeOutSituation = getTimeLeft(takeOrderProcess.getOperationTime(),Long.valueOf(orderTakingOverTime)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 2.响应超时(处理超时) --> 参考时间: 故障接单
|
|
|
|
|
|
LambdaQueryWrapper<WorkOrderProcess> dealQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
dealQueryWrapper.eq(WorkOrderProcess::getWorkOrderId, workOrderId); |
|
|
|
|
|
dealQueryWrapper.eq(WorkOrderProcess::getStage, "故障接单"); |
|
|
|
|
|
dealQueryWrapper.orderByDesc(WorkOrderProcess::getCreateTime); |
|
|
|
|
|
dealQueryWrapper.last("LIMIT 1"); |
|
|
|
|
|
WorkOrderProcess dealProcess = workOrderProcessMapper.selectOne(dealQueryWrapper); |
|
|
|
|
|
if (dealProcess != null && dealProcess.getOperationTime() != null) { |
|
|
|
|
|
handleTimeOutSituation = getTimeLeft(dealProcess.getOperationTime(),record.getResponseTime() ); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (handleTimeOutSituation.startsWith("超时")) { |
|
|
|
|
|
int timeoutHours = calculateTotalTimeoutHours(handleTimeOutSituation); |
|
|
|
|
|
record.setHandleTimeOutCount(timeoutHours); |
|
|
|
|
|
record.setHandleTimeOutCost(timeoutHours * Double.parseDouble(handleTimeOutCost)); |
|
|
|
|
|
} |
|
|
|
|
|
if (orderAcceptTimeOutSituation.startsWith("超时")) { |
|
|
|
|
|
int timeoutHours = calculateTotalTimeoutHours(orderAcceptTimeOutSituation); |
|
|
|
|
|
record.setOrderAcceptTimeOutCount(timeoutHours); |
|
|
|
|
|
record.setHandleTimeOutCost(timeoutHours * Double.parseDouble(orderTakingCost)); |
|
|
|
|
|
} |
|
|
|
|
|
return record; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 截取“超时”后面的部分 |
|
|
|
|
|
*/ |
|
|
|
|
|
private String extractTimePart(String input) { |
|
|
|
|
|
if (!input.startsWith("超时")) { |
|
|
|
|
|
throw new IllegalArgumentException("输入必须以 '超时' 开头"); |
|
|
|
|
|
} |
|
|
|
|
|
return input.substring(2); // 去掉前两个字“超时”
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 使用正则表达式解析出天、小时、分钟 |
|
|
|
|
|
*/ |
|
|
|
|
|
private int[] parseTime(String timeStr) { |
|
|
|
|
|
Pattern pattern = Pattern.compile( |
|
|
|
|
|
"(\\d+)[天]*(\\d+)[小时]*(\\d+)[分]*" |
|
|
|
|
|
); |
|
|
|
|
|
Matcher matcher = pattern.matcher(timeStr); |
|
|
|
|
|
|
|
|
|
|
|
if (!matcher.matches()) { |
|
|
|
|
|
throw new IllegalArgumentException("时间格式不正确,应为 'X天Y小时Z分',例如:'2天22小时48分'"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int days = Integer.parseInt(matcher.group(1)); |
|
|
|
|
|
int hours = Integer.parseInt(matcher.group(2)); |
|
|
|
|
|
int minutes = Integer.parseInt(matcher.group(3)); |
|
|
|
|
|
|
|
|
|
|
|
return new int[]{days, hours, minutes}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public int calculateTotalTimeoutHours(String input) { |
|
|
|
|
|
// 步骤一:截取“超时”后面的部分
|
|
|
|
|
|
String timePart = extractTimePart(input); |
|
|
|
|
|
|
|
|
|
|
|
// 步骤二:解析天、小时、分钟
|
|
|
|
|
|
int[] timeValues = parseTime(timePart); |
|
|
|
|
|
|
|
|
|
|
|
int days = timeValues[0]; |
|
|
|
|
|
int hours = timeValues[1]; |
|
|
|
|
|
int minutes = timeValues[2]; |
|
|
|
|
|
|
|
|
|
|
|
// 步骤三:计算总计超时小时数
|
|
|
|
|
|
return days * 24 + hours + (minutes >= 1 ? 1 : 0); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|