diff --git a/src/main/java/com/huaheng/pc/config/location/controller/LocationController.java b/src/main/java/com/huaheng/pc/config/location/controller/LocationController.java index cfdb477..e26903c 100644 --- a/src/main/java/com/huaheng/pc/config/location/controller/LocationController.java +++ b/src/main/java/com/huaheng/pc/config/location/controller/LocationController.java @@ -72,9 +72,10 @@ public class LocationController extends BaseController { .eq(StringUtils.isNotNull(location.getIColumn()), Location::getIColumn, location.getIColumn()) .eq(StringUtils.isNotNull(location.getIGrid()), Location::getIGrid, location.getIGrid()) .eq(StringUtils.isNotNull(location.getILayer()), Location::getILayer, location.getILayer()) + .eq(StringUtils.isNotEmpty(location.getStatus()),Location::getStatus,location.getStatus()) .eq(StringUtils.isNotEmpty(location.getLocationType()), Location::getLocationType, location.getLocationType()) .eq(Location::getDeleted,false) - .orderByDesc(Location::getCreated); + .orderByDesc(Location::getId); if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)){ /*使用分页查询*/ @@ -104,8 +105,8 @@ public class LocationController extends BaseController { @PostMapping("/add") @ResponseBody public AjaxResult addSave(Location location) { - Boolean result = locationService.save(location); - return toAjax(result); + AjaxResult result = locationService.addsave(location); + return result; } diff --git a/src/main/java/com/huaheng/pc/config/location/service/LocationService.java b/src/main/java/com/huaheng/pc/config/location/service/LocationService.java index 9dc7299..6500a7f 100644 --- a/src/main/java/com/huaheng/pc/config/location/service/LocationService.java +++ b/src/main/java/com/huaheng/pc/config/location/service/LocationService.java @@ -1,9 +1,12 @@ package com.huaheng.pc.config.location.service; +import com.huaheng.framework.web.domain.AjaxResult; import com.huaheng.pc.config.location.domain.Location; import com.baomidou.mybatisplus.extension.service.IService; public interface LocationService extends IService<Location>{ + AjaxResult addsave(Location location); + boolean insertLocation(Location location); void updateStatus(String locationCode, String status); diff --git a/src/main/java/com/huaheng/pc/config/location/service/LocationServiceImpl.java b/src/main/java/com/huaheng/pc/config/location/service/LocationServiceImpl.java index fbe766a..339ca18 100644 --- a/src/main/java/com/huaheng/pc/config/location/service/LocationServiceImpl.java +++ b/src/main/java/com/huaheng/pc/config/location/service/LocationServiceImpl.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.huaheng.common.exception.service.ServiceException; import com.huaheng.common.utils.StringUtils; import com.huaheng.common.utils.security.ShiroUtils; +import com.huaheng.framework.web.domain.AjaxResult; import com.huaheng.pc.config.locationType.domain.LocationType; import com.huaheng.pc.config.locationType.service.LocationTypeService; import com.huaheng.pc.config.zone.domain.Zone; @@ -33,6 +34,44 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i @Resource private LocationMapper locationMapper; + + //新增库位,需要建立code,并判断是否重复 + @Override + public AjaxResult addsave(Location location){ + + //库区与库位类型的匹配判断 + if(!location.getZoneCode().equals(location.getLocationType())){ + throw new ServiceException(location.getLocationType()+"的库位类型与"+location.getZoneCode()+"库区不匹配"); + } + + //创建库位编码code + String prefix = location.getLocationType().substring(1); + String code = MessageFormat.format("{0}{1}-{2}-{3}-{4}", + prefix, + String.format("%02d", location.getIRow()), + String.format("%02d", location.getIColumn()), + String.format("%02d", location.getILayer()), + String.format("%02d", location.getIGrid())); + + + //判断code是否重复 + LambdaQueryWrapper<Location> lam = Wrappers.lambdaQuery(); + lam.eq(Location::getWarehouseCode,ShiroUtils.getWarehouseCode()) + .eq(Location::getCode,code); + if(this.getOne(lam)!=null){ + return AjaxResult.error("该位置已有库位生成,请重新输入位置"); + } + + //插入数据库 + location.setWarehouseCode(ShiroUtils.getWarehouseCode()); + location.setCreatedBy(ShiroUtils.getLoginName()); + Boolean flag=this.save(location); + if(flag == false){ + return AjaxResult.error("新增库位失败,插入数据库时失败"); + } + return AjaxResult.success("新增库位成功"); + } + @Override public boolean insertLocation(Location location) { /* 判断库位类型编码是否存在*/ @@ -54,6 +93,9 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i throw new ServiceException("库区编码不存在"); } + if(!location.getZoneCode().equals(location.getLocationType())){ + throw new ServiceException(location.getLocationType()+"的库位类型与"+location.getZoneCode()+"库区不匹配"); + } String prefix = location.getLocationType().substring(1); List<Location> locations = new ArrayList<>(); for (int i=1; i<=location.getIRow().intValue(); i++) { @@ -78,18 +120,14 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i String.format("%02d", j), String.format("%02d", k), String.format("%02d", m)); - QueryWrapper<Location> queryWrapper = new QueryWrapper<>(); - List<Location> locationList = locationService.list(queryWrapper.eq("code", code)); - if (locationList.size() != 0){ - return true; - } else { + LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery(); + queryWrapper.eq(Location::getCode,code) + .eq(Location::getWarehouseCode,ShiroUtils.getWarehouseCode()); + List<Location> locationList = locationService.list(queryWrapper); + if (locationList.size() != 0) { param.setCode(code); - location.setWarehouseCode(ShiroUtils.getWarehouseCode()); - location.setCreatedBy(ShiroUtils.getLoginName()); - location.setLastUpdatedBy(ShiroUtils.getLoginName()); + locations.add(param); } - param.setCode(code); - locations.add(param); } } } diff --git a/src/main/java/com/huaheng/pc/config/locationType/service/LocationTypeServiceImpl.java b/src/main/java/com/huaheng/pc/config/locationType/service/LocationTypeServiceImpl.java index 6f5f921..dcd856b 100644 --- a/src/main/java/com/huaheng/pc/config/locationType/service/LocationTypeServiceImpl.java +++ b/src/main/java/com/huaheng/pc/config/locationType/service/LocationTypeServiceImpl.java @@ -17,7 +17,6 @@ public class LocationTypeServiceImpl extends ServiceImpl<LocationTypeMapper, Loc public List<Map<String, Object>> getLocationPrefix(){ LambdaQueryWrapper<LocationType> lambdaQueryWrapper = Wrappers.lambdaQuery(); lambdaQueryWrapper.eq(LocationType::getWarehouseCode, ShiroUtils.getWarehouseCode()) - .eq(LocationType::getEnable, false) .eq(LocationType::getEnable, true); return this.listMaps(lambdaQueryWrapper); } diff --git a/src/main/java/com/huaheng/pc/config/materialUnit/controller/MaterialUnitController.java b/src/main/java/com/huaheng/pc/config/materialUnit/controller/MaterialUnitController.java index b582649..111fa2d 100644 --- a/src/main/java/com/huaheng/pc/config/materialUnit/controller/MaterialUnitController.java +++ b/src/main/java/com/huaheng/pc/config/materialUnit/controller/MaterialUnitController.java @@ -66,10 +66,11 @@ public class MaterialUnitController extends BaseController { lambdaQueryWrapper.gt(StringUtils.isNotEmpty(createdBegin), MaterialUnit::getCreated, createdBegin) .lt(StringUtils.isNotEmpty(createdEnd), MaterialUnit::getCreated, createdEnd) .eq(StringUtils.isNotEmpty(materialUnit.getMaterialCode()), MaterialUnit::getMaterialCode, materialUnit.getMaterialCode()) - .eq(StringUtils.isNotEmpty(materialUnit.getMaterialName()), MaterialUnit::getMaterialName, materialUnit.getMaterialName()) + .like(StringUtils.isNotEmpty(materialUnit.getMaterialName()), MaterialUnit::getMaterialName, materialUnit.getMaterialName()) .eq(StringUtils.isNotEmpty(materialUnit.getUnit()), MaterialUnit::getUnit, materialUnit.getUnit()) .in(MaterialUnit::getCompanyCode, ShiroUtils.getCompanyCodeList()) - .eq(MaterialUnit::getWarehouseCode, ShiroUtils.getWarehouseCode()); + .eq(MaterialUnit::getWarehouseCode, ShiroUtils.getWarehouseCode()) + .orderByDesc(MaterialUnit::getId); if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)){ /*使用分页查询*/ diff --git a/src/main/resources/templates/config/location/addBatch.html b/src/main/resources/templates/config/location/addBatch.html index 917d117..2982097 100644 --- a/src/main/resources/templates/config/location/addBatch.html +++ b/src/main/resources/templates/config/location/addBatch.html @@ -66,22 +66,34 @@ var prefix = ctx + "config/location" $("#form-location-add").validate({ rules:{ - row:{ + iRow:{ required:true, digits:true }, - line:{ + iColumn:{ required:true, digits:true }, - layer:{ + iLayer:{ required:true, digits:true }, - grid:{ + iGrid:{ required:true, digits:true - } + }, + zoneCode:{ + required:true, + digits:true + }, + locationType:{ + required:true, + digits:true + }, + status:{ + required:true, + digits:true + } }, submitHandler: function(form) { $.ajax({ @@ -95,7 +107,7 @@ "iGrid": $("input[name='iGrid']").val(), "locationType": $("#locationType option:selected").val(), "zoneCode": $("#zone option:selected").attr("code"), - "enable" : $("input[name='enable']").is(':checked'), + "status" : $("input[name='status']").is(':checked'), }, async : false, error : function(request) { diff --git a/src/main/resources/templates/config/location/location.html b/src/main/resources/templates/config/location/location.html index 4a6a884..8719e3c 100644 --- a/src/main/resources/templates/config/location/location.html +++ b/src/main/resources/templates/config/location/location.html @@ -25,25 +25,25 @@ 库区编码:<input type="text" name="zoneCode"/> </li> <li> - 行:<input type="text" name="row"/> + 行:<input type="text" name="iRow"/> </li> <li> - 列:<input type="text" name="line"/> + 列:<input type="text" name="iColumn"/> </li> <li> - 层:<input type="text" name="layer"/> + 层:<input type="text" name="iLayer"/> </li> <li> - 格:<input type="text" name="grid"/> - </li> - <li> - 巷道:<input type="text" name="roadway"/> + 格:<input type="text" name="iGrid"/> </li> <!--<li>--> + <!--巷道:<input type="text" name="roadway"/>--> + <!--</li>--> + <!--<li>--> <!--名称:<input type="text" name="name"/>--> <!--</li>--> <li> - 库位类型:<select name="type" th:with="locationTypes = ${@locationType.getLocationPrefix()}"> + 库位类型:<select name="locationType" th:with="locationTypes = ${@locationType.getLocationPrefix()}"> <option value="">所有</option> <option th:each="e : ${locationTypes}" th:text="${e['name']}" th:value="${e['code']}"></option> </select> diff --git a/src/main/resources/templates/config/locationType/locationType.html b/src/main/resources/templates/config/locationType/locationType.html index f8fcd17..51504d8 100644 --- a/src/main/resources/templates/config/locationType/locationType.html +++ b/src/main/resources/templates/config/locationType/locationType.html @@ -10,7 +10,7 @@ <div class="select-list"> <ul> <li> - 编码:<input type="text" name="code"/> + 货位类型:<input type="text" name="code"/> </li> <li> 名称:<input type="text" name="name"/> @@ -107,10 +107,6 @@ title : '校验位' }, { - field : 'checkDigit', - title : '校验位' - }, - { field : 'maxMaterials', title : '最多混放物料数' }, diff --git a/src/main/resources/templates/config/material/material.html b/src/main/resources/templates/config/material/material.html index d48e6e7..4c91f8b 100644 --- a/src/main/resources/templates/config/material/material.html +++ b/src/main/resources/templates/config/material/material.html @@ -29,9 +29,9 @@ </li> <li class="time"> <label>创建时间: </label> - <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[createdBegin]"/> + <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="createdBegin"/> <span>-</span> - <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[createdEnd]"/> + <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="createdEnd"/> </li> <li> <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i> 搜索</a> @@ -206,7 +206,7 @@ align: 'center', formatter: function(value, row, index) { var actions = []; - actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> '); + // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> '); actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-trash-o"></i>删除</a>'); return actions.join(''); } diff --git a/src/main/resources/templates/config/zoneCapacity/zoneCapacity.html b/src/main/resources/templates/config/zoneCapacity/zoneCapacity.html index 265f6a5..b9e1597 100644 --- a/src/main/resources/templates/config/zoneCapacity/zoneCapacity.html +++ b/src/main/resources/templates/config/zoneCapacity/zoneCapacity.html @@ -10,13 +10,10 @@ <div class="select-list"> <ul> <li> - 编码:<input type="text" name="code"/> + 商品编码:<input type="text" name="materialCode"/> </li> <li> - 名称:<input type="text" name="name"/> - </li> - <li> - 存货编码:<input type="text" name="materialId"/> + 商品名称:<input type="text" name="materialName"/> </li> </li> <li>