xuhy
4 天以前 433bc1e314ecfd483379ca0e2e74e7c815d3261f
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpMaintenanceReminderServiceImpl.java
@@ -1,7 +1,7 @@
package com.ruoyi.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lkl.laop.sdk.LKLSDK;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.mapper.*;
@@ -14,6 +14,8 @@
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@@ -44,15 +46,55 @@
    private TErpSupplierWarehousingBatchMapper erpSupplierWarehousingBatchMapper;
    @Resource
    private TErpClinicWarehousingBatchMapper erpClinicWarehousingBatchMapper;
    @Resource
    private TErpSupplierWarehousingMapper erpSupplierWarehousingMapper;
    @Resource
    private TErpClinicOutboundGoodsMapper erpClinicOutboundGoodsMapper;
    @Resource
    private TErpSupplierOutboundGoodsMapper erpSupplierOutboundGoodsMapper;
    @Resource
    private  TCrmClinicMapper crmClinicMapper;
    @Resource
    private  TCrmSupplierMapper crmSupplierMapper;
    @Override
    public PageInfo<TErpMaintenanceReminderListVo> pageList(TErpMaintenanceReminderQuery query, SysUser user) {
        Integer roleType = user.getRoleType();
        String supplierClinicId = null;
        if(roleType == 4){
            // 供应商
            TCrmSupplier crmSupplier = crmSupplierMapper.selectOne(Wrappers.lambdaQuery(TCrmSupplier.class)
                    .eq(TCrmSupplier::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            supplierClinicId =crmSupplier.getId();
        }
        if(roleType == 5){
            // 诊所
            TCrmClinic crmClinic = crmClinicMapper.selectOne(Wrappers.lambdaQuery(TCrmClinic.class)
                    .eq(TCrmClinic::getUserId, user.getUserId())
                    .last("LIMIT 1"));
            supplierClinicId =crmClinic.getId();
        }
        PageInfo<TErpMaintenanceReminderListVo> page = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<TErpMaintenanceReminderListVo> list = baseMapper.pageList(page, query, user);
        // 获取明天的时间
        LocalDateTime tomorrow = LocalDateTime.now().plusDays(1);
        List<TErpMaintenanceReminderListVo> list=new ArrayList<>();
        if(roleType==4){
           list = baseMapper.pageList(page, query, user,supplierClinicId,tomorrow);
        }else {
           list = baseMapper.pageList1(page, query, user,supplierClinicId,tomorrow);
        }
        if(list.isEmpty()){
            return page;
        }
@@ -80,9 +122,6 @@
        TErpMaintenanceReminderDetailVo tErpMaintenanceReminderDetailVo = new TErpMaintenanceReminderDetailVo();
        TErpMaintenanceReminder tErpMaintenanceReminder = baseMapper.selectById(id);
        if(tErpMaintenanceReminder == null || tErpMaintenanceReminder.getMaintenanceType()!=1 || !tErpMaintenanceReminder.getClinicSupplierId().equals(user.getUserId().toString())){
            return tErpMaintenanceReminderDetailVo;
        }
        tErpMaintenanceReminderDetailVo.setId(tErpMaintenanceReminder.getId());
        tErpMaintenanceReminderDetailVo.setMaintenanceTime(tErpMaintenanceReminder.getMaintenanceTime());
        tErpMaintenanceReminderDetailVo.setMaintenanceRecord(tErpMaintenanceReminder.getMaintenanceRecord());
@@ -94,26 +133,47 @@
        String warehousingBatchId = tErpMaintenanceReminder.getWarehousingBatchId();
        if(warehousingBatchId != null){
            TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch = erpSupplierWarehousingBatchMapper.selectById(warehousingBatchId);
            tErpMaintenanceReminderDetailVo.setBatchNumber(tErpSupplierWarehousingBatch.getBatchNumber());
            TErpSupplierWarehousing tErpSupplierWarehousing = erpSupplierWarehousingMapper.selectById(tErpSupplierWarehousingBatch.getWarehousingId());
            if(tErpSupplierWarehousing!=null){
                String goodsId = tErpSupplierWarehousing.getGoodsId();
                if(goodsId != null){
                    TErpGoods goods = erpGoodsMapper.selectById(goodsId);
                    tErpMaintenanceReminderDetailVo.setGoodsName(goods.getGoodsName());
                    tErpMaintenanceReminderDetailVo.setQuasiNumber(goods.getQuasiNumber());
                    tErpMaintenanceReminderDetailVo.setGoodsIdCode(goods.getGoodsIdCode());
                    String packingUnitId = goods.getPackingUnitId();
                    if(packingUnitId != null){
                        TErpGoodsUnit tErpGoodsUnit = erpGoodsUnitMapper.selectById(packingUnitId);
                        tErpMaintenanceReminderDetailVo.setUnitName(tErpGoodsUnit.getUnitName());
            if(tErpMaintenanceReminder.getMaintenanceType()==2){
                TErpClinicWarehousingBatch tErpSupplierWarehousingBatch = erpClinicWarehousingBatchMapper.selectById(warehousingBatchId);
                tErpMaintenanceReminderDetailVo.setBatchNumber(tErpSupplierWarehousingBatch.getBatchNumber());
                    String goodsId = tErpSupplierWarehousingBatch.getGoodsId();
                    if(goodsId != null){
                        TErpGoods goods = erpGoodsMapper.selectById(goodsId);
                        tErpMaintenanceReminderDetailVo.setGoodsName(goods.getGoodsName());
                        tErpMaintenanceReminderDetailVo.setQuasiNumber(goods.getQuasiNumber());
                        tErpMaintenanceReminderDetailVo.setGoodsIdCode(goods.getGoodsIdCode());
                        String packingUnitId = goods.getPackingUnitId();
                        if(packingUnitId != null){
                            TErpGoodsUnit tErpGoodsUnit = erpGoodsUnitMapper.selectById(packingUnitId);
                            tErpMaintenanceReminderDetailVo.setUnitName(tErpGoodsUnit.getUnitName());
                        }
                    }
                List<TErpClinicOutboundGoods> tErpSupplierOutboundGoods = erpClinicOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpClinicOutboundGoods>().eq(TErpClinicOutboundGoods::getWarehousingBatchId, warehousingBatchId));
                int sum = tErpSupplierOutboundGoods.stream().mapToInt(TErpClinicOutboundGoods::getOutboundCount).sum();
                tErpMaintenanceReminderDetailVo.setNumber(tErpSupplierWarehousingBatch.getWarehousingNumber()-sum);
            }else {
                TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch = erpSupplierWarehousingBatchMapper.selectById(warehousingBatchId);
                tErpMaintenanceReminderDetailVo.setBatchNumber(tErpSupplierWarehousingBatch.getBatchNumber());
                TErpSupplierWarehousing tErpSupplierWarehousing = erpSupplierWarehousingMapper.selectById(tErpSupplierWarehousingBatch.getWarehousingId());
                if(tErpSupplierWarehousing!=null){
                    String goodsId = tErpSupplierWarehousing.getGoodsId();
                    if(goodsId != null){
                        TErpGoods goods = erpGoodsMapper.selectById(goodsId);
                        tErpMaintenanceReminderDetailVo.setGoodsName(goods.getGoodsName());
                        tErpMaintenanceReminderDetailVo.setQuasiNumber(goods.getQuasiNumber());
                        tErpMaintenanceReminderDetailVo.setGoodsIdCode(goods.getGoodsIdCode());
                        String packingUnitId = goods.getPackingUnitId();
                        if(packingUnitId != null){
                            TErpGoodsUnit tErpGoodsUnit = erpGoodsUnitMapper.selectById(packingUnitId);
                            tErpMaintenanceReminderDetailVo.setUnitName(tErpGoodsUnit.getUnitName());
                        }
                    }
                }
                List<TErpSupplierOutboundGoods> tErpSupplierOutboundGoods = erpSupplierOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpSupplierOutboundGoods>().eq(TErpSupplierOutboundGoods::getWarehousingBatchId, warehousingBatchId));
                int sum = tErpSupplierOutboundGoods.stream().mapToInt(TErpSupplierOutboundGoods::getOutboundCount).sum();
                tErpMaintenanceReminderDetailVo.setNumber(tErpSupplierWarehousingBatch.getWarehousingNumber()-sum);
            }
            List<TErpSupplierOutboundGoods> tErpSupplierOutboundGoods = erpSupplierOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpSupplierOutboundGoods>().eq(TErpSupplierOutboundGoods::getWarehousingBatchId, warehousingBatchId));
            int sum = tErpSupplierOutboundGoods.stream().mapToInt(TErpSupplierOutboundGoods::getOutboundCount).sum();
            tErpMaintenanceReminderDetailVo.setNumber(tErpSupplierWarehousingBatch.getWarehousingNumber()-sum);
        }
        return tErpMaintenanceReminderDetailVo;