jiangping
2024-10-09 c5cc7da07c7f202f336468c0cd0d2789b4775b03
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformBooksServiceImpl.java
@@ -11,13 +11,12 @@
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.DateUtil;
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.ApproveTemplMapper;
import com.doumee.dao.business.MemberMapper;
import com.doumee.dao.business.PlatformBooksMapper;
import com.doumee.dao.business.PlatformReasonMapper;
import com.doumee.dao.business.*;
import com.doumee.dao.business.join.ApproveJoinMapper;
import com.doumee.dao.business.model.*;
import com.doumee.dao.business.vo.ApproveDataVO;
import com.doumee.dao.system.join.NoticesJoinMapper;
import com.doumee.dao.web.reqeust.ConfirmTaskDTO;
import com.doumee.dao.web.reqeust.PlatformBooksApplyDTO;
import com.doumee.dao.web.reqeust.PlatformBooksCheckNumDTO;
import com.doumee.dao.web.reqeust.RevokeDTO;
@@ -52,6 +51,9 @@
    private PlatformBooksMapper platformBooksMapper;
    @Autowired
    private NoticesJoinMapper noticesJoinMapper;
    @Autowired
    private ApproveTemplMapper approveTemplMapper;
    @Autowired
@@ -68,6 +70,9 @@
    @Autowired
    private ApproveJoinMapper approveJoinMapper;
    @Autowired
    private CarsMapper carsMapper;
    @Override
@@ -158,16 +163,24 @@
                .eq(pageWrap.getModel().getPlateNum() != null, PlatformBooks::getPlateNum, pageWrap.getModel().getPlateNum())
                .eq(pageWrap.getModel().getDriverPhone() != null, PlatformBooks::getDriverPhone, pageWrap.getModel().getDriverPhone())
                .ge(pageWrap.getModel().getQueryDate() != null, PlatformBooks::getCreateDate, pageWrap.getModel().getQueryDate())
                .ge(pageWrap.getModel().getArriveDateStart() != null, PlatformBooks::getArriveDate, Utils.Date.getStart(pageWrap.getModel().getArriveDateStart()))
                .le(pageWrap.getModel().getArriveDateEnd() != null, PlatformBooks::getArriveDate, Utils.Date.getEnd(pageWrap.getModel().getArriveDateEnd()))
                .orderByDesc(PlatformBooks::getCreateDate)
        ;
        for(PageWrap.SortData sortData: pageWrap.getSorts()) {
            if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
                queryWrapper.orderByDesc(sortData.getProperty());
            } else {
                queryWrapper.orderByAsc(sortData.getProperty());
        PageData<PlatformBooks> pageData = PageData.from(platformBooksMapper.selectPage(page, queryWrapper));
        for (PlatformBooks platformBooks:pageData.getRecords()) {
            if(Constants.equalsInteger(platformBooks.getStatus(),Constants.ONE)||Constants.equalsInteger(platformBooks.getStatus(),Constants.ZERO)){
                String auditName = approveService.getApproveUserName(platformBooks.getId(),Constants.approveObjectType.reason);
                platformBooks.setAuditName(auditName);
            }
        }
        return PageData.from(platformBooksMapper.selectPage(page, queryWrapper));
        return pageData;
    }
    @Override
    public long count(PlatformBooks platformBooks) {
@@ -228,6 +241,10 @@
        if(Objects.isNull(platformReason)|| !Constants.equalsInteger(platformReason.getIsdeleted(),Constants.ZERO)){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"入园原因信息异常,请刷新重试");
        }
        //查询车辆是否为自有车
        if(carsMapper.selectCount(new QueryWrapper<Cars>().lambda().eq(Cars::getIsdeleted,Constants.ZERO).eq(Cars::getCode,platformBooksApplyDTO.getCarCodeFront()))>Constants.ZERO){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"["+platformBooksApplyDTO.getCarCodeFront()+"]属于内部车辆,无法预约");
        };
        ApproveTempl approveTempl = approveTemplMapper.selectById(platformReason.getId());
        if(Objects.isNull(approveTempl)){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未配置审批流,请联系管理员");
@@ -241,6 +258,7 @@
        platformBooks.setIsdeleted(Constants.ZERO);
        platformBooks.setStatus(Constants.ZERO);
        platformBooks.setDriverId(platformBooksApplyDTO.getUserId());
        platformBooks.setEditDate(new Date());
        platformBooksMapper.insert(platformBooks);
        //创建审批流信息
@@ -250,7 +268,7 @@
//    @Override
    @Override
    @Transactional(rollbackFor = {BusinessException.class,Exception.class})
    public Integer edit(PlatformBooksApplyDTO platformBooksApplyDTO){
        if(Objects.isNull(platformBooksApplyDTO)
@@ -265,11 +283,13 @@
                || StringUtils.isBlank(platformBooksApplyDTO.getDriverPhone())
                || StringUtils.isBlank(platformBooksApplyDTO.getDriverName())
                || StringUtils.isBlank(platformBooksApplyDTO.getTransportImg())
                || Objects.isNull(platformBooksApplyDTO.getReasonId())
                || StringUtils.isBlank(platformBooksApplyDTO.getInReason())
        ){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        //查询车辆是否为自有车
        if(carsMapper.selectCount(new QueryWrapper<Cars>().lambda().eq(Cars::getIsdeleted,Constants.ZERO).eq(Cars::getCode,platformBooksApplyDTO.getCarCodeFront()))>Constants.ZERO){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"["+platformBooksApplyDTO.getCarCodeFront()+"]属于内部车辆,无法预约");
        };
        PlatformBooks platformBooks = platformBooksMapper.selectById(platformBooksApplyDTO.getId());
        if(Objects.isNull(platformBooks)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY);
@@ -279,7 +299,9 @@
        }
        BeanUtils.copyProperties(platformBooksApplyDTO,platformBooks);
        platformBooks.setEditDate(new Date());
        platformBooksMapper.insert(platformBooks);
        platformBooks.setReasonId(null);
        platformBooks.setInReason(null);
        platformBooksMapper.updateById(platformBooks);
        return platformBooks.getId();
    }
@@ -358,7 +380,6 @@
                .eq(Approve::getObjId,revokeDTO.getId())
        );
    }
}