物料操作流水新增功能完善
This commit is contained in:
parent
44dba2b232
commit
6e858b5724
|
|
@ -86,8 +86,7 @@ public class BusiMaterialOperateController extends BaseController
|
||||||
@Log(title = "物料操作流水", businessType = BusinessType.INSERT)
|
@Log(title = "物料操作流水", businessType = BusinessType.INSERT)
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult addSave(BusiMaterialOperate busiMaterialOperate)
|
public AjaxResult addSave(BusiMaterialOperate busiMaterialOperate) throws Exception {
|
||||||
{
|
|
||||||
busiMaterialOperate.setCreateBy(getLoginName());
|
busiMaterialOperate.setCreateBy(getLoginName());
|
||||||
busiMaterialOperate.setCreateTime(DateUtils.getNowDate());
|
busiMaterialOperate.setCreateTime(DateUtils.getNowDate());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,8 @@ public class BusiMaterialOperate extends BaseEntity {
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单
|
* 物料库存ID
|
||||||
*/
|
*/
|
||||||
@Excel(name = "订单")
|
|
||||||
private String materialStockId;
|
private String materialStockId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -44,32 +43,62 @@ public class BusiMaterialOperate extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
private String colorAndType;
|
private String colorAndType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单ID
|
||||||
|
*/
|
||||||
private String orderId;
|
private String orderId;
|
||||||
|
|
||||||
public String getColor() {
|
/**
|
||||||
if (colorAndType != null) {
|
* 订单名称
|
||||||
return colorAndType.split(";")[0];
|
*/
|
||||||
} else {
|
@Excel(name = "订单")
|
||||||
return "";
|
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() {
|
public String getClassify() {
|
||||||
if (colorAndType != null) {
|
return classify;
|
||||||
return colorAndType.split(";")[1];
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setClassify(String classify) {
|
||||||
|
this.classify = classify;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColor(String color) {
|
||||||
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUnit() {
|
public String getUnit() {
|
||||||
if (colorAndType != null) {
|
return unit;
|
||||||
return colorAndType.split(";")[2];
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUnit(String unit) {
|
||||||
|
this.unit = unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOrderId() {
|
public String getOrderId() {
|
||||||
|
|
@ -86,6 +115,10 @@ public class BusiMaterialOperate extends BaseEntity {
|
||||||
|
|
||||||
public void setColorAndType(String colorAndType) {
|
public void setColorAndType(String colorAndType) {
|
||||||
this.colorAndType = colorAndType;
|
this.colorAndType = colorAndType;
|
||||||
|
this.color = colorAndType.split(";")[0];
|
||||||
|
this.classify = colorAndType.split(";")[1];
|
||||||
|
this.unit = colorAndType.split(";")[2];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Long id) {
|
public void setId(Long id) {
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ public interface IBusiMaterialOperateService
|
||||||
* @param busiMaterialOperate 物料操作流水
|
* @param busiMaterialOperate 物料操作流水
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int insertBusiMaterialOperate(BusiMaterialOperate busiMaterialOperate);
|
public int insertBusiMaterialOperate(BusiMaterialOperate busiMaterialOperate) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改物料操作流水
|
* 修改物料操作流水
|
||||||
|
|
|
||||||
|
|
@ -58,16 +58,20 @@ public class BusiMaterialOperateServiceImpl implements IBusiMaterialOperateServi
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public int insertBusiMaterialOperate(BusiMaterialOperate busiMaterialOperate) {
|
public int insertBusiMaterialOperate(BusiMaterialOperate busiMaterialOperate) throws Exception {
|
||||||
// 先查询库存
|
// 先查询库存
|
||||||
List<BusiMaterialStock> busiMaterialStocks = queryBusiMaterialStocks(busiMaterialOperate);
|
List<BusiMaterialStock> busiMaterialStocks = queryBusiMaterialStocks(busiMaterialOperate);
|
||||||
BusiMaterialStock busiMaterialStock;
|
BusiMaterialStock busiMaterialStock;
|
||||||
|
|
||||||
if (busiMaterialStocks.size() != 0) { // 已有库存,则更新
|
if (busiMaterialStocks.size() != 0) { // 已有库存,则更新
|
||||||
busiMaterialStock = busiMaterialStocks.get(0);
|
busiMaterialStock = busiMaterialStocks.get(0);
|
||||||
if ("1".equals(busiMaterialOperate.getOprateType())) {
|
if ("1".equals(busiMaterialOperate.getOprateType())) { // 1为入库
|
||||||
busiMaterialStock.setAmountIn(busiMaterialOperate.getAmount() + busiMaterialStock.getAmountIn());
|
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());
|
busiMaterialStock.setAmountOut(busiMaterialOperate.getAmount() + busiMaterialStock.getAmountOut());
|
||||||
}
|
}
|
||||||
busiMaterialStockMapper.updateBusiMaterialStock(busiMaterialStock);
|
busiMaterialStockMapper.updateBusiMaterialStock(busiMaterialStock);
|
||||||
|
|
@ -83,7 +87,7 @@ public class BusiMaterialOperateServiceImpl implements IBusiMaterialOperateServi
|
||||||
if ("1".equals(busiMaterialOperate.getOprateType())) {
|
if ("1".equals(busiMaterialOperate.getOprateType())) {
|
||||||
busiMaterialStock.setAmountIn(busiMaterialOperate.getAmount());
|
busiMaterialStock.setAmountIn(busiMaterialOperate.getAmount());
|
||||||
} else {
|
} else {
|
||||||
busiMaterialStock.setAmountOut(busiMaterialOperate.getAmount());
|
throw new Exception("尚未建立库存,请先入库再出库");
|
||||||
}
|
}
|
||||||
busiMaterialStockMapper.insertBusiMaterialStock(busiMaterialStock);
|
busiMaterialStockMapper.insertBusiMaterialStock(busiMaterialStock);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<resultMap type="BusiMaterialOperate" id="BusiMaterialOperateResult">
|
<resultMap type="BusiMaterialOperate" id="BusiMaterialOperateResult">
|
||||||
<result property="id" column="id" />
|
<result property="id" column="id" />
|
||||||
<result property="materialStockId" column="material_stock_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="amount" column="amount" />
|
||||||
<result property="oprateType" column="oprate_type" />
|
<result property="oprateType" column="oprate_type" />
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by" />
|
||||||
|
|
@ -15,22 +19,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectBusiMaterialOperateVo">
|
<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>
|
</sql>
|
||||||
|
|
||||||
<select id="selectBusiMaterialOperateList" parameterType="BusiMaterialOperate" resultMap="BusiMaterialOperateResult">
|
<select id="selectBusiMaterialOperateList" parameterType="BusiMaterialOperate" resultMap="BusiMaterialOperateResult">
|
||||||
<include refid="selectBusiMaterialOperateVo"/>
|
<include refid="selectBusiMaterialOperateVo"/>
|
||||||
<where>
|
<where>
|
||||||
<if test="materialStockId != null and materialStockId != ''"> and material_stock_id = #{materialStockId}</if>
|
<if test="orderId != null and orderId != ''"> and bo.id = #{orderId}</if>
|
||||||
<if test="oprateType != null and oprateType != ''"> and oprate_type = #{oprateType}</if>
|
<if test="oprateType != null and oprateType != ''"> and bmo.oprate_type = #{oprateType}</if>
|
||||||
<if test="createBy != null and createBy != ''"> and create_by = #{createBy}</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>
|
<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>
|
</where>
|
||||||
|
order by create_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectBusiMaterialOperateById" parameterType="Long" resultMap="BusiMaterialOperateResult">
|
<select id="selectBusiMaterialOperateById" parameterType="Long" resultMap="BusiMaterialOperateResult">
|
||||||
<include refid="selectBusiMaterialOperateVo"/>
|
<include refid="selectBusiMaterialOperateVo"/>
|
||||||
where id = #{id}
|
where bmo.id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertBusiMaterialOperate" parameterType="BusiMaterialOperate" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertBusiMaterialOperate" parameterType="BusiMaterialOperate" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
|
|
||||||
|
|
@ -15,24 +15,23 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label" title="若无对应的物料选项,请先在产品需求中添加物料需求">物料选择:<i class="fa fa-question-circle-o"></i></label>
|
<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 id="post" name="colorAndType" class="form-control required" >
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<label class="control-label text-danger">需求量:<span id="requireAmount" class=""> -- </span></label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label is-required">数量:</label>
|
<label class="col-sm-3 control-label is-required">数量:</label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<input name="amount" class="form-control" type="text" required>
|
<input name="amount" class="form-control" type="text" required>
|
||||||
</div>
|
</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>
|
||||||
<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">
|
||||||
<select name="oprateType" class="form-control m-b">
|
<select name="oprateType" class="form-control m-b">
|
||||||
<option value="">所有</option>
|
|
||||||
<option value="1" selected>入库</option>
|
<option value="1" selected>入库</option>
|
||||||
<option value="2">出库</option>
|
<option value="2">出库</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,9 @@
|
||||||
<div class="select-list">
|
<div class="select-list">
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<label>订单:</label>
|
<label>订单名称:</label>
|
||||||
<input type="text" name="materialStockId"/>
|
<input id="treeId" name="orderId" type="text" style="display: none;">
|
||||||
|
<input id="treeName" name="orderName" type="text" readonly="true" onclick="selectOrder()" >
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<label>操作类型:</label>
|
<label>操作类型:</label>
|
||||||
|
|
@ -45,12 +46,12 @@
|
||||||
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="busi:materialperate:add">
|
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="busi:materialperate:add">
|
||||||
<i class="fa fa-plus"></i> 添加
|
<i class="fa fa-plus"></i> 添加
|
||||||
</a>
|
</a>
|
||||||
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="busi:materialperate:edit">
|
<!-- <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="busi:materialperate:edit">-->
|
||||||
<i class="fa fa-edit"></i> 修改
|
<!-- <i class="fa fa-edit"></i> 修改-->
|
||||||
</a>
|
<!-- </a>-->
|
||||||
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="busi:materialperate:remove">
|
<!-- <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="busi:materialperate:remove">-->
|
||||||
<i class="fa fa-remove"></i> 删除
|
<!-- <i class="fa fa-remove"></i> 删除-->
|
||||||
</a>
|
<!-- </a>-->
|
||||||
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="busi:materialperate:export">
|
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="busi:materialperate:export">
|
||||||
<i class="fa fa-download"></i> 导出
|
<i class="fa fa-download"></i> 导出
|
||||||
</a>
|
</a>
|
||||||
|
|
@ -65,6 +66,10 @@
|
||||||
var editFlag = [[${@permission.hasPermi('busi:materialperate:edit')}]];
|
var editFlag = [[${@permission.hasPermi('busi:materialperate:edit')}]];
|
||||||
var removeFlag = [[${@permission.hasPermi('busi:materialperate:remove')}]];
|
var removeFlag = [[${@permission.hasPermi('busi:materialperate:remove')}]];
|
||||||
var prefix = ctx + "busi/materialperate";
|
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() {
|
$(function() {
|
||||||
var options = {
|
var options = {
|
||||||
|
|
@ -83,16 +88,46 @@
|
||||||
visible: false
|
visible: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'materialStockId',
|
field: 'orderName',
|
||||||
title: '订单'
|
title: '所属订单'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'amount',
|
field: 'amount',
|
||||||
title: '操作数量'
|
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',
|
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',
|
field: 'createBy',
|
||||||
|
|
@ -102,19 +137,37 @@
|
||||||
field: 'createTime',
|
field: 'createTime',
|
||||||
title: '操作时间'
|
title: '操作时间'
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
title: '操作',
|
// title: '操作',
|
||||||
align: 'center',
|
// align: 'center',
|
||||||
formatter: function(value, row, index) {
|
// formatter: function(value, row, index) {
|
||||||
var actions = [];
|
// 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-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>');
|
// 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('');
|
// return actions.join('');
|
||||||
}
|
// }
|
||||||
}]
|
// }
|
||||||
|
]
|
||||||
};
|
};
|
||||||
$.table.init(options);
|
$.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>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Loading…
Reference in New Issue