ICSShipmentDetailServiceImpl.java 6.04 KB
package com.huaheng.pc.u8.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.common.utils.DateUtils;
import com.huaheng.pc.config.company.domain.CompanyU8;
import com.huaheng.pc.config.company.service.CompanyU8Service;
import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail;
import com.huaheng.pc.u8.domain.ICSShipmentDetail;
import com.huaheng.pc.u8.domain.ICSShipmentHeader;
import com.huaheng.pc.u8.mapper.ICSShipmentDetailMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 出库下发或回传单子 服务层实现
 *
 * @author huaheng
 * @date 2018-12-17
 */
@Service
public class ICSShipmentDetailServiceImpl extends ServiceImpl<ICSShipmentDetailMapper, ICSShipmentDetail> implements ICSShipmentDetailService {

    @Resource
    private CompanyU8Service companyU8Service;

    @Override
    public List<ICSShipmentDetail> getDetailsByMO(List<ShipmentDetail> detailList, ICSShipmentHeader header, Map<Integer, BigDecimal> detailsQtyMap) {
        List<ICSShipmentDetail> details = new ArrayList<>();
        for (ShipmentDetail detail : detailList) {
            BigDecimal totalQty = detailsQtyMap.get(detail.getId());
            if(totalQty==null){
                continue;
            }
            ICSShipmentDetail detail1 = new ICSShipmentDetail();
            detail1.setAutoID(detail.getReferId());
            detail1.setCCode(header.getReferCode());
            detail1.setCComUnitName(detail.getMaterialUnit());
            detail1.setCInvCode(detail.getMaterialCode());
            detail1.setCInvName(detail.getMaterialName());
            detail1.setCInvStd(detail.getMaterialSpec());
            CompanyU8 companyU8 = companyU8Service.getCompanyU8ByCode(detail.getCompanyCode(), detail.getWarehouseCode());
            detail1.setCompanyCode(companyU8.getUCompanyCode());
            detail1.setID(header.getReferId());
            detail1.setIMaIDs(0);
            detail1.setCModifyDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getNowDate()));
            detail1.setIQuantity(totalQty);
            detail1.setMoCode(detail.getMoCode());
            details.add(detail1);
        }
        header.setCMemo(detailList.get(0).getMoCode());
        header.setReferId(null);
        header.setReferCode(null);
        return details;
    }

    @Override
    public List<ICSShipmentDetail> getDetailsByOO(List<ShipmentDetail> detailList, ICSShipmentHeader header, Map<Integer, BigDecimal> detailsQtyMap) {
        return null;
    }

    @Override
    public List<ICSShipmentDetail> getDetailsBySO(List<ShipmentDetail> detailList, ICSShipmentHeader header, Map<Integer, BigDecimal> detailsQtyMap) {
        List<ICSShipmentDetail> details = new ArrayList<>();
        for (ShipmentDetail detail : detailList) {
            BigDecimal totalQty = detailsQtyMap.get(detail.getId());
            if(totalQty==null){
                continue;
            }
            ICSShipmentDetail detail1 = new ICSShipmentDetail();
            detail1.setAutoID(detail.getAutoId());
            detail1.setCCode(header.getReferCode());
            detail1.setCComUnitName(detail.getMaterialUnit());
            detail1.setCInvCode(detail.getMaterialCode());
            detail1.setCInvName(detail.getMaterialName());
            detail1.setCInvStd(detail.getMaterialSpec());
            CompanyU8 companyU8 = companyU8Service.getCompanyU8ByCode(detail.getCompanyCode(), detail.getWarehouseCode());
            detail1.setCSOAutoID(detail.getSoAutoId());
            detail1.setCSOCode(detail.getSoCode());
            detail1.setCSOID(detail.getSoId());
            detail1.setCWHCode(detail.getUWarehouseCode());
            detail1.setDLID(header.getReferId());
            detail1.setCompanyCode(companyU8.getUCompanyCode());
            detail1.setID(header.getReferId());
            detail1.setCModifyDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getNowDate()));
            detail1.setIQuantity(totalQty);
            details.add(detail1);
            header.setReferId(null);
            header.setReferCode(null);
        }
        return details;
    }

    @Override
    public List<ICSShipmentDetail> getDetailsByPRO(List<ShipmentDetail> detailList, ICSShipmentHeader header, Map<Integer, BigDecimal> detailsQtyMap) {
        List<ICSShipmentDetail> details = new ArrayList<>();
        for (ShipmentDetail detail : detailList) {
            BigDecimal totalQty = detailsQtyMap.get(detail.getId());
            if(totalQty==null){
                continue;
            }
            totalQty = totalQty.negate();
            ICSShipmentDetail detail1 = new ICSShipmentDetail();
            detail1.setAutoID(detail.getAutoId());
            detail1.setCCode(header.getReferCode());
            detail1.setCComUnitName(detail.getMaterialUnit());
            detail1.setCInvCode(detail.getMaterialCode());
            detail1.setCInvName(detail.getMaterialName());
            detail1.setCInvStd(detail.getMaterialSpec());
            CompanyU8 companyU8 = companyU8Service.getCompanyU8ByCode(detail.getCompanyCode(), detail.getWarehouseCode());
            detail1.setCModifyDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getNowDate()));
            detail1.setCWHCode(detail.getUWarehouseCode());
            detail1.setCompanyCode(companyU8.getUCompanyCode());
            detail1.setIArrsId(detail.getAutoId());
            detail1.setID(header.getReferId());
            detail1.setIPOsID(detail.getPodId());
            detail1.setPODID(detail.getPodId());
            detail1.setPOID(detail.getPoId());
            detail1.setPOCode(detail.getPoCode());
            detail1.setIrowno(Integer.valueOf(detail.getReferLineNum()));
            detail1.setCWHCode(detail.getUWarehouseCode());
            detail1.setIQuantity(totalQty);
            details.add(detail1);
        }
        header.setReferId(null);
        header.setReferCode(null);
        return details;
    }
}