jiangping
2025-03-27 e4a06e0730dc0aa6ced97cbb3362d6b8ef473d39
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformBooksServiceImpl.java
@@ -1,11 +1,13 @@
package com.doumee.service.business.impl;
import com.alibaba.fastjson.JSONObject;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.model.LoginUserInfo;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.dao.business.dao.UserActionMapper;
import com.doumee.service.business.third.model.LoginUserInfo;
import com.doumee.service.business.third.model.PageData;
import com.doumee.service.business.third.model.PageWrap;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.DateUtil;
import com.doumee.core.utils.SmsConstants;
@@ -13,13 +15,18 @@
import com.doumee.core.wx.wxPlat.WxPlatConstants;
import com.doumee.core.wx.wxPlat.WxPlatNotice;
import com.doumee.dao.business.*;
import com.doumee.dao.business.dao.MemberMapper;
import com.doumee.dao.business.dao.SmsConfigMapper;
import com.doumee.dao.business.dao.SmsEmailMapper;
import com.doumee.dao.business.join.ApproveJoinMapper;
import com.doumee.dao.business.model.*;
import com.doumee.dao.business.vo.ApproveDataVO;
import com.doumee.dao.business.model.Member;
import com.doumee.dao.system.SystemUserMapper;
import com.doumee.dao.system.join.NoticesJoinMapper;
import com.doumee.dao.system.model.Notices;
import com.doumee.dao.system.model.SystemUser;
import com.doumee.dao.web.reqeust.PlatformBooksApplyDTO;
import com.doumee.dao.web.reqeust.PlatformBooksCheckNumDTO;
import com.doumee.dao.web.reqeust.RevokeDTO;
@@ -53,6 +60,10 @@
    @Autowired
    private PlatformBooksMapper platformBooksMapper;
    @Autowired
    private UserActionMapper userActionMapper;
    @Autowired
    private PlatformJobMapper platformJobMapper;
    @Autowired
    private NoticesJoinMapper noticesJoinMapper;
@@ -68,6 +79,9 @@
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
    @Autowired
    private SystemUserMapper systemUserMapper;
    @Autowired
    private ApproveService approveService;
@@ -93,6 +107,9 @@
    @Autowired
    private WxNoticeConfigMapper wxNoticeConfigMapper;
    @Autowired
    private ApproveMapper approveMapper;
    @Override
    public Integer create(PlatformBooks platformBooks) {
@@ -105,7 +122,39 @@
    public void deleteById(Integer id) {
        platformBooksMapper.deleteById(id);
    }
    @Override
    @Transactional(rollbackFor = {BusinessException.class,Exception.class})
    public void deleteById(Integer id,LoginUserInfo user) {
        PlatformBooks model =findById(id);
        if(model ==null || Constants.equalsInteger(model.getIsdeleted(),Constants.ONE)){
            throw  new BusinessException(ResponseStatus.DATA_EMPTY);
        }
        Date date =new Date();
        platformBooksMapper.update(null,new UpdateWrapper<PlatformBooks>().lambda()
                .set(PlatformBooks::getIsdeleted,Constants.ONE)
                .set(PlatformBooks::getEditDate,date)
                .set(PlatformBooks::getEditor,user.getId())
                .eq(PlatformBooks::getId,id));
        if(model.getJobId()!=null){
            platformJobMapper.update(null,new UpdateWrapper<PlatformJob>().lambda()
                    .set(PlatformJob::getIsdeleted,Constants.ONE)
                    .set(PlatformJob::getEditDate,new Date())
                    .set(PlatformJob::getEditor,user.getId())
                    .eq(PlatformJob::getId,model.getJobId())
                    .eq(PlatformJob::getIsdeleted,Constants.ZERO));
        }
        String[] params = new String[3];
        params[0] = user.getRealname();
        params[1]=DateUtil.getPlusTime2(date);
        params[2]="【合同号:"+model.getContractNum()+"】-【司机:"+model.getDriverName()+" "+model.getDriverPhone()+"】-【车牌好: "+model.getPlateNum()+"】";
        //记录删除日志
        UserActionServiceImpl.saveUserActionBiz(user,id,Constants.UserActionType.PLATFROM_BOOK_DEL,userActionMapper,date,params, JSONObject.toJSONString(model));
        //标记任务记录
        VisitsServiceImpl.dealCancelNoticesData(noticesJoinMapper,approveMapper,"系统删除",model.getId(),
                Constants.approveObjectType.reason,
                Constants.noticesObjectType.reason
        );
    }
    @Override
    public void delete(PlatformBooks platformBooks) {
        UpdateWrapper<PlatformBooks> deleteWrapper = new UpdateWrapper<>(platformBooks);
@@ -156,6 +205,7 @@
    public PageData<PlatformBooks> findPage(PageWrap<PlatformBooks> pageWrap) {
        IPage<PlatformBooks> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
        QueryWrapper<PlatformBooks> queryWrapper = new QueryWrapper<>();
        pageWrap.getModel().setIsdeleted(Constants.ZERO);
        Utils.MP.blankToNull(pageWrap.getModel());
        queryWrapper.lambda()
                .eq(pageWrap.getModel().getId() != null, PlatformBooks::getId, pageWrap.getModel().getId())
@@ -169,7 +219,7 @@
                .eq(pageWrap.getModel().getName() != null, PlatformBooks::getName, pageWrap.getModel().getName())
                .eq(pageWrap.getModel().getRemark() != null, PlatformBooks::getRemark, pageWrap.getModel().getRemark())
                .eq(pageWrap.getModel().getStatus() != null, PlatformBooks::getStatus, pageWrap.getModel().getStatus())
                .eq(pageWrap.getModel().getContractNum() != null, PlatformBooks::getContractNum, pageWrap.getModel().getContractNum())
                .like(pageWrap.getModel().getContractNum() != null, PlatformBooks::getContractNum, pageWrap.getModel().getContractNum())
                .ge(pageWrap.getModel().getArriveDate() != null, PlatformBooks::getArriveDate, Utils.Date.getStart(pageWrap.getModel().getArriveDate()))
                .le(pageWrap.getModel().getArriveDate() != null, PlatformBooks::getArriveDate, Utils.Date.getEnd(pageWrap.getModel().getArriveDate()))
                .eq(pageWrap.getModel().getInType() != null, PlatformBooks::getInType, pageWrap.getModel().getInType())
@@ -223,6 +273,7 @@
        List<PlatformBooks> platformBooksList = platformBooksMapper.selectList(new QueryWrapper<PlatformBooks>().lambda()
                .eq(PlatformBooks::getReasonId,platformBooksCheckNumDTO.getReasonId())
                .ne(PlatformBooks::getStatus,Constants.THREE)
                .eq(PlatformBooks::getIsdeleted,Constants.ZERO)
                .like(PlatformBooks::getCreateDate, DateUtil.getDate(platformBooksCheckNumDTO.getArriveDate(),"yyyy-MM-dd"))
        );
        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(platformBooksList)){
@@ -292,16 +343,21 @@
        //创建审批流信息
        approveService.createApproveForPlatfrom(approveTempl.getId(),platformBooks.getId(),platformBooks.getDriverId());
        //发送公众号通知 给提交人
        Member member = memberMapper.selectById(platformBooks.getDriverId());
        if(Objects.nonNull(member)&&StringUtils.isNotBlank(member.getOpenid())){
        SystemUser driver = systemUserMapper.selectOne(new QueryWrapper<SystemUser>().lambda()
                .eq(SystemUser::getDeleted, Constants.ZERO)
                .eq(SystemUser::getType, Constants.ZERO)
                .eq(SystemUser::getMobile,platformBooks.getDriverPhone())
                .isNotNull(SystemUser::getOpenid)
                .last(" limit 1 "));
        if(Objects.nonNull(driver)&&StringUtils.isNotBlank(driver.getOpenid())){
            WxPlatNotice wxPlatNotice = new WxPlatNotice();
            wxPlatNotice.sendPlatformBookTemplateNotice(
                    wxNoticeConfigMapper,platformBooks,
            wxPlatNotice.sendPlatformBookTemplateNotice(systemDictDataBiz,
                    wxNoticeConfigMapper, platformBooks,
                    WxPlatConstants.platformBookContent.platformBookUpload,
                    systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(),
                    Arrays.asList(member.getOpenid().split(",")),0);
                    Arrays.asList(driver.getOpenid().split(",")),0);
        }
        return platformBooks.getId();
    }
@@ -330,7 +386,7 @@
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"["+platformBooksApplyDTO.getCarCodeFront()+"]属于内部车辆,无法预约");
        };
        PlatformBooks platformBooks = platformBooksMapper.selectById(platformBooksApplyDTO.getId());
        if(Objects.isNull(platformBooks)){
        if(Objects.isNull(platformBooks)||Constants.equalsInteger(platformBooks.getIsdeleted(),Constants.ONE)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY);
        }
        if(!Constants.equalsInteger(platformBooks.getStatus(),Constants.ZERO)){
@@ -349,7 +405,7 @@
    @Override
    public PlatformBooks getDetail(Integer id,Integer memberId){
        PlatformBooks model = platformBooksMapper.selectById(id);
        if(Objects.isNull(model)){
        if(Objects.isNull(model)||Constants.equalsInteger(model.getIsdeleted(),Constants.ONE)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到预约记录");
        }
        String prefixUrl = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() +
@@ -383,6 +439,20 @@
            approve.setCheckDate(model.getCancelTime());
            approveList.add(approve);
        }
        Notices notices = noticesJoinMapper.selectOne(new QueryWrapper<Notices>().lambda()
                .eq(Notices::getObjId,id)
                .eq(Notices::getType,Constants.noticesObjectType.reason)
                .eq(Notices::getUserId,memberId)
                .eq(Notices::getSendacopy,Constants.ZERO)
                .orderByDesc(Notices::getId).last(" limit 1 "));
        if(Objects.nonNull(notices)){
            if(Constants.equalsInteger(notices.getStatus(),Constants.ZERO)){
                model.setInfo("待我处理");
            }else{
                model.setInfo(notices.getInfo());
            }
        }
        return model;
    }
@@ -392,12 +462,11 @@
    public void revoke(RevokeDTO revokeDTO, LoginUserInfo loginUserInfo){
        if(Objects.isNull(revokeDTO)
                || Objects.isNull(revokeDTO.getId())
                || StringUtils.isBlank(revokeDTO.getInfo())
        ){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        PlatformBooks model = platformBooksMapper.selectById(revokeDTO.getId());
        if(Objects.isNull(model)){
        if(Objects.isNull(model)||Constants.equalsInteger(model.getIsdeleted(),Constants.ONE)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到预约记录");
        }
        if(!(Constants.equalsInteger(model.getStatus(),Constants.ZERO)||Constants.equalsInteger(model.getStatus(),Constants.ONE))){
@@ -419,6 +488,16 @@
                .eq(Approve::getObjId,revokeDTO.getId())
        );
        noticesJoinMapper.update(null,new UpdateWrapper<Notices>().lambda()
                .set(Notices::getEditDate,new Date())
                .set(Notices::getInfo,"物流车预约申请取消")
                .set(Notices::getReaded,Constants.ONE)
                .set(Notices::getParam2,Constants.TWO)
                .set(Notices::getStatus,Constants.ONE)
                .eq(Notices::getType,Constants.noticesObjectType.reason)
                .eq(Notices::getObjId,model.getId())
        );
        //发送短信通知
        SmsEmailServiceImpl.sendPlatformBookSms(systemDictDataBiz,
                emayService,smsEmailMapper,smsConfigMapper,platformBooksMapper,model.getId(),