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. 6
      ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseInventoryCheckDetailMapper.xml
  6. 231
      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 com.ruoyi.warehouse.domain.VO.WarehouseMaterialVO;
import com.ruoyi.warehouse.domain.WarehouseInventoryCheckDetail;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -105,12 +106,23 @@ public class WarehouseInventoryCheckController extends BaseController
@Log(title = "仓库库存盘点", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(WarehouseInventoryCheck warehouseInventoryCheck)
public AjaxResult editSave(@RequestBody WarehouseInventoryCheck 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 结果
*/
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 com.ruoyi.warehouse.domain.WarehouseInventoryCheck;
import com.ruoyi.warehouse.domain.VO.WarehouseMaterialVO;
import com.ruoyi.warehouse.domain.WarehouseInventoryCheckDetail;
/**
* 仓库库存盘点Service接口
@ -50,4 +51,8 @@ public interface IWarehouseInventoryCheckService
* */
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 仓库库存盘点
* @return 结果
*/
@Transactional
@Override
public int updateWarehouseInventoryCheck(WarehouseInventoryCheck warehouseInventoryCheck)
{
String loginName = ShiroUtils.getLoginName();
warehouseInventoryCheck.setUpdateBy(loginName);
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);
}
@ -146,6 +161,15 @@ public class WarehouseInventoryCheckServiceImpl implements IWarehouseInventoryCh
return warehouseMaterialVOs;
}
/**
* 根据盘点单号查找盘点详情信息
* */
@Override
public List<WarehouseInventoryCheckDetail> selectInventoryCheckDetailListByCode(String inventoryCheckCode) {
return inventoryCheckDetailMapper.selectInventoryCheckDetailListByCode(inventoryCheckCode);
}
/**
*库存盘点单号生成规则

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

@ -43,6 +43,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where inventory_check_detail_id = #{inventoryCheckDetailId}
</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 into warehouse_inventory_check_detail
<trim prefix="(" suffix=")" suffixOverrides=",">

231
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}">
<input name="inventoryCheckId" th:field="*{inventoryCheckId}" type="hidden">
<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">
<input name="inventoryCheckCode" th:field="*{inventoryCheckCode}" class="form-control" type="text">
</div>
</div>
<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">
<input name="inventoryCheckName" th:field="*{inventoryCheckName}" 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="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">
<label class="col-sm-3 control-label">仓库号:</label>
<div class="col-sm-8">
@ -45,7 +33,7 @@
</div>
</div>
<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="input-group date">
<input name="inventoryCheckDate" th:value="${#dates.format(warehouseInventoryCheck.inventoryCheckDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
@ -54,44 +42,223 @@
</div>
</div>
<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">
<input name="materialTotal" th:field="*{materialTotal}" class="form-control" type="text">
<textarea name="remark" class="form-control">[[*{remark}]]</textarea>
</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">
</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="form-group">
<label class="col-sm-3 control-label">备注内容:</label>
<div class="col-sm-8">
<textarea name="remark" class="form-control">[[*{remark}]]</textarea>
<div class="row">
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
</form>
</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";
var warehouseInventoryCheck = [[${warehouseInventoryCheck}]];
$("#form-inventoryCheck-edit").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-inventoryCheck-edit').serialize());
}
}
$("input[name='inventoryCheckDate']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
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>
</body>
</html>
Loading…
Cancel
Save