rentaiming
2024-07-03 2df8a92c7affbb7bf04659cab7d784b57a3e1bf5
ruoyi-modules/ruoyi-management/src/main/java/com/ruoyi/management/service/impl/InventoriesSuppliesInfoServiceImpl.java
@@ -1,9 +1,25 @@
package com.ruoyi.management.service.impl;
import com.ruoyi.management.domain.InventoriesSuppliesInfo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.utils.page.PageDTO;
import com.ruoyi.management.domain.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.management.domain.dto.InventoriesSuppliesInfoDTO;
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.service.InventoriesSuppliesInfoService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashSet;
import java.util.List;
import java.util.ListResourceBundle;
import java.util.Set;
/**
 * <p>
@@ -16,4 +32,91 @@
@Service
public class InventoriesSuppliesInfoServiceImpl extends ServiceImpl<InventoriesSuppliesInfoMapper, InventoriesSuppliesInfo> implements InventoriesSuppliesInfoService {
    @Resource
    private SlVolumeProductionRkMapper slVolumeProductionRkMapper;
    @Resource
    private SlGoodsMaterialsMapper slGoodsMaterialsMapper;
    @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::getDelFlag,0);
        wrapper1.orderByDesc(InventoriesSuppliesInfo::getCreateTime);
        wrapper1.orderByDesc(InventoriesSuppliesInfo::getType);
        Page<InventoriesSuppliesInfo> page2 = this.page(page, wrapper1);
        PageDTO<InventoriesSuppliesInfoVO> slGoodsMaterialsVO = PageDTO.of(page2, InventoriesSuppliesInfoVO.class);
        List<InventoriesSuppliesInfoVO> list = slGoodsMaterialsVO.getList();
        for (InventoriesSuppliesInfoVO sl:list){
            SlVolumeProductionRk slVolumeProductionRk = slVolumeProductionRkMapper.selectById(sl.getRkId());
            sl.setRkNumber(slVolumeProductionRk.getRkNumber());
            sl.setRkModel(slVolumeProductionRk.getRkModel());
            SlGoodsMaterials slGoodsMaterials = slGoodsMaterialsMapper.selectById(slVolumeProductionRk.getMaterialsId());
            sl.setGoodsMaterialsName(slGoodsMaterials.getGoodsMaterialsName());
            sl.setIsConsume(slGoodsMaterials.getIsConsume());
        }
        return slGoodsMaterialsVO;
    }
    @Override
    public void addInventoriesSuppliesInfo(InventoriesSuppliesInfoDTO inventoriesSuppliesInfoDTO) {
        if (inventoriesSuppliesInfoDTO.getId()==0){
            InventoriesSuppliesInfo inventoriesSuppliesInf=new InventoriesSuppliesInfo();
            inventoriesSuppliesInf.setSuppliesId(inventoriesSuppliesInfoDTO.getSuppliesId());
            inventoriesSuppliesInf.setRkId(inventoriesSuppliesInfoDTO.getRkId());
            SlVolumeProductionRk slVolumeProductionRk = slVolumeProductionRkMapper.selectById(inventoriesSuppliesInfoDTO.getRkId());
            inventoriesSuppliesInf.setZkNum(slVolumeProductionRk.getRepertoryZhai());
            inventoriesSuppliesInf.setSuppliesNum(inventoriesSuppliesInfoDTO.getSuppliesNum());
            this.save(inventoriesSuppliesInf);
        }else{
            InventoriesSuppliesInfo byId = this.getById(inventoriesSuppliesInfoDTO.getId());
            byId.setSuppliesNum(inventoriesSuppliesInfoDTO.getSuppliesNum());
            this.updateById(byId);
        }
    }
    @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::getDelFlag,0);
        InventoriesSuppliesInfo page2 = this.getOne(wrapper1);
        return page2;
    }
    @Override
    public void submitInventoriesSuppliesInfo(InventoriesSuppliesInfoDTO inventoriesSuppliesInfoDTO) {
        LambdaQueryWrapper< InventoriesSuppliesInfo> wrapper1= Wrappers.lambdaQuery();
        wrapper1.gt(InventoriesSuppliesInfo::getSuppliesId, inventoriesSuppliesInfoDTO.getSuppliesId());
        wrapper1.eq( InventoriesSuppliesInfo::getDelFlag,0);
        List<InventoriesSuppliesInfo> page2 = this.list(wrapper1);
        for (InventoriesSuppliesInfo page:page2){
            if (page.getZkNum()!=page.getSuppliesNum()){
                page.setType(2);
            }
            this.updateById(page);
        }
    }
    @Override
    public void accomplishInventoriesSuppliesInfo(InventoriesSuppliesInfoDTO inventoriesSuppliesInfoDTO) {
        LambdaQueryWrapper< InventoriesSuppliesInfo> wrapper1= Wrappers.lambdaQuery();
        wrapper1.gt(InventoriesSuppliesInfo::getSuppliesId, inventoriesSuppliesInfoDTO.getSuppliesId());
        wrapper1.gt(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);
        }
    }
}