From 31ee3ad1f501f72f8a7aacabd4e0d427fc6110e7 Mon Sep 17 00:00:00 2001 From: mrzhssss <pro6@qq.com> Date: 星期二, 22 三月 2022 09:38:39 +0800 Subject: [PATCH] # --- src/main/java/zy/cloud/wms/manager/controller/WaveController.java | 15 ++ src/main/webapp/static/js/wave/wave.js | 77 ++++++++++++++ src/main/java/zy/cloud/wms/manager/service/impl/WaveServiceImpl.java | 10 + src/main/webapp/views/wave/wave.html | 7 + src/main/java/zy/cloud/wms/manager/service/impl/WorkServiceImpl.java | 37 +++++++ src/main/java/zy/cloud/wms/manager/service/WorkService.java | 2 src/main/java/zy/cloud/wms/common/model/WaveStoDto.java | 33 ++++++ src/main/java/zy/cloud/wms/manager/service/WaveService.java | 3 src/main/java/zy/cloud/wms/common/service/MainService.java | 76 +++++++++++++++ 9 files changed, 253 insertions(+), 7 deletions(-) diff --git a/src/main/java/zy/cloud/wms/common/model/WaveStoDto.java b/src/main/java/zy/cloud/wms/common/model/WaveStoDto.java new file mode 100644 index 0000000..8a49715 --- /dev/null +++ b/src/main/java/zy/cloud/wms/common/model/WaveStoDto.java @@ -0,0 +1,33 @@ +package zy.cloud.wms.common.model; + +import lombok.Data; +import zy.cloud.wms.manager.entity.OrderDetl; +import zy.cloud.wms.manager.entity.WaveDetl; + +import java.util.ArrayList; +import java.util.List; + +@Data +public class WaveStoDto { + + private String orderNo; + + private List<MatnrDto> dtos; + + public WaveStoDto() { + } + + public WaveStoDto create(String id, List<WaveDetl> orderDetls){ + this.setOrderNo(id); + List<MatnrDto> matnrDtos = new ArrayList<>(); + for (WaveDetl waveDetl : orderDetls) { + MatnrDto matnrDto = new MatnrDto(); + matnrDto.setMatnr(waveDetl.getMatnr()); + matnrDto.setCount(waveDetl.getAnfme()); + matnrDto.setBatch(waveDetl.getBatch()); + matnrDtos.add(matnrDto); + } + this.setDtos(matnrDtos); + return this; + } +} diff --git a/src/main/java/zy/cloud/wms/common/service/MainService.java b/src/main/java/zy/cloud/wms/common/service/MainService.java index 1ee698d..d3e184d 100644 --- a/src/main/java/zy/cloud/wms/common/service/MainService.java +++ b/src/main/java/zy/cloud/wms/common/service/MainService.java @@ -10,6 +10,7 @@ import zy.cloud.wms.common.model.MatnrDto; import zy.cloud.wms.common.model.OrderStoDto; import zy.cloud.wms.common.model.ReceiveStoDto; +import zy.cloud.wms.common.model.WaveStoDto; import zy.cloud.wms.common.utils.VersionUtils; import zy.cloud.wms.manager.entity.*; import zy.cloud.wms.manager.service.*; @@ -503,4 +504,79 @@ } } } + + public Object waveOutPreview(WaveStoDto waveStoDto, Long hostId) { + if (Cools.isEmpty(waveStoDto) || Cools.isEmpty(waveStoDto.getDtos())) { + throw new CoolException("鏁版嵁寮傚父锛岃鑱旂郴绠$悊鍛�"); + } + List<StoPreTab> res = new ArrayList<>(); + // 妫�鏌ュ簱瀛樻槸鍚﹁冻澶� +// locDetlService.checkLocDetlCount(orderStoDto.getDtos()); + + for (MatnrDto matnrDto : waveStoDto.getDtos()) { + // 鍒ゆ柇鐗╂枡鏄惁瀛樺湪 + Mat mat = matService.selectByMatnr(hostId, matnrDto.getMatnr()); + if (null == mat) { + throw new CoolException(matnrDto.getMatnr() + "鐗╂枡灏氭湭鏇存柊銆�" + waveStoDto.getOrderNo() +"鍗曟嵁鍥犳涓柇锛�"); + } + + Double sumAnfme = Optional.ofNullable(locDetlService.selectCountByMatnr(mat.getMatnr(), hostId)).orElse(0.0D); + double lack = 0.0D; + // 缂鸿揣 + if (sumAnfme < matnrDto.getCount()) { + lack = matnrDto.getCount() - sumAnfme; + // 瑙嗗浘瀵硅薄 + StoPreTab tab = new StoPreTab(); + tab.setTitle(mat.getMaktx() + "锛�" + mat.getMatnr() + "锛�"); + tab.setMatnr(mat.getMatnr()); + tab.setMaktx(mat.getMaktx()); + tab.setAnfme(matnrDto.getCount()); + tab.setLocNo("缂鸿揣"); + tab.setTotal(lack); + tab.setReduce(lack); + tab.setRemQty(0.0D); + tab.setPrior(false); + tab.setPrior$("脳"); + tab.setType(0); + res.add(tab); + } + + // 鏌ヨ瀛樻湁褰撳墠鐗╂枡鐨勮揣浣� + List<LocDetl> locDetls = locDetlService.findOfSort(hostId, mat.getMatnr()); + double issued = Optional.of(matnrDto.getCount() - lack).orElse(0.0D) ; + double anfme = issued; + for (LocDetl locDetl : locDetls) { + if (issued > 0) { + // 瑙嗗浘瀵硅薄 + StoPreTab tab = new StoPreTab(); + tab.setTitle(mat.getMaktx() + "锛�" + mat.getMatnr() + "锛�"); + tab.setMatnr(mat.getMatnr()); + tab.setMaktx(mat.getMaktx()); + tab.setAnfme(matnrDto.getCount()); + + 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(locDetlService.isPrior(locDetl.getNodeId(), mat.getMatnr())); + tab.setPrior$(tab.getPrior()?"鉁�":"脳"); + tab.setType(1); + res.add(tab); + // 鍓╀綑寰呭嚭鏁伴噺閫掑噺 + issued = issued - locDetl.getAnfme(); + } + } + + } + res.sort(new Comparator<StoPreTab>() { + @Override + public int compare(StoPreTab o1, StoPreTab o2) { +// return o1.getMatnr().length() - o2.getMatnr().length(); + return (int) (o1.getAnfme() - o2.getAnfme()); + } + }); + return res; + + } } diff --git a/src/main/java/zy/cloud/wms/manager/controller/WaveController.java b/src/main/java/zy/cloud/wms/manager/controller/WaveController.java index 2f34179..3982916 100644 --- a/src/main/java/zy/cloud/wms/manager/controller/WaveController.java +++ b/src/main/java/zy/cloud/wms/manager/controller/WaveController.java @@ -8,6 +8,7 @@ import com.core.common.DateUtils; import zy.cloud.wms.manager.entity.Wave; import zy.cloud.wms.manager.entity.WaveDetl; +import zy.cloud.wms.manager.entity.param.StockOutParam; import zy.cloud.wms.manager.service.OrderService; import zy.cloud.wms.manager.service.WaveDetlService; import zy.cloud.wms.manager.service.WaveService; @@ -18,8 +19,10 @@ import zy.cloud.wms.common.web.BaseController; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import zy.cloud.wms.manager.service.WorkService; import java.util.*; + @RestController public class WaveController extends BaseController { @@ -30,6 +33,8 @@ private WaveDetlService waveDetlService; @Autowired private OrderService orderService; + @Autowired + private WorkService workService; @RequestMapping(value = "/wave/{id}/auth") @ManagerAuth @@ -158,8 +163,14 @@ @RequestMapping("/wave/createOut") @ManagerAuth public R createWaveOut(@RequestBody Wave wave){ - waveService.createOut(wave,getUserId(),getHostId()); - return R.ok(); + + return waveService.createOut(wave,getUserId(),getHostId()); + } + + @RequestMapping("/wave/preview") + @ManagerAuth + public R createWavePreview(@RequestBody StockOutParam stockOutParam){ + return workService.wavePreview(stockOutParam, getUserId(), getHostId()); } } diff --git a/src/main/java/zy/cloud/wms/manager/service/WaveService.java b/src/main/java/zy/cloud/wms/manager/service/WaveService.java index 9030a70..fa52561 100644 --- a/src/main/java/zy/cloud/wms/manager/service/WaveService.java +++ b/src/main/java/zy/cloud/wms/manager/service/WaveService.java @@ -1,9 +1,10 @@ package zy.cloud.wms.manager.service; +import com.core.common.R; import zy.cloud.wms.manager.entity.Wave; import com.baomidou.mybatisplus.service.IService; public interface WaveService extends IService<Wave> { - void createOut(Wave wave, Long userId, Long hostId); + R createOut(Wave wave, Long userId, Long hostId); } diff --git a/src/main/java/zy/cloud/wms/manager/service/WorkService.java b/src/main/java/zy/cloud/wms/manager/service/WorkService.java index 0b09670..8c0691c 100644 --- a/src/main/java/zy/cloud/wms/manager/service/WorkService.java +++ b/src/main/java/zy/cloud/wms/manager/service/WorkService.java @@ -42,4 +42,6 @@ R stockCheckAuditing(Long checkId, Long userId, Long hostId); R initOutOrder(InitOrderParam param, Long userId, Long hostId); + + R wavePreview(StockOutParam stockOutParam, Long userId, Long hostId); } diff --git a/src/main/java/zy/cloud/wms/manager/service/impl/WaveServiceImpl.java b/src/main/java/zy/cloud/wms/manager/service/impl/WaveServiceImpl.java index 841a1cb..cdce31c 100644 --- a/src/main/java/zy/cloud/wms/manager/service/impl/WaveServiceImpl.java +++ b/src/main/java/zy/cloud/wms/manager/service/impl/WaveServiceImpl.java @@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.core.common.Cools; +import com.core.common.R; import com.core.exception.CoolException; import org.springframework.beans.factory.annotation.Autowired; import zy.cloud.wms.manager.entity.WaveDetl; @@ -33,7 +34,7 @@ * @param hostId */ @Override - public void createOut(Wave wave, Long userId, Long hostId) { + public R createOut(Wave wave, Long userId, Long hostId) { HashSet<String> orderIds = new HashSet<>(); /** * 鎺х @@ -63,5 +64,12 @@ wave.setStatus((short) 1); waveService.update(wave,new EntityWrapper<Wave>() .eq("id",wave.getId())); + + /** + * 鐢熸垚鎷h揣鍗� + */ + + + return R.ok(); } } diff --git a/src/main/java/zy/cloud/wms/manager/service/impl/WorkServiceImpl.java b/src/main/java/zy/cloud/wms/manager/service/impl/WorkServiceImpl.java index d167f48..9e5baaf 100644 --- a/src/main/java/zy/cloud/wms/manager/service/impl/WorkServiceImpl.java +++ b/src/main/java/zy/cloud/wms/manager/service/impl/WorkServiceImpl.java @@ -14,6 +14,7 @@ import zy.cloud.wms.common.model.MatnrDto; import zy.cloud.wms.common.model.OrderStoDto; import zy.cloud.wms.common.model.ReceiveStoDto; +import zy.cloud.wms.common.model.WaveStoDto; import zy.cloud.wms.common.service.MainService; import zy.cloud.wms.common.utils.VersionUtils; import zy.cloud.wms.manager.entity.*; @@ -62,6 +63,10 @@ private ReceiveDetlService receiveDetlService; @Autowired ReceiveLogService receiveLogService; + @Autowired + private WaveService waveService; + @Autowired + private WaveDetlService waveDetlService; @Override @@ -1093,4 +1098,36 @@ return R.ok("鍒涘缓璁㈠崟鎴愬姛"); } + @Override + public R wavePreview(StockOutParam stockOutParam, Long userId, Long hostId) { + Wrapper<Wave> wrapper = new EntityWrapper<Wave>() + .eq("id", stockOutParam.getOrderNo()); + + if (hostId != null) { + wrapper.eq("host_id", hostId); + } + Wave wave = waveService.selectOne(wrapper); + + if (wave.getStatus() != 0){ + return R.error("姝ゅ崟鎹棤娉曠敓鎴愭嫞璐у崟"); + } +// Order order = orderService.selectByOrderNo(param.getOrderNo(), hostId); +// if (order.getSettle() != 1) { +// return R.error("姝ゅ崟鎹棤娉曠敓鎴愭嫞璐у崟"); +// } + List<WaveDetl> waveDetls = waveDetlService.selectList(new EntityWrapper<WaveDetl>() + .eq("wave_id", stockOutParam.getOrderNo())); + if (Cools.isEmpty(waveDetls)) { + return R.error("姝ゅ崟鎹凡澶辨晥锛岃鑱旂郴绠$悊鍛�"); + } +// List<OrderDetl> orderDetls = orderDetlService.selectByOrderNo(order.getOrderNo(), hostId); +// if (Cools.isEmpty(orderDetls)) { +// return R.error("姝ゅ崟鎹凡澶辨晥锛岃鑱旂郴绠$悊鍛�"); +// } + + WaveStoDto waveStoDto = new WaveStoDto().create(stockOutParam.getOrderNo(),waveDetls); +// OrderStoDto dto = new OrderStoDto().create(order.getOrderNo(), orderDetls); + return R.ok().add(mainService.waveOutPreview(waveStoDto, hostId)); + } + } diff --git a/src/main/webapp/static/js/wave/wave.js b/src/main/webapp/static/js/wave/wave.js index 776afdc..e78a5f0 100644 --- a/src/main/webapp/static/js/wave/wave.js +++ b/src/main/webapp/static/js/wave/wave.js @@ -1,13 +1,14 @@ var pageCurr; layui.config({ base: baseUrl + "/static/layui/lay/modules/" -}).use(['table','laydate', 'form', 'admin'], function(){ +}).use(['table','laydate', 'form', 'admin','tableMerge'], function(){ var table = layui.table; var $ = layui.jquery; var layer = layui.layer; var layDate = layui.laydate; var form = layui.form; var admin = layui.admin; + var tableMerge = layui.tableMerge; // 鏁版嵁娓叉煋 tableIns = table.render({ @@ -128,7 +129,78 @@ } }); - function createWaveOut(mData) { + function createWaveOut(data) { + console.log(data) + var loadIndex = layer.load(2); + $.ajax({ + url: baseUrl + "/wave/preview", + headers: {'token': localStorage.getItem('token')}, + contentType: 'application/json;charset=UTF-8', + data: JSON.stringify({ + orderNo: data.id + }), + method: 'POST', + success: function (res) { + layer.close(loadIndex); + if (res.code === 200){ + layer.open({ + type: 1 + ,title: false + ,closeBtn: false + ,offset: '100px' + ,area: '1000px' + ,shade: 0.5 + ,shadeClose: true + ,btn: ['绔嬪嵆鐢熸垚', '绋嶅悗澶勭悊'] + ,btnAlign: 'c' + ,moveType: 1 //鎷栨嫿妯″紡锛�0鎴栬��1 + ,content: $('#stoukOutPreview') + ,success: function(layero, index){ + table.render({ + elem: '#stoPreTab', + data: res.data, + page: true, + cellMinWidth: 100, + height: 432, + cols: [[ + {field: 'title', title: '鍟嗗搧', merge: true, align: 'center'}, + {field: 'anfme', title: '鎬绘暟閲�', merge: ['title'], align: 'center', style: 'font-weight: bold', width: 90}, + {field: 'type', title: '浠撳簱', merge: true, align: 'center', templet: '#typeTpl', width: 90}, + {field: 'locNo', title: '璐т綅', align: 'center'}, + {field: 'prior$', title: '鎺ㄨ崘璐т綅', align: 'center', width: 100}, + {field: 'reduce', title: '鏁伴噺', align: 'center', width: 90, style: 'font-weight: bold'}, + // {field: 'remQty', title: '浣欓噺', align: 'center', width: 80}, + {field: 'total', title: '鎬婚噺', align: 'center', width: 90}, + ]], + done: function () { + tableMerge.render(this); + $('.layui-table-body.layui-table-main').css("overflow", "auto") + } + }); + + } + ,yes: function(index, layero){ + //鎸夐挳銆愰┈涓婃嫞璐с�戠殑鍥炶皟 + stockOut(res.data); + } + ,btn2: function(index, layero){ + //鎸夐挳銆愮◢鍚庡鐞嗐�戠殑鍥炶皟 + //return false 寮�鍚浠g爜鍙姝㈢偣鍑昏鎸夐挳鍏抽棴 + } + }); + } else if (res.code === 403){ + top.location.href = baseUrl+"/"; + } else { + layer.msg(res.msg, {icon: 2}) + } + } + }) + + + } + function stockOut(mData){ + + console.log(mData); layer.confirm('纭畾鐢熸垚璇ユ尝娆$殑鎷h揣鍗曪紵', { skin: 'layui-layer-admin', shade: .1 @@ -154,7 +226,6 @@ } }) }); - } // 鐩戝惉琛屽伐鍏蜂簨浠� table.on('tool(wave)', function(obj){ diff --git a/src/main/webapp/views/wave/wave.html b/src/main/webapp/views/wave/wave.html index c59091c..e05449a 100644 --- a/src/main/webapp/views/wave/wave.html +++ b/src/main/webapp/views/wave/wave.html @@ -31,6 +31,13 @@ <div class="layui-form"> <table class="layui-hide" id="wave" lay-filter="wave"></table> </div> +<div id="stoukOutPreview" style="display: none"> + <div style="padding: 25px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;"> + <span style="font-size: large; font-weight: bold">鎷h揣鍗曢瑙�</span> + </div> + <table id="stoPreTab" lay-filter="stoPreTab"></table> +</div> + <script type="text/html" id="toolbar"> <div class="layui-btn-container"> <!-- <button class="layui-btn layui-btn-sm" id="btn-add" lay-event="addData" >鏂板</button>--> -- Gitblit v1.9.1