package com.gkhy.safePlatform.specialWork.service.baseService.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.gkhy.safePlatform.commons.enums.ResultCodes;
|
import com.gkhy.safePlatform.commons.exception.BusinessException;
|
import com.gkhy.safePlatform.specialWork.entity.SpecialWorkAppointmentInfo;
|
import com.gkhy.safePlatform.specialWork.enums.SpecialWorkAppointmentStatusEnum;
|
import com.gkhy.safePlatform.specialWork.model.bo.WorkStatisticsBO;
|
import com.gkhy.safePlatform.specialWork.model.query.SpecialWorkAppointmentQuery;
|
import com.gkhy.safePlatform.specialWork.repository.SpecialWorkAppointmentInfoRepository;
|
import com.gkhy.safePlatform.specialWork.service.baseService.SpecialWorkAppointmentInfoService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.time.LocalDateTime;
|
import java.util.Date;
|
import java.util.List;
|
|
@Service("SpecialWorkAppointmentInfoService")
|
public class SpecialWorkAppointmentInfoServiceImpl extends ServiceImpl<SpecialWorkAppointmentInfoRepository, SpecialWorkAppointmentInfo> implements SpecialWorkAppointmentInfoService {
|
@Autowired
|
private SpecialWorkAppointmentInfoRepository repository;
|
|
|
/**
|
* 新增
|
* @param appointmentInfo
|
* @return
|
*/
|
@Override
|
public int saveOne(SpecialWorkAppointmentInfo appointmentInfo) {
|
appointmentInfo.setGmtCreate(LocalDateTime.now());
|
appointmentInfo.setStatus(SpecialWorkAppointmentStatusEnum.VALID.getCode());
|
return baseMapper.saveOne(appointmentInfo);
|
}
|
|
/**
|
* 修改
|
* @param appointmentInfo
|
* @return
|
*/
|
@Override
|
public int updateOne(SpecialWorkAppointmentInfo appointmentInfo) {
|
if (appointmentInfo.getId() == null) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
appointmentInfo.setGmtModified(LocalDateTime.now());
|
return baseMapper.updateOne(appointmentInfo);
|
}
|
|
/**
|
* 删除
|
* @param id
|
* @return
|
*/
|
@Override
|
public int updateStatus(Long id) {
|
if (id == null) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
return baseMapper.updateStatus(id,SpecialWorkAppointmentStatusEnum.ABANDONED.getCode());
|
}
|
/**
|
* 批量删除
|
* @param ids
|
* @return
|
*/
|
@Override
|
public int updateStatusByIds(List<Long> ids) {
|
if (ids == null || ids.size()==0) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
return baseMapper.updateStatusByIds(ids,SpecialWorkAppointmentStatusEnum.ABANDONED.getCode());
|
}
|
/**
|
* 查询一条
|
* @param id
|
* @return
|
*/
|
@Override
|
public SpecialWorkAppointmentInfo queryById(Long id) {
|
if (id == null) {
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
return baseMapper.queryById(id,SpecialWorkAppointmentStatusEnum.VALID.getCode());
|
}
|
|
/**
|
* 分页查询
|
* @param page
|
* @param query
|
* @return
|
*/
|
@Override
|
public List<SpecialWorkAppointmentInfo> listByPage(IPage<SpecialWorkAppointmentInfo> page, SpecialWorkAppointmentQuery query) {
|
query.setStatus(SpecialWorkAppointmentStatusEnum.VALID.getCode());
|
return baseMapper.listByConditions(page,query);
|
}
|
|
/**
|
* 列表查询
|
* @param query
|
* @return
|
*/
|
@Override
|
public List<SpecialWorkAppointmentInfo> list(SpecialWorkAppointmentQuery query) {
|
query.setStatus(SpecialWorkAppointmentStatusEnum.VALID.getCode());
|
return baseMapper.listByConditions(query);
|
}
|
|
@Override
|
public Long getCountByDepAndTime(Long depId, Date appointmentTime) {
|
if(null == depId || null == appointmentTime){
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
Long count = baseMapper.selectCount(new LambdaQueryWrapper<SpecialWorkAppointmentInfo>()
|
.eq(SpecialWorkAppointmentInfo::getApplyDepId, depId)
|
.eq(SpecialWorkAppointmentInfo::getAppointmentTime, appointmentTime)
|
.eq(SpecialWorkAppointmentInfo::getStatus, SpecialWorkAppointmentStatusEnum.VALID.getCode())
|
);
|
return count;
|
}
|
|
@Override
|
public List<WorkStatisticsBO> statisticsAppointment(SpecialWorkAppointmentQuery query) {
|
return baseMapper.statisticsAppointment(query,SpecialWorkAppointmentStatusEnum.VALID.getCode());
|
}
|
}
|