You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
165 lines
4.5 KiB
165 lines
4.5 KiB
package com.gaotao.modules.warehouse.controller;
|
|
|
|
import com.gaotao.common.utils.PageUtils;
|
|
import com.gaotao.common.utils.R;
|
|
import com.gaotao.modules.factory.service.AccessSiteService;
|
|
import com.gaotao.modules.warehouse.entity.Pallet;
|
|
import com.gaotao.modules.warehouse.entity.dto.PalletQueryDto;
|
|
import com.gaotao.modules.warehouse.entity.vo.PalletVo;
|
|
import com.gaotao.modules.warehouse.service.PalletService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* 托盘管理控制器
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/warehouse/pallet")
|
|
public class PalletController {
|
|
|
|
@Autowired
|
|
private PalletService palletService;
|
|
|
|
@Autowired
|
|
private AccessSiteService accessSiteService;
|
|
|
|
/**
|
|
* 获取托盘列表
|
|
*/
|
|
@PostMapping("/list")
|
|
public R list(@RequestBody PalletQueryDto queryDto) {
|
|
PageUtils page = palletService.queryPage(queryDto);
|
|
return R.ok().put("page", page);
|
|
}
|
|
|
|
/**
|
|
* 根据托盘ID获取托盘信息
|
|
*/
|
|
@PostMapping("/info")
|
|
public R info(@RequestBody Pallet pallet) {
|
|
PalletVo palletVo = palletService.getPalletByPalletId(pallet.getPalletId());
|
|
return R.ok().put("pallet", palletVo);
|
|
}
|
|
|
|
/**
|
|
* 根据主键ID获取托盘信息
|
|
*/
|
|
@GetMapping("/info/{id}")
|
|
public R info(@PathVariable("id") Long id) {
|
|
Pallet pallet = palletService.getById(id);
|
|
return R.ok().put("pallet", pallet);
|
|
}
|
|
|
|
/**
|
|
* 保存托盘信息
|
|
*/
|
|
@PostMapping("/save")
|
|
public R save(@RequestBody Pallet pallet) {
|
|
try {
|
|
palletService.savePallet(pallet);
|
|
return R.ok("托盘信息保存成功");
|
|
} catch (Exception e) {
|
|
return R.error(e.getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 修改托盘信息
|
|
*/
|
|
@PostMapping("/update")
|
|
public R update(@RequestBody Pallet pallet) {
|
|
try {
|
|
palletService.updatePallet(pallet);
|
|
return R.ok("托盘信息修改成功");
|
|
} catch (Exception e) {
|
|
return R.error(e.getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 删除托盘
|
|
*/
|
|
@PostMapping("/delete")
|
|
public R delete(@RequestBody Long[] ids) {
|
|
try {
|
|
palletService.deletePalletBatch(ids);
|
|
return R.ok("托盘删除成功");
|
|
} catch (Exception e) {
|
|
return R.error(e.getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 检查托盘ID是否存在
|
|
*/
|
|
@PostMapping("/checkPalletId")
|
|
public R checkPalletId(@RequestBody Pallet pallet) {
|
|
boolean exists = palletService.checkPalletIdExists(pallet.getPalletId(), pallet.getId());
|
|
return R.ok().put("exists", exists);
|
|
}
|
|
|
|
/**
|
|
* 获取托盘状态选项
|
|
*/
|
|
@GetMapping("/statusOptions")
|
|
public R getStatusOptions() {
|
|
return R.ok().put("options", Arrays.asList(
|
|
new StatusOption("AVAILABLE", "可用"),
|
|
new StatusOption("OCCUPIED", "使用中"),
|
|
new StatusOption("DAMAGED", "损坏"),
|
|
new StatusOption("DISABLED", "禁用")
|
|
));
|
|
}
|
|
|
|
/**
|
|
* 获取用户授权站点列表
|
|
*/
|
|
@PostMapping("/getUserAuthorizedSites")
|
|
public R getUserAuthorizedSites(@RequestBody Map<String, Object> params) {
|
|
String userName = (String) params.get("userName");
|
|
|
|
if (userName == null || userName.trim().isEmpty()) {
|
|
return R.error("用户名不能为空");
|
|
}
|
|
|
|
try {
|
|
List<Map<String, Object>> siteList = accessSiteService.getUserAuthorizedSites(userName.trim());
|
|
return R.ok().put("data", siteList);
|
|
} catch (Exception e) {
|
|
return R.error("获取站点列表失败:" + e.getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 状态选项内部类
|
|
*/
|
|
public static class StatusOption {
|
|
private String value;
|
|
private String label;
|
|
|
|
public StatusOption(String value, String label) {
|
|
this.value = value;
|
|
this.label = label;
|
|
}
|
|
|
|
public String getValue() {
|
|
return value;
|
|
}
|
|
|
|
public void setValue(String value) {
|
|
this.value = value;
|
|
}
|
|
|
|
public String getLabel() {
|
|
return label;
|
|
}
|
|
|
|
public void setLabel(String label) {
|
|
this.label = label;
|
|
}
|
|
}
|
|
}
|