yangyang
2025-03-21 a27be22b8e8f4d0eb48f560303041c8a961202a9
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/LocController.java
@@ -1,5 +1,6 @@
package com.vincent.rsf.server.manager.controller;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vincent.rsf.framework.common.Cools;
@@ -18,8 +19,10 @@
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
@@ -65,10 +68,26 @@
    @OperationLog("Create 库位信息表")
    @PostMapping("/loc/save")
    public R save(@RequestBody Loc loc) {
        if (Objects.isNull(loc.getWarehouseId())) {
            throw new CoolException("仓库ID不能为空!!");
        }
        if (Objects.isNull(loc.getAreaId())) {
            throw new CoolException("仓库ID不能为空!!");
        }
        if (Objects.isNull(loc.getTypeIds())) {
            throw new CoolException("库位类型不能为空!!");
        }
        String join = StringUtils.join(loc.getTypeIds(), ",");
        loc.setType(join);
        loc.setCreateBy(getLoginUserId());
        loc.setUpdateBy(getLoginUserId());
        if (!locService.save(loc)) {
            return R.error("Save Fail");
        }
        if (!locService.saveType(loc)) {
            throw new CoolException("库位类型关联关系保存失败!!");
        }
        return R.ok("Save Success").add(loc);
    }
@@ -76,11 +95,19 @@
    @PreAuthorize("hasAuthority('manager:loc:update')")
    @OperationLog("Update 库位信息表")
    @PostMapping("/loc/update")
    @Transactional(rollbackFor = Exception.class)
    public R update(@RequestBody Loc loc) {
        loc.setUpdateBy(getLoginUserId());
        loc.setUpdateTime(new Date());
        String join = StringUtils.join(loc.getTypeIds(), ",");
        loc.setType(join);
        if (!locService.updateById(loc)) {
            return R.error("Update Fail");
        }
        if (!locService.updateLoc(loc)) {
            throw new CoolException("库位类型关联关系修改失败!@!");
        }
        return R.ok("Update Success").add(loc);
    }
@@ -132,6 +159,16 @@
        return locService.modifyLocs(locs);
    }
    @PreAuthorize("hasAuthority('manager:loc:update')")
    @PostMapping("/loc/batch/area")
    @ApiOperation("库位批量分区")
    public R batchLocArea(@RequestBody LocModifyParams locs) {
        if (Objects.isNull(locs)) {
            throw new CoolException("参数不能为空!!");
        }
        return locService.batchBindLocs(locs);
    }
    @PreAuthorize("hasAuthority('manager:loc:update')")
    @ApiOperation("库位初始化")