拣选大屏后台
This commit is contained in:
@@ -0,0 +1,129 @@
|
|||||||
|
package com.ruoyi.api.controller;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.api.service.IProductPortService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓库和点位API接口
|
||||||
|
*
|
||||||
|
* @author lsy
|
||||||
|
* @date 2025-06-23
|
||||||
|
*/
|
||||||
|
@Api(tags = "仓库和点位接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/warehouse")
|
||||||
|
public class WarehousePortController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JdbcTemplate jdbcTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IProductPortService productPortService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取仓库列表
|
||||||
|
*/
|
||||||
|
@ApiOperation("获取仓库列表")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public AjaxResult getWarehouseList() {
|
||||||
|
try {
|
||||||
|
String sql = "SELECT warehouse_id, warehouse_no, warehouse_name, address, c_desc " +
|
||||||
|
"FROM bas_warehouse " +
|
||||||
|
"WHERE is_current = 'Y' " +
|
||||||
|
"ORDER BY warehouse_no";
|
||||||
|
|
||||||
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
||||||
|
return success(list);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("查询仓库列表失败:", e);
|
||||||
|
return error("查询仓库列表失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据仓库ID获取点位列表
|
||||||
|
*/
|
||||||
|
@ApiOperation("获取点位列表")
|
||||||
|
@GetMapping("/port/{warehouseId}")
|
||||||
|
public AjaxResult getPortList(@ApiParam(value = "仓库ID", required = true) @PathVariable("warehouseId") String warehouseId) {
|
||||||
|
if (warehouseId == null || warehouseId.trim().isEmpty()) {
|
||||||
|
return error("仓库ID不能为空");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put("warehouseId", warehouseId);
|
||||||
|
params.put("portType", 2);
|
||||||
|
List<Map<String, Object>> portList = productPortService.selectPortListByParams(params);
|
||||||
|
return success(portList);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("查询点位列表失败:", e);
|
||||||
|
return error("查询点位列表失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据工位号数组查询任务数据
|
||||||
|
*/
|
||||||
|
@ApiOperation("根据工位号查询任务数据")
|
||||||
|
@PostMapping("/workstation/jobs")
|
||||||
|
public AjaxResult getJobsByWorkstations(@RequestBody Map<String, Object> request) {
|
||||||
|
try {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<String> workstationNumbers = (List<String>) request.get("workstationNumbers");
|
||||||
|
String warehouseId = (String) request.get("warehouseId");
|
||||||
|
if (workstationNumbers == null || workstationNumbers.isEmpty()) {
|
||||||
|
return error("工位号数组不能为空");
|
||||||
|
}
|
||||||
|
if (warehouseId == null || warehouseId.trim().isEmpty()) {
|
||||||
|
return error("仓库ID不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder placeholders = new StringBuilder();
|
||||||
|
for (int i = 0; i < workstationNumbers.size(); i++) {
|
||||||
|
placeholders.append(i == 0 ? "?" : ", ?");
|
||||||
|
}
|
||||||
|
|
||||||
|
String sql = "SELECT j.*, jd.out_quantity, jd.product_id, bp.product_name " +
|
||||||
|
"FROM mydo_job j " +
|
||||||
|
"LEFT JOIN mydo_job_detail jd ON j.job_id = jd.job_id " +
|
||||||
|
"LEFT JOIN bas_product bp ON jd.product_id = bp.product_id " +
|
||||||
|
"WHERE j.exit_id IN (" + placeholders.toString() + ") " +
|
||||||
|
"AND j.warehouse_id = ? ";
|
||||||
|
|
||||||
|
Object[] params = new Object[workstationNumbers.size() + 1];
|
||||||
|
for (int i = 0; i < workstationNumbers.size(); i++) {
|
||||||
|
params[i] = workstationNumbers.get(i);
|
||||||
|
}
|
||||||
|
params[workstationNumbers.size()] = warehouseId;
|
||||||
|
List<Map<String, Object>> queryResult = jdbcTemplate.queryForList(sql, params);
|
||||||
|
|
||||||
|
// 按工位号分组
|
||||||
|
Map<String, List<Map<String, Object>>> groupedResult = new HashMap<>();
|
||||||
|
for (Map<String, Object> job : queryResult) {
|
||||||
|
String exitId = (String) job.get("exit_id");
|
||||||
|
groupedResult.computeIfAbsent(exitId, k -> new ArrayList<>()).add(job);
|
||||||
|
}
|
||||||
|
|
||||||
|
return success(groupedResult);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("查询工位任务数据失败:", e);
|
||||||
|
return error("查询工位任务数据失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.ruoyi.api.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点位查询Service接口
|
||||||
|
*
|
||||||
|
* @author lsy
|
||||||
|
* @date 2025-06-23
|
||||||
|
*/
|
||||||
|
public interface IProductPortService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据仓库ID查询点位列表
|
||||||
|
*
|
||||||
|
* @param warehouseId 仓库ID
|
||||||
|
* @return 点位列表
|
||||||
|
*/
|
||||||
|
public List<Map<String, Object>> selectPortListByWarehouseId(String warehouseId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据查询条件获取点位列表
|
||||||
|
*
|
||||||
|
* @param params 查询参数,包含 warehouseId(仓库ID)和 portType(点位类型)
|
||||||
|
* @return 点位列表
|
||||||
|
*/
|
||||||
|
public List<Map<String, Object>> selectPortListByParams(Map<String, Object> params);
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.ruoyi.api.service.impl;
|
||||||
|
|
||||||
|
import com.ruoyi.api.service.IProductPortService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点位查询Service实现
|
||||||
|
*
|
||||||
|
* @author lsy
|
||||||
|
* @date 2025-06-23
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ProductPortServiceImpl implements IProductPortService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JdbcTemplate jdbcTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据仓库ID查询点位列表
|
||||||
|
*
|
||||||
|
* @param warehouseId 仓库ID
|
||||||
|
* @return 点位列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> selectPortListByWarehouseId(String warehouseId) {
|
||||||
|
String sql = "SELECT port_name, port_desc FROM bas_product_port WHERE warehouse_id = ?";
|
||||||
|
return jdbcTemplate.queryForList(sql, warehouseId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据查询条件获取点位列表
|
||||||
|
*
|
||||||
|
* @param params 查询参数
|
||||||
|
* @return 点位列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> selectPortListByParams(Map<String, Object> params) {
|
||||||
|
String sql = "SELECT port_name, port_desc FROM bas_product_port WHERE warehouse_id = ? AND port_type = ?";
|
||||||
|
return jdbcTemplate.queryForList(sql, params.get("warehouseId"), params.get("portType"));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user