liukangdong
2024-11-22 42ffad01769b4c57c76d3ee9f3a69463889f9813
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractServiceImpl.java
@@ -1,11 +1,20 @@
package com.doumee.service.business.impl;
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.core.utils.Constants;
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.YwContractMapper;
import com.doumee.dao.business.YwCustomerMapper;
import com.doumee.dao.business.YwProjectMapper;
import com.doumee.dao.business.YwRoomMapper;
import com.doumee.dao.business.dao.CompanyMapper;
import com.doumee.dao.business.model.Company;
import com.doumee.dao.business.model.YwContract;
import com.doumee.dao.system.SystemUserMapper;
import com.doumee.service.business.YwContractService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -13,8 +22,10 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.List;
/**
@@ -27,11 +38,44 @@
    @Autowired
    private YwContractMapper ywContractMapper;
    @Autowired
    private CompanyMapper companyMapper;
    @Autowired
    private YwProjectMapper projectMapper;
    @Autowired
    private YwRoomMapper roomMapper;
    @Autowired
    private SystemUserMapper systemUserMapper;
    @Autowired
    private YwCustomerMapper customerMapper;
    @Override
    public Integer create(YwContract ywContract) {
        ywContractMapper.insert(ywContract);
        return ywContract.getId();
    @Transactional(rollbackFor = {BusinessException.class,Exception.class})
    public Integer create(YwContract model) {
        isParamValidCreated(model);
        model.setCreator(model.getLoginUserInfo().getId());
        model.setIsdeleted(Constants.ZERO);
        model.setCreateDate(new Date());
        model.setStatus(Constants.ZERO);
        model.setEditDate(model.getCreateDate());
        model.setEditor(model.getCreator());
        ywContractMapper.insert(model);
        return model.getId();
    }
    private void isParamValidCreated(YwContract model) {
        if(model.getCompanyId()==null){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,请选择正确的公司信息");
        }
        Company ywProject = companyMapper.selectById(model.getCompanyId());
        if(ywProject ==null || Constants.equalsInteger(ywProject.getIsdeleted(),Constants.ONE)
                || !Constants.equalsInteger(ywProject.getType(),Constants.TWO)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,请选择正确的公司信息!");
        }
    }
    @Override