Commit bc7b7ba8 authored by 李驰骋's avatar 李驰骋

报工工时BUG修复(日历查询问题)

parent dbb9ff0f
...@@ -608,7 +608,7 @@ public class ProFeedbackServiceImpl implements IProFeedbackService { ...@@ -608,7 +608,7 @@ public class ProFeedbackServiceImpl implements IProFeedbackService {
} else { } else {
breakTimeSum = proStartWorks.stream().collect(Collectors.summarizingLong(ProStartWork::getBreakTimeSec)).getSum(); breakTimeSum = proStartWorks.stream().collect(Collectors.summarizingLong(ProStartWork::getBreakTimeSec)).getSum();
workTimeSum = proStartWorks.stream().collect(Collectors.summarizingLong(ProStartWork::getWorkTimeSec)).getSum() - breakTimeSum; workTimeSum = proStartWorks.stream().collect(Collectors.summarizingLong(ProStartWork::getWorkTimeSec)).getSum();
} }
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
......
...@@ -237,7 +237,7 @@ public class ProStartWorkServiceImpl implements IProStartWorkService { ...@@ -237,7 +237,7 @@ public class ProStartWorkServiceImpl implements IProStartWorkService {
} }
startWork.setEndDate(new Date()); startWork.setEndDate(new Date());
Map<String, Long> map = computeWorkTime(startWork, proTaskWorkunitMapper.selectListByQw(new QueryWrapper<ProTaskWorkunit>().eq("task_id", proTask.getTaskId())).get(0).getWorkunitId()); Map<String, Long> map = this.computeWorkTime(startWork, proTaskWorkunitMapper.selectListByQw(new QueryWrapper<ProTaskWorkunit>().eq("task_id", proTask.getTaskId())).get(0).getWorkunitId());
startWork.setWorkTimeSec(DataUtil.getNormalData(map.get("workTimeSec"), Long.class)); startWork.setWorkTimeSec(DataUtil.getNormalData(map.get("workTimeSec"), Long.class));
startWork.setBreakTimeSec(DataUtil.getNormalData(map.get("breakTimeSec"), Long.class)); startWork.setBreakTimeSec(DataUtil.getNormalData(map.get("breakTimeSec"), Long.class));
...@@ -252,9 +252,9 @@ public class ProStartWorkServiceImpl implements IProStartWorkService { ...@@ -252,9 +252,9 @@ public class ProStartWorkServiceImpl implements IProStartWorkService {
QueryWrapper<CalPlanWorkunit> calPlanWorkunitQueryWrapper = new QueryWrapper<>(); QueryWrapper<CalPlanWorkunit> calPlanWorkunitQueryWrapper = new QueryWrapper<>();
Date startDate = startWork.getStartDate(); Date startDate = startWork.getStartDate();
Date endDate = startWork.getEndDate(); Date endDate = startWork.getEndDate();
calPlanWorkunitQueryWrapper.between("start_date", startDate, endDate).eq("rest_flag", 0).eq("workunit_id", workunitId) calPlanWorkunitQueryWrapper.lt("start_date", startDate).gt("end_date", startDate).eq("rest_flag", 0).eq("workunit_id", workunitId)
.or() .or()
.between("end_date", startDate, endDate).eq("rest_flag", 0).eq("workunit_id", workunitId); .lt("start_date", endDate).gt("end_date", endDate).eq("rest_flag", 0).eq("workunit_id", workunitId);
List<CalPlanWorkunit> calPlanWorkunits = calPlanWorkunitService.selectListByQw(calPlanWorkunitQueryWrapper); List<CalPlanWorkunit> calPlanWorkunits = calPlanWorkunitService.selectListByQw(calPlanWorkunitQueryWrapper);
return this.computeWorkTime(startWork, calPlanWorkunits, workunitId); return this.computeWorkTime(startWork, calPlanWorkunits, workunitId);
} }
......
package com.bs.mes.pro; package com.bs.mes.pro;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.ximai.common.utils.data.DataUtil;
import com.ximai.mes.cal.domain.CalPlanWorkunit; import com.ximai.mes.cal.domain.CalPlanWorkunit;
import com.ximai.mes.pro.domain.ProStartWork; import com.ximai.mes.pro.domain.ProStartWork;
import com.ximai.mes.pro.schedule.Equipment; import com.ximai.mes.pro.schedule.Equipment;
...@@ -61,6 +62,21 @@ public class ProStartWorkServiceImplTest { ...@@ -61,6 +62,21 @@ public class ProStartWorkServiceImplTest {
Assert.assertEquals((228+240)*60, rst.get("workTimeSec").longValue()); Assert.assertEquals((228+240)*60, rst.get("workTimeSec").longValue());
Assert.assertEquals((proStartWork.getEndDate().getTime()-proStartWork.getStartDate().getTime())/1000-rst.get("workTimeSec").longValue(), Assert.assertEquals((proStartWork.getEndDate().getTime()-proStartWork.getStartDate().getTime())/1000-rst.get("workTimeSec").longValue(),
rst.get("breakTimeSec").longValue()); rst.get("breakTimeSec").longValue());
calPlanWorkunits.add(new CalPlanWorkunit(){
{
setStartDate(DateUtil.parse("2024-12-03 08:00","yyyy-MM-dd HH:mm"));
setEndDate(DateUtil.parse("2024-12-03 12:00","yyyy-MM-dd HH:mm"));
};
});
//测试3 时间精确到秒
proStartWork.setStartDate(DateUtil.parse("2024-12-03 10:19:36","yyyy-MM-dd HH:mm:ss"));
proStartWork.setEndDate(DateUtil.parse("2024-12-03 10:20:42","yyyy-MM-dd HH:mm:ss"));
rst = (Map) methods.invoke(proStartWorkService, proStartWork, calPlanWorkunits, 0l);
Assert.assertEquals(60+6, rst.get("workTimeSec").longValue());
Assert.assertEquals(0l,
rst.get("breakTimeSec").longValue());
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment