6 changed files with 409 additions and 0 deletions
-
40src/main/java/com/gaotao/modules/automatedWarehouse/entity/AgvStationData.java
-
27src/main/java/com/gaotao/modules/automatedWarehouse/entity/Area.java
-
26src/main/java/com/gaotao/modules/automatedWarehouse/mapper/AgvStationMapper.java
-
51src/main/java/com/gaotao/modules/automatedWarehouse/service/AgvStationService.java
-
249src/main/java/com/gaotao/modules/automatedWarehouse/service/impl/AgvStationServiceImpl.java
-
16src/main/resources/mapper/automatedWarehouse/AgvStationMapper.xml
@ -0,0 +1,40 @@ |
|||
package com.gaotao.modules.automatedWarehouse.entity; |
|||
|
|||
import lombok.Data; |
|||
import org.apache.ibatis.type.Alias; |
|||
|
|||
/** |
|||
* @Description AGV站点信息业务实体类 - 用于查询和业务操作 - rqrq |
|||
* @Author rqrq |
|||
* @Date 2025/10/14 |
|||
*/ |
|||
@Data |
|||
@Alias("AgvStationData") |
|||
public class AgvStationData extends AgvStation { |
|||
|
|||
/** |
|||
* 分页参数 - 当前页码 |
|||
*/ |
|||
private Integer page; |
|||
|
|||
/** |
|||
* 分页参数 - 每页数量 |
|||
*/ |
|||
private Integer limit; |
|||
|
|||
/** |
|||
* 查询条件 - 站点编码(模糊查询) |
|||
*/ |
|||
private String searchStationCode; |
|||
|
|||
/** |
|||
* 查询条件 - 站点名称(模糊查询) |
|||
*/ |
|||
private String searchStationName; |
|||
|
|||
/** |
|||
* 查询条件 - 站点ID(模糊查询) |
|||
*/ |
|||
private String searchStationId; |
|||
} |
|||
|
|||
@ -0,0 +1,27 @@ |
|||
package com.gaotao.modules.automatedWarehouse.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import lombok.Data; |
|||
import org.apache.ibatis.type.Alias; |
|||
|
|||
/** |
|||
* @Description 区域信息基础实体类 - 直接映射数据库表 - rqrq |
|||
* @Author rqrq |
|||
* @Date 2025/10/14 |
|||
*/ |
|||
@Data |
|||
@TableName("area") |
|||
@Alias("Area") |
|||
public class Area { |
|||
|
|||
/** |
|||
* 区域ID |
|||
*/ |
|||
private String areaId; |
|||
|
|||
/** |
|||
* 区域描述 |
|||
*/ |
|||
private String areaDesc; |
|||
} |
|||
|
|||
@ -0,0 +1,26 @@ |
|||
package com.gaotao.modules.automatedWarehouse.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.gaotao.modules.automatedWarehouse.entity.AgvStation; |
|||
import com.gaotao.modules.automatedWarehouse.entity.Area; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description AGV站点信息Mapper - rqrq |
|||
* @Author rqrq |
|||
* @Date 2025/10/14 |
|||
*/ |
|||
@Mapper |
|||
public interface AgvStationMapper extends BaseMapper<AgvStation> { |
|||
|
|||
/** |
|||
* @Description 获取区域类型下拉选项 - rqrq |
|||
* @return List<Area> |
|||
* @author rqrq |
|||
* @date 2025/10/14 |
|||
*/ |
|||
List<Area> getAreaOptions(); |
|||
} |
|||
|
|||
@ -0,0 +1,51 @@ |
|||
package com.gaotao.modules.automatedWarehouse.service; |
|||
|
|||
import com.baomidou.mybatisplus.extension.service.IService; |
|||
import com.gaotao.common.utils.PageUtils; |
|||
import com.gaotao.modules.automatedWarehouse.entity.AgvStation; |
|||
import com.gaotao.modules.automatedWarehouse.entity.AgvStationData; |
|||
import com.gaotao.modules.automatedWarehouse.entity.Area; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description AGV站点信息服务接口 - rqrq |
|||
* @Author rqrq |
|||
* @Date 2025/10/14 |
|||
*/ |
|||
public interface AgvStationService extends IService<AgvStation> { |
|||
|
|||
/** |
|||
* @Description 分页查询AGV站点列表 - rqrq |
|||
* @param data 查询条件 |
|||
* @return PageUtils |
|||
* @author rqrq |
|||
* @date 2025/10/14 |
|||
*/ |
|||
PageUtils queryPage(AgvStationData data) throws Exception; |
|||
|
|||
/** |
|||
* @Description 新增AGV站点 - rqrq |
|||
* @param data 站点信息 |
|||
* @author rqrq |
|||
* @date 2025/10/14 |
|||
*/ |
|||
void addAgvStation(AgvStationData data) throws Exception; |
|||
|
|||
/** |
|||
* @Description 修改AGV站点 - rqrq |
|||
* @param data 站点信息 |
|||
* @author rqrq |
|||
* @date 2025/10/14 |
|||
*/ |
|||
void updateAgvStation(AgvStationData data) throws Exception; |
|||
|
|||
/** |
|||
* @Description 获取区域类型下拉选项 - rqrq |
|||
* @return List<Area> |
|||
* @author rqrq |
|||
* @date 2025/10/14 |
|||
*/ |
|||
List<Area> getAreaOptions() throws Exception; |
|||
} |
|||
|
|||
@ -0,0 +1,249 @@ |
|||
package com.gaotao.modules.automatedWarehouse.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
|
|||
import com.gaotao.common.utils.PageUtils; |
|||
import com.gaotao.modules.automatedWarehouse.entity.AgvStation; |
|||
import com.gaotao.modules.automatedWarehouse.entity.AgvStationData; |
|||
import com.gaotao.modules.automatedWarehouse.entity.Area; |
|||
import com.gaotao.modules.automatedWarehouse.mapper.AgvStationMapper; |
|||
import com.gaotao.modules.automatedWarehouse.service.AgvStationService; |
|||
import com.gaotao.modules.warehouse.entity.Location; |
|||
import com.gaotao.modules.warehouse.dao.LocationMapper; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.StringUtils; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description AGV站点信息服务实现类 - rqrq |
|||
* @Author rqrq |
|||
* @Date 2025/10/14 |
|||
*/ |
|||
@Service |
|||
public class AgvStationServiceImpl extends ServiceImpl<AgvStationMapper, AgvStation> |
|||
implements AgvStationService { |
|||
|
|||
@Autowired |
|||
private LocationMapper locationMapper; |
|||
|
|||
/** |
|||
* @Description 分页查询AGV站点列表 - rqrq |
|||
* @param data 查询条件 |
|||
* @return PageUtils |
|||
* @author rqrq |
|||
* @date 2025/10/14 |
|||
*/ |
|||
@Override |
|||
public PageUtils queryPage(AgvStationData data) throws Exception { |
|||
System.out.println("开始查询AGV站点列表 - rqrq"); |
|||
|
|||
// 构建查询条件 - rqrq |
|||
QueryWrapper<AgvStation> wrapper = new QueryWrapper<>(); |
|||
|
|||
// 只查询station_type='正式站点' 且 active='Y'的数据 - rqrq |
|||
if (StringUtils.hasText(data.getStationType())) { |
|||
wrapper.eq("station_type", data.getStationType()); |
|||
} |
|||
if (StringUtils.hasText(data.getActive())) { |
|||
wrapper.eq("active", data.getActive()); |
|||
} |
|||
|
|||
// 站点编码模糊查询 - rqrq |
|||
if (StringUtils.hasText(data.getSearchStationCode())) { |
|||
wrapper.like("station_code", data.getSearchStationCode()); |
|||
} |
|||
|
|||
// 站点名称模糊查询 - rqrq |
|||
if (StringUtils.hasText(data.getSearchStationName())) { |
|||
wrapper.like("station_name", data.getSearchStationName()); |
|||
} |
|||
|
|||
// 站点ID模糊查询 - rqrq |
|||
if (StringUtils.hasText(data.getSearchStationId())) { |
|||
wrapper.like("station_id", data.getSearchStationId()); |
|||
} |
|||
|
|||
// 按ID倒序排列 - rqrq |
|||
wrapper.orderByDesc("id"); |
|||
|
|||
// 分页查询 - rqrq |
|||
int page = data.getPage() != null ? data.getPage() : 1; |
|||
int limit = data.getLimit() != null ? data.getLimit() : 20; |
|||
|
|||
IPage<AgvStation> pageResult = this.baseMapper.selectPage( |
|||
new Page<>(page, limit), |
|||
wrapper |
|||
); |
|||
|
|||
System.out.println("查询AGV站点列表完成 - rqrq,共" + pageResult.getTotal() + "条记录"); |
|||
|
|||
return new PageUtils(pageResult); |
|||
} |
|||
|
|||
/** |
|||
* @Description 新增AGV站点 - rqrq |
|||
* @param data 站点信息 |
|||
* @author rqrq |
|||
* @date 2025/10/14 |
|||
*/ |
|||
@Override |
|||
public void addAgvStation(AgvStationData data) throws Exception { |
|||
System.out.println("开始新增AGV站点 - rqrq,站点编码:" + data.getStationCode()); |
|||
|
|||
// 校验库位是否存在 - rqrq |
|||
validateLocation(data.getLocationCode(), data.getWarehouseCode()); |
|||
|
|||
// 根据area_type查询area表获取area_desc - rqrq |
|||
if (StringUtils.hasText(data.getAreaType())) { |
|||
List<Area> areaList = this.baseMapper.getAreaOptions(); |
|||
for (Area area : areaList) { |
|||
if (data.getAreaType().equals(area.getAreaId())) { |
|||
data.setStationArea(area.getAreaDesc()); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
// 根据status_db设置status - rqrq |
|||
if (data.getStatusDb() != null) { |
|||
switch (data.getStatusDb()) { |
|||
case 0: |
|||
data.setStatus("空闲"); |
|||
break; |
|||
case 1: |
|||
data.setStatus("有货"); |
|||
break; |
|||
case 2: |
|||
data.setStatus("待放货"); |
|||
break; |
|||
case 3: |
|||
data.setStatus("待取货"); |
|||
break; |
|||
default: |
|||
data.setStatus("未知"); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
// 设置默认站点类型为"正式站点" - rqrq |
|||
if (!StringUtils.hasText(data.getStationType())) { |
|||
data.setStationType("正式站点"); |
|||
} |
|||
|
|||
// 保存到数据库 - rqrq |
|||
this.save(data); |
|||
|
|||
System.out.println("新增AGV站点完成 - rqrq"); |
|||
} |
|||
|
|||
/** |
|||
* @Description 修改AGV站点 - rqrq |
|||
* @param data 站点信息 |
|||
* @author rqrq |
|||
* @date 2025/10/14 |
|||
*/ |
|||
@Override |
|||
public void updateAgvStation(AgvStationData data) throws Exception { |
|||
System.out.println("开始修改AGV站点 - rqrq,站点ID:" + data.getId()); |
|||
|
|||
// 校验库位是否存在 - rqrq |
|||
validateLocation(data.getLocationCode(), data.getWarehouseCode()); |
|||
|
|||
// 根据area_type查询area表获取area_desc - rqrq |
|||
if (StringUtils.hasText(data.getAreaType())) { |
|||
List<Area> areaList = this.baseMapper.getAreaOptions(); |
|||
for (Area area : areaList) { |
|||
if (data.getAreaType().equals(area.getAreaId())) { |
|||
data.setStationArea(area.getAreaDesc()); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
// 根据status_db设置status - rqrq |
|||
if (data.getStatusDb() != null) { |
|||
switch (data.getStatusDb()) { |
|||
case 0: |
|||
data.setStatus("空闲"); |
|||
break; |
|||
case 1: |
|||
data.setStatus("有货"); |
|||
break; |
|||
case 2: |
|||
data.setStatus("待放货"); |
|||
break; |
|||
case 3: |
|||
data.setStatus("待取货"); |
|||
break; |
|||
default: |
|||
data.setStatus("未知"); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
// 更新到数据库 - rqrq |
|||
this.updateById(data); |
|||
|
|||
System.out.println("修改AGV站点完成 - rqrq"); |
|||
} |
|||
|
|||
/** |
|||
* @Description 获取区域类型下拉选项 - rqrq |
|||
* @return List<Area> |
|||
* @author rqrq |
|||
* @date 2025/10/14 |
|||
*/ |
|||
@Override |
|||
public List<Area> getAreaOptions() throws Exception { |
|||
System.out.println("开始获取区域类型下拉选项 - rqrq"); |
|||
|
|||
List<Area> areaList = this.baseMapper.getAreaOptions(); |
|||
|
|||
System.out.println("获取区域类型下拉选项完成 - rqrq,共" + areaList.size() + "条记录"); |
|||
|
|||
return areaList; |
|||
} |
|||
|
|||
/** |
|||
* @Description 校验库位是否存在于指定仓库 - rqrq |
|||
* @param locationCode 库位编码 |
|||
* @param warehouseCode 仓库编码 |
|||
* @author rqrq |
|||
* @date 2025/10/14 |
|||
*/ |
|||
private void validateLocation(String locationCode, String warehouseCode) { |
|||
System.out.println("开始校验库位 - rqrq,库位编码:" + locationCode + ",仓库编码:" + warehouseCode); |
|||
|
|||
// 检查参数是否为空 - rqrq |
|||
if (!StringUtils.hasText(locationCode)) { |
|||
System.out.println("库位编码为空,跳过校验 - rqrq"); |
|||
return; |
|||
} |
|||
|
|||
if (!StringUtils.hasText(warehouseCode)) { |
|||
System.out.println("仓库编码为空,跳过校验 - rqrq"); |
|||
return; |
|||
} |
|||
|
|||
// 查询库位表,检查库位是否存在于指定仓库 - rqrq |
|||
QueryWrapper<Location> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq("LocationID", locationCode); |
|||
wrapper.eq("WareHouseID", warehouseCode); |
|||
|
|||
Location location = locationMapper.selectOne(wrapper); |
|||
|
|||
if (location == null) { |
|||
String errorMsg = "仓库【" + warehouseCode + "】下不存在库位【" + locationCode + "】,请先在库位管理中创建该库位"; |
|||
System.out.println("库位校验失败 - rqrq:" + errorMsg); |
|||
throw new RuntimeException(errorMsg); |
|||
} |
|||
|
|||
System.out.println("库位校验通过 - rqrq"); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,16 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.gaotao.modules.automatedWarehouse.mapper.AgvStationMapper"> |
|||
|
|||
<!-- rqrq - 获取区域类型下拉选项 --> |
|||
<select id="getAreaOptions" resultType="Area"> |
|||
SELECT |
|||
area_id AS areaId, |
|||
area_desc AS areaDesc |
|||
FROM area |
|||
ORDER BY area_id |
|||
</select> |
|||
|
|||
</mapper> |
|||
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue