Browse Source

完成拆单出库功能

lwx_dev
erdanergou 3 years ago
parent
commit
e2d5813057
  1. 60
      src/main/java/com/dreamchaser/depository_manage/service/impl/SplitUnitServiceImpl.java
  2. 1
      src/main/resources/templates/pages/material/selectMaterial.html
  3. 77
      src/main/resources/templates/pages/split/split_add.html
  4. 2
      src/main/resources/templates/pages/warehouse/depository_add.html
  5. 5
      src/test/java/com/dreamchaser/depository_manage/TestForOther.java

60
src/main/java/com/dreamchaser/depository_manage/service/impl/SplitUnitServiceImpl.java

@ -46,6 +46,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
/**
* 用于添加一条拆单记录
*
* @param map 待添加数据
* @return
*/
@ -56,7 +57,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
// 获取物料id
paramForUnit.put("mid", map.get("mid"));
// 获取拆单前的计量单位
paramForUnit.put("oldUnit",map.get("oldUnit"));
paramForUnit.put("newUnit", map.get("oldUnit"));
// 查询当前要拆单的记录是否已经是拆单过的
SplitInfo splitInfoForUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForUnit);
if (splitInfoForUnit != null) {
@ -73,6 +74,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
/**
* 用于添加一条拆单库存处理记录
*
* @param map 待添加数据
* @return
*/
@ -86,9 +88,15 @@ public class SplitUnitServiceImpl implements SplitUnitService {
// 查询当前拆单是否存在
SplitInfo splitInfoForUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo);
// 用于存储最终计算结果
Integer result = 0;
if (splitInfoForUnit != null) {
// 获取当前进制
// Integer scale = findSplitInfoQuantity(splitInfoForUnit);
Integer scale = findSplitInfoQuantity(splitInfoForUnit);
// 获取当前处理的类型
String type = (String) map.get("type");
@ -108,8 +116,9 @@ public class SplitUnitServiceImpl implements SplitUnitService {
splitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForInsertSplitInventory);
// 获取对应的库存记录
inventory = materialMapper.findInventoryById(iid);
}
else{
} else {
Map<String, Object> param = new HashMap<>();
param.put("depositoryId", map.get("depositoryId"));
param.put("mid", map.get("mid"));
@ -131,27 +140,26 @@ public class SplitUnitServiceImpl implements SplitUnitService {
// 如果是入库操作
// 计算处理数量(下取整)
int disposeQuantity = (int) Math.round(Math.floor(quantity / splitInfoForUnit.getQuantity()));
int disposeQuantity = (int) Math.round(Math.floor(quantity / scale));
// 最终存储到拆单处理的数量
double saveQuantity = quantity - disposeQuantity * splitInfoForUnit.getQuantity();
double saveQuantity = quantity - disposeQuantity * scale;
if (splitInventory != null) {
// 如果有过记录
// 最终存储数量
int realQuantity = (int) Math.round(saveQuantity) + splitInventory.getSaveQuantity();
if(realQuantity > splitInfoForUnit.getQuantity()){
if (realQuantity > scale) {
// 如果当前入库的数量大于拆单规定的进制数量
int quantity_in = realQuantity - (realQuantity / splitInfoForUnit.getQuantity());
int quantity_in = realQuantity - (realQuantity / scale);
disposeQuantity += quantity_in;
realQuantity = realQuantity - quantity_in * splitInfoForUnit.getQuantity();
realQuantity = realQuantity - quantity_in * scale;
}
// 设置当前计量单位的库存
splitInventory.setSaveQuantity(realQuantity);
// 设置当前计量单位的入库数目
if (splitInventory.getInQuantity() != null) {
// 如果当前库存不为空
splitInventory.setInQuantity((int) Math.round(splitInventory.getInQuantity() + quantity));
} else {
splitInventory.setInQuantity((int) Math.round(quantity));
@ -175,8 +183,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
if (disposeQuantity != 0) {
// 用于更改库存的数量
map.put("quantity", String.valueOf(disposeQuantity));
}
else{
} else {
map.put("quantity", "0");
}
// 实际入库数量
@ -191,11 +198,31 @@ public class SplitUnitServiceImpl implements SplitUnitService {
}
}
}
return result;
}
/**
* 用于计算当前拆单单位与基础单位之间的进率
*
* @param splitInfo 待查询拆单记录
* @return
*/
private int findSplitInfoQuantity(SplitInfo splitInfo) {
int quantity = 1;
quantity *= splitInfo.getQuantity();
if (splitInfo.getParentId() != null) {
SplitInfo splitInfoById = splitUnitMapper.findSplitInfoById(splitInfo.getParentId());
return quantity * findSplitInfoQuantity(splitInfoById);
} else {
return quantity;
}
}
/**
* 根据条件查询对应拆单详细信息
*
* @param map 查询条件
* @return
*/
@ -220,6 +247,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
/**
* 根据条件查询对应拆单数量
*
* @param map 查询条件
* @return
*/
@ -230,6 +258,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
/**
* 根据主键删除拆单信息软删除
*
* @param id 待删除id
* @return
*/
@ -262,6 +291,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
/**
* 根据主键删除拆单信息硬删除
*
* @param id 待删除id
* @return
*/
@ -293,6 +323,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
/**
* 根据条件修改拆单信息
*
* @param map 待修改数据
* @return
*/
@ -304,6 +335,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
/**
* 根据主键id获取拆单信息
*
* @param id 待查询主键
* @return
*/
@ -314,6 +346,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
/**
* 根据主键id获取拆单详细信息
*
* @param id 待查询主键
* @return
*/
@ -324,6 +357,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
/**
* 根据物料id查询对应的拆单记录
*
* @param mid 待查询物料id
* @return
*/
@ -335,6 +369,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
/**
* 通过物料id与拆单前的计量单位获取对应拆单记录
*
* @param map 查询条件
* @return
*/
@ -345,6 +380,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
/**
* 根据库存id获取对应拆单库存处理记录
*
* @param Iid 待查询库存id
* @return
*/

1
src/main/resources/templates/pages/material/selectMaterial.html

@ -23,6 +23,7 @@
var tempData = [];
var req = {};
req.mname = mname;
req.type = "1";
var test = tree.render({
elem: '#test2'
, data: []

77
src/main/resources/templates/pages/split/split_add.html

@ -34,10 +34,10 @@
padding-right: 0px;
}
.inputdiv .layui-unselect {
border-style: none;
.layui-form-select{
width: 100%;
}
</style>
<div class="layuimini-container">
<div class="layuimini-main">
@ -119,8 +119,9 @@
<label class="layui-form-label">计量单位:</label>
<div class="layui-input-block">
<input type="text" name="oldUnit" class="layui-input" id="unit" readonly
lay-verify="required"/>
<select id="unit" name="oldUnit">
</select>
</div>
</div>
@ -240,7 +241,7 @@
codeValue.val("");
version.val("");
typeName.val("");
unit.val("");
unit.empty();
return false;
} else if (d.count === 0) {
layer.msg("没有该物品,请确认输入是否正确");
@ -249,7 +250,7 @@
materialName.val("");
version.val("");
typeName.val("");
unit.val("");
unit.empty();
return false;
} else {
var material = d.data[0];
@ -258,7 +259,34 @@
codeValue.val(material.code);
version.val(material.version);
typeName.val(material.typeName);
unit.val(material.unit);
unit.append(new Option(material.unit,material.unit));
var splitInfoList = material["splitInfoList"];
$.each(splitInfoList,function (index,item) {
$("#unit").append(new Option(item.newUnit, item.newUnit));//往下拉菜单里添加元素
});
form.render();
var materialAndBarCodeList = material["materialAndBarCodeList"];
if (materialAndBarCodeList !== null && materialAndBarCodeList.length > 0) {
// 如果有对应的条形码
$("#barCode").remove();
var barCodeSelect = `
<select id="barCode" name= "barCode"></select>`;
$("#barCodeImg").before(barCodeSelect);
form.render();
$.each(materialAndBarCodeList, function (index, item) {
$("#barCode").append(new Option(item.bmcode, item.id));//往下拉菜单里添加元素
});
form.render();
}else{
let children = $("#barCode").parent().children();
if(children.length > 2){
$("#barCode").empty();
$(children[1]).empty();
}
}
}
}
});
@ -301,10 +329,16 @@
}
$("#code").val(code);
$("#version").val(material.version);
$("#unit").val(material.unit);
$("#unit").append(new Option(material.unit,material.unit));
var splitInfoList = material["splitInfoList"];
$.each(splitInfoList,function (index,item) {
$("#unit").append(new Option(item.newUnit, item.newUnit));//往下拉菜单里添加元素
});
form.render();
$("#typeName").val(material.typeName);
var materialAndBarCodeList = material["materialAndBarCodeList"];
if (materialAndBarCodeList.length > 0) {
if (materialAndBarCodeList !== null && materialAndBarCodeList.length > 0) {
// 如果有对应的条形码
$("#barCode").remove();
var barCodeSelect = `
@ -315,6 +349,12 @@
$("#barCode").append(new Option(item.bmcode, item.id));//往下拉菜单里添加元素
});
form.render();
}else{
let children = $("#barCode").parent().children();
if(children.length > 2){
$("#barCode").empty();
$(children[1]).empty();
}
}
}
});
@ -406,7 +446,7 @@
$("#code").val("");
$("#barCode").val("");
$("#version").val("");
$("#unit").val("");
$("#unit").empty();
$("#typeName").val("");
form.render();
@ -414,11 +454,17 @@
$("#mname").val(d.mname);
$("#mid").val( d.mid);
$("#version").val(d.version);
$("#unit").val(d.unit);
$("#unit").empty();
$('#unit').append(new Option(d.unit,d.unit));
var splitInfoList = d["splitInfoList"];
$.each(splitInfoList,function (index,item) {
$("#unit").append(new Option(item.newUnit, item.newUnit));//往下拉菜单里添加元素
});
form.render();
$("#typeName").val(d.typeName);
// 获取物料与条形码的对应关系
var materialAndBarCodeList = d["materialAndBarCodeList"];
if (materialAndBarCodeList.length > 0) {
if (materialAndBarCodeList !== null && materialAndBarCodeList.length > 0) {
// 如果有对应的条形码
$("#barCode").remove();
$(".layui-unselect").remove();
@ -433,8 +479,11 @@
});
form.render();
} else {
$("#barCode").remove();
$(".layui-unselect").remove();
let children = $("#barCode").parent().children();
if(children.length > 2){
$("#barCode").empty();
$(children[1]).empty();
}
}
}

2
src/main/resources/templates/pages/warehouse/depository_add.html

@ -112,7 +112,7 @@
dataType:'json',
contentType: "application/json;charset=utf-8",
success:function(d){
if(data.value != "") {
if(data.value !== "") {
$('#adminorg').empty();
$('#adminorg').append(new Option("请选择部门", ""));
$.each(d.data, function (index, item) {

5
src/test/java/com/dreamchaser/depository_manage/TestForOther.java

@ -1,8 +1,11 @@
package com.dreamchaser.depository_manage;
import com.dreamchaser.depository_manage.entity.SplitInfo;
import com.dreamchaser.depository_manage.mapper.SplitUnitMapper;
import com.dreamchaser.depository_manage.utils.CreateQrCodeUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import sun.misc.BASE64Decoder;
@ -21,8 +24,10 @@ import java.io.OutputStream;
public class TestForOther {
@Test
public void Test() throws IOException {
}
}

Loading…
Cancel
Save