add:安全库存设置,安全库存预警
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package org.nl.wms.basedata_manage.controller;
|
||||
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.base.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.wms.basedata_manage.service.IStIvtMaterialsafeivtService;
|
||||
import org.nl.wms.basedata_manage.service.dto.StIvtMaterialLsafeIvtDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 安全库存设置 控制层
|
||||
* </p>
|
||||
*
|
||||
* @author Liuxy
|
||||
* @since 2025-09-01
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/materialsafeivt")
|
||||
@Slf4j
|
||||
public class MaterialLasfeController {
|
||||
|
||||
@Autowired
|
||||
private IStIvtMaterialsafeivtService iStIvtMaterialsafeivtService;
|
||||
|
||||
@GetMapping
|
||||
@Log("分页查询")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page) {
|
||||
return new ResponseEntity<>(TableDataInfo.build(iStIvtMaterialsafeivtService.queryAll(whereJson, page)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/insertSafe")
|
||||
@Log("保存")
|
||||
public ResponseEntity<Object> insertSafe(@RequestBody StIvtMaterialLsafeIvtDto dto) {
|
||||
iStIvtMaterialsafeivtService.insertSafe(dto);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/safeIvtWarning")
|
||||
@Log("安全预警查询")
|
||||
public ResponseEntity<Object> safeIvtWarning(@RequestParam Map whereJson, PageQuery page) {
|
||||
return new ResponseEntity<>(TableDataInfo.build(iStIvtMaterialsafeivtService.safeIvtWarning(whereJson, page)), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.nl.wms.basedata_manage.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.basedata_manage.service.dao.StIvtMaterialsafeivt;
|
||||
import org.nl.wms.basedata_manage.service.dto.StIvtMaterialLsafeIvtDto;
|
||||
import org.nl.wms.warehouse_management.service.dto.PieceBoxMstDto;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 物料安全库存设置表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Liuxy
|
||||
* @since 2025-09-01
|
||||
*/
|
||||
public interface IStIvtMaterialsafeivtService extends IService<StIvtMaterialsafeivt> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param whereJson : {查询参数}
|
||||
* @param page : 分页对象
|
||||
* @return 返回结果
|
||||
*/
|
||||
IPage<StIvtMaterialLsafeIvtDto> queryAll(Map whereJson, PageQuery page);
|
||||
|
||||
/**
|
||||
* 安全库存设置
|
||||
* @param dto dto类
|
||||
*/
|
||||
void insertSafe(StIvtMaterialLsafeIvtDto dto);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param whereJson : {查询参数}
|
||||
* @param page : 分页对象
|
||||
* @return 返回结果
|
||||
*/
|
||||
IPage<StIvtMaterialLsafeIvtDto> safeIvtWarning(Map whereJson, PageQuery page);
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package org.nl.wms.basedata_manage.service.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 物料安全库存设置表
|
||||
* </p>
|
||||
*
|
||||
* @author Liuxy
|
||||
* @since 2025-09-01
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("st_ivt_materialsafeivt")
|
||||
public class StIvtMaterialsafeivt implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 物料标识
|
||||
*/
|
||||
@TableId
|
||||
private String material_id;
|
||||
|
||||
/**
|
||||
* 下限
|
||||
*/
|
||||
private BigDecimal safe_ivt_down;
|
||||
|
||||
/**
|
||||
* 上限
|
||||
*/
|
||||
private BigDecimal safe_ivt_up;
|
||||
|
||||
/**
|
||||
* 计量单位标识
|
||||
*/
|
||||
private String qty_unit_id;
|
||||
|
||||
/**
|
||||
* 计量单位名称
|
||||
*/
|
||||
private String qty_unit_name;
|
||||
|
||||
/**
|
||||
* 设置人标识
|
||||
*/
|
||||
private String set_id;
|
||||
|
||||
/**
|
||||
* 设置人名称
|
||||
*/
|
||||
private String set_name;
|
||||
|
||||
/**
|
||||
* 设置时间
|
||||
*/
|
||||
private String set_time;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.nl.wms.basedata_manage.service.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.nl.wms.basedata_manage.service.dao.StIvtMaterialsafeivt;
|
||||
import org.nl.wms.basedata_manage.service.dto.StIvtMaterialLsafeIvtDto;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 物料安全库存设置表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Liuxy
|
||||
* @since 2025-09-01
|
||||
*/
|
||||
public interface StIvtMaterialsafeivtMapper extends BaseMapper<StIvtMaterialsafeivt> {
|
||||
|
||||
/**
|
||||
* 安全库存分页查询
|
||||
* @param page 分页条件
|
||||
* @param whereJson 查询条件
|
||||
* @return IPage<PieceBoxMstDto>
|
||||
*/
|
||||
IPage<StIvtMaterialLsafeIvtDto> queryAllByPage(Page<StIvtMaterialLsafeIvtDto> page, @Param("param") Map whereJson);
|
||||
|
||||
/**
|
||||
* 安全库存预警查询
|
||||
* @param page 分页条件
|
||||
* @param whereJson 查询条件
|
||||
* @return IPage<PieceBoxMstDto>
|
||||
*/
|
||||
IPage<StIvtMaterialLsafeIvtDto> safeIvtWarning(Page<StIvtMaterialLsafeIvtDto> page, @Param("param") Map whereJson);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?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.nl.wms.basedata_manage.service.dao.mapper.StIvtMaterialsafeivtMapper">
|
||||
<select id="queryAllByPage" resultType="org.nl.wms.basedata_manage.service.dto.StIvtMaterialLsafeIvtDto">
|
||||
SELECT
|
||||
ivt.safe_ivt_down,
|
||||
ivt.safe_ivt_up,
|
||||
ivt.qty_unit_id,
|
||||
ivt.qty_unit_name,
|
||||
ivt.set_id,
|
||||
ivt.set_name,
|
||||
ivt.set_time,
|
||||
mater.material_id,
|
||||
mater.material_code,
|
||||
mater.material_name,
|
||||
mater.material_spec
|
||||
FROM
|
||||
md_me_materialbase mater
|
||||
LEFT JOIN st_ivt_materialsafeivt ivt ON mater.material_id = ivt.material_id
|
||||
<where>
|
||||
1 = 1
|
||||
<if test="param.material_code != null and param.material_code != ''">
|
||||
AND
|
||||
(mater.material_code LIKE #{param.material_code} or
|
||||
mater.material_name LIKE #{param.material_code} )
|
||||
</if>
|
||||
|
||||
</where>
|
||||
ORDER BY ivt.set_time Desc
|
||||
</select>
|
||||
|
||||
<select id="safeIvtWarning" resultType="org.nl.wms.basedata_manage.service.dto.StIvtMaterialLsafeIvtDto">
|
||||
SELECT
|
||||
ivt.safe_ivt_down,
|
||||
ivt.safe_ivt_up,
|
||||
ivt.qty_unit_id,
|
||||
ivt.qty_unit_name,
|
||||
ivt.set_id,
|
||||
ivt.set_name,
|
||||
ivt.set_time,
|
||||
pivt.ivt_qty,
|
||||
mater.material_id,
|
||||
mater.material_code,
|
||||
mater.material_name,
|
||||
mater.material_spec
|
||||
FROM
|
||||
md_me_materialbase mater
|
||||
LEFT JOIN st_ivt_materialsafeivt ivt ON mater.material_id = ivt.material_id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
SUM(canuse_qty) AS ivt_qty,
|
||||
material_id
|
||||
FROM
|
||||
md_pb_storagevehicleext
|
||||
WHERE
|
||||
1 = 1
|
||||
GROUP BY material_id
|
||||
) pivt ON pivt.material_id = mater.material_id
|
||||
<where>
|
||||
1 = 1
|
||||
<if test="param.material_code != null and param.material_code != ''">
|
||||
AND
|
||||
(mater.material_code LIKE #{param.material_code} or
|
||||
mater.material_name LIKE #{param.material_code} )
|
||||
</if>
|
||||
|
||||
<if test="param.is_all != 0 ">
|
||||
AND
|
||||
ivt.safe_ivt_down > pivt.ivt_qty
|
||||
</if>
|
||||
|
||||
</where>
|
||||
ORDER BY ivt.set_time Desc
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.nl.wms.basedata_manage.service.dto;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import org.nl.wms.basedata_manage.service.dao.StIvtMaterialsafeivt;
|
||||
import org.nl.wms.warehouse_management.service.dao.StIvtPieceBoxDtl;
|
||||
import org.nl.wms.warehouse_management.service.dao.StIvtPieceBoxMst;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 拼单管理dto
|
||||
* </p>
|
||||
*
|
||||
* @author Liuxy
|
||||
* @since 2025-09-01
|
||||
*/
|
||||
@Data
|
||||
public class StIvtMaterialLsafeIvtDto extends StIvtMaterialsafeivt {
|
||||
|
||||
/**
|
||||
* 物料编号
|
||||
*/
|
||||
private String material_code;
|
||||
|
||||
/**
|
||||
* 物料名称
|
||||
*/
|
||||
private String material_name;
|
||||
|
||||
/**
|
||||
* 物料批次
|
||||
*/
|
||||
private String material_spec;
|
||||
|
||||
/**
|
||||
* 库存
|
||||
*/
|
||||
private String ivt_qty;
|
||||
|
||||
/**
|
||||
* 新增安全设置明细
|
||||
*/
|
||||
private List<StIvtMaterialsafeivt> rows;
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package org.nl.wms.basedata_manage.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
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 org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.basedata_manage.service.IMdPbMeasureunitService;
|
||||
import org.nl.wms.basedata_manage.service.IStIvtMaterialsafeivtService;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdPbMeasureunit;
|
||||
import org.nl.wms.basedata_manage.service.dao.StIvtMaterialsafeivt;
|
||||
import org.nl.wms.basedata_manage.service.dao.mapper.StIvtMaterialsafeivtMapper;
|
||||
import org.nl.wms.basedata_manage.service.dto.StIvtMaterialLsafeIvtDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 物料安全库存设置表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Liuxy
|
||||
* @since 2025-09-01
|
||||
*/
|
||||
@Service
|
||||
public class StIvtMaterialsafeivtServiceImpl extends ServiceImpl<StIvtMaterialsafeivtMapper, StIvtMaterialsafeivt> implements IStIvtMaterialsafeivtService {
|
||||
|
||||
/**
|
||||
* 计量单位服务
|
||||
*/
|
||||
@Autowired
|
||||
private IMdPbMeasureunitService iMdPbMeasureunitService;
|
||||
|
||||
@Override
|
||||
public IPage<StIvtMaterialLsafeIvtDto> queryAll(Map whereJson, PageQuery page) {
|
||||
return this.baseMapper.queryAllByPage(new Page<>(page.getPage() + 1, page.getSize()),
|
||||
whereJson);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void insertSafe(StIvtMaterialLsafeIvtDto dto) {
|
||||
List<StIvtMaterialsafeivt> rows = dto.getRows();
|
||||
// 判断是否有记录, 有修改,没有新增
|
||||
List<StIvtMaterialsafeivt> ivtList = this.list(
|
||||
new QueryWrapper<StIvtMaterialsafeivt>().lambda()
|
||||
.in(StIvtMaterialsafeivt::getMaterial_id, rows.stream()
|
||||
.map(StIvtMaterialsafeivt::getMaterial_id)
|
||||
.collect(Collectors.toList())
|
||||
)
|
||||
);
|
||||
// 计量单位默认重量KG
|
||||
MdPbMeasureunit unitDao = iMdPbMeasureunitService.getByCode("KG");
|
||||
|
||||
List<StIvtMaterialsafeivt> insertList = new ArrayList<>();
|
||||
List<StIvtMaterialsafeivt> updateList = new ArrayList<>();
|
||||
for (StIvtMaterialsafeivt dao : rows) {
|
||||
StIvtMaterialsafeivt queryDao = ivtList.stream()
|
||||
.filter(row -> row.getMaterial_id().equals(dao.getMaterial_id()))
|
||||
.findFirst().orElse(null);
|
||||
|
||||
if (ObjectUtil.isEmpty(queryDao)) {
|
||||
// 新增
|
||||
StIvtMaterialsafeivt insertDao = new StIvtMaterialsafeivt();
|
||||
insertDao.setMaterial_id(dao.getMaterial_id());
|
||||
insertDao.setQty_unit_id(unitDao.getMeasure_unit_id());
|
||||
insertDao.setQty_unit_name(unitDao.getUnit_name());
|
||||
insertDao.setSafe_ivt_down(dao.getSafe_ivt_down());
|
||||
insertDao.setSet_id(SecurityUtils.getCurrentUserId());
|
||||
insertDao.setSet_name(SecurityUtils.getCurrentNickName());
|
||||
insertDao.setSet_time(DateUtil.now());
|
||||
insertList.add(insertDao);
|
||||
} else {
|
||||
// 修改
|
||||
queryDao.setSafe_ivt_down(dao.getSafe_ivt_up());
|
||||
updateList.add(queryDao);
|
||||
}
|
||||
|
||||
this.saveBatch(insertList);
|
||||
this.updateBatchById(updateList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<StIvtMaterialLsafeIvtDto> safeIvtWarning(Map whereJson, PageQuery page) {
|
||||
return this.baseMapper.safeIvtWarning(new Page<>(page.getPage() + 1, page.getSize()),
|
||||
whereJson);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user