Browse Source

[fix]

修改仓库管理添加和修改页面,仓库单号从后端代码添加,前端添加页面不展示,修改页面不可修改单号,设置为只读;
修改 通过采购报价单号查找所有采购报价子表集合方法:使用动态SQL,list集合加上“list != null and list.size > 0”条件,防止出现空指针问题;
采购计划添加采购订单方法:加上对仓库ID的校验,不添加仓库ID不可以发起采购
dev
liuxiaoxu 2 months ago
parent
commit
c5849c3d53
  1. 75
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java
  2. 2
      ruoyi-admin/src/main/java/com/ruoyi/stock/service/impl/StockInfoServiceImpl.java
  3. 7
      ruoyi-admin/src/main/resources/mapper/purchase/PurchaseQuoteChildMapper.xml
  4. 42
      ruoyi-admin/src/main/resources/templates/stock/stockInfo/add.html
  5. 2
      ruoyi-admin/src/main/resources/templates/stock/stockInfo/edit.html

75
ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java

@ -357,6 +357,11 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
List<PurchasePlanSelectSupplierVo> purchasePlanSelectSupplierVoList = addPurchaseOrder.getPurchasePlanSelectSupplierVoList();
List<PurchasePlanSelectMaterialVo> purchasePlanSelectMaterialVoList = addPurchaseOrder.getPurchasePlanSelectMaterialVoList();
String warehouseCode = purchasePlanTwo.getWarehouseCode();
if (StringUtils.isEmpty(warehouseCode)){
throw new BusinessException("请选择仓库ID");
}
//先不判断处理本次占用库存数
//判断本次采购数
boolean anyNullThisPurchaseNum = purchasePlanSelectMaterialVoList.stream().anyMatch(item -> item.getThisPurchaseNum() == null);
@ -460,6 +465,28 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
Integer thisPurchaseNum = purchasePlanSelectMaterialVo.getThisPurchaseNum();
Integer sharedInventoryOccupancyNum = purchasePlanSelectMaterialVo.getSharedInventoryOccupancyNum();
//库存查询
WarehouseInventoryInquiry warehouseInventoryInquiry = inventoryInquiryMapper.selectWarehouseInventoryInquiryByMaterialNo(materialNo);
if ( sharedInventoryOccupancyNum != null && sharedInventoryOccupancyNum > 0){
Integer sharedAvailableStockNum = Optional.ofNullable(warehouseInventoryInquiry.getSharedAvailableStockNum()).orElse(0);
Integer availableStockNum = Optional.ofNullable(warehouseInventoryInquiry.getAvailableStockNum()).orElse(0);
Integer lockStockNum = Optional.ofNullable(warehouseInventoryInquiry.getLockStockNum()).orElse(0);
warehouseInventoryInquiry.setAvailableStockNum(availableStockNum - sharedInventoryOccupancyNum);
warehouseInventoryInquiry.setSharedAvailableStockNum(sharedAvailableStockNum - sharedInventoryOccupancyNum);
warehouseInventoryInquiry.setLockStockNum(lockStockNum + sharedInventoryOccupancyNum);
warehouseInventoryInquiry.setNoOccupancyNum(sharedAvailableStockNum - sharedInventoryOccupancyNum);
warehouseInventoryInquiry.setUpdateTime(new Date());
warehouseInventoryInquiry.setUpdateBy(ShiroUtils.getLoginName());
int updateInventoryInquiry = inventoryInquiryMapper.updateWarehouseInventoryInquiry(warehouseInventoryInquiry);
if (updateInventoryInquiry <= 0){
throw new BusinessException("更新库存查询记录失败");
}
}
// 检查是否有共享库存占用数,没有的话直接使用thisPurchaseNum
Integer remainingSharedInventoryOccupancyNum = 0;
if (sharedInventoryOccupancyNum == null || sharedInventoryOccupancyNum <= 0) {
@ -714,11 +741,59 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
if (purchaseOrder.getAuditStatus().equals("2")){
purchaseOrderAuditRefuse(purchaseOrder);
}
//处理审核通过的情况
if (purchaseOrder.getAuditStatus().equals("1")){
purchaseOrderAuditApprove(purchaseOrder);
}
return purchaseOrderMapper.updatePurchaseOrder(purchaseOrder);
}
/**
* 采购订单审核通过需要更新库存查询数据
* */
private void purchaseOrderAuditApprove(PurchaseOrder purchaseOrder) {
Long purchaseOrderId = purchaseOrder.getPurchaseOrderId();
PurchaseOrderVo purchaseOrderVo = purchaseOrderMapper.selectPurchaseOrderById(purchaseOrderId);
String purchaseOrderCode = purchaseOrderVo.getPurchaseOrderCode();
//得到采购订单子表的数据
List<PurchaseOrderChild> purchaseOrderChildList = purchaseOrderChildMapper.selectPurchaseOrderChildByOrderCode(purchaseOrderCode);
String purchasePlanCode = purchaseOrderVo.getPurchasePlanCode();
//得到采购计划单号的集合
List<String> purchasePlanCodeList = new ArrayList<>();
if (StringUtils.isNotEmpty(purchasePlanCode)){
String[] splitSalesOrderCode = purchasePlanCode.split(",");
purchasePlanCodeList = Arrays.asList(splitSalesOrderCode);
}
// 得到采购计划主表数据
List<PurchasePlan> purchasePlanList = purchasePlanMapper.selectPurchaseOrderByPlanCodeList(purchasePlanCodeList);
// 得到采购计划子表数据
List<PurchasePlanChild> purchasePlanChildList = purchasePlanChildMapper.selectPurchasePlanChildPlanCodeList(purchasePlanCodeList);
// 创建一个 map 用于快速查找采购计划子表数据
Map<String, List<PurchasePlanChild>> purchasePlanChildMap = purchasePlanChildList.stream()
.collect(Collectors.groupingBy(PurchasePlanChild::getPurchasePlanCode));
//
// for (PurchasePlanChild purchasePlanChild : purchasePlanChildList) {
//
// }
}
/**
* 采购订单审核拒绝需要更新采购计划数据采购计划子表数据
* */

2
ruoyi-admin/src/main/java/com/ruoyi/stock/service/impl/StockInfoServiceImpl.java

@ -76,6 +76,8 @@ public class StockInfoServiceImpl implements IStockInfoService
SysDiffLog sysDiffLog = new SysDiffLog();
stockInfo.setFirstAddTime(DateUtils.getNowDate());
String stockNO = redisCache.generateNo("CK");
stockInfo.setStockNO(stockNO);
int insertStockInfo = stockInfoMapper.insertStockInfo(stockInfo);
Long stockId = stockInfo.getStockId();
sysDiffLog.setBusinessId(stockId);

7
ruoyi-admin/src/main/resources/mapper/purchase/PurchaseQuoteChildMapper.xml

@ -77,14 +77,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectPurchaseQuoteChildListByQuoteCodeList" parameterType="Long" resultMap="PurchaseQuoteChildResult">
<include refid="selectPurchaseQuoteChildVo"/>
where purchase_quote_code in
<where>
<if test="list != null and list.size > 0">
purchase_quote_code in
<foreach item="purchaseQuoteCode" collection="list" separator="," open="(" close=")">
#{purchaseQuoteCode}
</foreach>
</if>
</where>
</select>
<select id="selectQuoteChildBySupplierCode" parameterType="String" resultMap="PurchaseQuoteChildResult">
<include refid="selectPurchaseQuoteChildVo"/>
where supplier_code = #{supplierCode}

42
ruoyi-admin/src/main/resources/templates/stock/stockInfo/add.html

@ -6,12 +6,12 @@
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-stockInfo-add">
<div class="form-group">
<label class="col-sm-3 control-label is-required">仓库编号:</label>
<div class="col-sm-8">
<input name="StockNO" class="form-control" type="text" required>
</div>
</div>
<!-- <div class="form-group"> -->
<!-- <label class="col-sm-3 control-label is-required">仓库编号:</label>-->
<!-- <div class="col-sm-8">-->
<!-- <input name="StockNO" class="form-control" type="text" required>-->
<!-- </div>-->
<!-- </div>-->
<div class="form-group">
<label class="col-sm-3 control-label is-required">仓库名:</label>
<div class="col-sm-8">
@ -67,21 +67,21 @@
$("#form-stockInfo-add").validate({
focusCleanup: true
});
$(function (){
$.ajax({
url: prefix + "/getId",
type: "post",
dataType: "json",
success: function (result) {
console.log(result);
if (result.code == 0) {
$("input[name='StockNO']").val(result.msg);
} else {
$.modal.msgError(result.msg);
}
}
});
})
// $(function (){
// $.ajax({
// url: prefix + "/getId",
// type: "post",
// dataType: "json",
// success: function (result) {
// console.log(result);
// if (result.code == 0) {
// $("input[name='StockNO']").val(result.msg);
// } else {
// $.modal.msgError(result.msg);
// }
// }
// });
// })
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-stockInfo-add').serialize());

2
ruoyi-admin/src/main/resources/templates/stock/stockInfo/edit.html

@ -10,7 +10,7 @@
<div class="form-group">
<label class="col-sm-3 control-label is-required">仓库编号:</label>
<div class="col-sm-8">
<input name="StockNO" th:field="*{StockNO}" class="form-control" type="text" required>
<input name="StockNO" th:field="*{StockNO}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">

Loading…
Cancel
Save