add 入库单保存主子表
parent
9ed76216bd
commit
5462616262
@ -0,0 +1,116 @@
|
||||
package org.dromara.wms.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.wms.domain.vo.WmsInStockDetailsVo;
|
||||
import org.dromara.wms.domain.bo.WmsInStockDetailsBo;
|
||||
import org.dromara.wms.service.IWmsInStockDetailsService;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 入库单明细
|
||||
* 前端访问路由地址为:/wms/inStockDetails
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-10-28
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/inStockDetails")
|
||||
public class WmsInStockDetailsController extends BaseController {
|
||||
|
||||
private final IWmsInStockDetailsService wmsInStockDetailsService;
|
||||
|
||||
/**
|
||||
* 查询入库单明细列表
|
||||
*/
|
||||
@SaCheckPermission("wms:inStockDetails:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<WmsInStockDetailsVo> list(WmsInStockDetailsBo bo, PageQuery pageQuery) {
|
||||
return wmsInStockDetailsService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出入库单明细列表
|
||||
*/
|
||||
@SaCheckPermission("wms:inStockDetails:export")
|
||||
@Log(title = "入库单明细", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(WmsInStockDetailsBo bo, HttpServletResponse response) {
|
||||
List<WmsInStockDetailsVo> list = wmsInStockDetailsService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "入库单明细", WmsInStockDetailsVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取入库单明细详细信息
|
||||
*
|
||||
* @param inStockDetailsId 主键
|
||||
*/
|
||||
@SaCheckPermission("wms:inStockDetails:query")
|
||||
@GetMapping("/{inStockDetailsId}")
|
||||
public R<WmsInStockDetailsVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable("inStockDetailsId") Long inStockDetailsId) {
|
||||
return R.ok(wmsInStockDetailsService.queryById(inStockDetailsId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增入库单明细
|
||||
*/
|
||||
@SaCheckPermission("wms:inStockDetails:add")
|
||||
@Log(title = "入库单明细", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody WmsInStockDetailsBo bo) {
|
||||
return toAjax(wmsInStockDetailsService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改入库单明细
|
||||
*/
|
||||
@SaCheckPermission("wms:inStockDetails:edit")
|
||||
@Log(title = "入库单明细", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody WmsInStockDetailsBo bo) {
|
||||
return toAjax(wmsInStockDetailsService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除入库单明细
|
||||
*
|
||||
* @param inStockDetailsIds 主键串
|
||||
*/
|
||||
@SaCheckPermission("wms:inStockDetails:remove")
|
||||
@Log(title = "入库单明细", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{inStockDetailsIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable("inStockDetailsIds") Long[] inStockDetailsIds) {
|
||||
return toAjax(wmsInStockDetailsService.deleteWithValidByIds(List.of(inStockDetailsIds), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉框查询入库单明细列表
|
||||
*/
|
||||
@GetMapping("/getWmsInStockDetailsList")
|
||||
public R<List<WmsInStockDetailsVo>> getWmsInStockDetailsList(WmsInStockDetailsBo bo) {
|
||||
List<WmsInStockDetailsVo> list = wmsInStockDetailsService.queryList(bo);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
package org.dromara.wms.domain.bo;
|
||||
|
||||
import org.dromara.wms.domain.WmsInStockDetails;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 入库单明细业务对象 wms_in_stock_details
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-10-28
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = WmsInStockDetails.class, reverseConvertGenerate = false)
|
||||
public class WmsInStockDetailsBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 入库单明细ID
|
||||
*/
|
||||
@NotNull(message = "入库单明细ID不能为空", groups = { EditGroup.class })
|
||||
private Long inStockDetailsId;
|
||||
|
||||
/**
|
||||
* 入库单ID
|
||||
*/
|
||||
private Long inStockBillId;
|
||||
|
||||
/**
|
||||
* 仓库ID
|
||||
*/
|
||||
private Long warehouseId;
|
||||
|
||||
/**
|
||||
* 物料ID
|
||||
*/
|
||||
private Long materialId;
|
||||
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
private String batchNumber;
|
||||
|
||||
/**
|
||||
* 单价
|
||||
*/
|
||||
private Double unitPrice;
|
||||
|
||||
/**
|
||||
* 入库数量
|
||||
*/
|
||||
private Double inStockAmount;
|
||||
|
||||
/**
|
||||
* 物料单位
|
||||
*/
|
||||
private String unitName;
|
||||
|
||||
/**
|
||||
* 总价
|
||||
*/
|
||||
private Double totalPrice;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
package org.dromara.wms.domain.vo;
|
||||
|
||||
import org.dromara.wms.domain.WmsInStockDetails;
|
||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 入库单明细视图对象 wms_in_stock_details
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-10-28
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = WmsInStockDetails.class)
|
||||
public class WmsInStockDetailsVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 入库单明细ID
|
||||
*/
|
||||
@ExcelProperty(value = "入库单明细ID")
|
||||
private Long inStockDetailsId;
|
||||
|
||||
/**
|
||||
* 入库单ID
|
||||
*/
|
||||
@ExcelProperty(value = "入库单ID")
|
||||
private Long inStockBillId;
|
||||
|
||||
/**
|
||||
* 仓库ID
|
||||
*/
|
||||
@ExcelProperty(value = "仓库ID")
|
||||
private Long warehouseId;
|
||||
|
||||
/**
|
||||
* 物料ID
|
||||
*/
|
||||
@ExcelProperty(value = "物料ID")
|
||||
private Long materialId;
|
||||
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
@ExcelProperty(value = "批次号")
|
||||
private String batchNumber;
|
||||
|
||||
/**
|
||||
* 单价
|
||||
*/
|
||||
@ExcelProperty(value = "单价")
|
||||
private Double unitPrice;
|
||||
|
||||
/**
|
||||
* 入库数量
|
||||
*/
|
||||
@ExcelProperty(value = "入库数量")
|
||||
private Double inStockAmount;
|
||||
|
||||
/**
|
||||
* 物料单位
|
||||
*/
|
||||
@ExcelProperty(value = "物料单位")
|
||||
private String unitName;
|
||||
|
||||
/**
|
||||
* 总价
|
||||
*/
|
||||
@ExcelProperty(value = "总价")
|
||||
private Double totalPrice;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ExcelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@ExcelProperty(value = "更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package org.dromara.wms.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.wms.domain.WmsInStockDetails;
|
||||
import org.dromara.wms.domain.vo.WmsInStockDetailsVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 入库单明细Mapper接口
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-10-28
|
||||
*/
|
||||
@Repository
|
||||
public interface WmsInStockDetailsMapper extends BaseMapperPlus<WmsInStockDetails, WmsInStockDetailsVo> {
|
||||
|
||||
/**
|
||||
* 查询入库单明细列表
|
||||
*
|
||||
* @param page 分页
|
||||
* @param queryWrapper 条件
|
||||
* @return 入库单明细集合
|
||||
*/
|
||||
public Page<WmsInStockDetailsVo> selectCustomWmsInStockDetailsVoList(@Param("page") Page<WmsInStockDetailsVo> page, @Param(Constants.WRAPPER) MPJLambdaWrapper<WmsInStockDetails> queryWrapper);
|
||||
|
||||
/**
|
||||
* 查询入库单明细列表
|
||||
*
|
||||
* @param queryWrapper 条件
|
||||
* @return 入库单明细集合
|
||||
*/
|
||||
public List<WmsInStockDetailsVo> selectCustomWmsInStockDetailsVoList(@Param(Constants.WRAPPER) MPJLambdaWrapper<WmsInStockDetails> queryWrapper);
|
||||
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
package org.dromara.wms.service;
|
||||
|
||||
import org.dromara.wms.domain.WmsInStockDetails;
|
||||
import org.dromara.wms.domain.vo.WmsInStockDetailsVo;
|
||||
import org.dromara.wms.domain.bo.WmsInStockDetailsBo;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 入库单明细Service接口
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-10-28
|
||||
*/
|
||||
public interface IWmsInStockDetailsService {
|
||||
|
||||
/**
|
||||
* 查询入库单明细
|
||||
*
|
||||
* @param inStockDetailsId 主键
|
||||
* @return 入库单明细
|
||||
*/
|
||||
WmsInStockDetailsVo queryById(Long inStockDetailsId);
|
||||
|
||||
/**
|
||||
* 分页查询入库单明细列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 入库单明细分页列表
|
||||
*/
|
||||
TableDataInfo<WmsInStockDetailsVo> queryPageList(WmsInStockDetailsBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的入库单明细列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 入库单明细列表
|
||||
*/
|
||||
List<WmsInStockDetailsVo> queryList(WmsInStockDetailsBo bo);
|
||||
|
||||
/**
|
||||
* 新增入库单明细
|
||||
*
|
||||
* @param bo 入库单明细
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(WmsInStockDetailsBo bo);
|
||||
|
||||
/**
|
||||
* 修改入库单明细
|
||||
*
|
||||
* @param bo 入库单明细
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(WmsInStockDetailsBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除入库单明细信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@ -0,0 +1,135 @@
|
||||
package org.dromara.wms.service.impl;
|
||||
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.toolkit.JoinWrappers;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.wms.domain.bo.WmsInStockDetailsBo;
|
||||
import org.dromara.wms.domain.vo.WmsInStockDetailsVo;
|
||||
import org.dromara.wms.domain.WmsInStockDetails;
|
||||
import org.dromara.wms.mapper.WmsInStockDetailsMapper;
|
||||
import org.dromara.wms.service.IWmsInStockDetailsService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 入库单明细Service业务层处理
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-10-28
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class WmsInStockDetailsServiceImpl implements IWmsInStockDetailsService {
|
||||
|
||||
private final WmsInStockDetailsMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询入库单明细
|
||||
*
|
||||
* @param inStockDetailsId 主键
|
||||
* @return 入库单明细
|
||||
*/
|
||||
@Override
|
||||
public WmsInStockDetailsVo queryById(Long inStockDetailsId){
|
||||
return baseMapper.selectVoById(inStockDetailsId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询入库单明细列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 入库单明细分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<WmsInStockDetailsVo> queryPageList(WmsInStockDetailsBo bo, PageQuery pageQuery) {
|
||||
MPJLambdaWrapper<WmsInStockDetails> lqw = buildQueryWrapper(bo);
|
||||
Page<WmsInStockDetailsVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的入库单明细列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 入库单明细列表
|
||||
*/
|
||||
@Override
|
||||
public List<WmsInStockDetailsVo> queryList(WmsInStockDetailsBo bo) {
|
||||
MPJLambdaWrapper<WmsInStockDetails> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private MPJLambdaWrapper<WmsInStockDetails> buildQueryWrapper(WmsInStockDetailsBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
MPJLambdaWrapper<WmsInStockDetails> lqw = JoinWrappers.lambda(WmsInStockDetails.class)
|
||||
.selectAll(WmsInStockDetails.class)
|
||||
.eq(bo.getInStockBillId() != null, WmsInStockDetails::getInStockBillId, bo.getInStockBillId())
|
||||
.eq(bo.getWarehouseId() != null, WmsInStockDetails::getWarehouseId, bo.getWarehouseId())
|
||||
.eq(bo.getMaterialId() != null, WmsInStockDetails::getMaterialId, bo.getMaterialId())
|
||||
.eq(StringUtils.isNotBlank(bo.getBatchNumber()), WmsInStockDetails::getBatchNumber, bo.getBatchNumber())
|
||||
;
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增入库单明细
|
||||
*
|
||||
* @param bo 入库单明细
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(WmsInStockDetailsBo bo) {
|
||||
WmsInStockDetails add = MapstructUtils.convert(bo, WmsInStockDetails.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setInStockDetailsId(add.getInStockDetailsId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改入库单明细
|
||||
*
|
||||
* @param bo 入库单明细
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(WmsInStockDetailsBo bo) {
|
||||
WmsInStockDetails update = MapstructUtils.convert(bo, WmsInStockDetails.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(WmsInStockDetails entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除入库单明细信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
<?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="org.dromara.wms.mapper.WmsInStockDetailsMapper">
|
||||
<resultMap type="org.dromara.wms.domain.vo.WmsInStockDetailsVo" id="WmsInStockDetailsResult">
|
||||
</resultMap>
|
||||
|
||||
<select id="selectCustomWmsInStockDetailsVoList" resultMap="WmsInStockDetailsResult">
|
||||
select in_stock_details_id, tenant_id, in_stock_bill_id, warehouse_id, materiel_id, batch_number, unit_price, in_stock_amount, unit_name, total_price, del_flag, create_dept, create_by, create_time, update_by, update_time from wms_in_stock_details t
|
||||
${ew.getCustomSqlSegment}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue