服务指令预览调整超时逻辑
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 org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 护理类服务指令计划API
|
* @Description: 护理类服务指令计划API
|
||||||
|
|
@ -285,27 +282,70 @@ public class CareDirectiveApi {
|
||||||
//给数据加标识
|
//给数据加标识
|
||||||
if (!CollectionUtils.isEmpty(history)) {
|
if (!CollectionUtils.isEmpty(history)) {
|
||||||
history.stream().forEach(item -> {
|
history.stream().forEach(item -> {
|
||||||
if("N".equals(item.getIzStart())) {
|
if ("N".equals(item.getIzStart())) {
|
||||||
//未开始
|
// 未开始
|
||||||
item.setExecuteStatus("hisUnExe");
|
item.setExecuteStatus("hisUnExe");
|
||||||
}else{
|
} else {
|
||||||
//判断是否超时
|
// 已开始
|
||||||
//如果izStrart = 'Y' && beginTime > (endTime + 容错时长) 也是超时
|
Date ygkssj = item.getStartTime(); // 应该开始时间
|
||||||
// {
|
Date sjkssj = item.getBeginTime(); // 实际开始时间
|
||||||
// //如果没点结束
|
Date sjjssj = item.getFinishTime(); // 实际结束时间
|
||||||
// if("N".equals(item.getIzFinish())){
|
String rcsc = item.getServiceAllowedTimeout(); // 容错时长(分钟)
|
||||||
// //todo 超时 (beginTime + serviceDura + 容错时长) > now()
|
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())) {
|
long sjfwsc = 0;
|
||||||
//超时
|
if (sjkssj != null) {
|
||||||
item.setExecuteStatus("hisTimeOut");
|
Date sjjssjDate = sjjssj;
|
||||||
}else{
|
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");
|
item.setExecuteStatus("hisOk");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue