rentaiming
2024-07-30 837da67d468fbcdd10ee27dcc44a94e7b1130a85
ruoyi-modules/ruoyi-management/src/main/java/com/ruoyi/management/service/impl/InventoriesSuppliesInfoServiceImpl.java
@@ -9,9 +9,7 @@
import com.ruoyi.management.domain.dto.InventoriesSuppliesInfoQuery;
import com.ruoyi.management.domain.vo.InventoriesSuppliesInfoVO;
import com.ruoyi.management.domain.vo.InventoriesSuppliesVO;
import com.ruoyi.management.mapper.InventoriesSuppliesInfoMapper;
import com.ruoyi.management.mapper.SlGoodsMaterialsMapper;
import com.ruoyi.management.mapper.SlVolumeProductionRkMapper;
import com.ruoyi.management.mapper.*;
import com.ruoyi.management.service.InventoriesSuppliesInfoService;
import org.springframework.stereotype.Service;
@@ -38,12 +36,18 @@
    @Resource
    private SlGoodsMaterialsMapper slGoodsMaterialsMapper;
    @Resource
    private ManagementGoodsMaterialsMapper managementGoodsMaterialsMapper;
    @Resource
    private SlGoodsShelfMapper slGoodsShelfMapper;
    @Override
    public PageDTO<InventoriesSuppliesInfoVO> inventoriesSuppliesInfoService(InventoriesSuppliesInfoQuery inventoriesSuppliesInfoQuery) {
        Page<InventoriesSuppliesInfo> page = new Page<>(inventoriesSuppliesInfoQuery.getPageCurr(), inventoriesSuppliesInfoQuery.getPageSize());
        LambdaQueryWrapper< InventoriesSuppliesInfo> wrapper1= Wrappers.lambdaQuery();
        wrapper1.gt(InventoriesSuppliesInfo::getSuppliesId, inventoriesSuppliesInfoQuery.getSuppliesId());
        wrapper1.eq(InventoriesSuppliesInfo::getSuppliesId, inventoriesSuppliesInfoQuery.getSuppliesId());
        wrapper1.eq( InventoriesSuppliesInfo::getDelFlag,0);
        wrapper1.orderByDesc(InventoriesSuppliesInfo::getCreateTime);
        wrapper1.orderByDesc(InventoriesSuppliesInfo::getType);
@@ -54,27 +58,32 @@
            SlVolumeProductionRk slVolumeProductionRk = slVolumeProductionRkMapper.selectById(sl.getRkId());
            sl.setRkNumber(slVolumeProductionRk.getRkNumber());
            sl.setRkModel(slVolumeProductionRk.getRkModel());
            sl.setZkNum(slVolumeProductionRk.getRepertoryZhai());
            SlGoodsMaterials slGoodsMaterials = slGoodsMaterialsMapper.selectById(slVolumeProductionRk.getMaterialsId());
            sl.setGoodsMaterialsName(slGoodsMaterials.getGoodsMaterialsName());
            sl.setIsConsume(slGoodsMaterials.getIsConsume());
            sl.setStoreManagementNumber(slVolumeProductionRk.getStoreManagementNumber());
            SlGoodsShelf slGoodsShelf = slGoodsShelfMapper.selectById(slVolumeProductionRk.getShelfId());
            sl.setGoodsShelfName(slGoodsShelf.getGoodsShelfName());
        }
        return slGoodsMaterialsVO;
    }
    @Override
    public void addInventoriesSuppliesInfo(InventoriesSuppliesInfoDTO inventoriesSuppliesInfoDTO) {
        if (inventoriesSuppliesInfoDTO.getId()==0){
    public void addInventoriesSuppliesInfo(List<InventoriesSuppliesInfoDTO> inventoriesSuppliesInfoDTO) {
        for (InventoriesSuppliesInfoDTO m:inventoriesSuppliesInfoDTO)
        if (m.getId()==null){
            InventoriesSuppliesInfo inventoriesSuppliesInf=new InventoriesSuppliesInfo();
            inventoriesSuppliesInf.setSuppliesId(inventoriesSuppliesInfoDTO.getSuppliesId());
            inventoriesSuppliesInf.setRkId(inventoriesSuppliesInfoDTO.getRkId());
            SlVolumeProductionRk slVolumeProductionRk = slVolumeProductionRkMapper.selectById(inventoriesSuppliesInfoDTO.getRkId());
            inventoriesSuppliesInf.setSuppliesId(m.getSuppliesId());
            inventoriesSuppliesInf.setRkId(m.getRkId());
            SlVolumeProductionRk slVolumeProductionRk = slVolumeProductionRkMapper.selectById(m.getRkId());
            inventoriesSuppliesInf.setZkNum(slVolumeProductionRk.getRepertoryZhai());
            inventoriesSuppliesInf.setSuppliesNum(inventoriesSuppliesInfoDTO.getSuppliesNum());
            inventoriesSuppliesInf.setSuppliesNum(m.getSuppliesNum());
            this.save(inventoriesSuppliesInf);
        }else{
            InventoriesSuppliesInfo byId = this.getById(inventoriesSuppliesInfoDTO.getId());
            byId.setSuppliesNum(inventoriesSuppliesInfoDTO.getSuppliesNum());
            InventoriesSuppliesInfo byId = this.getById(m.getId());
            byId.setSuppliesNum(m.getSuppliesNum());
            this.updateById(byId);
        }
@@ -83,8 +92,8 @@
    @Override
    public InventoriesSuppliesInfo getInventoriesSuppliesInfo(InventoriesSuppliesInfoDTO inventoriesSuppliesInfoDTO) {
        LambdaQueryWrapper< InventoriesSuppliesInfo> wrapper1= Wrappers.lambdaQuery();
        wrapper1.gt(InventoriesSuppliesInfo::getSuppliesId, inventoriesSuppliesInfoDTO.getSuppliesId());
        wrapper1.gt(InventoriesSuppliesInfo::getRkId, inventoriesSuppliesInfoDTO.getSuppliesId());
        wrapper1.eq(InventoriesSuppliesInfo::getSuppliesId, inventoriesSuppliesInfoDTO.getSuppliesId());
        wrapper1.eq(InventoriesSuppliesInfo::getRkId, inventoriesSuppliesInfoDTO.getSuppliesId());
        wrapper1.eq( InventoriesSuppliesInfo::getDelFlag,0);
        InventoriesSuppliesInfo page2 = this.getOne(wrapper1);
        return page2;
@@ -93,7 +102,7 @@
    @Override
    public void submitInventoriesSuppliesInfo(InventoriesSuppliesInfoDTO inventoriesSuppliesInfoDTO) {
        LambdaQueryWrapper< InventoriesSuppliesInfo> wrapper1= Wrappers.lambdaQuery();
        wrapper1.gt(InventoriesSuppliesInfo::getSuppliesId, inventoriesSuppliesInfoDTO.getSuppliesId());
        wrapper1.eq(InventoriesSuppliesInfo::getSuppliesId, inventoriesSuppliesInfoDTO.getSuppliesId());
        wrapper1.eq( InventoriesSuppliesInfo::getDelFlag,0);
        List<InventoriesSuppliesInfo> page2 = this.list(wrapper1);
        for (InventoriesSuppliesInfo page:page2){
@@ -108,14 +117,25 @@
    public void accomplishInventoriesSuppliesInfo(InventoriesSuppliesInfoDTO inventoriesSuppliesInfoDTO) {
        LambdaQueryWrapper< InventoriesSuppliesInfo> wrapper1= Wrappers.lambdaQuery();
        wrapper1.gt(InventoriesSuppliesInfo::getSuppliesId, inventoriesSuppliesInfoDTO.getSuppliesId());
        wrapper1.gt(InventoriesSuppliesInfo::getType, 2);
        wrapper1.eq(InventoriesSuppliesInfo::getSuppliesId, inventoriesSuppliesInfoDTO.getSuppliesId());
        wrapper1.eq(InventoriesSuppliesInfo::getType, 2);
        wrapper1.eq( InventoriesSuppliesInfo::getDelFlag,0);
        List<InventoriesSuppliesInfo> page2 = this.list(wrapper1);
        for (InventoriesSuppliesInfo page:page2){
            SlVolumeProductionRk slVolumeProductionRk = slVolumeProductionRkMapper.selectById(page.getRkId());
            slVolumeProductionRk.setRepertoryZhai(page.getSuppliesNum());
            slVolumeProductionRkMapper.updateById(slVolumeProductionRk);
            LambdaQueryWrapper<ManagementGoodsMaterials> wrapper2 = Wrappers.lambdaQuery();
            wrapper2.eq(ManagementGoodsMaterials::getGoodsMaterialsId,slVolumeProductionRk.getMaterialsId());
            wrapper2.eq(ManagementGoodsMaterials::getManagementId,slVolumeProductionRk.getManagementId());
            wrapper2.eq(ManagementGoodsMaterials::getDelFlag, 0);
            ManagementGoodsMaterials managementGoodsMaterials = managementGoodsMaterialsMapper.selectOne(wrapper2);
            if (managementGoodsMaterials!=null){
                managementGoodsMaterials.setRepertoryZhai(page.getSuppliesNum());
                managementGoodsMaterialsMapper.updateById(managementGoodsMaterials);
            }
        }
    }