diff --git a/.gitignore b/.gitignore index 77f1bc5..dc08aa2 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ target/ *.iml *.ipr .idea/workspace.xml +.idea/compiler.xml + ### NetBeans ### /nbproject/private/ diff --git a/src/main/java/com/huaheng/pc/config/locationType/controller/LocationTypeController.java b/src/main/java/com/huaheng/pc/config/locationType/controller/LocationTypeController.java index cee5eeb..3458c59 100644 --- a/src/main/java/com/huaheng/pc/config/locationType/controller/LocationTypeController.java +++ b/src/main/java/com/huaheng/pc/config/locationType/controller/LocationTypeController.java @@ -1,6 +1,5 @@ package com.huaheng.pc.config.locationType.controller; - import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -17,133 +16,134 @@ import com.huaheng.framework.web.page.TableDataInfo; import com.huaheng.framework.web.page.TableSupport; import com.huaheng.pc.config.locationType.domain.LocationType; import com.huaheng.pc.config.locationType.service.LocationTypeService; -import com.huaheng.pc.general.location.domain.Location; -import com.huaheng.pc.general.location.service.LocationService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.*; -import java.util.Arrays; import java.util.List; +/** + * 库位类型 信息操作处理 + * + * @author huaheng + * @date 2018-08-19 + */ @Controller @RequestMapping("/config/locationType") -public class LocationTypeController extends BaseController { - +public class LocationTypeController extends BaseController +{ private String prefix = "config/locationType"; - - @Autowired - private LocationTypeService locationTypeService; - @Autowired - private LocationService locationService; - - @RequestMapping("config:locationType:view") - @GetMapping() - public String locationType() - { - return prefix + "/locationType"; - } - - /** - * 查询库位类型列表 - */ - @RequiresPermissions("config:locationType:list") - @Log(title = "通用-库位类型管理", operating = "查看库位类型列表", action = BusinessType.GRANT) - @PostMapping("/list") - @ResponseBody - public TableDataInfo list(LocationType locationType,String createdBegin, String createdEnd) { - LambdaQueryWrapper<LocationType> lambdaQueryWrapper = Wrappers.lambdaQuery(); - PageDomain pageDomain = TableSupport.buildPageRequest(); - Integer pageNum = pageDomain.getPageNum(); - Integer pageSize = pageDomain.getPageSize(); - - lambdaQueryWrapper.ge(StringUtils.isNotEmpty(createdBegin),LocationType::getCreated, createdBegin) - .le(StringUtils.isNotEmpty(createdEnd), LocationType::getCreated, createdEnd) - .eq(LocationType::getWarehouseCode, ShiroUtils.getWarehouseCode()) - .eq(StringUtils.isNotEmpty(locationType.getCode()),LocationType::getCode,locationType.getCode()) - .like(StringUtils.isNotEmpty(locationType.getName()),LocationType::getName,locationType.getName()); - - if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)){ - /** - * 使用分页查询 - */ - Page<LocationType> page = new Page<>(pageNum, pageSize); - IPage<LocationType> iPage = locationTypeService.page(page, lambdaQueryWrapper); - return getDataTable(iPage.getRecords()); - } else { - List<LocationType> list = locationTypeService.list(lambdaQueryWrapper); - return getDataTable(list); - } - } - - /** - * 新增库位类型 - */ - @GetMapping("/add") - public String add() { - return prefix + "/add"; - } - - /** - * 新增保存库位类型 - */ - @RequiresPermissions("config:locationType:add") - @Log(title = "通用-库位类型管理", operating = "新增库位类型", action = BusinessType.INSERT) - @PostMapping("/add") - @ResponseBody - public AjaxResult addSave(LocationType locationType) { - Boolean result = locationTypeService.save(locationType); - return toAjax(result); - } - - /** - * 修改库位类型 - */ - @GetMapping("/edit/{id}") - public String edit(@PathVariable("id") Integer id, ModelMap mmap) { - LocationType locationType = locationTypeService.getById(id); - mmap.put("locationType", locationType); - return prefix + "/edit"; - } - - /** - * 修改保存库位类型 - */ - @RequiresPermissions("config:locationType:edit") - @Log(title = "通用-库位类型管理", operating = "修改库位类型", action = BusinessType.UPDATE) - @PostMapping("/edit") - @ResponseBody - public AjaxResult editSave(LocationType locationType) { - locationType.setLastUpdatedBy(ShiroUtils.getLoginName()); - Boolean result = locationTypeService.updateById(locationType); - return toAjax(result); - } - - /** - * 删除库位 - */ - @RequiresPermissions("config:locationType:remove") - @Log(title = "通用-库位类型管理", operating = "删除库位类型", action = BusinessType.DELETE) - @PostMapping( "/remove") - @ResponseBody - public AjaxResult remove(String ids) { - if (StringUtils.isEmpty(ids)){ - return AjaxResult.error("id不能为空"); - } - - for (Integer id : Convert.toIntArray(ids)) { - LambdaQueryWrapper<Location> lambdaQueryWrapper = Wrappers.lambdaQuery(); - lambdaQueryWrapper.eq(Location::getLocationType,id); - - int count = locationService.count(lambdaQueryWrapper); - if (count != 0){ - return AjaxResult.error("库位类型id="+id+",存在库位,不能删除。"); - } - } - List<Integer> list = Arrays.asList(Convert.toIntArray(ids)); - locationTypeService.removeByIds(list); - return AjaxResult.success("删除成功!"); - } + + @Autowired + private LocationTypeService locationTypeService; + + @RequiresPermissions("config:locationType:view") + @GetMapping() + public String locationType() + { + return prefix + "/locationType"; + } + + /** + * 查询库位类型列表 + */ + @RequiresPermissions("config:locationType:list") + @Log(title = "配置-库位类型设置", operating = "查看库位类型", action = BusinessType.GRANT) + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(LocationType locationType,String createdBegin, String createdEnd) + { + LambdaQueryWrapper<LocationType> lambdaQueryWrapper = Wrappers.lambdaQuery(); + PageDomain pageDomain = TableSupport.buildPageRequest(); + Integer pageNum = pageDomain.getPageNum(); + Integer pageSize = pageDomain.getPageSize(); + + lambdaQueryWrapper.ge(StringUtils.isNotEmpty(createdBegin),LocationType::getCreated, createdBegin) + .le(StringUtils.isNotEmpty(createdEnd), LocationType::getCreated, createdEnd) + .eq(LocationType::getWarehouseCode,ShiroUtils.getWarehouseCode()) + .eq(StringUtils.isNotEmpty(locationType.getCode()), LocationType::getCode, locationType.getCode()) + .like(StringUtils.isNotEmpty(locationType.getName()), LocationType::getName, locationType.getName()) + .orderByAsc(LocationType::getId); + + if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)){ + /** + * 使用分页查询 + */ + Page<LocationType> page = new Page<>(pageNum, pageSize); + IPage<LocationType> iPage = locationTypeService.page(page, lambdaQueryWrapper); + return getMpDataTable(iPage.getRecords(),iPage.getTotal()); + } else { + List<LocationType> list = locationTypeService.list(lambdaQueryWrapper); + return getDataTable(list); + } + } + + /** + * 新增库位类型 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存库位类型 + */ + @RequiresPermissions("config:locationType:add") + @Log(title = "配置-库位类型设置", operating = "新增库位类型", action = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(LocationType locationType) + { + locationType.setWarehouseCode(ShiroUtils.getWarehouseCode()); + locationType.setCreatedBy(ShiroUtils.getLoginName()); + locationType.setLastUpdatedBy(ShiroUtils.getLoginName()); + return toAjax(locationTypeService.save(locationType)); + } + + /** + * 修改库位类型 + */ + @GetMapping("/edit/{id}") + public String edit(@PathVariable("id") Integer id, ModelMap mmap) + { + LocationType locationType = locationTypeService.getById(id); + mmap.put("locationType", locationType); + return prefix + "/edit"; + } + + /** + * 修改保存库位类型 + */ + @RequiresPermissions("config:locationType:edit") + @Log(title = "配置-库位类型设置", operating = "修改库位类型", action = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(LocationType locationType) + { + locationType.setLastUpdatedBy(ShiroUtils.getLoginName()); + return toAjax(locationTypeService.saveOrUpdate(locationType)); + } + + /** + * 删除库位类型 + */ + @RequiresPermissions("config:locationType:remove") + @Log(title = "配置-库位类型设置", operating = "删除库位类型", action = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + if (StringUtils.isEmpty(ids)) + return AjaxResult.error("id不能为空"); + for (Integer id : Convert.toIntArray(ids)) + { + locationTypeService.removeById(id); + } + return AjaxResult.success("删除成功!"); + } + }