|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.wms.asrs.controller; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.zy.asrs.framework.common.Cools; | 
|---|
|  |  |  | import com.zy.asrs.framework.common.R; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.entity.LocDetl; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.entity.enums.LocStsType; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.service.LocDetlService; | 
|---|
|  |  |  | import com.zy.asrs.wms.common.annotation.OperationLog; | 
|---|
|  |  |  | import com.zy.asrs.wms.common.domain.BaseParam; | 
|---|
|  |  |  | import com.zy.asrs.wms.common.domain.KeyValVo; | 
|---|
|  |  |  | import com.zy.asrs.wms.common.domain.PageParam; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.entity.Loc; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.service.LocService; | 
|---|
|  |  |  | import com.zy.asrs.wms.system.controller.BaseController; | 
|---|
|  |  |  | import com.zy.asrs.wms.utils.ExcelUtil; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.security.access.prepost.PreAuthorize; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.servlet.http.HttpServletResponse; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping("/api") | 
|---|
|  |  |  | public class LocController extends BaseController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocService locService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocDetlService locDetlService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:list')") | 
|---|
|  |  |  | @PostMapping("/loc/page") | 
|---|
|  |  |  | public R page(@RequestBody Map<String, Object> map) { | 
|---|
|  |  |  | BaseParam baseParam = buildParam(map, BaseParam.class); | 
|---|
|  |  |  | PageParam<Loc, BaseParam> pageParam = new PageParam<>(baseParam, Loc.class); | 
|---|
|  |  |  | return R.ok().add(locService.page(pageParam, pageParam.buildWrapper(true))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:list')") | 
|---|
|  |  |  | @PostMapping("/loc/list") | 
|---|
|  |  |  | public R list(@RequestBody Map<String, Object> map) { | 
|---|
|  |  |  | return R.ok().add(locService.list()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:list')") | 
|---|
|  |  |  | @GetMapping("/loc/{id}") | 
|---|
|  |  |  | public R get(@PathVariable("id") Long id) { | 
|---|
|  |  |  | return R.ok().add(locService.getById(id)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:list')") | 
|---|
|  |  |  | @PostMapping("/loc/search/locNo") | 
|---|
|  |  |  | public R get(@RequestParam("locNo") String locNo) { | 
|---|
|  |  |  | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, locNo)); | 
|---|
|  |  |  | if(loc == null) { | 
|---|
|  |  |  | return R.error("库位不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<LocDetl> locDetls = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocId, loc.getId())); | 
|---|
|  |  |  | locDetls = locDetlService.parseLocDetl(locDetls); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | HashMap<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | map.put("loc", loc); | 
|---|
|  |  |  | map.put("locDetls", locDetls); | 
|---|
|  |  |  | return R.ok().add(map); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:list')") | 
|---|
|  |  |  | @PostMapping("/loc/search/like/locNo") | 
|---|
|  |  |  | public R search(@RequestParam("locNo") String locNo) { | 
|---|
|  |  |  | if (Cools.isEmpty(locNo)) { | 
|---|
|  |  |  | return R.ok().add(new ArrayList<>()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<LocDetl> locDetls = locDetlService.list(new LambdaQueryWrapper<LocDetl>().like(LocDetl::getLocNo, locNo)); | 
|---|
|  |  |  | locDetls = locDetlService.parseLocDetl(locDetls); | 
|---|
|  |  |  | return R.ok().add(locDetls); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:list')") | 
|---|
|  |  |  | @PostMapping("/loc/search/empty/locNo") | 
|---|
|  |  |  | public R searchEmpty(@RequestParam("locNo") String locNo) { | 
|---|
|  |  |  | if (Cools.isEmpty(locNo)) { | 
|---|
|  |  |  | return R.ok().add(locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getLocStsId, LocStsType.O.val()))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Loc> list = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getLocStsId, LocStsType.O.val()).like(Loc::getLocNo, locNo)); | 
|---|
|  |  |  | return R.ok().add(list); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:save')") | 
|---|
|  |  |  | @OperationLog("添加库位") | 
|---|
|  |  |  | @PostMapping("/loc/save") | 
|---|
|  |  |  | public R save(@RequestBody Loc loc) { | 
|---|
|  |  |  | if (!locService.save(loc)) { | 
|---|
|  |  |  | return R.error("添加失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok("添加成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:update')") | 
|---|
|  |  |  | @OperationLog("修改库位") | 
|---|
|  |  |  | @PostMapping("/loc/update") | 
|---|
|  |  |  | public R update(@RequestBody Loc loc) { | 
|---|
|  |  |  | if (!locService.updateById(loc)) { | 
|---|
|  |  |  | return R.error("修改失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok("修改成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:remove')") | 
|---|
|  |  |  | @OperationLog("删除库位") | 
|---|
|  |  |  | @PostMapping("/loc/remove/{ids}") | 
|---|
|  |  |  | public R remove(@PathVariable Long[] ids) { | 
|---|
|  |  |  | if (!locService.removeByIds(Arrays.asList(ids))) { | 
|---|
|  |  |  | return R.error("删除失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok("删除成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:list')") | 
|---|
|  |  |  | @PostMapping("/loc/query") | 
|---|
|  |  |  | public R query(@RequestParam(required = false) String condition) { | 
|---|
|  |  |  | List<KeyValVo> vos = new ArrayList<>(); | 
|---|
|  |  |  | LambdaQueryWrapper<Loc> wrapper = new LambdaQueryWrapper<>(); | 
|---|
|  |  |  | if (!Cools.isEmpty(condition)) { | 
|---|
|  |  |  | wrapper.like(Loc::getLocNo, condition); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | locService.page(new Page<>(1, 30), wrapper).getRecords().forEach( | 
|---|
|  |  |  | item -> vos.add(new KeyValVo(item.getId(), item.getLocNo())) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | return R.ok().add(vos); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:list')") | 
|---|
|  |  |  | @PostMapping("/loc/export") | 
|---|
|  |  |  | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { | 
|---|
|  |  |  | ExcelUtil.build(ExcelUtil.create(locService.list(), Loc.class), response); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | package com.zy.asrs.wms.asrs.controller; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.zy.asrs.framework.common.Cools; | 
|---|
|  |  |  | import com.zy.asrs.framework.common.R; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.entity.LocDetl; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.entity.enums.LocStsType; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.service.LocDetlService; | 
|---|
|  |  |  | import com.zy.asrs.wms.common.annotation.CacheData; | 
|---|
|  |  |  | import com.zy.asrs.wms.common.annotation.OperationLog; | 
|---|
|  |  |  | import com.zy.asrs.wms.common.domain.BaseParam; | 
|---|
|  |  |  | import com.zy.asrs.wms.common.domain.KeyValVo; | 
|---|
|  |  |  | import com.zy.asrs.wms.common.domain.PageParam; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.entity.Loc; | 
|---|
|  |  |  | import com.zy.asrs.wms.asrs.service.LocService; | 
|---|
|  |  |  | import com.zy.asrs.wms.system.controller.BaseController; | 
|---|
|  |  |  | import com.zy.asrs.wms.utils.ExcelUtil; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.security.access.prepost.PreAuthorize; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.servlet.http.HttpServletResponse; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping("/api") | 
|---|
|  |  |  | public class LocController extends BaseController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocService locService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocDetlService locDetlService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:list')") | 
|---|
|  |  |  | @PostMapping("/loc/page") | 
|---|
|  |  |  | @CacheData(tableName = {"man_loc"}) | 
|---|
|  |  |  | public R page(@RequestBody Map<String, Object> map) { | 
|---|
|  |  |  | BaseParam baseParam = buildParam(map, BaseParam.class); | 
|---|
|  |  |  | PageParam<Loc, BaseParam> pageParam = new PageParam<>(baseParam, Loc.class); | 
|---|
|  |  |  | return R.ok().add(locService.page(pageParam, pageParam.buildWrapper(true))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:list')") | 
|---|
|  |  |  | @PostMapping("/loc/list") | 
|---|
|  |  |  | @CacheData(tableName = {"man_loc"}) | 
|---|
|  |  |  | public R list(@RequestBody Map<String, Object> map) { | 
|---|
|  |  |  | return R.ok().add(locService.list()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:list')") | 
|---|
|  |  |  | @GetMapping("/loc/{id}") | 
|---|
|  |  |  | @CacheData(tableName = {"man_loc"}) | 
|---|
|  |  |  | public R get(@PathVariable("id") Long id) { | 
|---|
|  |  |  | return R.ok().add(locService.getById(id)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:list')") | 
|---|
|  |  |  | @PostMapping("/loc/search/locNo") | 
|---|
|  |  |  | @CacheData(tableName = {"man_loc"}) | 
|---|
|  |  |  | public R get(@RequestParam("locNo") String locNo) { | 
|---|
|  |  |  | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, locNo)); | 
|---|
|  |  |  | if(loc == null) { | 
|---|
|  |  |  | return R.error("库位不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<LocDetl> locDetls = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocId, loc.getId())); | 
|---|
|  |  |  | locDetls = locDetlService.parseLocDetl(locDetls); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | HashMap<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | map.put("loc", loc); | 
|---|
|  |  |  | map.put("locDetls", locDetls); | 
|---|
|  |  |  | return R.ok().add(map); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:list')") | 
|---|
|  |  |  | @PostMapping("/loc/search/like/locNo") | 
|---|
|  |  |  | @CacheData(tableName = {"man_loc"}) | 
|---|
|  |  |  | public R search(@RequestParam("locNo") String locNo) { | 
|---|
|  |  |  | if (Cools.isEmpty(locNo)) { | 
|---|
|  |  |  | return R.ok().add(new ArrayList<>()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<LocDetl> locDetls = locDetlService.list(new LambdaQueryWrapper<LocDetl>().like(LocDetl::getLocNo, locNo)); | 
|---|
|  |  |  | locDetls = locDetlService.parseLocDetl(locDetls); | 
|---|
|  |  |  | return R.ok().add(locDetls); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:list')") | 
|---|
|  |  |  | @PostMapping("/loc/search/empty/locNo") | 
|---|
|  |  |  | @CacheData(tableName = {"man_loc"}) | 
|---|
|  |  |  | public R searchEmpty(@RequestParam("locNo") String locNo) { | 
|---|
|  |  |  | if (Cools.isEmpty(locNo)) { | 
|---|
|  |  |  | return R.ok().add(locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getLocStsId, LocStsType.O.val()))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Loc> list = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getLocStsId, LocStsType.O.val()).like(Loc::getLocNo, locNo)); | 
|---|
|  |  |  | return R.ok().add(list); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:save')") | 
|---|
|  |  |  | @OperationLog("添加库位") | 
|---|
|  |  |  | @PostMapping("/loc/save") | 
|---|
|  |  |  | public R save(@RequestBody Loc loc) { | 
|---|
|  |  |  | if (!locService.save(loc)) { | 
|---|
|  |  |  | return R.error("添加失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok("添加成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:update')") | 
|---|
|  |  |  | @OperationLog("修改库位") | 
|---|
|  |  |  | @PostMapping("/loc/update") | 
|---|
|  |  |  | public R update(@RequestBody Loc loc) { | 
|---|
|  |  |  | if (!locService.updateById(loc)) { | 
|---|
|  |  |  | return R.error("修改失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok("修改成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:remove')") | 
|---|
|  |  |  | @OperationLog("删除库位") | 
|---|
|  |  |  | @PostMapping("/loc/remove/{ids}") | 
|---|
|  |  |  | public R remove(@PathVariable Long[] ids) { | 
|---|
|  |  |  | if (!locService.removeByIds(Arrays.asList(ids))) { | 
|---|
|  |  |  | return R.error("删除失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok("删除成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:list')") | 
|---|
|  |  |  | @PostMapping("/loc/query") | 
|---|
|  |  |  | public R query(@RequestParam(required = false) String condition) { | 
|---|
|  |  |  | List<KeyValVo> vos = new ArrayList<>(); | 
|---|
|  |  |  | LambdaQueryWrapper<Loc> wrapper = new LambdaQueryWrapper<>(); | 
|---|
|  |  |  | if (!Cools.isEmpty(condition)) { | 
|---|
|  |  |  | wrapper.like(Loc::getLocNo, condition); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | locService.page(new Page<>(1, 30), wrapper).getRecords().forEach( | 
|---|
|  |  |  | item -> vos.add(new KeyValVo(item.getId(), item.getLocNo())) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | return R.ok().add(vos); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('asrs:loc:list')") | 
|---|
|  |  |  | @PostMapping("/loc/export") | 
|---|
|  |  |  | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { | 
|---|
|  |  |  | BaseParam baseParam = buildParam(map, BaseParam.class); | 
|---|
|  |  |  | PageParam<Loc, BaseParam> pageParam = new PageParam<>(baseParam, Loc.class); | 
|---|
|  |  |  | List<Loc> data = locService.list(pageParam.buildWrapper(true)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ExcelUtil.build(ExcelUtil.create(data, Loc.class), response); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|