物料操作流水新增功能完善

This commit is contained in:
wangcl 2021-12-27 09:07:13 +08:00
parent 44dba2b232
commit 6e858b5724
7 changed files with 149 additions and 55 deletions

View File

@ -86,8 +86,7 @@ public class BusiMaterialOperateController extends BaseController
@Log(title = "物料操作流水", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(BusiMaterialOperate busiMaterialOperate)
{
public AjaxResult addSave(BusiMaterialOperate busiMaterialOperate) throws Exception {
busiMaterialOperate.setCreateBy(getLoginName());
busiMaterialOperate.setCreateTime(DateUtils.getNowDate());

View File

@ -22,9 +22,8 @@ public class BusiMaterialOperate extends BaseEntity {
private Long id;
/**
* 订单
* 物料库存ID
*/
@Excel(name = "订单")
private String materialStockId;
/**
@ -44,32 +43,62 @@ public class BusiMaterialOperate extends BaseEntity {
*/
private String colorAndType;
/**
* 订单ID
*/
private String orderId;
public String getColor() {
if (colorAndType != null) {
return colorAndType.split(";")[0];
} else {
return "";
}
/**
* 订单名称
*/
@Excel(name = "订单")
private String orderName;
/**
* 类型
*/
private String classify;
/**
* 颜色
*/
private String color;
/**
* 单位
*/
private String unit;
public String getOrderName() {
return orderName;
}
public void setOrderName(String orderName) {
this.orderName = orderName;
}
public String getClassify() {
if (colorAndType != null) {
return colorAndType.split(";")[1];
} else {
return "";
}
return classify;
}
public void setClassify(String classify) {
this.classify = classify;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public String getUnit() {
if (colorAndType != null) {
return colorAndType.split(";")[2];
} else {
return "";
}
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public String getOrderId() {
@ -86,6 +115,10 @@ public class BusiMaterialOperate extends BaseEntity {
public void setColorAndType(String colorAndType) {
this.colorAndType = colorAndType;
this.color = colorAndType.split(";")[0];
this.classify = colorAndType.split(";")[1];
this.unit = colorAndType.split(";")[2];
}
public void setId(Long id) {

View File

@ -33,7 +33,7 @@ public interface IBusiMaterialOperateService
* @param busiMaterialOperate 物料操作流水
* @return 结果
*/
public int insertBusiMaterialOperate(BusiMaterialOperate busiMaterialOperate);
public int insertBusiMaterialOperate(BusiMaterialOperate busiMaterialOperate) throws Exception;
/**
* 修改物料操作流水

View File

@ -58,16 +58,20 @@ public class BusiMaterialOperateServiceImpl implements IBusiMaterialOperateServi
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int insertBusiMaterialOperate(BusiMaterialOperate busiMaterialOperate) {
public int insertBusiMaterialOperate(BusiMaterialOperate busiMaterialOperate) throws Exception {
// 先查询库存
List<BusiMaterialStock> busiMaterialStocks = queryBusiMaterialStocks(busiMaterialOperate);
BusiMaterialStock busiMaterialStock;
if (busiMaterialStocks.size() != 0) { // 已有库存则更新
busiMaterialStock = busiMaterialStocks.get(0);
if ("1".equals(busiMaterialOperate.getOprateType())) {
if ("1".equals(busiMaterialOperate.getOprateType())) { // 1为入库
busiMaterialStock.setAmountIn(busiMaterialOperate.getAmount() + busiMaterialStock.getAmountIn());
} else {
} else {// 2为入库
long stockAmount = busiMaterialStock.getAmountIn() - busiMaterialStock.getAmountOut();
if(busiMaterialOperate.getAmount() > stockAmount){
throw new Exception("出库超过库存");
}
busiMaterialStock.setAmountOut(busiMaterialOperate.getAmount() + busiMaterialStock.getAmountOut());
}
busiMaterialStockMapper.updateBusiMaterialStock(busiMaterialStock);
@ -83,7 +87,7 @@ public class BusiMaterialOperateServiceImpl implements IBusiMaterialOperateServi
if ("1".equals(busiMaterialOperate.getOprateType())) {
busiMaterialStock.setAmountIn(busiMaterialOperate.getAmount());
} else {
busiMaterialStock.setAmountOut(busiMaterialOperate.getAmount());
throw new Exception("尚未建立库存,请先入库再出库");
}
busiMaterialStockMapper.insertBusiMaterialStock(busiMaterialStock);
}

View File

@ -7,6 +7,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="BusiMaterialOperate" id="BusiMaterialOperateResult">
<result property="id" column="id" />
<result property="materialStockId" column="material_stock_id" />
<result property="orderName" column="order_name" />
<result property="unit" column="unit" />
<result property="color" column="color" />
<result property="classify" column="classify" />
<result property="amount" column="amount" />
<result property="oprateType" column="oprate_type" />
<result property="createBy" column="create_by" />
@ -15,22 +19,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectBusiMaterialOperateVo">
select id, material_stock_id, amount, oprate_type, create_by, create_time, remark from busi_material_operate
select bmo.id, bmo.material_stock_id,bo.order_name, bms.unit, bms.color, bms.classify, bmo.amount, bmo.oprate_type, bmo.create_by, bmo.create_time, bmo.remark
from busi_material_operate bmo LEFT JOIN busi_material_stock bms on bmo.material_stock_id = bms.id LEFT JOIN busi_order bo on bo.id = bms.order_id
</sql>
<select id="selectBusiMaterialOperateList" parameterType="BusiMaterialOperate" resultMap="BusiMaterialOperateResult">
<include refid="selectBusiMaterialOperateVo"/>
<where>
<if test="materialStockId != null and materialStockId != ''"> and material_stock_id = #{materialStockId}</if>
<if test="oprateType != null and oprateType != ''"> and oprate_type = #{oprateType}</if>
<if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
<if test="orderId != null and orderId != ''"> and bo.id = #{orderId}</if>
<if test="oprateType != null and oprateType != ''"> and bmo.oprate_type = #{oprateType}</if>
<if test="createBy != null and createBy != ''"> and bmo.create_by = #{createBy}</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
</where>
order by create_time DESC
</select>
<select id="selectBusiMaterialOperateById" parameterType="Long" resultMap="BusiMaterialOperateResult">
<include refid="selectBusiMaterialOperateVo"/>
where id = #{id}
where bmo.id = #{id}
</select>
<insert id="insertBusiMaterialOperate" parameterType="BusiMaterialOperate" useGeneratedKeys="true" keyProperty="id">

View File

@ -15,24 +15,23 @@
</div>
<div class="form-group">
<label class="col-sm-3 control-label" title="若无对应的物料选项,请先在产品需求中添加物料需求">物料选择:<i class="fa fa-question-circle-o"></i></label>
<div class="col-sm-8">
<div class="col-sm-6">
<select id="post" name="colorAndType" class="form-control required" >
</select>
</div>
<label class="control-label text-danger">需求量:<span id="requireAmount" class=""> -- </span></label>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">数量:</label>
<div class="col-sm-6">
<input name="amount" class="form-control" type="text" required>
</div>
<label class="control-label text-danger">需求量:<span id="requireAmount" class=""> -- </span></label>
<label class="control-label text-danger">库存量:<span id="requireAmount" class=""> -- </span></label>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">操作类型:</label>
<div class="col-sm-8">
<select name="oprateType" class="form-control m-b">
<option value="">所有</option>
<option value="1" selected>入库</option>
<option value="2">出库</option>
</select>

View File

@ -11,8 +11,9 @@
<div class="select-list">
<ul>
<li>
<label>订单:</label>
<input type="text" name="materialStockId"/>
<label>订单名称:</label>
<input id="treeId" name="orderId" type="text" style="display: none;">
<input id="treeName" name="orderName" type="text" readonly="true" onclick="selectOrder()" >
</li>
<li>
<label>操作类型:</label>
@ -45,12 +46,12 @@
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="busi:materialperate:add">
<i class="fa fa-plus"></i> 添加
</a>
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="busi:materialperate:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="busi:materialperate:remove">
<i class="fa fa-remove"></i> 删除
</a>
<!-- <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="busi:materialperate:edit">-->
<!-- <i class="fa fa-edit"></i> 修改-->
<!-- </a>-->
<!-- <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="busi:materialperate:remove">-->
<!-- <i class="fa fa-remove"></i> 删除-->
<!-- </a>-->
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="busi:materialperate:export">
<i class="fa fa-download"></i> 导出
</a>
@ -65,6 +66,10 @@
var editFlag = [[${@permission.hasPermi('busi:materialperate:edit')}]];
var removeFlag = [[${@permission.hasPermi('busi:materialperate:remove')}]];
var prefix = ctx + "busi/materialperate";
var colorDatas = [[${@dict.getType('busi_color')}]];
var unitDatas = [[${@dict.getType('busi_material_unit')}]];
var classifyDatas = [[${@dict.getType('busi_material_type')}]];
var operateTypeDatas = [[${@dict.getType('busi_operate_type')}]];
$(function() {
var options = {
@ -83,16 +88,46 @@
visible: false
},
{
field: 'materialStockId',
title: '订单'
field: 'orderName',
title: '所属订单'
},
{
field: 'amount',
title: '操作数量'
},
{
field: 'unit',
title: '单位',
formatter: function(value, row, index) {
return $.table.selectDictLabel(unitDatas, value);
}
},
{
field: 'color',
title: '颜色',
formatter: function(value, row, index) {
return $.table.selectDictLabel(colorDatas, value);
}
},
{
field: 'classify',
title: '类型',
formatter: function(value, row, index) {
return $.table.selectDictLabel(classifyDatas, value);
}
},
{
field: 'oprateType',
title: '操作类型'
title: '操作类型',
formatter: function(value, row, index) {
if (value == "1") {
return "<i class='fa fa-arrow-circle-down'>入库</i>";
} else if (value == "2") {
return "<i class='fa fa-arrow-circle-up'>出库</i>";
} else {
return "未知操作";
}
}
},
{
field: 'createBy',
@ -102,19 +137,37 @@
field: 'createTime',
title: '操作时间'
},
{
title: '操作',
align: 'center',
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.id + '\')"><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.id + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}]
// {
// title: '操作',
// align: 'center',
// 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.id + '\')"><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.id + '\')"><i class="fa fa-remove"></i>删除</a>');
// return actions.join('');
// }
// }
]
};
$.table.init(options);
});
/*订单选择*/
function selectOrder() {
var options = {
title: '选择订单',
width: "380",
height: "400",
url: ctx + "busi/order/selectOrder/" ,
callBack: function(index, layero){
var body = $.modal.getChildFrame(index);
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
$.modal.close(index);
}
};
$.modal.openOptions(options);
}
</script>
</body>
</html>