package doumeemes.service.business.impl; 
 | 
  
 | 
import com.alibaba.fastjson.JSON; 
 | 
import com.alibaba.fastjson.JSONObject; 
 | 
import com.baomidou.mybatisplus.core.conditions.Wrapper; 
 | 
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; 
 | 
import doumeemes.biz.system.SystemDictDataBiz; 
 | 
import doumeemes.core.constants.ResponseStatus; 
 | 
import doumeemes.core.exception.BusinessException; 
 | 
import doumeemes.core.model.ApiResponse; 
 | 
import doumeemes.core.model.LoginUserInfo; 
 | 
import doumeemes.core.model.PageData; 
 | 
import doumeemes.core.model.PageWrap; 
 | 
import doumeemes.core.utils.Constants; 
 | 
import doumeemes.core.utils.DateUtil; 
 | 
import doumeemes.core.utils.Utils; 
 | 
import doumeemes.core.utils.redis.RedisUtil; 
 | 
import doumeemes.dao.business.*; 
 | 
import doumeemes.dao.business.model.*; 
 | 
import doumeemes.dao.ext.*; 
 | 
import doumeemes.dao.ext.bean.*; 
 | 
import doumeemes.dao.ext.beanDto.QueryWStockDto; 
 | 
import doumeemes.dao.ext.vo.BarcodeParamExtListVO; 
 | 
import doumeemes.dao.ext.vo.WOutboundRecordExtListVO; 
 | 
import doumeemes.dao.ext.vo.WorkorderRecordExtListVO; 
 | 
import doumeemes.dao.system.SystemDictDataMapper; 
 | 
import doumeemes.dao.system.SystemUserMapper; 
 | 
import doumeemes.dao.system.model.SystemDictData; 
 | 
import doumeemes.dao.system.model.SystemUser; 
 | 
import doumeemes.service.business.BarcodeParamService; 
 | 
import doumeemes.service.business.WOutboundService; 
 | 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 
 | 
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; 
 | 
import com.baomidou.mybatisplus.core.metadata.IPage; 
 | 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 
 | 
import doumeemes.service.ext.BarcodeParamExtService; 
 | 
import doumeemes.service.ext.NoticesExtService; 
 | 
import doumeemes.service.ext.WStockRecordExtService; 
 | 
import doumeemes.service.system.SystemUserExternalService; 
 | 
import doumeemes.service.system.SystemUserService; 
 | 
import io.swagger.models.auth.In; 
 | 
import net.sf.json.JSONArray; 
 | 
import org.apache.commons.lang3.StringUtils; 
 | 
import org.apache.shiro.SecurityUtils; 
 | 
import org.springframework.beans.BeanUtils; 
 | 
import org.springframework.beans.factory.annotation.Autowired; 
 | 
import org.springframework.data.redis.core.RedisTemplate; 
 | 
import org.springframework.stereotype.Service; 
 | 
import org.springframework.transaction.annotation.Transactional; 
 | 
import org.springframework.util.CollectionUtils; 
 | 
  
 | 
import java.math.BigDecimal; 
 | 
import java.util.*; 
 | 
import java.util.stream.Collectors; 
 | 
  
 | 
/** 
 | 
 * 仓库管理-出入库单信息表Service实现 
 | 
 * @author 江蹄蹄 
 | 
 * @date 2022/04/20 09:37 
 | 
 */ 
 | 
@Service 
 | 
public class WOutboundServiceImpl implements WOutboundService { 
 | 
  
 | 
    @Autowired 
 | 
    private RedisTemplate<String, Object> redisTemplate; 
 | 
  
 | 
    @Autowired 
 | 
    private WOutboundMapper wOutboundMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private WOutboundExtMapper wOutboundExtMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private WOutboundDetailExtMapper wOutboundDetailExtMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private WOutboundDetailMapper wOutboundDetailMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private WOutboundRecordMapper wOutboundRecordMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private WOutboundRecordExtMapper wOutboundRecordExtMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private WorkorderRecordExtMapper workorderRecordExtMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private WarehouseMapper warehouseMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private WTransferExtMapper wTransferExtMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private WHistoryMapper wHistoryMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private WTransferDetailExtMapper wTransferDetailExtMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private WTransferDetailMapper wTransferDetailMapper; 
 | 
    @Autowired 
 | 
    private AppliancesExtMapper appliancesExtMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private WStockExtMapper wStockExtMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private WStockMapper wStockMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private BarcodeParamExtService barcodeParamExtService; 
 | 
  
 | 
    @Autowired 
 | 
    private WarehouseLocationExtMapper warehouseLocationExtMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private SystemDictDataMapper systemDictDataMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private CompanyUserMapper companyUserMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private SystemDictDataBiz systemDictDataBiz; 
 | 
  
 | 
    @Autowired 
 | 
    private NoticesExtService noticesExtService; 
 | 
  
 | 
    @Autowired 
 | 
    private WTransferMapper wTransferMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private AppliancesMapper appliancesMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private MaterialDistributeMapper materialDistributeMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private MaterialMapper materialMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private BomMapper bomMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private RouteProcedureMapper routeProcedureMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private ProceduresMapper proceduresMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private AdjustmentRecordMapper adjustmentRecordMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private WStockRecordExtService wStockRecordExtService; 
 | 
  
 | 
  
 | 
    @Autowired 
 | 
    private CompanyUserExtMapper companyUserExtMapper; 
 | 
  
 | 
    @Autowired 
 | 
    private DepartmentExtMapper departmentExtMapper; 
 | 
  
 | 
    @Override 
 | 
    public Integer create(WOutbound wOutbound) { 
 | 
        wOutboundMapper.insert(wOutbound); 
 | 
        return wOutbound.getId(); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public void deleteById(Integer id) { 
 | 
        wOutboundMapper.deleteById(id); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public void delete(WOutbound wOutbound) { 
 | 
        UpdateWrapper<WOutbound> deleteWrapper = new UpdateWrapper<>(wOutbound); 
 | 
        wOutboundMapper.delete(deleteWrapper); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public void deleteByIdInBatch(List<Integer> ids) { 
 | 
        if (CollectionUtils.isEmpty(ids)) { 
 | 
            return; 
 | 
        } 
 | 
        wOutboundMapper.deleteBatchIds(ids); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public void updateById(WOutbound wOutbound) { 
 | 
        wOutboundMapper.updateById(wOutbound); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public void updateByIdInBatch(List<WOutbound> wOutbounds) { 
 | 
        if (CollectionUtils.isEmpty(wOutbounds)) { 
 | 
            return; 
 | 
        } 
 | 
        for (WOutbound wOutbound: wOutbounds) { 
 | 
            this.updateById(wOutbound); 
 | 
        } 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public WOutbound findById(Integer id) { 
 | 
        return wOutboundMapper.selectById(id); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public WOutbound findOne(WOutbound wOutbound) { 
 | 
        QueryWrapper<WOutbound> wrapper = new QueryWrapper<>(wOutbound); 
 | 
        return wOutboundMapper.selectOne(wrapper); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public List<WOutbound> findList(WOutbound wOutbound) { 
 | 
        QueryWrapper<WOutbound> wrapper = new QueryWrapper<>(wOutbound); 
 | 
        return wOutboundMapper.selectList(wrapper); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public PageData<WOutbound> findPage(PageWrap<WOutbound> pageWrap) { 
 | 
        IPage<WOutbound> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); 
 | 
        QueryWrapper<WOutbound> queryWrapper = new QueryWrapper<>(); 
 | 
        Utils.MP.blankToNull(pageWrap.getModel()); 
 | 
        if (pageWrap.getModel().getId() != null) { 
 | 
            queryWrapper.lambda().eq(WOutbound::getId, pageWrap.getModel().getId()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getDeleted() != null) { 
 | 
            queryWrapper.lambda().eq(WOutbound::getDeleted, pageWrap.getModel().getDeleted()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getCreateUser() != null) { 
 | 
            queryWrapper.lambda().eq(WOutbound::getCreateUser, pageWrap.getModel().getCreateUser()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getCreateTime() != null) { 
 | 
            queryWrapper.lambda().ge(WOutbound::getCreateTime, Utils.Date.getStart(pageWrap.getModel().getCreateTime())); 
 | 
            queryWrapper.lambda().le(WOutbound::getCreateTime, Utils.Date.getEnd(pageWrap.getModel().getCreateTime())); 
 | 
        } 
 | 
        if (pageWrap.getModel().getUpdateUser() != null) { 
 | 
            queryWrapper.lambda().eq(WOutbound::getUpdateUser, pageWrap.getModel().getUpdateUser()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getUpdateTime() != null) { 
 | 
            queryWrapper.lambda().ge(WOutbound::getUpdateTime, Utils.Date.getStart(pageWrap.getModel().getUpdateTime())); 
 | 
            queryWrapper.lambda().le(WOutbound::getUpdateTime, Utils.Date.getEnd(pageWrap.getModel().getUpdateTime())); 
 | 
        } 
 | 
        if (pageWrap.getModel().getRemark() != null) { 
 | 
            queryWrapper.lambda().eq(WOutbound::getRemark, pageWrap.getModel().getRemark()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getRootDepartId() != null) { 
 | 
            queryWrapper.lambda().eq(WOutbound::getRootDepartId, pageWrap.getModel().getRootDepartId()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getDepartId() != null) { 
 | 
            queryWrapper.lambda().eq(WOutbound::getDepartId, pageWrap.getModel().getDepartId()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getCode() != null) { 
 | 
            queryWrapper.lambda().eq(WOutbound::getCode, pageWrap.getModel().getCode()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getOrigin() != null) { 
 | 
            queryWrapper.lambda().eq(WOutbound::getOrigin, pageWrap.getModel().getOrigin()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getValidDate() != null) { 
 | 
            queryWrapper.lambda().ge(WOutbound::getValidDate, Utils.Date.getStart(pageWrap.getModel().getValidDate())); 
 | 
            queryWrapper.lambda().le(WOutbound::getValidDate, Utils.Date.getEnd(pageWrap.getModel().getValidDate())); 
 | 
        } 
 | 
        if (pageWrap.getModel().getType() != null) { 
 | 
            queryWrapper.lambda().eq(WOutbound::getType, pageWrap.getModel().getType()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getOriginType() != null) { 
 | 
            queryWrapper.lambda().eq(WOutbound::getOriginType, pageWrap.getModel().getOriginType()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getOriginCode() != null) { 
 | 
            queryWrapper.lambda().eq(WOutbound::getOriginCode, pageWrap.getModel().getOriginCode()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getOriginId() != null) { 
 | 
            queryWrapper.lambda().eq(WOutbound::getOriginId, pageWrap.getModel().getOriginId()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getAbstracts() != null) { 
 | 
            queryWrapper.lambda().eq(WOutbound::getAbstracts, pageWrap.getModel().getAbstracts()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getUserId() != null) { 
 | 
            queryWrapper.lambda().eq(WOutbound::getUserId, pageWrap.getModel().getUserId()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getWarehouseId() != null) { 
 | 
            queryWrapper.lambda().eq(WOutbound::getWarehouseId, pageWrap.getModel().getWarehouseId()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getDealDate() != null) { 
 | 
            queryWrapper.lambda().ge(WOutbound::getDealDate, Utils.Date.getStart(pageWrap.getModel().getDealDate())); 
 | 
            queryWrapper.lambda().le(WOutbound::getDealDate, Utils.Date.getEnd(pageWrap.getModel().getDealDate())); 
 | 
        } 
 | 
        if (pageWrap.getModel().getStatus() != null) { 
 | 
            queryWrapper.lambda().eq(WOutbound::getStatus, pageWrap.getModel().getStatus()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getPlanDate() != null) { 
 | 
            queryWrapper.lambda().ge(WOutbound::getPlanDate, Utils.Date.getStart(pageWrap.getModel().getPlanDate())); 
 | 
            queryWrapper.lambda().le(WOutbound::getPlanDate, Utils.Date.getEnd(pageWrap.getModel().getPlanDate())); 
 | 
        } 
 | 
        if (pageWrap.getModel().getProcedureId() != null) { 
 | 
            queryWrapper.lambda().eq(WOutbound::getProcedureId, pageWrap.getModel().getProcedureId()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getCancelUserId() != null) { 
 | 
            queryWrapper.lambda().eq(WOutbound::getCancelUserId, pageWrap.getModel().getCancelUserId()); 
 | 
        } 
 | 
        if (pageWrap.getModel().getCancelDate() != null) { 
 | 
            queryWrapper.lambda().ge(WOutbound::getCancelDate, Utils.Date.getStart(pageWrap.getModel().getCancelDate())); 
 | 
            queryWrapper.lambda().le(WOutbound::getCancelDate, Utils.Date.getEnd(pageWrap.getModel().getCancelDate())); 
 | 
        } 
 | 
        if (pageWrap.getModel().getCancelInfo() != null) { 
 | 
            queryWrapper.lambda().eq(WOutbound::getCancelInfo, pageWrap.getModel().getCancelInfo()); 
 | 
        } 
 | 
        for(PageWrap.SortData sortData: pageWrap.getSorts()) { 
 | 
            if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { 
 | 
                queryWrapper.orderByDesc(sortData.getProperty()); 
 | 
            } else { 
 | 
                queryWrapper.orderByAsc(sortData.getProperty()); 
 | 
            } 
 | 
        } 
 | 
        return PageData.from(wOutboundMapper.selectPage(page, queryWrapper)); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public long count(WOutbound wOutbound) { 
 | 
        QueryWrapper<WOutbound> wrapper = new QueryWrapper<>(wOutbound); 
 | 
        return wOutboundMapper.selectCount(wrapper); 
 | 
    } 
 | 
  
 | 
  
 | 
    @Override 
 | 
    @Transactional 
 | 
    public ApiResponse saveBean(WOutBoundBean wOutBoundBean, LoginUserInfo loginUserInfo){ 
 | 
        WOutbound wOutbound = new WOutbound(); 
 | 
        wOutbound.setPlanDate(wOutBoundBean.getPlanDate()); 
 | 
        wOutbound.setType(wOutBoundBean.getType()); 
 | 
        wOutbound.setWarehouseId(wOutBoundBean.getWarehouseId()); 
 | 
        wOutbound.setCreateTime(new Date()); 
 | 
        wOutbound.setCreateUser(loginUserInfo.getId()); 
 | 
        wOutbound.setValidDate(new Date()); 
 | 
        wOutbound.setOrigin(wOutBoundBean.getOrigin()); 
 | 
        wOutbound.setOrigin(Constants.ZERO); 
 | 
        wOutbound.setAbstracts(wOutBoundBean.getAbstracts()); 
 | 
        wOutbound.setStatus(Constants.ZERO); 
 | 
        wOutbound.setRootDepartId(loginUserInfo.getRootDepartment().getId()); 
 | 
        wOutbound.setDepartId(loginUserInfo.getCurComDepartment().getId()); 
 | 
        wOutbound.setUserId(loginUserInfo.getId()); 
 | 
        wOutbound.setBillType(wOutBoundBean.getBillType()); 
 | 
        //TODO 关联单据查询是否使用 
 | 
        List<WoutBoundDetailBean> woutBoundDetailBeans = wOutBoundBean.getWoutBoundDetailBeans(); 
 | 
        if(woutBoundDetailBeans.size()<=0){ 
 | 
            throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "仓库信息异常"); 
 | 
        } 
 | 
        woutBoundDetailBeans.forEach(i->{ 
 | 
            if(Objects.isNull(i.getNum()) 
 | 
                    ||Objects.isNull(i.getMaterialId())||Objects.isNull(i.getUnitId())){ 
 | 
                throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "明细入参数据异常"); 
 | 
            } 
 | 
        }); 
 | 
        //TODO 工序信息 
 | 
        Warehouse warehouse =  warehouseMapper.selectById(wOutbound.getWarehouseId()); 
 | 
        if(Objects.isNull(warehouse)){ 
 | 
            throw new BusinessException(ResponseStatus.ITEM_ERR_STATUS.getCode(), "无行项目数据"); 
 | 
        } 
 | 
        if(Constants.ONE == wOutBoundBean.getType()){ 
 | 
            wOutbound.setCode(getNextInCode(loginUserInfo.getCompany().getId()));//TODO 单据编码 
 | 
        }else{ 
 | 
            wOutbound.setCode(getNextOutCode(loginUserInfo.getCompany().getId()));//TODO 单据编码 
 | 
        } 
 | 
        wOutboundMapper.insert(wOutbound); 
 | 
        woutBoundDetailBeans.forEach(i->{ 
 | 
            WOutboundDetail wOutboundDetail = new WOutboundDetail(); 
 | 
            wOutboundDetail.setNum(i.getNum()); 
 | 
            wOutboundDetail.setUnitId(i.getUnitId()); 
 | 
            wOutboundDetail.setBatch(i.getBatch()); 
 | 
            wOutboundDetail.setMaterialId(i.getMaterialId()); 
 | 
            wOutboundDetail.setLocationId(i.getLocationId()); 
 | 
            wOutboundDetail.setOutboundId(wOutbound.getId()); 
 | 
            wOutboundDetail.setCreateTime(new Date()); 
 | 
            wOutboundDetail.setCreateUser(loginUserInfo.getId()); 
 | 
            wOutboundDetail.setRootDepartId(loginUserInfo.getRootDepartment().getId()); 
 | 
            wOutboundDetail.setWarehouseId(wOutbound.getWarehouseId()); 
 | 
            wOutboundDetail.setQualityType(i.getQualityType()); 
 | 
            wOutboundDetail.setProcedureId(i.getProcedureId()); 
 | 
            wOutboundDetailMapper.insert(wOutboundDetail); 
 | 
        }); 
 | 
  
 | 
        CompanyUser companyUser = companyUserMapper.selectOne(new QueryWrapper<CompanyUser>() 
 | 
                .eq("USER_ID",warehouse.getManagerId()) 
 | 
                .eq("DELETED",0) 
 | 
                .eq("ROOT_DEPART_ID",wOutbound.getRootDepartId()) 
 | 
        ); 
 | 
        if(Objects.isNull(companyUser)){ 
 | 
            throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到出库仓管员信息【"+wOutbound.getCreateUser()+"】"); 
 | 
        } 
 | 
  
 | 
        Constants.Notices_Type_Transfer notices_type_transfer =  Constants.Notices_Type_Transfer.checkEnum(wOutbound.getBillType()); 
 | 
        if(Objects.isNull(notices_type_transfer)){ 
 | 
            throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到出库单类型信息【"+wOutbound.getBillType()+"】"); 
 | 
        } 
 | 
  
 | 
        sendOutNotice(companyUser.getId(),wOutbound.getId(),wOutbound.getCode(),notices_type_transfer,Constants.getNoticeUrl(loginUserInfo.getCompany(),Constants.DINGDING_NOTICE_URL.woutOut)); 
 | 
        return ApiResponse.success(wOutbound); 
 | 
    } 
 | 
  
 | 
  
 | 
  
 | 
    @Override 
 | 
    @Transactional 
 | 
    public ApiResponse saveBeanForStandard(WOutBoundBean wOutBoundBean, LoginUserInfo loginUserInfo){ 
 | 
        WOutbound wOutbound = new WOutbound(); 
 | 
        wOutbound.setPlanDate(wOutBoundBean.getPlanDate()); 
 | 
        wOutbound.setType(wOutBoundBean.getType()); 
 | 
        wOutbound.setWarehouseId(wOutBoundBean.getWarehouseId()); 
 | 
        wOutbound.setCreateTime(new Date()); 
 | 
        wOutbound.setCreateUser(loginUserInfo.getId()); 
 | 
        wOutbound.setValidDate(new Date()); 
 | 
        wOutbound.setOrigin(wOutBoundBean.getOrigin()); 
 | 
        wOutbound.setAbstracts(wOutBoundBean.getAbstracts()); 
 | 
        wOutbound.setStatus(Constants.ONE); 
 | 
        wOutbound.setDealDate(new Date()); 
 | 
        wOutbound.setRootDepartId(loginUserInfo.getRootDepartment().getId()); 
 | 
        wOutbound.setDepartId(loginUserInfo.getCurComDepartment().getId()); 
 | 
        wOutbound.setUserId(loginUserInfo.getId()); 
 | 
        wOutbound.setBillType(wOutBoundBean.getBillType()); 
 | 
        //TODO 关联单据查询是否使用 
 | 
        List<WoutBoundDetailBean> woutBoundDetailBeans = wOutBoundBean.getWoutBoundDetailBeans(); 
 | 
        if(woutBoundDetailBeans.size()<=0){ 
 | 
            throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "仓库信息异常"); 
 | 
        } 
 | 
        woutBoundDetailBeans.forEach(i->{ 
 | 
            if(Objects.isNull(i.getNum()) 
 | 
                    ||Objects.isNull(i.getMaterialId())||Objects.isNull(i.getUnitId())){ 
 | 
                throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "明细入参数据异常"); 
 | 
            } 
 | 
        }); 
 | 
        //  工序信息 
 | 
        Warehouse warehouse =  warehouseMapper.selectById(wOutbound.getWarehouseId()); 
 | 
        if(Objects.isNull(warehouse)){ 
 | 
            throw new BusinessException(ResponseStatus.ITEM_ERR_STATUS.getCode(), "无行项目数据"); 
 | 
        } 
 | 
        if(Constants.ONE == wOutBoundBean.getType()){ 
 | 
            wOutbound.setCode(getNextInCode(loginUserInfo.getCompany().getId())); 
 | 
        }else{ 
 | 
            wOutbound.setCode(getNextOutCode(loginUserInfo.getCompany().getId())); 
 | 
        } 
 | 
        wOutboundMapper.insert(wOutbound); 
 | 
        woutBoundDetailBeans.forEach(i->{ 
 | 
            WOutboundDetail wOutboundDetail = new WOutboundDetail(); 
 | 
            wOutboundDetail.setNum(i.getNum()); 
 | 
            wOutboundDetail.setUnitId(i.getUnitId()); 
 | 
            wOutboundDetail.setBatch(i.getBatch()); 
 | 
            wOutboundDetail.setMaterialId(i.getMaterialId()); 
 | 
            wOutboundDetail.setLocationId(i.getLocationId()); 
 | 
            wOutboundDetail.setOutboundId(wOutbound.getId()); 
 | 
            wOutboundDetail.setCreateTime(new Date()); 
 | 
            wOutboundDetail.setCreateUser(loginUserInfo.getId()); 
 | 
            wOutboundDetail.setRootDepartId(loginUserInfo.getRootDepartment().getId()); 
 | 
            wOutboundDetail.setStatus(Constants.ONE); 
 | 
            wOutboundDetail.setWarehouseId(wOutbound.getWarehouseId()); 
 | 
            wOutboundDetail.setDoneNum(wOutboundDetail.getNum()); 
 | 
            wOutboundDetail.setQualityType(i.getQualityType()); 
 | 
            wOutboundDetail.setProcedureId(i.getProcedureId()); 
 | 
            wOutboundDetailMapper.insert(wOutboundDetail); 
 | 
            //处理库存 
 | 
            if(Objects.isNull(warehouse)){ 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到仓库数据【" + warehouse.getId() + "】"); 
 | 
            } 
 | 
            List<WStock> wStockList = wStockMapper.selectList(new QueryWrapper<WStock>() 
 | 
                    .eq("ROOT_DEPART_ID", wOutbound.getRootDepartId()) 
 | 
                    .eq("MATERIAL_ID", wOutboundDetail.getMaterialId()) 
 | 
                    .eq("WAREHOUSE_ID", wOutboundDetail.getWarehouseId()) 
 | 
                    .eq(StringUtils.isNotBlank(wOutboundDetail.getBatch()),"BATCH", i.getBatch()) 
 | 
                    .isNull(StringUtils.isBlank(wOutboundDetail.getBatch()),"BATCH") 
 | 
                    .eq(!Objects.isNull(wOutboundDetail.getProcedureId()),"PROCEDURE_ID",wOutboundDetail.getProcedureId()) 
 | 
                    .isNull(Objects.isNull(wOutboundDetail.getProcedureId()),"PROCEDURE_ID") 
 | 
                    .eq("QUALITY_TYPE",wOutboundDetail.getQualityType()) 
 | 
                    .eq(StringUtils.isNotBlank(wOutboundDetail.getBatch())&&warehouse.getUseLocation()==Constants.ONE,"LOCATION_ID", i.getLocationId()) 
 | 
            ); 
 | 
            if (wStockList.size()<=Constants.ZERO) { 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到仓库/货位库存信息"); 
 | 
            }else if(wStockList.size()>1){ 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "库存数据异常,存在多条库存信息,请检查库存数据"); 
 | 
            } 
 | 
            WStock wStock = wStockList.get(0); 
 | 
            // 更新货位库存 
 | 
            if (wOutboundDetail.getNum().compareTo(wStock.getNum()) > Constants.ZERO) { 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "货位库存不足,请刷新查看"); 
 | 
            } 
 | 
            wStock.setNum(wStock.getNum().subtract(wOutboundDetail.getNum())); 
 | 
            wStockExtMapper.updateById(wStock); 
 | 
        }); 
 | 
        return ApiResponse.success(wOutbound); 
 | 
    } 
 | 
  
 | 
  
 | 
    public void sendOutNotice(Integer userId ,Integer billId , String billCode ,Constants.Notices_Type_Transfer notices_type_transfer,String url){ 
 | 
        //发送通知 
 | 
        Notices notices = new Notices(); 
 | 
        notices.setCompanyUserId(userId); 
 | 
        notices.setType(notices_type_transfer.getNoticeOutType()); 
 | 
        notices.setContent("【"+billCode+"】"+ notices_type_transfer.getContent().replace("{optType}","出库")); 
 | 
        notices.setTitle(notices_type_transfer.getTitle()); 
 | 
        notices.setObjId(billId); 
 | 
        notices.setUrl(url.replace("{id}",billId.toString())); 
 | 
        noticesExtService.sendNotice(notices); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public WOutbound getBeanById(Integer id){ 
 | 
        WOutbound wOutbound = wOutboundExtMapper.wOutboundById(id); 
 | 
        List<WOutboundDetail> wOutboundDetailList = wOutboundDetailExtMapper.wOutboundDetailListById(id,Constants.ZERO); 
 | 
//        if(wOutbound.getType()==Constants.ZERO){ 
 | 
//            for (WOutboundDetail wOutboundDetail:wOutboundDetailList) { 
 | 
//                QueryWStockDto queryWStockDto = new QueryWStockDto(); 
 | 
//                queryWStockDto.setRootDepartId(wOutboundDetail.getRootDepartId()); 
 | 
//                queryWStockDto.setMaterialId(wOutboundDetail.getMaterialId()); 
 | 
//                queryWStockDto.setWarehouseId(wOutboundDetail.getWarehouseId()); 
 | 
//                queryWStockDto.setLocationId(wOutboundDetail.getLocationId()); 
 | 
//                queryWStockDto.setUnitId(wOutboundDetail.getUnitId()); 
 | 
//                queryWStockDto.setBatch(wOutboundDetail.getBatch()); 
 | 
//                wOutboundDetail.setWStockExtListVOList(wStockExtMapper.stockListByDto(queryWStockDto)); 
 | 
//            } 
 | 
            wOutbound.setWOutboundDetailsOut(wOutboundDetailExtMapper.wOutboundDetailListById(id,Constants.ONE)); 
 | 
//        } 
 | 
        wOutbound.setWOutboundDetailsWait(wOutboundDetailList); 
 | 
        return wOutbound; 
 | 
    } 
 | 
  
 | 
  
 | 
    @Override 
 | 
    @Transactional 
 | 
    public ApiResponse cancel(Integer id,String detail,LoginUserInfo loginUserInfo){ 
 | 
        WOutbound wOutbound =  wOutboundMapper.selectById(id); 
 | 
        if(Objects.isNull(wOutbound)){ 
 | 
            throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "未查询到对象信息"); 
 | 
        } 
 | 
        if(Constants.ONE ==wOutbound.getStatus()){ 
 | 
            throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "单据已处理,无法取消"); 
 | 
        }else if(Constants.TWO == wOutbound.getStatus()){ 
 | 
            throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "单据已取消"); 
 | 
        } 
 | 
        wOutbound.setStatus(Constants.TWO); 
 | 
        wOutbound.setCancelDate(new Date()); 
 | 
        wOutbound.setCancelInfo(detail); 
 | 
        wOutbound.setCancelUserId(loginUserInfo.getId()); 
 | 
        wOutboundMapper.updateById(wOutbound); 
 | 
  
 | 
        //2022年8月8日10:05:21  处理 清空条码与入库单 绑定信息的数据 
 | 
        if(wOutbound.getType() == Constants.ONE && wOutbound.getOrigin() == Constants.ZERO){ 
 | 
            List<AdjustmentRecord> adjustmentRecords = adjustmentRecordMapper.selectList(new QueryWrapper<AdjustmentRecord>().eq("OUTBOUND_ID",id)); 
 | 
            if(!Objects.isNull(adjustmentRecords)&&adjustmentRecords.size()>0){ 
 | 
                for (AdjustmentRecord adjustmentRecord:adjustmentRecords) { 
 | 
                    Appliances appliances = appliancesMapper.selectById(adjustmentRecord.getAppliancesId()); 
 | 
                    LambdaUpdateWrapper<Appliances> updateWrapper = new LambdaUpdateWrapper<>(); 
 | 
                    updateWrapper.eq(Appliances::getId,appliances.getId()); 
 | 
                    updateWrapper.set(Appliances::getMaterialId,null); 
 | 
                    updateWrapper.set(Appliances::getStatus,Constants.ONE); 
 | 
                    updateWrapper.set(Appliances::getQualityType,null); 
 | 
                    updateWrapper.set(Appliances::getBatch,null); 
 | 
                    updateWrapper.set(Appliances::getProcedureId,null); 
 | 
                    updateWrapper.set(Appliances::getNum,BigDecimal.ZERO); 
 | 
                    updateWrapper.set(Appliances::getPositionType,null); 
 | 
                    updateWrapper.set(Appliances::getNextProcedureId,null); 
 | 
                    appliancesExtMapper.update(appliances,updateWrapper); 
 | 
                } 
 | 
            } 
 | 
        } 
 | 
  
 | 
        //消除待办 
 | 
        Constants.Notices_Type_Transfer notices_type_transfer = Constants.Notices_Type_Transfer.checkEnum(wOutbound.getBillType()); 
 | 
        noticesExtService.dealNotice(id,wOutbound.getType()==Constants.ZERO?notices_type_transfer.getNoticeOutType():notices_type_transfer.getNoticeInType(),null); 
 | 
  
 | 
        //记录操作记录 
 | 
        WHistory wHistory = wOutbound.toWHistory(loginUserInfo.getId()); 
 | 
        wHistory.setTitle("出入库单取消"); 
 | 
        wHistory.setInfo("出入库单取消"); 
 | 
        wHistoryMapper.insert(wHistory); 
 | 
  
 | 
        return ApiResponse.success(wOutbound); 
 | 
    } 
 | 
  
 | 
  
 | 
    @Override 
 | 
    @Transactional 
 | 
    public ApiResponse<WTransfer> getOutByWTransferId(Integer id){ 
 | 
        WTransfer wTransfer = wTransferExtMapper.wTransferById(id); 
 | 
        if(Objects.isNull(wTransfer)){ 
 | 
            throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "未查询到转库单对象信息"); 
 | 
        } 
 | 
        if(wTransfer.getStatus()!=Constants.ZERO){ 
 | 
            throw new BusinessException(ResponseStatus.ERR_STATUS.getCode(), "转库单状态已转出!"); 
 | 
        } 
 | 
        //获取明细所有仓库信息(分组) 
 | 
        List<WTransferWarehouse> wTransferOutWarehouses = wTransferDetailExtMapper.wTransferOutWarehouseListById(id); 
 | 
        //获取明细所有物料信息 并获取库存仓位信息 
 | 
        List<WTransferDetail> wTransferDetailList = wTransferDetailExtMapper.wTransferDetailListById(id); 
 | 
        for (WTransferDetail wTransferDetail:wTransferDetailList ) { 
 | 
            QueryWStockDto queryWStockDto = new QueryWStockDto(); 
 | 
            queryWStockDto.setRootDepartId(wTransferDetail.getRootDepartId()); 
 | 
            queryWStockDto.setMaterialId(wTransferDetail.getMaterialId()); 
 | 
            queryWStockDto.setWarehouseId(wTransferDetail.getOutWarehouseId()); 
 | 
            queryWStockDto.setUnitId(wTransferDetail.getUnitId()); 
 | 
            queryWStockDto.setBatch(wTransferDetail.getBatch()); 
 | 
            //获取仓库信息 根据 
 | 
            Warehouse warehouse = warehouseMapper.selectById(wTransferDetail.getOutWarehouseId()); 
 | 
            if(Objects.isNull(warehouse)){ 
 | 
                throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "未查询到仓库信息"); 
 | 
            }else{ 
 | 
                if(Constants.ZERO == warehouse.getUseLocation()){ 
 | 
                    wTransferDetail.setWStockExtListVOList(wStockExtMapper.choiceStockListNoLocation(queryWStockDto)); 
 | 
                }else{ 
 | 
//                    wTransferDetail.setWStockExtListVOList(wStockExtMapper.stockListByDto(queryWStockDto)); 
 | 
                    wTransferDetail.setWStockExtListVOList(wStockExtMapper.choiceStockList(queryWStockDto)); 
 | 
                } 
 | 
            } 
 | 
        } 
 | 
        //物料信息根据仓库信息 添加至各个仓库下 返回 
 | 
        wTransferOutWarehouses.forEach(i->{ 
 | 
            List<WTransferDetail> detail = new ArrayList<>(); 
 | 
            wTransferDetailList.forEach(j->{ 
 | 
                if(i.getWarehouseId() == j.getOutWarehouseId()){ 
 | 
                    detail.add(j); 
 | 
                } 
 | 
            }); 
 | 
            i.setWTransferDetailList(detail); 
 | 
        }); 
 | 
        wTransfer.setWTransferWarehouseList(wTransferOutWarehouses); 
 | 
        return ApiResponse.success(wTransfer); 
 | 
    } 
 | 
  
 | 
  
 | 
    @Override 
 | 
    @Transactional 
 | 
    public ApiResponse<WTransfer> getInByWTransferId(Integer id){ 
 | 
        WTransfer wTransfer = wTransferExtMapper.wTransferById(id); 
 | 
        if(Objects.isNull(wTransfer)){ 
 | 
            throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "未查询到转库单对象信息"); 
 | 
        } 
 | 
        //获取明细所有仓库信息(分组) 
 | 
        List<WTransferWarehouse> wTransferInWarehouses = wTransferDetailExtMapper.wTransferInWarehouseListById(id); 
 | 
        //获取明细所有物料信息 
 | 
        List<WTransferDetail> wTransferDetailList = wTransferDetailExtMapper.wTransferDetailListById(id); 
 | 
        //物料信息根据仓库信息 添加至各个仓库下 返回 
 | 
        wTransferInWarehouses.forEach(i->{ 
 | 
            List<WTransferDetail> detail = new ArrayList<>(); 
 | 
            wTransferDetailList.forEach(j->{ 
 | 
                if(i.getWarehouseId() == j.getInWarehouseId()){ 
 | 
                    detail.add(j); 
 | 
                } 
 | 
            }); 
 | 
            i.setWTransferDetailList(detail); 
 | 
        }); 
 | 
        wTransfer.setWTransferWarehouseList(wTransferInWarehouses); 
 | 
        return ApiResponse.success(wTransfer); 
 | 
    } 
 | 
  
 | 
  
 | 
    /** 
 | 
     * 出入库扫描条码 
 | 
     * @param barCode 扫描条码 
 | 
     * @param type 类别:转库单/出库单/入库单 1/2/3 
 | 
     * @param pId 转库单主键/出库单主键/入库单主键 
 | 
     * @param warehouseId 仓库主键 
 | 
     * @param locationId 货位主键 
 | 
     * @param loginUserInfo 当前登录人 
 | 
     * @return 
 | 
     */ 
 | 
    @Override 
 | 
    public ApiResponse<OutScanBean> outScanAppliances(String barCode,Integer type,Integer pId,Integer warehouseId,Integer locationId,LoginUserInfo loginUserInfo){ 
 | 
        BarcodeParamExtListVO barcodeParamExtListVO =barcodeParamExtService.getByCode(loginUserInfo.getCompany().getId(),loginUserInfo.getCurComDepartment().getId(),barCode); 
 | 
        if(Objects.isNull(barcodeParamExtListVO)){ 
 | 
            throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "未查询到【BarcodeParam】对象信息"); 
 | 
        } 
 | 
        if(4 != barcodeParamExtListVO.getType()){ 
 | 
            throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "条码类别错误,非篮筐类条码"); 
 | 
        } 
 | 
        OutScanBean outScanBean = appliancesExtMapper.scanDetailForOut( 
 | 
                barcodeParamExtListVO.getId(), 
 | 
                barCode.replaceFirst(barcodeParamExtListVO.getPrefix(),"") 
 | 
                //,loginUserInfo.getCompany().getId() 
 | 
                ,loginUserInfo.getCurComDepartment().getId() 
 | 
        ); 
 | 
        if(Objects.isNull(outScanBean)){ 
 | 
            throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "未查询到条码信息"); 
 | 
        } 
 | 
  
 | 
  
 | 
//        outScanBean.setScanCode(barCode); 
 | 
        //查询物料是否在明细中 
 | 
        if(Constants.ONE == type){ 
 | 
            //查询物料是否在转库单据中 
 | 
            Integer isHave = wTransferDetailExtMapper.selectCount(new QueryWrapper<WTransferDetail>() 
 | 
                    .eq("TRANSFER_ID",pId) 
 | 
                    .eq("MATERIAL_ID",outScanBean.getMaterialId()) 
 | 
            ); 
 | 
            if(isHave <= Constants.ZERO){ 
 | 
                throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "扫描篮筐数据未存在于当前转库单中"); 
 | 
            } 
 | 
            WTransfer wTransfer = wTransferMapper.selectById(pId); 
 | 
            if(wTransfer.getStatus()==0){ 
 | 
                if(null == outScanBean.getWarehouseId() || null == outScanBean.getLocationId()){ 
 | 
                    throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "篮筐数据异常:未存在归属仓库【" + outScanBean.getId() + "】"); 
 | 
                } 
 | 
                //查询篮筐是否处于投料中 
 | 
                if(appliancesExtMapper.selectCount(new QueryWrapper<Appliances>() 
 | 
                        .eq("id",outScanBean.getId()) 
 | 
                        .apply("  id in ( select b.APPLIANCES_ID from workorder a inner join  workorder_record b on a.id = b.WORKORDER_ID and a.status in ( 0,1,2,3 ) and b.DELETED = 0   )   ") 
 | 
                )>Constants.ZERO){ 
 | 
                    throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "该工装处于投料中"); 
 | 
                }; 
 | 
  
 | 
            }else if(wTransfer.getStatus()==1){ 
 | 
                //验证扫描篮筐是否在当前操作的入库单使用的出库单中 
 | 
                if(wOutboundRecordExtMapper.selectCount(new QueryWrapper<WOutboundRecord>() 
 | 
                        .eq("APPLIANCES_ID",outScanBean.getId()) 
 | 
                        .apply(" OUTBOUND_ID in( select w.id from w_outbound w where w.ORIGIN_ID = '"+pId+"' and w.ORIGIN_TYPE = 3 and w.STATUS = 1   ) ") 
 | 
                )<=Constants.ZERO){ 
 | 
                    throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "扫描篮筐数据未存在于当前转库出库单中"); 
 | 
                }; 
 | 
  
 | 
                if(null != outScanBean.getWarehouseId() || null != outScanBean.getLocationId()){ 
 | 
                    throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "篮筐数据异常:存在归属仓库【" + outScanBean.getId() + "】"); 
 | 
                } 
 | 
            }else{ 
 | 
                throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "转库单状态错误!"); 
 | 
            } 
 | 
  
 | 
  
 | 
        }else if(Constants.TWO == type){ 
 | 
            //查询物料是否在出库单据中 
 | 
            Integer isHave =  wOutboundDetailExtMapper.selectCount(new QueryWrapper<WOutboundDetail>() 
 | 
                    .eq("OUTBOUND_ID",pId) 
 | 
                    .eq("MATERIAL_ID",outScanBean.getMaterialId()) 
 | 
//                    .eq("BATCH",outScanBean.getBatch()) 
 | 
            ); 
 | 
            if(isHave <= Constants.ZERO){ 
 | 
                throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "扫描篮筐物料数据未存在于当前出库单中"); 
 | 
            } 
 | 
            if(null == outScanBean.getWarehouseId() || null == outScanBean.getLocationId()){ 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "篮筐数据异常:未存在归属仓库【" + outScanBean.getId() + "】"); 
 | 
            } 
 | 
            //查询篮筐是否处于投料中 
 | 
            if(appliancesExtMapper.selectCount(new QueryWrapper<Appliances>() 
 | 
                    .eq("id",outScanBean.getId()) 
 | 
                    .apply("  id in ( select b.APPLIANCES_ID from workorder a inner join  workorder_record b on a.id = b.WORKORDER_ID and a.status in ( 0,1,2,3 ) and b.DELETED = 0  )  ") 
 | 
            )>Constants.ZERO){ 
 | 
                throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "该工装处于投料中"); 
 | 
            }; 
 | 
  
 | 
        }else{ 
 | 
            //获取仓库信息 
 | 
            Warehouse warehouse = warehouseMapper.selectById(warehouseId); 
 | 
            if(Objects.isNull(warehouse)){ 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到仓库数据【" + warehouseId + "】"); 
 | 
            } 
 | 
            if(null != outScanBean.getWarehouseId() || null != outScanBean.getLocationId()){ 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "篮筐数据异常:存在归属仓库【" + outScanBean.getId() + "】"); 
 | 
            } 
 | 
            WOutbound wOutbound = wOutboundMapper.selectById(pId); 
 | 
            if(Objects.isNull(wOutbound)){ 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到入库单信息"); 
 | 
            } 
 | 
            //验证扫描篮筐是否在当前操作的入库单使用的出库单中 
 | 
            if(!(wOutbound.getBillType()==28||wOutbound.getBillType()==25)&&wOutboundRecordExtMapper.selectCount(new QueryWrapper<WOutboundRecord>() 
 | 
                    .eq("APPLIANCES_ID",outScanBean.getId()) 
 | 
                    .eq("OUTBOUND_ID",pId))<=Constants.ZERO){ 
 | 
                throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "扫描篮筐数据未存在于当前出库单中"); 
 | 
            }; 
 | 
            //开启仓位 
 | 
            if(warehouse.getUseLocation()==Constants.ONE){ 
 | 
                //查询货位类别 混合无需处理 
 | 
                WarehouseLocation warehouseLocation = warehouseLocationExtMapper.selectById(locationId); 
 | 
                if(Objects.isNull(warehouseLocation)){ 
 | 
                    throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到货位信息"); 
 | 
                } 
 | 
                //根据货位类别 区分是否验证工装器具类别 
 | 
                SystemDictData systemDictData = systemDictDataMapper.selectById(warehouseLocation.getSystemDicDataId()); 
 | 
                if(Objects.isNull(systemDictData)){ 
 | 
                    throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到货位类别"); 
 | 
                } 
 | 
//                if(!Constants.isQualityTypeValid(outScanBean.getQualityType(),systemDictData.getLabel())){ 
 | 
//                    throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,工装【"+barCode+"】的质量属性与货位属性不一致!"); 
 | 
//                } 
 | 
                if(!systemDictData.getLabel().equals(Constants.APPLIANCES_TYPE_LABLE.mix)){ 
 | 
                    if(!StringUtils.equals(outScanBean.getType(),warehouseLocation.getSystemDicDataId())){ 
 | 
                        throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,工装【"+barCode+"】的质量属性与货位属性不一致!"); 
 | 
                    } 
 | 
                } 
 | 
                outScanBean.setLocationName(warehouseLocation.getUnionName()); 
 | 
            }else{ 
 | 
                //根据货位类别 区分是否验证工装器具类别 
 | 
                SystemDictData systemDictData = systemDictDataMapper.selectById(warehouse.getSystemDicDataId()); 
 | 
                if(Objects.isNull(systemDictData)){ 
 | 
                    throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到货位类别"); 
 | 
                } 
 | 
                //如果是入库操作,并且是提交数据,检查是否篮筐的质量属性,满足仓库和库位的质量属性 
 | 
//                if(!Constants.isQualityTypeValid(outScanBean.getQualityType(),systemDictData.getLabel())){ 
 | 
//                    throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,工装【"+barCode+"】的质量属性与仓库属性不一致!"); 
 | 
//                } 
 | 
                if(!systemDictData.getLabel().equals(Constants.APPLIANCES_TYPE_LABLE.mix)){ 
 | 
                    if(outScanBean.getType()!=warehouse.getSystemDicDataId()){ 
 | 
                        throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "工装属性与库位属性不一致"); 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
            //查询篮筐是否被占用 
 | 
            if(!Objects.isNull(appliancesExtMapper.selectById(outScanBean.getId()).getLocationId())){ 
 | 
                throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "篮筐使用中,无法进行入库"); 
 | 
            }; 
 | 
            //查询物料是否在入库单中 
 | 
            Integer isHave =  wOutboundDetailExtMapper.selectCount(new QueryWrapper<WOutboundDetail>() 
 | 
                    .eq("OUTBOUND_ID",pId) 
 | 
                    .eq("MATERIAL_ID",outScanBean.getMaterialId()) 
 | 
//                    .eq("BATCH",outScanBean.getBatch()) 
 | 
            ); 
 | 
            if(isHave <= Constants.ZERO){ 
 | 
                throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "扫描篮筐数据未存在于当前入库单中"); 
 | 
            } 
 | 
            //判断篮筐是否是处理 
 | 
        } 
 | 
        return ApiResponse.success(outScanBean); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    @Transactional 
 | 
    public ApiResponse saveOut(WOutBoundOutBean wOutBoundOutBean, LoginUserInfo loginUserInfo){ 
 | 
        // billType = 1  转库单(未生成出库数据) ; 2 :出库单(已存在出库数据) 
 | 
        if(Constants.ONE == wOutBoundOutBean.getBillType()){ 
 | 
            //获取转库单数据 
 | 
            WTransfer wTransfer = wTransferExtMapper.wTransferById(wOutBoundOutBean.getId()); 
 | 
            if (Objects.isNull(wTransfer)) { 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到转库单对象信息"); 
 | 
            } 
 | 
            if(wTransfer.getStatus()!=Constants.ZERO){ 
 | 
                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "转库单状态错误,无法进行出库"); 
 | 
            } 
 | 
            List<WOutBoundOutWarehouse> wOutBoundOutWarehouseList = wOutBoundOutBean.getWOutBoundOutWarehouseList(); 
 | 
            if(wOutBoundOutWarehouseList.size()==Constants.ZERO){ 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "无行数据,请检查数据信息"); 
 | 
            } 
 | 
            wOutBoundOutWarehouseList.forEach(wOutBoundOutWarehouse-> { 
 | 
                //明细行项目信息 
 | 
                List<WOutBoundOutDetailBean> wOutBoundOutDetailBeanList = wOutBoundOutWarehouse.getWOutBoundOutDetailBeanList(); 
 | 
                if (wOutBoundOutDetailBeanList.size() == Constants.ZERO) { 
 | 
                    throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "无行数据,请检查数据信息"); 
 | 
                } 
 | 
                //生成出库单单头 
 | 
                WOutbound wOutbound = new WOutbound(); 
 | 
                wOutbound.setCreateUser(loginUserInfo.getId()); 
 | 
                wOutbound.setCreateTime(new Date()); 
 | 
                wOutbound.setRootDepartId(loginUserInfo.getRootDepartment().getId()); 
 | 
                wOutbound.setDepartId(loginUserInfo.getComDepartment().getId()); 
 | 
                wOutbound.setCode(getNextOutCode(loginUserInfo.getCompany().getId())); 
 | 
                wOutbound.setOrigin(Constants.ONE); 
 | 
                wOutbound.setValidDate(new Date()); 
 | 
                wOutbound.setType(Constants.ZERO); 
 | 
                wOutbound.setOriginType(Constants.WOUTBOUND_ORIGIN_TYPE.transfer); 
 | 
                wOutbound.setOriginCode(wTransfer.getCode()); 
 | 
                wOutbound.setOriginId(wTransfer.getId()); 
 | 
                wOutbound.setUserId(loginUserInfo.getId()); 
 | 
                wOutbound.setWarehouseId(wTransfer.getOutWarehouseId()); 
 | 
                wOutbound.setDealDate(new Date()); 
 | 
                wOutbound.setStatus(Constants.ONE); 
 | 
                wOutbound.setPlanDate(wTransfer.getOutPlandate()); 
 | 
                //TODO 工序编码 wOutbound.setProcedureId(); 
 | 
                wOutboundMapper.insert(wOutbound); 
 | 
                //生成出库单明细 
 | 
                wOutBoundOutDetailBeanList.forEach(i -> { 
 | 
                    WTransferDetail wTransferDetail = wTransferDetailExtMapper.selectById(i.getId()); 
 | 
                    if (Objects.isNull(wTransferDetail)) { 
 | 
                        throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到转库单明细行数据【" + i.getId() + "】"); 
 | 
                    } 
 | 
                    //获取仓库信息 
 | 
                    Warehouse warehouse = warehouseMapper.selectById(wTransferDetail.getOutWarehouseId()); 
 | 
                    if(Objects.isNull(warehouse)){ 
 | 
                        throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到仓库数据【" + i.getId() + "】"); 
 | 
                    } 
 | 
  
 | 
                    if(wTransferDetail.getOutPlannum().compareTo(i.getOutNum())<Constants.ZERO){ 
 | 
                        throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "入库数量超出转库单已出数量!"); 
 | 
                    } 
 | 
                    QueryWrapper wrapper = new QueryWrapper<WStock>(); 
 | 
                    wrapper.eq("ROOT_DEPART_ID", wOutbound.getRootDepartId()); 
 | 
                    wrapper.eq("MATERIAL_ID", wTransferDetail.getMaterialId()); 
 | 
                    wrapper.eq("WAREHOUSE_ID", wTransferDetail.getOutWarehouseId()); 
 | 
                    if(StringUtils.isNotBlank(wTransferDetail.getBatch())){ 
 | 
                        wrapper.eq("BATCH" , i.getBatch()); 
 | 
                    }else{ 
 | 
                        wrapper.apply("BATCH is null "); 
 | 
                    } 
 | 
                    wrapper.eq(!Objects.isNull(i.getLocationId())&&warehouse.getUseLocation()==Constants.ONE,"LOCATION_ID", i.getLocationId()); 
 | 
                    wrapper.eq("DELETED",0); 
 | 
  
 | 
                    List<WStock> wStockList = wStockMapper.selectList(  wrapper ); 
 | 
                    if (wStockList.size()<=Constants.ZERO) { 
 | 
                        throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到仓库/货位库存信息【" + i.getId() + "】"); 
 | 
                    }else if(wStockList.size()>1){ 
 | 
                        throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "库存数据异常,存在多条库存信息,请检查库存数据【" + i.getId() + "】"); 
 | 
                    } 
 | 
                    WStock wStock = wStockList.get(0); 
 | 
                    if (wStock.getNum().compareTo(i.getOutNum()) < Constants.ZERO) { 
 | 
                        throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "当前货位库存数量不足;剩余数量【" + wStock.getNum() + "】;出库数量【" + i.getOutNum() + "】"); 
 | 
                    } 
 | 
                    //使用篮筐数据 
 | 
                    List<OutScanBarcodeBean> outScanBarcodeBeanList = i.getOutScanBarcodeBeanList(); 
 | 
                    if (outScanBarcodeBeanList.size() == Constants.ZERO) { 
 | 
                        throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "无扫描条码数据,请检查数据信息【" + i.getId() + "】"); 
 | 
                    } 
 | 
                    WOutboundDetail wOutboundDetail = new WOutboundDetail(); 
 | 
                    wOutboundDetail.setCreateUser(loginUserInfo.getId()); 
 | 
                    wOutboundDetail.setCreateTime(new Date()); 
 | 
                    wOutboundDetail.setRootDepartId(loginUserInfo.getRootDepartment().getId()); 
 | 
                    wOutboundDetail.setOutboundId(wOutbound.getId()); 
 | 
                    wOutboundDetail.setMaterialId(wTransferDetail.getMaterialId()); 
 | 
                    wOutboundDetail.setUnitId(wTransferDetail.getUnitId()); 
 | 
                    wOutboundDetail.setBatch(i.getBatch()); 
 | 
                    wOutboundDetail.setNum(i.getOutNum()); 
 | 
                    wOutboundDetail.setDoneDate(new Date()); 
 | 
                    wOutboundDetail.setWarehouseId(wOutbound.getWarehouseId()); 
 | 
                    wOutboundDetail.setLocationId(i.getLocationId()); 
 | 
                    wOutboundDetail.setStatus(Constants.ONE); 
 | 
                    wOutboundDetail.setDoneNum(i.getOutNum()); 
 | 
                    wOutboundDetailExtMapper.insert(wOutboundDetail); 
 | 
                    // 更新货位库存 
 | 
                    if (i.getOutNum().compareTo(wStock.getNum()) > Constants.ZERO) { 
 | 
                        throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "货位库存不足,请刷新查看"); 
 | 
                    } 
 | 
                    wStock.setNum(wStock.getNum().subtract(i.getOutNum())); 
 | 
                    wStockExtMapper.updateById(wStock); 
 | 
                    // 更新篮筐数据 
 | 
                    updAppliances(outScanBarcodeBeanList,wOutbound.getId()); 
 | 
                    // 添加操作记录 
 | 
                    saveOutBoundRecord(outScanBarcodeBeanList, wOutboundDetail, loginUserInfo); 
 | 
                }); 
 | 
            }); 
 | 
            //更新转库单信息 
 | 
            updWTransfer(wOutBoundOutBean,wTransfer); 
 | 
  
 | 
            CompanyUser companyUser = companyUserMapper.selectOne(new QueryWrapper<CompanyUser>() 
 | 
                    .eq("USER_ID",wTransfer.getInUserId()) 
 | 
                    .eq("ROOT_DEPART_ID",wTransfer.getRootDepartId()) 
 | 
                    .eq("DELETED",0) 
 | 
            ); 
 | 
            //处理通知 
 | 
            if(wTransfer.getType() == Constants.ONE){ 
 | 
                noticesExtService.dealNotice(wTransfer.getId(),Constants.Notices_Type.workShopOut.getType(),null); 
 | 
                sendNotice(companyUser.getId(),wTransfer.getId(),wTransfer.getCode(),Constants.Notices_Type.workShopIn,Constants.getNoticeUrl(loginUserInfo.getCompany(),Constants.DINGDING_NOTICE_URL.in)); 
 | 
            }else if(wTransfer.getType() == Constants.TWO){ 
 | 
                noticesExtService.dealNotice(wTransfer.getId(),Constants.Notices_Type.transferWaitOut.getType(),null); 
 | 
                sendNotice(companyUser.getId(),wTransfer.getId(),wTransfer.getCode(),Constants.Notices_Type.transferWaitIn,Constants.getNoticeUrl(loginUserInfo.getCompany(),Constants.DINGDING_NOTICE_URL.finish)); 
 | 
            }else if(wTransfer.getType() == 3){ 
 | 
                noticesExtService.dealNotice(wTransfer.getId(),Constants.Notices_Type.wStockTransferOut.getType(),null); 
 | 
                sendNotice(companyUser.getId(),wTransfer.getId(),wTransfer.getCode(),Constants.Notices_Type.wStockTransferIn,Constants.getNoticeUrl(loginUserInfo.getCompany(),Constants.DINGDING_NOTICE_URL.in)); 
 | 
            } 
 | 
  
 | 
            }else if(Constants.TWO == wOutBoundOutBean.getBillType()){ //使用出库单出库 
 | 
                WOutbound wOutbound = wOutboundMapper.selectById(wOutBoundOutBean.getId()); 
 | 
                if(Objects.isNull(wOutbound)){ 
 | 
                    throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到出库单据信息"); 
 | 
                } 
 | 
                List<WOutBoundOutWarehouse> wOutBoundOutWarehouseList = wOutBoundOutBean.getWOutBoundOutWarehouseList(); 
 | 
                if(wOutBoundOutWarehouseList.size()==Constants.ZERO){ 
 | 
                    throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "无行数据,请检查数据信息"); 
 | 
                } 
 | 
                for (WOutBoundOutWarehouse wOutBoundOutWarehouse:wOutBoundOutWarehouseList) { 
 | 
                    List<WOutBoundOutDetailBean> wOutBoundOutDetailBeanList = wOutBoundOutWarehouse.getWOutBoundOutDetailBeanList(); 
 | 
                    wOutBoundOutDetailBeanList.forEach(i->{ 
 | 
                        WOutboundDetail wOutboundDetail = wOutboundDetailExtMapper.selectById(i.getId()); 
 | 
                        //更新出库单明细 实际出库数量 
 | 
                        if(wOutboundDetail.getStatus() == Constants.ZERO){ 
 | 
                            updWOutBoundDetail(wOutBoundOutDetailBeanList,wOutboundDetail); 
 | 
                        } 
 | 
                        //使用篮筐数据 
 | 
                        List<OutScanBarcodeBean> outScanBarcodeBeanList = i.getOutScanBarcodeBeanList(); 
 | 
                        if(outScanBarcodeBeanList.size() == Constants.ZERO ){ 
 | 
                            throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "无扫描条码数据,请检查数据信息【"+i.getId()+"】"); 
 | 
                        } 
 | 
                        //获取仓库信息 
 | 
                        Warehouse warehouse = warehouseMapper.selectById(wOutboundDetail.getWarehouseId()); 
 | 
                        if(Objects.isNull(warehouse)){ 
 | 
                            throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到仓库数据【" + i.getId() + "】"); 
 | 
                        } 
 | 
                        List<WStock> wStockList = wStockMapper.selectList(new QueryWrapper<WStock>() 
 | 
                                .eq("ROOT_DEPART_ID", wOutbound.getRootDepartId()) 
 | 
                                .eq("MATERIAL_ID", wOutboundDetail.getMaterialId()) 
 | 
                                .eq("WAREHOUSE_ID", wOutboundDetail.getWarehouseId()) 
 | 
                                .eq(StringUtils.isNotBlank(wOutboundDetail.getBatch()),"BATCH", i.getBatch()) 
 | 
                                .eq(StringUtils.isNotBlank(wOutboundDetail.getBatch())&&warehouse.getUseLocation()==Constants.ONE,"LOCATION_ID", i.getLocationId()) 
 | 
                        ); 
 | 
                        if (wStockList.size()<=Constants.ZERO) { 
 | 
                            throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到仓库/货位库存信息【" + i.getId() + "】"); 
 | 
                        }else if(wStockList.size()>1){ 
 | 
                            throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "库存数据异常,存在多条库存信息,请检查库存数据【" + i.getId() + "】"); 
 | 
                        } 
 | 
                        WStock wStock = wStockList.get(0); 
 | 
                        if(i.getOutNum().compareTo(wStock.getNum())>Constants.ZERO){ 
 | 
                            throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "货位库存不足,请刷新查看"); 
 | 
                        } 
 | 
                        // 更新货位库存 
 | 
                        wStock.setNum(wStock.getNum().subtract(i.getOutNum())); 
 | 
                        wStockExtMapper.updateById(wStock); 
 | 
                        // 更新篮筐数据 取消绑定关系 
 | 
                        updAppliances(outScanBarcodeBeanList,wOutbound.getId()); 
 | 
                        // 添加操作记录 
 | 
                        saveOutBoundRecord(outScanBarcodeBeanList,wOutboundDetail,loginUserInfo); 
 | 
                    }); 
 | 
                } 
 | 
                wOutbound.setStatus(Constants.ONE); 
 | 
                wOutbound.setUpdateTime(new Date()); 
 | 
                wOutbound.setUpdateUser(loginUserInfo.getId()); 
 | 
                wOutbound.setDealDate(new Date()); 
 | 
                wOutboundMapper.updateById(wOutbound); 
 | 
            } 
 | 
        return ApiResponse.success("操作成功"); 
 | 
    } 
 | 
  
 | 
  
 | 
    public void sendNotice(Integer userId ,Integer billId , String billCode ,Constants.Notices_Type notices_type,String url){ 
 | 
        //发送通知 
 | 
        Notices notices = new Notices(); 
 | 
        notices.setCompanyUserId(userId); 
 | 
        notices.setType(notices_type.getType()); 
 | 
        notices.setContent("【"+billCode+"】"+ notices_type.getContent()); 
 | 
        notices.setTitle(notices_type.getTitle()); 
 | 
        notices.setObjId(billId); 
 | 
        notices.setUrl(url.replace("{id}",billId.toString()).replace("{type}","9")); 
 | 
        noticesExtService.sendNotice(notices); 
 | 
    } 
 | 
  
 | 
  
 | 
  
 | 
  
 | 
    /** 
 | 
     * 更新转库单明细信息 
 | 
     * @param wOutBoundOutBean 
 | 
     * @param wTransfer 
 | 
     */ 
 | 
    public void updWTransfer(WOutBoundOutBean wOutBoundOutBean,WTransfer wTransfer){ 
 | 
        List<WTransferDetail> wTransferDetailList = wTransferDetailMapper.selectList( 
 | 
                new QueryWrapper<WTransferDetail>().eq("TRANSFER_ID",wTransfer.getId()) 
 | 
        ); 
 | 
        if(wOutBoundOutBean.getBillType()==Constants.ONE&&wTransfer.getStatus()==Constants.ZERO){ 
 | 
            //更新转库单明细已出库数量 
 | 
            wTransferDetailList.forEach(i->{ 
 | 
                BigDecimal outNum = BigDecimal.ZERO; 
 | 
                List<WOutBoundOutWarehouse> wOutBoundOutWarehouseList = wOutBoundOutBean.getWOutBoundOutWarehouseList(); 
 | 
                for (WOutBoundOutWarehouse wOutBoundOutWarehouse:wOutBoundOutWarehouseList) { 
 | 
                    List<WOutBoundOutDetailBean> wOutBoundOutDetailBeanList =  wOutBoundOutWarehouse.getWOutBoundOutDetailBeanList(); 
 | 
                    for (WOutBoundOutDetailBean w:wOutBoundOutDetailBeanList) { 
 | 
                        if(w.getId().toString().equals(i.getId().toString())){ 
 | 
                            outNum = outNum.add(w.getOutNum()); 
 | 
                        } 
 | 
                    } 
 | 
                }; 
 | 
                i.setOutActnum(outNum); 
 | 
                i.setOutActdate(new Date()); 
 | 
                wTransferDetailExtMapper.updateById(i); 
 | 
            }); 
 | 
            //更新转库单状态 
 | 
            wTransfer.setStatus(Constants.ONE); 
 | 
            wTransfer.setOutActdate(new Date()); 
 | 
        }else  if(wOutBoundOutBean.getBillType()==Constants.ONE&&wTransfer.getStatus()==Constants.ONE){ 
 | 
            wTransferDetailList.forEach(i->{ 
 | 
                BigDecimal inNum = BigDecimal.ZERO; 
 | 
                List<WOutBoundOutWarehouse> wOutBoundOutWarehouseList = wOutBoundOutBean.getWOutBoundOutWarehouseList(); 
 | 
                for (WOutBoundOutWarehouse wOutBoundOutWarehouse:wOutBoundOutWarehouseList) { 
 | 
                    List<WOutBoundOutDetailBean> wOutBoundOutDetailBeanList =  wOutBoundOutWarehouse.getWOutBoundOutDetailBeanList(); 
 | 
                    for (WOutBoundOutDetailBean w:wOutBoundOutDetailBeanList) { 
 | 
                        if(w.getId().toString().equals(i.getId().toString())){ 
 | 
                            inNum = inNum.add(w.getOutNum()); 
 | 
                        } 
 | 
                    } 
 | 
                }; 
 | 
                i.setInActnum(inNum); 
 | 
                i.setInActdate(new Date()); 
 | 
                wTransferDetailExtMapper.updateById(i); 
 | 
            }); 
 | 
            wTransfer.setStatus(Constants.TWO); 
 | 
            wTransfer.setInActdate(new Date()); 
 | 
        } 
 | 
        wTransferExtMapper.updateById(wTransfer); 
 | 
    } 
 | 
  
 | 
  
 | 
    /** 
 | 
     * 更新出入库明细行数据 
 | 
     * @param wOutBoundOutDetailBeanList 
 | 
     * @param wOutboundDetail 
 | 
     */ 
 | 
    public void updWOutBoundDetail(List<WOutBoundOutDetailBean> wOutBoundOutDetailBeanList,WOutboundDetail wOutboundDetail){ 
 | 
        BigDecimal num = BigDecimal.ZERO; 
 | 
        for (WOutBoundOutDetailBean w: wOutBoundOutDetailBeanList) { 
 | 
            if(w.getId() == wOutboundDetail.getId()){ 
 | 
                num = num.add(w.getOutNum()); 
 | 
            } 
 | 
        } 
 | 
        wOutboundDetail.setStatus(Constants.ONE); 
 | 
        wOutboundDetail.setNum(num); 
 | 
        wOutboundDetailExtMapper.updateById(wOutboundDetail); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 更新工装器具信息 - 出库 
 | 
     * @param outScanBarcodeBeanList 
 | 
     * @param curObjId 
 | 
     */ 
 | 
    public void updAppliances(List<OutScanBarcodeBean> outScanBarcodeBeanList,Integer curObjId){ 
 | 
        outScanBarcodeBeanList.forEach(j->{ 
 | 
            Appliances appliances = appliancesExtMapper.selectById(j.getAppliancesId()); 
 | 
            if(Objects.isNull(appliances)){ 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到工装器具信息【"+j.getAppliancesId()+"】"); 
 | 
            } 
 | 
            appliances.setWarehouseId(null); 
 | 
            appliances.setLocationId(null); 
 | 
            appliances.setCurObjId(curObjId); 
 | 
            appliances.setCurObjType(0); 
 | 
            appliancesExtMapper.updateById(appliances); 
 | 
        }); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 保存出库明细记录 
 | 
     * @param outScanBarcodeBeanList 
 | 
     * @param wOutboundDetail 
 | 
     * @param loginUserInfo 
 | 
     */ 
 | 
    public void saveOutBoundRecord(List<OutScanBarcodeBean> outScanBarcodeBeanList,WOutboundDetail wOutboundDetail,LoginUserInfo loginUserInfo){ 
 | 
        List<WOutboundRecord> wOutboundRecordList = new ArrayList<>(); 
 | 
        outScanBarcodeBeanList.forEach(j->{ 
 | 
            WOutboundRecord wOutboundRecord = new WOutboundRecord(); 
 | 
            wOutboundRecord.setCreateTime(new Date()); 
 | 
            wOutboundRecord.setCreateUser(loginUserInfo.getId()); 
 | 
            wOutboundRecord.setOutboundId(wOutboundDetail.getOutboundId()); 
 | 
            wOutboundRecord.setDetailId(wOutboundDetail.getId()); 
 | 
            wOutboundRecord.setMaterialId(wOutboundDetail.getMaterialId()); 
 | 
            wOutboundRecord.setUnitId(wOutboundDetail.getUnitId()); 
 | 
            wOutboundRecord.setRootDepartId(wOutboundDetail.getRootDepartId()); 
 | 
            wOutboundRecord.setBatch(j.getBatch()); 
 | 
            wOutboundRecord.setNum(j.getNum()); 
 | 
            wOutboundRecord.setWarehouseId(wOutboundDetail.getWarehouseId()); 
 | 
            wOutboundRecord.setAppliancesId(j.getAppliancesId()); 
 | 
            wOutboundRecordList.add(wOutboundRecord); 
 | 
            wOutboundRecordExtMapper.insert(wOutboundRecord); 
 | 
        }); 
 | 
//        wOutboundRecordExtMapper.insertBatch(wOutboundRecordList); 
 | 
    } 
 | 
  
 | 
  
 | 
//    @Override 
 | 
//    @Transactional 
 | 
//    public ApiResponse saveInByOut(WOutBoundInBean wOutBoundInBean, LoginUserInfo loginUserInfo){ 
 | 
//        WOutbound wOutbound = wOutboundExtMapper.selectById(wOutBoundInBean.getId()); 
 | 
//        if(Objects.isNull(wOutbound)){ 
 | 
//            throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到出库单据信息【"+wOutBoundInBean.getWOutBoundInDetailBeanList()+"】"); 
 | 
//        }else if(Objects.isNull(wOutbound.getOriginId())){ 
 | 
//            throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "出库单未关联转库单信息"); 
 | 
//        } 
 | 
//        WTransfer wTransfer = wTransferExtMapper.wTransferById(wOutbound.getOriginId()); 
 | 
//        if(Objects.isNull(wTransfer)){ 
 | 
//            throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到转库据信息【"+wOutbound.getOriginId()+"】"); 
 | 
//        } 
 | 
//        List<WOutBoundInDetailBean> wOutBoundInDetailBeanList = wOutBoundInBean.getWOutBoundInDetailBeanList(); 
 | 
//        if(wOutBoundInDetailBeanList.size()<=Constants.ZERO){ 
 | 
//            throw new BusinessException(ResponseStatus.DEFECT_PARAMETER.getCode(), "未传入入库行数据信息"); 
 | 
//        } 
 | 
//        WOutbound wOutboundIn = new WOutbound(); 
 | 
//        wOutboundIn.setCreateUser(loginUserInfo.getId()); 
 | 
//        wOutboundIn.setCreateTime(new Date()); 
 | 
//        wOutboundIn.setRootDepartId(loginUserInfo.getRootDepartment().getId()); 
 | 
//        wOutboundIn.setDepartId(loginUserInfo.getDepartment().getId()); 
 | 
//        // 单据编码 RK-20220519-0001 
 | 
//        wOutboundIn.setCode(getNextInCode(loginUserInfo.getCompany().getId())); 
 | 
//        wOutboundIn.setOrigin(Constants.ONE); 
 | 
//        wOutboundIn.setValidDate(new Date()); 
 | 
//        wOutboundIn.setType(Constants.ONE); 
 | 
//        wOutboundIn.setOriginType(3); 
 | 
//        wOutboundIn.setOriginCode(wTransfer.getCode()); 
 | 
//        wOutboundIn.setOriginId(wTransfer.getId()); 
 | 
//        wOutboundIn.setUserId(wTransfer.getInUserId()); 
 | 
//        wOutboundIn.setWarehouseId(wTransfer.getInWarehouseId()); 
 | 
//        wOutboundIn.setStatus(Constants.ONE); 
 | 
//        wOutboundIn.setDealDate(new Date()); 
 | 
//        wOutboundIn.setPlanDate(wTransfer.getInPlandate()); 
 | 
//        wOutboundExtMapper.insert(wOutboundIn); 
 | 
// 
 | 
//        wOutBoundInDetailBeanList.forEach(i->{ 
 | 
//            WOutboundDetail wOutboundDetail = new WOutboundDetail(); 
 | 
//            wOutboundDetail.setCreateUser(loginUserInfo.getId()); 
 | 
//            wOutboundDetail.setCreateTime(new Date()); 
 | 
//            wOutboundDetail.setRootDepartId(wOutboundIn.getRootDepartId()); 
 | 
//            wOutboundDetail.setOutboundId(wOutboundIn.getId()); 
 | 
//            wOutboundDetail.setMaterialId(i.getMaterialId()); 
 | 
//            wOutboundDetail.setUnitId(i.getUnitId()); 
 | 
//            wOutboundDetail.setBatch(i.getBatch()); 
 | 
//            wOutboundDetail.setNum(i.getNum()); 
 | 
//            wOutboundDetail.setWarehouseId(wOutboundIn.getWarehouseId()); 
 | 
//            wOutboundDetail.setLocationId(i.getLocationId()); 
 | 
//            wOutboundDetail.setStatus(Constants.ONE); 
 | 
//            wOutboundDetail.setDoneDate(new Date()); 
 | 
//            wOutboundDetail.setDoneNum(i.getNum()); 
 | 
//            wOutboundDetailExtMapper.insert(wOutboundDetail); 
 | 
//            WOutboundRecord wOutboundRecord = new WOutboundRecord(); 
 | 
//            BeanUtils.copyProperties(wOutboundDetail,wOutboundRecord); 
 | 
//            wOutboundRecord.setId(null); 
 | 
//            wOutboundRecord.setDetailId(wOutboundDetail.getId()); 
 | 
//            wOutboundRecordExtMapper.insert(wOutboundRecord); 
 | 
//            //获取货位库存信息 
 | 
//            WStock wStock = wStockMapper.selectOne(new QueryWrapper<WStock>() 
 | 
//                    .eq("ROOT_DEPART_ID",wOutbound.getRootDepartId()) 
 | 
//                    .eq("WAREHOUSE_ID",wTransfer.getInWarehouseId()) 
 | 
//                    .eq("LOCATION_ID",i.getLocationId()) 
 | 
//                    .eq("DELETED",Constants.ZERO) 
 | 
//            ); 
 | 
//            if(Objects.isNull(wStock)){ 
 | 
//                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到库位信息【"+i.getLocationId()+"】"); 
 | 
//            } 
 | 
//            //更新货位库存 
 | 
//            if(StringUtils.isEmpty(wStock.getBatch())&&Objects.isNull(wStock.getMaterialId())){ 
 | 
//                wStock.setBatch(i.getBatch()); 
 | 
//                wStock.setMaterialId(i.getMaterialId()); 
 | 
//                wStock.setUnitId(i.getUnitId()); 
 | 
//                wStock.setNum(i.getNum()); 
 | 
//                wStockMapper.updateById(wStock); 
 | 
//            }else{ 
 | 
//                wStock.setNum(wStock.getNum().add(i.getNum())); 
 | 
//                wStockExtMapper.updateById(wStock); 
 | 
//            } 
 | 
//            //更新篮筐数据 
 | 
//            updInAppliances(i.getOutScanBarcodeBeanList(),wOutboundDetail); 
 | 
//        }); 
 | 
//        return ApiResponse.success("操作成功"); 
 | 
//    } 
 | 
  
 | 
    /** 
 | 
     * 更新工装器具信息 - 入库 
 | 
     * @param outScanBarcodeBeanList 
 | 
     * @param wOutboundDetail 
 | 
     */ 
 | 
    public void updInAppliances(List<OutScanBarcodeBean> outScanBarcodeBeanList,WOutboundDetail wOutboundDetail){ 
 | 
        outScanBarcodeBeanList.forEach(j->{ 
 | 
            Appliances appliances = appliancesExtMapper.selectById(j.getAppliancesId()); 
 | 
            if(Objects.isNull(appliances)){ 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到工装器具信息【"+j.getAppliancesId()+"】"); 
 | 
            } 
 | 
            appliances.setWarehouseId(wOutboundDetail.getWarehouseId()); 
 | 
            appliances.setLocationId(wOutboundDetail.getLocationId()); 
 | 
            appliances.setCurObjId(wOutboundDetail.getOutboundId()); 
 | 
            appliances.setCurObjType(Constants.ZERO); 
 | 
            appliancesExtMapper.updateById(appliances); 
 | 
        }); 
 | 
    } 
 | 
  
 | 
  
 | 
  
 | 
    @Override 
 | 
    @Transactional 
 | 
    public ApiResponse saveIn(WOutBoundOutBean wOutBoundOutBean, LoginUserInfo loginUserInfo){ 
 | 
        // billType = 1  转库单(未生成入库数据) ; 2 :入库单(已存在入库数据) 
 | 
        if(Constants.ONE == wOutBoundOutBean.getBillType()){ 
 | 
            //获取转库单数据 
 | 
            WTransfer wTransfer = wTransferExtMapper.wTransferById(wOutBoundOutBean.getId()); 
 | 
            if (Objects.isNull(wTransfer)) { 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到转库单对象信息"); 
 | 
            } 
 | 
            if(wTransfer.getStatus()!=Constants.ONE){ 
 | 
                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "转库单状态错误,无法进行入库"); 
 | 
            } 
 | 
            List<WOutBoundOutWarehouse> wOutBoundOutWarehouseList = wOutBoundOutBean.getWOutBoundOutWarehouseList(); 
 | 
            if(wOutBoundOutWarehouseList.size()==Constants.ZERO){ 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "无行数据,请检查数据信息"); 
 | 
            } 
 | 
            wOutBoundOutWarehouseList.forEach(wOutBoundOutWarehouse-> { 
 | 
                //明细行项目信息 
 | 
                List<WOutBoundOutDetailBean> wOutBoundOutDetailBeanList = wOutBoundOutWarehouse.getWOutBoundOutDetailBeanList(); 
 | 
                if (wOutBoundOutDetailBeanList.size() == Constants.ZERO) { 
 | 
                    throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "无行数据,请检查数据信息"); 
 | 
                } 
 | 
                //生成入库单单头 
 | 
                WOutbound wOutbound = new WOutbound(); 
 | 
                wOutbound.setCreateUser(loginUserInfo.getId()); 
 | 
                wOutbound.setCreateTime(new Date()); 
 | 
                wOutbound.setRootDepartId(loginUserInfo.getRootDepartment().getId()); 
 | 
                wOutbound.setDepartId(loginUserInfo.getComDepartment().getId()); 
 | 
                wOutbound.setCode(getNextInCode(loginUserInfo.getCompany().getId()));//单据编码 CK-20220519-0001 
 | 
                wOutbound.setOrigin(Constants.ONE); 
 | 
                wOutbound.setValidDate(new Date()); 
 | 
                wOutbound.setType(Constants.ONE); 
 | 
                wOutbound.setOriginType(3); 
 | 
                wOutbound.setOriginCode(wTransfer.getCode()); 
 | 
                wOutbound.setOriginId(wTransfer.getId()); 
 | 
                wOutbound.setUserId(loginUserInfo.getId()); 
 | 
                wOutbound.setWarehouseId(wTransfer.getInWarehouseId()); 
 | 
                wOutbound.setDealDate(new Date()); 
 | 
                wOutbound.setStatus(Constants.ONE); 
 | 
                wOutbound.setPlanDate(wTransfer.getInPlandate()); 
 | 
                //TODO 工序编码 wOutbound.setProcedureId(); 
 | 
                wOutboundMapper.insert(wOutbound); 
 | 
                //生成入库单明细 
 | 
                wOutBoundOutDetailBeanList.forEach(i -> { 
 | 
                    WTransferDetail wTransferDetail = wTransferDetailExtMapper.selectById(i.getId()); 
 | 
                    if (Objects.isNull(wTransferDetail)) { 
 | 
                        throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到转库单明细行数据【" + i.getId() + "】"); 
 | 
                    } 
 | 
                    if(wTransferDetail.getOutActnum().compareTo(i.getOutNum())<Constants.ZERO){ 
 | 
                        throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "入库数量超出转库单已出数量!"); 
 | 
                    } 
 | 
                    //使用篮筐数据 
 | 
                    List<OutScanBarcodeBean> outScanBarcodeBeanList = i.getOutScanBarcodeBeanList(); 
 | 
                    if (outScanBarcodeBeanList.size() == Constants.ZERO) { 
 | 
                        throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "无扫描条码数据,请检查数据信息【" + i.getId() + "】"); 
 | 
                    } 
 | 
                    WOutboundDetail wOutboundDetail = new WOutboundDetail(); 
 | 
                    wOutboundDetail.setCreateUser(loginUserInfo.getId()); 
 | 
                    wOutboundDetail.setCreateTime(new Date()); 
 | 
                    wOutboundDetail.setRootDepartId(loginUserInfo.getRootDepartment().getId()); 
 | 
                    wOutboundDetail.setOutboundId(wOutbound.getId()); 
 | 
                    wOutboundDetail.setMaterialId(wTransferDetail.getMaterialId()); 
 | 
                    wOutboundDetail.setUnitId(wTransferDetail.getUnitId()); 
 | 
                    wOutboundDetail.setBatch(i.getBatch()); 
 | 
                    wOutboundDetail.setNum(wTransferDetail.getOutActnum()); 
 | 
                    wOutboundDetail.setDoneDate(new Date()); 
 | 
                    wOutboundDetail.setWarehouseId(wOutbound.getWarehouseId()); 
 | 
                    wOutboundDetail.setLocationId(i.getLocationId()); 
 | 
                    wOutboundDetail.setStatus(Constants.ONE); 
 | 
                    wOutboundDetail.setDoneNum(i.getOutNum()); 
 | 
                    wOutboundDetailExtMapper.insert(wOutboundDetail); 
 | 
                    //仓库数据 
 | 
                    Warehouse warehouse = warehouseMapper.selectById(wTransferDetail.getOutWarehouseId()); 
 | 
                    if(Objects.isNull(warehouse)){ 
 | 
                        throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到仓库数据【" + i.getId() + "】"); 
 | 
                    } 
 | 
  
 | 
                    QueryWrapper wrapper = new QueryWrapper<WStock>(); 
 | 
                    wrapper.eq("ROOT_DEPART_ID", wOutbound.getRootDepartId()); 
 | 
                    wrapper.eq("MATERIAL_ID", wTransferDetail.getMaterialId()); 
 | 
                    wrapper.eq("WAREHOUSE_ID", wTransferDetail.getInWarehouseId()); 
 | 
                    if(StringUtils.isNotBlank(wTransferDetail.getBatch())){ 
 | 
                        wrapper.eq("BATCH" , i.getBatch()); 
 | 
                    }else{ 
 | 
                        wrapper.apply("BATCH is null "); 
 | 
                    } 
 | 
                    wrapper.eq(!Objects.isNull(i.getLocationId())&&warehouse.getUseLocation()==Constants.ONE,"LOCATION_ID", i.getLocationId()); 
 | 
                    wrapper.eq("DELETED",0); 
 | 
  
 | 
                    //获取货位库存信息 
 | 
                    WStock wStock = wStockMapper.selectOne(wrapper); 
 | 
                    if (Objects.isNull(wStock)) { 
 | 
                        WStock newWStock = new WStock(); 
 | 
                        newWStock.setCreateTime(new Date()); 
 | 
                        newWStock.setCreateUser(loginUserInfo.getId()); 
 | 
                        newWStock.setRootDepartId(wOutbound.getRootDepartId()); 
 | 
                        newWStock.setMaterialId(wTransferDetail.getMaterialId()); 
 | 
                        newWStock.setBatch(i.getBatch()); 
 | 
                        newWStock.setDeleted(Constants.ZERO); 
 | 
                        newWStock.setWarehouseId(wTransferDetail.getInWarehouseId()); 
 | 
                        //此仓库 开启仓位 
 | 
                        if(warehouse.getUseLocation()==Constants.ONE){ 
 | 
                            newWStock.setLocationId(i.getLocationId()); 
 | 
                        } 
 | 
                        newWStock.setUnitId(wTransferDetail.getUnitId()); 
 | 
                        newWStock.setNum(i.getOutNum()); 
 | 
                        wStockMapper.insert(newWStock); 
 | 
                    }else{ 
 | 
                        wStock.setNum(wStock.getNum().add(i.getOutNum())); 
 | 
                        wStockExtMapper.updateById(wStock); 
 | 
                    } 
 | 
                    // 更新篮筐数据 
 | 
                    updInAppliances(i.getOutScanBarcodeBeanList(),wOutboundDetail); 
 | 
                    // 添加操作记录 
 | 
                    saveOutBoundRecord(outScanBarcodeBeanList, wOutboundDetail, loginUserInfo); 
 | 
                }); 
 | 
            }); 
 | 
            //更新转库单信息 
 | 
            updWTransfer(wOutBoundOutBean,wTransfer); 
 | 
  
 | 
            //处理通知 
 | 
            if(wTransfer.getType() == Constants.ONE){ 
 | 
                noticesExtService.dealNotice(wTransfer.getId(),Constants.Notices_Type.workShopIn.getType(),null); 
 | 
            }else if(wTransfer.getType() == Constants.TWO){ 
 | 
                noticesExtService.dealNotice(wTransfer.getId(),Constants.Notices_Type.transferWaitIn.getType(),null); 
 | 
            }else if(wTransfer.getType() == 3){ 
 | 
                noticesExtService.dealNotice(wTransfer.getId(),Constants.Notices_Type.wStockTransferIn.getType(),null); 
 | 
            }else if(wTransfer.getType() == 4){ 
 | 
                noticesExtService.dealNotice(wTransfer.getId(),Constants.Notices_Type.finishIn.getType(),null); 
 | 
            } 
 | 
  
 | 
        }else if(Constants.TWO == wOutBoundOutBean.getBillType()){ //使用入库单入库 
 | 
            WOutbound wOutbound = wOutboundMapper.selectById(wOutBoundOutBean.getId()); 
 | 
            if(Objects.isNull(wOutbound)){ 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到入库单据信息"); 
 | 
            } 
 | 
            if(wOutbound.getStatus()!=Constants.ZERO){ 
 | 
                throw new BusinessException(ResponseStatus.ERR_STATUS.getCode(), "入库单据已操作,无法再次处理"); 
 | 
            } 
 | 
            List<WOutBoundOutWarehouse> wOutBoundOutWarehouseList = wOutBoundOutBean.getWOutBoundOutWarehouseList(); 
 | 
            if(wOutBoundOutWarehouseList.size()==Constants.ZERO){ 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "无行数据,请检查数据信息"); 
 | 
            } 
 | 
            for (WOutBoundOutWarehouse wOutBoundOutWarehouse:wOutBoundOutWarehouseList) { 
 | 
                List<WOutBoundOutDetailBean> wOutBoundOutDetailBeanList = wOutBoundOutWarehouse.getWOutBoundOutDetailBeanList(); 
 | 
                wOutBoundOutDetailBeanList.forEach(i->{ 
 | 
                    WOutboundDetail wOutboundDetail = wOutboundDetailExtMapper.selectById(i.getId()); 
 | 
                    //更新入库单明细 实际入库数量 
 | 
                    if(wOutboundDetail.getStatus() == Constants.ZERO){ 
 | 
                        updWOutBoundDetail(wOutBoundOutDetailBeanList,wOutboundDetail); 
 | 
                    } 
 | 
                    //使用篮筐数据 
 | 
                    List<OutScanBarcodeBean> outScanBarcodeBeanList = i.getOutScanBarcodeBeanList(); 
 | 
                    if(outScanBarcodeBeanList.size() == Constants.ZERO ){ 
 | 
                        throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "无扫描条码数据,请检查数据信息【"+i.getId()+"】"); 
 | 
                    } 
 | 
                    //仓库数据 
 | 
                    Warehouse warehouse = warehouseMapper.selectById(wOutbound.getWarehouseId()); 
 | 
                    if(Objects.isNull(warehouse)){ 
 | 
                        throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到仓库数据【" + i.getId() + "】"); 
 | 
                    } 
 | 
  
 | 
                    //获取货位库存信息 
 | 
                    WStock wStock = wStockMapper.selectOne(new QueryWrapper<WStock>() 
 | 
                            .eq("ROOT_DEPART_ID", wOutbound.getRootDepartId()) 
 | 
                            .eq("MATERIAL_ID", wOutboundDetail.getMaterialId()) 
 | 
                            .eq("WAREHOUSE_ID", wOutbound.getWarehouseId()) 
 | 
                            .eq("BATCH", i.getBatch()) 
 | 
                            .eq(warehouse.getUseLocation()==Constants.ONE,"LOCATION_ID", i.getLocationId()) 
 | 
                    ); 
 | 
                    if (Objects.isNull(wStock)) { 
 | 
                        WStock newWStock = new WStock(); 
 | 
                        newWStock.setCreateTime(new Date()); 
 | 
                        newWStock.setCreateUser(loginUserInfo.getId()); 
 | 
                        newWStock.setRootDepartId(wOutbound.getRootDepartId()); 
 | 
                        newWStock.setMaterialId(wOutboundDetail.getMaterialId()); 
 | 
                        newWStock.setBatch(i.getBatch()); 
 | 
                        newWStock.setWarehouseId(wOutbound.getWarehouseId()); 
 | 
                        //此仓库 开启仓位 
 | 
                        if(warehouse.getUseLocation()==Constants.ONE){ 
 | 
                            newWStock.setLocationId(i.getLocationId()); 
 | 
                        } 
 | 
                        newWStock.setUnitId(wOutboundDetail.getUnitId()); 
 | 
                        newWStock.setNum(i.getOutNum()); 
 | 
                        wStockMapper.insert(newWStock); 
 | 
                    }else{ 
 | 
                        wStock.setNum(wStock.getNum().add(i.getOutNum())); 
 | 
                        wStockExtMapper.updateById(wStock); 
 | 
                    } 
 | 
                    // 更新篮筐数据 
 | 
                    updInAppliances(i.getOutScanBarcodeBeanList(),wOutboundDetail); 
 | 
                    // 添加操作记录 
 | 
                    saveOutBoundRecord(outScanBarcodeBeanList,wOutboundDetail,loginUserInfo); 
 | 
                }); 
 | 
            } 
 | 
            wOutbound.setStatus(Constants.ONE); 
 | 
            wOutbound.setDealDate(new Date()); 
 | 
            wOutboundMapper.updateById(wOutbound); 
 | 
        } 
 | 
        return ApiResponse.success("操作成功"); 
 | 
    } 
 | 
  
 | 
  
 | 
    @Override 
 | 
    public synchronized  String  getNextInCode(Integer comId ){ 
 | 
        String prefix =  "RK-" + DateUtil.getDate(new Date(),"yyyyMMdd") +"-"; 
 | 
        Integer countNum  = RedisUtil.getObject(redisTemplate,Constants.RedisKeys.COM_OUTBOUND_IN_KEY+comId,Integer.class); 
 | 
        countNum = Constants.formatIntegerNum(countNum)+1; 
 | 
        //更新缓存 
 | 
        RedisUtil.addObject(redisTemplate,Constants.RedisKeys.COM_OUTBOUND_IN_KEY+comId,countNum); 
 | 
        String nextIndex =Integer.toString( countNum); 
 | 
        return prefix + StringUtils.leftPad(nextIndex,4,"0"); 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    public synchronized String  getNextOutCode(Integer comId ){ 
 | 
        String prefix =  "CK-" + DateUtil.getDate(new Date(),"yyyyMMdd") +"-"; 
 | 
        Integer countNum  = RedisUtil.getObject(redisTemplate,Constants.RedisKeys.COM_OUTBOUND_OUT_KEY+comId,Integer.class); 
 | 
        countNum = Constants.formatIntegerNum(countNum)+1; 
 | 
        //更新缓存 
 | 
        RedisUtil.addObject(redisTemplate,Constants.RedisKeys.COM_OUTBOUND_OUT_KEY+comId,countNum); 
 | 
        String nextIndex =Integer.toString( countNum ); 
 | 
        return prefix + StringUtils.leftPad(nextIndex,4,"0"); 
 | 
    } 
 | 
  
 | 
  
 | 
    /** 
 | 
     * 出入库单详情与出入库业务处理 
 | 
     * @param id 
 | 
     * @param wOutboundType 操作类别 0 出库 1 入库 
 | 
     * @param optType 1: 添加 2 移除 
 | 
     * @param jsonBean 操作条码信息 
 | 
     * @return 
 | 
     */ 
 | 
    @Override 
 | 
    @Transactional 
 | 
    public WOutboundRedisBean wOutBoundForInOut(Integer id,Integer wOutboundType,Integer optType,String jsonBean){ 
 | 
        WOutboundRedisBean wOutboundRedisBean = new WOutboundRedisBean(); 
 | 
        if(!(wOutboundType==Constants.ONE||wOutboundType==Constants.ZERO)){ 
 | 
            throw new BusinessException(ResponseStatus.ERR_STATUS.getCode(), "操作单据类型错误"); 
 | 
        } 
 | 
        WOutbound wOutbound = wOutboundExtMapper.wOutboundById(id); 
 | 
        if(Objects.isNull(wOutbound)||wOutbound.getType()!=wOutboundType){ 
 | 
            throw new BusinessException(ResponseStatus.ERR_STATUS.getCode(), "未查询到对应类型单据"); 
 | 
        } 
 | 
        if(wOutbound.getStatus()!=Constants.ZERO){ 
 | 
            throw new BusinessException(ResponseStatus.ERR_STATUS.getCode(), "单据状态错误"); 
 | 
        } 
 | 
        List<WOutboundDetail> wOutboundDetailList = wOutboundDetailExtMapper.wOutboundDetailListById(id,Constants.ZERO); 
 | 
        if(wOutbound.getType()==Constants.ZERO){ 
 | 
            for (WOutboundDetail wOutboundDetail:wOutboundDetailList) { 
 | 
                QueryWStockDto queryWStockDto = new QueryWStockDto(); 
 | 
                queryWStockDto.setRootDepartId(wOutboundDetail.getRootDepartId()); 
 | 
                queryWStockDto.setMaterialId(wOutboundDetail.getMaterialId()); 
 | 
                queryWStockDto.setWarehouseId(wOutboundDetail.getWarehouseId()); 
 | 
                queryWStockDto.setLocationId(wOutboundDetail.getLocationId()); 
 | 
                queryWStockDto.setUnitId(wOutboundDetail.getUnitId()); 
 | 
                queryWStockDto.setBatch(wOutboundDetail.getBatch()); 
 | 
                queryWStockDto.setQualityType(wOutboundDetail.getQualityType()); 
 | 
                queryWStockDto.setProcedureId(wOutboundDetail.getProcedureId()); 
 | 
                wOutboundDetail.setWStockExtListVOList(wStockExtMapper.stockListByDto(queryWStockDto)); 
 | 
            } 
 | 
            wOutbound.setWOutboundDetailsOut(wOutboundDetailExtMapper.wOutboundDetailListById(id,Constants.ONE)); 
 | 
        } 
 | 
  
 | 
        List<WOutboundRedisCodeBean> wOutboundRedisCodeBeanList = new ArrayList<>(); 
 | 
        String jsonArray = RedisUtil.getObject(redisTemplate,Constants.RedisKeys.COM_WOUTBOUND_KEY+wOutbound.getId(),String.class); 
 | 
        List<WOutboundRedisCodeBean> redisWOutboundRedisCodeBeanList = JSON.parseArray(jsonArray,WOutboundRedisCodeBean.class); 
 | 
        if(!Objects.isNull(redisWOutboundRedisCodeBeanList)&&redisWOutboundRedisCodeBeanList.size()>Constants.ZERO){ 
 | 
            //TODO 特殊处理 批次为null redis 转义后 变为“” 
 | 
            for (WOutboundRedisCodeBean wOutboundRedisCodeBean:redisWOutboundRedisCodeBeanList) { 
 | 
                if(StringUtils.isEmpty(wOutboundRedisCodeBean.getBatch())){ 
 | 
                    wOutboundRedisCodeBean.setBatch(null); 
 | 
                } 
 | 
                if(Objects.isNull(wOutboundRedisCodeBean.getProcedureId())||wOutboundRedisCodeBean.getProcedureId()==Constants.ZERO){ 
 | 
                    wOutboundRedisCodeBean.setProcedureId(null); 
 | 
                } 
 | 
            } 
 | 
            wOutboundRedisCodeBeanList.addAll(redisWOutboundRedisCodeBeanList); 
 | 
        } 
 | 
        if(!Objects.isNull(optType)){ 
 | 
            WOutboundRedisCodeBean codeBean =  JSON.parseObject(jsonBean,WOutboundRedisCodeBean.class); 
 | 
            if(StringUtils.isEmpty(codeBean.getBatch())){ 
 | 
                codeBean.setBatch(null); 
 | 
            } 
 | 
            if(Objects.isNull(codeBean.getProcedureId())){ 
 | 
                codeBean.setProcedureId(null); 
 | 
            } 
 | 
            if(wOutboundType == Constants.ZERO && optType==Constants.ONE){ 
 | 
                if(workorderRecordExtMapper.checkIsWork(codeBean.getAppliancesId().toString()).size()>Constants.ZERO){ 
 | 
                    throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "当前篮筐处于投料中"); 
 | 
                }; 
 | 
            } 
 | 
            //2022-9-14 13:41:33 处理 添加验证篮筐属性与仓库属性 
 | 
            Warehouse warehouse = warehouseMapper.selectById(wOutbound.getWarehouseId()); 
 | 
            //获取仓库属性 判断扫描篮筐数据属性 
 | 
            SystemDictData systemDictData = systemDictDataMapper.selectById(warehouse.getSystemDicDataId()); 
 | 
            if(Objects.isNull(systemDictData)){ 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到仓库类型数据"); 
 | 
            } 
 | 
            // 0合格 1不良 2报废 ; 
 | 
            Integer wareHouseQualityType = 3 ; 
 | 
            if(systemDictData.getLabel().equals(Constants.APPLIANCES_TYPE_LABLE.qualified)){ 
 | 
                wareHouseQualityType = 0 ; 
 | 
            }else if(systemDictData.getLabel().equals(Constants.APPLIANCES_TYPE_LABLE.rejects)){ 
 | 
                wareHouseQualityType = 1 ; 
 | 
            }else if(systemDictData.getLabel().equals(Constants.APPLIANCES_TYPE_LABLE.scrap)){ 
 | 
                wareHouseQualityType = 2 ; 
 | 
            } 
 | 
            if(wareHouseQualityType != 3){ 
 | 
                if(codeBean.getQualityType()!=wareHouseQualityType){ 
 | 
                    throw new BusinessException(ResponseStatus.ERR_STATUS.getCode(), "篮筐质量属性与仓库属性不一致"); 
 | 
                } 
 | 
            } 
 | 
            //验证当前扫描篮筐与出库单明细是否匹配 
 | 
            if(optType==Constants.ONE){ 
 | 
                this.checkDetail(codeBean); 
 | 
            } 
 | 
            //TODO 更新数据 
 | 
            this.updateRedisCode(wOutboundRedisCodeBeanList,optType,codeBean,wOutboundType); 
 | 
  
 | 
        } 
 | 
        if(!Objects.isNull(wOutboundType)){ 
 | 
            //TODO 整理已扫描物料数据 
 | 
            this.handleWOutboundOutCode(wOutboundRedisBean,wOutboundRedisCodeBeanList,false); 
 | 
        } 
 | 
        wOutboundRedisBean.setWOutbound(wOutbound); 
 | 
        wOutboundRedisBean.setWOutboundDetailsWait(wOutboundDetailList); 
 | 
        wOutboundRedisBean.setWOutboundRedisCodeBeanList(wOutboundRedisCodeBeanList); 
 | 
        wOutboundRedisBean.setWarehouse(warehouseMapper.selectById(wOutbound.getWarehouseId())); 
 | 
        if(!Objects.isNull(optType)){ 
 | 
            RedisUtil.addObject(redisTemplate,Constants.RedisKeys.COM_WOUTBOUND_KEY+wOutbound.getId(), JSONArray.fromObject(wOutboundRedisCodeBeanList).toString()); 
 | 
        } 
 | 
  
 | 
//        Constants.Notices_Type_Transfer notices_type_transfer = Constants.Notices_Type_Transfer.checkEnum(wOutbound.getBillType()); 
 | 
//        noticesExtService.dealNotice(wOutbound.getId(),notices_type_transfer.getNoticeInType(),null); 
 | 
        return wOutboundRedisBean; 
 | 
    } 
 | 
  
 | 
    public void checkDetail(WOutboundRedisCodeBean codeBean){ 
 | 
        WOutboundDetail wOutboundDetail = wOutboundDetailMapper.selectById(codeBean.getWOutboundDetailId()); 
 | 
        if(Objects.isNull(wOutboundDetail)){ 
 | 
            throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到出库明细信息"); 
 | 
        } 
 | 
        if(!Objects.equals(codeBean.getWarehouseId(),wOutboundDetail.getWarehouseId())){ 
 | 
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "仓库信息不匹配"); 
 | 
        } 
 | 
        if(!Objects.isNull(wOutboundDetail.getLocationId())&&!Objects.equals(codeBean.getLocationId(),wOutboundDetail.getLocationId())){ 
 | 
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "仓位信息信息不匹配"); 
 | 
        } 
 | 
        if(!Objects.equals(codeBean.getMaterialId(),wOutboundDetail.getMaterialId())){ 
 | 
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "物料信息信息不匹配"); 
 | 
        } 
 | 
        if(!Objects.isNull(wOutboundDetail.getBatch())&&!Objects.equals(codeBean.getBatch(),wOutboundDetail.getBatch())){ 
 | 
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "物料批次信息不匹配"); 
 | 
        } 
 | 
        if(!Objects.equals(codeBean.getQualityType(),wOutboundDetail.getQualityType())){ 
 | 
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "物料质量属性信息不匹配"); 
 | 
        } 
 | 
        if(!Objects.isNull(wOutboundDetail.getProcedureId())&&!Objects.equals(codeBean.getProcedureId(),wOutboundDetail.getProcedureId())){ 
 | 
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "物料工序信息不匹配"); 
 | 
        } 
 | 
  
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 出入库业务处理提交 
 | 
     * @param id 
 | 
     * @param wOutboundType 操作类别 0 出库 1 入库 
 | 
     * @return 
 | 
     */ 
 | 
    @Override 
 | 
    @Transactional 
 | 
    public void wOutBoundForUpload(Integer id,Integer wOutboundType,LoginUserInfo loginUserInfo){ 
 | 
        WOutboundRedisBean wOutboundRedisBean = new WOutboundRedisBean(); 
 | 
        if(!(wOutboundType==Constants.ONE||wOutboundType==Constants.ZERO)){ 
 | 
            throw new BusinessException(ResponseStatus.ERR_STATUS.getCode(), "操作单据类型错误"); 
 | 
        } 
 | 
        WOutbound wOutbound = wOutboundExtMapper.wOutboundById(id); 
 | 
        if(Objects.isNull(wOutbound)||wOutbound.getType()!=wOutboundType){ 
 | 
            throw new BusinessException(ResponseStatus.ERR_STATUS.getCode(), "未查询到对应类型单据"); 
 | 
        } 
 | 
        if(wOutbound.getStatus()!=Constants.ZERO){ 
 | 
            throw new BusinessException(ResponseStatus.ERR_STATUS.getCode(), "单据状态错误"); 
 | 
        } 
 | 
        Warehouse warehouse = warehouseMapper.selectById(wOutbound.getWarehouseId()); 
 | 
        List<WOutboundDetail> wOutboundDetailList = wOutboundDetailExtMapper.wOutboundDetailListById(id,Constants.ZERO); 
 | 
        if(wOutbound.getType()==Constants.ZERO){ 
 | 
            for (WOutboundDetail wOutboundDetail:wOutboundDetailList) { 
 | 
                QueryWStockDto queryWStockDto = new QueryWStockDto(); 
 | 
                queryWStockDto.setRootDepartId(wOutboundDetail.getRootDepartId()); 
 | 
                queryWStockDto.setMaterialId(wOutboundDetail.getMaterialId()); 
 | 
                queryWStockDto.setWarehouseId(wOutboundDetail.getWarehouseId()); 
 | 
                queryWStockDto.setLocationId(wOutboundDetail.getLocationId()); 
 | 
                queryWStockDto.setUnitId(wOutboundDetail.getUnitId()); 
 | 
                queryWStockDto.setBatch(wOutboundDetail.getBatch()); 
 | 
                queryWStockDto.setQualityType(wOutboundDetail.getQualityType()); 
 | 
                queryWStockDto.setProcedureId(wOutboundDetail.getProcedureId()); 
 | 
                wOutboundDetail.setWStockExtListVOList(wStockExtMapper.stockListByDto(queryWStockDto)); 
 | 
            } 
 | 
            wOutbound.setWOutboundDetailsOut(wOutboundDetailExtMapper.wOutboundDetailListById(id,Constants.ONE)); 
 | 
        } 
 | 
  
 | 
        List<WOutboundRedisCodeBean> wOutboundRedisCodeBeanList = new ArrayList<>(); 
 | 
        String jsonArray = RedisUtil.getObject(redisTemplate,Constants.RedisKeys.COM_WOUTBOUND_KEY+wOutbound.getId(),String.class); 
 | 
        List<WOutboundRedisCodeBean> redisWOutboundRedisCodeBeanList = JSON.parseArray(jsonArray,WOutboundRedisCodeBean.class); 
 | 
  
 | 
        //2022年9月26日11:23:29 加入 验证所有篮筐必须处于未投料状态 所有篮筐必须与出库单据仓库一致 
 | 
        if(wOutboundType==Constants.ZERO){ 
 | 
            List<String> idList = redisWOutboundRedisCodeBeanList.stream().map(x -> x.getAppliancesId().toString()).collect(Collectors.toList()); 
 | 
            String ids = StringUtils.join(idList.toArray(), ","); 
 | 
            List<WorkorderRecordExtListVO>  workorderRecordExtListVOList = workorderRecordExtMapper.checkIsWork(ids); 
 | 
            if(workorderRecordExtListVOList.size()>Constants.ZERO){ 
 | 
                List<String> useIdList = workorderRecordExtListVOList.stream().map(x -> x.getAppliancesId().toString()).collect(Collectors.toList()); 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(),"【" + StringUtils.join(useIdList.toArray(), ",") +  "】篮筐处于投料中"); 
 | 
            } 
 | 
            // 所有篮筐必须与出库单据仓库一致 
 | 
            redisWOutboundRedisCodeBeanList.forEach(i->{ 
 | 
                Appliances appliances = appliancesExtMapper.selectById(i.getAppliancesId()); 
 | 
                if(!Objects.equals(appliances.getWarehouseId(),wOutbound.getWarehouseId())){ 
 | 
                    throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(),"【" + i.getScanCode() +  "】篮筐归属仓库信息错误"); 
 | 
                } 
 | 
            }); 
 | 
        }else{ 
 | 
            //入库的篮筐不能有仓库信息 
 | 
            redisWOutboundRedisCodeBeanList.forEach(i->{ 
 | 
                Appliances appliances = appliancesExtMapper.selectById(i.getAppliancesId()); 
 | 
                if(!Objects.isNull(appliances.getWarehouseId())||!Objects.isNull(appliances.getLocationId())){ 
 | 
                    throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(),"【" + i.getScanCode() +  "】篮筐存在归属仓库信息"); 
 | 
                } 
 | 
            }); 
 | 
        } 
 | 
  
 | 
        //限制入库数据数量 必须等于待入库数量 
 | 
        if(wOutboundType==Constants.ONE){ 
 | 
            List<WOutboundDetail> detailList =  wOutboundDetailMapper.selectList(new QueryWrapper<WOutboundDetail>().eq("OUTBOUND_ID",id)); 
 | 
            for (WOutboundDetail wOutboundDetail:detailList) { 
 | 
                BigDecimal scanNum = BigDecimal.ZERO; 
 | 
                for (WOutboundRedisCodeBean wOutboundRedisCodeBean:redisWOutboundRedisCodeBeanList) { 
 | 
                    if(Objects.equals(wOutboundRedisCodeBean.getWOutboundDetailId(),wOutboundDetail.getId())){ 
 | 
                        scanNum = scanNum.add(wOutboundRedisCodeBean.getNum()); 
 | 
                    } 
 | 
                } 
 | 
                if(wOutboundDetail.getNum().compareTo(scanNum)!=Constants.ZERO){ 
 | 
                    throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "入库数量应与待入库数量相同"); 
 | 
                } 
 | 
            } 
 | 
        } 
 | 
  
 | 
        if(!Objects.isNull(redisWOutboundRedisCodeBeanList)&&redisWOutboundRedisCodeBeanList.size()>Constants.ZERO){ 
 | 
            //TODO 特殊处理 批次为null redis 转义后 变为“” 
 | 
            for (WOutboundRedisCodeBean wOutboundRedisCodeBean:redisWOutboundRedisCodeBeanList) { 
 | 
                if(StringUtils.isEmpty(wOutboundRedisCodeBean.getBatch())){ 
 | 
                    wOutboundRedisCodeBean.setBatch(null); 
 | 
                } 
 | 
                if(Objects.isNull(wOutboundRedisCodeBean.getProcedureId())||wOutboundRedisCodeBean.getProcedureId()==Constants.ZERO){ 
 | 
                    wOutboundRedisCodeBean.setProcedureId(null); 
 | 
                } 
 | 
            } 
 | 
            wOutboundRedisCodeBeanList.addAll(redisWOutboundRedisCodeBeanList); 
 | 
        } 
 | 
        //TODO 整理已扫描物料数据 
 | 
        this.handleWOutboundOutCode(wOutboundRedisBean,wOutboundRedisCodeBeanList,true); 
 | 
        wOutboundRedisBean.setWOutbound(wOutbound); 
 | 
        wOutboundRedisBean.setWOutboundDetailsWait(wOutboundDetailList); 
 | 
        wOutboundRedisBean.setWOutboundRedisCodeBeanList(wOutboundRedisCodeBeanList); 
 | 
        // TODO 更新篮筐库存数据 添加操作记录 
 | 
        this.updateAppliances(wOutboundRedisBean.getWoScanMaterialBeanList(),warehouse,wOutboundType,loginUserInfo,wOutbound.getOrigin()); 
 | 
        // TODO 更新单据数据 
 | 
        wOutbound.setStatus(Constants.ONE); 
 | 
        wOutbound.setDealDate(new Date()); 
 | 
        wOutboundMapper.updateById(wOutbound); 
 | 
        RedisUtil.deleteObject(redisTemplate,wOutbound.getId().toString()); 
 | 
        Constants.Notices_Type_Transfer notices_type_transfer = Constants.Notices_Type_Transfer.checkEnum(wOutbound.getBillType()); 
 | 
        noticesExtService.dealNotice(wOutbound.getId(),wOutboundType==Constants.ZERO?notices_type_transfer.getNoticeOutType():notices_type_transfer.getNoticeInType(),null); 
 | 
        //记录操作记录 
 | 
        WHistory wHistory = wOutbound.toWHistory(loginUserInfo.getId()); 
 | 
        wHistory.setTitle("出入库单完成"); 
 | 
        wHistory.setInfo("出入库单完成"); 
 | 
        wHistoryMapper.insert(wHistory); 
 | 
  
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 更新篮筐库存数据 添加操作记录 
 | 
     * @param woScanMaterialBeanList 
 | 
     * @param wOutboundType 
 | 
     * @param loginUserInfo 
 | 
     */ 
 | 
    @Transactional 
 | 
    public void updateAppliances(List<WoScanMaterialBean>  woScanMaterialBeanList,Warehouse warehouse,Integer wOutboundType,LoginUserInfo loginUserInfo,Integer orgin){ 
 | 
        if(Objects.isNull(woScanMaterialBeanList)||woScanMaterialBeanList.size()==Constants.ZERO){ 
 | 
            throw new BusinessException(ResponseStatus.ERR_STATUS.getCode(), "无扫描数据,提交失败"); 
 | 
        } 
 | 
        for (WoScanMaterialBean woScanMaterialBean:woScanMaterialBeanList) { 
 | 
            List<WOutboundRedisCodeBean> wOutboundRedisCodeBeanList = woScanMaterialBean.getWOutboundRedisCodeBeanList(); 
 | 
            if(wOutboundRedisCodeBeanList.size()>Constants.ZERO){ 
 | 
                WOutboundDetail wOutboundDetail = wOutboundDetailMapper.selectById(woScanMaterialBean.getWOutboundDetailId()); 
 | 
                for (WOutboundRedisCodeBean wOutboundRedisCodeBean:wOutboundRedisCodeBeanList) { 
 | 
                    Appliances appliances = appliancesMapper.selectById(wOutboundRedisCodeBean.getAppliancesId()); 
 | 
                    appliances.setCurObjId(wOutboundDetail.getOutboundId()); 
 | 
                    appliances.setCurObjType(Constants.ZERO); 
 | 
                    Integer outLocationId = Constants.ZERO ; 
 | 
                    if(wOutboundType==Constants.ZERO){ 
 | 
                        if(!Objects.isNull(appliances)){ 
 | 
                            if(warehouse.getUseLocation()==Constants.ONE) { 
 | 
                                outLocationId = appliances.getLocationId(); 
 | 
                            } 
 | 
                            appliances.setWarehouseId(null); 
 | 
                            appliances.setLocationId(null); 
 | 
                        } 
 | 
                    }else if(wOutboundType==Constants.ONE){ 
 | 
                        appliances.setWarehouseId(wOutboundDetail.getWarehouseId()); 
 | 
                        if(warehouse.getUseLocation()==Constants.ONE){ 
 | 
                            appliances.setLocationId(woScanMaterialBean.getLocationId()); 
 | 
                        } 
 | 
                    } 
 | 
                    WOutboundRecord wOutboundRecord = wOutboundDetail.toRecord(appliances,loginUserInfo); 
 | 
                    if(warehouse.getUseLocation()==Constants.ONE){ 
 | 
                        //根据出入库类别 记录record表货位数据  入库由扫描货位来 出库由原工装器具数据来 
 | 
                        if(wOutboundType==Constants.ZERO){ 
 | 
                            wOutboundRecord.setLocationId(outLocationId); 
 | 
                        }else{ 
 | 
                            wOutboundRecord.setLocationId(appliances.getLocationId()); 
 | 
                        } 
 | 
  
 | 
                    } 
 | 
                    wOutboundRecordMapper.insert(wOutboundRecord); 
 | 
                    //手工创建出库单 要更新掉工装器具内所有数据 2022年10月27日11:04:22 
 | 
                    if(wOutboundType==Constants.ZERO&&!Objects.isNull(orgin)&&Constants.ZERO == orgin){ 
 | 
                        appliances.setSerialNum(null); 
 | 
                        appliances.setStatus(Constants.ONE); 
 | 
                        appliances.setWorkorderId(null); 
 | 
                        appliances.setMaterialId(null); 
 | 
                        appliances.setNum(null); 
 | 
                        appliances.setPositionType(null); 
 | 
                        appliances.setProcedureId(null); 
 | 
                        appliances.setNextProcedureId(null); 
 | 
                        appliances.setCurObjId(null); 
 | 
                        appliances.setCurObjType(null); 
 | 
                        appliances.setBatch(null); 
 | 
                        appliances.setQualityType(null); 
 | 
                        appliances.setBackorderId(null); 
 | 
                        appliances.setSaleorderId(null); 
 | 
                        appliances.setBackProcedureId(null); 
 | 
                        appliances.setRelobjType(null); 
 | 
                    } 
 | 
                    if(!Objects.isNull(orgin)&&Constants.ZERO == orgin){ 
 | 
                        appliancesExtMapper.editById(appliances); 
 | 
                    }else{ 
 | 
                        appliancesMapper.updateById(appliances); 
 | 
                    } 
 | 
                } 
 | 
                wOutboundDetail.setDoneNum(woScanMaterialBean.getScanNum()); 
 | 
                wOutboundDetail.setStatus(Constants.ONE); 
 | 
                wOutboundDetail.setDoneDate(new Date()); 
 | 
                wOutboundDetailMapper.updateById(wOutboundDetail); 
 | 
                //记录库存变动记录 
 | 
                wStockRecordExtService.saveRecordNoLocationId(wOutboundType,wOutboundDetail.getId(),loginUserInfo,woScanMaterialBean.getLocationId()); 
 | 
                this.updateStock(woScanMaterialBean,wOutboundDetail,warehouse,wOutboundType,loginUserInfo); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
  
 | 
    /** 
 | 
     * 更新库存信息 
 | 
     * @param woScanMaterialBean 
 | 
     * @param wOutboundDetail 
 | 
     * @param loginUserInfo 
 | 
     */ 
 | 
    @Transactional 
 | 
    public void updateStock(WoScanMaterialBean woScanMaterialBean,WOutboundDetail wOutboundDetail,Warehouse warehouse,Integer wOutboundType,LoginUserInfo loginUserInfo){ 
 | 
        //TODO 查询库存数据 
 | 
        QueryWrapper wrapper = new QueryWrapper<WStock>(); 
 | 
        wrapper.eq("ROOT_DEPART_ID", wOutboundDetail.getRootDepartId()); 
 | 
        wrapper.eq("MATERIAL_ID", woScanMaterialBean.getMaterialId()); 
 | 
        wrapper.eq("WAREHOUSE_ID", wOutboundDetail.getWarehouseId()); 
 | 
        wrapper.eq("QUALITY_TYPE", wOutboundDetail.getQualityType()); 
 | 
        if(StringUtils.isNotBlank(wOutboundDetail.getBatch())){ 
 | 
            wrapper.eq("BATCH" , wOutboundDetail.getBatch()); 
 | 
        }else{ 
 | 
            wrapper.apply("BATCH is null "); 
 | 
        } 
 | 
        if(Objects.isNull(wOutboundDetail.getProcedureId())){ 
 | 
            wrapper.apply(" PROCEDURE_ID is null  "); 
 | 
        }else{ 
 | 
            wrapper.eq("PROCEDURE_ID" , wOutboundDetail.getProcedureId()); 
 | 
        } 
 | 
        wrapper.eq(!Objects.isNull(wOutboundDetail.getLocationId())&&warehouse.getUseLocation()==Constants.ONE,"LOCATION_ID", wOutboundDetail.getLocationId()); 
 | 
        wrapper.eq("DELETED",0); 
 | 
        List<WStock> wStockList = wStockMapper.selectList(wrapper); 
 | 
        if(wOutboundType==Constants.ZERO){ 
 | 
            if(Objects.isNull(wStockList)||wStockList.size()==Constants.ZERO){ 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "库存信息异常:【"+warehouse.getId()+"】 - 【"+wOutboundDetail.getLocationId()+"】 - 【"+wOutboundDetail.getMaterialId()+"】- 【"+wOutboundDetail.getBatch()+"】"); 
 | 
            } 
 | 
            WStock wStock = wStockList.get(0); 
 | 
            if (wStock.getNum().compareTo(woScanMaterialBean.getScanNum()) < Constants.ZERO) { 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "当前货位库存数量不足;剩余数量【" + wStock.getNum() + "】;出库数量【" + woScanMaterialBean.getScanNum() + "】"); 
 | 
            } 
 | 
            wStock.setNum(wStock.getNum().subtract(woScanMaterialBean.getScanNum())); 
 | 
            wStockMapper.updateById(wStock); 
 | 
        }else{ 
 | 
            if(Objects.isNull(wStockList)||wStockList.size()==Constants.ZERO){ 
 | 
                WStock newWStock = new WStock(); 
 | 
                newWStock.setCreateTime(new Date()); 
 | 
                newWStock.setCreateUser(loginUserInfo.getId()); 
 | 
                newWStock.setRootDepartId(wOutboundDetail.getRootDepartId()); 
 | 
                newWStock.setWarehouseId(wOutboundDetail.getWarehouseId()); 
 | 
                //此仓库 开启仓位 
 | 
                if(warehouse.getUseLocation()==Constants.ONE){ 
 | 
                    newWStock.setLocationId(woScanMaterialBean.getLocationId()); 
 | 
                } 
 | 
                newWStock.setMaterialId(wOutboundDetail.getMaterialId()); 
 | 
                newWStock.setBatch(wOutboundDetail.getBatch()); 
 | 
                newWStock.setUnitId(wOutboundDetail.getUnitId()); 
 | 
                newWStock.setNum(woScanMaterialBean.getScanNum()); 
 | 
                newWStock.setQualityType(wOutboundDetail.getQualityType()); 
 | 
                newWStock.setProcedureId(wOutboundDetail.getProcedureId()); 
 | 
                wStockMapper.insert(newWStock); 
 | 
            }else{ 
 | 
                WStock wStock = wStockList.get(0); 
 | 
                wStock.setNum(wStock.getNum().add(woScanMaterialBean.getScanNum())); 
 | 
                wStockMapper.updateById(wStock); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
  
 | 
  
 | 
    public void handleWOutboundOutCode(WOutboundRedisBean wOutboundRedisBean,List<WOutboundRedisCodeBean> wOutboundRedisCodeBeanList,boolean isError){ 
 | 
        List<WoScanMaterialBean>  woScanMaterialBeanList = new ArrayList<>(); 
 | 
        if(!Objects.isNull(wOutboundRedisCodeBeanList)&&wOutboundRedisCodeBeanList.size()>Constants.ZERO){ 
 | 
            //获取仓库属性 判断扫描篮筐数据属性 
 | 
            for (WOutboundRedisCodeBean wOutboundRedisCodeBean:wOutboundRedisCodeBeanList) { 
 | 
                //遍历已扫工装数据 
 | 
                if(woScanMaterialBeanList.size()==Constants.ZERO || !isRepeatMaterialData(woScanMaterialBeanList,wOutboundRedisCodeBean)){ 
 | 
                    woScanMaterialBeanList.add(wOutboundRedisCodeBean.toWoScanMaterialBean()); 
 | 
                } 
 | 
            } 
 | 
            //TODO 已扫描物料数据 绑定已扫描条码 更新已扫描数量 
 | 
            for (WoScanMaterialBean woScanMaterialBean:woScanMaterialBeanList) { 
 | 
                BigDecimal scanNum = BigDecimal.ZERO; 
 | 
  
 | 
                List<WOutboundRedisCodeBean> wOutboundRedisCodeBeans = new ArrayList<>(); 
 | 
                for (WOutboundRedisCodeBean wOutboundRedisCodeBean:wOutboundRedisCodeBeanList) { 
 | 
                    if(StringUtils.equals(woScanMaterialBean.getWOutboundDetailId().toString(),wOutboundRedisCodeBean.getWOutboundDetailId().toString()) 
 | 
                            &&StringUtils.equals(woScanMaterialBean.getMaterialId().toString(),wOutboundRedisCodeBean.getMaterialId().toString()) 
 | 
//                            &&StringUtils.equals(woScanMaterialBean.getLocationId().toString(),wOutboundRedisCodeBean.getLocationId().toString()) 
 | 
                            &&woScanMaterialBean.getQualityType().intValue() == wOutboundRedisCodeBean.getQualityType().intValue() 
 | 
                    ){ 
 | 
                        if(!Objects.equals(woScanMaterialBean.getLocationId(),wOutboundRedisCodeBean.getLocationId())){ 
 | 
                            continue; 
 | 
                        } 
 | 
                        //TODO 判断工序是否都不为空 
 | 
                        if(!Objects.isNull(woScanMaterialBean.getProcedureId())&&!Objects.isNull(wOutboundRedisCodeBean.getProcedureId())){ 
 | 
                            if(!woScanMaterialBean.getProcedureId().equals(wOutboundRedisCodeBean.getProcedureId())){ 
 | 
                                continue; 
 | 
                            } 
 | 
                        }else if(Objects.isNull(woScanMaterialBean.getProcedureId())&&!Objects.isNull(wOutboundRedisCodeBean.getProcedureId())){ 
 | 
                            continue; 
 | 
                        }else if(!Objects.isNull(woScanMaterialBean.getProcedureId())&&Objects.isNull(wOutboundRedisCodeBean.getProcedureId())){ 
 | 
                            continue; 
 | 
                        } 
 | 
                        //TODO 若批次为 null /“” 则不验证批次,否则验证 
 | 
                        if(StringUtils.isNotEmpty(woScanMaterialBean.getBatch())&&StringUtils.equals(woScanMaterialBean.getBatch(),wOutboundRedisCodeBean.getBatch())){ 
 | 
                            wOutboundRedisCodeBeans.add(wOutboundRedisCodeBean); 
 | 
                            scanNum = scanNum.add(wOutboundRedisCodeBean.getNum()); 
 | 
                        }else if(StringUtils.isEmpty(woScanMaterialBean.getBatch())){ 
 | 
                            wOutboundRedisCodeBeans.add(wOutboundRedisCodeBean); 
 | 
                            scanNum = scanNum.add(wOutboundRedisCodeBean.getNum()); 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
                if(isError){ 
 | 
                    WOutboundDetail wOutboundDetail = wOutboundDetailMapper.selectById(woScanMaterialBean.getWOutboundDetailId()); 
 | 
  
 | 
                    if( scanNum.compareTo(wOutboundDetail.getNum())>0){ 
 | 
                        throw new BusinessException(ResponseStatus.EXCEED_PLAN_NUM.getCode(), "超出计划数量,扫描失败"); 
 | 
                    } 
 | 
  
 | 
                } 
 | 
                woScanMaterialBean.setWOutboundRedisCodeBeanList(wOutboundRedisCodeBeans); 
 | 
                woScanMaterialBean.setScanNum(scanNum); 
 | 
            } 
 | 
            wOutboundRedisBean.setWoScanMaterialBeanList(woScanMaterialBeanList); 
 | 
         } 
 | 
    } 
 | 
  
 | 
    private boolean isRepeatMaterialData(List<WoScanMaterialBean> woScanMaterialBeanList, WOutboundRedisCodeBean wOutboundRedisCodeBean) { 
 | 
        //TODO 物料/批次/货位是否相同 相同则跳过,否则加入数据 
 | 
        for (WoScanMaterialBean woScanMaterialBean:woScanMaterialBeanList) { 
 | 
            if(StringUtils.equals(woScanMaterialBean.getWOutboundDetailId().toString(),wOutboundRedisCodeBean.getWOutboundDetailId().toString()) 
 | 
                    &&StringUtils.equals(woScanMaterialBean.getMaterialId().toString(),wOutboundRedisCodeBean.getMaterialId().toString()) 
 | 
                    &&StringUtils.equals(woScanMaterialBean.getLocationId().toString(),wOutboundRedisCodeBean.getLocationId().toString()) 
 | 
                    &&Constants.equalsInteger(woScanMaterialBean.getQualityType(),wOutboundRedisCodeBean.getQualityType()) 
 | 
            ) { 
 | 
                // 物料/批次/货位相同 
 | 
                //TODO 判断工序是否都不为空 
 | 
                if(!Objects.isNull(woScanMaterialBean.getProcedureId())&&!Objects.isNull(wOutboundRedisCodeBean.getProcedureId()) && !Constants.equalsInteger(woScanMaterialBean.getProcedureId(),(wOutboundRedisCodeBean.getProcedureId()))){ 
 | 
                        return false; 
 | 
                }else if(Objects.isNull(woScanMaterialBean.getProcedureId())&&!Objects.isNull(wOutboundRedisCodeBean.getProcedureId())){ 
 | 
                    return false; 
 | 
                }else if(!Objects.isNull(woScanMaterialBean.getProcedureId())&&Objects.isNull(wOutboundRedisCodeBean.getProcedureId())){ 
 | 
                    return false; 
 | 
                } 
 | 
                //TODO 若批次为 null /“” 则不验证批次,否则验证 
 | 
                if(StringUtils.isNotEmpty(woScanMaterialBean.getBatch())&&!StringUtils.equals(woScanMaterialBean.getBatch(),wOutboundRedisCodeBean.getBatch())){ 
 | 
                    return false; 
 | 
                }else if(StringUtils.isNotEmpty(woScanMaterialBean.getBatch()) && StringUtils.isEmpty(wOutboundRedisCodeBean.getBatch())){ 
 | 
                    return false; 
 | 
                }else if(StringUtils.isEmpty(woScanMaterialBean.getBatch()) && StringUtils.isNotEmpty(wOutboundRedisCodeBean.getBatch())){ 
 | 
                    return false; 
 | 
                } 
 | 
                return true; 
 | 
            } 
 | 
  
 | 
        } 
 | 
         return false; 
 | 
    } 
 | 
  
 | 
  
 | 
    /** 
 | 
     * 更新条码列表 
 | 
     * @param wOutboundRedisCodeBeanList 所有条码列表 
 | 
     * @param optType 1:添加;2:删除 
 | 
     * @param codeBean 工装器具 
 | 
     */ 
 | 
    @Transactional 
 | 
    public void updateRedisCode(List<WOutboundRedisCodeBean> wOutboundRedisCodeBeanList,Integer optType,WOutboundRedisCodeBean codeBean,Integer wOutboundType){ 
 | 
        if(Objects.isNull(optType)|| (optType!=Constants.ONE&&optType!=Constants.TWO)){ 
 | 
            throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "更新操作类别异常"); 
 | 
        }if(optType==Constants.ONE){ 
 | 
            // 校验 工装器具数据是否已扫描 
 | 
            for (WOutboundRedisCodeBean wOutboundRedisCodeBean:wOutboundRedisCodeBeanList) { 
 | 
                if(StringUtils.equals(wOutboundRedisCodeBean.getAppliancesId().toString(),codeBean.getAppliancesId().toString())){ 
 | 
                    throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "工装器具数据已扫描,无法重复扫描"); 
 | 
                } 
 | 
                //判断条码是是否在当前单据中 
 | 
                WOutboundDetail wOutboundDetail = wOutboundDetailMapper.selectById(codeBean.getWOutboundDetailId()); 
 | 
                if(StringUtils.equals(wOutboundDetail.getMaterialId().toString(),codeBean.getMaterialId().toString()) 
 | 
                        &&StringUtils.equals(wOutboundDetail.getWarehouseId().toString(),codeBean.getWarehouseId().toString())){ 
 | 
  
 | 
                    if(!Objects.isNull(wOutboundDetail.getProcedureId())&&!Objects.isNull( codeBean.getProcedureId())){ 
 | 
                        if(!wOutboundDetail.getProcedureId().equals(codeBean.getProcedureId())){ 
 | 
                            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "添加条码数据工序数据不匹配"); 
 | 
                        } 
 | 
                    }else if(Objects.isNull(wOutboundDetail.getProcedureId())&&!Objects.isNull( codeBean.getProcedureId())){ 
 | 
                        throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "添加条码数据工序数据不匹配"); 
 | 
                    }else if(!Objects.isNull(wOutboundDetail.getProcedureId())&&Objects.isNull( codeBean.getProcedureId())){ 
 | 
                        throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "添加条码数据工序数据不匹配"); 
 | 
                    } 
 | 
                    if(StringUtils.isNotBlank(wOutboundDetail.getBatch())){ 
 | 
                        if(!wOutboundDetail.getBatch().equals(codeBean.getBatch())){ 
 | 
                            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "添加条码数据批次不匹配"); 
 | 
                        } 
 | 
                    } 
 | 
                    if(StringUtils.isNotBlank(wOutboundDetail.getBatch())){ 
 | 
                        if(!wOutboundDetail.getBatch().equals(codeBean.getBatch())){ 
 | 
                            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "添加条码数据批次不匹配"); 
 | 
                        } 
 | 
                    } 
 | 
                    if(!Objects.isNull(wOutboundDetail.getLocationId())){ 
 | 
                        if(!Objects.equals(wOutboundDetail.getLocationId(),codeBean.getLocationId())){ 
 | 
                            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "添加条码数据货位不匹配"); 
 | 
                        } 
 | 
                    } 
 | 
                }else{ 
 | 
                    throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "添加条码数据不匹配"); 
 | 
                } 
 | 
            } 
 | 
            wOutboundRedisCodeBeanList.add(codeBean); 
 | 
        }else if(optType==Constants.TWO){ 
 | 
            //TODO 是否在当前单据数据内 
 | 
            Boolean isHave = true; 
 | 
            for (WOutboundRedisCodeBean wOutboundRedisCodeBean:wOutboundRedisCodeBeanList) { 
 | 
                if (StringUtils.equals(wOutboundRedisCodeBean.getAppliancesId().toString(), codeBean.getAppliancesId().toString())) { 
 | 
                    wOutboundRedisCodeBeanList.remove(wOutboundRedisCodeBean); 
 | 
                    isHave = false; 
 | 
                    break; 
 | 
                } 
 | 
            } 
 | 
            if(isHave){ 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "扫描条码未存在当前单据内"); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    @Override 
 | 
    @Transactional(rollbackFor = Exception.class) 
 | 
    public void wOutBoundForStockUp(WOutboundInHeadBean wOutboundInHeadBean,LoginUserInfo loginUserInfo){ 
 | 
        if(!(wOutboundInHeadBean.getType()==25||wOutboundInHeadBean.getType()==26||wOutboundInHeadBean.getType()==27||wOutboundInHeadBean.getType()==28)){ 
 | 
            throw new BusinessException(ResponseStatus.ERR_STATUS.getCode(), "单据类别错误"); 
 | 
        } 
 | 
        Warehouse warehouse = warehouseMapper.selectById(wOutboundInHeadBean.getWarehouseId()); 
 | 
        if(Objects.isNull(warehouse)){ 
 | 
            throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到仓库数据"); 
 | 
        } 
 | 
        WOutbound wOutbound = new WOutbound(); 
 | 
        wOutbound.setPlanDate(new Date()); 
 | 
        wOutbound.setType(Constants.ONE); 
 | 
        wOutbound.setBillType(wOutboundInHeadBean.getType()); 
 | 
        wOutbound.setWarehouseId(wOutboundInHeadBean.getWarehouseId()); 
 | 
        wOutbound.setCreateTime(new Date()); 
 | 
        wOutbound.setCreateUser(loginUserInfo.getId()); 
 | 
        wOutbound.setOrigin(Constants.ZERO); 
 | 
        wOutbound.setValidDate(wOutboundInHeadBean.getValidDate()); 
 | 
        wOutbound.setStatus(Constants.ONE); 
 | 
        wOutbound.setCode(getNextInCode(loginUserInfo.getCompany().getId()));// 单据编码 
 | 
        wOutbound.setRootDepartId(loginUserInfo.getRootDepartment().getId()); 
 | 
        wOutbound.setDepartId(loginUserInfo.getCurComDepartment().getId()); 
 | 
        wOutbound.setUserId(loginUserInfo.getId()); 
 | 
        wOutbound.setAbstracts(wOutboundInHeadBean.getAbstracts()); 
 | 
        wOutboundMapper.insert(wOutbound); 
 | 
        List<WOutboundInBodyBean> wOutboundInBodyBeanList = wOutboundInHeadBean.getWOutboundInBodyBeanList(); 
 | 
        if(Objects.isNull(wOutboundInBodyBeanList)){ 
 | 
            throw new BusinessException(ResponseStatus.ITEM_ERR_STATUS.getCode(), "无行项目数据"); 
 | 
        } 
 | 
        //获取仓库属性 判断扫描篮筐数据属性 
 | 
        SystemDictData systemDictData = systemDictDataMapper.selectById(warehouse.getSystemDicDataId()); 
 | 
        if(Objects.isNull(systemDictData)){ 
 | 
            throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到仓库类型数据"); 
 | 
        } 
 | 
        // 0合格 1不良 2报废 ; 
 | 
        Integer wareHouseQualityType = 3 ; 
 | 
        if(systemDictData.getLabel().equals(Constants.APPLIANCES_TYPE_LABLE.qualified)){ 
 | 
            wareHouseQualityType = 0 ; 
 | 
        }else if(systemDictData.getLabel().equals(Constants.APPLIANCES_TYPE_LABLE.rejects)){ 
 | 
            wareHouseQualityType = 1 ; 
 | 
        }else if(systemDictData.getLabel().equals(Constants.APPLIANCES_TYPE_LABLE.scrap)){ 
 | 
            wareHouseQualityType = 2 ; 
 | 
        } 
 | 
        //记录操作记录 
 | 
        WHistory wHistory = wOutbound.toWHistory(loginUserInfo.getId()); 
 | 
         if(wOutboundInHeadBean.getType()==25||wOutboundInHeadBean.getType()==26||wOutboundInHeadBean.getType()==27|wOutboundInHeadBean.getType()==28){ 
 | 
            this.purchaseIn(wOutboundInHeadBean,warehouse,wOutbound,loginUserInfo,wareHouseQualityType); 
 | 
        } 
 | 
//         else if(wOutboundInHeadBean.getType()==28){ 
 | 
//            this.adjustmentIn(wOutboundInHeadBean,warehouse,wOutbound,loginUserInfo,wareHouseQualityType); 
 | 
//        } 
 | 
        wHistory.setTitle( "完成出入库业务"); 
 | 
        wHistory.setInfo("完成出入库业务"); 
 | 
        wHistoryMapper.insert(wHistory); 
 | 
    } 
 | 
  
 | 
    public String sub(WOutboundInBodyBean i){ 
 | 
        StringBuffer sub = new StringBuffer(); 
 | 
        sub.append(i.getMaterialId() 
 | 
                +i.getUnitId() 
 | 
                +i.getQualityType() 
 | 
                ); 
 | 
        if(!Objects.isNull(i.getLocationId())){ 
 | 
            sub.append(i.getLocationId()); 
 | 
        } 
 | 
        if(!Objects.isNull(i.getBatch())){ 
 | 
            sub.append(i.getBatch()); 
 | 
        } 
 | 
        if(!Objects.isNull(i.getProcedureId())){ 
 | 
            sub.append(i.getProcedureId()); 
 | 
        } 
 | 
        return  sub.toString(); 
 | 
    } 
 | 
  
 | 
    @Transactional 
 | 
    public void purchaseIn(WOutboundInHeadBean wOutboundInHeadBean,Warehouse warehouse,WOutbound wOutbound,LoginUserInfo loginUserInfo,Integer wareHouseQualityType){ 
 | 
        List<WOutboundInBodyBean> wOutboundInBodyBeanList =  wOutboundInHeadBean.getWOutboundInBodyBeanList(); 
 | 
        //整理数据过滤 相同属性数据合并后 进行数据写入 
 | 
        Map<String, List<WOutboundInBodyBean>> wOutboundInBodyBeanMap = wOutboundInBodyBeanList.stream() 
 | 
                    .collect(Collectors.groupingBy(i -> this.sub(i))); 
 | 
        Iterator<String> iter = wOutboundInBodyBeanMap.keySet().iterator(); 
 | 
        while(iter.hasNext()) { 
 | 
            String key = iter.next(); 
 | 
            //获取当前行处理数据 
 | 
            List<WOutboundInBodyBean> wOutboundInBodyBeans = wOutboundInBodyBeanMap.get(key); 
 | 
            WOutboundInBodyBean wOutboundInBodyBean = wOutboundInBodyBeans.get(Constants.ZERO); 
 | 
            //累计入库数量 
 | 
            wOutboundInBodyBean.setNum(wOutboundInBodyBeans.stream().map(s -> s.getNum()).reduce(BigDecimal.ZERO, BigDecimal::add)); 
 | 
            if(wOutboundInBodyBean.getNum().compareTo(BigDecimal.ZERO)<=Constants.ZERO){ 
 | 
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "数量异常,请检查数量!"); 
 | 
            } 
 | 
            WOutboundDetail wOutboundDetail = new WOutboundDetail(); 
 | 
            //查询物料数据 
 | 
            MaterialDistribute materialDistribute = materialDistributeMapper.selectById(wOutboundInBodyBean.getMaterialId()); 
 | 
            if(Objects.isNull(materialDistribute)){ 
 | 
                throw new BusinessException(ResponseStatus.DEFECT_PARAMETER.getCode(), "未查询到物料数据:"+wOutboundInBodyBean.getMaterialId()); 
 | 
            } 
 | 
            if(wareHouseQualityType != 3){ 
 | 
                if(wOutboundInBodyBean.getQualityType()!=wareHouseQualityType){ 
 | 
                    throw new BusinessException(ResponseStatus.ERR_STATUS.getCode(), "仓库质量属性与入库数据质量属性不一致"); 
 | 
                } 
 | 
            } 
 | 
            wOutboundDetail.setNum(wOutboundInBodyBean.getNum()); 
 | 
            wOutboundDetail.setMaterialId(materialDistribute.getId()); 
 | 
            wOutboundDetail.setUnitId(wOutboundInBodyBean.getUnitId()); 
 | 
            if(StringUtils.isNotBlank(wOutboundInBodyBean.getBatch())){ 
 | 
                wOutboundDetail.setBatch(wOutboundInBodyBean.getBatch()); 
 | 
            } 
 | 
            wOutboundDetail.setOutboundId(wOutbound.getId()); 
 | 
            wOutboundDetail.setCreateTime(new Date()); 
 | 
            wOutboundDetail.setCreateUser(loginUserInfo.getId()); 
 | 
            wOutboundDetail.setRootDepartId(loginUserInfo.getRootDepartment().getId()); 
 | 
            wOutboundDetail.setWarehouseId(wOutbound.getWarehouseId()); 
 | 
            wOutboundDetail.setQualityType(wOutboundInBodyBean.getQualityType()); 
 | 
            wOutboundDetail.setDoneNum(wOutboundInBodyBean.getNum()); 
 | 
            wOutboundDetail.setDoneDate(new Date()); 
 | 
            wOutboundDetail.setStatus(Constants.ONE); 
 | 
            //此仓库 开启仓位 
 | 
            if(warehouse.getUseLocation()==Constants.ONE){ 
 | 
                wOutboundDetail.setLocationId(wOutboundInBodyBean.getLocationId()); 
 | 
            } 
 | 
            if(StringUtils.isNotBlank(wOutboundInBodyBean.getProcedureId())){ 
 | 
                wOutboundDetail.setProcedureId(Integer.valueOf(wOutboundInBodyBean.getProcedureId())); 
 | 
            } 
 | 
            wOutboundDetailMapper.insert(wOutboundDetail); 
 | 
            //更新库存数据 
 | 
            QueryWrapper wrapper = new QueryWrapper<WStock>(); 
 | 
            wrapper.eq("ROOT_DEPART_ID", wOutboundDetail.getRootDepartId()); 
 | 
            wrapper.eq("MATERIAL_ID", wOutboundDetail.getMaterialId()); 
 | 
            wrapper.eq("WAREHOUSE_ID", wOutboundDetail.getWarehouseId()); 
 | 
            wrapper.eq("QUALITY_TYPE", wOutboundDetail.getQualityType()); 
 | 
            wrapper.eq(StringUtils.isNotBlank(wOutboundDetail.getBatch()),"BATCH", wOutboundDetail.getBatch()); 
 | 
            wrapper.apply(StringUtils.isBlank(wOutboundDetail.getBatch()),"BATCH is null"); 
 | 
            wrapper.eq(!Objects.isNull(wOutboundDetail.getProcedureId()),"PROCEDURE_ID" , wOutboundDetail.getProcedureId()); 
 | 
            wrapper.apply(Objects.isNull(wOutboundDetail.getProcedureId()),"PROCEDURE_ID is null"); 
 | 
            wrapper.eq(!Objects.isNull(wOutboundDetail.getLocationId())&&warehouse.getUseLocation()==Constants.ONE,"LOCATION_ID", wOutboundDetail.getLocationId()); 
 | 
            wrapper.eq("DELETED",0); 
 | 
            WStock wStock  = wStockMapper.selectOne(wrapper); 
 | 
            if(Objects.isNull(wStock)){ 
 | 
                WStock newWStock = new WStock(); 
 | 
                newWStock.setCreateTime(new Date()); 
 | 
                newWStock.setCreateUser(loginUserInfo.getId()); 
 | 
                newWStock.setRootDepartId(wOutboundDetail.getRootDepartId()); 
 | 
                newWStock.setWarehouseId(wOutboundDetail.getWarehouseId()); 
 | 
                //此仓库 开启仓位 
 | 
                if(warehouse.getUseLocation()==Constants.ONE){ 
 | 
                    newWStock.setLocationId(wOutboundInBodyBean.getLocationId()); 
 | 
                } 
 | 
                newWStock.setMaterialId(wOutboundDetail.getMaterialId()); 
 | 
                newWStock.setBatch(wOutboundDetail.getBatch()); 
 | 
                newWStock.setUnitId(wOutboundDetail.getUnitId()); 
 | 
                newWStock.setNum(wOutboundInBodyBean.getNum()); 
 | 
                newWStock.setQualityType(wOutboundDetail.getQualityType()); 
 | 
                newWStock.setProcedureId(wOutboundDetail.getProcedureId()); 
 | 
                wStockMapper.insert(newWStock); 
 | 
            }else{ 
 | 
                wStock.setNum(wStock.getNum().add(wOutboundInBodyBean.getNum())); 
 | 
                wStockMapper.updateById(wStock); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
    @Transactional 
 | 
    public void adjustmentIn(WOutboundInHeadBean wOutboundInHeadBean,Warehouse warehouse,WOutbound wOutbound,LoginUserInfo loginUserInfo,Integer wareHouseQualityType){ 
 | 
        List<Map<String,Object>> mapList = new ArrayList<>(); 
 | 
        List<WOutboundInBodyBean> wOutboundInBodyBeanList =  wOutboundInHeadBean.getWOutboundInBodyBeanList(); 
 | 
  
 | 
  
 | 
        //整理数据入库数据类别  根据 物料主键,生产工序,质量属性,批次  分类 更新篮筐数据 
 | 
        for (WOutboundInBodyBean i:wOutboundInBodyBeanList) { 
 | 
            if(Objects.isNull(i.getMaterialId()) 
 | 
                    ||Objects.isNull(i.getBatch()) 
 | 
                    ||Objects.isNull(i.getProcedureId()) 
 | 
                    ||Objects.isNull(i.getQualityType()) 
 | 
                    ||Objects.isNull(i.getNum()) 
 | 
                    ||Objects.isNull(i.getAppliancesId()) 
 | 
            ){ 
 | 
                throw new BusinessException(ResponseStatus.DEFECT_PARAMETER.getCode(), "参数异常"); 
 | 
            } 
 | 
            if(i.getNum().compareTo(BigDecimal.ZERO)<=Constants.ZERO){ 
 | 
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "篮筐数量不能为0"); 
 | 
            } 
 | 
            if(wareHouseQualityType != 3){ 
 | 
                if(i.getQualityType()!=wareHouseQualityType){ 
 | 
                    throw new BusinessException(ResponseStatus.ERR_STATUS.getCode(), "篮筐质量属性与仓库属性不一致"); 
 | 
                } 
 | 
            } 
 | 
            MaterialDistribute materialDistribute = materialDistributeMapper.selectById(i.getMaterialId()); 
 | 
            if(Objects.isNull(materialDistribute)){ 
 | 
                throw new BusinessException(ResponseStatus.ERR_STATUS.getCode(), "未查询到物料分配数据"); 
 | 
            } 
 | 
            Material material = materialMapper.selectById(materialDistribute.getMaterialId()); 
 | 
            if(Objects.isNull(material)){ 
 | 
                throw new BusinessException(ResponseStatus.ERR_STATUS.getCode(), "未查询到物料数据"); 
 | 
            } 
 | 
  
 | 
            //更新篮筐数据 
 | 
            Appliances appliances = appliancesMapper.selectById(i.getAppliancesId()); 
 | 
            if(Objects.isNull(appliances)){ 
 | 
                throw new BusinessException(ResponseStatus.DEFECT_PARAMETER.getCode(), "未查询到篮筐:" + i.getAppliancesId()); 
 | 
            } 
 | 
            appliances.setMaterialId(i.getMaterialId()); 
 | 
            appliances.setStatus(3); 
 | 
            appliances.setQualityType(i.getQualityType()); 
 | 
            appliances.setBatch(i.getBatch()); 
 | 
            appliances.setPositionType(Constants.ZERO); 
 | 
            appliances.setNum(i.getNum()); 
 | 
  
 | 
            //根据物料查询当前BOM分配的工序 
 | 
            List<Bom> bomList = bomMapper.selectList(new QueryWrapper<Bom>().eq("MATERIAL_ID",i.getMaterialId()).eq("STATUS",1)); 
 | 
            if(!Objects.isNull(bomList)&&bomList.size()>Constants.ZERO){ 
 | 
                if(StringUtils.isBlank(i.getProcedureId())){ 
 | 
                    throw new BusinessException(ResponseStatus.DEFECT_PARAMETER.getCode(), "物料存在工序,请选择工序"); 
 | 
                } 
 | 
                if(bomList.size()>Constants.ONE){ 
 | 
                    throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,当前物料对应BOM数据异常,存在多条启用BOM!"); 
 | 
                } 
 | 
                Bom bom = bomList.get(Constants.ZERO); 
 | 
                //查询当前生产工序在工艺路线数据中的序号 
 | 
                RouteProcedure routeProcedure = routeProcedureMapper.selectOne(new QueryWrapper<RouteProcedure>().eq("DELETED",Constants.ZERO) 
 | 
                                .eq("ROUTE_ID",bom.getRouteId()) 
 | 
                                .eq("PROCEDURE_ID",i.getProcedureId()) 
 | 
//                        .eq("DEPART_ID",bom.getDepartId()) 
 | 
                ); 
 | 
                if(Objects.isNull(routeProcedure)){ 
 | 
                    throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "对不起,未查询到当前工艺路线数据"); 
 | 
                } 
 | 
                RouteProcedure nextRouteProcedure =  routeProcedureMapper.selectOne(new QueryWrapper<RouteProcedure>() 
 | 
                                .eq("ROUTE_ID",routeProcedure.getRouteId()) 
 | 
//                        .eq("DEPART_ID",bom.getDepartId()) 
 | 
                                .apply("  SORTNUM >  "+routeProcedure.getSortnum()+" ") 
 | 
                                .last(" limit 1  ") 
 | 
                ); 
 | 
                if(!Objects.isNull(nextRouteProcedure)){ 
 | 
                    appliances.setNextProcedureId(nextRouteProcedure.getProcedureId()); 
 | 
                } 
 | 
                appliances.setProcedureId(Integer.valueOf(i.getProcedureId())); 
 | 
            } 
 | 
            appliancesMapper.updateById(appliances); 
 | 
  
 | 
            //添加调整明细记录 用于取消业务使用 2022年8月8日10:01:36 
 | 
            AdjustmentRecord adjustmentRecord = new AdjustmentRecord(); 
 | 
            adjustmentRecord.setCreateTime(new Date()); 
 | 
            adjustmentRecord.setCreateUser(loginUserInfo.getId()); 
 | 
            adjustmentRecord.setAppliancesId(appliances.getId()); 
 | 
            adjustmentRecord.setOutboundId(wOutbound.getId()); 
 | 
            adjustmentRecord.setDeleted(Constants.ZERO); 
 | 
            adjustmentRecord.setRootDepartId(wOutbound.getRootDepartId()); 
 | 
            adjustmentRecordMapper.insert(adjustmentRecord); 
 | 
  
 | 
            Map<String,Object> map = new HashMap<>(); 
 | 
            map.put("materialId",i.getMaterialId()); 
 | 
            map.put("batch",i.getBatch()); 
 | 
            map.put("procedureId",i.getProcedureId()); 
 | 
            map.put("qualityType",i.getQualityType()); 
 | 
            map.put("unitId",material.getUnitId()); 
 | 
            map.put("num",i.getNum()); 
 | 
            //整理入库明细数据 
 | 
            if(Objects.isNull(mapList)||mapList.size()==Constants.ZERO){ 
 | 
                mapList.add(map); 
 | 
            }else{ 
 | 
                Boolean flag = true ; 
 | 
                for (Map<String,Object> m:mapList) { 
 | 
                    if(Objects.equals(m.get("materialId"),map.get("materialId")) 
 | 
                            &&Objects.equals(m.get("batch"),map.get("batch")) 
 | 
                            &&Objects.equals(m.get("procedureId"),map.get("procedureId")) 
 | 
                            &&Objects.equals(m.get("qualityType"),map.get("qualityType")) 
 | 
                    ){ 
 | 
                        BigDecimal num = new BigDecimal(m.get("num").toString()); 
 | 
                        num = num.add(new BigDecimal(map.get("num").toString())); 
 | 
                        m.put("num",num); 
 | 
                        flag = false; 
 | 
                        continue; 
 | 
                    } 
 | 
                } 
 | 
                if(flag){ 
 | 
                    mapList.add(map); 
 | 
                } 
 | 
            } 
 | 
        }; 
 | 
        if(!(Objects.isNull(mapList)||mapList.size()==Constants.ZERO)){ 
 | 
            for (Map<String,Object> m:mapList) { 
 | 
                WOutboundDetail wOutboundDetail = new WOutboundDetail(); 
 | 
                //查询物料数据 
 | 
                MaterialDistribute materialDistribute = materialDistributeMapper.selectById(m.get("materialId").toString()); 
 | 
                if(Objects.isNull(materialDistribute)){ 
 | 
                    throw new BusinessException(ResponseStatus.DEFECT_PARAMETER.getCode(), "未查询到物料数据:"+m.get("materialId").toString()); 
 | 
                } 
 | 
                wOutboundDetail.setNum(new BigDecimal(m.get("num").toString())); 
 | 
                wOutboundDetail.setMaterialId(materialDistribute.getId()); 
 | 
                wOutboundDetail.setUnitId(Integer.valueOf(m.get("unitId").toString())); 
 | 
                if(StringUtils.isNotBlank(m.get("batch").toString())){ 
 | 
                    wOutboundDetail.setBatch(m.get("batch").toString()); 
 | 
                } 
 | 
                wOutboundDetail.setOutboundId(wOutbound.getId()); 
 | 
                wOutboundDetail.setCreateTime(new Date()); 
 | 
                wOutboundDetail.setCreateUser(loginUserInfo.getId()); 
 | 
                wOutboundDetail.setRootDepartId(loginUserInfo.getRootDepartment().getId()); 
 | 
                wOutboundDetail.setWarehouseId(wOutbound.getWarehouseId()); 
 | 
                wOutboundDetail.setQualityType(Integer.valueOf(m.get("qualityType").toString())); 
 | 
                if(StringUtils.isNotBlank(m.get("procedureId").toString())){ 
 | 
                    wOutboundDetail.setProcedureId(Integer.valueOf(m.get("procedureId").toString())); 
 | 
                } 
 | 
                wOutboundDetailMapper.insert(wOutboundDetail); 
 | 
            } 
 | 
        } 
 | 
  
 | 
        //发送钉钉通知 
 | 
        CompanyUser companyUser = companyUserMapper.selectOne(new QueryWrapper<CompanyUser>() 
 | 
                .eq("USER_ID",warehouse.getManagerId()) 
 | 
                .eq("ROOT_DEPART_ID",wOutbound.getRootDepartId()) 
 | 
                .eq("DELETED",0) 
 | 
        ); 
 | 
        Constants.Notices_Type_Transfer notices_type_transfer = Constants.Notices_Type_Transfer.checkEnum(wOutboundInHeadBean.getType()); 
 | 
        if(Objects.isNull(notices_type_transfer)){ 
 | 
            throw new BusinessException(ResponseStatus.DEFECT_PARAMETER.getCode(), "单据操作类型错误!"); 
 | 
        } 
 | 
        String url = Constants.getNoticeUrl(loginUserInfo.getCompany(),Constants.DINGDING_NOTICE_URL.woutIn); 
 | 
        Notices notices = new Notices(); 
 | 
        notices.setCompanyUserId(companyUser.getId()); 
 | 
        notices.setType(notices_type_transfer.getNoticeInType()); 
 | 
        notices.setContent("【"+wOutbound.getCode()+"】"+ notices_type_transfer.getContent().replace("{optType}","入库")); 
 | 
        notices.setTitle(notices_type_transfer.getTitle()); 
 | 
        notices.setObjId(wOutbound.getId()); 
 | 
        notices.setUrl(url.replace("{id}",wOutbound.getId().toString())); 
 | 
        noticesExtService.sendNotice(notices); 
 | 
    } 
 | 
  
 | 
  
 | 
  
 | 
  
 | 
  
 | 
  
 | 
    /********************************************************标准版本接口开始***************************************************************/ 
 | 
  
 | 
//    @Override 
 | 
    @Transactional 
 | 
    public WOutboundRedisBean wOutBoundForInOutStandard(Integer id,Integer wOutboundType,Integer optType,String jsonBean){ 
 | 
        WOutboundRedisBean wOutboundRedisBean = new WOutboundRedisBean(); 
 | 
        if(!(wOutboundType==Constants.ONE||wOutboundType==Constants.ZERO)){ 
 | 
            throw new BusinessException(ResponseStatus.ERR_STATUS.getCode(), "操作单据类型错误"); 
 | 
        } 
 | 
        WOutbound wOutbound = wOutboundExtMapper.wOutboundById(id); 
 | 
        if(Objects.isNull(wOutbound)||wOutbound.getType()!=wOutboundType){ 
 | 
            throw new BusinessException(ResponseStatus.ERR_STATUS.getCode(), "未查询到对应类型单据"); 
 | 
        } 
 | 
        if(wOutbound.getStatus()!=Constants.ZERO){ 
 | 
            throw new BusinessException(ResponseStatus.ERR_STATUS.getCode(), "单据状态错误"); 
 | 
        } 
 | 
        List<WOutboundDetail> wOutboundDetailList = wOutboundDetailExtMapper.wOutboundDetailListById(id,Constants.ZERO); 
 | 
        if(wOutbound.getType()==Constants.ZERO){ 
 | 
            for (WOutboundDetail wOutboundDetail:wOutboundDetailList) { 
 | 
                QueryWStockDto queryWStockDto = new QueryWStockDto(); 
 | 
                queryWStockDto.setRootDepartId(wOutboundDetail.getRootDepartId()); 
 | 
                queryWStockDto.setMaterialId(wOutboundDetail.getMaterialId()); 
 | 
                queryWStockDto.setWarehouseId(wOutboundDetail.getWarehouseId()); 
 | 
                queryWStockDto.setLocationId(wOutboundDetail.getLocationId()); 
 | 
                queryWStockDto.setUnitId(wOutboundDetail.getUnitId()); 
 | 
                queryWStockDto.setBatch(wOutboundDetail.getBatch()); 
 | 
                queryWStockDto.setQualityType(wOutboundDetail.getQualityType()); 
 | 
                queryWStockDto.setProcedureId(wOutboundDetail.getProcedureId()); 
 | 
                wOutboundDetail.setWStockExtListVOList(wStockExtMapper.stockListByDto(queryWStockDto)); 
 | 
            } 
 | 
            wOutbound.setWOutboundDetailsOut(wOutboundDetailExtMapper.wOutboundDetailListById(id,Constants.ONE)); 
 | 
        } 
 | 
  
 | 
        List<WOutboundRedisCodeBean> wOutboundRedisCodeBeanList = new ArrayList<>(); 
 | 
        String jsonArray = RedisUtil.getObject(redisTemplate,Constants.RedisKeys.COM_WOUTBOUND_KEY+wOutbound.getId(),String.class); 
 | 
        List<WOutboundRedisCodeBean> redisWOutboundRedisCodeBeanList = JSON.parseArray(jsonArray,WOutboundRedisCodeBean.class); 
 | 
        if(!Objects.isNull(redisWOutboundRedisCodeBeanList)&&redisWOutboundRedisCodeBeanList.size()>Constants.ZERO){ 
 | 
            //TODO 特殊处理 批次为null redis 转义后 变为“” 
 | 
            for (WOutboundRedisCodeBean wOutboundRedisCodeBean:redisWOutboundRedisCodeBeanList) { 
 | 
                if(StringUtils.isEmpty(wOutboundRedisCodeBean.getBatch())){ 
 | 
                    wOutboundRedisCodeBean.setBatch(null); 
 | 
                } 
 | 
                if(Objects.isNull(wOutboundRedisCodeBean.getProcedureId())||wOutboundRedisCodeBean.getProcedureId()==Constants.ZERO){ 
 | 
                    wOutboundRedisCodeBean.setProcedureId(null); 
 | 
                } 
 | 
            } 
 | 
            wOutboundRedisCodeBeanList.addAll(redisWOutboundRedisCodeBeanList); 
 | 
        } 
 | 
        if(!Objects.isNull(optType)){ 
 | 
            WOutboundRedisCodeBean codeBean =  JSON.parseObject(jsonBean,WOutboundRedisCodeBean.class); 
 | 
            if(StringUtils.isEmpty(codeBean.getBatch())){ 
 | 
                codeBean.setBatch(null); 
 | 
            } 
 | 
            if(Objects.isNull(codeBean.getProcedureId())){ 
 | 
                codeBean.setProcedureId(null); 
 | 
            } 
 | 
//            if(wOutboundType == Constants.ZERO && optType==Constants.ONE){ 
 | 
//                if(workorderRecordExtMapper.checkIsWork(codeBean.getAppliancesId().toString()).size()>Constants.ZERO){ 
 | 
//                    throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "当前篮筐处于投料中"); 
 | 
//                }; 
 | 
//            } 
 | 
            //2022-9-14 13:41:33 处理 添加验证篮筐属性与仓库属性 
 | 
            Warehouse warehouse = warehouseMapper.selectById(wOutbound.getWarehouseId()); 
 | 
            //获取仓库属性 判断扫描篮筐数据属性 
 | 
            SystemDictData systemDictData = systemDictDataMapper.selectById(warehouse.getSystemDicDataId()); 
 | 
            if(Objects.isNull(systemDictData)){ 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到仓库类型数据"); 
 | 
            } 
 | 
            // 0合格 1不良 2报废 ; 
 | 
            Integer wareHouseQualityType = 3 ; 
 | 
            if(systemDictData.getLabel().equals(Constants.APPLIANCES_TYPE_LABLE.qualified)){ 
 | 
                wareHouseQualityType = 0 ; 
 | 
            }else if(systemDictData.getLabel().equals(Constants.APPLIANCES_TYPE_LABLE.rejects)){ 
 | 
                wareHouseQualityType = 1 ; 
 | 
            }else if(systemDictData.getLabel().equals(Constants.APPLIANCES_TYPE_LABLE.scrap)){ 
 | 
                wareHouseQualityType = 2 ; 
 | 
            } 
 | 
            if(wareHouseQualityType != 3){ 
 | 
                if(codeBean.getQualityType()!=wareHouseQualityType){ 
 | 
                    throw new BusinessException(ResponseStatus.ERR_STATUS.getCode(), "库存质量属性与出库仓库属性不一致"); 
 | 
                } 
 | 
            } 
 | 
            //验证当前扫描篮筐与出库单明细是否匹配 
 | 
            if(optType==Constants.ONE){ 
 | 
                this.checkDetailStandard(codeBean); 
 | 
            } 
 | 
            //TODO 更新数据 
 | 
            this.updateRedisCodeStandard(wOutboundRedisCodeBeanList,optType,codeBean,wOutboundType); 
 | 
  
 | 
        } 
 | 
        if(!Objects.isNull(wOutboundType)){ 
 | 
            //TODO 整理已扫描物料数据 
 | 
            this.handleWOutboundOutCodeStandard(wOutboundRedisBean,wOutboundRedisCodeBeanList,false); 
 | 
        } 
 | 
        wOutboundRedisBean.setWOutbound(wOutbound); 
 | 
        wOutboundRedisBean.setWOutboundDetailsWait(wOutboundDetailList); 
 | 
        wOutboundRedisBean.setWOutboundRedisCodeBeanList(wOutboundRedisCodeBeanList); 
 | 
        wOutboundRedisBean.setWarehouse(warehouseMapper.selectById(wOutbound.getWarehouseId())); 
 | 
        if(!Objects.isNull(optType)){ 
 | 
            RedisUtil.addObject(redisTemplate,Constants.RedisKeys.COM_WOUTBOUND_KEY+wOutbound.getId(), JSONArray.fromObject(wOutboundRedisCodeBeanList).toString()); 
 | 
        } 
 | 
  
 | 
//        Constants.Notices_Type_Transfer notices_type_transfer = Constants.Notices_Type_Transfer.checkEnum(wOutbound.getBillType()); 
 | 
//        noticesExtService.dealNotice(wOutbound.getId(),notices_type_transfer.getNoticeInType(),null); 
 | 
        return wOutboundRedisBean; 
 | 
    } 
 | 
  
 | 
  
 | 
  
 | 
  
 | 
    @Transactional 
 | 
    public void updateAppliancesStandard(List<WoScanMaterialBean>  woScanMaterialBeanList,Warehouse warehouse,Integer wOutboundType,LoginUserInfo loginUserInfo,Integer orgin){ 
 | 
        if(Objects.isNull(woScanMaterialBeanList)||woScanMaterialBeanList.size()==Constants.ZERO){ 
 | 
            throw new BusinessException(ResponseStatus.ERR_STATUS.getCode(), "无扫描数据,提交失败"); 
 | 
        } 
 | 
        for (WoScanMaterialBean woScanMaterialBean:woScanMaterialBeanList) { 
 | 
            List<WOutboundRedisCodeBean> wOutboundRedisCodeBeanList = woScanMaterialBean.getWOutboundRedisCodeBeanList(); 
 | 
            if(wOutboundRedisCodeBeanList.size()>Constants.ZERO){ 
 | 
                WOutboundDetail wOutboundDetail = wOutboundDetailMapper.selectById(woScanMaterialBean.getWOutboundDetailId()); 
 | 
                for (WOutboundRedisCodeBean wOutboundRedisCodeBean:wOutboundRedisCodeBeanList) { 
 | 
                    Appliances appliances = appliancesMapper.selectById(wOutboundRedisCodeBean.getAppliancesId()); 
 | 
                    appliances.setCurObjId(wOutboundDetail.getOutboundId()); 
 | 
                    appliances.setCurObjType(Constants.ZERO); 
 | 
                    Integer outLocationId = Constants.ZERO ; 
 | 
                    if(wOutboundType==Constants.ZERO){ 
 | 
                        if(!Objects.isNull(appliances)){ 
 | 
                            if(warehouse.getUseLocation()==Constants.ONE) { 
 | 
                                outLocationId = appliances.getLocationId(); 
 | 
                            } 
 | 
                            appliances.setWarehouseId(null); 
 | 
                            appliances.setLocationId(null); 
 | 
                        } 
 | 
                    }else if(wOutboundType==Constants.ONE){ 
 | 
                        appliances.setWarehouseId(wOutboundDetail.getWarehouseId()); 
 | 
                        if(warehouse.getUseLocation()==Constants.ONE){ 
 | 
                            appliances.setLocationId(woScanMaterialBean.getLocationId()); 
 | 
                        } 
 | 
                    } 
 | 
                    WOutboundRecord wOutboundRecord = wOutboundDetail.toRecord(appliances,loginUserInfo); 
 | 
                    if(warehouse.getUseLocation()==Constants.ONE){ 
 | 
                        //根据出入库类别 记录record表货位数据  入库由扫描货位来 出库由原工装器具数据来 
 | 
                        if(wOutboundType==Constants.ZERO){ 
 | 
                            wOutboundRecord.setLocationId(outLocationId); 
 | 
                        }else{ 
 | 
                            wOutboundRecord.setLocationId(appliances.getLocationId()); 
 | 
                        } 
 | 
  
 | 
                    } 
 | 
                    wOutboundRecordMapper.insert(wOutboundRecord); 
 | 
                    //手工创建出库单 要更新掉工装器具内所有数据 2022年10月27日11:04:22 
 | 
                    if(wOutboundType==Constants.ZERO&&!Objects.isNull(orgin)&&Constants.ZERO == orgin){ 
 | 
                        appliances.setSerialNum(null); 
 | 
                        appliances.setStatus(Constants.ONE); 
 | 
                        appliances.setWorkorderId(null); 
 | 
                        appliances.setMaterialId(null); 
 | 
                        appliances.setNum(null); 
 | 
                        appliances.setPositionType(null); 
 | 
                        appliances.setProcedureId(null); 
 | 
                        appliances.setNextProcedureId(null); 
 | 
                        appliances.setCurObjId(null); 
 | 
                        appliances.setCurObjType(null); 
 | 
                        appliances.setBatch(null); 
 | 
                        appliances.setQualityType(null); 
 | 
                        appliances.setBackorderId(null); 
 | 
                        appliances.setSaleorderId(null); 
 | 
                        appliances.setBackProcedureId(null); 
 | 
                        appliances.setRelobjType(null); 
 | 
                    } 
 | 
                    if(!Objects.isNull(orgin)&&Constants.ZERO == orgin){ 
 | 
                        appliancesExtMapper.editById(appliances); 
 | 
                    }else{ 
 | 
                        appliancesMapper.updateById(appliances); 
 | 
                    } 
 | 
                } 
 | 
                wOutboundDetail.setDoneNum(woScanMaterialBean.getScanNum()); 
 | 
                wOutboundDetail.setStatus(Constants.ONE); 
 | 
                wOutboundDetail.setDoneDate(new Date()); 
 | 
                wOutboundDetailMapper.updateById(wOutboundDetail); 
 | 
                //记录库存变动记录 
 | 
                wStockRecordExtService.saveRecordNoLocationId(wOutboundType,wOutboundDetail.getId(),loginUserInfo,woScanMaterialBean.getLocationId()); 
 | 
                this.updateStock(woScanMaterialBean,wOutboundDetail,warehouse,wOutboundType,loginUserInfo); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
  
 | 
    /** 
 | 
     * 更新库存信息 
 | 
     * @param woScanMaterialBean 
 | 
     * @param wOutboundDetail 
 | 
     * @param loginUserInfo 
 | 
     */ 
 | 
    @Transactional 
 | 
    public void updateStockStandard(WoScanMaterialBean woScanMaterialBean,WOutboundDetail wOutboundDetail,Warehouse warehouse,Integer wOutboundType,LoginUserInfo loginUserInfo){ 
 | 
        //TODO 查询库存数据 
 | 
        QueryWrapper wrapper = new QueryWrapper<WStock>(); 
 | 
        wrapper.eq("ROOT_DEPART_ID", wOutboundDetail.getRootDepartId()); 
 | 
        wrapper.eq("MATERIAL_ID", woScanMaterialBean.getMaterialId()); 
 | 
        wrapper.eq("WAREHOUSE_ID", wOutboundDetail.getWarehouseId()); 
 | 
        wrapper.eq("QUALITY_TYPE", wOutboundDetail.getQualityType()); 
 | 
        if(StringUtils.isNotBlank(wOutboundDetail.getBatch())){ 
 | 
            wrapper.eq("BATCH" , wOutboundDetail.getBatch()); 
 | 
        }else{ 
 | 
            wrapper.apply("BATCH is null "); 
 | 
        } 
 | 
        if(Objects.isNull(wOutboundDetail.getProcedureId())){ 
 | 
            wrapper.apply(" PROCEDURE_ID is null  "); 
 | 
        }else{ 
 | 
            wrapper.eq("PROCEDURE_ID" , wOutboundDetail.getProcedureId()); 
 | 
        } 
 | 
        wrapper.eq(!Objects.isNull(wOutboundDetail.getLocationId())&&warehouse.getUseLocation()==Constants.ONE,"LOCATION_ID", wOutboundDetail.getLocationId()); 
 | 
        wrapper.eq("DELETED",0); 
 | 
        List<WStock> wStockList = wStockMapper.selectList(wrapper); 
 | 
        if(wOutboundType==Constants.ZERO){ 
 | 
            if(Objects.isNull(wStockList)||wStockList.size()==Constants.ZERO){ 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "库存信息异常:【"+warehouse.getId()+"】 - 【"+wOutboundDetail.getLocationId()+"】 - 【"+wOutboundDetail.getMaterialId()+"】- 【"+wOutboundDetail.getBatch()+"】"); 
 | 
            } 
 | 
            WStock wStock = wStockList.get(0); 
 | 
            if (wStock.getNum().compareTo(woScanMaterialBean.getScanNum()) < Constants.ZERO) { 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "当前货位库存数量不足;剩余数量【" + wStock.getNum() + "】;出库数量【" + woScanMaterialBean.getScanNum() + "】"); 
 | 
            } 
 | 
            wStock.setNum(wStock.getNum().subtract(woScanMaterialBean.getScanNum())); 
 | 
            wStockMapper.updateById(wStock); 
 | 
        }else{ 
 | 
            if(Objects.isNull(wStockList)||wStockList.size()==Constants.ZERO){ 
 | 
                WStock newWStock = new WStock(); 
 | 
                newWStock.setCreateTime(new Date()); 
 | 
                newWStock.setCreateUser(loginUserInfo.getId()); 
 | 
                newWStock.setRootDepartId(wOutboundDetail.getRootDepartId()); 
 | 
                newWStock.setWarehouseId(wOutboundDetail.getWarehouseId()); 
 | 
                //此仓库 开启仓位 
 | 
                if(warehouse.getUseLocation()==Constants.ONE){ 
 | 
                    newWStock.setLocationId(woScanMaterialBean.getLocationId()); 
 | 
                } 
 | 
                newWStock.setMaterialId(wOutboundDetail.getMaterialId()); 
 | 
                newWStock.setBatch(wOutboundDetail.getBatch()); 
 | 
                newWStock.setUnitId(wOutboundDetail.getUnitId()); 
 | 
                newWStock.setNum(woScanMaterialBean.getScanNum()); 
 | 
                newWStock.setQualityType(wOutboundDetail.getQualityType()); 
 | 
                newWStock.setProcedureId(wOutboundDetail.getProcedureId()); 
 | 
                wStockMapper.insert(newWStock); 
 | 
            }else{ 
 | 
                WStock wStock = wStockList.get(0); 
 | 
                wStock.setNum(wStock.getNum().add(woScanMaterialBean.getScanNum())); 
 | 
                wStockMapper.updateById(wStock); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
  
 | 
  
 | 
    public void handleWOutboundOutCodeStandard(WOutboundRedisBean wOutboundRedisBean,List<WOutboundRedisCodeBean> wOutboundRedisCodeBeanList,boolean isError){ 
 | 
        List<WoScanMaterialBean>  woScanMaterialBeanList = new ArrayList<>(); 
 | 
        if(!Objects.isNull(wOutboundRedisCodeBeanList)&&wOutboundRedisCodeBeanList.size()>Constants.ZERO){ 
 | 
            //获取仓库属性 判断扫描篮筐数据属性 
 | 
            for (WOutboundRedisCodeBean wOutboundRedisCodeBean:wOutboundRedisCodeBeanList) { 
 | 
                //遍历已扫工装数据 
 | 
                if(woScanMaterialBeanList.size()==Constants.ZERO || !isRepeatMaterialDataStandard(woScanMaterialBeanList,wOutboundRedisCodeBean)){ 
 | 
                    woScanMaterialBeanList.add(wOutboundRedisCodeBean.toWoScanMaterialBean()); 
 | 
                } 
 | 
            } 
 | 
            //TODO 已扫描物料数据 绑定已扫描条码 更新已扫描数量 
 | 
            for (WoScanMaterialBean woScanMaterialBean:woScanMaterialBeanList) { 
 | 
                BigDecimal scanNum = BigDecimal.ZERO; 
 | 
  
 | 
                List<WOutboundRedisCodeBean> wOutboundRedisCodeBeans = new ArrayList<>(); 
 | 
                for (WOutboundRedisCodeBean wOutboundRedisCodeBean:wOutboundRedisCodeBeanList) { 
 | 
                    if(StringUtils.equals(woScanMaterialBean.getWOutboundDetailId().toString(),wOutboundRedisCodeBean.getWOutboundDetailId().toString()) 
 | 
                            &&StringUtils.equals(woScanMaterialBean.getMaterialId().toString(),wOutboundRedisCodeBean.getMaterialId().toString()) 
 | 
//                            &&StringUtils.equals(woScanMaterialBean.getLocationId().toString(),wOutboundRedisCodeBean.getLocationId().toString()) 
 | 
                            &&woScanMaterialBean.getQualityType().intValue() == wOutboundRedisCodeBean.getQualityType().intValue() 
 | 
                    ){ 
 | 
                        if(!Objects.equals(woScanMaterialBean.getLocationId(),wOutboundRedisCodeBean.getLocationId())){ 
 | 
                            continue; 
 | 
                        } 
 | 
                        //TODO 判断工序是否都不为空 
 | 
                        if(!Objects.isNull(woScanMaterialBean.getProcedureId())&&!Objects.isNull(wOutboundRedisCodeBean.getProcedureId())){ 
 | 
                            if(!woScanMaterialBean.getProcedureId().equals(wOutboundRedisCodeBean.getProcedureId())){ 
 | 
                                continue; 
 | 
                            } 
 | 
                        }else if(Objects.isNull(woScanMaterialBean.getProcedureId())&&!Objects.isNull(wOutboundRedisCodeBean.getProcedureId())){ 
 | 
                            continue; 
 | 
                        }else if(!Objects.isNull(woScanMaterialBean.getProcedureId())&&Objects.isNull(wOutboundRedisCodeBean.getProcedureId())){ 
 | 
                            continue; 
 | 
                        } 
 | 
                        //TODO 若批次为 null /“” 则不验证批次,否则验证 
 | 
                        if(StringUtils.isNotEmpty(woScanMaterialBean.getBatch())&&StringUtils.equals(woScanMaterialBean.getBatch(),wOutboundRedisCodeBean.getBatch())){ 
 | 
                            wOutboundRedisCodeBeans.add(wOutboundRedisCodeBean); 
 | 
                            scanNum = scanNum.add(wOutboundRedisCodeBean.getNum()); 
 | 
                        }else if(StringUtils.isEmpty(woScanMaterialBean.getBatch())){ 
 | 
                            wOutboundRedisCodeBeans.add(wOutboundRedisCodeBean); 
 | 
                            scanNum = scanNum.add(wOutboundRedisCodeBean.getNum()); 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
                if(isError){ 
 | 
                    WOutboundDetail wOutboundDetail = wOutboundDetailMapper.selectById(woScanMaterialBean.getWOutboundDetailId()); 
 | 
  
 | 
                    if( scanNum.compareTo(wOutboundDetail.getNum())>0){ 
 | 
                        throw new BusinessException(ResponseStatus.EXCEED_PLAN_NUM.getCode(), "超出计划数量,扫描失败"); 
 | 
                    } 
 | 
  
 | 
                } 
 | 
                woScanMaterialBean.setWOutboundRedisCodeBeanList(wOutboundRedisCodeBeans); 
 | 
                woScanMaterialBean.setScanNum(scanNum); 
 | 
            } 
 | 
            wOutboundRedisBean.setWoScanMaterialBeanList(woScanMaterialBeanList); 
 | 
        } 
 | 
    } 
 | 
  
 | 
    private boolean isRepeatMaterialDataStandard(List<WoScanMaterialBean> woScanMaterialBeanList, WOutboundRedisCodeBean wOutboundRedisCodeBean) { 
 | 
        //TODO 物料/批次/货位是否相同 相同则跳过,否则加入数据 
 | 
        for (WoScanMaterialBean woScanMaterialBean:woScanMaterialBeanList) { 
 | 
            if(StringUtils.equals(woScanMaterialBean.getWOutboundDetailId().toString(),wOutboundRedisCodeBean.getWOutboundDetailId().toString()) 
 | 
                    &&StringUtils.equals(woScanMaterialBean.getMaterialId().toString(),wOutboundRedisCodeBean.getMaterialId().toString()) 
 | 
                    &&StringUtils.equals(woScanMaterialBean.getLocationId().toString(),wOutboundRedisCodeBean.getLocationId().toString()) 
 | 
                    &&Constants.equalsInteger(woScanMaterialBean.getQualityType(),wOutboundRedisCodeBean.getQualityType()) 
 | 
            ) { 
 | 
                // 物料/批次/货位相同 
 | 
                //TODO 判断工序是否都不为空 
 | 
                if(!Objects.isNull(woScanMaterialBean.getProcedureId())&&!Objects.isNull(wOutboundRedisCodeBean.getProcedureId()) && !Constants.equalsInteger(woScanMaterialBean.getProcedureId(),(wOutboundRedisCodeBean.getProcedureId()))){ 
 | 
                    return false; 
 | 
                }else if(Objects.isNull(woScanMaterialBean.getProcedureId())&&!Objects.isNull(wOutboundRedisCodeBean.getProcedureId())){ 
 | 
                    return false; 
 | 
                }else if(!Objects.isNull(woScanMaterialBean.getProcedureId())&&Objects.isNull(wOutboundRedisCodeBean.getProcedureId())){ 
 | 
                    return false; 
 | 
                } 
 | 
                //TODO 若批次为 null /“” 则不验证批次,否则验证 
 | 
                if(StringUtils.isNotEmpty(woScanMaterialBean.getBatch())&&!StringUtils.equals(woScanMaterialBean.getBatch(),wOutboundRedisCodeBean.getBatch())){ 
 | 
                    return false; 
 | 
                }else if(StringUtils.isNotEmpty(woScanMaterialBean.getBatch()) && StringUtils.isEmpty(wOutboundRedisCodeBean.getBatch())){ 
 | 
                    return false; 
 | 
                }else if(StringUtils.isEmpty(woScanMaterialBean.getBatch()) && StringUtils.isNotEmpty(wOutboundRedisCodeBean.getBatch())){ 
 | 
                    return false; 
 | 
                } 
 | 
                return true; 
 | 
            } 
 | 
  
 | 
        } 
 | 
        return false; 
 | 
    } 
 | 
  
 | 
  
 | 
    /** 
 | 
     * 更新条码列表 
 | 
     * @param wOutboundRedisCodeBeanList 所有条码列表 
 | 
     * @param optType 1:添加;2:删除 
 | 
     * @param codeBean 工装器具 
 | 
     */ 
 | 
    @Transactional 
 | 
    public void updateRedisCodeStandard(List<WOutboundRedisCodeBean> wOutboundRedisCodeBeanList,Integer optType,WOutboundRedisCodeBean codeBean,Integer wOutboundType){ 
 | 
        if(Objects.isNull(optType)|| (optType!=Constants.ONE&&optType!=Constants.TWO)){ 
 | 
            throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "更新操作类别异常"); 
 | 
        }if(optType==Constants.ONE){ 
 | 
            // 校验 工装器具数据是否已扫描 
 | 
            for (WOutboundRedisCodeBean wOutboundRedisCodeBean:wOutboundRedisCodeBeanList) { 
 | 
                if(StringUtils.equals(wOutboundRedisCodeBean.getAppliancesId().toString(),codeBean.getAppliancesId().toString())){ 
 | 
                    throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "工装器具数据已扫描,无法重复扫描"); 
 | 
                } 
 | 
                //判断条码是是否在当前单据中 
 | 
                WOutboundDetail wOutboundDetail = wOutboundDetailMapper.selectById(codeBean.getWOutboundDetailId()); 
 | 
                if(StringUtils.equals(wOutboundDetail.getMaterialId().toString(),codeBean.getMaterialId().toString()) 
 | 
                        &&StringUtils.equals(wOutboundDetail.getWarehouseId().toString(),codeBean.getWarehouseId().toString())){ 
 | 
  
 | 
                    if(!Objects.isNull(wOutboundDetail.getProcedureId())&&!Objects.isNull( codeBean.getProcedureId())){ 
 | 
                        if(!wOutboundDetail.getProcedureId().equals(codeBean.getProcedureId())){ 
 | 
                            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "添加条码数据工序数据不匹配"); 
 | 
                        } 
 | 
                    }else if(Objects.isNull(wOutboundDetail.getProcedureId())&&!Objects.isNull( codeBean.getProcedureId())){ 
 | 
                        throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "添加条码数据工序数据不匹配"); 
 | 
                    }else if(!Objects.isNull(wOutboundDetail.getProcedureId())&&Objects.isNull( codeBean.getProcedureId())){ 
 | 
                        throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "添加条码数据工序数据不匹配"); 
 | 
                    } 
 | 
                    if(StringUtils.isNotBlank(wOutboundDetail.getBatch())){ 
 | 
                        if(!wOutboundDetail.getBatch().equals(codeBean.getBatch())){ 
 | 
                            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "添加条码数据批次不匹配"); 
 | 
                        } 
 | 
                    } 
 | 
                    if(StringUtils.isNotBlank(wOutboundDetail.getBatch())){ 
 | 
                        if(!wOutboundDetail.getBatch().equals(codeBean.getBatch())){ 
 | 
                            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "添加条码数据批次不匹配"); 
 | 
                        } 
 | 
                    } 
 | 
                    if(!Objects.isNull(wOutboundDetail.getLocationId())){ 
 | 
                        if(!Objects.equals(wOutboundDetail.getLocationId(),codeBean.getLocationId())){ 
 | 
                            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "添加条码数据货位不匹配"); 
 | 
                        } 
 | 
                    } 
 | 
                }else{ 
 | 
                    throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "添加条码数据不匹配"); 
 | 
                } 
 | 
            } 
 | 
            wOutboundRedisCodeBeanList.add(codeBean); 
 | 
        }else if(optType==Constants.TWO){ 
 | 
            //TODO 是否在当前单据数据内 
 | 
            Boolean isHave = true; 
 | 
            for (WOutboundRedisCodeBean wOutboundRedisCodeBean:wOutboundRedisCodeBeanList) { 
 | 
                if (StringUtils.equals(wOutboundRedisCodeBean.getAppliancesId().toString(), codeBean.getAppliancesId().toString())) { 
 | 
                    wOutboundRedisCodeBeanList.remove(wOutboundRedisCodeBean); 
 | 
                    isHave = false; 
 | 
                    break; 
 | 
                } 
 | 
            } 
 | 
            if(isHave){ 
 | 
                throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "扫描条码未存在当前单据内"); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
  
 | 
  
 | 
  
 | 
    public void checkDetailStandard(WOutboundRedisCodeBean codeBean){ 
 | 
        WOutboundDetail wOutboundDetail = wOutboundDetailMapper.selectById(codeBean.getWOutboundDetailId()); 
 | 
        if(Objects.isNull(wOutboundDetail)){ 
 | 
            throw new BusinessException(ResponseStatus.OBJECT_EMP.getCode(), "未查询到出库明细信息"); 
 | 
        } 
 | 
        if(!Objects.equals(codeBean.getWarehouseId(),wOutboundDetail.getWarehouseId())){ 
 | 
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "仓库信息不匹配"); 
 | 
        } 
 | 
        if(!Objects.isNull(wOutboundDetail.getLocationId())&&!Objects.equals(codeBean.getLocationId(),wOutboundDetail.getLocationId())){ 
 | 
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "仓位信息信息不匹配"); 
 | 
        } 
 | 
        if(!Objects.equals(codeBean.getMaterialId(),wOutboundDetail.getMaterialId())){ 
 | 
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "物料信息信息不匹配"); 
 | 
        } 
 | 
        if(!Objects.isNull(wOutboundDetail.getBatch())&&!Objects.equals(codeBean.getBatch(),wOutboundDetail.getBatch())){ 
 | 
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "物料批次信息不匹配"); 
 | 
        } 
 | 
        if(!Objects.equals(codeBean.getQualityType(),wOutboundDetail.getQualityType())){ 
 | 
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "物料质量属性信息不匹配"); 
 | 
        } 
 | 
        if(!Objects.isNull(wOutboundDetail.getProcedureId())&&!Objects.equals(codeBean.getProcedureId(),wOutboundDetail.getProcedureId())){ 
 | 
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "物料工序信息不匹配"); 
 | 
        } 
 | 
    } 
 | 
  
 | 
  
 | 
    /********************************************************标准版本接口结束***************************************************************/ 
 | 
} 
 |