|
|
@ -1,13 +1,9 @@ |
|
|
|
package org.dromara.platform.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.date.DateTime; |
|
|
|
import cn.hutool.core.date.DateUnit; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import jakarta.annotation.Resource; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.ibatis.annotations.Param; |
|
|
|
import org.apache.poi.hssf.record.DVALRecord; |
|
|
|
import org.dromara.common.core.domain.model.LoginUser; |
|
|
|
import org.dromara.common.core.utils.MapstructUtils; |
|
|
|
import org.dromara.common.core.utils.StringUtils; |
|
|
@ -28,9 +24,7 @@ import org.dromara.workflow.domain.bo.StartProcessBo; |
|
|
|
import org.dromara.workflow.domain.bo.TaskBo; |
|
|
|
import org.dromara.workflow.domain.bo.TestLeaveBo; |
|
|
|
import org.dromara.workflow.domain.vo.TaskVo; |
|
|
|
import org.dromara.workflow.domain.vo.TestLeaveVo; |
|
|
|
import org.flowable.engine.RuntimeService; |
|
|
|
import org.flowable.engine.runtime.ProcessInstance; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -202,6 +196,7 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService { |
|
|
|
|
|
|
|
boolean flag = baseMapper.insert(add) > 0; |
|
|
|
if (flag) { |
|
|
|
// 自动生成的工单id
|
|
|
|
String generatedId = add.getId(); |
|
|
|
bo.setId(generatedId); // 设置到bo对象中
|
|
|
|
String isDispatched = bo.getIsDispatched(); |
|
|
@ -218,10 +213,16 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService { |
|
|
|
workOrderProcess1.setOperationTime(date1); |
|
|
|
workOrderProcess1.setFeedback("故障以上报,等待派遣"); |
|
|
|
|
|
|
|
workOrderProcessService.insertByBo(workOrderProcess1); |
|
|
|
//TODO 修改对应的工单的状态 :待派遣
|
|
|
|
if ( workOrderProcessService.insertByBo(workOrderProcess1)){ |
|
|
|
LambdaUpdateWrapper<WorkOrderInfo> updateWrapper = new LambdaUpdateWrapper<>(); |
|
|
|
updateWrapper.eq(WorkOrderInfo::getId, generatedId) |
|
|
|
.set(WorkOrderInfo::getStatus, 0); |
|
|
|
baseMapper.update(null, updateWrapper); |
|
|
|
log.info("修改对应的工单的状态 :待派遣"); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.equals(isDispatched, "是")) { |
|
|
|
//TODO 修改对应的工单的状态 待接单
|
|
|
|
|
|
|
|
WorkOrderProcessBo workOrderProcess2 = new WorkOrderProcessBo(); |
|
|
|
workOrderProcess2.setWorkOrderId(generatedId); |
|
|
|
workOrderProcess2.setOperator(loginUser.getNickname()); |
|
|
@ -240,7 +241,12 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService { |
|
|
|
long durationInSeconds = duration.getSeconds(); |
|
|
|
String formatDuration = formatDuration((int) durationInSeconds); |
|
|
|
workOrderProcess2.setDuration(formatDuration); |
|
|
|
workOrderProcessService.insertByBo(workOrderProcess2); |
|
|
|
if(workOrderProcessService.insertByBo(workOrderProcess2)){ |
|
|
|
LambdaUpdateWrapper<WorkOrderInfo> updateWrapper = new LambdaUpdateWrapper<>(); |
|
|
|
updateWrapper.eq(WorkOrderInfo::getId, generatedId) |
|
|
|
.set(WorkOrderInfo::getStatus, 1); |
|
|
|
baseMapper.update(null, updateWrapper); |
|
|
|
log.info("修改对应的工单的状态 :待接单"); } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -381,10 +387,79 @@ public class WorkOrderInfoServiceImpl implements IWorkOrderInfoService { |
|
|
|
List<WorkOrderInfoVo> filterRecords = records.stream() |
|
|
|
.filter(record -> record.getStatus() != null && record.getStatus() < 4) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 封装
|
|
|
|
for (WorkOrderInfoVo record : filterRecords) { |
|
|
|
String workOrderId = record.getId(); |
|
|
|
|
|
|
|
LambdaQueryWrapper<WorkOrderProcess> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
queryWrapper.eq(WorkOrderProcess::getWorkOrderId, workOrderId); |
|
|
|
queryWrapper.eq(WorkOrderProcess::getStage, "故障接单"); |
|
|
|
|
|
|
|
WorkOrderProcess target = workOrderProcessMapper.selectOne(queryWrapper); |
|
|
|
|
|
|
|
if (target != null && target.getOperationTime() != null) { |
|
|
|
Date operationTime = target.getOperationTime(); |
|
|
|
// 单位:小时
|
|
|
|
Long responseTime = record.getResponseTime(); |
|
|
|
// 设置剩余时间提示
|
|
|
|
record.setRestTime(getTimeLeft(operationTime, responseTime)); |
|
|
|
} else { |
|
|
|
// 如果没有找到接单记录或没有接单时间,可以设为默认值
|
|
|
|
record.setRestTime("暂无接单信息"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
result.setRecords(filterRecords); |
|
|
|
return TableDataInfo.build(result); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 计算距离响应截止时间的剩余/超时时间 |
|
|
|
* |
|
|
|
* @param acceptTime 接单时间(Date) |
|
|
|
* @param responseHour 响应时间要求(单位:小时) |
|
|
|
* @return 格式化的时间字符串,如:"剩余2天3小时4分" 或 "超时5小时6分" |
|
|
|
*/ |
|
|
|
public String getTimeLeft(Date acceptTime, Long responseHour) { |
|
|
|
if (acceptTime == null || responseHour == null || responseHour <= 0) { |
|
|
|
return "无响应时间限制"; |
|
|
|
} |
|
|
|
|
|
|
|
// 当前时间
|
|
|
|
LocalDateTime now = LocalDateTime.now(); |
|
|
|
|
|
|
|
// 接单时间转为 LocalDateTime
|
|
|
|
LocalDateTime acceptDateTime = acceptTime.toInstant() |
|
|
|
.atZone(ZoneId.systemDefault()) |
|
|
|
.toLocalDateTime(); |
|
|
|
|
|
|
|
// 截止时间 = 接单时间 + 响应时间(小时)
|
|
|
|
LocalDateTime dueDateTime = acceptDateTime.plusHours(responseHour); |
|
|
|
|
|
|
|
Duration duration; |
|
|
|
boolean isOverdue; |
|
|
|
|
|
|
|
if (now.isAfter(dueDateTime)) { |
|
|
|
duration = Duration.between(dueDateTime, now); |
|
|
|
isOverdue = true; |
|
|
|
} else { |
|
|
|
duration = Duration.between(now, dueDateTime); |
|
|
|
isOverdue = false; |
|
|
|
} |
|
|
|
|
|
|
|
long days = duration.toDays(); |
|
|
|
long hours = duration.toHours() % 24; |
|
|
|
long minutes = duration.toMinutes() % 60; |
|
|
|
|
|
|
|
if (isOverdue) { |
|
|
|
return String.format("超时%d天%d小时%d分", days, hours, minutes); |
|
|
|
} else { |
|
|
|
return String.format("剩余%d天%d小时%d分", days, hours, minutes); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public TableDataInfo<WorkOrderInfoVo> reviewList(WorkOrderInfoBo bo, PageQuery pageQuery) { |
|
|
|
LambdaQueryWrapper<WorkOrderInfo> lqw = buildQueryWrapper(bo); |
|
|
|