ShippingCombinationService.java
7.16 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package com.huaheng.pc.shipment.shippingCombination.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.huaheng.common.utils.Wrappers;
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.security.ShiroUtils;
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;
import com.huaheng.pc.config.materialType.domain.MaterialType;
import com.huaheng.pc.config.materialType.service.MaterialTypeService;
import com.huaheng.pc.config.shipmentPreference.domain.ShipmentPreference;
import com.huaheng.pc.config.shipmentPreference.service.ShipmentPreferenceService;
import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail;
import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader;
import com.huaheng.pc.shipment.shipmentHeader.service.ShipmentHeaderService;
import com.huaheng.pc.shipment.shippingCombination.domain.ShippingCombinationDetailModel;
import com.huaheng.pc.shipment.shippingCombination.mapper.ShippingCombinationMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Service
public class ShippingCombinationService {
@Resource
private ShippingCombinationMapper shippingCombinationMapper;
@Resource
InventoryDetailService inventoryDetailService;
@Resource
ConfigValueService configValueService;
@Resource
FilterConfigDetailService filterConfigDetailService;
@Resource
ShipmentPreferenceService shipmentPreferenceService;
@Resource
MaterialServiceImpl materialService;
@Resource
MaterialTypeService materialTypeService;
@Resource
private ShipmentHeaderService shipmentHeaderService;
//根据分配规则查找库存
public List<InventoryDetail> getInventorys(ShipmentDetail shipmentDetail) {
String warehouseCode = shipmentDetail.getWarehouseCode();
String companyCode = shipmentDetail.getCompanyCode();
String materialCode = shipmentDetail.getMaterialCode();
String inventorySts = shipmentDetail.getInventorySts();
if(StringUtils.isEmpty(warehouseCode)) {
throw new ServiceException("出库详情没有仓库编码");
}
if(StringUtils.isEmpty(companyCode)) {
throw new ServiceException("出库详情没有货主编码");
}
if(StringUtils.isEmpty(materialCode)) {
throw new ServiceException("出库详情没有物料编码");
}
if(StringUtils.isEmpty(inventorySts)) {
throw new ServiceException("出库详情没有物料品质");
}
LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper =Wrappers.lambdaQuery();
inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getWarehouseCode, warehouseCode)
.eq(InventoryDetail::getCompanyCode, companyCode)
.eq(InventoryDetail::getMaterialCode, materialCode)
// .eq(InventoryDetail::getBatch, shipmentDetail.getBatch())
.eq(InventoryDetail::getInventorySts, inventorySts);
// .eq(StringUtils.isNotEmpty(shipmentDetail.getMoCode()),InventoryDetail::getMoCode, shipmentDetail.getMoCode());
//昆山手工組盤不限制工作令
if(StringUtils.isEmpty(shipmentDetail.getMoCode())&&!ShiroUtils.getWarehouseCode().equals("KS0001")){
inventoryDetailLambdaQueryWrapper.apply(" (moCode is null or moCode='')");
}
if(StringUtils.isNotEmpty(shipmentDetail.getMoCode())&&!ShiroUtils.getWarehouseCode().equals("KS0001")){
inventoryDetailLambdaQueryWrapper.apply(" (moCode is null or moCode='' or moCode='"+shipmentDetail.getMoCode()+"')");
}
List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
return inventoryDetailList;
}
public List<InventoryDetail> getInventoryAutoKS(ShipmentDetail shipmentDetail) {
ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(new LambdaQueryWrapper<ShipmentHeader>()
.eq(ShipmentHeader::getCode, shipmentDetail.getShipmentCode())
.eq(ShipmentHeader::getWarehouseCode,shipmentDetail.getWarehouseCode())
);
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())
// .eq(StringUtils.isNotEmpty(shipmentDetail.getMoCode()),InventoryDetail::getMoCode,shipmentDetail.getMoCode())
.eq(InventoryDetail::getMaterialCode, shipmentDetail.getMaterialCode())
.eq(InventoryDetail::getInventorySts, shipmentDetail.getInventorySts());
if(StringUtils.isEmpty(shipmentDetail.getMoCode())){
inventoryDetailLambdaQueryWrapper.apply(" (moCode is null or moCode='')");
}
if(StringUtils.isNotEmpty(shipmentDetail.getMoCode())){
inventoryDetailLambdaQueryWrapper.apply(" (moCode is null or moCode='' or moCode='"+shipmentDetail.getMoCode()+"')");
}
inventoryDetailLambdaQueryWrapper.apply(" (uWarehouseCode not in('ksaiersenweId','kshhhanjieweId'))");
List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
return inventoryDetailList;
}
public List<ShippingCombinationDetailModel> selectOfView(ShippingCombinationDetailModel shippingCombinationDetailModel) {
return shippingCombinationMapper.selectOfView(shippingCombinationDetailModel);
}
}