diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index 1b0c172046..9035d81861 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -150,6 +150,9 @@ public enum EpmetErrorCode { // 删除可预约事项存在预约记录时提示 MATTER_EXISTS_APPOINTMENT_ERROR(8526, "尚有未履行的预约存在,请确认后操作"), + // 预约某事项在某时间段存在记录时 + APPOINTMENT_TIME_ERROR(8527, "该时间段已被预约,请选择其他时间段"), + // 该错误不会提示给前端,只是后端传输错误信息用。 ACCESS_SQL_FILTER_MISSION_ARGS(8701, "缺少生成权限过滤SQL所需参数"), OPER_ADD_CUSTOMER_ROOT_AGENCY_ERROR(8702, "添加客户根级组织失败"), diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AppointmentRecordFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AppointmentRecordFormDTO.java index 089a7826a3..ef3783f1fa 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AppointmentRecordFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AppointmentRecordFormDTO.java @@ -21,6 +21,7 @@ public class AppointmentRecordFormDTO implements Serializable { @NotBlank(message = "matterId不能为空",groups = AppointmentRecordForm.class) private String matterId; + @NotBlank(message = "date不能为空",groups = AppointmentRecordForm.class) private String date; public AppointmentRecordFormDTO() { diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AppointmentRecordResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AppointmentRecordResultDTO.java index 6d3c0452a1..ae76c66052 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AppointmentRecordResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AppointmentRecordResultDTO.java @@ -1,8 +1,11 @@ package com.epmet.dto.result; +import com.epmet.commons.tools.constant.NumConstant; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.io.Serializable; +import java.util.ArrayList; import java.util.List; /** @@ -41,4 +44,16 @@ public class AppointmentRecordResultDTO implements Serializable { * 预约时间 */ private List appointmentTime; + + @JsonIgnore + private String timeId; + + public AppointmentRecordResultDTO() { + this.sort = NumConstant.ZERO; + this.matterName = ""; + this.appointmentName = ""; + this.appointmentPhone = ""; + this.remark = ""; + this.appointmentTime = new ArrayList<>(); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcMatterAppointmentRecordDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcMatterAppointmentRecordDao.java index 98a08ee373..f8c02d5429 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcMatterAppointmentRecordDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcMatterAppointmentRecordDao.java @@ -18,8 +18,12 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.AppointmentRecordResultDTO; import com.epmet.entity.IcMatterAppointmentRecordEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 事项预约记录 @@ -29,5 +33,14 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface IcMatterAppointmentRecordDao extends BaseDao { - + + /** + * @Description 查询预约列表 + * @param matterId + * @param date + * @author zxc + * @date 2021/11/23 1:55 下午 + */ + List appointmentRecord(@Param("matterId")String matterId,@Param("date")String date); + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcPartyServiceCenterServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcPartyServiceCenterServiceImpl.java index 2390106303..382e65c112 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcPartyServiceCenterServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcPartyServiceCenterServiceImpl.java @@ -33,7 +33,6 @@ import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; -import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.PartyServiceCenterConstant; import com.epmet.dao.IcMatterAppointmentRecordDao; import com.epmet.dao.IcPartyServiceCenterDao; @@ -60,8 +59,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; - -import static com.epmet.commons.tools.utils.DateUtils.DATE_PATTERN; +import java.util.concurrent.atomic.AtomicReference; /** * 党群服务中心 @@ -233,8 +231,21 @@ public class IcPartyServiceCenterServiceImpl extends BaseServiceImpl l = new LambdaQueryWrapper<>(); + l.eq(IcMatterAppointmentRecordEntity::getMatterId,formDTO.getMatterId()) + .eq(IcMatterAppointmentRecordEntity::getAppointmentDate,formDTO.getAppointmentDate()) + .eq(IcMatterAppointmentRecordEntity::getStatus,PartyServiceCenterConstant.APPOINTMENT_STATUS_APPOINTING) + .eq(BaseEpmetEntity::getDelFlag,NumConstant.ZERO); + List records = matterAppointmentRecordDao.selectList(l); + if (CollectionUtils.isNotEmpty(records)){ + List timeIds = new ArrayList<>(); + records.forEach(r -> { + timeIds.addAll(Arrays.asList(r.getTimeId().split(","))); + }); + if (timeIds.retainAll(Arrays.asList(formDTO.getTimeId().split(",")))){ + throw new RenException(EpmetErrorCode.APPOINTMENT_TIME_ERROR.getCode()); + } + } CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, tokenDto.getUserId()); if (null == staffInfo){ throw new RenException(String.format("查询人员{%s}信息失败",tokenDto.getUserId())); @@ -346,7 +357,24 @@ public class IcPartyServiceCenterServiceImpl extends BaseServiceImpl appointmentRecord(AppointmentRecordFormDTO formDTO) { - return null; + List result = matterAppointmentRecordDao.appointmentRecord(formDTO.getMatterId(), formDTO.getDate()); + if (CollectionUtils.isEmpty(result)){ + return new ArrayList<>(); + } + IcPartyServiceCenterMatterEntity matter = matterService.selectById(formDTO.getMatterId()); + if (null == matter){ + throw new RenException("事项不存在..."); + } + List timeList = getTimeList(matter.getStartTime(), matter.getEndTime(), NumConstant.THIRTY); + AtomicReference sort = new AtomicReference<>(NumConstant.ONE); + result.forEach(r -> { + r.setSort(sort.getAndSet(sort.get() + NumConstant.ONE)); + List time = new ArrayList<>(); + List list = Arrays.asList(r.getTimeId().split(",")); + list.forEach(l -> timeList.stream().filter( t -> l.equals(t.getTimeId())).forEach(t -> time.add(t.getTime()))); + r.setAppointmentTime(time); + }); + return result; } public List getTimeList(String start,String end,Integer interval){ diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcMatterAppointmentRecordDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcMatterAppointmentRecordDao.xml index 0602d34e44..c77ebceca6 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcMatterAppointmentRecordDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcMatterAppointmentRecordDao.xml @@ -3,4 +3,19 @@ + + \ No newline at end of file