Commit 8eb844943f33c32cbe37b1928be3889eef361dad
1 parent
35d24c80
事务回滚
Showing
5 changed files
with
273 additions
and
239 deletions
src/main/java/com/huaheng/pc/receipt/receiptContainerDetail/service/ReceiptContainerDetailServiceImpl.java
... | ... | @@ -20,6 +20,7 @@ import com.huaheng.pc.receipt.receiptDetail.service.ReceiptDetailService; |
20 | 20 | import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader; |
21 | 21 | import com.huaheng.pc.receipt.receiptHeader.service.ReceiptHeaderService; |
22 | 22 | import org.springframework.stereotype.Service; |
23 | +import org.springframework.transaction.annotation.Transactional; | |
23 | 24 | |
24 | 25 | import javax.annotation.Resource; |
25 | 26 | import java.util.ArrayList; |
... | ... | @@ -27,7 +28,7 @@ import java.util.List; |
27 | 28 | import java.util.Map; |
28 | 29 | |
29 | 30 | @Service |
30 | -public class ReceiptContainerDetailServiceImpl extends ServiceImpl<ReceiptContainerDetailMapper, ReceiptContainerDetail> implements ReceiptContainerDetailService{ | |
31 | +public class ReceiptContainerDetailServiceImpl extends ServiceImpl<ReceiptContainerDetailMapper, ReceiptContainerDetail> implements ReceiptContainerDetailService { | |
31 | 32 | |
32 | 33 | @Resource |
33 | 34 | private ReceiptDetailService receiptDetailService; |
... | ... | @@ -39,8 +40,10 @@ public class ReceiptContainerDetailServiceImpl extends ServiceImpl<ReceiptContai |
39 | 40 | private MaterialService materialService; |
40 | 41 | @Resource |
41 | 42 | private LocationService locationService; |
43 | + | |
42 | 44 | /** |
43 | 45 | * 根据入库单编码查询入库组盘明细 |
46 | + * | |
44 | 47 | * @param receiptCode 入库单编码 |
45 | 48 | * @return AjaxResult |
46 | 49 | */ |
... | ... | @@ -56,15 +59,16 @@ public class ReceiptContainerDetailServiceImpl extends ServiceImpl<ReceiptContai |
56 | 59 | |
57 | 60 | /** |
58 | 61 | * 撤销入库组盘明细 |
62 | + * | |
59 | 63 | * @param idList |
60 | 64 | * @return |
61 | 65 | */ |
62 | 66 | @Override |
63 | 67 | public Boolean detailRemove(List<Integer> idList) { |
64 | - for (Integer id : idList){ | |
68 | + for (Integer id : idList) { | |
65 | 69 | ReceiptContainerDetail receiptContainerDetail = this.getById(id); |
66 | 70 | //如果已生成任务不允许撤销 |
67 | - if (receiptContainerDetail.getStatus() < QuantityConstant.RECEIPT_CONTAINER_TASK){ | |
71 | + if (receiptContainerDetail.getStatus() < QuantityConstant.RECEIPT_CONTAINER_TASK) { | |
68 | 72 | //回滚入库单明细收货数量 |
69 | 73 | ReceiptDetail receiptDetail = receiptDetailService.getById(receiptContainerDetail.getReceiptDetailId()); |
70 | 74 | receiptDetail.setTaskQty(receiptDetail.getTaskQty().subtract(receiptContainerDetail.getQty())); |
... | ... | @@ -72,18 +76,22 @@ public class ReceiptContainerDetailServiceImpl extends ServiceImpl<ReceiptContai |
72 | 76 | //如果为临时容器,则删除 |
73 | 77 | receiptContainerDetail.getContainerCode(); |
74 | 78 | |
75 | - if (!receiptDetailService.updateById(receiptDetail)){throw new SecurityException("回滚入库单明细失败");} | |
79 | + if (!receiptDetailService.updateById(receiptDetail)) { | |
80 | + throw new SecurityException("回滚入库单明细失败"); | |
81 | + } | |
76 | 82 | //删除组盘明细 |
77 | - if (!this.removeById(id)){ throw new ServiceException("回滚入库组盘失败");} | |
83 | + if (!this.removeById(id)) { | |
84 | + throw new ServiceException("回滚入库组盘失败"); | |
85 | + } | |
78 | 86 | LambdaQueryWrapper<ReceiptContainerDetail> lambdaQueryWrapper = Wrappers.lambdaQuery(); |
79 | 87 | lambdaQueryWrapper.eq(ReceiptContainerDetail::getReceiptContainerId, receiptContainerDetail.getReceiptContainerId()); |
80 | 88 | List<ReceiptContainerDetail> list = this.list(lambdaQueryWrapper); |
81 | - if (list.size() == 0){ | |
89 | + if (list.size() == 0) { | |
82 | 90 | String locationCode = receiptContainerDetail.getLocationCode(); |
83 | - if(StringUtils.isNotEmpty(locationCode)) { | |
91 | + if (StringUtils.isNotEmpty(locationCode)) { | |
84 | 92 | locationService.updateStatus(locationCode, QuantityConstant.STATUS_LOCATION_EMPTY); |
85 | 93 | } |
86 | - if (!receiptContainerHeaderService.removeById(receiptContainerDetail.getReceiptContainerId())){ | |
94 | + if (!receiptContainerHeaderService.removeById(receiptContainerDetail.getReceiptContainerId())) { | |
87 | 95 | throw new ServiceException("删除入库组盘头失败"); |
88 | 96 | } |
89 | 97 | } |
... | ... | @@ -95,14 +103,16 @@ public class ReceiptContainerDetailServiceImpl extends ServiceImpl<ReceiptContai |
95 | 103 | |
96 | 104 | |
97 | 105 | //如果入库组盘没有该入库单的组盘信息,回滚入库单状态 |
98 | - if (containerDetailList.size() == 0){ | |
106 | + if (containerDetailList.size() == 0) { | |
99 | 107 | ReceiptHeader receiptHeader = new ReceiptHeader(); |
100 | 108 | receiptHeader.setId(receiptContainerDetail.getReceiptId()); |
101 | 109 | receiptHeader.setFirstStatus(QuantityConstant.RECEIPT_HEADER_RECEIVING); |
102 | 110 | receiptHeader.setLastStatus(QuantityConstant.RECEIPT_HEADER_RECEIVING); |
103 | 111 | receiptHeader.setLastUpdatedBy(ShiroUtils.getName()); |
104 | 112 | |
105 | - if (!receiptHeaderService.updateById(receiptHeader)){ throw new ServiceException("回滚头表状态失败"); } | |
113 | + if (!receiptHeaderService.updateById(receiptHeader)) { | |
114 | + throw new ServiceException("回滚头表状态失败"); | |
115 | + } | |
106 | 116 | } |
107 | 117 | |
108 | 118 | } else { |
... | ... | @@ -127,16 +137,19 @@ public class ReceiptContainerDetailServiceImpl extends ServiceImpl<ReceiptContai |
127 | 137 | // return AjaxResult.success(receiptContainerDetails); |
128 | 138 | // } |
129 | 139 | |
130 | - /**保存到组盘详细*/ | |
140 | + /** | |
141 | + * 保存到组盘详细 | |
142 | + */ | |
143 | + @Transactional(rollbackFor = Exception.class) | |
131 | 144 | @Override |
132 | 145 | public List<Integer> insertTodayReceiptcContainerDetail(int headerId, int receiptId, List<Integer> receiptDetailId, List<ReceiptBill> receiptBills) { |
133 | 146 | List<Integer> mReceiptContainerIds = new ArrayList<>(); |
134 | 147 | |
135 | 148 | ReceiptHeader receiptHeader = receiptHeaderService.getById(receiptId); |
136 | - if(receiptHeader == null) { | |
149 | + if (receiptHeader == null) { | |
137 | 150 | throw new ServiceException("没有找到入库单表头!"); |
138 | 151 | } |
139 | - for(int i=0; i<receiptBills.size(); i++) { | |
152 | + for (int i = 0; i < receiptBills.size(); i++) { | |
140 | 153 | ReceiptBill receiptBill = receiptBills.get(i); |
141 | 154 | Material condition2 = new Material(); |
142 | 155 | condition2.setCode(receiptBill.getMaterialCode()); |
... | ... | @@ -158,7 +171,7 @@ public class ReceiptContainerDetailServiceImpl extends ServiceImpl<ReceiptContai |
158 | 171 | record.setInventorySts("good"); |
159 | 172 | record.setQty(receiptBill.getQty()); |
160 | 173 | record.setContainerCode(receiptBills.get(0).getReceiptContainerCode()); |
161 | - if(receiptBill.getWeight() != null) { | |
174 | + if (receiptBill.getWeight() != null) { | |
162 | 175 | record.setWeight(receiptBill.getWeight()); |
163 | 176 | } |
164 | 177 | record.setCreatedBy(ShiroUtils.getName()); |
... | ... | @@ -168,7 +181,7 @@ public class ReceiptContainerDetailServiceImpl extends ServiceImpl<ReceiptContai |
168 | 181 | detailyWrapper.eq(ReceiptContainerDetail::getReceiptContainerId, headerId) |
169 | 182 | .eq(ReceiptContainerDetail::getReceiptCode, receiptHeader.getCode()); |
170 | 183 | ReceiptContainerDetail receiptContainerDetail = getOne(detailyWrapper); |
171 | - if(receiptContainerDetail == null) { | |
184 | + if (receiptContainerDetail == null) { | |
172 | 185 | save(record); |
173 | 186 | mReceiptContainerIds.add(record.getId()); |
174 | 187 | } else { |
... | ... |
src/main/java/com/huaheng/pc/receipt/receiptContainerHeader/service/ReceiptContainerHeaderServiceImpl.java
... | ... | @@ -44,9 +44,11 @@ import java.text.MessageFormat; |
44 | 44 | import java.util.Calendar; |
45 | 45 | import java.util.Date; |
46 | 46 | import java.util.List; |
47 | -@Service | |
48 | -public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContainerHeaderMapper, ReceiptContainerHeader> implements ReceiptContainerHeaderService{ | |
49 | 47 | |
48 | +@Service | |
49 | +public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContainerHeaderMapper, ReceiptContainerHeader> implements ReceiptContainerHeaderService { | |
50 | + @Resource | |
51 | + private ReceiptContainerHeaderService receiptContainerHeaderService; | |
50 | 52 | @Resource |
51 | 53 | private TaskHeaderService taskHeaderService; |
52 | 54 | @Resource |
... | ... | @@ -74,22 +76,23 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
74 | 76 | |
75 | 77 | /** |
76 | 78 | * 保存入库组盘 |
77 | - * @param receiptCode 入库单编码 | |
78 | - * @param containerCode 容器编码 | |
79 | + * | |
80 | + * @param receiptCode 入库单编码 | |
81 | + * @param containerCode 容器编码 | |
79 | 82 | * @param receiptDetailId 入库单详情id |
80 | - * @param locationCode 库位编码 | |
81 | - * @param qty 收货数量 | |
82 | - * @param locatingRule 定位规则 | |
83 | + * @param locationCode 库位编码 | |
84 | + * @param qty 收货数量 | |
85 | + * @param locatingRule 定位规则 | |
83 | 86 | * @return 是否保存成功 |
84 | 87 | */ |
85 | 88 | @Override |
86 | - @Transactional | |
89 | + @Transactional(rollbackFor = Exception.class) | |
87 | 90 | public AjaxResult saveContainer(String receiptCode, String containerCode, Integer receiptDetailId, |
88 | - String locationCode, BigDecimal qty, String locatingRule) { | |
91 | + String locationCode, BigDecimal qty, String locatingRule) { | |
89 | 92 | ReceiptDetail detail = receiptDetailService.getById(receiptDetailId); |
90 | - AjaxResult ajaxResult=new AjaxResult(); | |
93 | + AjaxResult ajaxResult = new AjaxResult(); | |
91 | 94 | BigDecimal receiptQty = detail.getQty().subtract(detail.getTaskQty()); |
92 | - if(receiptQty.compareTo(qty) < 0) { | |
95 | + if (receiptQty.compareTo(qty) < 0) { | |
93 | 96 | return AjaxResult.error("不允许超收"); |
94 | 97 | } |
95 | 98 | |
... | ... | @@ -103,12 +106,14 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
103 | 106 | } else if (taskType == 2) { |
104 | 107 | throw new ServiceException("该物料不能放在这个容器上,请检查该物料是否可以混放"); |
105 | 108 | } else { |
106 | - if (taskType == 0){ throw new ServiceException("容器状态未知"); } | |
109 | + if (taskType == 0) { | |
110 | + throw new ServiceException("容器状态未知"); | |
111 | + } | |
107 | 112 | } |
108 | 113 | //判断该物料是用大托盘还是小托盘 |
109 | - Material material=materialService.getMaterialByCode(detail.getMaterialCode()); | |
114 | + Material material = materialService.getMaterialByCode(detail.getMaterialCode()); | |
110 | 115 | Container container = containerService.getContainerByCode(containerCode); |
111 | - if(material!=null){ | |
116 | + if (material != null) { | |
112 | 117 | /* |
113 | 118 | if (material.getIsHigh()!=null&&material.getIsHigh()==1){//只能用高托盘 |
114 | 119 | if (container.getContainerType().equals("S")){ |
... | ... | @@ -131,19 +136,19 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
131 | 136 | checkLocationCode(locationCode, containerCode, taskType); |
132 | 137 | |
133 | 138 | int unCompleteCombineNumber = shipmentContainerHeaderService.getUnCompleteCombineNumber(containerCode); |
134 | - if(unCompleteCombineNumber > 0) { | |
139 | + if (unCompleteCombineNumber > 0) { | |
135 | 140 | throw new ServiceException("该托盘已经用于出库组盘"); |
136 | 141 | } |
137 | 142 | /* 新建保存组盘头表记录*/ |
138 | 143 | //根据容器编码查询组盘表头记录 |
139 | 144 | LambdaQueryWrapper<ReceiptContainerHeader> lambda = Wrappers.lambdaQuery(); |
140 | 145 | lambda.eq(ReceiptContainerHeader::getContainerCode, containerCode) |
141 | - .eq(ReceiptContainerHeader::getStatus, QuantityConstant.RECEIPT_CONTAINER_BUILD); | |
146 | + .eq(ReceiptContainerHeader::getStatus, QuantityConstant.RECEIPT_CONTAINER_BUILD); | |
142 | 147 | List<ReceiptContainerHeader> list = this.list(lambda); |
143 | 148 | |
144 | 149 | ReceiptContainerHeader receiptContainerHeader = new ReceiptContainerHeader(); |
145 | 150 | //当size大于等于1表示容器已经有组盘了 |
146 | - if (list.size() < 1){ | |
151 | + if (list.size() < 1) { | |
147 | 152 | ReceiptDetail receiptDetail = receiptDetailService.getById(receiptDetailId); |
148 | 153 | receiptContainerHeader.setWarehouseCode(ShiroUtils.getWarehouseCode()); |
149 | 154 | receiptContainerHeader.setCompanyCode(receiptDetail.getCompanyCode()); |
... | ... | @@ -165,12 +170,12 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
165 | 170 | receiptContainerHeader.setLastUpdatedBy(ShiroUtils.getName()); |
166 | 171 | receiptContainerHeader.setLocatingRule(locatingRule); |
167 | 172 | receiptContainerHeader.setCreatedBy("test"); |
168 | - if (!this.save(receiptContainerHeader)){ | |
173 | + if (!this.save(receiptContainerHeader)) { | |
169 | 174 | throw new ServiceException("入库组盘头表保存失败"); |
170 | 175 | } |
171 | 176 | } else { |
172 | 177 | receiptContainerHeader = list.get(0); |
173 | - if (receiptContainerHeader.getStatus() >= QuantityConstant.RECEIPT_CONTAINER_TASK && receiptContainerHeader.getStatus() < QuantityConstant.RECEIPT_CONTAINER_FINISHED){ | |
178 | + if (receiptContainerHeader.getStatus() >= QuantityConstant.RECEIPT_CONTAINER_TASK && receiptContainerHeader.getStatus() < QuantityConstant.RECEIPT_CONTAINER_FINISHED) { | |
174 | 179 | throw new ServiceException("容器已经生成任务,不能放物料了!"); |
175 | 180 | } |
176 | 181 | } |
... | ... | @@ -181,7 +186,7 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
181 | 186 | receiptDetail.setId(receiptDetailId); |
182 | 187 | receiptDetail.setTaskQty(qty.add(receiptDetail.getTaskQty())); |
183 | 188 | //更新入库单详情的收货数量 |
184 | - if (!receiptDetailService.updateById(receiptDetail)){ | |
189 | + if (!receiptDetailService.updateById(receiptDetail)) { | |
185 | 190 | throw new ServiceException("更新入库单详情失败"); |
186 | 191 | } |
187 | 192 | |
... | ... | @@ -189,24 +194,24 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
189 | 194 | |
190 | 195 | receiptContainerDetailAdd(receiptContainerHeaders.get(0), receiptDetail, qty, containerCode, locationCode); |
191 | 196 | //如果单据数量等于已收数量,更新入库详情状态和入库单状态 |
192 | - if (receiptDetail.getQty().compareTo(receiptDetail.getTaskQty()) == 0){ | |
193 | - if (StringUtils.isNotEmpty(locationCode)){ | |
197 | + if (receiptDetail.getQty().compareTo(receiptDetail.getTaskQty()) == 0) { | |
198 | + if (StringUtils.isNotEmpty(locationCode)) { | |
194 | 199 | receiptDetail.setProcessStamp(QuantityConstant.RECEIPT_HEADER_POSITION.toString()); |
195 | 200 | } else { |
196 | 201 | receiptDetail.setProcessStamp(QuantityConstant.RECEIPT_HEADER_RECEIVING.toString()); |
197 | 202 | } |
198 | - if (!receiptDetailService.updateById(receiptDetail)){ | |
203 | + if (!receiptDetailService.updateById(receiptDetail)) { | |
199 | 204 | throw new ServiceException("更新入库详情处理标记失败"); |
200 | 205 | } |
201 | 206 | |
202 | 207 | ReceiptDetail receiptDetail1 = receiptDetailService.queryflow(receiptDetail); |
203 | - if (!receiptDetailService.updateById(receiptDetail1)){ | |
208 | + if (!receiptDetailService.updateById(receiptDetail1)) { | |
204 | 209 | throw new ServiceException("更新入库详情下一流程失败"); |
205 | 210 | } |
206 | 211 | } |
207 | 212 | receiptDetailService.updateReceiptHeaderLastStatus(receiptDetail.getReceiptId()); |
208 | - JSONObject json=new JSONObject(); | |
209 | - json.put("id",receiptContainerHeader.getId()); | |
213 | + JSONObject json = new JSONObject(); | |
214 | + json.put("id", receiptContainerHeader.getId()); | |
210 | 215 | ajaxResult.setData(json); |
211 | 216 | ajaxResult.setMsg("组盘成功"); |
212 | 217 | ajaxResult.setCode(200); |
... | ... | @@ -215,19 +220,20 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
215 | 220 | |
216 | 221 | /** |
217 | 222 | * 超收检查 |
223 | + * | |
218 | 224 | * @param detail |
219 | 225 | * @param qty |
220 | 226 | */ |
221 | - private void checkOverReceiving(ReceiptDetail detail, BigDecimal qty){ | |
227 | + private void checkOverReceiving(ReceiptDetail detail, BigDecimal qty) { | |
222 | 228 | BigDecimal _total = detail.getTaskQty().add(qty); |
223 | - if(_total.compareTo(detail.getQty()) <= 0){ | |
229 | + if (_total.compareTo(detail.getQty()) <= 0) { | |
224 | 230 | //收货量<=明细总量 |
225 | 231 | return; |
226 | 232 | } |
227 | 233 | |
228 | 234 | ConfigValue configValue = configValueMapper.getConfigValue(ShiroUtils.getWarehouseCode(), "receipt"); |
229 | - ReceiptPreference preference = receiptPreferenceMapper.getReceiptPreference(ShiroUtils.getWarehouseCode(),configValue.getValue()); | |
230 | - if(!preference.getAllowOverReceiving()){ | |
235 | + ReceiptPreference preference = receiptPreferenceMapper.getReceiptPreference(ShiroUtils.getWarehouseCode(), configValue.getValue()); | |
236 | + if (!preference.getAllowOverReceiving()) { | |
231 | 237 | //入库首选项配置为不允许超收 |
232 | 238 | throw new ServiceException(String.format("不允许超收")); |
233 | 239 | } |
... | ... | @@ -235,19 +241,20 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
235 | 241 | //超收比例 |
236 | 242 | BigDecimal _over_rate = new BigDecimal(String.valueOf(1 + preference.getAllowOverReceivingQty() / 100.0)); |
237 | 243 | //超收量上限 |
238 | - BigDecimal _total_over = detail.getQty().multiply (_over_rate); | |
239 | - if(_total_over.compareTo(_total) >= 0){ | |
244 | + BigDecimal _total_over = detail.getQty().multiply(_over_rate); | |
245 | + if (_total_over.compareTo(_total) >= 0) { | |
240 | 246 | //在入库首选项的超收范围内 |
241 | 247 | return; |
242 | 248 | } |
243 | 249 | |
244 | 250 | //超过了入库首选项配置的超收比例 |
245 | 251 | throw new ServiceException(String.format("超收上限是: %s%", |
246 | - _over_rate.multiply(new BigDecimal(100)) )); | |
252 | + _over_rate.multiply(new BigDecimal(100)))); | |
247 | 253 | } |
248 | 254 | |
249 | 255 | /** |
250 | 256 | * 批量撤销入库组盘 |
257 | + * | |
251 | 258 | * @param ids 容器头表标识列表 |
252 | 259 | * @return true 全部取消成功 |
253 | 260 | */ |
... | ... | @@ -256,17 +263,19 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
256 | 263 | public Boolean cancelByIds(List<Integer> ids) { |
257 | 264 | for (Integer id : ids) { |
258 | 265 | //如果已生成任务则不允许取消组盘 |
259 | - if (this.getById(id).getStatus() < QuantityConstant.RECEIPT_CONTAINER_TASK){ | |
266 | + if (this.getById(id).getStatus() < QuantityConstant.RECEIPT_CONTAINER_TASK) { | |
260 | 267 | //根据组盘头表id查询组盘明细表 |
261 | 268 | LambdaQueryWrapper<ReceiptContainerDetail> containerDetailLambda = Wrappers.lambdaQuery(); |
262 | 269 | containerDetailLambda.eq(ReceiptContainerDetail::getReceiptContainerId, id); |
263 | 270 | List<ReceiptContainerDetail> receiptContainerDetails = receiptContainerDetailService.list(containerDetailLambda); |
264 | 271 | |
265 | 272 | //查询入库单明细,减去已收数量,更新单据 |
266 | - for (ReceiptContainerDetail receiptContainerDetail: receiptContainerDetails){ | |
273 | + for (ReceiptContainerDetail receiptContainerDetail : receiptContainerDetails) { | |
267 | 274 | ReceiptDetail receiptDetail = receiptDetailService.getById(receiptContainerDetail.getReceiptDetailId()); |
268 | 275 | receiptDetail.setTaskQty(receiptDetail.getTaskQty().subtract(receiptContainerDetail.getQty())); |
269 | - if (!receiptDetailService.updateById(receiptDetail)){throw new ServiceException("回滚入库明细失败"); } | |
276 | + if (!receiptDetailService.updateById(receiptDetail)) { | |
277 | + throw new ServiceException("回滚入库明细失败"); | |
278 | + } | |
270 | 279 | |
271 | 280 | containerDetailLambda = Wrappers.lambdaQuery(); |
272 | 281 | containerDetailLambda.eq(ReceiptContainerDetail::getReceiptId, receiptContainerDetail.getReceiptId()); |
... | ... | @@ -276,22 +285,24 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
276 | 285 | containerService.removeContainer(receiptContainerDetail.getContainerType(), receiptContainerDetail.getContainerCode()); |
277 | 286 | |
278 | 287 | //如果入库组盘没有该入库单的组盘信息,回滚入库单状态 |
279 | - if (containerDetailList == null){ | |
288 | + if (containerDetailList == null) { | |
280 | 289 | ReceiptHeader receiptHeader = new ReceiptHeader(); |
281 | 290 | receiptHeader.setId(receiptContainerDetail.getReceiptId()); |
282 | 291 | receiptHeader.setFirstStatus(QuantityConstant.RECEIPT_HEADER_RECEIVING); |
283 | 292 | receiptHeader.setLastStatus(QuantityConstant.RECEIPT_HEADER_RECEIVING); |
284 | 293 | receiptHeader.setLastUpdatedBy(ShiroUtils.getName()); |
285 | 294 | |
286 | - if (!receiptHeaderService.updateById(receiptHeader)){ throw new ServiceException("回滚头表状态失败"); } | |
295 | + if (!receiptHeaderService.updateById(receiptHeader)) { | |
296 | + throw new ServiceException("回滚头表状态失败"); | |
297 | + } | |
287 | 298 | } |
288 | 299 | |
289 | - if (!receiptContainerDetailService.removeById(receiptContainerDetail.getId())){ | |
290 | - throw new ServiceException("删除入库组盘明细表失败,id是"+receiptContainerDetail.getId()); | |
300 | + if (!receiptContainerDetailService.removeById(receiptContainerDetail.getId())) { | |
301 | + throw new ServiceException("删除入库组盘明细表失败,id是" + receiptContainerDetail.getId()); | |
291 | 302 | } |
292 | 303 | } |
293 | 304 | //删除入库组盘头表 |
294 | - if (!this.removeById(id)){ | |
305 | + if (!this.removeById(id)) { | |
295 | 306 | throw new ServiceException("删除入库组盘头表失败"); |
296 | 307 | } |
297 | 308 | } else { |
... | ... | @@ -331,7 +342,7 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
331 | 342 | |
332 | 343 | AjaxResult ajaxResult = null; |
333 | 344 | for (ReceiptContainerView receiptContainerView : list) { |
334 | - ajaxResult = saveContainer(receiptContainerView.getReceiptCode(), receiptContainerView.getReceiptContainerCode(), | |
345 | + ajaxResult = saveContainer(receiptContainerView.getReceiptCode(), receiptContainerView.getReceiptContainerCode(), | |
335 | 346 | receiptContainerView.getReceiptDetailId(), receiptContainerView.getLocationCode(), receiptContainerView.getQty(), null); |
336 | 347 | } |
337 | 348 | return ajaxResult; |
... | ... | @@ -339,6 +350,7 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
339 | 350 | |
340 | 351 | /** |
341 | 352 | * 移动端校验库位 |
353 | + * | |
342 | 354 | * @param record |
343 | 355 | * @return |
344 | 356 | */ |
... | ... | @@ -349,23 +361,24 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
349 | 361 | |
350 | 362 | /** |
351 | 363 | * 检查容器编码合法性 |
364 | + * | |
352 | 365 | * @param containerCode 容器编码 |
353 | - * @param materialCode 物料编码 | |
366 | + * @param materialCode 物料编码 | |
354 | 367 | * @return 返回容器状态,如果需自动生成容器编码返回1 |
355 | 368 | */ |
356 | 369 | @Transactional |
357 | 370 | public Integer checkContainer(String containerCode, String materialCode) { |
358 | 371 | Material material = materialService.getMaterialByCode(materialCode); |
359 | - if (StringUtils.isEmpty(containerCode)){ | |
360 | - if (material.getAutoGenSerialNum() == 0){ | |
361 | - return 1; | |
362 | - //需自动生成容器编码 | |
372 | + if (StringUtils.isEmpty(containerCode)) { | |
373 | + if (material.getAutoGenSerialNum() == 0) { | |
374 | + return 1; | |
375 | + //需自动生成容器编码 | |
363 | 376 | } else { |
364 | 377 | throw new ServiceException("容器不能为空"); |
365 | 378 | } |
366 | 379 | } |
367 | - if (material == null){ | |
368 | - throw new ServiceException("物料:"+materialCode+"不存在"); | |
380 | + if (material == null) { | |
381 | + throw new ServiceException("物料:" + materialCode + "不存在"); | |
369 | 382 | } |
370 | 383 | /** |
371 | 384 | * 判断物料是否可以放在当前容器 |
... | ... | @@ -389,7 +402,7 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
389 | 402 | lambda.eq(Container::getCode, containerCode); |
390 | 403 | lambda.eq(Container::getWarehouseCode, ShiroUtils.getWarehouseCode()); |
391 | 404 | Container container = containerService.getOne(lambda); |
392 | - if (container == null){ | |
405 | + if (container == null) { | |
393 | 406 | throw new ServiceException("该容器编号不存在"); |
394 | 407 | } |
395 | 408 | |
... | ... | @@ -400,21 +413,21 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
400 | 413 | .lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED) |
401 | 414 | .eq(TaskHeader::getWarehouseCode, ShiroUtils.getWarehouseCode()); |
402 | 415 | //补充入库跳过校验 |
403 | - if (taskHeaderService.count(lambdaQueryWrapper) >0 && taskHeaderService.getOne(lambdaQueryWrapper).getStatus()==QuantityConstant.TASK_STATUS_ARRIVED_STATION){ | |
416 | + if (taskHeaderService.count(lambdaQueryWrapper) > 0 && taskHeaderService.getOne(lambdaQueryWrapper).getStatus() == QuantityConstant.TASK_STATUS_ARRIVED_STATION) { | |
404 | 417 | |
405 | - }else{ | |
406 | - if (container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_LOCK)){ | |
418 | + } else { | |
419 | + if (container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_LOCK)) { | |
407 | 420 | throw new ServiceException("容器已经锁定,不能再组盘"); |
408 | 421 | } |
409 | 422 | } |
410 | 423 | if (taskHeaderService.count(lambdaQueryWrapper) > 0 && taskHeaderService.getOne(lambdaQueryWrapper).getTaskType() != 200) { |
411 | 424 | throw new ServiceException("容器已经存在任务,请更换容器"); |
412 | 425 | } |
413 | - if (StringUtils.isEmpty(container.getLocationCode())){ | |
426 | + if (StringUtils.isEmpty(container.getLocationCode())) { | |
414 | 427 | return QuantityConstant.TASK_TYPE_WHOLERECEIPT; |
415 | - }else if (StringUtils.isNotEmpty(container.getStatus()) | |
416 | - &&(container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_EMPTY) | |
417 | - ||container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_SOME))) { | |
428 | + } else if (StringUtils.isNotEmpty(container.getStatus()) | |
429 | + && (container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_EMPTY) | |
430 | + || container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_SOME))) { | |
418 | 431 | return QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT; |
419 | 432 | } else if (QuantityConstant.STATUS_CONTAINER_FULL.equals(container.getStatus())) { |
420 | 433 | throw new ServiceException("该容器已满,请更换容器"); |
... | ... | @@ -424,16 +437,17 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
424 | 437 | |
425 | 438 | /** |
426 | 439 | * 检查库位是否合法 |
427 | - * @param locationCode 库位编码 | |
440 | + * | |
441 | + * @param locationCode 库位编码 | |
428 | 442 | * @param containerCode 容器编码 |
429 | - * @param taskType 任务类型 | |
443 | + * @param taskType 任务类型 | |
430 | 444 | * @return |
431 | 445 | */ |
432 | 446 | @Transactional |
433 | - Boolean checkLocationCode(String locationCode, String containerCode, Integer taskType) { | |
447 | + public Boolean checkLocationCode(String locationCode, String containerCode, Integer taskType) { | |
434 | 448 | //如果选了库位,就要校验库位和已经组盘的库位是否一致,避免重入库 |
435 | 449 | if (StringUtils.isEmpty(locationCode)) { |
436 | - if (QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT == taskType.intValue()) { | |
450 | + if (QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT == taskType.intValue()) { | |
437 | 451 | throw new ServiceException("补充入库,必须填写库位"); |
438 | 452 | } else { |
439 | 453 | return true; |
... | ... | @@ -450,10 +464,10 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
450 | 464 | .lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED) |
451 | 465 | .eq(TaskHeader::getWarehouseCode, ShiroUtils.getWarehouseCode()); |
452 | 466 | //补充入库跳过校验 |
453 | - if (taskHeaderService.count(lambdaQueryWrapper) >0 && taskHeaderService.getOne(lambdaQueryWrapper).getStatus()==QuantityConstant.TASK_STATUS_ARRIVED_STATION && taskHeaderService.getOne(lambdaQueryWrapper).getTaskType()==QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT){ | |
467 | + if (taskHeaderService.count(lambdaQueryWrapper) > 0 && taskHeaderService.getOne(lambdaQueryWrapper).getStatus() == QuantityConstant.TASK_STATUS_ARRIVED_STATION && taskHeaderService.getOne(lambdaQueryWrapper).getTaskType() == QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT) { | |
454 | 468 | |
455 | - }else{ | |
456 | - if (!QuantityConstant.STATUS_LOCATION_EMPTY.equals(location.getStatus()) ) { | |
469 | + } else { | |
470 | + if (!QuantityConstant.STATUS_LOCATION_EMPTY.equals(location.getStatus())) { | |
457 | 471 | throw new ServiceException("库位不是空闲状态!"); |
458 | 472 | } |
459 | 473 | } |
... | ... | @@ -463,11 +477,11 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
463 | 477 | throw new ServiceException("库位(" + locationCode + ")有容器(" + location.getContainerCode() + "),不能整盘入库!"); |
464 | 478 | } |
465 | 479 | } |
466 | - if(QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT== taskType.intValue()) { | |
467 | - if (StringUtils.isEmpty(location.getContainerCode())){ | |
480 | + if (QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT == taskType.intValue()) { | |
481 | + if (StringUtils.isEmpty(location.getContainerCode())) { | |
468 | 482 | throw new ServiceException("库位(" + locationCode + ")没有容器,不能补充入库!"); |
469 | 483 | } else if (!location.getContainerCode().equals(containerCode)) { |
470 | - throw new ServiceException("库位(" + containerCode + ")对应的容器是:" + location.getContainerCode()+ ",请重选库位!"); | |
484 | + throw new ServiceException("库位(" + containerCode + ")对应的容器是:" + location.getContainerCode() + ",请重选库位!"); | |
471 | 485 | } |
472 | 486 | } |
473 | 487 | return true; |
... | ... | @@ -475,13 +489,14 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
475 | 489 | |
476 | 490 | /** |
477 | 491 | * 增加组盘明细记录 |
478 | - * @param 入库组盘头表id | |
479 | - * @param receiptDetail 入库详情 | |
480 | - * @param qty 收货数量 | |
481 | - * @param containerCode 容器编码 | |
492 | + * | |
493 | + * @param receiptContainerHeader | |
494 | + * @param receiptDetail 入库详情 | |
495 | + * @param qty 收货数量 | |
496 | + * @param containerCode 容器编码 | |
482 | 497 | */ |
483 | 498 | @Transactional |
484 | - public void receiptContainerDetailAdd(ReceiptContainerHeader receiptContainerHeader, ReceiptDetail receiptDetail, BigDecimal qty, String containerCode, String locationCode){ | |
499 | + public void receiptContainerDetailAdd(ReceiptContainerHeader receiptContainerHeader, ReceiptDetail receiptDetail, BigDecimal qty, String containerCode, String locationCode) { | |
485 | 500 | int receiptContainerHeaderId = receiptContainerHeader.getId(); |
486 | 501 | LambdaQueryWrapper<ReceiptContainerDetail> lambda = Wrappers.lambdaQuery(); |
487 | 502 | lambda.eq(ReceiptContainerDetail::getReceiptContainerId, receiptContainerHeaderId) |
... | ... | @@ -490,7 +505,7 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
490 | 505 | .last("Limit 1"); |
491 | 506 | ReceiptContainerDetail receiptContainerDetail = receiptContainerDetailService.getOne(lambda); |
492 | 507 | |
493 | - if (receiptContainerDetail == null){ | |
508 | + if (receiptContainerDetail == null) { | |
494 | 509 | //查询入库头表 |
495 | 510 | LambdaQueryWrapper<ReceiptHeader> receiptHeaderLambda = Wrappers.lambdaQuery(); |
496 | 511 | receiptHeaderLambda.eq(ReceiptHeader::getId, receiptDetail.getReceiptId()) |
... | ... | @@ -530,12 +545,12 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
530 | 545 | receiptContainerDetail.setInventorySts(receiptDetail.getInventorySts()); |
531 | 546 | receiptContainerDetail.setCreatedBy(ShiroUtils.getName()); |
532 | 547 | receiptContainerDetail.setLastUpdatedBy(ShiroUtils.getName()); |
533 | - if (!receiptContainerDetailService.save(receiptContainerDetail)){ | |
548 | + if (!receiptContainerDetailService.save(receiptContainerDetail)) { | |
534 | 549 | throw new ServiceException("保存入库组盘详情失败"); |
535 | 550 | } |
536 | 551 | } else { |
537 | 552 | receiptContainerDetail.setQty(receiptContainerDetail.getQty().add(qty)); |
538 | - if (!receiptContainerDetailService.updateById(receiptContainerDetail)){ | |
553 | + if (!receiptContainerDetailService.updateById(receiptContainerDetail)) { | |
539 | 554 | throw new ServiceException("更新入库组盘详情失败"); |
540 | 555 | } |
541 | 556 | } |
... | ... | @@ -545,10 +560,11 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
545 | 560 | |
546 | 561 | /** |
547 | 562 | * 自动生成容器编码 |
563 | + * | |
548 | 564 | * @return 容器编码 |
549 | 565 | */ |
550 | 566 | @Transactional |
551 | - public String createContainer(){ | |
567 | + public String createContainer() { | |
552 | 568 | String code = MessageFormat.format("{0}{1}", |
553 | 569 | "LS", |
554 | 570 | String.format("%d", Calendar.getInstance().getTimeInMillis())); |
... | ... | @@ -562,7 +578,7 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
562 | 578 | container.setLastUpdatedBy(ShiroUtils.getName()); |
563 | 579 | container.setEnable(true); |
564 | 580 | container.setStatus(QuantityConstant.STATUS_CONTAINER_EMPTY); |
565 | - if (!containerService.save(container)){ | |
581 | + if (!containerService.save(container)) { | |
566 | 582 | throw new ServiceException("新增容器失败"); |
567 | 583 | } |
568 | 584 | return code; |
... | ... | @@ -591,7 +607,7 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
591 | 607 | .eq(ReceiptContainerHeader::getStatus, 0); |
592 | 608 | |
593 | 609 | ReceiptContainerHeader receiptContainerHeader = getOne(receiptContainerHeaderLambada); |
594 | - if(receiptContainerHeader == null) { | |
610 | + if (receiptContainerHeader == null) { | |
595 | 611 | save(recorder); |
596 | 612 | } else { |
597 | 613 | return receiptContainerHeader.getId(); |
... | ... | @@ -605,6 +621,7 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
605 | 621 | |
606 | 622 | /** |
607 | 623 | * 取消入库任务 |
624 | + * | |
608 | 625 | * @param id 入库组盘头id |
609 | 626 | * @return |
610 | 627 | */ |
... | ... | @@ -617,7 +634,7 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
617 | 634 | ReceiptContainerHeader receiptContainerHeader = new ReceiptContainerHeader(); |
618 | 635 | receiptContainerHeader.setStatus(QuantityConstant.RECEIPT_CONTAINER_BUILD); |
619 | 636 | receiptContainerHeader.setId(id); |
620 | - if (!updateById(receiptContainerHeader)){ | |
637 | + if (!updateById(receiptContainerHeader)) { | |
621 | 638 | throw new ServiceException("回滚入库组盘头表失败"); |
622 | 639 | } |
623 | 640 | |
... | ... | @@ -659,7 +676,7 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
659 | 676 | .lt(ReceiptContainerHeader::getStatus, QuantityConstant.RECEIPT_CONTAINER_FINISHED); |
660 | 677 | int number = 0; |
661 | 678 | List<ReceiptContainerHeader> receiptContainerHeaderList = list(receiptContainerHeaderLambdaQueryWrapper); |
662 | - if(receiptContainerHeaderList != null && receiptContainerHeaderList.size() > 0) { | |
679 | + if (receiptContainerHeaderList != null && receiptContainerHeaderList.size() > 0) { | |
663 | 680 | number = receiptContainerHeaderList.size(); |
664 | 681 | } |
665 | 682 | return number; |
... | ... |
src/main/java/com/huaheng/pc/shipment/shipmentDetail/service/ShipmentDetailServiceImpl.java
... | ... | @@ -23,6 +23,7 @@ import com.huaheng.pc.shipment.wave.service.WaveService; |
23 | 23 | import com.huaheng.pc.task.taskDetail.domain.TaskDetail; |
24 | 24 | import org.springframework.beans.factory.annotation.Autowired; |
25 | 25 | import org.springframework.stereotype.Service; |
26 | + | |
26 | 27 | import javax.annotation.Resource; |
27 | 28 | import java.math.BigDecimal; |
28 | 29 | import java.util.ArrayList; |
... | ... | @@ -35,11 +36,12 @@ import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail; |
35 | 36 | import org.springframework.transaction.annotation.Transactional; |
36 | 37 | |
37 | 38 | @Service |
38 | -public class ShipmentDetailServiceImpl extends ServiceImpl<ShipmentDetailMapper, ShipmentDetail> implements ShipmentDetailService{ | |
39 | +public class ShipmentDetailServiceImpl extends ServiceImpl<ShipmentDetailMapper, ShipmentDetail> implements ShipmentDetailService { | |
39 | 40 | |
40 | 41 | @Autowired |
41 | 42 | private ShipmentHeaderService shipmentHeaderService; |
42 | - | |
43 | + @Resource | |
44 | + private ShipmentDetailService shipmentDetailService; | |
43 | 45 | @Autowired |
44 | 46 | private MaterialService materialService; |
45 | 47 | @Resource |
... | ... | @@ -62,11 +64,12 @@ public class ShipmentDetailServiceImpl extends ServiceImpl<ShipmentDetailMapper, |
62 | 64 | * @return |
63 | 65 | */ |
64 | 66 | @Override |
67 | + @Transactional(rollbackFor = Exception.class) | |
65 | 68 | public AjaxResult insertDetail(ShipmentDetail shipmentDetail) { |
66 | 69 | //查看主单是否存在 |
67 | 70 | LambdaQueryWrapper<ShipmentHeader> lambdaQueryWrapper = Wrappers.lambdaQuery(); |
68 | - lambdaQueryWrapper.eq(ShipmentHeader::getId,shipmentDetail.getShipmentId()) | |
69 | - .eq(ShipmentHeader::getWarehouseCode,ShiroUtils.getWarehouseCode()); | |
71 | + lambdaQueryWrapper.eq(ShipmentHeader::getId, shipmentDetail.getShipmentId()) | |
72 | + .eq(ShipmentHeader::getWarehouseCode, ShiroUtils.getWarehouseCode()); | |
70 | 73 | ShipmentHeader shipmentHeader = shipmentHeaderService.getOne(lambdaQueryWrapper); |
71 | 74 | if (shipmentHeader == null) { |
72 | 75 | return AjaxResult.error("找不到主单据"); |
... | ... | @@ -78,15 +81,14 @@ public class ShipmentDetailServiceImpl extends ServiceImpl<ShipmentDetailMapper, |
78 | 81 | |
79 | 82 | //查找物料 |
80 | 83 | LambdaQueryWrapper<Material> lam = Wrappers.lambdaQuery(); |
81 | - lam.eq(Material::getCode,shipmentDetail.getMaterialCode()) | |
82 | - .eq(Material::getWarehouseCode,ShiroUtils.getWarehouseCode()); | |
84 | + lam.eq(Material::getCode, shipmentDetail.getMaterialCode()) | |
85 | + .eq(Material::getWarehouseCode, ShiroUtils.getWarehouseCode()); | |
83 | 86 | Material material = materialService.getOne(lam); |
84 | 87 | if (material == null) { |
85 | 88 | return AjaxResult.error("物料未找到"); |
86 | 89 | } |
87 | 90 | if (StringUtils.isNotEmpty(material.getCompanyCode()) && |
88 | - ShiroUtils.getCompanyCodeList().contains(material.getCompanyCode()) == false) | |
89 | - { | |
91 | + ShiroUtils.getCompanyCodeList().contains(material.getCompanyCode()) == false) { | |
90 | 92 | return AjaxResult.error("物料不属于当前货主!"); |
91 | 93 | } |
92 | 94 | shipmentDetail.setId(null); |
... | ... | @@ -102,15 +104,14 @@ public class ShipmentDetailServiceImpl extends ServiceImpl<ShipmentDetailMapper, |
102 | 104 | shipmentDetail.setLastUpdated(null); |
103 | 105 | shipmentDetail.setLastUpdatedBy(ShiroUtils.getName()); |
104 | 106 | shipmentDetail.setLastUpdatedByName(ShiroUtils.getName()); |
105 | - if (this.save(shipmentDetail)==true){ | |
107 | + if (this.save(shipmentDetail) == true) { | |
106 | 108 | //更新单据总行数与总数量 |
107 | 109 | shipmentHeader.setTotalLines(shipmentHeader.getTotalLines() + 1); |
108 | 110 | shipmentHeader.setTotalQty(shipmentHeader.getTotalQty().add(shipmentDetail.getQty())); |
109 | 111 | shipmentHeaderService.saveOrUpdate(shipmentHeader); |
110 | - updateShipmentHeader(shipmentHeader); | |
112 | + shipmentDetailService.updateShipmentHeader(shipmentHeader); | |
111 | 113 | return AjaxResult.success("新增单据明细成功"); |
112 | - } | |
113 | - else { | |
114 | + } else { | |
114 | 115 | return AjaxResult.error("新增单据明细失败"); |
115 | 116 | } |
116 | 117 | } |
... | ... | @@ -123,13 +124,13 @@ public class ShipmentDetailServiceImpl extends ServiceImpl<ShipmentDetailMapper, |
123 | 124 | * @return |
124 | 125 | */ |
125 | 126 | @Override |
126 | - @Transactional | |
127 | + @Transactional(rollbackFor = Exception.class) | |
127 | 128 | public AjaxResult deleteDetail(String id) { |
128 | 129 | if (StringUtils.isEmpty(id)) { |
129 | 130 | return AjaxResult.error("id不能为空"); |
130 | 131 | } |
131 | 132 | String[] ids = id.split(","); |
132 | - List<Map<String,Integer>> list = shipmentDetailMapper.SelectFirstStatus(id); | |
133 | + List<Map<String, Integer>> list = shipmentDetailMapper.SelectFirstStatus(id); | |
133 | 134 | if (list.size() < 1) { |
134 | 135 | return AjaxResult.error("找不到主单据!"); |
135 | 136 | } |
... | ... | @@ -141,29 +142,27 @@ public class ShipmentDetailServiceImpl extends ServiceImpl<ShipmentDetailMapper, |
141 | 142 | } |
142 | 143 | Integer result = shipmentDetailMapper.batchDelete(ids); |
143 | 144 | if (result > 0) { |
144 | - Integer headerId=list.get(0).get("id"); | |
145 | - Map<String,String> map= shipmentDetailMapper.StatisticalByReceiptId(headerId); | |
146 | - if(DataUtils.getInteger(map.get("totalLines")) <= 0) { | |
145 | + Integer headerId = list.get(0).get("id"); | |
146 | + Map<String, String> map = shipmentDetailMapper.StatisticalByReceiptId(headerId); | |
147 | + if (DataUtils.getInteger(map.get("totalLines")) <= 0) { | |
147 | 148 | shipmentHeaderService.removeById(headerId); |
148 | - } | |
149 | - else { | |
149 | + } else { | |
150 | 150 | //更新表头的总行数和总数量统计 |
151 | 151 | ShipmentHeader shipmentHeader = new ShipmentHeader(); |
152 | 152 | shipmentHeader.setId(headerId); |
153 | 153 | // shipmentHeader.setTotalLines(DataUtils.getInteger(map.get("totalLines"))); |
154 | 154 | // shipmentHeader.setTotalQty(DataUtils.getBigDecimal(map.get("totalQty"))); |
155 | 155 | // shipmentHeaderService.saveOrUpdate(shipmentHeader); |
156 | - updateShipmentHeader(shipmentHeader); | |
156 | + shipmentDetailService.updateShipmentHeader(shipmentHeader); | |
157 | 157 | } |
158 | 158 | return AjaxResult.success("删除单据明细成功"); |
159 | - } | |
160 | - else { | |
159 | + } else { | |
161 | 160 | return AjaxResult.error("删除单据明细失败"); |
162 | 161 | } |
163 | 162 | } |
164 | 163 | |
165 | 164 | /** |
166 | - ** 查找没有出库完的详情 | |
165 | + * * 查找没有出库完的详情 | |
167 | 166 | */ |
168 | 167 | @Override |
169 | 168 | public Integer countUnCompleted(Integer shipmentId) { |
... | ... | @@ -171,10 +170,10 @@ public class ShipmentDetailServiceImpl extends ServiceImpl<ShipmentDetailMapper, |
171 | 170 | shipmentDetailLambdaQueryWrapper.eq(ShipmentDetail::getShipmentId, shipmentId); |
172 | 171 | List<ShipmentDetail> shipmentDetailList = list(shipmentDetailLambdaQueryWrapper); |
173 | 172 | int n = 0; |
174 | - for(ShipmentDetail shipmentDetail : shipmentDetailList) { | |
173 | + for (ShipmentDetail shipmentDetail : shipmentDetailList) { | |
175 | 174 | BigDecimal qty = shipmentDetail.getQty(); |
176 | 175 | BigDecimal taskQty = shipmentDetail.getTaskQty(); |
177 | - if(qty.compareTo(taskQty) > 0) { | |
176 | + if (qty.compareTo(taskQty) > 0) { | |
178 | 177 | n++; |
179 | 178 | } |
180 | 179 | } |
... | ... | @@ -190,72 +189,71 @@ public class ShipmentDetailServiceImpl extends ServiceImpl<ShipmentDetailMapper, |
190 | 189 | * 修改加入波次的子单,修改子单和主单的状态,并修改子单的waveId |
191 | 190 | */ |
192 | 191 | @Override |
193 | - @Transactional | |
192 | + @Transactional(rollbackFor = Exception.class) | |
194 | 193 | public void saveWave(String ids, String code) { |
195 | 194 | Integer status = QuantityConstant.SHIPMENT_HEADER_POOL; |
196 | - List<ShipmentHeader> shipmentHeaderList =shipmentPreferenceService.checkShipmentProcess(ids,status,code); | |
195 | + List<ShipmentHeader> shipmentHeaderList = shipmentPreferenceService.checkShipmentProcess(ids, status, code); | |
197 | 196 | |
198 | 197 | //找到波次主表,看系统是否有此波次 |
199 | - LambdaQueryWrapper<WaveMaster> lam=Wrappers.lambdaQuery(); | |
200 | - lam.eq(WaveMaster::getCode,code) | |
201 | - .eq(WaveMaster::getWarehouseCode,ShiroUtils.getWarehouseCode()); | |
202 | - WaveMaster waveMaster=waveMasterService.getOne(lam); | |
203 | - if(waveMaster == null){ | |
198 | + LambdaQueryWrapper<WaveMaster> lam = Wrappers.lambdaQuery(); | |
199 | + lam.eq(WaveMaster::getCode, code) | |
200 | + .eq(WaveMaster::getWarehouseCode, ShiroUtils.getWarehouseCode()); | |
201 | + WaveMaster waveMaster = waveMasterService.getOne(lam); | |
202 | + if (waveMaster == null) { | |
204 | 203 | throw new ServiceException("系统没有此波次"); |
205 | 204 | } |
206 | 205 | |
207 | - if(Convert.toIntArray(ids).length >waveMaster.getMaxShipments()){ | |
206 | + if (Convert.toIntArray(ids).length > waveMaster.getMaxShipments()) { | |
208 | 207 | throw new ServiceException("加入波次的单据数量超过波次的单据限制"); |
209 | 208 | } |
210 | 209 | |
211 | - List<ShipmentDetail> shipmentDetailList=new ArrayList<>(); | |
212 | - BigDecimal qty=new BigDecimal(0); | |
210 | + List<ShipmentDetail> shipmentDetailList = new ArrayList<>(); | |
211 | + BigDecimal qty = new BigDecimal(0); | |
213 | 212 | //检查出库子表是否有处于波次的 |
214 | - for (Integer id : Convert.toIntArray(ids)) | |
215 | - { | |
216 | - LambdaQueryWrapper<ShipmentDetail> lamDetail=Wrappers.lambdaQuery(); | |
217 | - lamDetail.eq(ShipmentDetail::getWarehouseCode,ShiroUtils.getWarehouseCode()) | |
218 | - .eq(ShipmentDetail::getShipmentId,id); | |
219 | - List<ShipmentDetail> shipmentDetails=this.list(lamDetail); | |
220 | - if(shipmentDetails == null || shipmentDetails.size() == 0){ | |
221 | - throw new ServiceException("系统没有主单id为"+id+"的子单"); | |
213 | + for (Integer id : Convert.toIntArray(ids)) { | |
214 | + LambdaQueryWrapper<ShipmentDetail> lamDetail = Wrappers.lambdaQuery(); | |
215 | + lamDetail.eq(ShipmentDetail::getWarehouseCode, ShiroUtils.getWarehouseCode()) | |
216 | + .eq(ShipmentDetail::getShipmentId, id); | |
217 | + List<ShipmentDetail> shipmentDetails = this.list(lamDetail); | |
218 | + if (shipmentDetails == null || shipmentDetails.size() == 0) { | |
219 | + throw new ServiceException("系统没有主单id为" + id + "的子单"); | |
222 | 220 | } |
223 | 221 | |
224 | 222 | //查看是否有单据处于波次中 |
225 | - for(ShipmentDetail shipmentDetail : shipmentDetails) { | |
223 | + for (ShipmentDetail shipmentDetail : shipmentDetails) { | |
226 | 224 | if (shipmentDetail.getWaveId() != 0) { |
227 | 225 | throw new ServiceException("主单id为" + id + "子单id为" + shipmentDetail.getId() + "的子单已加入波次,不可再加入波次"); |
228 | 226 | } |
229 | - if(shipmentDetail.getQty().compareTo(shipmentDetail.getTaskQty())!=0) { | |
227 | + if (shipmentDetail.getQty().compareTo(shipmentDetail.getTaskQty()) != 0) { | |
230 | 228 | shipmentDetailList.add(shipmentDetail); |
231 | 229 | qty = qty.add(shipmentDetail.getQty().subtract(shipmentDetail.getTaskQty())); |
232 | 230 | } |
233 | 231 | } |
234 | 232 | } |
235 | 233 | |
236 | - if(shipmentDetailList.size()>waveMaster.getMaxLines()){ | |
234 | + if (shipmentDetailList.size() > waveMaster.getMaxLines()) { | |
237 | 235 | throw new ServiceException("加入波次的总行数超过波次的行数限制"); |
238 | 236 | } |
239 | 237 | |
240 | - Boolean flag=false; | |
238 | + Boolean flag = false; | |
241 | 239 | |
242 | 240 | //查看波次是否建成未执行 |
243 | 241 | LambdaQueryWrapper<Wave> waveLam = Wrappers.lambdaQuery(); |
244 | - waveLam.eq(Wave::getStatus,QuantityConstant.WAVE_STATUS_BUILD) | |
245 | - .eq(Wave::getWaveMode,code) | |
246 | - .eq(Wave::getWarehouseCode,ShiroUtils.getWarehouseCode()); | |
242 | + waveLam.eq(Wave::getStatus, QuantityConstant.WAVE_STATUS_BUILD) | |
243 | + .eq(Wave::getWaveMode, code) | |
244 | + .eq(Wave::getWarehouseCode, ShiroUtils.getWarehouseCode()); | |
247 | 245 | Wave wave = waveService.getOne(waveLam); |
248 | - if(wave != null && (wave.getTotalShipments()+Convert.toIntArray(ids).length)<= waveMaster.getMaxShipments() | |
249 | - && (wave.getTotalLines()+shipmentDetailList.size()<= waveMaster.getMaxLines())){ | |
246 | + if (wave != null && (wave.getTotalShipments() + Convert.toIntArray(ids).length) <= waveMaster.getMaxShipments() | |
247 | + && (wave.getTotalLines() + shipmentDetailList.size() <= waveMaster.getMaxLines())) { | |
250 | 248 | //修改波次 |
251 | 249 | wave.setTotalShipments(Convert.toIntArray(ids).length + wave.getTotalShipments()); |
252 | 250 | wave.setTotalLines(shipmentDetailList.size() + wave.getTotalLines()); |
253 | 251 | wave.setTotalQty(qty.add(wave.getTotalQty())); |
254 | 252 | wave.setLastUpdatedBy(ShiroUtils.getName()); |
255 | 253 | |
256 | - }else { | |
254 | + } else { | |
257 | 255 | //创建波次 |
258 | - wave=new Wave(); | |
256 | + wave = new Wave(); | |
259 | 257 | wave.setWarehouseCode(ShiroUtils.getWarehouseCode()); |
260 | 258 | wave.setMasterCode(code); |
261 | 259 | wave.setWaveName(waveMaster.getName()); |
... | ... | @@ -272,27 +270,27 @@ public class ShipmentDetailServiceImpl extends ServiceImpl<ShipmentDetailMapper, |
272 | 270 | } |
273 | 271 | |
274 | 272 | //修改出库子单,加入波次ID,并修改状态为波次 |
275 | - for(ShipmentDetail shipmentDetail :shipmentDetailList){ | |
273 | + for (ShipmentDetail shipmentDetail : shipmentDetailList) { | |
276 | 274 | shipmentDetail.setWaveId(wave.getId()); |
277 | - if(shipmentDetail.getStatus()<QuantityConstant.SHIPMENT_HEADER_WAVE) { | |
275 | + if (shipmentDetail.getStatus() < QuantityConstant.SHIPMENT_HEADER_WAVE) { | |
278 | 276 | shipmentDetail.setStatus(QuantityConstant.SHIPMENT_HEADER_WAVE); |
279 | 277 | } |
280 | 278 | } |
281 | 279 | |
282 | 280 | flag = this.updateBatchById(shipmentDetailList); |
283 | - if(flag == false){ | |
281 | + if (flag == false) { | |
284 | 282 | throw new ServiceException("出库子单加入波次失败"); |
285 | 283 | } |
286 | 284 | |
287 | - for(ShipmentHeader shipmentHeader :shipmentHeaderList){ | |
285 | + for (ShipmentHeader shipmentHeader : shipmentHeaderList) { | |
288 | 286 | shipmentHeader.setWaveId(wave.getId()); |
289 | 287 | shipmentHeader.setFirstStatus(QuantityConstant.SHIPMENT_HEADER_WAVE); |
290 | - if(shipmentHeader.getLastStatus()<QuantityConstant.SHIPMENT_HEADER_WAVE) { | |
288 | + if (shipmentHeader.getLastStatus() < QuantityConstant.SHIPMENT_HEADER_WAVE) { | |
291 | 289 | shipmentHeader.setLastStatus(QuantityConstant.SHIPMENT_HEADER_WAVE); |
292 | 290 | } |
293 | 291 | } |
294 | 292 | flag = shipmentHeaderService.updateBatchById(shipmentHeaderList); |
295 | - if(flag == false){ | |
293 | + if (flag == false) { | |
296 | 294 | throw new ServiceException("修改主单状态失败"); |
297 | 295 | } |
298 | 296 | |
... | ... | @@ -301,7 +299,7 @@ public class ShipmentDetailServiceImpl extends ServiceImpl<ShipmentDetailMapper, |
301 | 299 | |
302 | 300 | //查看最高状态和最低状态 |
303 | 301 | @Override |
304 | - public Map<String,Integer> selectStatus(Integer id) { | |
302 | + public Map<String, Integer> selectStatus(Integer id) { | |
305 | 303 | return shipmentDetailMapper.selectStatus(id); |
306 | 304 | } |
307 | 305 | |
... | ... | @@ -323,32 +321,34 @@ public class ShipmentDetailServiceImpl extends ServiceImpl<ShipmentDetailMapper, |
323 | 321 | @Override |
324 | 322 | public Boolean insertDetails(List<ShipmentDetail> shipmentDetails) { |
325 | 323 | int flag = shipmentDetailMapper.insertDetails(shipmentDetails); |
326 | - if(flag > 0){ | |
324 | + if (flag > 0) { | |
327 | 325 | return true; |
328 | - }else { | |
326 | + } else { | |
329 | 327 | return false; |
330 | 328 | } |
331 | 329 | } |
332 | 330 | |
333 | 331 | /** |
334 | 332 | * 更新入库单头表状态 |
333 | + * | |
335 | 334 | * @param shipmentHeader 入库单按头表 |
336 | 335 | * @return |
337 | 336 | */ |
338 | 337 | @Override |
338 | + @Transactional(rollbackFor = Exception.class) | |
339 | 339 | public AjaxResult updateShipmentHeader(ShipmentHeader shipmentHeader) { |
340 | 340 | BigDecimal totalQty = new BigDecimal(0); |
341 | 341 | int totalLines = 0; |
342 | 342 | LambdaQueryWrapper<ShipmentDetail> shipmentDetailLambdaQueryWrapper = Wrappers.lambdaQuery(); |
343 | 343 | shipmentDetailLambdaQueryWrapper.eq(ShipmentDetail::getShipmentId, shipmentHeader.getId()); |
344 | - List<ShipmentDetail> shipmentDetailList = list(shipmentDetailLambdaQueryWrapper); | |
345 | - for(ShipmentDetail shipmentDetail : shipmentDetailList) { | |
344 | + List<ShipmentDetail> shipmentDetailList = list(shipmentDetailLambdaQueryWrapper); | |
345 | + for (ShipmentDetail shipmentDetail : shipmentDetailList) { | |
346 | 346 | totalLines++; |
347 | 347 | totalQty = totalQty.add(shipmentDetail.getQty()); |
348 | 348 | } |
349 | 349 | shipmentHeader.setTotalQty(totalQty); |
350 | 350 | shipmentHeader.setTotalLines(totalLines); |
351 | - if (!shipmentHeaderService.updateById(shipmentHeader)){ | |
351 | + if (!shipmentHeaderService.updateById(shipmentHeader)) { | |
352 | 352 | return AjaxResult.error("出库头表更新失败"); |
353 | 353 | } |
354 | 354 | return AjaxResult.success("入库头表更新成功"); |
... | ... |
src/main/java/com/huaheng/pc/shipment/shipmentHeader/service/ShipmentHeaderServiceImpl.java
... | ... | @@ -39,7 +39,7 @@ import java.util.List; |
39 | 39 | import java.util.Map; |
40 | 40 | |
41 | 41 | @Service |
42 | -public class ShipmentHeaderServiceImpl extends ServiceImpl<ShipmentHeaderMapper, ShipmentHeader> implements ShipmentHeaderService{ | |
42 | +public class ShipmentHeaderServiceImpl extends ServiceImpl<ShipmentHeaderMapper, ShipmentHeader> implements ShipmentHeaderService { | |
43 | 43 | |
44 | 44 | @Autowired |
45 | 45 | private IDictDataService dictDataService; |
... | ... | @@ -63,12 +63,12 @@ public class ShipmentHeaderServiceImpl extends ServiceImpl<ShipmentHeaderMapper, |
63 | 63 | private ShipmentTypeService shipmentTypeService; |
64 | 64 | |
65 | 65 | //新增出库主单 |
66 | + @Transactional(rollbackFor = Exception.class) | |
66 | 67 | @Override |
67 | 68 | public AjaxResult<Boolean> saveHeader(ShipmentHeader shipmentHeader) { |
68 | 69 | |
69 | - if(shipmentTypeService.checkCode(shipmentHeader.getShipmentType()) == false) | |
70 | - { | |
71 | - return AjaxResult.error("没有对应的出库单类型"); | |
70 | + if (shipmentTypeService.checkCode(shipmentHeader.getShipmentType()) == false) { | |
71 | + return AjaxResult.error("没有对应的出库单类型"); | |
72 | 72 | } |
73 | 73 | String code = createCode(shipmentHeader.getShipmentType()); |
74 | 74 | shipmentHeader.setId(null); |
... | ... | @@ -80,43 +80,40 @@ public class ShipmentHeaderServiceImpl extends ServiceImpl<ShipmentHeaderMapper, |
80 | 80 | shipmentHeader.setCreatedBy(ShiroUtils.getName()); |
81 | 81 | shipmentHeader.setWarehouseCode(ShiroUtils.getWarehouseCode()); |
82 | 82 | shipmentHeader.setCode(code); |
83 | - if(StringUtils.isNotEmpty(shipmentHeader.getCustomerCode())){ | |
83 | + if (StringUtils.isNotEmpty(shipmentHeader.getCustomerCode())) { | |
84 | 84 | LambdaQueryWrapper<Customer> customerLambd = Wrappers.lambdaQuery(); |
85 | - customerLambd.eq(Customer::getCode,shipmentHeader.getCustomerCode()); | |
86 | - Customer customer =customerService.getOne(customerLambd); | |
87 | - if(customer == null){ | |
85 | + customerLambd.eq(Customer::getCode, shipmentHeader.getCustomerCode()); | |
86 | + Customer customer = customerService.getOne(customerLambd); | |
87 | + if (customer == null) { | |
88 | 88 | return AjaxResult.error("客户编码错误,wms系统没有此客户"); |
89 | 89 | } |
90 | 90 | } |
91 | 91 | boolean result = this.save(shipmentHeader); |
92 | - return AjaxResult.toAjax(result); | |
92 | + return AjaxResult.toAjax(result); | |
93 | 93 | } |
94 | 94 | |
95 | 95 | |
96 | 96 | //根据单据类型建单据号 |
97 | + @Transactional(rollbackFor = Exception.class) | |
97 | 98 | @Override |
98 | - public String createCode(String shipmentType) | |
99 | - { | |
99 | + public String createCode(String shipmentType) { | |
100 | 100 | String code = null; |
101 | 101 | Date now = new Date(); |
102 | 102 | SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd"); |
103 | 103 | LambdaQueryWrapper<ShipmentHeader> lambda = Wrappers.lambdaQuery(); |
104 | 104 | lambda.select(ShipmentHeader::getCode).eq(ShipmentHeader::getShipmentType, shipmentType) |
105 | - .inSql(ShipmentHeader::getCode, "select code from shipment_header where code like '"+shipmentType+"%'") | |
105 | + .inSql(ShipmentHeader::getCode, "select code from shipment_header where code like '" + shipmentType + "%'") | |
106 | 106 | .orderByDesc(ShipmentHeader::getId).last("Limit 1"); |
107 | 107 | ShipmentHeader shipmentHeader = this.getOne(lambda); |
108 | 108 | String maxCode = null; |
109 | - if(shipmentHeader != null){ | |
109 | + if (shipmentHeader != null) { | |
110 | 110 | maxCode = shipmentHeader.getCode(); |
111 | 111 | } |
112 | 112 | // String maxCode = shipmentHeaderMapper.createCode(shipmentType); |
113 | - if (maxCode != null && maxCode.length() > 13 && maxCode.substring(maxCode.length() - 13, maxCode.length() - 5).equals(df.format(now))) | |
114 | - { | |
113 | + if (maxCode != null && maxCode.length() > 13 && maxCode.substring(maxCode.length() - 13, maxCode.length() - 5).equals(df.format(now))) { | |
115 | 114 | Integer Count = Integer.valueOf(maxCode.substring(maxCode.length() - 5, maxCode.length())); |
116 | 115 | code = shipmentType + df.format(now) + String.format("%05d", Count + 1); |
117 | - } | |
118 | - else | |
119 | - { | |
116 | + } else { | |
120 | 117 | code = shipmentType + df.format(now) + "00001"; |
121 | 118 | } |
122 | 119 | return code; |
... | ... | @@ -124,41 +121,43 @@ public class ShipmentHeaderServiceImpl extends ServiceImpl<ShipmentHeaderMapper, |
124 | 121 | |
125 | 122 | /** |
126 | 123 | * 根据Id更新这个单据的首尾状态 |
124 | + * | |
127 | 125 | * @param shipmentId |
128 | 126 | * @return |
129 | 127 | */ |
130 | 128 | @Override |
131 | - public AjaxResult updateShipmentStatus(int shipmentId) { | |
129 | + @Transactional(rollbackFor = Exception.class) | |
130 | + public AjaxResult updateShipmentStatus(int shipmentId) { | |
132 | 131 | //获取这个单 |
133 | 132 | ShipmentHeader shipmentHeader = this.getById(shipmentId); |
134 | - if(shipmentHeader==null){ | |
135 | - return AjaxResult.error("单据未找到,Id:"+shipmentId); | |
133 | + if (shipmentHeader == null) { | |
134 | + return AjaxResult.error("单据未找到,Id:" + shipmentId); | |
136 | 135 | } |
137 | 136 | //查询是否有生成出库货箱,如果有,则返回出库货箱的最高与最低状态 |
138 | - Map<String,Integer> map = shipmentContainerHeaderService.getShipmentContainerMaxAndMinStatusByShipmentID(shipmentId); | |
139 | - if(map==null){ | |
137 | + Map<String, Integer> map = shipmentContainerHeaderService.getShipmentContainerMaxAndMinStatusByShipmentID(shipmentId); | |
138 | + if (map == null) { | |
140 | 139 | //说明没有货箱,则直接首位均为新建 |
141 | 140 | shipmentHeader.setFirstStatus(QuantityConstant.RECEIPT_HEADER_POOL); |
142 | 141 | shipmentHeader.setLastStatus(QuantityConstant.RECEIPT_HEADER_POOL); |
143 | 142 | this.saveOrUpdate(shipmentHeader); |
144 | - }else { | |
143 | + } else { | |
145 | 144 | int firstStatus = map.get("maxStatus"); |
146 | 145 | int lastStatus = map.get("minStatus"); |
147 | - if(firstStatus<=QuantityConstant.SHIPMENT_CONTAINER_FINISHED){ | |
146 | + if (firstStatus <= QuantityConstant.SHIPMENT_CONTAINER_FINISHED) { | |
148 | 147 | shipmentHeader.setFirstStatus(QuantityConstant.SHIPMENT_HEADER_GROUPDISK); |
149 | 148 | } |
150 | - if(firstStatus==QuantityConstant.SHIPMENT_CONTAINER_REVIEWSUCCESS){ | |
149 | + if (firstStatus == QuantityConstant.SHIPMENT_CONTAINER_REVIEWSUCCESS) { | |
151 | 150 | shipmentHeader.setFirstStatus(QuantityConstant.SHIPMENT_HEADER_COMPLETED); |
152 | 151 | } |
153 | - if(lastStatus <=QuantityConstant.SHIPMENT_CONTAINER_FINISHED){ | |
152 | + if (lastStatus <= QuantityConstant.SHIPMENT_CONTAINER_FINISHED) { | |
154 | 153 | shipmentHeader.setLastStatus(QuantityConstant.SHIPMENT_HEADER_GROUPDISK); |
155 | 154 | } |
156 | - if(lastStatus==QuantityConstant.SHIPMENT_CONTAINER_REVIEWSUCCESS){ | |
155 | + if (lastStatus == QuantityConstant.SHIPMENT_CONTAINER_REVIEWSUCCESS) { | |
157 | 156 | shipmentHeader.setLastStatus(QuantityConstant.SHIPMENT_HEADER_COMPLETED); |
158 | 157 | } |
159 | 158 | //是否存在未配盘的数量,如果是,则尾状态为新建 |
160 | 159 | Integer UnCompleted = shipmentDetailService.countUnCompleted(shipmentId); |
161 | - if(UnCompleted != null && UnCompleted.intValue() > 0){ | |
160 | + if (UnCompleted != null && UnCompleted.intValue() > 0) { | |
162 | 161 | shipmentHeader.setLastStatus(QuantityConstant.SHIPMENT_HEADER_POOL); |
163 | 162 | } |
164 | 163 | this.saveOrUpdate(shipmentHeader); |
... | ... | @@ -170,15 +169,15 @@ public class ShipmentHeaderServiceImpl extends ServiceImpl<ShipmentHeaderMapper, |
170 | 169 | |
171 | 170 | //出库单字段变为历史出库单 |
172 | 171 | @Override |
173 | - @Transactional | |
172 | + @Transactional(rollbackFor = Exception.class) | |
174 | 173 | public AjaxResult addHistory(ShipmentHeader shipmentHeader) throws InvocationTargetException, IllegalAccessException { |
175 | 174 | //单据主单重复 |
176 | 175 | LambdaQueryWrapper<ShipmentHeaderHistory> headerHistoryLamb = Wrappers.lambdaQuery(); |
177 | - headerHistoryLamb.eq(ShipmentHeaderHistory::getCode,shipmentHeader.getCode()) | |
178 | - .eq(ShipmentHeaderHistory::getWarehouseCode,shipmentHeader.getWarehouseCode()); | |
176 | + headerHistoryLamb.eq(ShipmentHeaderHistory::getCode, shipmentHeader.getCode()) | |
177 | + .eq(ShipmentHeaderHistory::getWarehouseCode, shipmentHeader.getWarehouseCode()); | |
179 | 178 | |
180 | - ShipmentHeaderHistory headerHistory =shipmentHeaderHistoryService.getOne(headerHistoryLamb); | |
181 | - if(headerHistory == null) { | |
179 | + ShipmentHeaderHistory headerHistory = shipmentHeaderHistoryService.getOne(headerHistoryLamb); | |
180 | + if (headerHistory == null) { | |
182 | 181 | //历史出库主单 |
183 | 182 | ShipmentHeaderHistory shipmentHeaderHistory = new ShipmentHeaderHistory(); |
184 | 183 | // BeanUtils.copyProperties(shipmentHeaderHistory, shipmentHeader); |
... | ... | @@ -205,26 +204,27 @@ public class ShipmentHeaderServiceImpl extends ServiceImpl<ShipmentHeaderMapper, |
205 | 204 | throw new ServiceException("存入历史出库主单失败"); |
206 | 205 | } |
207 | 206 | } |
208 | - LambdaQueryWrapper<ShipmentDetail> lambdaQueryWrapper = Wrappers.lambdaQuery(); | |
209 | - lambdaQueryWrapper.eq(ShipmentDetail::getWarehouseCode, shipmentHeader.getWarehouseCode()) | |
210 | - .eq(ShipmentDetail::getShipmentCode, shipmentHeader.getCode()); | |
211 | - List<ShipmentDetail> shipmentDetails = shipmentDetailService.list(lambdaQueryWrapper); | |
207 | + LambdaQueryWrapper<ShipmentDetail> lambdaQueryWrapper = Wrappers.lambdaQuery(); | |
208 | + lambdaQueryWrapper.eq(ShipmentDetail::getWarehouseCode, shipmentHeader.getWarehouseCode()) | |
209 | + .eq(ShipmentDetail::getShipmentCode, shipmentHeader.getCode()); | |
210 | + List<ShipmentDetail> shipmentDetails = shipmentDetailService.list(lambdaQueryWrapper); | |
212 | 211 | |
213 | - //历史出库子单 | |
214 | - List<ShipmentDetailHistory> shipmentDetailHistories = new ArrayList<>(); | |
215 | - for (ShipmentDetail item : shipmentDetails) { | |
216 | - ShipmentDetailHistory shipmentDetailHistory = new ShipmentDetailHistory(); | |
217 | - BeanUtils.copyProperties(shipmentDetailHistory, item); | |
218 | - shipmentDetailHistories.add(shipmentDetailHistory); | |
219 | - } | |
220 | - Boolean flag = shipmentDetailHistoryService.saveBatch(shipmentDetailHistories); | |
221 | - if (flag == false) { | |
222 | - throw new ServiceException("存入历史出库子单失败"); | |
223 | - } | |
212 | + //历史出库子单 | |
213 | + List<ShipmentDetailHistory> shipmentDetailHistories = new ArrayList<>(); | |
214 | + for (ShipmentDetail item : shipmentDetails) { | |
215 | + ShipmentDetailHistory shipmentDetailHistory = new ShipmentDetailHistory(); | |
216 | + BeanUtils.copyProperties(shipmentDetailHistory, item); | |
217 | + shipmentDetailHistories.add(shipmentDetailHistory); | |
218 | + } | |
219 | + Boolean flag = shipmentDetailHistoryService.saveBatch(shipmentDetailHistories); | |
220 | + if (flag == false) { | |
221 | + throw new ServiceException("存入历史出库子单失败"); | |
222 | + } | |
224 | 223 | return null; |
225 | 224 | } |
226 | 225 | |
227 | - /**审核出库单,加入订单池 | |
226 | + /** | |
227 | + * 审核出库单,加入订单池 | |
228 | 228 | * 1、找到主单,确定主单的状态是否小于100 |
229 | 229 | * 2.小于100时,把主单和相应的子单加入到list中,大于等于100时,直接跳过 |
230 | 230 | * 3.将修改后的主单列表和子单列表进行修改,加入订单池 |
... | ... | @@ -234,53 +234,53 @@ public class ShipmentHeaderServiceImpl extends ServiceImpl<ShipmentHeaderMapper, |
234 | 234 | */ |
235 | 235 | |
236 | 236 | @Override |
237 | - @Transactional | |
237 | + @Transactional(rollbackFor = Exception.class) | |
238 | 238 | public AjaxResult review(String ids) { |
239 | 239 | |
240 | 240 | List<ShipmentHeader> shipmentHeaders = new ArrayList<>(); |
241 | 241 | List<ShipmentDetail> shipmentDetails = new ArrayList<>(); |
242 | 242 | |
243 | 243 | //1、找到主单,确定主单的状态是否小于100 |
244 | - for (Integer id : Convert.toIntArray(ids)){ | |
244 | + for (Integer id : Convert.toIntArray(ids)) { | |
245 | 245 | ShipmentHeader shipmentHeader = this.getById(id); |
246 | - if(shipmentHeader == null){ | |
247 | - return AjaxResult.error("id为"+id+"的主单在系统不存在"); | |
246 | + if (shipmentHeader == null) { | |
247 | + return AjaxResult.error("id为" + id + "的主单在系统不存在"); | |
248 | 248 | } |
249 | 249 | |
250 | 250 | //2.小于100时,把主单和相应的子单加入到list中,大于等于100时,直接跳过 |
251 | - if(shipmentHeader.getFirstStatus() < QuantityConstant.SHIPMENT_HEADER_POOL && shipmentHeader.getLastStatus() <QuantityConstant.SHIPMENT_HEADER_POOL){ | |
251 | + if (shipmentHeader.getFirstStatus() < QuantityConstant.SHIPMENT_HEADER_POOL && shipmentHeader.getLastStatus() < QuantityConstant.SHIPMENT_HEADER_POOL) { | |
252 | 252 | shipmentHeader.setFirstStatus(QuantityConstant.SHIPMENT_HEADER_POOL); |
253 | 253 | shipmentHeader.setLastStatus(QuantityConstant.SHIPMENT_HEADER_POOL); |
254 | 254 | shipmentHeaders.add(shipmentHeader); |
255 | 255 | |
256 | 256 | LambdaQueryWrapper<ShipmentDetail> lam = Wrappers.lambdaQuery(); |
257 | - lam.eq(ShipmentDetail::getShipmentId,id) | |
258 | - .eq(ShipmentDetail::getWarehouseCode,ShiroUtils.getWarehouseCode()); | |
257 | + lam.eq(ShipmentDetail::getShipmentId, id) | |
258 | + .eq(ShipmentDetail::getWarehouseCode, ShiroUtils.getWarehouseCode()); | |
259 | 259 | List<ShipmentDetail> shipmentDetailList = shipmentDetailService.list(lam); |
260 | - if(!shipmentDetailList.isEmpty()){ | |
261 | - for(ShipmentDetail shipmentDetail : shipmentDetailList){ | |
260 | + if (!shipmentDetailList.isEmpty()) { | |
261 | + for (ShipmentDetail shipmentDetail : shipmentDetailList) { | |
262 | 262 | shipmentDetail.setStatus(QuantityConstant.SHIPMENT_HEADER_POOL); |
263 | 263 | } |
264 | 264 | shipmentDetails.addAll(shipmentDetailList); |
265 | - }else { | |
266 | - return AjaxResult.error("id为"+id+"的出库明细在系统不存在"); | |
265 | + } else { | |
266 | + return AjaxResult.error("id为" + id + "的出库明细在系统不存在"); | |
267 | 267 | } |
268 | 268 | } |
269 | 269 | } |
270 | 270 | |
271 | - if(shipmentHeaders.isEmpty()){ | |
271 | + if (shipmentHeaders.isEmpty()) { | |
272 | 272 | return AjaxResult.error("选中的单据不需要订单审核"); |
273 | 273 | } |
274 | - if(shipmentDetails.isEmpty()){ | |
274 | + if (shipmentDetails.isEmpty()) { | |
275 | 275 | return AjaxResult.error("选中的单据不需要订单审核或没有子单"); |
276 | 276 | } |
277 | 277 | // 3.将修改后的主单列表和子单列表进行修改,加入订单池 |
278 | 278 | Boolean flag = this.updateBatchById(shipmentHeaders); |
279 | - if (flag == false){ | |
279 | + if (flag == false) { | |
280 | 280 | throw new ServiceException("修改主单状态失败"); |
281 | 281 | } |
282 | 282 | flag = shipmentDetailService.updateBatchById(shipmentDetails); |
283 | - if (flag == false){ | |
283 | + if (flag == false) { | |
284 | 284 | throw new ServiceException("修改明细状态失败"); |
285 | 285 | } |
286 | 286 | return AjaxResult.success("订单审核成功,成功加入订单池"); |
... | ... |
src/main/java/com/huaheng/pc/task/taskDetail/service/TaskDetailServiceImpl.java
... | ... | @@ -20,6 +20,7 @@ import com.huaheng.pc.inventory.cycleCountDetail.service.CycleCountDetailService |
20 | 20 | import com.huaheng.pc.task.taskHeader.domain.TaskHeader; |
21 | 21 | import com.huaheng.pc.task.taskHeader.service.TaskHeaderService; |
22 | 22 | import org.springframework.stereotype.Service; |
23 | + | |
23 | 24 | import javax.annotation.Resource; |
24 | 25 | import java.util.ArrayList; |
25 | 26 | import java.util.List; |
... | ... | @@ -30,7 +31,7 @@ import com.huaheng.pc.task.taskDetail.domain.TaskDetail; |
30 | 31 | import org.springframework.transaction.annotation.Transactional; |
31 | 32 | |
32 | 33 | @Service |
33 | -public class TaskDetailServiceImpl extends ServiceImpl<TaskDetailMapper, TaskDetail> implements TaskDetailService{ | |
34 | +public class TaskDetailServiceImpl extends ServiceImpl<TaskDetailMapper, TaskDetail> implements TaskDetailService { | |
34 | 35 | |
35 | 36 | |
36 | 37 | @Resource |
... | ... | @@ -50,23 +51,24 @@ public class TaskDetailServiceImpl extends ServiceImpl<TaskDetailMapper, TaskDet |
50 | 51 | |
51 | 52 | /** |
52 | 53 | * 盘点任务首选项 |
54 | + * | |
53 | 55 | * @param taskDetailList |
54 | 56 | * @return |
55 | 57 | */ |
56 | - @Transactional | |
58 | + @Transactional(rollbackFor = Exception.class) | |
57 | 59 | @Override |
58 | 60 | public List<TaskDetail> preferenceRealize(List<TaskDetail> taskDetailList) { |
59 | 61 | /*查出盘点明细,找出盘点首选项,根据首选项显示字段*/ |
60 | 62 | List<TaskDetail> taskDetails = new ArrayList<>(); |
61 | 63 | |
62 | - for (TaskDetail item:taskDetailList){ | |
64 | + for (TaskDetail item : taskDetailList) { | |
63 | 65 | //盘点明细 |
64 | 66 | CycleCountDetail cycleCountDetailtemp = new CycleCountDetail(); |
65 | 67 | cycleCountDetailtemp.setCycleCountHeadCode(item.getBillCode()); |
66 | 68 | cycleCountDetailtemp.setId(item.getBillDetailId()); |
67 | 69 | LambdaQueryWrapper<CycleCountDetail> detailLambdaQueryWrapper = Wrappers.lambdaQuery(cycleCountDetailtemp); |
68 | 70 | CycleCountDetail cycleCountDetail = cycleCountDetailService.getOne(detailLambdaQueryWrapper); |
69 | - if(cycleCountDetail == null){ | |
71 | + if (cycleCountDetail == null) { | |
70 | 72 | throw new SecurityException("没有找到子任务对应的盘点明细!"); |
71 | 73 | } |
72 | 74 | //找盘点首选项 |
... | ... | @@ -75,27 +77,27 @@ public class TaskDetailServiceImpl extends ServiceImpl<TaskDetailMapper, TaskDet |
75 | 77 | cycleCountPreferenceTemp.setWarehouseCode(cycleCountDetail.getWarehouseCode()); |
76 | 78 | LambdaQueryWrapper<CycleCountPreference> preferenceLambdaQueryWrapper = Wrappers.lambdaQuery(cycleCountPreferenceTemp); |
77 | 79 | CycleCountPreference cycleCountPreference = cycleCountPreferenceService.getOne(preferenceLambdaQueryWrapper); |
78 | - if(cycleCountPreference == null){ | |
80 | + if (cycleCountPreference == null) { | |
79 | 81 | throw new SecurityException("没有找到盘点首选项!"); |
80 | 82 | } |
81 | 83 | //根据首选项判断数据 |
82 | - if(cycleCountPreference.getPromptLocation() == false){ | |
84 | + if (cycleCountPreference.getPromptLocation() == false) { | |
83 | 85 | //库位 |
84 | 86 | item.setFromLocation(""); |
85 | 87 | item.setToLocation(""); |
86 | 88 | } |
87 | - if(cycleCountPreference.getPromptLpn() == false){ | |
89 | + if (cycleCountPreference.getPromptLpn() == false) { | |
88 | 90 | //容器 |
89 | 91 | item.setContainerCode(""); |
90 | 92 | } |
91 | - if(cycleCountPreference.getPromptItem() == false){ | |
93 | + if (cycleCountPreference.getPromptItem() == false) { | |
92 | 94 | //物料 |
93 | 95 | item.setMaterialCode(""); |
94 | 96 | item.setMaterialName(""); |
95 | 97 | item.setMaterialUnit(""); |
96 | 98 | item.setMaterialSpec(""); |
97 | 99 | } |
98 | - if(cycleCountPreference.getPromptQuantity() == false){ | |
100 | + if (cycleCountPreference.getPromptQuantity() == false) { | |
99 | 101 | //系统数量 |
100 | 102 | item.setQty(null); |
101 | 103 | } |
... | ... | @@ -107,6 +109,7 @@ public class TaskDetailServiceImpl extends ServiceImpl<TaskDetailMapper, TaskDet |
107 | 109 | /** |
108 | 110 | * 任务位置拣货单打印 |
109 | 111 | * 根据任务头表id查询任务明细,根据上架或拣货货规则排序 |
112 | + * | |
110 | 113 | * @param ids 头表id数组 |
111 | 114 | * @return |
112 | 115 | */ |
... | ... | @@ -130,12 +133,12 @@ public class TaskDetailServiceImpl extends ServiceImpl<TaskDetailMapper, TaskDet |
130 | 133 | } |
131 | 134 | //Integer数组转object数组 |
132 | 135 | Object[] objects = new Object[ids.length]; |
133 | - try{ | |
134 | - for(int i = 0; i < ids.length ; i++){ | |
135 | - Object a = (ids[i]); | |
136 | + try { | |
137 | + for (int i = 0; i < ids.length; i++) { | |
138 | + Object a = (ids[i]); | |
136 | 139 | objects[i] = a; |
137 | 140 | } |
138 | - }catch (Exception e){ | |
141 | + } catch (Exception e) { | |
139 | 142 | throw new ServiceException(e.toString()); |
140 | 143 | } |
141 | 144 | LambdaQueryWrapper<TaskDetail> queryWrapper = Wrappers.lambdaQuery(); |
... | ... | @@ -147,6 +150,7 @@ public class TaskDetailServiceImpl extends ServiceImpl<TaskDetailMapper, TaskDet |
147 | 150 | |
148 | 151 | /** |
149 | 152 | * 根据任务头表id查询任务明细 |
153 | + * | |
150 | 154 | * @param id |
151 | 155 | * @return |
152 | 156 | */ |
... | ... |