成品库存过期

master
maxw@mesnac.com 1 month ago
parent 3ad2ca23c8
commit 4e13e7b5f3

@ -0,0 +1,117 @@
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.common.mybatis.core.page.TableDataInfo;
import org.dromara.wms.domain.bo.WmsPsmAreaBo;
import org.dromara.wms.domain.vo.WmsPsmAreaVo;
import org.dromara.wms.service.IWmsPsmAreaService;
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;
/**
*
* 访:/system/psmArea
*
* @author LionLi
* @date 2025-02-27
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/psmArea")
public class WmsPsmAreaController extends BaseController {
private final IWmsPsmAreaService wmsPsmAreaService;
/**
*
*/
@SaCheckPermission("system:psmArea:list")
@GetMapping("/list")
public TableDataInfo<WmsPsmAreaVo> list(WmsPsmAreaBo bo, PageQuery pageQuery) {
return wmsPsmAreaService.queryPageList(bo, pageQuery);
}
/**
*
*/
@SaCheckPermission("system:psmArea:export")
@Log(title = "成品库区", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(WmsPsmAreaBo bo, HttpServletResponse response) {
List<WmsPsmAreaVo> list = wmsPsmAreaService.queryList(bo);
ExcelUtil.exportExcel(list, "成品库区", WmsPsmAreaVo.class, response);
}
/**
*
*
* @param areaId
*/
@SaCheckPermission("system:psmArea:query")
@GetMapping("/{areaId}")
public R<WmsPsmAreaVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long areaId) {
return R.ok(wmsPsmAreaService.queryById(areaId));
}
/**
*
*/
@SaCheckPermission("system:psmArea:add")
@Log(title = "成品库区", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody WmsPsmAreaBo bo) {
return toAjax(wmsPsmAreaService.insertByBo(bo));
}
/**
*
*/
@SaCheckPermission("system:psmArea:edit")
@Log(title = "成品库区", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody WmsPsmAreaBo bo) {
return toAjax(wmsPsmAreaService.updateByBo(bo));
}
/**
*
*
* @param areaIds
*/
@SaCheckPermission("system:psmArea:remove")
@Log(title = "成品库区", businessType = BusinessType.DELETE)
@DeleteMapping("/{areaIds}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] areaIds) {
return toAjax(wmsPsmAreaService.deleteWithValidByIds(List.of(areaIds), true));
}
/**
*
*/
@GetMapping("/getWmsPsmAreaList")
public R<List<WmsPsmAreaVo>> getWmsPsmAreaList(WmsPsmAreaBo bo) {
List<WmsPsmAreaVo> list = wmsPsmAreaService.queryList(bo);
return R.ok(list);
}
}

@ -114,4 +114,21 @@ public class WmsPsmStorageController extends BaseController {
List<WmsPsmStorageVo> list = wmsPsmStorageService.queryList(bo);
return R.ok(list);
}
/**
*
*/
@SaCheckPermission("system:psmStorage:list")
@GetMapping("/expiredList")
public TableDataInfo<WmsPsmStorageVo> expiredList(WmsPsmStorageBo bo, PageQuery pageQuery) {
return wmsPsmStorageService.expiredList(bo, pageQuery);
}
/**
*
*/
@SaCheckPermission("system:psmStorage:list")
@GetMapping("/expiringList")
public TableDataInfo<WmsPsmStorageVo> expiringList(WmsPsmStorageBo bo, PageQuery pageQuery) {
return wmsPsmStorageService.expiringList(bo, pageQuery);
}
}

@ -0,0 +1,76 @@
package org.dromara.wms.domain;
import org.dromara.common.tenant.core.TenantEntity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.util.Date;
/**
* wms_psm_area
*
* @author LionLi
* @date 2025-02-27
*/
@Data
@TableName("wms_psm_area")
public class WmsPsmArea {
@Serial
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(value = "area_id", type = IdType.AUTO)
private Long areaId;
/**
*
*/
private String areaName;
/**
*
*/
private String areaCode;
/**
*
*/
private Long warehouseId;
/**
* 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;
/**
*
*/
@TableField(fill = FieldFill.INSERT)
private String createDept;
}

@ -0,0 +1,48 @@
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.WmsPsmArea;
/**
* wms_psm_area
*
* @author LionLi
* @date 2025-02-27
*/
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = WmsPsmArea.class, reverseConvertGenerate = false)
public class WmsPsmAreaBo extends BaseEntity {
/**
*
*/
@NotNull(message = "主键不能为空", groups = { AddGroup.class, EditGroup.class })
private Long areaId;
/**
*
*/
@NotBlank(message = "库区名称不能为空", groups = { AddGroup.class, EditGroup.class })
private String areaName;
/**
*
*/
@NotBlank(message = "库区代码不能为空", groups = { AddGroup.class, EditGroup.class })
private String areaCode;
/**
*
*/
@NotNull(message = "仓库不能为空", groups = { AddGroup.class, EditGroup.class })
private Long warehouseId;
}

@ -0,0 +1,89 @@
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.WmsPsmArea;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
/**
* wms_psm_area
*
* @author LionLi
* @date 2025-02-27
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = WmsPsmArea.class)
public class WmsPsmAreaVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
*
*/
@ExcelProperty(value = "主键")
private Long areaId;
/**
*
*/
@ExcelProperty(value = "库区名称")
private String areaName;
/**
*
*/
@ExcelProperty(value = "库区代码")
private String areaCode;
/**
*
*/
@ExcelProperty(value = "仓库")
private Long warehouseId;
/**
* id
*/
private String tenantId;
private String createBy;
/**
*
*/
private Date createTime;
/**
*
*/
private String updateBy;
/**
*
*/
private Date updateTime;
/**
*
*/
private String createDept;
}

@ -1,15 +1,22 @@
package org.dromara.wms.mapper;
import com.baomidou.mybatisplus.extension.toolkit.Db;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.dromara.wms.domain.WmsAllocateOrderDetail;
import org.dromara.wms.domain.vo.WmsAllocateOrderDetailVo;
import java.util.ArrayList;
import java.util.Collection;
/**
* Mapper
*
* @author LionLi
* @date 2025-01-09
*/
public interface WmsAllocateOrderDetailMapper extends BaseMapperPlus<WmsAllocateOrderDetail, WmsAllocateOrderDetailVo> {
public interface WmsAllocateOrderDetailMapper extends BaseMapperPlus<WmsAllocateOrderDetail, WmsAllocateOrderDetailVo>{
@Options(useGeneratedKeys = false)
int insertDetails(@Param("list") ArrayList<WmsAllocateOrderDetail> list);
}

@ -0,0 +1,15 @@
package org.dromara.wms.mapper;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.dromara.wms.domain.WmsPsmArea;
import org.dromara.wms.domain.vo.WmsPsmAreaVo;
/**
* Mapper
*
* @author LionLi
* @date 2025-02-27
*/
public interface WmsPsmAreaMapper extends BaseMapperPlus<WmsPsmArea, WmsPsmAreaVo> {
}

@ -1,9 +1,13 @@
package org.dromara.wms.mapper;
import org.apache.ibatis.annotations.Param;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.dromara.wms.domain.WmsPsmStorage;
import org.dromara.wms.domain.bo.WmsPsmStorageBo;
import org.dromara.wms.domain.vo.WmsPsmStorageVo;
import java.util.List;
/**
* Mapper
*
@ -12,4 +16,7 @@ import org.dromara.wms.domain.vo.WmsPsmStorageVo;
*/
public interface WmsPsmStorageMapper extends BaseMapperPlus<WmsPsmStorage, WmsPsmStorageVo> {
List<WmsPsmStorageVo> expiredList(@Param("entity") WmsPsmStorageBo bo);
List<WmsPsmStorageVo> expiringList(@Param("entity") WmsPsmStorageBo bo);
}

@ -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.WmsPsmAreaBo;
import org.dromara.wms.domain.vo.WmsPsmAreaVo;
import java.util.Collection;
import java.util.List;
/**
* Service
*
* @author LionLi
* @date 2025-02-27
*/
public interface IWmsPsmAreaService {
/**
*
*
* @param areaId
* @return
*/
WmsPsmAreaVo queryById(Long areaId);
/**
*
*
* @param bo
* @param pageQuery
* @return
*/
TableDataInfo<WmsPsmAreaVo> queryPageList(WmsPsmAreaBo bo, PageQuery pageQuery);
/**
*
*
* @param bo
* @return
*/
List<WmsPsmAreaVo> queryList(WmsPsmAreaBo bo);
/**
*
*
* @param bo
* @return
*/
Boolean insertByBo(WmsPsmAreaBo bo);
/**
*
*
* @param bo
* @return
*/
Boolean updateByBo(WmsPsmAreaBo bo);
/**
*
*
* @param ids
* @param isValid
* @return
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
}

@ -65,4 +65,8 @@ public interface IWmsPsmStorageService {
* @return
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
TableDataInfo<WmsPsmStorageVo> expiredList(WmsPsmStorageBo bo, PageQuery pageQuery);
TableDataInfo<WmsPsmStorageVo> expiringList(WmsPsmStorageBo bo, PageQuery pageQuery);
}

@ -21,6 +21,8 @@ import org.dromara.wms.domain.vo.WmsAllocateOrderDetailVo;
import org.dromara.wms.mapper.WmsAllocateOrderDetailMapper;
import org.dromara.wms.service.IWmsAllocateOrderDetailService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
@ -110,14 +112,12 @@ public class WmsAllocateOrderDetailServiceImpl implements IWmsAllocateOrderDetai
ArrayList<WmsAllocateOrderDetail> list = new ArrayList<>();
for (WmsAllocateOrderDetailBo detailBo : bo) {
WmsAllocateOrderDetail add = MapstructUtils.convert(detailBo, WmsAllocateOrderDetail.class);
add.setCreateBy(LoginHelper.getUsername());
add.setTenantId(LoginHelper.getTenantId());
list.add(add);
}
boolean flag = baseMapper.insertBatch(list);
// if (flag) {
// bo.setAoDId(add.getAoDId());
// }
return flag;
int i = baseMapper.insertDetails(list);
return i > 0;
}
/**

@ -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.dromara.wms.domain.WmsPsmArea;
import org.dromara.wms.domain.bo.WmsPsmAreaBo;
import org.dromara.wms.domain.vo.WmsPsmAreaVo;
import org.dromara.wms.mapper.WmsPsmAreaMapper;
import org.dromara.wms.service.IWmsPsmAreaService;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Collection;
/**
* Service
*
* @author LionLi
* @date 2025-02-27
*/
@RequiredArgsConstructor
@Service
public class WmsPsmAreaServiceImpl implements IWmsPsmAreaService {
private final WmsPsmAreaMapper baseMapper;
/**
*
*
* @param areaId
* @return
*/
@Override
public WmsPsmAreaVo queryById(Long areaId){
return baseMapper.selectVoById(areaId);
}
/**
*
*
* @param bo
* @param pageQuery
* @return
*/
@Override
public TableDataInfo<WmsPsmAreaVo> queryPageList(WmsPsmAreaBo bo, PageQuery pageQuery) {
MPJLambdaWrapper<WmsPsmArea> lqw = buildQueryWrapper(bo);
Page<WmsPsmAreaVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
/**
*
*
* @param bo
* @return
*/
@Override
public List<WmsPsmAreaVo> queryList(WmsPsmAreaBo bo) {
MPJLambdaWrapper<WmsPsmArea> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private MPJLambdaWrapper<WmsPsmArea> buildQueryWrapper(WmsPsmAreaBo bo) {
Map<String, Object> params = bo.getParams();
MPJLambdaWrapper<WmsPsmArea> lqw = JoinWrappers.lambda(WmsPsmArea.class)
.selectAll(WmsPsmArea.class)
.eq(bo.getAreaId() != null, WmsPsmArea::getAreaId, bo.getAreaId())
.like(StringUtils.isNotBlank(bo.getAreaName()), WmsPsmArea::getAreaName, bo.getAreaName())
.like(StringUtils.isNotBlank(bo.getAreaCode()), WmsPsmArea::getAreaCode, bo.getAreaCode())
.eq(bo.getWarehouseId() != null, WmsPsmArea::getWarehouseId, bo.getWarehouseId())
.orderByDesc(WmsPsmArea::getCreateTime);
return lqw;
}
/**
*
*
* @param bo
* @return
*/
@Override
public Boolean insertByBo(WmsPsmAreaBo bo) {
WmsPsmArea add = MapstructUtils.convert(bo, WmsPsmArea.class);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setAreaId(add.getAreaId());
}
return flag;
}
/**
*
*
* @param bo
* @return
*/
@Override
public Boolean updateByBo(WmsPsmAreaBo bo) {
WmsPsmArea update = MapstructUtils.convert(bo, WmsPsmArea.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
*
*/
private void validEntityBeforeSave(WmsPsmArea entity){
//TODO 做一些数据校验,如唯一约束
}
/**
*
*
* @param ids
* @param isValid
* @return
*/
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteByIds(ids) > 0;
}
}

@ -124,6 +124,24 @@ public class WmsPsmStorageServiceImpl implements IWmsPsmStorageService {
//TODO 做一些数据校验,如唯一约束
}
@Override
public TableDataInfo<WmsPsmStorageVo> expiringList(WmsPsmStorageBo bo, PageQuery pageQuery) {
List<WmsPsmStorageVo> list = baseMapper.expiringList(bo);
Page<WmsPsmStorageVo> page = new Page<>();
page.setRecords(list);
page.setTotal(list.size());
return TableDataInfo.build(page);
}
@Override
public TableDataInfo<WmsPsmStorageVo> expiredList(WmsPsmStorageBo bo, PageQuery pageQuery) {
List<WmsPsmStorageVo> list = baseMapper.expiredList(bo);
Page<WmsPsmStorageVo> page = new Page<>();
page.setRecords(list);
page.setTotal(list.size());
return TableDataInfo.build(page);
}
/**
*
*

@ -4,4 +4,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dromara.wms.mapper.WmsAllocateOrderDetailMapper">
<insert id="insertDetails"
parameterType="org.dromara.wms.domain.WmsAllocateOrderDetail">
INSERT INTO wms_allocate_order_detail
(allocate_code,material_id,allocate_order_qty,tenant_id,create_by,create_time,update_by,update_time)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.allocateCode},#{item.materialId},#{item.allocateOrderQty},#{item.tenantId},#{item.createBy},#{item.createTime},#{item.updateBy},#{item.updateTime})
</foreach>
</insert>
</mapper>

@ -0,0 +1,7 @@
<?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.WmsPsmAreaMapper">
</mapper>

@ -4,4 +4,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dromara.wms.mapper.WmsPsmStorageMapper">
<select id="expiredList" resultType="org.dromara.wms.domain.vo.WmsPsmStorageVo"
parameterType="org.dromara.wms.domain.bo.WmsPsmStorageBo">
SELECT
a.*
from
wms_psm_storage a
left join base_material_info b on
a.material_id = b.material_id
where
DATEADD(HOUR, -b.max_parking_time , GETDATE()) > a.create_time
</select>
<select id="expiringList" resultType="org.dromara.wms.domain.vo.WmsPsmStorageVo"
parameterType="org.dromara.wms.domain.bo.WmsPsmStorageBo">
SELECT
a.*
from
wms_psm_storage a
left join base_material_info b on
a.material_id = b.material_id
where
DATEADD(HOUR, -(b.max_parking_time-1) , GETDATE()) > a.create_time
and a.create_time > DATEADD(HOUR, -(b.max_parking_time) , GETDATE())
</select>
</mapper>

Loading…
Cancel
Save