Browse Source

[feat]仓库管理:

库存盘点
完善库存盘点新增接口
新增查询所有物料信息接口
修改库存盘点后端新增接口
新增materialSelect.html页面
新增 物料信息WarehouseMaterialVO 实体类
dev
liuxiaoxu 5 months ago
parent
commit
54bae26845
  1. 33
      ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseInventoryCheckController.java
  2. 30
      ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/VO/WarehouseMaterialVO.java
  3. 14
      ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseInventoryCheck.java
  4. 7
      ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseInventoryCheckService.java
  5. 62
      ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseInventoryCheckServiceImpl.java
  6. 189
      ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/add.html
  7. 18
      ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/inventoryCheck.html
  8. 53
      ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/materialSelect.html

33
ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseInventoryCheckController.java

@ -1,15 +1,13 @@
package com.ruoyi.warehouse.controller;
import java.util.List;
import com.ruoyi.warehouse.domain.VO.WarehouseMaterialVO;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.warehouse.domain.WarehouseInventoryCheck;
@ -84,7 +82,7 @@ public class WarehouseInventoryCheckController extends BaseController
@Log(title = "仓库库存盘点", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(WarehouseInventoryCheck warehouseInventoryCheck)
public AjaxResult addSave(@RequestBody WarehouseInventoryCheck warehouseInventoryCheck)
{
return toAjax(warehouseInventoryCheckService.insertWarehouseInventoryCheck(warehouseInventoryCheck));
}
@ -113,4 +111,27 @@ public class WarehouseInventoryCheckController extends BaseController
}
/**
* 物料信息弹出页面
*/
@GetMapping("/materialSelect")
public String materialSelect()
{
return prefix + "/materialSelect";
}
/**
* 查找与库存查询有关的物料信息
* */
@ResponseBody
@PostMapping("/getAllMaterialInfo")
public TableDataInfo getAllMaterialInfo(){
startPage();
List<WarehouseMaterialVO> list = warehouseInventoryCheckService.selectAllMaterialInfo();
return getDataTable(list);
}
}

30
ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/VO/WarehouseMaterialVO.java

@ -0,0 +1,30 @@
package com.ruoyi.warehouse.domain.VO;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
@Data
public class WarehouseMaterialVO extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 料号 */
@Excel(name = "料号")
private String materialNo;
/** 物料名称 */
@Excel(name = "物料名称")
private String materialName;
/** 物料单位 */
@Excel(name = "物料单位")
private String materialUnit;
/** 物料描述 */
@Excel(name = "物料描述")
private String materialDescribe;
}

14
ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseInventoryCheck.java

@ -1,6 +1,8 @@
package com.ruoyi.warehouse.domain;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@ -57,6 +59,8 @@ public class WarehouseInventoryCheck extends BaseEntity
@Excel(name = "数量合计")
private Integer numTotal;
private List<WarehouseInventoryCheckDetail> inventoryCheckDetails;
public void setInventoryCheckId(Long inventoryCheckId)
{
this.inventoryCheckId = inventoryCheckId;
@ -148,6 +152,15 @@ public class WarehouseInventoryCheck extends BaseEntity
return numTotal;
}
public List<WarehouseInventoryCheckDetail> getInventoryCheckDetails() {
return inventoryCheckDetails;
}
public void setInventoryCheckDetails(List<WarehouseInventoryCheckDetail> inventoryCheckDetails) {
this.inventoryCheckDetails = inventoryCheckDetails;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -166,6 +179,7 @@ public class WarehouseInventoryCheck extends BaseEntity
.append("createBy", getCreateBy())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("inventoryCheckDetails",getInventoryCheckDetails())
.toString();
}
}

7
ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseInventoryCheckService.java

@ -2,6 +2,7 @@ package com.ruoyi.warehouse.service;
import java.util.List;
import com.ruoyi.warehouse.domain.WarehouseInventoryCheck;
import com.ruoyi.warehouse.domain.VO.WarehouseMaterialVO;
/**
* 仓库库存盘点Service接口
@ -43,4 +44,10 @@ public interface IWarehouseInventoryCheckService
*/
public int updateWarehouseInventoryCheck(WarehouseInventoryCheck warehouseInventoryCheck);
/**
* 查找与库存查询有关的物料信息
* */
public List<WarehouseMaterialVO> selectAllMaterialInfo();
}

62
ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseInventoryCheckServiceImpl.java

@ -2,6 +2,8 @@ package com.ruoyi.warehouse.service.impl;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@ -9,12 +11,18 @@ import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.erp.domain.ErpMaterialVo;
import com.ruoyi.erp.mapper.ErpMaterialMapper;
import com.ruoyi.warehouse.domain.VO.WarehouseMaterialVO;
import com.ruoyi.warehouse.domain.WarehouseInventoryCheckDetail;
import com.ruoyi.warehouse.mapper.WarehouseInventoryCheckDetailMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.warehouse.mapper.WarehouseInventoryCheckMapper;
import com.ruoyi.warehouse.domain.WarehouseInventoryCheck;
import com.ruoyi.warehouse.service.IWarehouseInventoryCheckService;
import com.ruoyi.common.core.text.Convert;
import org.springframework.transaction.annotation.Transactional;
/**
* 仓库库存盘点Service业务层处理
@ -22,12 +30,19 @@ import com.ruoyi.common.core.text.Convert;
* @author 刘晓旭
* @date 2024-06-07
*/
@Slf4j
@Service
public class WarehouseInventoryCheckServiceImpl implements IWarehouseInventoryCheckService
{
@Autowired
private WarehouseInventoryCheckMapper warehouseInventoryCheckMapper;
@Autowired
private ErpMaterialMapper erpMaterialMapper;
@Autowired
private WarehouseInventoryCheckDetailMapper inventoryCheckDetailMapper;
/**
* 查询仓库库存盘点
*
@ -58,20 +73,42 @@ public class WarehouseInventoryCheckServiceImpl implements IWarehouseInventoryCh
* @param warehouseInventoryCheck 仓库库存盘点
* @return 结果
*/
@Transactional
@Override
public int insertWarehouseInventoryCheck(WarehouseInventoryCheck warehouseInventoryCheck)
{
String loginName = ShiroUtils.getLoginName();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
String prefix = "KCPD" + simpleDateFormat.format(new Date()).replace("-", "");
String maxCode = warehouseInventoryCheckMapper.findMaxRoundCode(prefix);
String newCode = generateCode(prefix,maxCode);
warehouseInventoryCheck.setInventoryCheckCode(newCode);
warehouseInventoryCheck.setCreateTime(DateUtils.getNowDate());
String loginName = ShiroUtils.getLoginName();
warehouseInventoryCheck.setCreateBy(loginName);
List<WarehouseInventoryCheckDetail> inventoryCheckDetails = warehouseInventoryCheck.getInventoryCheckDetails();
if (StringUtils.isEmpty(inventoryCheckDetails)){
log.warn("仓库盘点物料相关信息为空:{}",inventoryCheckDetails);
}
for (WarehouseInventoryCheckDetail tempInventoryCheckDetail : inventoryCheckDetails) {
WarehouseInventoryCheckDetail inventoryCheckDetail = new WarehouseInventoryCheckDetail();
inventoryCheckDetail.setInventoryCheckCode(newCode);
inventoryCheckDetail.setMaterialNo(tempInventoryCheckDetail.getMaterialNo());
inventoryCheckDetail.setMaterialName(tempInventoryCheckDetail.getMaterialName());
inventoryCheckDetail.setMaterialDescribe(tempInventoryCheckDetail.getMaterialDescribe());
inventoryCheckDetail.setMaterialUnit(tempInventoryCheckDetail.getMaterialUnit());
inventoryCheckDetail.setInventoryCheckNum(tempInventoryCheckDetail.getInventoryCheckNum());
inventoryCheckDetail.setInventoryAccountNum(tempInventoryCheckDetail.getInventoryAccountNum());
inventoryCheckDetail.setRemark(tempInventoryCheckDetail.getRemark());
inventoryCheckDetail.setWarehouseStoreAddress(tempInventoryCheckDetail.getWarehouseStoreAddress());
inventoryCheckDetail.setCreateBy(loginName);
inventoryCheckDetail.setCreateTime(new Date());
inventoryCheckDetailMapper.insertWarehouseInventoryCheckDetail(inventoryCheckDetail);
}
return warehouseInventoryCheckMapper.insertWarehouseInventoryCheck(warehouseInventoryCheck);
}
@ -90,6 +127,25 @@ public class WarehouseInventoryCheckServiceImpl implements IWarehouseInventoryCh
return warehouseInventoryCheckMapper.updateWarehouseInventoryCheck(warehouseInventoryCheck);
}
/**
* 查找与库存查询有关的物料信息
* */
@Override
public List<WarehouseMaterialVO> selectAllMaterialInfo() {
List<WarehouseMaterialVO> warehouseMaterialVOs = new ArrayList<>();
List<ErpMaterialVo> erpMaterialVos = erpMaterialMapper.selectAllErpMaterialList();
for (ErpMaterialVo erpMaterialVo : erpMaterialVos) {
WarehouseMaterialVO warehouseMaterialVO = new WarehouseMaterialVO();
warehouseMaterialVO.setMaterialNo(erpMaterialVo.getMaterialNo());
warehouseMaterialVO.setMaterialName(erpMaterialVo.getMaterialName());
warehouseMaterialVO.setMaterialDescribe(erpMaterialVo.getDescribe());
warehouseMaterialVO.setMaterialUnit(erpMaterialVo.getUnit());
warehouseMaterialVOs.add(warehouseMaterialVO);
}
return warehouseMaterialVOs;
}
/**
*库存盘点单号生成规则

189
ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/add.html

@ -41,26 +41,203 @@
</div>
</div>
</form>
<!-- 物料信息 -->
<div class="container">
<div class="form-row">
<div class="btn-group-sm" id="toolbar" role="group">
<span>选择物料</span>
<a class="btn btn-success" onclick="insertRow()">
<i class="fa fa-plus"></i> 选择物料
</a>
</div>
</div>
<div class="row">
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<!--用于可以修改列表字段的插件-->
<th:block th:include="include :: bootstrap-table-editable-js" />
<script th:inline="javascript">
var prefix = ctx + "warehouse/inventoryCheck"
$("#form-inventoryCheck-add").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-inventoryCheck-add').serialize());
}
}
$("input[name='inventoryCheckDate']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
});
// 新增提交
function submitHandler() {
// 获取表单数据
const inventoryCheckData = $("#form-inventoryCheck-add").serializeArray().reduce((obj, item) => {
obj[item.name] = item.value;
return obj;
}, {});
// 获取bootstrap-table的数据,这里假设你使用bootstrap-table的API获取所有数据
var table = $('#bootstrap-table').bootstrapTable('getData');
// 检查表格数据是否为空
if (table.length===0){
$.modal.alertWarning("请至少添加一条物料数据后再保存!");
return;
}
console.log(table);
// 将表数据转换成与complaintNoticeData格式一致的数组
var materialDataList = table.map(function(item) {
// 根据实际字段名调整
return {
"materialNo": item.materialNo, // 假设id对应materialId
"materialName": item.materialName,
"materialUnit": item.materialUnit,
"materialDescribe": item.materialDescribe,
"inventoryCheckNum": item.inventoryCheckNum,
"inventoryAccountNum": item.inventoryAccountNum,
"warehouseStoreAddress": item.warehouseStoreAddress,
"batchNumber": item.batchNumber,
"remark": item.remark,
// ...其他字段
};
});
const combinedData = Object.assign({}, inventoryCheckData, { inventoryCheckDetails: materialDataList });
// 合并表单数据和表格数据
// const combinedData = Object.assign({}, ...complaintNoticeData.array(item => ({ [item.name]: item.value })), ...materialData);
console.log(combinedData)
// 使用 JSON.stringify() 序列化数据
const jsonData = JSON.stringify(combinedData);
// 发送 AJAX 请求到后端接口
$.operate.saveJson(prefix + "/add", jsonData);
}
//添加物料信息
function insertRow() {
var url = ctx + 'warehouse/inventoryCheck/materialSelect';
var options = {
title: '选择物料',
url: url,
callBack: doSubmit
};
$.modal.openOptions(options);
}
//收款凭证table列表
$(function() {
var options = {
modalName: "收款凭证",
showColumns: false,
pagination: false,
showToggle: false,
showRefresh:false,
showSearch:false,
singleSelect:true,
columns: [{
checkbox: false
},
{
title: '库存盘点详情ID',
field: 'inventoryCheckDetailId',
visible: false
},
{
title: '料号',
field: 'materialNo',
},
{
title: '物料名称',
field: 'materialName',
},
{
title: '物料单位',
field: 'materialUnit',
},
{
title: '物料描述',
field: 'materialDescribe',
},
{
title: '盘点数量',
field: 'inventoryCheckNum',
editable:true
},
{
title: '当时库存账上数量',
field: 'inventoryAccountNum',
editable:true
},
{
title: '存放地址',
field: 'warehouseStoreAddress',
editable:true
},
{
title: '批号',
field: 'batchNumber',
editable:true
},
{
title: '说明',
field: 'remark',
editable:true
},
{
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeRow(\'' + row.receivablesRecordsId + '\')"><i class="fa fa-remove"></i>删除</a> ');
return actions.join('');
}
}
]
};
$.table.init(options);
})
function doSubmit(index, layero,uniqueId){
console.log(uniqueId);
var iframeWin = window[layero.find('iframe')[0]['name']];
var rowData = iframeWin.$('#bootstrap-materialSelect-table').bootstrapTable('getSelections')[0];
console.log("rowData: "+rowData);
$("#bootstrap-table").bootstrapTable('insertRow', {
index:1,
row: {
materialNo:rowData.materialNo,
materialName: rowData.materialName,
materialDescribe: rowData.materialDescribe,
materialUnit: rowData.materialUnit,
inventoryCheckNum : "",
inventoryAccountNum : "",
warehouseStoreAddress : "",
batchNumber : "",
remark : ""
}
})
layer.close(index);
}
// 逻辑删除前端的一行数据
function removeRow(materialNo){
$("#bootstrap-table").bootstrapTable('remove', {
field: 'materialNo',
values: materialNo
})
}
</script>
</body>
</html>

18
ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/inventoryCheck.html

@ -49,12 +49,6 @@
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="warehouse:inventoryCheck:add">
<i class="fa fa-plus"></i> 添加
</a>
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="warehouse:inventoryCheck:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="warehouse:inventoryCheck:remove">
<i class="fa fa-remove"></i> 删除
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="warehouse:inventoryCheck:export">
<i class="fa fa-download"></i> 导出
</a>
@ -67,9 +61,6 @@
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('warehouse:inventoryCheck:edit')}]];
var removeFlag = [[${@permission.hasPermi('warehouse:inventoryCheck:remove')}]];
var cancelFlag = [[${@permission.hasPermi('warehouse:inventoryCheck:cancel')}]];
var restoreFlag = [[${@permission.hasPermi('warehouse:inventoryCheck:restore')}]];
var prefix = ctx + "warehouse/inventoryCheck";
$(function() {
@ -77,9 +68,6 @@
url: prefix + "/list",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
cancelUrl: prefix + "/cancel/{id}",
restoreUrl: prefix + "/restore/{id}",
exportUrl: prefix + "/export",
modalName: "仓库库存盘点",
columns: [{
@ -152,12 +140,6 @@
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.inventoryCheckId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.inventoryCheckId + '\')"><i class="fa fa-remove"></i>删除</a> ');
if(row.delFlag == '0'){
actions.push('<a class="btn btn-danger btn-xs ' + cancelFlag + '" href="javascript:void(0)" onclick="$.operate.cancel(\'' + row.id + '\')"><i class="fa fa-remove"></i>作废</a> ');
}else{
actions.push('<a class="btn btn-success btn-xs ' + restoreFlag + '" href="javascript:void(0)" onclick="$.operate.restore(\'' + row.id + '\')"><i class="fa fa-window-restore"></i>恢复</a> ');
}
return actions.join('');
}
}]

53
ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/materialSelect.html

@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="include :: header('选择物料信息列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-materialSelect-table"></table>
</div>
</div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var prefix = ctx + "warehouse/inventoryCheck";
// 从后端拿到传入的makeNo
// var makeNo = /*[[${makeNo}]]*/ '';
$(function() {
var options = {
id: 'bootstrap-materialSelect-table',
clickToSelect: true, // 点击选中行
singleSelect: true, // 单选
url: prefix + "/getAllMaterialInfo",
modalName: "物料信息",
columns: [{
checkbox: true
},
{
title: '料号',
field: 'materialNo',
},
{
title: '物料名称',
field: 'materialName',
},
{
title: '描述',
field: 'materialDescribe',
},
{
title: '单位',
field: 'materialUnit',
},
]
};
$.table.init(options);
});
</script>
</body>
</html>
Loading…
Cancel
Save