ICSReceiptDetailServiceImpl.java
9.62 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package com.huaheng.pc.u8.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.common.utils.DateUtils;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.Wrappers;
import com.huaheng.pc.config.company.domain.CompanyU8;
import com.huaheng.pc.config.company.service.CompanyU8Service;
import com.huaheng.pc.receipt.receiptDetail.domain.ReceiptDetail;
import com.huaheng.pc.u8.domain.ICSReceiptDetail;
import com.huaheng.pc.u8.domain.ICSReceiptHeader;
import com.huaheng.pc.u8.mapper.ICSReceiptDetailMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 入库下发或回传子单 实现层
*
* @author huaheng
* @date 2019-1-2
*/
@Service
public class ICSReceiptDetailServiceImpl extends ServiceImpl<ICSReceiptDetailMapper,ICSReceiptDetail> implements ICSReceiptDetailService{
@Resource
private CompanyU8Service companyU8Service;
/**
* 根据入库单头rId删除
* @param headerId ICSReceiptHeader rId
* @return
*/
@Override
public boolean removeByHeaderId(Integer headerId) {
List<ICSReceiptDetail> receiptDetails = this.list(new LambdaQueryWrapper<ICSReceiptDetail>()
.eq(ICSReceiptDetail::getHeaderId, headerId));
List<Integer> ids = receiptDetails.stream().map(ICSReceiptDetail::getRid).collect(Collectors.toList());
return this.removeByIds(ids);
}
@Override
public List<ICSReceiptDetail> getDetailsByPI(List<ReceiptDetail> detailList, ICSReceiptHeader header, Map<Integer, BigDecimal> detailsQtyMap) {
List<ICSReceiptDetail> details = new ArrayList<>();
for (ReceiptDetail receiptDetail : detailList) {
BigDecimal totalQty = detailsQtyMap.get(receiptDetail.getId());
if(totalQty==null){
continue;
}
ICSReceiptDetail detail = new ICSReceiptDetail();
detail.setAutoID(receiptDetail.getAutoId());
detail.setCCode(header.getReferCode());
if(!StringUtils.isEmpty(receiptDetail.getBatch())){
detail.setCDefine22(receiptDetail.getBatch());
}
if(!StringUtils.isEmpty(receiptDetail.getMoCode())){
detail.setCDefine22(receiptDetail.getMoCode());
}
detail.setCDefine23(receiptDetail.getLot());
detail.setCComUnitName(receiptDetail.getMaterialUnit());
detail.setCInvCode(receiptDetail.getMaterialCode());
detail.setCInvName(receiptDetail.getMaterialName());
detail.setCInvStd(receiptDetail.getMaterialSpec());
detail.setCWHCode(receiptDetail.getUWarehouseCode());
CompanyU8 companyU8 = companyU8Service.getCompanyU8ByCode(receiptDetail.getCompanyCode(), receiptDetail.getWarehouseCode());
detail.setCompanyCode(companyU8.getUCompanyCode());
detail.setIArrsId(receiptDetail.getAutoId());
detail.setCModifyDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getNowDate()));
detail.setID(receiptDetail.getId());
// detail.setIrowno(Integer.parseInt(receiptDetail.getReferLineNum()));
detail.setIPOsID(receiptDetail.getReferId());
detail.setIQuantity(totalQty);
detail.setPOCode(receiptDetail.getReferCode());
detail.setPOID(header.getReferId());
detail.setPODID(receiptDetail.getReferId());
detail.setCComUnitName(receiptDetail.getMaterialUnit());
details.add(detail);
}
return details;
}
@Override
public List<ICSReceiptDetail> getDetailsByPCI(List<ReceiptDetail> detailList, ICSReceiptHeader header,Map<Integer,BigDecimal> detailsQtyMap) {
return null;
}
@Override
public List<ICSReceiptDetail> getDetailsByCI(List<ReceiptDetail> detailList, ICSReceiptHeader header,Map<Integer,BigDecimal> detailsQtyMap) {
List<ICSReceiptDetail> details = new ArrayList<>();
for (ReceiptDetail receiptDetail : detailList) {
BigDecimal totalQty = detailsQtyMap.get(receiptDetail.getId());
if(totalQty==null){
continue;
}
ICSReceiptDetail detail = new ICSReceiptDetail();
detail.setAutoID(receiptDetail.getAutoId());
detail.setCCode(header.getCCode());
detail.setCComUnitName(receiptDetail.getMaterialUnit());
detail.setCInvCode(receiptDetail.getMaterialCode());
detail.setCInvName(receiptDetail.getMaterialName());
detail.setCInvStd(receiptDetail.getMaterialSpec());
CompanyU8 companyU8 = companyU8Service.getCompanyU8ByCode(receiptDetail.getCompanyCode(), receiptDetail.getWarehouseCode());
detail.setCompanyCode(companyU8.getUCompanyCode());
detail.setCModifyDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getNowDate()));
detail.setID(header.getReferId());
detail.setIQuantity(totalQty.negate());
detail.setMoCode(receiptDetail.getMoCode());
details.add(detail);
}
header.setReferId(null);
header.setReferCode(null);
return details;
}
@Override
public List<ICSReceiptDetail> getDetailsBySRI(List<ReceiptDetail> detailList, ICSReceiptHeader header,Map<Integer,BigDecimal> detailsQtyMap) {
List<ICSReceiptDetail> details = new ArrayList<>();
for (ReceiptDetail receiptDetail : detailList) {
BigDecimal totalQty = detailsQtyMap.get(receiptDetail.getId());
if(totalQty==null){
continue;
}
ICSReceiptDetail detail = new ICSReceiptDetail();
detail.setAutoID(receiptDetail.getReferId());
detail.setCCode(header.getReferCode());
detail.setCComUnitName(receiptDetail.getMaterialUnit());
detail.setCInvCode(receiptDetail.getMaterialCode());
detail.setCInvName(receiptDetail.getMaterialName());
detail.setCInvStd(receiptDetail.getMaterialUnit());
CompanyU8 companyU8 = companyU8Service.getCompanyU8ByCode(receiptDetail.getCompanyCode(), receiptDetail.getWarehouseCode());
detail.setCompanyCode(companyU8.getUCompanyCode());
detail.setCModifyDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,DateUtils.getNowDate()));
detail.setID(receiptDetail.getId());
detail.setIQuantity(totalQty.negate());
detail.setCSOAutoID(receiptDetail.getReferId());
detail.setCSOCode(receiptDetail.getReferCode());
detail.setCSOID(receiptDetail.getSoId());
detail.setCWHCode(receiptDetail.getUWarehouseCode());
detail.setDLID(header.getReferId());
detail.setID(header.getReferId());
details.add(detail);
}
header.setReferId(null);
header.setReferCode(null);
return details;
}
@Override
public List<ICSReceiptDetail> getDetailsBySI(List<ReceiptDetail> detailList, ICSReceiptHeader header, Map<Integer, BigDecimal> detailsQtyMap) {
List<ICSReceiptDetail> details = new ArrayList<>();
for (ReceiptDetail receiptDetail : detailList) {
BigDecimal totalQty = detailsQtyMap.get(receiptDetail.getId());
if(totalQty==null){
continue;
}
ICSReceiptDetail detail = new ICSReceiptDetail();
// icsReceiptDetailA.setiMPoIds(Integer.valueOf(item.getSourceLine()));
detail.setIMPoIds(Integer.valueOf(receiptDetail.getReferLineNum()));
detail.setCDefine22(receiptDetail.getMoCode());
detail.setCInvCode(receiptDetail.getMaterialCode());
detail.setCInvName(receiptDetail.getMaterialName());
detail.setIQuantity(totalQty);
details.add(detail);
}
return details;
}
@Override
public ICSReceiptDetail selectModel(ICSReceiptDetail model){
LambdaQueryWrapper<ICSReceiptDetail> lamb = Wrappers.lambdaQuery();
lamb.eq(StringUtils.isNotEmpty(model.getCCode()),ICSReceiptDetail::getCCode,model.getCCode());
lamb.eq(StringUtils.isNotEmpty(model.getCompanyCode()),ICSReceiptDetail::getCompanyCode,model.getCompanyCode());
lamb.eq(StringUtils.isNotEmpty(model.getCInvCode()),ICSReceiptDetail::getCInvCode,model.getCInvCode());
lamb.eq(StringUtils.isNotNull(model.getITrIds()),ICSReceiptDetail::getITrIds,model.getITrIds());
lamb.eq(StringUtils.isNotNull(model.getAutoID()),ICSReceiptDetail::getAutoID,model.getAutoID());
lamb.last("limit 1");
return this.getOne(lamb);
}
@Override
public List<ICSReceiptDetail> selectModelList(ICSReceiptDetail model){
LambdaQueryWrapper<ICSReceiptDetail> lamb = Wrappers.lambdaQuery();
lamb.eq(StringUtils.isNotEmpty(model.getCCode()),ICSReceiptDetail::getCCode,model.getCCode());
lamb.eq(StringUtils.isNotNull(model.getID()),ICSReceiptDetail::getID,model.getID());
lamb.eq(StringUtils.isNotEmpty(model.getCompanyCode()),ICSReceiptDetail::getCompanyCode,model.getCompanyCode());
lamb.eq(StringUtils.isNotEmpty(model.getCInvCode()),ICSReceiptDetail::getCInvCode,model.getCInvCode());
lamb.eq(StringUtils.isNotNull(model.getITrIds()),ICSReceiptDetail::getITrIds,model.getITrIds());
lamb.eq(StringUtils.isNotNull(model.getAutoID()),ICSReceiptDetail::getAutoID,model.getAutoID());
return this.list(lamb);
}
}