ICSShipmentHeaderServiceImpl.java 6.56 KB
package com.huaheng.pc.u8.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.common.utils.DateUtils;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.Wrappers;
import com.huaheng.pc.config.company.domain.CompanyU8;
import com.huaheng.pc.config.company.service.CompanyU8Service;
import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader;
import com.huaheng.pc.u8.domain.ICSShipmentHeader;
import com.huaheng.pc.u8.mapper.ICSShipmentHeaderMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 出库下发或回传单主 服务层实现
 *
 * @author huaheng
 * @date 2018-12-17
 */
@Service
public class ICSShipmentHeaderServiceImpl extends ServiceImpl<ICSShipmentHeaderMapper,ICSShipmentHeader> implements ICSShipmentHeaderService {

    @Resource
    private CompanyU8Service companyU8Service;

    @Override
    public ICSShipmentHeader selectModel(ICSShipmentHeader condition) {
        LambdaQueryWrapper<ICSShipmentHeader> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(StringUtils.isNotEmpty(condition.getCDLCode()),ICSShipmentHeader::getCDLCode,condition.getCDLCode());
        lambdaQueryWrapper.eq(StringUtils.isNotEmpty(condition.getCSCName()),ICSShipmentHeader::getCSCName,condition.getCSCName());
        lambdaQueryWrapper.last("limit 1");
        return this.getOne(lambdaQueryWrapper);
    }

    @Override
    public ICSShipmentHeader getHeaderByMO(ShipmentHeader header) {
        String warehouseCode = header.getWarehouseCode();
        header.getCompanyCode();
        CompanyU8 companyU8 = companyU8Service.getCompanyU8ByCode(header.getCompanyCode(), header.getWarehouseCode());
        ICSShipmentHeader sh = new ICSShipmentHeader();
        sh.setReferCode(header.getReferCode());
        sh.setReferId(header.getReferId());
        sh.setCCode(header.getReferCode());
        sh.setCompanyCode(companyU8.getUCompanyCode());
        sh.setCWHCode(header.getUWarehouseCode());
        sh.setCRDName("生产领料");
        sh.setCBusType("领料");
        sh.setID(header.getReferId());
        sh.setDDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getNowDate()));
        sh.setCModifyDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getNowDate()));
        sh.setCMaker(header.getLastUpdatedBy());
        sh.setType("MO");
//        sh.setCMemo();
        sh.setVoucherType("UpdateICSRdRecord_11_Confirm");
        return sh;
    }

    @Override
    public ICSShipmentHeader getHeaderByOO(ShipmentHeader header) {
        String warehouseCode = header.getWarehouseCode();
        header.getCompanyCode();
        CompanyU8 companyU8 = companyU8Service.getCompanyU8ByCode(header.getCompanyCode(), header.getWarehouseCode());
        ICSShipmentHeader sh = new ICSShipmentHeader();
        sh.setReferCode(header.getReferCode());
        sh.setReferId(header.getReferId());
        sh.setCCode(header.getReferCode());
        sh.setCompanyCode(companyU8.getUCompanyCode());
        sh.setCWHCode(header.getUWarehouseCode());
        sh.setCWHCode(header.getUWarehouseCode());
        sh.setCBusType("普通采购");
        sh.setID(header.getId());
        sh.setDPODate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getNowDate()));
        sh.setCModifyDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getNowDate()));
        sh.setCMaker(header.getLastUpdatedBy());
        sh.setVoucherType("CreateICSRdRecord_01");
        return sh;
    }

    @Override
    public ICSShipmentHeader getHeaderByPRO(ShipmentHeader header) {
        String warehouseCode = header.getWarehouseCode();
        header.getCompanyCode();
        CompanyU8 companyU8 = companyU8Service.getCompanyU8ByCode(header.getCompanyCode(), header.getWarehouseCode());
        ICSShipmentHeader sh = new ICSShipmentHeader();
        sh.setReferCode(header.getReferCode());
        sh.setReferId(header.getReferId());
        sh.setCCode(header.getReferCode());
        sh.setCompanyCode(companyU8.getUCompanyCode());
        sh.setCWHCode(header.getUWarehouseCode());
        sh.setCVenCode(header.getSupplierCode());
        sh.setCBusType("普通采购");
        sh.setType(header.getShipmentType());
        sh.setID(header.getId());
        sh.setDPODate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getNowDate()));
        sh.setCModifyDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getNowDate()));
        sh.setCMaker(header.getCreatedBy());
        sh.setVoucherType("CreateICSRdRecord_01_Return");
        sh.setCMemo(header.getLastUpdatedBy());
        sh.setCDepCode(header.getDeptCode());
        return sh;
    }

    @Override
    public ICSShipmentHeader getHeaderBySO(ShipmentHeader header) {
        String warehouseCode = header.getWarehouseCode();
        header.getCompanyCode();
        CompanyU8 companyU8 = companyU8Service.getCompanyU8ByCode(header.getCompanyCode(), header.getWarehouseCode());
        ICSShipmentHeader sh = new ICSShipmentHeader();
        sh.setReferCode(header.getReferCode());
        sh.setReferId(header.getReferId());
        sh.setCCode(header.getReferCode());
        sh.setCompanyCode(companyU8.getUCompanyCode());
        sh.setCWHCode(header.getUWarehouseCode());
        sh.setCCusCode(header.getCustomerCode());
        sh.setCCusName(header.getCustomerName());
        sh.setCDLCode(header.getReferCode());
        sh.setCDepCode(header.getDeptCode());
        sh.setCMemo(header.getShipmentNote());
        sh.setCBusType("普通销售");
        sh.setCSTName("普通销售");
        sh.setID(header.getReferId());
        sh.setDPODate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getNowDate()));
        sh.setDDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getNowDate()));
        sh.setCModifyDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getNowDate()));
        sh.setCMaker(header.getLastUpdatedBy());
        sh.setDLID(header.getReferId());
        sh.setSendName(header.getSendName());
        sh.setSendMobile(header.getSendMobile());
        sh.setSendCompany(header.getSendCompany());
        sh.setSendAddr(header.getSendAddr());
        sh.setRecName(header.getRecName());
        sh.setRecMobile(header.getRecMobile());
        sh.setRecCompany(header.getRecCompany());
        sh.setRecAddr(header.getRecAddr());
        sh.setType("SO");
        sh.setVoucherType("CreateICSRdRecord_32");
        return sh;
    }
}