Browse Source

[feat]仓库管理:

库存盘点
修改 库存盘点修改接口
修改 库存盘点修改页面
新增根据盘点单号查询库存盘点详情信息接口
dev
liuxiaoxu 5 months ago
parent
commit
8389dde4a8
  1. 14
      ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseInventoryCheckController.java
  2. 5
      ruoyi-admin/src/main/java/com/ruoyi/warehouse/mapper/WarehouseInventoryCheckDetailMapper.java
  3. 5
      ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseInventoryCheckService.java
  4. 24
      ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseInventoryCheckServiceImpl.java
  5. 8
      ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseInventoryCheckDetailMapper.xml
  6. 233
      ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/edit.html

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

@ -3,6 +3,7 @@ package com.ruoyi.warehouse.controller;
import java.util.List; import java.util.List;
import com.ruoyi.warehouse.domain.VO.WarehouseMaterialVO; import com.ruoyi.warehouse.domain.VO.WarehouseMaterialVO;
import com.ruoyi.warehouse.domain.WarehouseInventoryCheckDetail;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -105,12 +106,23 @@ public class WarehouseInventoryCheckController extends BaseController
@Log(title = "仓库库存盘点", businessType = BusinessType.UPDATE) @Log(title = "仓库库存盘点", businessType = BusinessType.UPDATE)
@PostMapping("/edit") @PostMapping("/edit")
@ResponseBody @ResponseBody
public AjaxResult editSave(WarehouseInventoryCheck warehouseInventoryCheck) public AjaxResult editSave(@RequestBody WarehouseInventoryCheck warehouseInventoryCheck)
{ {
return toAjax(warehouseInventoryCheckService.updateWarehouseInventoryCheck(warehouseInventoryCheck)); return toAjax(warehouseInventoryCheckService.updateWarehouseInventoryCheck(warehouseInventoryCheck));
} }
/**
* 根据盘点单号查询盘点详情信息
*/
@ResponseBody
@PostMapping("/getInventoryCheckDetailList")
public TableDataInfo getInventoryCheckDetailList(WarehouseInventoryCheck warehouseInventoryCheck){
startPage();
List<WarehouseInventoryCheckDetail> list = warehouseInventoryCheckService.selectInventoryCheckDetailListByCode(warehouseInventoryCheck.getInventoryCheckCode());
return getDataTable(list);
}
/** /**
* 物料信息弹出页面 * 物料信息弹出页面

5
ruoyi-admin/src/main/java/com/ruoyi/warehouse/mapper/WarehouseInventoryCheckDetailMapper.java

@ -74,4 +74,9 @@ public interface WarehouseInventoryCheckDetailMapper
* @return 结果 * @return 结果
*/ */
public int restoreWarehouseInventoryCheckDetailById(Long inventoryCheckDetailId); public int restoreWarehouseInventoryCheckDetailById(Long inventoryCheckDetailId);
/**
* 根据盘点单号查找盘点详情信息
* */
List<WarehouseInventoryCheckDetail> selectInventoryCheckDetailListByCode(String inventoryCheckCode);
} }

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

@ -3,6 +3,7 @@ package com.ruoyi.warehouse.service;
import java.util.List; import java.util.List;
import com.ruoyi.warehouse.domain.WarehouseInventoryCheck; import com.ruoyi.warehouse.domain.WarehouseInventoryCheck;
import com.ruoyi.warehouse.domain.VO.WarehouseMaterialVO; import com.ruoyi.warehouse.domain.VO.WarehouseMaterialVO;
import com.ruoyi.warehouse.domain.WarehouseInventoryCheckDetail;
/** /**
* 仓库库存盘点Service接口 * 仓库库存盘点Service接口
@ -50,4 +51,8 @@ public interface IWarehouseInventoryCheckService
* */ * */
public List<WarehouseMaterialVO> selectAllMaterialInfo(); public List<WarehouseMaterialVO> selectAllMaterialInfo();
/**
* 根据盘点单号查找盘点详情信息
* */
List<WarehouseInventoryCheckDetail> selectInventoryCheckDetailListByCode(String inventoryCheckCode);
} }

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

@ -118,12 +118,27 @@ public class WarehouseInventoryCheckServiceImpl implements IWarehouseInventoryCh
* @param warehouseInventoryCheck 仓库库存盘点 * @param warehouseInventoryCheck 仓库库存盘点
* @return 结果 * @return 结果
*/ */
@Transactional
@Override @Override
public int updateWarehouseInventoryCheck(WarehouseInventoryCheck warehouseInventoryCheck) public int updateWarehouseInventoryCheck(WarehouseInventoryCheck warehouseInventoryCheck)
{ {
String loginName = ShiroUtils.getLoginName(); String loginName = ShiroUtils.getLoginName();
warehouseInventoryCheck.setUpdateBy(loginName); warehouseInventoryCheck.setUpdateBy(loginName);
warehouseInventoryCheck.setUpdateTime(DateUtils.getNowDate()); warehouseInventoryCheck.setUpdateTime(DateUtils.getNowDate());
List<WarehouseInventoryCheckDetail> inventoryCheckDetails = warehouseInventoryCheck.getInventoryCheckDetails();
if (StringUtils.isEmpty(inventoryCheckDetails)){
log.warn("仓库盘点物料相关信息为空:{}",inventoryCheckDetails);
}
for (WarehouseInventoryCheckDetail tempInventoryCheckDetail : inventoryCheckDetails) {
tempInventoryCheckDetail.setUpdateBy(loginName);
tempInventoryCheckDetail.setUpdateTime(new Date());
inventoryCheckDetailMapper.updateWarehouseInventoryCheckDetail(tempInventoryCheckDetail);
}
return warehouseInventoryCheckMapper.updateWarehouseInventoryCheck(warehouseInventoryCheck); return warehouseInventoryCheckMapper.updateWarehouseInventoryCheck(warehouseInventoryCheck);
} }
@ -146,6 +161,15 @@ public class WarehouseInventoryCheckServiceImpl implements IWarehouseInventoryCh
return warehouseMaterialVOs; return warehouseMaterialVOs;
} }
/**
* 根据盘点单号查找盘点详情信息
* */
@Override
public List<WarehouseInventoryCheckDetail> selectInventoryCheckDetailListByCode(String inventoryCheckCode) {
return inventoryCheckDetailMapper.selectInventoryCheckDetailListByCode(inventoryCheckCode);
}
/** /**
*库存盘点单号生成规则 *库存盘点单号生成规则

8
ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseInventoryCheckDetailMapper.xml

@ -42,7 +42,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectWarehouseInventoryCheckDetailVo"/> <include refid="selectWarehouseInventoryCheckDetailVo"/>
where inventory_check_detail_id = #{inventoryCheckDetailId} where inventory_check_detail_id = #{inventoryCheckDetailId}
</select> </select>
<select id="selectInventoryCheckDetailListByCode" parameterType="String" resultMap="WarehouseInventoryCheckDetailResult">
<include refid="selectWarehouseInventoryCheckDetailVo"/>
where inventory_check_code = #{inventoryCheckCode}
</select>
<insert id="insertWarehouseInventoryCheckDetail" parameterType="WarehouseInventoryCheckDetail" useGeneratedKeys="true" keyProperty="inventoryCheckDetailId"> <insert id="insertWarehouseInventoryCheckDetail" parameterType="WarehouseInventoryCheckDetail" useGeneratedKeys="true" keyProperty="inventoryCheckDetailId">
insert into warehouse_inventory_check_detail insert into warehouse_inventory_check_detail
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">

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

@ -9,29 +9,17 @@
<form class="form-horizontal m" id="form-inventoryCheck-edit" th:object="${warehouseInventoryCheck}"> <form class="form-horizontal m" id="form-inventoryCheck-edit" th:object="${warehouseInventoryCheck}">
<input name="inventoryCheckId" th:field="*{inventoryCheckId}" type="hidden"> <input name="inventoryCheckId" th:field="*{inventoryCheckId}" type="hidden">
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">库存盘点单号:</label> <label class="col-sm-3 control-label">盘点单号:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input name="inventoryCheckCode" th:field="*{inventoryCheckCode}" class="form-control" type="text"> <input name="inventoryCheckCode" th:field="*{inventoryCheckCode}" class="form-control" type="text">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">库存盘点人名:</label> <label class="col-sm-3 control-label">盘点人名:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input name="inventoryCheckName" th:field="*{inventoryCheckName}" class="form-control" type="text"> <input name="inventoryCheckName" th:field="*{inventoryCheckName}" class="form-control" type="text">
</div> </div>
</div> </div>
<div class="form-group">
<label class="col-sm-3 control-label">料号:</label>
<div class="col-sm-8">
<input name="materialNo" th:field="*{materialNo}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">物料名称:</label>
<div class="col-sm-8">
<input name="materialName" th:field="*{materialName}" class="form-control" type="text">
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">仓库号:</label> <label class="col-sm-3 control-label">仓库号:</label>
<div class="col-sm-8"> <div class="col-sm-8">
@ -45,7 +33,7 @@
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">库存盘点日期:</label> <label class="col-sm-3 control-label">盘点日期:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<div class="input-group date"> <div class="input-group date">
<input name="inventoryCheckDate" th:value="${#dates.format(warehouseInventoryCheck.inventoryCheckDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text"> <input name="inventoryCheckDate" th:value="${#dates.format(warehouseInventoryCheck.inventoryCheckDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
@ -53,18 +41,6 @@
</div> </div>
</div> </div>
</div> </div>
<div class="form-group">
<label class="col-sm-3 control-label">物料数合计:</label>
<div class="col-sm-8">
<input name="materialTotal" th:field="*{materialTotal}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">数量合计:</label>
<div class="col-sm-8">
<input name="numTotal" th:field="*{numTotal}" class="form-control" type="text">
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">备注内容:</label> <label class="col-sm-3 control-label">备注内容:</label>
<div class="col-sm-8"> <div class="col-sm-8">
@ -72,26 +48,217 @@
</div> </div>
</div> </div>
</form> </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> </div>
<th:block th:include="include :: footer" /> <th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" /> <th:block th:include="include :: datetimepicker-js" />
<!--用于可以修改列表字段的插件-->
<th:block th:include="include :: bootstrap-table-editable-js" />
<script th:inline="javascript"> <script th:inline="javascript">
var prefix = ctx + "warehouse/inventoryCheck"; var prefix = ctx + "warehouse/inventoryCheck";
var warehouseInventoryCheck = [[${warehouseInventoryCheck}]];
$("#form-inventoryCheck-edit").validate({ $("#form-inventoryCheck-edit").validate({
focusCleanup: true focusCleanup: true
}); });
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-inventoryCheck-edit').serialize());
}
}
$("input[name='inventoryCheckDate']").datetimepicker({ $("input[name='inventoryCheckDate']").datetimepicker({
format: "yyyy-mm-dd", format: "yyyy-mm-dd",
minView: "month", minView: "month",
autoclose: true autoclose: true
}); });
// 新增提交
function submitHandler() {
// 获取表单数据
const inventoryCheckData = $("#form-inventoryCheck-edit").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 {
"inventoryCheckDetailId":item.inventoryCheckDetailId,
"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 + "/edit", jsonData);
}
//添加物料信息
function insertRow() {
var url = ctx + 'warehouse/inventoryCheck/materialSelect';
var options = {
title: '选择物料',
url: url,
callBack: doSubmit
};
$.modal.openOptions(options);
}
//收款凭证table列表
$(function() {
var options = {
modalName: "收款凭证",
url: prefix + '/getInventoryCheckDetailList',
queryParams: queryParams,
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 queryParams(params) {
var curParams = {
// 传递参数查询参数
inventoryCheckCode: warehouseInventoryCheck.inventoryCheckCode
};
console.log(curParams);
return curParams;
}
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> </script>
</body> </body>
</html> </html>
Loading…
Cancel
Save