|  |  | 
 |  |  | import com.vincent.rsf.server.common.domain.BaseParam; | 
 |  |  | import com.vincent.rsf.server.common.domain.KeyValVo; | 
 |  |  | import com.vincent.rsf.server.common.domain.PageParam; | 
 |  |  | import com.vincent.rsf.server.manager.controller.params.WarehouseAreaParam; | 
 |  |  | import com.vincent.rsf.server.manager.entity.Loc; | 
 |  |  | import com.vincent.rsf.server.manager.entity.WarehouseAreas; | 
 |  |  | import com.vincent.rsf.server.manager.service.LocService; | 
 |  |  | import com.vincent.rsf.server.manager.service.WarehouseAreasService; | 
 |  |  | import com.vincent.rsf.server.system.controller.BaseController; | 
 |  |  | import io.swagger.annotations.Api; | 
 |  |  | import io.swagger.annotations.ApiOperation; | 
 |  |  | 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.*; | 
 |  |  |  | 
 |  |  | @Api(tags = "仓库库区") | 
 |  |  | @RestController | 
 |  |  | public class WarehouseAreasController extends BaseController { | 
 |  |  |  | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:warehouseAreas:update')") | 
 |  |  |     @ApiOperation("库区批量修改") | 
 |  |  |     @PostMapping("/warehouseAreas/batch/update") | 
 |  |  |     public R batchUpdate(@RequestBody WarehouseAreaParam params) { | 
 |  |  |         if (Objects.isNull(params)) { | 
 |  |  |             return R.error("参数不能为空!!"); | 
 |  |  |         } | 
 |  |  |         if (Objects.isNull(params.getIds()) &&  params.getIds().isEmpty()) { | 
 |  |  |             return R.error("库区ID不能为空!!"); | 
 |  |  |         } | 
 |  |  |         if (warehouseAreasService.batchUpdate(params, getLoginUserId())) { | 
 |  |  |             return R.ok("修改成功!!"); | 
 |  |  |         } else { | 
 |  |  |             return R.error("修改失败!!"); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:warehouseAreas:update')") | 
 |  |  |     @OperationLog("Update 库区信息表") | 
 |  |  |     @PostMapping("/warehouseAreas/update") | 
 |  |  |     public R update(@RequestBody WarehouseAreas warehouseAreas) { | 
 |  |  |         warehouseAreas.setUpdateBy(getLoginUserId()); | 
 |  |  |         warehouseAreas.setUpdateTime(new Date()); | 
 |  |  |         WarehouseAreas areas = warehouseAreasService.getById(warehouseAreas.getId()); | 
 |  |  |         if (Objects.isNull(areas)) { | 
 |  |  |             throw new CoolException("数据错误:仓库库区不存在!!"); | 
 |  |  |         } | 
 |  |  |         if (!warehouseAreas.getName().equals(areas.getName())) { | 
 |  |  |             List<WarehouseAreas> areasList = warehouseAreasService.list(new LambdaQueryWrapper<WarehouseAreas>().eq(WarehouseAreas::getName, warehouseAreas.getName())); | 
 |  |  |             if (!areasList.isEmpty()) { | 
 |  |  |                 throw new CoolException("名称已存在!!"); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         if (!warehouseAreas.getCode().equals(areas.getCode())) { | 
 |  |  |             List<WarehouseAreas> areasList = warehouseAreasService.list(new LambdaQueryWrapper<WarehouseAreas>().eq(WarehouseAreas::getCode, warehouseAreas.getCode())); | 
 |  |  |             if (!areasList.isEmpty()) { | 
 |  |  |                 throw new CoolException("编码已存在!!"); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (!warehouseAreasService.updateById(warehouseAreas)) { | 
 |  |  |             return R.error("Update Fail"); | 
 |  |  |         } |