wms新增物料wms_instock_detail模块

master
maxw@mesnac.com 1 week ago
parent 3c3259cf49
commit 303a1bc364

@ -0,0 +1,107 @@
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.dromara.wms.domain.bo.WmsInstockDetailBo;
import org.dromara.wms.domain.vo.WmsInstockDetailVo;
import org.dromara.wms.service.IWmsInstockDetailService;
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.common.mybatis.core.page.TableDataInfo;
/**
* -
* 访:/system/instockDetail
*
* @author LionLi
* @date 2025-01-06
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/instockDetail")
public class WmsInstockDetailController extends BaseController {
private final IWmsInstockDetailService wmsInstockDetailService;
/**
* -
*/
@SaCheckPermission("system:instockDetail:list")
@GetMapping("/list")
public TableDataInfo<WmsInstockDetailVo> list(WmsInstockDetailBo bo, PageQuery pageQuery) {
return wmsInstockDetailService.queryPageList(bo, pageQuery);
}
/**
* -
*/
@SaCheckPermission("system:instockDetail:export")
@Log(title = "入库单-物料", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(WmsInstockDetailBo bo, HttpServletResponse response) {
List<WmsInstockDetailVo> list = wmsInstockDetailService.queryList(bo);
ExcelUtil.exportExcel(list, "入库单-物料", WmsInstockDetailVo.class, response);
}
/**
* -
*
* @param instockDetailId
*/
@SaCheckPermission("system:instockDetail:query")
@GetMapping("/{instockDetailId}")
public R<WmsInstockDetailVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long instockDetailId) {
return R.ok(wmsInstockDetailService.queryById(instockDetailId));
}
/**
* -
*/
@SaCheckPermission("system:instockDetail:add")
@Log(title = "入库单-物料", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@RequestBody WmsInstockDetailBo bo) {
return toAjax(wmsInstockDetailService.insertByBo(bo));
}
/**
* -
*/
@SaCheckPermission("system:instockDetail:edit")
@Log(title = "入库单-物料", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@RequestBody WmsInstockDetailBo bo) {
return toAjax(wmsInstockDetailService.updateByBo(bo));
}
/**
* -
*
* @param instockDetailIds
*/
@SaCheckPermission("system:instockDetail:remove")
@Log(title = "入库单-物料", businessType = BusinessType.DELETE)
@DeleteMapping("/{instockDetailIds}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] instockDetailIds) {
return toAjax(wmsInstockDetailService.deleteWithValidByIds(List.of(instockDetailIds), true));
}
}

@ -0,0 +1,123 @@
package org.dromara.wms.domain;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.util.Date;
/**
* - wms_instock_detail
*
* @author LionLi
* @date 2025-01-06
*/
@Data
//@EqualsAndHashCode(callSuper = true)
@TableName("wms_instock_detail")
public class WmsInstockDetail{
@Serial
private static final long serialVersionUID = 1L;
/**
*
*/
private Long instockDetailId;
/**
*
*/
private Long instockId;
/**
*
*/
private String instockCode;
/**
* -
*/
private Long dnDId;
/**
* -
*/
private Long poDId;
/**
* id
*/
private Long materialId;
/**
*
*/
private String materialCode;
/**
*
*/
private String materialName;
/**
*
*/
private Long instockQty;
/**
*
*/
private String materialSpe;
/**
*
*/
private String unitName;
/**
*
*/
private String codeYesNo;
/**
*
*/
private String materialCategories;
/**
* id
*/
private String tenantId;
@TableField(fill = FieldFill.INSERT)
private String createBy;
/**
*
*/
@TableField(fill = FieldFill.INSERT)
private Date createTime;
/**
*
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private String updateBy;
/**
*
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
// /**
// * 打印数量
// */
// private Integer printNum;
/**
*
*/
private Integer printedNum;
}

@ -0,0 +1,115 @@
package org.dromara.wms.domain.bo;
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.*;
import org.dromara.wms.domain.WmsInstockDetail;
/**
* - wms_instock_detail
*
* @author LionLi
* @date 2025-01-06
*/
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = WmsInstockDetail.class, reverseConvertGenerate = false)
public class WmsInstockDetailBo extends BaseEntity {
/**
*
*/
@NotNull(message = "入库单子表主键不能为空", groups = { AddGroup.class, EditGroup.class })
private Long instockDetailId;
/**
*
*/
@NotNull(message = "入库单 主键不能为空", groups = { AddGroup.class, EditGroup.class })
private Long instockId;
/**
*
*/
@NotBlank(message = "入库单号不能为空", groups = { AddGroup.class, EditGroup.class })
private String instockCode;
/**
* -
*/
@NotNull(message = "送货-物料表主键不能为空", groups = { AddGroup.class, EditGroup.class })
private Long dnDId;
/**
* -
*/
@NotNull(message = "采购-物料表主键不能为空", groups = { AddGroup.class, EditGroup.class })
private Long poDId;
/**
* id
*/
@NotNull(message = "物料id不能为空", groups = { AddGroup.class, EditGroup.class })
private Long materialId;
/**
*
*/
@NotBlank(message = "物料编码不能为空", groups = { AddGroup.class, EditGroup.class })
private String materialCode;
/**
*
*/
@NotBlank(message = "物料名称不能为空", groups = { AddGroup.class, EditGroup.class })
private String materialName;
/**
*
*/
@NotNull(message = "入库数量不能为空", groups = { AddGroup.class, EditGroup.class })
private Long instockQty;
/**
*
*/
@NotBlank(message = "物料规格不能为空", groups = { AddGroup.class, EditGroup.class })
private String materialSpe;
/**
*
*/
@NotBlank(message = "计量单位名称不能为空", groups = { AddGroup.class, EditGroup.class })
private String unitName;
/**
*
*/
@NotBlank(message = "是否有条码不能为空", groups = { AddGroup.class, EditGroup.class })
private String codeYesNo;
/**
*
*/
@NotBlank(message = "物料大类不能为空", groups = { AddGroup.class, EditGroup.class })
private String materialCategories;
/**
* id
*/
private String tenantId;
/**
*
*/
private Integer printNum;
/**
*
*/
private Integer printedNum;
private Long barcodeNum;
}

@ -0,0 +1,140 @@
package org.dromara.wms.domain.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import org.dromara.common.excel.annotation.ExcelDictFormat;
import org.dromara.common.excel.convert.ExcelDictConvert;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import org.dromara.wms.domain.WmsInstockDetail;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
/**
* - wms_instock_detail
*
* @author LionLi
* @date 2025-01-06
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = WmsInstockDetail.class)
public class WmsInstockDetailVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
*
*/
@ExcelProperty(value = "入库单子表主键")
private Long instockDetailId;
/**
*
*/
@ExcelProperty(value = "入库单 主键")
private Long instockId;
/**
*
*/
@ExcelProperty(value = "入库单号")
private String instockCode;
/**
* -
*/
@ExcelProperty(value = "送货-物料表主键")
private Long dnDId;
/**
* -
*/
@ExcelProperty(value = "采购-物料表主键")
private Long poDId;
/**
* id
*/
@ExcelProperty(value = "物料id")
private Long materialId;
/**
*
*/
@ExcelProperty(value = "物料编码")
private String materialCode;
/**
*
*/
@ExcelProperty(value = "物料名称")
private String materialName;
/**
*
*/
@ExcelProperty(value = "入库数量")
private Long instockQty;
/**
*
*/
@ExcelProperty(value = "物料规格")
private String materialSpe;
/**
*
*/
@ExcelProperty(value = "计量单位名称")
private String unitName;
/**
*
*/
@ExcelProperty(value = "是否有条码")
private String codeYesNo;
/**
*
*/
@ExcelProperty(value = "物料大类")
private String materialCategories;
@TableField(fill = FieldFill.INSERT)
private String createBy;
/**
*
*/
@TableField(fill = FieldFill.INSERT)
private Date createTime;
/**
*
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private String updateBy;
/**
*
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
/**
*
*/
private Integer printedNum;
/**
* id
*/
private String tenantId;
}

@ -0,0 +1,16 @@
package org.dromara.wms.mapper;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.dromara.wms.domain.WmsInstockDetail;
import org.dromara.wms.domain.vo.WmsInstockDetailVo;
/**
* -Mapper
*
* @author LionLi
* @date 2025-01-06
*/
public interface WmsInstockDetailMapper extends BaseMapperPlus<WmsInstockDetail, WmsInstockDetailVo> {
int updateDetail(WmsInstockDetail update);
}

@ -0,0 +1,68 @@
package org.dromara.wms.service;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.wms.domain.bo.WmsInstockDetailBo;
import org.dromara.wms.domain.vo.WmsInstockDetailVo;
import java.util.Collection;
import java.util.List;
/**
* -Service
*
* @author LionLi
* @date 2025-01-06
*/
public interface IWmsInstockDetailService {
/**
* -
*
* @param instockDetailId
* @return -
*/
WmsInstockDetailVo queryById(Long instockDetailId);
/**
* -
*
* @param bo
* @param pageQuery
* @return -
*/
TableDataInfo<WmsInstockDetailVo> queryPageList(WmsInstockDetailBo bo, PageQuery pageQuery);
/**
* -
*
* @param bo
* @return -
*/
List<WmsInstockDetailVo> queryList(WmsInstockDetailBo bo);
/**
* -
*
* @param bo -
* @return
*/
Boolean insertByBo(WmsInstockDetailBo bo);
/**
* -
*
* @param bo -
* @return
*/
Boolean updateByBo(WmsInstockDetailBo bo);
/**
* -
*
* @param ids
* @param isValid
* @return
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
}

@ -0,0 +1,190 @@
package org.dromara.wms.service.impl;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.dromara.wms.domain.WmsInstockDetail;
import org.dromara.wms.domain.WmsInstockOrder;
import org.dromara.wms.domain.WmsInstockPrint;
import org.dromara.wms.domain.bo.WmsInstockDetailBo;
import org.dromara.wms.domain.vo.BaseMaterialInfoVo;
import org.dromara.wms.domain.vo.WmsInstockDetailVo;
import org.dromara.wms.mapper.WmsInstockDetailMapper;
import org.dromara.wms.service.IBaseMaterialInfoService;
import org.dromara.wms.service.IWmsInstockDetailService;
import org.dromara.wms.service.IWmsInstockPrintService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Collection;
/**
* -Service
*
* @author LionLi
* @date 2025-01-06
*/
@RequiredArgsConstructor
@Service
public class WmsInstockDetailServiceImpl implements IWmsInstockDetailService {
private final WmsInstockDetailMapper baseMapper;
@Autowired
private IBaseMaterialInfoService baseMaterialInfoService;
@Autowired
private IWmsInstockPrintService wmsInstockPrintService;
/**
* -
*
* @param instockDetailId
* @return -
*/
@Override
public WmsInstockDetailVo queryById(Long instockDetailId){
LambdaQueryWrapper<WmsInstockDetail> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(WmsInstockDetail::getInstockDetailId,instockDetailId);
return baseMapper.selectVoOne(wrapper);
}
/**
* -
*
* @param bo
* @param pageQuery
* @return -
*/
@Override
public TableDataInfo<WmsInstockDetailVo> queryPageList(WmsInstockDetailBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<WmsInstockDetail> lqw = buildQueryWrapper(bo);
lqw.orderByDesc(WmsInstockDetail::getCreateTime);
Page<WmsInstockDetailVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
/**
* -
*
* @param bo
* @return -
*/
@Override
public List<WmsInstockDetailVo> queryList(WmsInstockDetailBo bo) {
LambdaQueryWrapper<WmsInstockDetail> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<WmsInstockDetail> buildQueryWrapper(WmsInstockDetailBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<WmsInstockDetail> lqw = Wrappers.lambdaQuery();
lqw.eq(bo.getInstockDetailId() != null, WmsInstockDetail::getInstockDetailId, bo.getInstockDetailId());
lqw.eq(bo.getInstockId() != null, WmsInstockDetail::getInstockId, bo.getInstockId());
lqw.eq(StringUtils.isNotBlank(bo.getInstockCode()), WmsInstockDetail::getInstockCode, bo.getInstockCode());
lqw.eq(bo.getDnDId() != null, WmsInstockDetail::getDnDId, bo.getDnDId());
lqw.eq(bo.getPoDId() != null, WmsInstockDetail::getPoDId, bo.getPoDId());
lqw.eq(bo.getMaterialId() != null, WmsInstockDetail::getMaterialId, bo.getMaterialId());
lqw.eq(StringUtils.isNotBlank(bo.getMaterialCode()), WmsInstockDetail::getMaterialCode, bo.getMaterialCode());
lqw.like(StringUtils.isNotBlank(bo.getMaterialName()), WmsInstockDetail::getMaterialName, bo.getMaterialName());
lqw.eq(bo.getInstockQty() != null, WmsInstockDetail::getInstockQty, bo.getInstockQty());
lqw.eq(StringUtils.isNotBlank(bo.getMaterialSpe()), WmsInstockDetail::getMaterialSpe, bo.getMaterialSpe());
lqw.like(StringUtils.isNotBlank(bo.getUnitName()), WmsInstockDetail::getUnitName, bo.getUnitName());
lqw.eq(StringUtils.isNotBlank(bo.getCodeYesNo()), WmsInstockDetail::getCodeYesNo, bo.getCodeYesNo());
lqw.eq(StringUtils.isNotBlank(bo.getMaterialCategories()), WmsInstockDetail::getMaterialCategories, bo.getMaterialCategories());
return lqw;
}
/**
* -
*
* @param bo -
* @return
*/
@Override
public Boolean insertByBo(WmsInstockDetailBo bo) {
WmsInstockDetail add = MapstructUtils.convert(bo, WmsInstockDetail.class);
BaseMaterialInfoVo baseMaterialInfoVo = baseMaterialInfoService.queryById(bo.getMaterialId());
BeanUtils.copyProperties(baseMaterialInfoVo,add);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setInstockDetailId(add.getInstockDetailId());
}
return flag;
}
/**
* -
*
* @param bo -
* @return
*/
@Override
public Boolean updateByBo(WmsInstockDetailBo bo) {
if (bo.getPrintNum()==null){
WmsInstockDetail update = MapstructUtils.convert(bo, WmsInstockDetail.class);
validEntityBeforeSave(update);
return baseMapper.updateDetail(update)>0;
}
//打印数量不能超过入库数量
if (bo.getPrintNum()+bo.getPrintedNum()>bo.getInstockQty()){
return false;
}
Integer printNum = (int)wmsInstockPrintService.queryPrintNum(bo) + 1;
String order = generateOrder(printNum);
WmsInstockPrint wmsInstockPrint = new WmsInstockPrint();
BeanUtils.copyProperties(bo,wmsInstockPrint);
String instockCode = bo.getInstockCode();
String materialCode = bo.getMaterialCode();
String batchCode = instockCode+materialCode+order;
wmsInstockPrint.setBatchCode(batchCode);
wmsInstockPrint.setApportionQty(bo.getPrintNum().longValue());
wmsInstockPrint.setMaterialQty(bo.getBarcodeNum());
int rows = wmsInstockPrintService.insertWmsInstockPrint(wmsInstockPrint);
WmsInstockDetail wmsInstockDetail = new WmsInstockDetail();
wmsInstockDetail.setPrintedNum(bo.getPrintedNum()+bo.getPrintNum());
LambdaUpdateWrapper<WmsInstockDetail> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(WmsInstockDetail::getInstockDetailId,bo.getInstockDetailId());
int update = baseMapper.update(wmsInstockDetail, updateWrapper);
return update>0;
}
public String generateOrder(Integer value){
if (value.toString().length()<3){
String fixedLengthString = String.format("%03d", value);
return fixedLengthString;
}else if (value.toString().length()==3){
return value.toString();
}
return value.toString();
}
/**
*
*/
private void validEntityBeforeSave(WmsInstockDetail 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,22 @@
<?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.WmsInstockDetailMapper">
<update id="updateDetail" parameterType="org.dromara.wms.domain.WmsInstockDetail">
update wms_instock_detail
<trim prefix="SET" suffixOverrides=",">
<if test="dnDId != null">dn_d_id = #{dnDId},</if>
<if test="poDId != null and poDId != ''">po_d_id = #{poDId},</if>
<if test="materialId != null and materialId != ''">material_id = #{materialId},</if>
<if test="instockQty != null">instock_qty = #{instockQty},</if>
<if test="codeYesNo != null">code_yes_no = #{codeYesNo},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where instock_id = #{instockId}
</update>
</mapper>
Loading…
Cancel
Save