xuhy
7 天以前 61ba04eb1338b3c25d50e1eff336433d82e1d1fe
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpSupplierWarehousingServiceImpl.java
@@ -3,21 +3,24 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.dto.WarehousingGoodsDto;
import com.ruoyi.system.dto.WarehousingGoodsNextDto;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.model.*;
import com.ruoyi.system.query.TErpGoodsQuery;
import com.ruoyi.system.query.TErpGoodsWarehouseQuery;
import com.ruoyi.system.query.ValidityPeriodWarningQuery;
import com.ruoyi.system.service.TErpSupplierWarehousingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.vo.TErpGoodsVO;
import com.ruoyi.system.vo.TErpGoodsWarehouseLastVO;
import com.ruoyi.system.vo.TErpGoodsWarehouseRecordLastVO;
import com.ruoyi.system.vo.TErpGoodsWarehouseVO;
import com.ruoyi.system.vo.*;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -52,6 +55,9 @@
    @Resource
    private TCrmWarehouseMapper crmWarehouseMapper;
    @Resource
    private TErpMaintenanceReminderMapper tErpMaintenanceReminderMapper;
    @Override
@@ -182,4 +188,58 @@
        pageInfo.setRecords( list);
        return pageInfo;
    }
    @Override
    public void warehousingGoods(List<WarehousingGoodsDto> dtos, SysUser user) {
        for (WarehousingGoodsDto dto : dtos) {
            TErpSupplierWarehousing tErpSupplierWarehousing = new TErpSupplierWarehousing();
            // 当前年月日时分秒
            String time = DateUtils.dateTimeNow();
            tErpSupplierWarehousing.setWarehousingNo("G"+time);
            tErpSupplierWarehousing.setSupplierId(user.getUserId().toString());
            tErpSupplierWarehousing.setWarehouseId(dto.getWarehouseId());
            tErpSupplierWarehousing.setGoodsId(dto.getGoodsId());
            TErpGoods goods = erpGoodsMapper.selectById(dto.getGoodsId());
            tErpSupplierWarehousing.setGoodsName(goods.getGoodsName());
            tErpSupplierWarehousing.setGoodsCount(tErpSupplierWarehousing.getGoodsCount());
            tErpSupplierWarehousing.setUnitAmount(tErpSupplierWarehousing.getUnitAmount());
            tErpSupplierWarehousing.setTotalPrice(tErpSupplierWarehousing.getTotalPrice());
            erpSupplierWarehousingMapper.insert(tErpSupplierWarehousing);
            List<WarehousingGoodsNextDto> warehousingGoodsNextDtos = dto.getWarehousingGoodsNextDtos();
            for (WarehousingGoodsNextDto warehousingGoodsNextDto : warehousingGoodsNextDtos) {
                TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch = new TErpSupplierWarehousingBatch();
                tErpSupplierWarehousingBatch.setWarehousingId(tErpSupplierWarehousing.getId());
                tErpSupplierWarehousingBatch.setWarehousingNumber(warehousingGoodsNextDto.getWarehousingNum());
                tErpSupplierWarehousingBatch.setBatchNumber(warehousingGoodsNextDto.getBatchNumber());
                tErpSupplierWarehousingBatch.setProductionDate(warehousingGoodsNextDto.getProductionDate().atStartOfDay());
                tErpSupplierWarehousingBatch.setExpiryDate(warehousingGoodsNextDto.getExpiryDate().atStartOfDay());
                erpSupplierWarehousingBatchMapper.insert(tErpSupplierWarehousingBatch);
                if(goods.getMaintenanceInterval()!=null){
                    TErpMaintenanceReminder tErpMaintenanceReminder = new TErpMaintenanceReminder();
                    tErpMaintenanceReminder.setClinicSupplierId(user.getUserId().toString());
                    tErpMaintenanceReminder.setMaintenanceType(1);
                    tErpMaintenanceReminder.setWarehousingBatchId(tErpSupplierWarehousingBatch.getId());
                    Integer day = Integer.valueOf(goods.getMaintenanceInterval());
                    // 当前时间+day天
                    LocalDateTime time1 = LocalDateTime.now().plusDays(day);
                    tErpMaintenanceReminder.setMaintenanceTime(time1);
                    tErpMaintenanceReminderMapper.insert(tErpMaintenanceReminder);
                }
            }
        }
    }
    @Override
    public PageInfo<ValidityPeriodWarningVo> validityPeriodWarning(ValidityPeriodWarningQuery query, SysUser user) {
        // 获取当前时间后9个月的时间
        LocalDateTime nineMonthLater = LocalDateTime.now().plusMonths(9);
        PageInfo<ValidityPeriodWarningVo> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        return this.baseMapper.validityPeriodWarning(pageInfo,query,user,nineMonthLater);
    }
}