|
@@ -8,7 +8,9 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import com.ruoyi.common.core.text.Convert;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
+import com.ruoyi.qdtl.domain.PlanSchedule;
|
|
|
import com.ruoyi.qdtl.domain.PlanUser;
|
|
|
+import com.ruoyi.qdtl.domain.TlInspectionLocation;
|
|
|
import com.ruoyi.qdtl.domain.TlInspectionPlan;
|
|
|
import com.ruoyi.qdtl.domain.TlInspectionPlanUser;
|
|
|
import com.ruoyi.qdtl.mapper.TlInspectionPlanMapper;
|
|
@@ -22,7 +24,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 巡检计划管理Service业务层处理
|
|
@@ -141,6 +145,59 @@ public class TlInspectionPlanServiceImpl implements ITlInspectionPlanService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 获取排班表
|
|
|
+ *
|
|
|
+ * @param nickName
|
|
|
+ * @param startDate
|
|
|
+ * @param endDate
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<PlanSchedule> getSchedule(String nickName, String startDate, String endDate) {
|
|
|
+ // 如果startDate或者endDate为空,则默认展示最近7天的
|
|
|
+ if (StrUtil.hasBlank(startDate, endDate)) {
|
|
|
+ startDate = DateUtil.today();
|
|
|
+ endDate = DateUtil.formatDate(DateUtil.offsetDay(new Date(), 7));
|
|
|
+ }
|
|
|
+ List<PlanSchedule> result = new ArrayList<>();
|
|
|
+ List<TlInspectionPlan> list = tlInspectionPlanMapper.queryByDatePeriod(startDate, endDate);
|
|
|
+ // 解析list
|
|
|
+ for (TlInspectionPlan inspectionPlan : list) {
|
|
|
+ PlanSchedule planSchedule = new PlanSchedule();
|
|
|
+ List<TlInspectionLocation> lineLocations = tlInspectionLocationService.queryLocationByLineId(inspectionPlan.getLineId());
|
|
|
+ planSchedule.setEffectDate(inspectionPlan.getStartDate() + "~" + inspectionPlan.getEndDate());
|
|
|
+ planSchedule.setLocations(lineLocations.stream().map(TlInspectionLocation::getLocationName).collect(Collectors.toList()));
|
|
|
+ planSchedule.setTimeUnit(StrUtil.split(inspectionPlan.getTimeUnit(), ","));
|
|
|
+ // 确定当前时间范围内的人员
|
|
|
+ List<DateTime> dateTimes = DateUtil.rangeToList(DateUtil.parseDate(startDate), DateUtil.parseDate(endDate), DateField.DAY_OF_YEAR);
|
|
|
+ List<PlanSchedule.PlanDetail> planDetails = new ArrayList<>();
|
|
|
+ // 查询计划的人员
|
|
|
+ TlInspectionPlanUser tlInspectionPlanUser = new TlInspectionPlanUser();
|
|
|
+ tlInspectionPlanUser.setPlanId(inspectionPlan.getId());
|
|
|
+ if (StrUtil.isNotBlank(nickName)) {
|
|
|
+ tlInspectionPlanUser.setNickName(nickName);
|
|
|
+ }
|
|
|
+ List<TlInspectionPlanUser> users = tlInspectionPlanUserService.selectTlInspectionPlanUserList(tlInspectionPlanUser);
|
|
|
+ String userText = users.stream().map(TlInspectionPlanUser::getNickName).collect(Collectors.joining("、"));
|
|
|
+ for (DateTime dateTime : dateTimes) {
|
|
|
+ PlanSchedule.PlanDetail planDetail = new PlanSchedule.PlanDetail();
|
|
|
+ planDetail.setQueryDate(DateUtil.formatDate(dateTime));
|
|
|
+ int week = DateUtil.dayOfWeek(dateTime);
|
|
|
+ planDetail.setWeek(week);
|
|
|
+ if (CollUtil.contains(StrUtil.split(inspectionPlan.getWeeks(), ","), Convert.toStr(week))) {
|
|
|
+ planDetail.setNickName(userText);
|
|
|
+ } else {
|
|
|
+ planDetail.setNickName("");
|
|
|
+ }
|
|
|
+ planDetails.add(planDetail);
|
|
|
+ }
|
|
|
+ planSchedule.setPlanDetails(planDetails);
|
|
|
+ result.add(planSchedule);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 校验计划中用户是否存在重复的
|
|
|
*
|
|
|
* @param tlInspectionPlan 待校验的计划数据
|