服务指令预览调整超时逻辑
This commit is contained in:
parent
0927ad01b7
commit
91c77b760b
|
|
@ -15,10 +15,7 @@ import org.springframework.util.CollectionUtils;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Description: 护理类服务指令计划API
|
||||
|
|
@ -285,27 +282,70 @@ public class CareDirectiveApi {
|
|||
//给数据加标识
|
||||
if (!CollectionUtils.isEmpty(history)) {
|
||||
history.stream().forEach(item -> {
|
||||
if("N".equals(item.getIzStart())) {
|
||||
//未开始
|
||||
if ("N".equals(item.getIzStart())) {
|
||||
// 未开始
|
||||
item.setExecuteStatus("hisUnExe");
|
||||
}else{
|
||||
//判断是否超时
|
||||
//如果izStrart = 'Y' && beginTime > (endTime + 容错时长) 也是超时
|
||||
// {
|
||||
// //如果没点结束
|
||||
// if("N".equals(item.getIzFinish())){
|
||||
// //todo 超时 (beginTime + serviceDura + 容错时长) > now()
|
||||
// }
|
||||
// }
|
||||
} else {
|
||||
// 已开始
|
||||
Date ygkssj = item.getStartTime(); // 应该开始时间
|
||||
Date sjkssj = item.getBeginTime(); // 实际开始时间
|
||||
Date sjjssj = item.getFinishTime(); // 实际结束时间
|
||||
String rcsc = item.getServiceAllowedTimeout(); // 容错时长(分钟)
|
||||
String fwsc = item.getServiceDuration(); // 服务时长(分钟)
|
||||
|
||||
// 判断是否超时(实际开始时间 > 应该开始时间 + 容错时长)
|
||||
if (ygkssj != null && sjkssj != null && rcsc != null) {
|
||||
try {
|
||||
int rcscInt = Integer.parseInt(rcsc);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(ygkssj);
|
||||
calendar.add(Calendar.MINUTE, rcscInt);
|
||||
Date deadlineTime = calendar.getTime(); // 最晚开始时间
|
||||
|
||||
if (sjkssj.after(deadlineTime)) {
|
||||
// 实际开始时间超过最晚开始时间
|
||||
item.setExecuteStatus("hisTimeOut");
|
||||
return; // 进行下一条处理
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
// 容错时长格式错误
|
||||
e.printStackTrace();
|
||||
item.setExecuteStatus("hisOk");
|
||||
}
|
||||
}
|
||||
|
||||
//已开始
|
||||
if ("Y".equals(item.getIzTimeout())) {
|
||||
//超时
|
||||
item.setExecuteStatus("hisTimeOut");
|
||||
}else{
|
||||
//未超时
|
||||
// 计算实际服务时长
|
||||
long sjfwsc = 0;
|
||||
if (sjkssj != null) {
|
||||
Date sjjssjDate = sjjssj;
|
||||
if (sjjssjDate == null) {
|
||||
// 如果实际结束时间为空,使用当前时间
|
||||
sjjssjDate = new Date();
|
||||
}
|
||||
|
||||
// 计算分钟数差值
|
||||
long diffInMillis = sjjssjDate.getTime() - sjkssj.getTime();
|
||||
sjfwsc = diffInMillis / (1000 * 60);
|
||||
}
|
||||
|
||||
// 判断实际服务时长是否超过服务时长
|
||||
if (fwsc != null) {
|
||||
try {
|
||||
int fwscInt = Integer.parseInt(fwsc);
|
||||
if (sjfwsc > fwscInt) {
|
||||
// 实际服务时长超过预定服务时长
|
||||
item.setExecuteStatus("hisTimeOut");
|
||||
} else {
|
||||
// 其他情况,视为成功
|
||||
item.setExecuteStatus("hisOk");
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
// 服务时长格式错误,视为成功
|
||||
item.setExecuteStatus("hisOk");
|
||||
}
|
||||
} else {
|
||||
// 没有服务时长配置,视为成功
|
||||
item.setExecuteStatus("hisOk");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue