/*
|
* Copyright (c) 2018-2025, ztt All rights reserved.
|
*
|
* Redistribution and use in source and binary forms, with or without
|
* modification, are permitted provided that the following conditions are met:
|
*
|
* Redistributions of source code must retain the above copyright notice,
|
* this list of conditions and the following disclaimer.
|
* Redistributions in binary form must reproduce the above copyright
|
* notice, this list of conditions and the following disclaimer in the
|
* documentation and/or other materials provided with the distribution.
|
* Neither the name of the pig4cloud.com developer nor the names of its
|
* contributors may be used to endorse or promote products derived from
|
* this software without specific prior written permission.
|
* Author: ztt
|
*/
|
package com.chinaztt.mes.warehouse.service.impl;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
|
import com.chinaztt.mes.warehouse.dto.ReturnDetailDTO;
|
import com.chinaztt.mes.warehouse.entity.ReturnDetail;
|
import com.chinaztt.mes.warehouse.entity.ReturnMain;
|
import com.chinaztt.mes.warehouse.mapper.ReturnDetailMapper;
|
import com.chinaztt.mes.warehouse.service.ReturnDetailService;
|
import lombok.AllArgsConstructor;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.List;
|
|
/**
|
* 退库申请明细表
|
*
|
* @author cxf
|
* @date 2020-10-21 10:46:33
|
*/
|
@Service
|
@AllArgsConstructor
|
@Transactional(rollbackFor = Exception.class)
|
public class ReturnDetailServiceImpl extends ServiceImpl<ReturnDetailMapper, ReturnDetail> implements ReturnDetailService {
|
|
@Override
|
public IPage<List<ReturnDetailDTO>> getReturnDetailPage(Page page, QueryWrapper<ReturnDetailDTO> gen) {
|
return baseMapper.getReturnDetailPage(page, gen);
|
}
|
|
@Override
|
public ReturnDetailDTO getReturnDetailById(Long id) {
|
return baseMapper.getReturnDetailById(id);
|
}
|
|
@Override
|
public boolean save(ReturnDetail returnDetail) {
|
checkRepeat(returnDetail);
|
return SqlHelper.retBool(baseMapper.insert(returnDetail));
|
}
|
|
@Override
|
public boolean updateById(ReturnDetail returnDetail) {
|
checkRepeat(returnDetail);
|
return SqlHelper.retBool(baseMapper.updateById(returnDetail));
|
}
|
|
/**
|
* 检查新增或保存的退库明细是否重复
|
*
|
* @param returnDetail
|
*/
|
public void checkRepeat(ReturnDetail returnDetail) {
|
List<ReturnDetail> result = baseMapper.selectList(Wrappers.<ReturnDetail>query().lambda().eq(ReturnDetail::getStockId, returnDetail.getStockId()).eq(ReturnDetail::getLocationId, returnDetail.getLocationId())
|
.eq(ReturnDetail::getReturnMainId, returnDetail.getReturnMainId()).ne(ReturnDetail::getId, returnDetail.getId()));
|
if (CollectionUtil.isNotEmpty(result)) {
|
throw new RuntimeException("零件已存在,请勿重复退库");
|
}
|
}
|
}
|