zhangfeng
2022-12-23 f7d2f20365467a834188edd35c464d9fb9349214
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.gkhy.safePlatform.equipment.service.baseService.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.equipment.entity.MaterialDeliveryRecordDO;
import com.gkhy.safePlatform.equipment.entity.MaterialReceiveRecordsBO;
import com.gkhy.safePlatform.equipment.entity.MaterialReceiveRecordsDO;
import com.gkhy.safePlatform.equipment.entity.MaterialReceiveRecordsInfo;
import com.gkhy.safePlatform.equipment.enums.MaterialRevertStatusEnum;
import com.gkhy.safePlatform.equipment.excepiton.EquipmentException;
import com.gkhy.safePlatform.equipment.repository.MaterialReceiveRecordsInfoRepository;
import com.gkhy.safePlatform.equipment.service.baseService.MaterialReceiveRecordsInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
 
import java.util.List;
 
@Service
public class MaterialReceiveRecordsInfoServiceImpl extends ServiceImpl<MaterialReceiveRecordsInfoRepository, MaterialReceiveRecordsInfo> implements MaterialReceiveRecordsInfoService {
    @Autowired
    private MaterialReceiveRecordsInfoRepository repository;
    @Override
    public MaterialDeliveryRecordDO getRecordBySmdId(Long smdId) {
        if(null == smdId){
            throw new EquipmentException(ResultCodes.CLIENT_PARAM_NULL);
        }
        return repository.getRecordBySmdId(smdId,MaterialRevertStatusEnum.REVERT_NO.getCode());
    }
 
    @Override
    public List<MaterialReceiveRecordsInfo> getNoReturnRecordByReceiveBaseId(Long receiveBaseId) {
        if(null == receiveBaseId){
            throw new EquipmentException(ResultCodes.CLIENT_PARAM_NULL);
        }
        List<MaterialReceiveRecordsInfo> recordsInfos = repository.selectList(new LambdaQueryWrapper<MaterialReceiveRecordsInfo>()
                .eq(MaterialReceiveRecordsInfo::getReceiveBaseId, receiveBaseId)
                .eq(MaterialReceiveRecordsInfo::getRevertStatus, MaterialRevertStatusEnum.REVERT_NO.getCode()));
        return recordsInfos;
    }
 
    @Override
    public List<MaterialReceiveRecordsDO> getNoReturnRecordByIds(List<Long> idList) {
        if (CollectionUtils.isEmpty(idList)) {
            throw new EquipmentException(ResultCodes.CLIENT_PARAM_NULL);
        }
        List<MaterialReceiveRecordsDO> records = repository.getNoReturnRecordByIds(idList, MaterialRevertStatusEnum.REVERT_NO.getCode());
        return records;
    }
 
    @Override
    public List<MaterialReceiveRecordsInfo> listByReceiveBaseIds(List<Long> idList) {
        if (CollectionUtils.isEmpty(idList)) {
            throw new EquipmentException(ResultCodes.CLIENT_PARAM_NULL);
        }
        List<MaterialReceiveRecordsInfo> receiveRecordsInfoList = repository.selectList(new LambdaQueryWrapper<MaterialReceiveRecordsInfo>()
                .in(MaterialReceiveRecordsInfo::getReceiveBaseId, idList));
        return receiveRecordsInfoList;
    }
 
    @Override
    public List<MaterialReceiveRecordsDO> getReceiveRecordsByReceiveUids(MaterialReceiveRecordsBO bo) {
        if (CollectionUtils.isEmpty(bo.getReceiveUids()) || CollectionUtils.isEmpty(bo.getSmallClassifyIds())) {
            throw new EquipmentException(ResultCodes.CLIENT_PARAM_NULL);
        }
        return repository.getReceiveRecordsByReceiveUids(bo);
    }
}