Commit 63db9f141f975d16fe980cd768476db4d37f2335
1 parent
b0b25e24
fix:srm送货单提交t100接口优化;
Showing
6 changed files
with
122 additions
and
8 deletions
src/main/java/com/huaheng/api/srm/service/SrmReceiptServiceImpl.java
... | ... | @@ -415,13 +415,13 @@ public class SrmReceiptServiceImpl implements SrmReceiptService{ |
415 | 415 | |
416 | 416 | List<SrmDetail> srmDetails=new ArrayList<>(); |
417 | 417 | int a=0; |
418 | - List<SrmDetail> filteredList = details.stream() | |
419 | - .filter(detail -> detail.getQualifiedQty().compareTo(new BigDecimal(0))>0) | |
420 | - .collect(Collectors.toList()); | |
421 | - if(filteredList==null||filteredList.size()==0){ | |
422 | - return AjaxResult.error("数据为空"); | |
423 | - } | |
424 | - for (SrmDetail srmDetail:filteredList){ | |
418 | +// List<SrmDetail> filteredList = details.stream() | |
419 | +// .filter(detail -> detail.getQualifiedQty().compareTo(new BigDecimal(0))>0) | |
420 | +// .collect(Collectors.toList()); | |
421 | +// if(filteredList==null||filteredList.size()==0){ | |
422 | +// return AjaxResult.success("数据为空"); | |
423 | +// } | |
424 | + for (SrmDetail srmDetail:details){ | |
425 | 425 | a++; |
426 | 426 | ErpReceiptDetail erpReceiptDetail=new ErpReceiptDetail(); |
427 | 427 | erpReceiptDetail.setQty(srmDetail.getQualifiedQty()); |
... | ... | @@ -456,8 +456,11 @@ public class SrmReceiptServiceImpl implements SrmReceiptService{ |
456 | 456 | erpReceipt.setReceiptDetailList(erpReceiptDetailList); |
457 | 457 | |
458 | 458 | SrmHeader srmHeaderB=srmHeaderService.getById(srmHeader.getId()); |
459 | + if(srmHeaderB==null){ | |
460 | + return AjaxResult.success("数据为空"); | |
461 | + } | |
459 | 462 | SrmHeader srmHeader1=new SrmHeader(); |
460 | - srmHeader1.setId(srmHeader.getId()); | |
463 | + srmHeader1.setId(srmHeaderB.getId()); | |
461 | 464 | if(StringUtils.isNotEmpty(srmHeaderB.getUserDef2())){ |
462 | 465 | srmHeader1.setUserDef2(srmHeaderB.getUserDef2()+","+referCode); |
463 | 466 | }else{ |
... | ... |
src/main/java/com/huaheng/pc/srm/controller/SRMHeaderController.java
... | ... | @@ -40,6 +40,7 @@ import org.springframework.web.bind.annotation.RequestMapping; |
40 | 40 | import org.springframework.web.bind.annotation.ResponseBody; |
41 | 41 | |
42 | 42 | import javax.annotation.Resource; |
43 | +import java.text.ParseException; | |
43 | 44 | import java.util.ArrayList; |
44 | 45 | import java.util.List; |
45 | 46 | import java.util.stream.Collectors; |
... | ... | @@ -353,4 +354,28 @@ public class SRMHeaderController extends BaseController { |
353 | 354 | } |
354 | 355 | return AjaxResult.success("删除成功!"); |
355 | 356 | } |
357 | + /** | |
358 | + * 生成到货单 | |
359 | + */ | |
360 | + @RequiresPermissions("srm:srmHeader:getReceipt") | |
361 | + @Log(title = "送货单-送货单", operating= "生成到货单", action = BusinessType.DELETE) | |
362 | + @PostMapping( "/saveSrmReceipt") | |
363 | + @ResponseBody | |
364 | + public AjaxResult saveSrmReceipt(String ids) { | |
365 | + if (StringUtils.isEmpty(ids)){ | |
366 | + return AjaxResult.error("id不能为空"); | |
367 | + } | |
368 | + String[] idss = ids.split(","); | |
369 | + for (String s : idss) { | |
370 | + AjaxResult ajaxResult = handleMultiProcessV1("saveSrmReceipt", new MultiProcessListener() { | |
371 | + @Override | |
372 | + public AjaxResult doProcess() { | |
373 | + List<SrmDetail> list = srmDetailService.list(new LambdaQueryWrapper<SrmDetail>().eq(SrmDetail::getHeaderId, s)); | |
374 | + AjaxResult ajaxResult1=srmHeaderService.saveSrmReceipt(list); | |
375 | + return ajaxResult1; | |
376 | + } | |
377 | + }); | |
378 | + } | |
379 | + return AjaxResult.success("成功"); | |
380 | + } | |
356 | 381 | } |
... | ... |
src/main/java/com/huaheng/pc/srm/domain/SrmHeader.java
... | ... | @@ -124,6 +124,9 @@ public class SrmHeader implements Serializable { |
124 | 124 | @ApiModelProperty(value = "") |
125 | 125 | private String userDef1; |
126 | 126 | |
127 | + /** | |
128 | + * t100收货单号,用英文逗号隔开 | |
129 | + */ | |
127 | 130 | @TableField(value = "userDef2") |
128 | 131 | @ApiModelProperty(value = "") |
129 | 132 | private String userDef2; |
... | ... |
src/main/java/com/huaheng/pc/srm/service/SrmDetailService.java
... | ... | @@ -249,6 +249,12 @@ public class SrmDetailService extends ServiceImpl<SrmDetailMapper, SrmDetail> { |
249 | 249 | if(icspoArrives==null||icspoArrives.size()==0){ |
250 | 250 | return AjaxResult.error("没有符合规定的送货单,请检查是否质检"); |
251 | 251 | } |
252 | + icspoArrives= icspoArrives.stream() | |
253 | + .filter(detail1 -> detail1.getQualifiedQty().compareTo(new BigDecimal(0))>0) | |
254 | + .collect(Collectors.toList()); | |
255 | + if(icspoArrives==null||icspoArrives.size()==0){ | |
256 | + return AjaxResult.error("没有符合规定的送货单,请检查是否质检"); | |
257 | + } | |
252 | 258 | //过滤分开srmheader |
253 | 259 | List<String> codes = icspoArrives.stream().map(SrmDetail::getPurchaseCode).distinct().collect(Collectors.toList()); |
254 | 260 | for (String code:codes) { |
... | ... |
src/main/java/com/huaheng/pc/srm/service/SrmHeaderService.java
... | ... | @@ -1056,6 +1056,12 @@ public class SrmHeaderService extends ServiceImpl<SrmHeaderMapper, SrmHeader> { |
1056 | 1056 | throw new ServiceException("已提交U8,不用重复提交"); |
1057 | 1057 | } |
1058 | 1058 | SrmHeader srmHeader = this.getOne(new LambdaQueryWrapper<SrmHeader>().eq(SrmHeader::getCode, srmDetails.get(0).getCode()).eq(SrmHeader::getWarehouseCode, ShiroUtils.getWarehouseCode())); |
1059 | + icspoArrives= icspoArrives.stream() | |
1060 | + .filter(detail -> detail.getQualifiedQty().compareTo(new BigDecimal(0))>0) | |
1061 | + .collect(Collectors.toList()); | |
1062 | + if(icspoArrives==null||icspoArrives.size()==0){ | |
1063 | + return AjaxResult.error("数据合格为空,不用提交t100"); | |
1064 | + } | |
1059 | 1065 | //SRM提示到货失败的需要去定时任务 |
1060 | 1066 | if(!icspoArrives.isEmpty()){ |
1061 | 1067 | List<String> codes = icspoArrives.stream().map(SrmDetail::getPurchaseCode).distinct().collect(Collectors.toList()); |
... | ... | @@ -1407,6 +1413,12 @@ public class SrmHeaderService extends ServiceImpl<SrmHeaderMapper, SrmHeader> { |
1407 | 1413 | if(icspoArrives==null||icspoArrives.size()==0){ |
1408 | 1414 | return AjaxResult.error("没有符合规定的送货单,请检查是否质检"); |
1409 | 1415 | } |
1416 | + icspoArrives= icspoArrives.stream() | |
1417 | + .filter(detail1 -> detail1.getQualifiedQty().compareTo(new BigDecimal(0))>0) | |
1418 | + .collect(Collectors.toList()); | |
1419 | + if(icspoArrives==null||icspoArrives.size()==0){ | |
1420 | + return AjaxResult.error("没有符合规定的送货单,请检查是否质检"); | |
1421 | + } | |
1410 | 1422 | List<String> codess = icspoArrives.stream().map(SrmDetail::getPurchaseCode).distinct().collect(Collectors.toList()); |
1411 | 1423 | for (String code:codess) { |
1412 | 1424 | if(StringUtils.isEmpty(code)){ |
... | ... | @@ -1715,4 +1727,42 @@ public class SrmHeaderService extends ServiceImpl<SrmHeaderMapper, SrmHeader> { |
1715 | 1727 | } |
1716 | 1728 | return AjaxResult.success("删除成功"); |
1717 | 1729 | } |
1730 | + | |
1731 | + @Transactional(rollbackFor = Exception.class) | |
1732 | + public AjaxResult saveSrmReceipt(List<SrmDetail> srmDetails) { | |
1733 | + if (srmDetails.isEmpty()) { | |
1734 | + return AjaxResult.error("请勿提交空数据!"); | |
1735 | + } | |
1736 | + List<SrmDetail> srmDetailList = new ArrayList<>(); | |
1737 | + for (SrmDetail srmDetail : srmDetails) { | |
1738 | + if ((srmDetail.getQualifiedQty().compareTo(new BigDecimal(0))>0||srmDetail.getUnqualifiedQty().compareTo(new BigDecimal(0))>0) && srmDetail.getEnable() == 1) { | |
1739 | + srmDetailList.add(srmDetail); | |
1740 | + } | |
1741 | + } | |
1742 | + | |
1743 | + SrmHeader srmHeader = this.getOne(new LambdaQueryWrapper<SrmHeader>().eq(SrmHeader::getCode, srmDetails.get(0).getCode()).eq(SrmHeader::getWarehouseCode, ShiroUtils.getWarehouseCode())); | |
1744 | + //SRM提示到货失败的需要去定时任务 | |
1745 | + AjaxResult ajaxResult1 =AjaxResult.success("送货单提交成功!"); | |
1746 | + if (!srmDetailList.isEmpty()) { | |
1747 | + List<String> codes = srmDetailList.stream().map(SrmDetail::getPurchaseCode).distinct().collect(Collectors.toList()); | |
1748 | + for (String code : codes) { | |
1749 | + if(StringUtils.isEmpty(code)){ | |
1750 | + continue; | |
1751 | + } | |
1752 | + List<SrmDetail> srmDetailPurchase = srmDetailList.stream().filter(srmDetaill -> srmDetaill.getPurchaseCode().equals(code)).collect(Collectors.toList()); | |
1753 | + if (srmDetailPurchase == null || srmDetailPurchase.size() == 0) { | |
1754 | + continue; | |
1755 | + } | |
1756 | + String refercode=srmDetailPurchase.get(0).getReferCode(); | |
1757 | + if(StringUtils.isEmpty(refercode)){ | |
1758 | + continue; | |
1759 | + } | |
1760 | + ajaxResult1 = srmReceiptService.addWmsReceiptSrm(srmDetailPurchase, srmHeader, refercode); | |
1761 | + if (ajaxResult1 != null && ajaxResult1.hasErr()) { | |
1762 | + continue; | |
1763 | + } | |
1764 | + } | |
1765 | + } | |
1766 | + return ajaxResult1; | |
1767 | + } | |
1718 | 1768 | } |
... | ... |
src/main/resources/templates/srm/srmHeader/srmHeader.html
... | ... | @@ -87,6 +87,10 @@ |
87 | 87 | shiro:hasPermission="srm:srmHeader:list"> |
88 | 88 | <i class="fa fa-paper-plane"></i> 获取ERP到货单 |
89 | 89 | </a> |
90 | + <a id="submit3" class="btn btn-outline btn-success btn-rounded" onclick="saveBatchReceipt()" | |
91 | + shiro:hasPermission="srm:srmDetail:saveReceipt"> | |
92 | + <i class="fa fa-paper-plane"></i> 生成ERP到货单 | |
93 | + </a> | |
90 | 94 | </div> |
91 | 95 | <input type="hidden" id="headerId" name="headerId" th:value="${headerId}"/> |
92 | 96 | <table id="bootstrap-table" data-mobile-responsive="true" |
... | ... | @@ -98,6 +102,7 @@ |
98 | 102 | shiro:hasPermission="srm:srmDetail:confirm"> |
99 | 103 | <i class="fa fa-paper-plane"></i> 获取ERP到货单(可多选) |
100 | 104 | </a> |
105 | + | |
101 | 106 | <a class="btn btn-outline btn-danger btn-rounded" onclick="batRemove()" |
102 | 107 | shiro:hasPermission="srm:srmDetail:edit"> |
103 | 108 | <i class="fa fa-trash-o"></i> 删除 |
... | ... | @@ -682,6 +687,7 @@ |
682 | 687 | }) |
683 | 688 | } |
684 | 689 | |
690 | + | |
685 | 691 | /*提交*/ |
686 | 692 | function confirm() { |
687 | 693 | var rows = $("#bootstrap-table2").bootstrapTable('getSelections') |
... | ... | @@ -943,6 +949,27 @@ |
943 | 949 | }) |
944 | 950 | } |
945 | 951 | } |
952 | + | |
953 | + function saveBatchReceipt() { | |
954 | + if (new Date().getTime() - resubmit > 2000) { | |
955 | + resubmit = new Date().getTime() | |
956 | + var rows = $("#bootstrap-table").bootstrapTable('getSelections'); | |
957 | + if (rows.length == 0) { | |
958 | + $.modal.alertWarning("请至少选择一条记录"); | |
959 | + return; | |
960 | + } | |
961 | + $.modal.confirm("确认执行选中的" + rows.length + "条数据吗?", function () { | |
962 | + var url = prefix + '/saveSrmReceipt'; | |
963 | + var ids = ""; | |
964 | + for (var i = 0; i < rows.length; i++) { | |
965 | + ids = ids + rows[i].id + "," | |
966 | + } | |
967 | + var data = {"ids": ids.substring(0, ids.length - 1)}; | |
968 | + $.operate.submit(url, "post", "json", data); | |
969 | + }) | |
970 | + } | |
971 | + | |
972 | + } | |
946 | 973 | </script> |
947 | 974 | </body> |
948 | 975 | </html> |
... | ... |