订单操作完善
This commit is contained in:
parent
24b561af81
commit
7a44a373f7
|
|
@ -71,8 +71,11 @@ public class BusiProductRequireController extends BaseController
|
||||||
* 新增产品需求
|
* 新增产品需求
|
||||||
*/
|
*/
|
||||||
@GetMapping("/add")
|
@GetMapping("/add")
|
||||||
public String add()
|
public String add(@RequestParam(name = "orderId", required = false)String orderId,
|
||||||
|
@RequestParam(name = "orderName", required = false)String orderName, ModelMap mmap)
|
||||||
{
|
{
|
||||||
|
mmap.put("orderId",orderId);
|
||||||
|
mmap.put("orderName",orderName);
|
||||||
return prefix + "/add";
|
return prefix + "/add";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ public class BusiOrder extends BaseEntity
|
||||||
|
|
||||||
/** 订单价格 */
|
/** 订单价格 */
|
||||||
@Excel(name = "订单价格")
|
@Excel(name = "订单价格")
|
||||||
private double price;
|
private Double price;
|
||||||
|
|
||||||
/** 类型 */
|
/** 类型 */
|
||||||
@Excel(name = "类型")
|
@Excel(name = "类型")
|
||||||
|
|
@ -137,11 +137,11 @@ public class BusiOrder extends BaseEntity
|
||||||
this.busiProductRequireList = busiProductRequireList;
|
this.busiProductRequireList = busiProductRequireList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPrice() {
|
public Double getPrice() {
|
||||||
return price;
|
return price;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrice(double price) {
|
public void setPrice(Double price) {
|
||||||
this.price = price;
|
this.price = price;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,18 @@
|
||||||
package com.ruoyi.busi.service.impl;
|
package com.ruoyi.busi.service.impl;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.ruoyi.busi.domain.*;
|
import com.ruoyi.busi.domain.*;
|
||||||
import com.ruoyi.busi.mapper.BusiOrderMapper;
|
import com.ruoyi.busi.mapper.*;
|
||||||
import com.ruoyi.busi.mapper.BusiProductStockMapper;
|
|
||||||
import com.ruoyi.busi.mapper.BusiSubTaskMapper;
|
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.ruoyi.busi.mapper.BusiProductOperateMapper;
|
|
||||||
import com.ruoyi.busi.service.IBusiProductOperateService;
|
import com.ruoyi.busi.service.IBusiProductOperateService;
|
||||||
import com.ruoyi.common.core.text.Convert;
|
import com.ruoyi.common.core.text.Convert;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 成品操作流水Service业务层处理
|
* 成品操作流水Service业务层处理
|
||||||
|
|
@ -36,6 +33,12 @@ public class BusiProductOperateServiceImpl implements IBusiProductOperateService
|
||||||
@Autowired
|
@Autowired
|
||||||
private BusiSubTaskMapper subTaskMapper;
|
private BusiSubTaskMapper subTaskMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BusiTaskMapper taskMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BusiPrisonLineMapper busiPrisonLineMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询成品操作流水
|
* 查询成品操作流水
|
||||||
*
|
*
|
||||||
|
|
@ -59,12 +62,13 @@ public class BusiProductOperateServiceImpl implements IBusiProductOperateService
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增成品操作流水
|
* 新增成品操作
|
||||||
*
|
*
|
||||||
* @param busiProductOperate 成品操作流水
|
* @param busiProductOperate 成品操作流水
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public int insertBusiProductOperate(BusiProductOperate busiProductOperate) {
|
public int insertBusiProductOperate(BusiProductOperate busiProductOperate) {
|
||||||
List<BusiProductStock> busiProductStocks = queryBusiProductStocks(busiProductOperate);
|
List<BusiProductStock> busiProductStocks = queryBusiProductStocks(busiProductOperate);
|
||||||
busiProductOperate.setProductValue(cacuValue(busiProductOperate));
|
busiProductOperate.setProductValue(cacuValue(busiProductOperate));
|
||||||
|
|
@ -109,20 +113,64 @@ public class BusiProductOperateServiceImpl implements IBusiProductOperateService
|
||||||
return busiProductOperateMapper.insertBusiProductOperate(busiProductOperate);
|
return busiProductOperateMapper.insertBusiProductOperate(busiProductOperate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新子任务完成量,并处理子任务状态
|
||||||
|
* @param subTaskId
|
||||||
|
* @param operateAmount
|
||||||
|
*/
|
||||||
private void updateCompletedAmount(String subTaskId, long operateAmount) {
|
private void updateCompletedAmount(String subTaskId, long operateAmount) {
|
||||||
BusiSubTask busiSubTask = subTaskMapper.selectBusiSubTaskById(subTaskId);
|
BusiSubTask busiSubTask = subTaskMapper.selectBusiSubTaskById(subTaskId);
|
||||||
long completedAmount = busiSubTask.getCompletedAmount();
|
long completedAmount = busiSubTask.getCompletedAmount();
|
||||||
if (operateAmount > 0) {// 若果操作为入库
|
|
||||||
if(completedAmount > busiSubTask.getTargetAmount()){
|
|
||||||
busiSubTask.setStatus("2"); //子任务完成
|
|
||||||
//若子任务为完成,检查任务是否完成,任务若完成,则更新状态同时释放产线为空闲
|
|
||||||
//若任务完成,则同时要检查订单状态,若订单所有任务完成,更新订单状态为生产完成。
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
busiSubTask.setCompletedAmount(completedAmount + operateAmount);
|
busiSubTask.setCompletedAmount(completedAmount + operateAmount);
|
||||||
subTaskMapper.updateBusiSubTask(busiSubTask); // 更新子任务完成量
|
subTaskMapper.updateBusiSubTask(busiSubTask); // 更新子任务完成量
|
||||||
|
|
||||||
|
if (operateAmount > 0) {// 若果操作为入库,还要处理完成状态
|
||||||
|
if (completedAmount > busiSubTask.getTargetAmount()) {// 若子任务为完成
|
||||||
|
busiSubTask.setStatus("2"); //子任务完成
|
||||||
|
subTaskMapper.updateBusiSubTask(busiSubTask);// 更新当前子任务状态
|
||||||
|
handleTaskStatus(busiSubTask);// 处理任务状态
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理任务状态
|
||||||
|
* @param busiSubTask
|
||||||
|
*/
|
||||||
|
private void handleTaskStatus(BusiSubTask busiSubTask) {
|
||||||
|
BusiSubTask subTaskQuery = new BusiSubTask();
|
||||||
|
subTaskQuery.setTaskId(busiSubTask.getTaskId());
|
||||||
|
subTaskQuery.setStatus("1"); // 查询任务下所有未完成的子任务
|
||||||
|
List<BusiSubTask> busiSubTasks = subTaskMapper.selectBusiSubTaskList(subTaskQuery);
|
||||||
|
if (busiSubTasks.size() == 0) {//检查任务是否完成(查全部子任务),任务若完成,则更新状态同时释放产线为空闲
|
||||||
|
BusiTask busiTask = taskMapper.selectBusiTaskById(busiSubTask.getTaskId());
|
||||||
|
busiTask.setStatus("2");
|
||||||
|
taskMapper.updateBusiTask(busiTask);// 任务更新为完成
|
||||||
|
|
||||||
|
BusiPrisonLine busiPrisonLine = new BusiPrisonLine();
|
||||||
|
busiPrisonLine.setId(busiTask.getPrisonLineId());
|
||||||
|
busiPrisonLine.setStatus("0");// 产线状态设置为空闲
|
||||||
|
busiPrisonLineMapper.updateBusiPrisonLine(busiPrisonLine);//产线更新
|
||||||
|
|
||||||
|
handleOrderStatus(busiTask);//处理订单状态
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理订单状态
|
||||||
|
* @param busiTask
|
||||||
|
*/
|
||||||
|
private void handleOrderStatus(BusiTask busiTask) {
|
||||||
|
BusiTask taskQuery = new BusiTask();
|
||||||
|
taskQuery.setOrderId(busiTask.getOrderId());
|
||||||
|
taskQuery.setStatus("1");// 未完成状态
|
||||||
|
List<BusiTask> busiTasks = taskMapper.selectBusiTaskList(taskQuery);
|
||||||
|
if (busiTasks.size() == 0) { //检查订单状态,若订单所有任务完成,更新订单状态为生产完成。
|
||||||
|
BusiOrder busiOrder = new BusiOrder();
|
||||||
|
busiOrder.setId(busiTask.getOrderId());
|
||||||
|
busiOrder.setStatus("3"); //完成
|
||||||
|
busiOrderMapper.updateBusiOrder(busiOrder);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@
|
||||||
align: 'center',
|
align: 'center',
|
||||||
title: '数量',
|
title: '数量',
|
||||||
formatter: function(value, row, index) {
|
formatter: function(value, row, index) {
|
||||||
var html = $.common.sprintf("<input class='form-control required digits' type='text' name='busiProductRequireList[%s].amount' value='%s'>", index, value);
|
var html = $.common.sprintf("<input class='form-control required digits' type='text' name='busiProductRequireList[%s].amount' value='%s' required>", index, value);
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -160,7 +160,7 @@
|
||||||
align: 'center',
|
align: 'center',
|
||||||
title: '截止日期',
|
title: '截止日期',
|
||||||
formatter: function(value, row, index) {
|
formatter: function(value, row, index) {
|
||||||
var html = $.common.sprintf("<input class='form-control endDate required' readonly type='text' name='busiProductRequireList[%s].endDate' value='%s'>", index, value);
|
var html = $.common.sprintf("<input class='form-control endDate required' readonly type='text' name='busiProductRequireList[%s].endDate' value='%s' required>", index, value);
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -124,9 +124,13 @@
|
||||||
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> ');
|
if(row.status != '3'){// 非完成状态
|
||||||
|
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> ');
|
||||||
|
var content = '<a title="为订单增加产品需求" class="btn btn-info btn-xs " href="javascript:void(0)" onclick="addProduct(\'%s\',\'%s\',\'%s\',\'%s\')"><i class="fa fa-plus"></i>产品需求</a> ';
|
||||||
|
actions.push($.common.sprintf(content,row.id,row.orderName,row.id,row.orderName));
|
||||||
|
}
|
||||||
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>');
|
||||||
actions.push('<a title="为订单增加产品需求" class="btn btn-info btn-xs " href="javascript:void(0)" onclick="addProduct(\'' + row.id + '\',\'' + row.orderName+'\')"><i class="fa fa-plus"></i>新增</a> ');
|
|
||||||
return actions.join('');
|
return actions.join('');
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
|
@ -153,8 +157,8 @@
|
||||||
$.table.search();
|
$.table.search();
|
||||||
}
|
}
|
||||||
|
|
||||||
function addProduct(id,name){
|
function addProduct(id,name,orderId,orderName){
|
||||||
var addUrl = ctx + "busi/productRequire/add"
|
var addUrl = ctx + "busi/productRequire/add?orderId="+id+"&orderName="+orderName
|
||||||
$.modal.open( name + ",添加产品需求", addUrl);
|
$.modal.open( name + ",添加产品需求", addUrl);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@
|
||||||
<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-8">
|
<div class="col-sm-8">
|
||||||
<input id="treeId" name="orderId" type="hidden">
|
<input id="treeId" name="orderId" type="hidden" th:value="${orderId}">
|
||||||
<input id="treeName" name="orderName" readonly="true" onclick="selectOrder(1)" class="form-control" type="text" required>
|
<input id="treeName" name="orderName" readonly="true" onclick="selectOrder(1)" class="form-control" type="text" required th:value="${orderName}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
@ -130,7 +130,7 @@
|
||||||
align: 'center',
|
align: 'center',
|
||||||
title: '数量',
|
title: '数量',
|
||||||
formatter: function(value, row, index) {
|
formatter: function(value, row, index) {
|
||||||
var html = $.common.sprintf("<input class='form-control number required' type='text' name='busiMaterialRequireList[%s].amount' value='%s'>", index, value);
|
var html = $.common.sprintf("<input class='form-control number required' type='text' name='busiMaterialRequireList[%s].amount' value='%s' required>", index, value);
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue