Blame view

src/main/java/com/huaheng/pc/shipment/shippingCombination/service/ShippingCombinationService.java 7.16 KB
pengcheng authored
1
2
3
package com.huaheng.pc.shipment.shippingCombination.service;
4
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
周鸿 authored
5
import com.huaheng.common.utils.Wrappers;
6
7
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.utils.StringUtils;
xumiao authored
8
import com.huaheng.common.utils.security.ShiroUtils;
9
10
11
12
13
14
import com.huaheng.pc.config.FilterConfigDetail.domain.FilterConfigDetail;
import com.huaheng.pc.config.FilterConfigDetail.service.FilterConfigDetailService;
import com.huaheng.pc.config.configValue.domain.ConfigValue;
import com.huaheng.pc.config.configValue.service.ConfigValueService;
import com.huaheng.pc.config.material.domain.Material;
import com.huaheng.pc.config.material.service.MaterialServiceImpl;
15
16
import com.huaheng.pc.config.materialType.domain.MaterialType;
import com.huaheng.pc.config.materialType.service.MaterialTypeService;
17
18
import com.huaheng.pc.config.shipmentPreference.domain.ShipmentPreference;
import com.huaheng.pc.config.shipmentPreference.service.ShipmentPreferenceService;
xqs authored
19
import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
20
21
import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail;
xumiao authored
22
23
import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader;
import com.huaheng.pc.shipment.shipmentHeader.service.ShipmentHeaderService;
xumiao authored
24
import com.huaheng.pc.shipment.shippingCombination.domain.ShippingCombinationDetailModel;
pengcheng authored
25
import com.huaheng.pc.shipment.shippingCombination.mapper.ShippingCombinationMapper;
26
import org.springframework.beans.factory.annotation.Autowired;
pengcheng authored
27
28
import org.springframework.stereotype.Service;
pengcheng authored
29
import javax.annotation.Resource;
30
import java.util.ArrayList;
pengcheng authored
31
32
import java.util.List;
pengcheng authored
33
34
35
36

@Service
public class ShippingCombinationService {
pengcheng authored
37
38
    @Resource
    private ShippingCombinationMapper shippingCombinationMapper;
39
    @Resource
40
    InventoryDetailService inventoryDetailService;
41
    @Resource
42
    ConfigValueService configValueService;
43
    @Resource
44
    FilterConfigDetailService filterConfigDetailService;
45
    @Resource
46
    ShipmentPreferenceService shipmentPreferenceService;
47
    @Resource
48
    MaterialServiceImpl materialService;
49
    @Resource
50
    MaterialTypeService materialTypeService;
xumiao authored
51
52
    @Resource
    private ShipmentHeaderService shipmentHeaderService;
pengcheng authored
53
54
55
56
57

    //根据分配规则查找库存
    public List<InventoryDetail> getInventorys(ShipmentDetail shipmentDetail) {
肖超群 authored
58
59
60
61
62
63
        String warehouseCode = shipmentDetail.getWarehouseCode();
        String companyCode = shipmentDetail.getCompanyCode();
        String materialCode = shipmentDetail.getMaterialCode();
        String inventorySts = shipmentDetail.getInventorySts();
        if(StringUtils.isEmpty(warehouseCode)) {
            throw new ServiceException("出库详情没有仓库编码");
pengcheng authored
64
        }
肖超群 authored
65
66
        if(StringUtils.isEmpty(companyCode)) {
            throw new ServiceException("出库详情没有货主编码");
pengcheng authored
67
        }
肖超群 authored
68
69
        if(StringUtils.isEmpty(materialCode)) {
            throw new ServiceException("出库详情没有物料编码");
70
        }
肖超群 authored
71
72
        if(StringUtils.isEmpty(inventorySts)) {
            throw new ServiceException("出库详情没有物料品质");
73
        }
肖超群 authored
74
75
76
77
        LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper =Wrappers.lambdaQuery();
        inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getWarehouseCode, warehouseCode)
                                        .eq(InventoryDetail::getCompanyCode, companyCode)
                                        .eq(InventoryDetail::getMaterialCode, materialCode)
周鸿 authored
78
79
80
//                                        .eq(InventoryDetail::getBatch, shipmentDetail.getBatch())
                                        .eq(InventoryDetail::getInventorySts, inventorySts);
//                .eq(StringUtils.isNotEmpty(shipmentDetail.getMoCode()),InventoryDetail::getMoCode, shipmentDetail.getMoCode());
81
82
        //昆山手工組盤不限制工作令
        if(StringUtils.isEmpty(shipmentDetail.getMoCode())&&!ShiroUtils.getWarehouseCode().equals("KS0001")){
83
84
            inventoryDetailLambdaQueryWrapper.apply(" (moCode is null or moCode='')");
        }
85
        if(StringUtils.isNotEmpty(shipmentDetail.getMoCode())&&!ShiroUtils.getWarehouseCode().equals("KS0001")){
周鸿 authored
86
            inventoryDetailLambdaQueryWrapper.apply(" (moCode is null or moCode='' or moCode='"+shipmentDetail.getMoCode()+"')");
周鸿 authored
87
        }
88
肖超群 authored
89
90
91
        List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);

        return inventoryDetailList;
pengcheng authored
92
93
    }
xumiao authored
94
    public List<InventoryDetail> getInventoryAutoKS(ShipmentDetail shipmentDetail) {
xumiao authored
95
96
97
98
        ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(new LambdaQueryWrapper<ShipmentHeader>()
                .eq(ShipmentHeader::getCode, shipmentDetail.getShipmentCode())
                .eq(ShipmentHeader::getWarehouseCode,shipmentDetail.getWarehouseCode())
        );
xumiao authored
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
        if(StringUtils.isEmpty(shipmentHeader.getWarehouseCode())) {
            throw new ServiceException("出库详情没有仓库编码");
        }
        if(StringUtils.isEmpty(shipmentHeader.getCompanyCode())) {
            throw new ServiceException("出库详情没有货主编码");
        }
        if(StringUtils.isEmpty(shipmentDetail.getMaterialCode())) {
            throw new ServiceException("出库详情没有物料编码");
        }
        if(StringUtils.isEmpty(shipmentDetail.getInventorySts())) {
            throw new ServiceException("出库详情没有物料品质");
        }
        LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper =Wrappers.lambdaQuery();
        //匹配 warehouseCode、companyCode、uWarehouseCode、MoCode、materialCode、inventorySts
        inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getWarehouseCode, shipmentHeader.getWarehouseCode())
                .eq(InventoryDetail::getCompanyCode, shipmentHeader.getCompanyCode())
                .eq(StringUtils.isNotEmpty(shipmentHeader.getUWarehouseCode()),InventoryDetail::getUWarehouseCode,shipmentHeader.getUWarehouseCode())
116
//                .eq(StringUtils.isNotEmpty(shipmentDetail.getMoCode()),InventoryDetail::getMoCode,shipmentDetail.getMoCode())
xumiao authored
117
118
                .eq(InventoryDetail::getMaterialCode, shipmentDetail.getMaterialCode())
                .eq(InventoryDetail::getInventorySts, shipmentDetail.getInventorySts());
119
        if(StringUtils.isEmpty(shipmentDetail.getMoCode())){
120
121
            inventoryDetailLambdaQueryWrapper.apply(" (moCode is null or moCode='')");
        }
122
        if(StringUtils.isNotEmpty(shipmentDetail.getMoCode())){
123
124
            inventoryDetailLambdaQueryWrapper.apply(" (moCode is null or moCode='' or moCode='"+shipmentDetail.getMoCode()+"')");
        }
125
        inventoryDetailLambdaQueryWrapper.apply(" (uWarehouseCode not in('ksaiersenweId','kshhhanjieweId'))");
xumiao authored
126
127
128
129
        List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
        return inventoryDetailList;
    }
xumiao authored
130
131
132
    public List<ShippingCombinationDetailModel> selectOfView(ShippingCombinationDetailModel shippingCombinationDetailModel) {
        return shippingCombinationMapper.selectOfView(shippingCombinationDetailModel);
    }
pengcheng authored
133
}