ShipmentPreferenceServiceImpl.java
5.46 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
package com.huaheng.pc.config.shipmentPreference.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.support.Convert;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.pc.config.configValue.domain.ConfigValue;
import com.huaheng.pc.config.configValue.service.ConfigValueService;
import com.huaheng.pc.config.shipmentPreference.domain.ShipmentPreference;
import com.huaheng.pc.config.shipmentPreference.mapper.ShipmentPreferenceMapper;
import com.huaheng.pc.config.statusFlow.domain.StatusFlowDetail;
import com.huaheng.pc.config.statusFlow.domain.StatusFlowHeader;
import com.huaheng.pc.config.statusFlow.service.StatusFlowDetailService;
import com.huaheng.pc.config.statusFlow.service.StatusFlowHeaderService;
import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader;
import com.huaheng.pc.shipment.shipmentHeader.service.ShipmentHeaderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service("shipmentPreference")
public class ShipmentPreferenceServiceImpl extends ServiceImpl<ShipmentPreferenceMapper, ShipmentPreference> implements ShipmentPreferenceService {
@Autowired
private ShipmentPreferenceService shipmentPreferenceService;
@Autowired
private StatusFlowHeaderService statusFlowHeaderService;
@Autowired
private StatusFlowDetailService statusFlowDetailService;
@Autowired
private ShipmentHeaderService shipmentHeaderService;
@Autowired
private ConfigValueService configValueService;
/**
* 1、找出出库首选项
* 2、查看出库首选项的出库流程
* 3、找到该状态流的出库流程明细
* 4、判断单据是否按出库流程操作
*
* @param ids 出库单id
* @param status 状态流
* @return
*/
@Override
public List<ShipmentHeader> checkShipmentProcess(String ids, Integer status,String code) {
LambdaQueryWrapper<ConfigValue> configValueLambdaQueryWrapper=Wrappers.lambdaQuery();
configValueLambdaQueryWrapper.eq(ConfigValue::getModuleType,"shipment")
.eq(ConfigValue::getWarehouseCode,ShiroUtils.getWarehouseCode());
ConfigValue configValue=configValueService.getOne(configValueLambdaQueryWrapper);
if(configValue==null){
throw new ServiceException("仓库的出库配置不存在");
}
//查找出库首选项
ShipmentPreference shipmentPreference = shipmentPreferenceService.list().get(0);
if(shipmentPreference == null){
throw new ServiceException("系统没有设置出库首选");
}
if(StringUtils.isEmpty(shipmentPreference.getShippingFlow())){
throw new ServiceException("出库首选没有绑定出库流程");
}
//查看出库流程
LambdaQueryWrapper<StatusFlowHeader> statusFlowHeaderLam = Wrappers.lambdaQuery();
statusFlowHeaderLam.eq(StatusFlowHeader::getCode,shipmentPreference.getShippingFlow())
.eq(StatusFlowHeader::getWarehouseCode, ShiroUtils.getWarehouseCode());
StatusFlowHeader statusFlowHeader = statusFlowHeaderService.getOne(statusFlowHeaderLam);
if(statusFlowHeader == null){
throw new ServiceException("出库首选绑定的出库流程不在系统中");
}
//查看流程明细
LambdaQueryWrapper<StatusFlowDetail> statusFlowDetailLamb = Wrappers.lambdaQuery();
statusFlowDetailLamb.eq(StatusFlowDetail::getHeaderId,statusFlowHeader.getId())
.eq(StatusFlowDetail::getWarehouseCode,ShiroUtils.getWarehouseCode())
.eq(StatusFlowDetail::getFlowCode,status.toString());
StatusFlowDetail statusFlowDetail = statusFlowDetailService.getOne(statusFlowDetailLamb);
List<ShipmentHeader> shipmentHeaderList = new ArrayList<>();
if(statusFlowDetail != null && statusFlowDetail.getNessary() == 1) {
if (StringUtils.isNotEmpty(ids)) {
for (Integer id : Convert.toIntArray(ids)) {
//判断单据是否按出库流程操作
ShipmentHeader shipmentHeader = shipmentHeaderService.getById(id);
if (shipmentHeader == null || shipmentHeader.getFirstStatus() < status) {
throw new ServiceException("单据状态不对,此操作不符合出库流程,请按照出库流程出库");
}
shipmentHeaderList.add(shipmentHeader);
}
}
else {
LambdaQueryWrapper<ShipmentHeader> lam = Wrappers.lambdaQuery();
lam.eq(ShipmentHeader::getCode,code)
.eq(ShipmentHeader::getWarehouseCode,ShiroUtils.getWarehouseCode());
ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(lam);
if (shipmentHeader == null || shipmentHeader.getFirstStatus() < status) {
throw new ServiceException("单据状态不对,此操作不符合出库流程,请按照出库流程出库");
}
shipmentHeaderList.add(shipmentHeader);
}
}
return shipmentHeaderList;
}
}