From 0a58dc2ed7c8349efc4e7dd0b45d8c6ab7e6f9df Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期一, 22 三月 2021 11:07:43 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/controller/OpenController.java | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 56 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/OpenController.java b/src/main/java/com/zy/asrs/controller/OpenController.java index dda44f6..f43c842 100644 --- a/src/main/java/com/zy/asrs/controller/OpenController.java +++ b/src/main/java/com/zy/asrs/controller/OpenController.java @@ -3,8 +3,12 @@ import com.core.common.Cools; import com.core.common.R; import com.core.exception.CoolException; +import com.zy.asrs.entity.LocDetl; +import com.zy.asrs.entity.MatCode; import com.zy.asrs.entity.param.OpenApiStockOutParam; +import com.zy.asrs.entity.result.StoPreTab; import com.zy.asrs.service.LocDetlService; +import com.zy.asrs.service.MatCodeService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.PostMapping; @@ -12,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -24,6 +29,57 @@ @Autowired private LocDetlService locDetlService; + @Autowired + private MatCodeService matCodeService; + + @PostMapping("/stockOut/prew") + @Transactional + public R stockOutPrew(@RequestBody List<OpenApiStockOutParam> params){ + List<StoPreTab> result = new ArrayList<>(); + StringBuilder errorMsg = new StringBuilder(); + boolean error = false; + for (OpenApiStockOutParam param : params) { + Double sumAnfme = Optional.ofNullable(locDetlService.getSumAnfme(param.getMatnr())).orElse(0.0D); + if (sumAnfme < param.getAnfme()) { + if (!error) { + error = true; + } + MatCode mat = matCodeService.selectById(param.getMatnr()); + errorMsg.append(mat == null ? param.getMatnr() : mat.getMatName()).append("搴撳瓨涓嶈冻锛岀己璐ф暟閲忥細").append(param.getAnfme() - sumAnfme).append("</br>"); + continue; + } + List<LocDetl> locDetls = locDetlService.selectPakoutByRule(param.getMatnr()); + double issued = Optional.ofNullable(param.getAnfme()).orElse(0.0D) ; + double anfme = issued; + for (LocDetl locDetl : locDetls) { + if (issued > 0) { + // 瑙嗗浘瀵硅薄 + StoPreTab tab = new StoPreTab(); + tab.setTitle(locDetl.getMatnr() + "锛�" + locDetl.getMaktx() + "锛�"); + tab.setMatnr(locDetl.getMatnr()); + tab.setMaktx(locDetl.getMaktx()); + tab.setAnfme(param.getTotal()); + + tab.setLocNo(locDetl.getLocNo()); +// tab.setNodeId(locDetl.getNodeId()); + tab.setTotal(locDetl.getAnfme()); + tab.setReduce(issued>=locDetl.getAnfme()?locDetl.getAnfme():issued); + tab.setRemQty(tab.getTotal() - tab.getReduce()); + tab.setPrior(false); + tab.setPrior$("脳"); + tab.setType(2); + result.add(tab); + // 鍓╀綑寰呭嚭鏁伴噺閫掑噺 + issued = issued - locDetl.getAnfme(); + } + } + + } + if (error) { + return R.error().add(errorMsg.toString()); + } + return R.ok().add(result); + } @PostMapping("/stockOut") @Transactional -- Gitblit v1.9.1