diff --git a/src/main/java/com/huaheng/pc/config/materialType/service/MaterialTypeService.java b/src/main/java/com/huaheng/pc/config/materialType/service/MaterialTypeService.java index c08bd9e..f7cd661 100644 --- a/src/main/java/com/huaheng/pc/config/materialType/service/MaterialTypeService.java +++ b/src/main/java/com/huaheng/pc/config/materialType/service/MaterialTypeService.java @@ -1,12 +1,21 @@ package com.huaheng.pc.config.materialType.service; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; +import java.util.Map; + import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.huaheng.pc.config.materialType.domain.MaterialType; import com.huaheng.pc.config.materialType.mapper.MaterialTypeMapper; -@Service +@Service("materialType") public class MaterialTypeService extends ServiceImpl<MaterialTypeMapper, MaterialType> { + public List<Map<String, Object>> queryType(){ + LambdaQueryWrapper<MaterialType> lambda = Wrappers.lambdaQuery(); + lambda.select(MaterialType::getCode, MaterialType::getName); + return this.listMaps(lambda); + } } diff --git a/src/main/java/com/huaheng/pc/shipment/shipmentDetail/service/ShipmentDetailServiceImpl.java b/src/main/java/com/huaheng/pc/shipment/shipmentDetail/service/ShipmentDetailServiceImpl.java index fbe805d..fee6620 100644 --- a/src/main/java/com/huaheng/pc/shipment/shipmentDetail/service/ShipmentDetailServiceImpl.java +++ b/src/main/java/com/huaheng/pc/shipment/shipmentDetail/service/ShipmentDetailServiceImpl.java @@ -151,7 +151,12 @@ public class ShipmentDetailServiceImpl extends ServiceImpl<ShipmentDetailMapper, } - //选中的单据加入波次 + /** + * 选中的单据加入波次 + * 根据选中的主单ID和波次主表的code,判断主单之和是否符合波次的限制条件, + * 看此code的波次是否建成未开始执行,如果是则只需修改波次属性,否则创建新的波次, + * 修改加入波次的子单,修改子单和主单的状态,并修改子单的waveId + */ @Override @Transactional public void saveWave(String ids, String code) { @@ -228,14 +233,29 @@ public class ShipmentDetailServiceImpl extends ServiceImpl<ShipmentDetailMapper, } } - //修改出库子单 + //修改出库子单,加入波次ID,并修改状态为波次 for(ShipmentDetail shipmentDetail :shipmentDetailList){ shipmentDetail.setWaveId(wave.getId()); + shipmentDetail.setStatus(200); } flag = this.updateBatchById(shipmentDetailList); if(flag == false){ throw new ServiceException("出库子单加入波次失败"); } + + List<ShipmentHeader> shipmentHeaderList=new ArrayList<>(); + //修改主单状态 + for (Integer id : Convert.toIntArray(ids)){ + ShipmentHeader shipmentHeader = shipmentHeaderService.getById(id); + shipmentHeader.setFirstStatus(200); + shipmentHeader.setLastStatus(200); + shipmentHeaderList.add(shipmentHeader); + } + flag = shipmentHeaderService.updateBatchById(shipmentHeaderList); + if(flag == false){ + throw new ServiceException("修改主单状态失败"); + } + } } diff --git a/src/main/java/com/huaheng/pc/shipment/shipmentHeader/controller/ShipmentHeaderController.java b/src/main/java/com/huaheng/pc/shipment/shipmentHeader/controller/ShipmentHeaderController.java index 76a300f..2ee90b1 100644 --- a/src/main/java/com/huaheng/pc/shipment/shipmentHeader/controller/ShipmentHeaderController.java +++ b/src/main/java/com/huaheng/pc/shipment/shipmentHeader/controller/ShipmentHeaderController.java @@ -272,6 +272,7 @@ public class ShipmentHeaderController extends BaseController } shipmentDetailService.saveWave(ids,code); + return AjaxResult.success("加入波次成功"); } diff --git a/src/main/java/com/huaheng/pc/shipment/wave/controller/WaveController.java b/src/main/java/com/huaheng/pc/shipment/wave/controller/WaveController.java index 75aa9fa..22c9dd0 100644 --- a/src/main/java/com/huaheng/pc/shipment/wave/controller/WaveController.java +++ b/src/main/java/com/huaheng/pc/shipment/wave/controller/WaveController.java @@ -173,4 +173,20 @@ public class WaveController extends BaseController { return result; } + + /** + * 开始波次 + */ + @RequiresPermissions("shipment:wave:freed") + @Log(title = "出库-波次", operating = "开始波次", action = BusinessType.UPDATE) + @PostMapping("/freed") + @ResponseBody + public AjaxResult freed(String ids) { + if (StringUtils.isEmpty(ids)){ + return AjaxResult.error("id不能为空"); + } + AjaxResult result=waveService.freed(ids); + return result; + } + } diff --git a/src/main/java/com/huaheng/pc/shipment/wave/service/WaveService.java b/src/main/java/com/huaheng/pc/shipment/wave/service/WaveService.java index d0bf227..67d171f 100644 --- a/src/main/java/com/huaheng/pc/shipment/wave/service/WaveService.java +++ b/src/main/java/com/huaheng/pc/shipment/wave/service/WaveService.java @@ -3,6 +3,7 @@ package com.huaheng.pc.shipment.wave.service; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.huaheng.common.exception.service.ServiceException; import com.huaheng.common.support.Convert; import com.huaheng.common.utils.security.ShiroUtils; import com.huaheng.framework.web.domain.AjaxResult; @@ -28,12 +29,28 @@ public class WaveService extends ServiceImpl<WaveMapper, Wave> { @Autowired private ShipmentContainerHeaderService shipmentContainerHeaderService; - //开始波次,对带有此波次号的单据进行后续的后台操作 + /** + * 开始波次,对带有此波次号的单据进行后续的后台操作 + * 1、查看波次是否符合开始波次的条件 + * 2、整合波次的所有子单单据 + * 3、对每个单据自动组盘,失败则回退 + * 4、生成任务 + * 5、修改波次的状态 + */ @Transactional public AjaxResult startWave(String ids) { + List<Wave> waves = new ArrayList<>(); List<ShipmentDetail> list = new ArrayList<>(); for (Integer id : Convert.toIntArray(ids)) { + + //查看此波次的状态,状态不为o时,无法开始波次 + Wave wave = this.getById(id); + if(wave == null || wave.getStatus() != 0){ + return AjaxResult.error("id为"+id+"的波次找不到,或者状态不能做开始操作"); + } + waves.add(wave); + //找到此波次的单据 LambdaQueryWrapper<ShipmentDetail> lam = Wrappers.lambdaQuery(); lam.eq(ShipmentDetail::getWaveId,id) @@ -52,6 +69,27 @@ public class WaveService extends ServiceImpl<WaveMapper, Wave> { //生成任务 shipmentContainerHeaderService.createTask(Arrays.asList(Convert.toIntArray(ajaxResult.getData().toString()))); } + + for(Wave wave : waves){ + wave.setStatus(400); + wave.setCurrentWaveStep("生成任务"); + } + Boolean flag = this.updateBatchById(waves); + if(flag == false){ + throw new ServiceException("波次运行失败,修改波次状态时报错"); + } return AjaxResult.success("波次运行成功"); } + + + /** + * 释放波次,执行任务 + * @param ids + * @return + */ + @Transactional + public AjaxResult freed(String ids) { + + return null; + } } diff --git a/src/main/resources/static/huaheng/js/huahengUI.js b/src/main/resources/static/huaheng/js/huahengUI.js index 40260c3..48e350c 100644 --- a/src/main/resources/static/huaheng/js/huahengUI.js +++ b/src/main/resources/static/huaheng/js/huahengUI.js @@ -29,7 +29,7 @@ pageList: [10, 25, 50], // 可供选择的每页的行数(*) iconSize: 'outline', // 图标大小:undefined默认的按钮尺寸 xs超小按钮sm小按钮lg大按钮 toolbar: '#toolbar', // 指定工作栏 - sidePagination: "server", // 启用服务端分页 + sidePagination: "server", // 启用服务端分页 search: $.common.visible(options.search), // 是否显示搜索框功能 showRefresh: $.common.visible(options.showRefresh), // 是否显示刷新按钮 showColumns: $.common.visible(options.showColumns), // 是否显示隐藏某列下拉框 diff --git a/src/main/resources/templates/config/material/add.html b/src/main/resources/templates/config/material/add.html index a1a199c..4a6c67d 100644 --- a/src/main/resources/templates/config/material/add.html +++ b/src/main/resources/templates/config/material/add.html @@ -40,8 +40,8 @@ <div class="form-group"> <label class="col-sm-3 control-label">物料类别:</label> <div class="col-sm-8"> - <select id="type" name="type" class="form-control" th:with="materialType=${@dict.getType('materialType')}"> - <option th:each="item : ${materialType}" th:text="${item['dictLabel']}" th:value="${item['dictValue']}"></option> + <select id="type" name="type" class="form-control" th:with="materialType=${@materialType.queryType()}"> + <option th:each="item : ${materialType}" th:text="${item['name']}" th:value="${item['code']}"></option> </select> </div> </div> diff --git a/src/main/resources/templates/config/material/edit.html b/src/main/resources/templates/config/material/edit.html index dea4517..92fd634 100644 --- a/src/main/resources/templates/config/material/edit.html +++ b/src/main/resources/templates/config/material/edit.html @@ -35,9 +35,8 @@ <div class="form-group"> <label class="col-sm-3 control-label">物料类别:</label> <div class="col-sm-8"> - <select id="type" name="type" class="form-control" th:with="materialType=${@dict.getType('materialType')}"> - <option th:each="item : ${materialType}" th:text="${item['dictLabel']}" th:value="${item['dictValue']}" - th:field="*{type}"></option> + <select id="type" name="type" class="form-control" th:with="materialType=${@materialType.queryType()}" th:field="*{type}"> + <option th:each="item : ${materialType}" th:text="${item['name']}" th:value="${item['code']}"></option> </select> </div> </div> diff --git a/src/main/resources/templates/config/material/material.html b/src/main/resources/templates/config/material/material.html index 410a2df..0b48f64 100644 --- a/src/main/resources/templates/config/material/material.html +++ b/src/main/resources/templates/config/material/material.html @@ -66,7 +66,7 @@ var removeFlag = [[${@permission.hasPermi('config:material:remove')}]]; var prefix = ctx + "config/material"; var datas = [[${@dict.getType('sys_normal_disable')}]]; - var mType = [[${@dict.getType('materialType')}]]; + var mType = [[${@materialType.queryType()}]]; $(function() { var options = { url: prefix + "/list", @@ -95,7 +95,14 @@ title : '物料类别' , align: 'center', formatter: function(value, row, index) { - return $.table.selectDictLabel(mType, value); + var actions = []; + $.each(mType, function(index, dict) { + if (dict.code == value) { + actions.push("<span class='badge badge-" + dict.code + "'>" + dict.name + "</span>"); + return false; + } + }); + return actions.join(''); } }, { diff --git a/src/main/resources/templates/config/statusFlowHeader/add.html b/src/main/resources/templates/config/statusFlowHeader/add.html index c6ad1b4..e5e8f7a 100644 --- a/src/main/resources/templates/config/statusFlowHeader/add.html +++ b/src/main/resources/templates/config/statusFlowHeader/add.html @@ -20,7 +20,9 @@ <div class="form-group"> <label class="col-sm-3 control-label">模块:</label> <div class="col-sm-8"> - <input id="moduleType" name="moduleType" class="form-control" type="text"> + <select id="moduleType" name="moduleType" class="form-control" th:with="moduleTyped=${@dict.getType('moduleType')}"> + <option th:each="item : ${moduleType}" th:text="${item['dictLabel']}" th:value="${item['dictValue']}"></option> + </select> </div> </div> <div class="form-group"> diff --git a/src/main/resources/templates/config/statusFlowHeader/edit.html b/src/main/resources/templates/config/statusFlowHeader/edit.html index 61ebc57..38fe41d 100644 --- a/src/main/resources/templates/config/statusFlowHeader/edit.html +++ b/src/main/resources/templates/config/statusFlowHeader/edit.html @@ -21,7 +21,9 @@ <div class="form-group"> <label class="col-sm-3 control-label">模块:</label> <div class="col-sm-8"> - <input id="moduleType" name="moduleType" class="form-control" type="text" th:field="*{moduleType}"> + <select id="moduleType" name="moduleType" class="form-control" th:with="moduleTyped=${@dict.getType('moduleType')}" th:field="*{moduleType}"> + <option th:each="item : ${moduleType}" th:text="${item['dictLabel']}" th:value="${item['dictValue']}"></option> + </select> </div> </div> <div class="form-group"> diff --git a/src/main/resources/templates/shipment/wave/wave.html b/src/main/resources/templates/shipment/wave/wave.html index 9b41e4b..2b4a993 100644 --- a/src/main/resources/templates/shipment/wave/wave.html +++ b/src/main/resources/templates/shipment/wave/wave.html @@ -231,6 +231,23 @@ }; localSubmit(url, "post", "json", data); } + + + //释放 + function freed() { + var rows = $("#bootstrap-table").bootstrapTable('getSelections'); + if (rows.length == 0) { + $.modal.alertWarning("请至少选择一条记录"); + return; + } + var url = prefix + "/freed"; + var data = { + "ids": rows.map(function (v) { + return v.id; + }).join(',') + }; + localSubmit(url, "post", "json", data); + } </script> </body> </html> \ No newline at end of file diff --git a/src/main/resources/templates/system/dict/data/data.html b/src/main/resources/templates/system/dict/data/data.html index da082d3..35a424a 100644 --- a/src/main/resources/templates/system/dict/data/data.html +++ b/src/main/resources/templates/system/dict/data/data.html @@ -146,7 +146,12 @@ function queryParams(params) { return { - dictType: $("#dictType").val() + dictType: $("#dictType").val(), + pageSize: params.limit, + pageNum: params.offset / params.limit + 1, + searchValue: params.search, + orderByColumn: params.sort, + isAsc: params.order }; }