新增采购单

This commit is contained in:
jinqiming 2021-01-13 18:20:45 +08:00
parent b8658c97b5
commit caa5602f48
10 changed files with 424 additions and 194 deletions

View File

@ -11,8 +11,10 @@ import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.snow.common.constant.SequenceContants;
import com.snow.common.utils.poi.EasyExcelUtil;
import com.snow.flowable.domain.CompleteTaskDTO;
import com.snow.flowable.domain.leave.SysOaLeaveForm;
import com.snow.flowable.domain.purchaseOrder.PurchaseOrderForm;
import com.snow.flowable.domain.purchaseOrder.PurchaseOrderMainTask;
import com.snow.flowable.service.FlowableService;
import com.snow.framework.excel.FinanceAlipayFlowListener;
import com.snow.framework.excel.PurchaseOrderListener;
@ -231,4 +233,28 @@ public class PurchaseOrderController extends BaseController
return prefix + "/detail";
}
/**
* 重新申请
*/
@PostMapping("/restart")
@ResponseBody
@Transactional
public AjaxResult restart(PurchaseOrderMainTask purchaseOrderMainTask)
{
SysUser sysUser = ShiroUtils.getSysUser();
purchaseOrderMainTask.setUpdateBy(String.valueOf(sysUser.getUserId()));
PurchaseOrderMain purchaseOrderMain=new PurchaseOrderMain();
BeanUtils.copyProperties(purchaseOrderMainTask,purchaseOrderMain);
int i = purchaseOrderMainService.updatePurchaseOrderMain(purchaseOrderMain);
CompleteTaskDTO completeTaskDTO=new CompleteTaskDTO();
completeTaskDTO.setUserId(String.valueOf(sysUser.getUserId()));
completeTaskDTO.setComment(purchaseOrderMainTask.getComment());
completeTaskDTO.setIsStart(purchaseOrderMainTask.getIsStart());
completeTaskDTO.setFiles(purchaseOrderMainTask.getFiles());
completeTaskDTO.setTaskId(purchaseOrderMainTask.getTaskId());
flowableService.completeTask(completeTaskDTO);
return toAjax(i);
}
}

View File

@ -1,18 +1,15 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet" />
<link th:href="@{/css/font-awesome.min.css}" rel="stylesheet" />
<!-- bootstrap-table 表格插件样式 -->
<link th:href="@{/ajax/libs/bootstrap-table/bootstrap-table.min.css}" rel="stylesheet"/>
<link th:href="@{/css/animate.css}" rel="stylesheet" />
<link th:href="@{/css/style.css}" rel="stylesheet" />
<link th:href="@{/ruoyi/css/ry-ui.css}" rel="stylesheet" />
<th:block th:include="include :: header('采购单审核')" />
<th:block th:include="include :: datetimepicker-css" />
<th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg" >
<form class="form-horizontal m-t" id="signupForm" th:object="${appFrom}">
<input class="form-control" type="hidden" name="taskId" th:value="${taskId}"/>
<input class="form-control" type="hidden" id="processInstanceId" th:value="${processInstanceId}"/>
<input class="form-control" type="hidden" name="businessKey" th:value="${appFrom.orderNo}"/>
<input name="id" th:value="${appFrom.id}" type="hidden">
<h2 class="form-header h2" align="center" >采购单信息</h2>
@ -20,31 +17,19 @@
<div class="form-group">
<label class="col-sm-3 control-label">订单号:</label>
<div class="col-sm-8">
<input name="orderNo" th:field="*{orderNo}" class="form-control" type="text">
<input name="orderNo" th:field="*{orderNo}" class="form-control" type="text" readonly>
</div>
</div>
<!-- <div class="form-group">
<label class="col-sm-3 control-label">总数量:</label>
<div class="col-sm-8">
<input name="totalQuantity" th:field="*{totalQuantity}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">采购总金额:</label>
<div class="col-sm-8">
<input name="totalPrice" th:field="*{totalPrice}" class="form-control" type="text">
</div>
</div>-->
<div class="form-group">
<label class="col-sm-3 control-label">采购标题:</label>
<div class="col-sm-8">
<input name="title" th:field="*{title}" class="form-control" type="text">
<input name="title" th:field="*{title}" 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="supplierName" th:field="*{supplierName}" class="form-control" type="text">
<input name="supplierName" th:field="*{supplierName}" class="form-control" type="text" >
</div>
</div>
<div class="form-group">
@ -74,21 +59,32 @@
</div>
<h4 class="form-header h4">采购单明细信息</h4>
<div class="row">
<div class="col-sm-12">
<div class="col-sm-11 col-sm-offset-1">
<button type="button" class="btn btn-success btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
<button type="button" class="btn btn-warning btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
<div class="col-sm-12 select-table table-striped">
<div class="col-sm-11 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
</form>
<h4 class="form-header h4">流程图</h4>
<div class="col-sm-offset-1">
<img class="imgcode" width="85%"/>
</div>
<h4 class="form-header h4">填写信息</h4>
<div class="form-group">
<label class="col-sm-3 control-label">审批结果:</label>
<div class="col-sm-8">
<div class="radio-box" th:each="dict : ${@dict.getType('process_check_status')}">
<input type="radio" th:id="${dict.dictCode}" name="isStart" th:value="${dict.dictValue}" required>
<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">审批意见:</label>
<div class="col-sm-8">
<textarea name="suggestion" class="form-control"></textarea>
<textarea name="comment" class="form-control"></textarea>
</div>
</div>
<div class="form-group">
@ -100,12 +96,22 @@
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-6 col-sm-10">
<button type="button" class="btn btn-sm btn-success" onclick="submitCheckHandler()"><i class="fa fa-check"></i>提 交</button>&nbsp;
</div>
</div>
</form>
<th:block th:include="include :: footer" />
<script src="http://www.jq22.com/jquery/jquery-migrate-1.2.1.min.js"></script>
<script th:src="@{/js/jquery.jqprint-0.3.js}"></script>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
var files=new Array();
$(function () {
var processInstanceId= $("#processInstanceId").val();
var url ="/modeler/getProcessDiagram?processInstanceId="+processInstanceId;
$(".imgcode").attr("src", url);
});
$(".file-upload").each(function (i) {
var val = $("input[name='" + this.id + "']").val();
$(this).fileinput({
@ -115,28 +121,44 @@
maxFileCount: 1,
autoReplace: true
}).on('fileuploaded', function (event, data, previewId, index) {
$("input[name='" + event.currentTarget.id + "']").val(data.response.url)
files.push({"key": data.response.fileKey,"name": data.response.fileName, "url":data.response.url});
// $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
}).on('fileremoved', function (event, id, index) {
$("input[name='" + event.currentTarget.id + "']").val('')
})
$(this).fileinput('_initFileActions');
});
$("input[name='orderTime']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
});
$("input[name='deliveryDate']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
});
function submitCheckHandler() {
if ($.validate.form()) {
var data = $("#signupForm").serializeArray();
data.push({"name": "checkStatus", "value": 0});
$.operate.saveTab("/system/leave/managerFinishTask", data);
for(var i=0;i<data.length;i++){
if(data[i].name=='comment'&&(data[i].value==''||data[i].value==null)){
$.modal.alertError("请填写审批意见");
return false;
}
}
if(files!=null||files!=''){
for(var i=0;i<files.length;i++){
data.push({"name": "files["+i+"].key", "value":files[i].key});
data.push({"name": "files["+i+"].name", "value":files[i].name});
data.push({"name": "files["+i+"].url", "value":files[i].url});
}
}
console.log(data);
$.operate.saveTab("/system/purchaseOrder/restart", data);
}
}
function submitHandler() {
if ($.validate.form()) {
var data = $("#signupForm").serializeArray();
data.push({"name": "checkStatus", "value": 1});
$.operate.saveTab("/system/leave/managerFinishTask", data);
}
}
$(function() {
var options = {
data: [[${appFrom.purchaseOrderItemList}]],
@ -146,7 +168,9 @@
showToggle: false,
showColumns: false,
sidePagination: "client",
columns: [
columns: [{
checkbox: true
},
{
field: 'index',
align: 'center',
@ -159,41 +183,81 @@
{
field: 'goodsNo',
align: 'center',
title: '货物编号'
title: '货物编号',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='purchaseOrderItemList[%s].goodsNo' value='%s'>", index, value);
return html;
}
},
{
field: 'goodsName',
align: 'center',
title: '名称'
title: '名称',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='purchaseOrderItemList[%s].goodsName' value='%s'>", index, value);
return html;
}
},
{
field: 'goodsSize',
align: 'center',
title: '规格'
title: '规格',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='purchaseOrderItemList[%s].goodsSize' value='%s'>", index, value);
return html;
}
},
{
field: 'goodsQuantity',
align: 'center',
title: '数量'
title: '数量',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='purchaseOrderItemList[%s].goodsQuantity' value='%s'>", index, value);
return html;
}
},
{
field: 'goodsPrice',
align: 'center',
title: '单价'
title: '单价',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='purchaseOrderItemList[%s].goodsPrice' value='%s'>", index, value);
return html;
}
},
{
field: 'totalPrice',
align: 'center',
title: '总价'
title: '总价',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='purchaseOrderItemList[%s].totalPrice' value='%s'>", index, value);
return html;
}
},
{
field: 'remark',
align: 'center',
title: '备注'
title: '备注',
formatter: function(value, row, index) {
var html = $.common.sprintf("<input class='form-control' type='text' name='purchaseOrderItemList[%s].remark' value='%s'>", index, value);
return html;
}
}]
};
$.table.init(options);
});
function addColumn() {
var row = {
goodsNo: "",
goodsName: "",
goodsSize: "",
goodsQuantity: "",
goodsPrice: "",
totalPrice: "",
remark: ""
};
sub.addColumn(row);
}
</script>
</body>
</html>

View File

@ -55,9 +55,6 @@ public class CompleteTaskDTO implements Serializable {
private Map<String,Object> paramMap;
private String attachments;
public final static String IS_PASS="isPass";
public final static String IS_START="isStart";

View File

@ -6,6 +6,8 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* @program: snow
@ -19,18 +21,41 @@ import java.io.Serializable;
@AllArgsConstructor
public class FinishTaskDTO implements Serializable {
/**
* 任务ID
*/
private String taskId;
private String suggestion;
private String suggestionFileUrl;
/**
* 0通过1--驳回
* 完成任务人
*/
private Integer checkStatus;
private String userId;
/**
* 业务参数
* 是否通过
*/
private String businessKey;
private Boolean isPass;
/**
* 是否通过
*/
private Boolean isStart;
/**
* 审批意见
*/
private String comment;
/**
* 审批节点的相关文件只在审批节点展示
*/
private List<FileEntry> files;
public final static String IS_PASS="isPass";
public final static String IS_START="isStart";
public final static String FILES="files";
public final static String COMMENT="comment";
}

View File

@ -0,0 +1,84 @@
package com.snow.flowable.domain.purchaseOrder;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.snow.common.core.domain.BaseEntity;
import com.snow.flowable.domain.FileEntry;
import com.snow.system.domain.PurchaseOrderItem;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @author qimingjin
* @Title:
* @Description:
* @date 2021/1/13 13:47
*/
@Data
public class PurchaseOrderMainTask extends BaseEntity implements Serializable {
/** id */
private Integer id;
/** 订单号 */
private String orderNo;
/** 总数量 */
private BigDecimal totalQuantity;
/** 采购总金额 */
private BigDecimal totalPrice;
/** 采购标题 */
private String title;
/** 供应商名称 */
private String supplierName;
/** 订货日期 */
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
private Date orderTime;
/** 交货日期 */
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
private Date deliveryDate;
/** 审批状态 */
private Long processStatus;
/** 采购人 */
private String belongUser;
private Long isDelete;
private List<PurchaseOrderItem> purchaseOrderItemList;
/**
* 任务ID
*/
private String taskId;
/**
* 完成任务人
*/
private String userId;
/**
* 是否通过
*/
private Boolean isStart;
/**
* 审批意见
*/
private String comment;
/**
* 审批节点的相关文件只在审批节点展示
*/
private List<FileEntry> files;
}

View File

@ -126,6 +126,13 @@ public interface FlowableService {
*/
void completeTask(CompleteTaskDTO completeTaskDTO);
/**
* 完成任务
* @param completeTaskDTO
* @param <T>
*/
<T extends CompleteTaskDTO> void submitTask(T completeTaskDTO);
/**
* 获取流程图
* @param httpServletResponse

View File

@ -0,0 +1,40 @@
package com.snow.flowable.service;
import com.snow.flowable.domain.CompleteTaskDTO;
import com.snow.flowable.domain.FinishTaskDTO;
/**
* @author qimingjin
* @Title: flowable 任务相关接口
* @Description:
* @date 2021/1/13 15:54
*/
public interface FlowableTaskService {
/**
* 完成任务
* @param finishTaskDTO
* @param <T>
*/
<T extends FinishTaskDTO> void submitTask(T finishTaskDTO);
/**
* 转办任务
* @param taskId 任务ID
* @param curUserId 当前人ID
* @param targetUserId 目标人ID
*/
void transferTask(String taskId,String curUserId,String targetUserId);
/**
* 委派任务
* @param taskId 任务ID
* @param curUserId 当前人ID
* @param targetUserId 目标人ID
*/
void delegateTask(String taskId,String curUserId,String targetUserId);
void suspendOrActiveApply(String instanceId, String suspendState);
}

View File

@ -492,7 +492,11 @@ public class FlowableServiceImpl implements FlowableService {
taskService.complete(task.getId(),paramMap,true);
}
@Override
public <T extends CompleteTaskDTO> void submitTask(T completeTaskDTO) {
return;
}
@Override
public void getProcessDiagram(HttpServletResponse httpServletResponse, String processId) {

View File

@ -0,0 +1,114 @@
package com.snow.flowable.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.google.common.collect.Maps;
import com.snow.common.exception.BusinessException;
import com.snow.flowable.common.constants.FlowConstants;
import com.snow.flowable.domain.CompleteTaskDTO;
import com.snow.flowable.domain.FileEntry;
import com.snow.flowable.domain.FinishTaskDTO;
import com.snow.flowable.service.FlowableService;
import com.snow.flowable.service.FlowableTaskService;
import lombok.extern.slf4j.Slf4j;
import org.flowable.common.engine.impl.identity.Authentication;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.task.api.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author qimingjin
* @Title:
* @Description:
* @date 2021/1/13 15:54
*/
@Slf4j
public class FlowableTaskServiceImpl implements FlowableTaskService {
@Autowired
private TaskService taskService;
@Autowired
private RuntimeService runtimeService;
@Autowired
private FlowableService flowableService;
@Override
public <T extends FinishTaskDTO> void submitTask(T finishTaskDTO) {
Task task = flowableService.getTask(finishTaskDTO.getTaskId());
if(StringUtils.isEmpty(task)){
log.info("完成任务时该任务ID:%不存在",finishTaskDTO.getTaskId());
throw new BusinessException(String.format("该任务ID:%不存在",finishTaskDTO.getTaskId()));
}
////设置审批人若不设置则数据表userid字段为null
Authentication.setAuthenticatedUserId(finishTaskDTO.getUserId());
if(!StringUtils.isEmpty(finishTaskDTO.getComment())){
taskService.addComment(task.getId(),task.getProcessInstanceId(),FlowConstants.OPINION,finishTaskDTO.getComment());
}else {
taskService.addComment(task.getId(),task.getProcessInstanceId(),FlowConstants.OPINION,"");
}
List<FileEntry> files = finishTaskDTO.getFiles();
if(!CollectionUtils.isEmpty(files)){
files.stream().forEach(t->
taskService.createAttachment("url",task.getId(),task.getProcessInstanceId(),t.getName(),t.getKey(),t.getUrl())
);
}
Map<String, Object> paramMap = BeanUtil.beanToMap(finishTaskDTO);
paramMap.remove(FinishTaskDTO.COMMENT);
paramMap.remove(FinishTaskDTO.FILES);
if(!CollectionUtils.isEmpty(paramMap)){
Set<Map.Entry<String, Object>> entries = paramMap.entrySet();
entries.stream().forEach(t->
runtimeService.setVariable(task.getExecutionId(),t.getKey(),t.getValue())
);
}
if(!StringUtils.isEmpty(finishTaskDTO.getIsPass())){
runtimeService.setVariable(task.getExecutionId(),CompleteTaskDTO.IS_PASS,finishTaskDTO.getIsPass());
paramMap.put(CompleteTaskDTO.IS_PASS,finishTaskDTO.getIsPass());
}
if(!StringUtils.isEmpty(finishTaskDTO.getIsStart())){
runtimeService.setVariable(task.getExecutionId(),CompleteTaskDTO.IS_START,finishTaskDTO.getIsStart());
paramMap.put(CompleteTaskDTO.IS_START,finishTaskDTO.getIsStart());
}
//claim the task当任务分配给了某一组人员时需要该组人员进行抢占抢到了就将该任务给谁处理其他人不能处理认领任务
taskService.claim(task.getId(),finishTaskDTO.getUserId());
taskService.complete(task.getId(),paramMap,true);
}
@Override
public void transferTask(String taskId, String curUserId, String targetUserId) {
try {
taskService.setOwner(taskId, curUserId);
taskService.setAssignee(taskId,targetUserId);
}catch (Exception e) {
log.error(e.getMessage(),e.getCause());
throw new RuntimeException("转办任务失败,请联系管理员");
}
}
@Override
public void delegateTask(String taskId, String curUserId, String targetUserId) {
try {
taskService.setOwner(taskId, curUserId);
taskService.delegateTask(taskId,targetUserId);
}catch (Exception e) {
log.error(e.getMessage(),e.getCause());
throw new RuntimeException("转办任务失败,请联系管理员");
}
}
@Override
public void suspendOrActiveApply(String instanceId, String suspendState) {
}
}

View File

@ -6,6 +6,7 @@ import java.util.Date;
import com.snow.common.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.snow.common.core.domain.BaseEntity;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@ -15,6 +16,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
* @author snow
* @date 2021-01-07
*/
@Data
public class PurchaseOrderMain extends BaseEntity
{
private static final long serialVersionUID = 1L;
@ -65,137 +67,4 @@ public class PurchaseOrderMain extends BaseEntity
/** $table.subTable.functionName信息 */
private List<PurchaseOrderItem> purchaseOrderItemList;
public void setId(Integer id)
{
this.id = id;
}
public Integer getId()
{
return id;
}
public void setOrderNo(String orderNo)
{
this.orderNo = orderNo;
}
public String getOrderNo()
{
return orderNo;
}
public void setTotalQuantity(BigDecimal totalQuantity)
{
this.totalQuantity = totalQuantity;
}
public BigDecimal getTotalQuantity()
{
return totalQuantity;
}
public void setTotalPrice(BigDecimal totalPrice)
{
this.totalPrice = totalPrice;
}
public BigDecimal getTotalPrice()
{
return totalPrice;
}
public void setTitle(String title)
{
this.title = title;
}
public String getTitle()
{
return title;
}
public void setSupplierName(String supplierName)
{
this.supplierName = supplierName;
}
public String getSupplierName()
{
return supplierName;
}
public void setOrderTime(Date orderTime)
{
this.orderTime = orderTime;
}
public Date getOrderTime()
{
return orderTime;
}
public void setDeliveryDate(Date deliveryDate)
{
this.deliveryDate = deliveryDate;
}
public Date getDeliveryDate()
{
return deliveryDate;
}
public void setProcessStatus(Long processStatus)
{
this.processStatus = processStatus;
}
public Long getProcessStatus()
{
return processStatus;
}
public void setBelongUser(String belongUser)
{
this.belongUser = belongUser;
}
public String getBelongUser()
{
return belongUser;
}
public void setIsDelete(Long isDelete)
{
this.isDelete = isDelete;
}
public Long getIsDelete()
{
return isDelete;
}
public List<PurchaseOrderItem> getPurchaseOrderItemList()
{
return purchaseOrderItemList;
}
public void setPurchaseOrderItemList(List<PurchaseOrderItem> purchaseOrderItemList)
{
this.purchaseOrderItemList = purchaseOrderItemList;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("orderNo", getOrderNo())
.append("totalQuantity", getTotalQuantity())
.append("totalPrice", getTotalPrice())
.append("title", getTitle())
.append("supplierName", getSupplierName())
.append("orderTime", getOrderTime())
.append("deliveryDate", getDeliveryDate())
.append("processStatus", getProcessStatus())
.append("belongUser", getBelongUser())
.append("isDelete", getIsDelete())
.append("createTime", getCreateTime())
.append("createBy", getCreateBy())
.append("updateTime", getUpdateTime())
.append("updateBy", getUpdateBy())
.append("remark", getRemark())
.append("purchaseOrderItemList", getPurchaseOrderItemList())
.toString();
}
}