|
|
|
@ -83,41 +83,64 @@ public class SchedulingServiceImpl implements SchedulingService { |
|
|
|
} else { |
|
|
|
throw new RuntimeException("工厂和部门有误!"); |
|
|
|
} |
|
|
|
Date startDate = data.getStartDate(); |
|
|
|
Date endDate = data.getEndDate(); |
|
|
|
String checkbox1 = Objects.toString(data.getCheckbox1()); |
|
|
|
String checkbox2 = Objects.toString(data.getCheckbox2()); |
|
|
|
Calendar cal = Calendar.getInstance(); |
|
|
|
cal.setTime(startDate); |
|
|
|
while (!cal.getTime().after(endDate)) { |
|
|
|
int day = cal.get(Calendar.DAY_OF_WEEK); |
|
|
|
if ((day == Calendar.SATURDAY && !"true".equals(checkbox1))){ |
|
|
|
if ("true".equals(data.getInsertType())){ |
|
|
|
Date startDate = data.getStartDate(); |
|
|
|
Date endDate = data.getEndDate(); |
|
|
|
String checkbox1 = Objects.toString(data.getCheckbox1()); |
|
|
|
String checkbox2 = Objects.toString(data.getCheckbox2()); |
|
|
|
Calendar cal = Calendar.getInstance(); |
|
|
|
cal.setTime(startDate); |
|
|
|
while (!cal.getTime().after(endDate)) { |
|
|
|
int day = cal.get(Calendar.DAY_OF_WEEK); |
|
|
|
if ((day == Calendar.SATURDAY && !"true".equals(checkbox1))){ |
|
|
|
cal.add(Calendar.DATE, 1); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if ((day == Calendar.SUNDAY && !"true".equals(checkbox2))){ |
|
|
|
cal.add(Calendar.DATE, 1); |
|
|
|
continue; |
|
|
|
} |
|
|
|
data.setDate(cal.getTime()); |
|
|
|
|
|
|
|
try { |
|
|
|
//新增主表信息 |
|
|
|
schedulingMapper.saveSchedulingHeader(data); |
|
|
|
}catch (Exception e){ |
|
|
|
throw new RuntimeException("保存失败,请检查是否存在重复的班次编码和日期"); |
|
|
|
} |
|
|
|
//设置子表参数 |
|
|
|
SchedulingRecordData schedulingRecordData = new SchedulingRecordData(); |
|
|
|
schedulingRecordData.setHeadId(data.getId()); |
|
|
|
schedulingRecordData.setIsHoliday("N"); |
|
|
|
List<EamAdminData> peopleList = data.getPeopleList(); |
|
|
|
for (int i = 0;i<peopleList.size();i++){ |
|
|
|
schedulingRecordData.setAdminId(peopleList.get(i).getAdminID()); |
|
|
|
schedulingRecordData.setAdminName(peopleList.get(i).getAdminName()); |
|
|
|
schedulingMapper.saveSchedulingRecord(schedulingRecordData); |
|
|
|
} |
|
|
|
cal.add(Calendar.DATE, 1); |
|
|
|
continue; |
|
|
|
} |
|
|
|
if ((day == Calendar.SUNDAY && !"true".equals(checkbox2))){ |
|
|
|
cal.add(Calendar.DATE, 1); |
|
|
|
continue; |
|
|
|
} |
|
|
|
data.setDate(cal.getTime()); |
|
|
|
|
|
|
|
try { |
|
|
|
//新增主表信息 |
|
|
|
schedulingMapper.saveSchedulingHeader(data); |
|
|
|
}catch (Exception e){ |
|
|
|
return R.error("保存失败,请检查是否存在重复的班次编码和日期"); |
|
|
|
} |
|
|
|
//设置子表参数 |
|
|
|
SchedulingRecordData schedulingRecordData = new SchedulingRecordData(); |
|
|
|
schedulingRecordData.setHeadId(data.getId()); |
|
|
|
schedulingRecordData.setIsHoliday("N"); |
|
|
|
List<EamAdminData> peopleList = data.getPeopleList(); |
|
|
|
for (int i = 0;i<peopleList.size();i++){ |
|
|
|
schedulingRecordData.setAdminId(peopleList.get(i).getAdminID()); |
|
|
|
schedulingRecordData.setAdminName(peopleList.get(i).getAdminName()); |
|
|
|
schedulingMapper.saveSchedulingRecord(schedulingRecordData); |
|
|
|
} |
|
|
|
cal.add(Calendar.DATE, 1); |
|
|
|
}else { |
|
|
|
List<Date> selectedDates = data.getSelectedDates(); |
|
|
|
selectedDates.forEach(date1 -> { |
|
|
|
data.setDate(date1); |
|
|
|
try { |
|
|
|
//新增主表信息 |
|
|
|
schedulingMapper.saveSchedulingHeader(data); |
|
|
|
}catch (Exception e){ |
|
|
|
throw new RuntimeException("保存失败,请检查是否存在重复的班次编码和日期"); |
|
|
|
} |
|
|
|
//设置子表参数 |
|
|
|
SchedulingRecordData schedulingRecordData = new SchedulingRecordData(); |
|
|
|
schedulingRecordData.setHeadId(data.getId()); |
|
|
|
schedulingRecordData.setIsHoliday("N"); |
|
|
|
List<EamAdminData> peopleList = data.getPeopleList(); |
|
|
|
for (int i = 0;i<peopleList.size();i++){ |
|
|
|
schedulingRecordData.setAdminId(peopleList.get(i).getAdminID()); |
|
|
|
schedulingRecordData.setAdminName(peopleList.get(i).getAdminName()); |
|
|
|
schedulingMapper.saveSchedulingRecord(schedulingRecordData); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
return R.ok(); |
|
|
|
|