完成生产任务新增
This commit is contained in:
parent
806b3314cd
commit
65982f2403
|
|
@ -1,15 +1,13 @@
|
|||
package com.ruoyi.busi.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.busi.domain.BusiTask;
|
||||
|
|
@ -123,4 +121,16 @@ public class BusiTaskController extends BaseController
|
|||
{
|
||||
return toAjax(busiTaskService.deleteBusiTaskByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过订单ID查询产品需求和已分配数量信息
|
||||
*/
|
||||
@PostMapping("/selectProductRequire")
|
||||
@ResponseBody
|
||||
public AjaxResult selectProductRequire(@RequestParam(name = "orderId",required = false) String orderId)
|
||||
{
|
||||
List<Map> list = busiTaskService.selectProductRequire(orderId);
|
||||
return success(list);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.ruoyi.busi.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ruoyi.busi.domain.BusiTask;
|
||||
import com.ruoyi.busi.domain.BusiSubTask;
|
||||
|
||||
|
|
@ -84,4 +86,13 @@ public interface BusiTaskMapper
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteBusiSubTaskByTaskId(String id);
|
||||
|
||||
|
||||
/**
|
||||
* 查询产品的需求和已分配数量信息
|
||||
* @param orderId
|
||||
* @return
|
||||
*/
|
||||
public List<Map> selectProductRequire(String orderId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.ruoyi.busi.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ruoyi.busi.domain.BusiTask;
|
||||
|
||||
/**
|
||||
|
|
@ -58,4 +60,7 @@ public interface IBusiTaskService
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteBusiTaskById(String id);
|
||||
|
||||
|
||||
public List<Map> selectProductRequire(String orderId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import com.ruoyi.common.utils.DateUtils;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.ruoyi.busi.domain.BusiSubTask;
|
||||
|
|
@ -108,6 +110,11 @@ public class BusiTaskServiceImpl implements IBusiTaskService
|
|||
return busiTaskMapper.deleteBusiTaskById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map> selectProductRequire(String orderId) {
|
||||
return busiTaskMapper.selectProductRequire(orderId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增产品子任务信息
|
||||
*
|
||||
|
|
@ -123,6 +130,8 @@ public class BusiTaskServiceImpl implements IBusiTaskService
|
|||
for (BusiSubTask busiSubTask : busiSubTaskList)
|
||||
{
|
||||
busiSubTask.setTaskId(id);
|
||||
busiSubTask.setStatus("1");
|
||||
busiSubTask.setCompletedAmount(0l);
|
||||
list.add(busiSubTask);
|
||||
}
|
||||
if (list.size() > 0)
|
||||
|
|
|
|||
|
|
@ -126,4 +126,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
<select id="selectProductRequire" parameterType="String" resultType="java.util.Map">
|
||||
SELECT bpr.id productRequireId,bpr.size,bpr.color,bpr.amount requireAmount,bst.target_amount assignedAmount FROM busi_product_require bpr
|
||||
left join
|
||||
(SELECT max(product_require_id) product_require_id,sum(target_amount) target_amount from busi_sub_task GROUP BY product_require_id) bst
|
||||
on bst.product_require_id = bpr.id
|
||||
WHERE bpr.order_id = #{orderId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -7,6 +7,12 @@
|
|||
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||
<form class="form-horizontal m" id="form-task-add">
|
||||
<h4 class="form-header h4">生产任务信息</h4>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">任务名称:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="taskName" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">产线选择:</label>
|
||||
<div class="col-sm-8">
|
||||
|
|
@ -19,16 +25,10 @@
|
|||
<label class="col-sm-3 control-label is-required">订单选择:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="treeId" name="orderId" type="hidden">
|
||||
<input id="treeName" name="orderName" readonly="true" onclick="selectOrder(1)" class="form-control" type="text" required>
|
||||
<input id="treeName" readonly="true" onclick="selectOrder(1)" class="form-control" type="text" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">任务名称:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="taskName" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-group hidden">
|
||||
<label class="col-sm-3 control-label is-required">任务状态:</label>
|
||||
<div class="col-sm-8">
|
||||
<select name="status" class="form-control m-b" th:with="type=${@dict.getType('busi_task_status')}" required>
|
||||
|
|
@ -36,11 +36,9 @@
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<h4 class="form-header h4">产品子任务信息</h4>
|
||||
<h4 class="form-header h4">订单产品分配</h4>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
|
||||
<button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
|
||||
<div class="col-sm-12 select-table table-striped">
|
||||
<table id="bootstrap-table"></table>
|
||||
</div>
|
||||
|
|
@ -51,6 +49,8 @@
|
|||
<th:block th:include="include :: footer" />
|
||||
<script th:inline="javascript">
|
||||
var prefix = ctx + "busi/task"
|
||||
var sizeDatas = [[${@dict.getType('busi_size')}]];
|
||||
var colorDatas = [[${@dict.getType('busi_color')}]];
|
||||
$("#form-task-add").validate({
|
||||
focusCleanup: true
|
||||
});
|
||||
|
|
@ -73,71 +73,99 @@
|
|||
checkbox: true
|
||||
},
|
||||
{
|
||||
field: 'index',
|
||||
field: 'productRequireId',
|
||||
align: 'center',
|
||||
title: "序号",
|
||||
formatter: function (value, row, index) {
|
||||
var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
|
||||
var columnIndex = $.common.sprintf("<input type='hidden' name='busiSubTaskList[%s].productRequireId' value='%s'>", index, value);
|
||||
return columnIndex + $.table.serialNumber(index);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'productRequireId',
|
||||
field: 'size',
|
||||
align: 'center',
|
||||
title: '产品需求ID',
|
||||
title: '尺码',
|
||||
formatter: function(value, row, index) {
|
||||
var html = $.common.sprintf("<input class='form-control' type='text' name='busiSubTaskList[%s].productRequireId' value='%s'>", index, value);
|
||||
var html = $.table.selectDictLabel(sizeDatas, value);
|
||||
return html;
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'color',
|
||||
align: 'center',
|
||||
title: '颜色',
|
||||
formatter: function(value, row, index) {
|
||||
var html = $.table.selectDictLabel(colorDatas, value);
|
||||
return html;
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'requireAmount',
|
||||
align: 'center',
|
||||
title: '需求数量'
|
||||
},
|
||||
{
|
||||
field: 'unassignedAmount',
|
||||
align: 'center',
|
||||
title: '未分配数量'
|
||||
},
|
||||
{
|
||||
field: 'targetAmount',
|
||||
align: 'center',
|
||||
title: '目标数量',
|
||||
formatter: function(value, row, index) {
|
||||
var html = $.common.sprintf("<input class='form-control' type='text' name='busiSubTaskList[%s].targetAmount' value='%s'>", index, value);
|
||||
var html = $.common.sprintf("<input class='form-control digits' type='text' name='busiSubTaskList[%s].targetAmount' value='%s' required>", index, value);
|
||||
return html;
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'completedAmount',
|
||||
align: 'center',
|
||||
title: '完成数量',
|
||||
formatter: function(value, row, index) {
|
||||
var html = $.common.sprintf("<input class='form-control' type='text' name='busiSubTaskList[%s].completedAmount' value='%s'>", index, value);
|
||||
return html;
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
align: 'center',
|
||||
title: '完成状态',
|
||||
formatter: function(value, row, index) {
|
||||
var html = $.common.sprintf("<input class='form-control' type='text' name='busiSubTaskList[%s].status' value='%s'>", index, value);
|
||||
return html;
|
||||
}
|
||||
|
||||
}]
|
||||
};
|
||||
$.table.init(options);
|
||||
});
|
||||
|
||||
function addColumn() {
|
||||
function addColumn(data) {
|
||||
var row = {
|
||||
productRequireId: data.productRequireId,
|
||||
size: data.size,
|
||||
color: data.color,
|
||||
requireAmount: data.requireAmount,
|
||||
unassignedAmount: data.requireAmount - (data.assignedAmount||0),
|
||||
targetAmount: ''
|
||||
};
|
||||
var count = $("#" + table.options.id).bootstrapTable('getData').length;
|
||||
sub.editColumn();
|
||||
|
||||
// sub.editColumn();
|
||||
$("#" + table.options.id).bootstrapTable('insertRow', {
|
||||
index: count,
|
||||
row: {
|
||||
index: $.table.serialNumber(count),
|
||||
productRequireId: "",
|
||||
targetAmount: "",
|
||||
completedAmount: "",
|
||||
status: ""
|
||||
row: row
|
||||
});
|
||||
}
|
||||
|
||||
function addValidator(data, index){
|
||||
var unassignedAmount = data.requireAmount - (data.assignedAmount||0);
|
||||
$("[name='busiSubTaskList[" + index + "].targetAmount']").rules("add", {
|
||||
min: 1,
|
||||
max: unassignedAmount,
|
||||
messages: {
|
||||
min: "分配数量必须大于0",
|
||||
max: "不能超过未分配数量"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function queryProductRequire(orderId){
|
||||
var url = prefix + "/selectProductRequire?orderId="+orderId;
|
||||
$.operate.ajaxPost(url, {}, function (result) {
|
||||
$("#" + table.options.id).bootstrapTable('removeAll');
|
||||
var datas = result.data;
|
||||
for (var i = 0; i < datas.length; i++) {
|
||||
var data = datas[i];
|
||||
if(data.requireAmount - (data.assignedAmount||0) > 0){
|
||||
addColumn(data);
|
||||
addValidator(data, i);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/*订单选择*/
|
||||
function selectOrder(status) {
|
||||
var options = {
|
||||
|
|
@ -150,6 +178,7 @@
|
|||
$("#treeId").val(body.find('#treeId').val());
|
||||
$("#treeName").val(body.find('#treeName').val());
|
||||
$.modal.close(index);
|
||||
queryProductRequire(body.find('#treeId').val());
|
||||
}
|
||||
};
|
||||
$.modal.openOptions(options);
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@
|
|||
},
|
||||
{
|
||||
field: 'lineName',
|
||||
title: '产线ID'
|
||||
title: '产线'
|
||||
},
|
||||
{
|
||||
field: 'taskName',
|
||||
|
|
|
|||
Loading…
Reference in New Issue