入库相关接口开发

This commit is contained in:
2025-06-03 14:27:17 +08:00
parent 68f96b9872
commit 1bfc086e8f
5 changed files with 65 additions and 4 deletions

View File

@@ -42,6 +42,17 @@ public class PcdeDetailController extends BaseController
return getDataTable(list);
}
/**
* 查询全部库位明细列表
*/
@PreAuthorize("@ss.hasPermi('information:pcdedetail:list')")
@GetMapping("/getAll")
public AjaxResult getAll()
{
List<PcdeDetail> list = pcdeDetailService.selectPcdeDetailList(new PcdeDetail());
return success(list);
}
/**
* 导出库位明细列表
*/
@@ -85,7 +96,7 @@ public class PcdeDetailController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('information:pcdedetail:add')")
@Log(title = "库位明细", businessType = BusinessType.INSERT)
@PostMapping
@PostMapping("/add")
public AjaxResult add(@RequestBody PcdeDetail pcdeDetail)
{
return toAjax(pcdeDetailService.insertPcdeDetail(pcdeDetail));

View File

@@ -6,6 +6,9 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.zg.common.exception.ServiceException;
import com.zg.common.utils.DateUtils;
import com.zg.project.wisdom.domain.GysJh;
import com.zg.project.wisdom.domain.RkInfo;
import com.zg.project.wisdom.mapper.RkInfoMapper;
import com.zg.project.wisdom.service.IRkInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zg.project.information.mapper.PcdeDetailMapper;
@@ -24,6 +27,9 @@ public class PcdeDetailServiceImpl implements IPcdeDetailService
@Autowired
private PcdeDetailMapper pcdeDetailMapper;
@Autowired
private RkInfoMapper rkInfoMapper;
/**
* 查询库位明细
*
@@ -93,6 +99,24 @@ public class PcdeDetailServiceImpl implements IPcdeDetailService
@Override
public int deletePcdeDetailByIds(Long[] ids)
{
for (Long id : ids) {
// 获取库位信息
PcdeDetail pcdeDetail = pcdeDetailMapper.selectPcdeDetailById(id);
if (pcdeDetail == null) {
throw new ServiceException("ID为 " + id + " 的库位不存在,无法删除");
}
// 获取库位编号
String locationCode = pcdeDetail.getLocationCode();
// 检查该库位是否仍有关联货物
int count = rkInfoMapper.countRkInfoByLocationCode(locationCode);
if (count > 0) {
throw new ServiceException("库位 [" + locationCode + "] 上还有货物,无法批量删除");
}
}
// 全部校验通过后再执行删除
return pcdeDetailMapper.deletePcdeDetailByIds(ids);
}
@@ -105,6 +129,22 @@ public class PcdeDetailServiceImpl implements IPcdeDetailService
@Override
public int deletePcdeDetailById(Long id)
{
// 根据主键获取库位明细
PcdeDetail pcdeDetail = pcdeDetailMapper.selectPcdeDetailById(id);
if (pcdeDetail == null) {
throw new ServiceException("库位信息不存在,无法删除");
}
// 获取库位编号
String locationCode = pcdeDetail.getLocationCode();
// 查询该库位上是否存在库存
int count = rkInfoMapper.countRkInfoByLocationCode(locationCode);
if (count > 0) {
throw new ServiceException("该库位上还有货物,无法删除");
}
// 删除库位信息
return pcdeDetailMapper.deletePcdeDetailById(id);
}

View File

@@ -2,6 +2,7 @@ package com.zg.project.wisdom.mapper;
import java.util.List;
import com.zg.project.wisdom.domain.RkInfo;
import org.apache.ibatis.annotations.Param;
/**
* 库存单据主Mapper接口
@@ -58,4 +59,11 @@ public interface RkInfoMapper
* @return
*/
int batchInsertRkInfo(List<RkInfo> saveList);
/**
* 根据库位编码查询入库单据
* @param locationCode
* @return
*/
int countRkInfoByLocationCode(@Param("locationCode") String locationCode);
}

View File

@@ -26,9 +26,6 @@ import com.zg.project.wisdom.service.IRkInfoService;
public class RkInfoServiceImpl implements IRkInfoService
{
@Autowired
private IGysJhService gysJhService;
@Autowired
private RkInfoMapper rkInfoMapper;

View File

@@ -117,6 +117,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id} and is_delete = 0
</select>
<select id="countRkInfoByLocationCode" resultType="int">
SELECT COUNT(1)
FROM rk_info
WHERE pcode = #{locationCode} AND is_delete = 0
</select>
<update id="updateRkInfo" parameterType="RkInfo">
update rk_info
<trim prefix="SET" suffixOverrides=",">