新增采购单

This commit is contained in:
jinqiming 2021-01-12 20:20:29 +08:00
parent 61f5167d2e
commit fa159f7523
15 changed files with 242 additions and 84 deletions

View File

@ -80,17 +80,12 @@ public class CommonController
*/
@PostMapping("/common/upload")
@ResponseBody
public AjaxResult uploadFile(MultipartFile file) throws Exception
public AjaxResult uploadFile(MultipartFile file)
{
try
{
String originalFilename = file.getOriginalFilename();
SysFile store = storageService.store(file.getInputStream(), file.getSize(), file.getContentType(), originalFilename);
/* // 上传文件路径
String filePath = Global.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName;*/
AjaxResult ajax = AjaxResult.success();
ajax.put("fileKey",store.getKey());
ajax.put("fileName", store.getName());

View File

@ -199,7 +199,7 @@ public class PurchaseOrderController extends BaseController
purchaseOrderForm.setBusinessKey(purchaseOrderMain.getOrderNo());
purchaseOrderForm.setStartUserId(String.valueOf(sysUser.getUserId()));
// purchaseOrderForm.setBusVarJson(JSON.toJSONString(purchaseOrderForm));
purchaseOrderForm.setClassPackName(PurchaseOrderForm.class.getCanonicalName());
// purchaseOrderForm.setClassPackName(PurchaseOrderForm.class.getCanonicalName());
purchaseOrderForm.setBusVarUrl("/system/purchaseOrder/detail");
ProcessInstance processInstance = flowableService.startProcessInstanceByAppForm(purchaseOrderForm);
//推进任务节点

View File

@ -82,6 +82,18 @@
</label>
</div>
</div>
</div>
</br>
<div class="row">
<div class="col-md-12">
<div th:each="attachment:${task.attachmentList}">
<label>附件:</label>
<label th:if="${attachment.url} ne ''">
<a th:href="${attachment.url}" target="_blank"><span th:text="${attachment.name}"></span></a>
</label>
</div>
</div>
</div>
</div>
</div>

View File

@ -11,64 +11,77 @@
<th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg" >
<form class="form-horizontal m-t" id="signupForm">
<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" name="businessKey" th:value="${purchaseOrder.orderNo}"/>
<input name="id" th:value="${purchaseOrder.id}" type="hidden">
<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>
<br/>
<div class="row">
<div class="col-xs-4 col-sm-5 col-md-offset-1">
<label>单号:</label>
<span th:text="${purchaseOrder.orderNo}"/>
</div>
<div class="col-xs-4 col-sm-6">
<label>采购标题:</label>
<span th:text="${purchaseOrder.title}"/>
<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">
</div>
</div>
<div class="row">
<div class="col-xs-3 col-sm-4 col-md-offset-1">
<label>供应商:</label>
<span th:text="${purchaseOrder.supplierName}"/>
</div>
<div class="col-xs-3 col-sm-3">
<label >订货日期:</label>
<span th:text="${#dates.format(purchaseOrder.orderTime, 'yyyy-MM-dd')}"/>
</div>
<div class="col-xs-3 col-sm-3">
<label>交货日期:</label>
<span th:text="${#dates.format(purchaseOrder.deliveryDate, 'yyyy-MM-dd')}"/>
<!-- <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">
</div>
</div>
<div class="row">
<div class="col-xs-3 col-sm-4 col-md-offset-1">
<label >采购人:</label>
<span th:text="${purchaseOrder.belongUser}"/>
</div>
<div class="col-xs-3 col-sm-3">
<label >总数量:</label>
<span th:text="${purchaseOrder.totalQuantity}"/>
</div>
<div class="col-xs-3 col-sm-3">
<label >总金额:</label>
<span th:text="${purchaseOrder.totalPrice}"/>
<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">
</div>
</div>
<div class="row">
<div class="col-xs-10 col-sm-10 col-md-offset-1">
<label>备注:</label>
<span th:text="${purchaseOrder.remark}"/>
</div>
</div>
<h4 class="form-header h4">采购单明细</h4>
<div class="row">
<div class="col-sm-12">
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">订货日期:</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="orderTime" th:value="${#dates.format(purchaseOrderMain.orderTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">交货日期:</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="deliveryDate" th:value="${#dates.format(purchaseOrderMain.deliveryDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">采购人:</label>
<div class="col-sm-8">
<input name="belongUser" th:field="*{belongUser}" class="form-control" type="text">
</div>
</div>
<h4 class="form-header h4">采购单明细信息</h4>
<div class="row">
<div class="col-sm-12">
<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">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
</form>
<h4 class="form-header h4">填写信息</h4>
@ -126,7 +139,7 @@
$(function() {
var options = {
data: [[${purchaseOrder.purchaseOrderItemList}]],
data: [[${appFrom.purchaseOrderItemList}]],
pagination: false,
showSearch: false,
showRefresh: false,

View File

@ -2,6 +2,8 @@ package com.snow.common.utils;
import java.util.Collection;
import java.util.Map;
import java.util.regex.Pattern;
import com.snow.common.core.text.StrFormatter;
/**
@ -157,6 +159,11 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
return (str == null ? "" : str.trim());
}
public static boolean isNumeric(String str){
Pattern pattern = Pattern.compile("[0-9]*");
return pattern.matcher(str).matches();
}
/**
* 截取字符串
*

View File

@ -0,0 +1,58 @@
package com.snow.flowable.cmd;
import org.flowable.bpmn.model.FlowElement;
import org.flowable.bpmn.model.Process;
import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.FlowableEngineAgenda;
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
import org.flowable.engine.impl.persistence.entity.ExecutionEntityManager;
import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.engine.impl.util.ProcessDefinitionUtil;
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
import org.flowable.task.service.impl.persistence.entity.TaskEntityManager;
/**
* @author qimingjin
* @Title:
* @Description:
* @date 2021/1/12 13:10
*/
public class TaskJumpCmd implements Command<Void> {
// 任务ID
private String taskId;
// 目标节点ID
private String targetNodeId;
public TaskJumpCmd(String taskId, String targetNodeId) {
this.taskId = taskId;
this.targetNodeId = targetNodeId;
}
@Override
public Void execute(CommandContext commandContext) {
// 获取命令执行实体管理器
ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager();
// 获取任务对象管理器
TaskEntityManager taskEntityManager = CommandContextUtil.getTaskServiceConfiguration().getTaskEntityManager();
// 根据任务ID获取任务对象
TaskEntity taskEntity = taskEntityManager.findById(taskId);
// 根据任务对象属性excutionId获取流程实例对象
ExecutionEntity executionEntity = executionEntityManager.findById(taskEntity.getExecutionId());
// 根据流程执行实例中的流程模板定义ID属性获取流程对象
Process process = ProcessDefinitionUtil.getProcess(executionEntity.getProcessDefinitionId());
// 根据目标节点ID获取对应节点
FlowElement targetFlowElement = ((Process) process).getFlowElement(targetNodeId);
// 在上一流程实例对象中改变当前节点
executionEntity.setCurrentFlowElement(targetFlowElement);
// 获取流程计划 : 翻译可能不对
FlowableEngineAgenda agenda = CommandContextUtil.getAgenda();
// 更新流程实例对象 : 翻译可能不对
agenda.planContinueProcessInCompensation(executionEntity);
// 根据在任务对象中删除之前任务
taskEntityManager.delete(taskId);
return null;
}
}

View File

@ -0,0 +1,19 @@
package com.snow.flowable.listener.purchaseOrder;
import com.snow.flowable.domain.purchaseOrder.PurchaseOrderForm;
import com.snow.flowable.listener.AbstractExecutionListener;
import org.springframework.stereotype.Service;
/**
* @author qimingjin
* @Title:
* @Description:
* @date 2021/1/12 19:13
*/
@Service("purApplayCheckFlowListener")
public class purchaseApplayCheckFlowListener extends AbstractExecutionListener<PurchaseOrderForm> {
@Override
protected void process() {
}
}

View File

@ -107,7 +107,7 @@ public interface FlowableService {
PageModel<TaskVO> findTasksByUserId(String userId,TaskBaseDTO taskBaseDTO);
/**
* 根据任务ID获取关联待办人活着待办组的人
* 根据任务ID获取关联待办人待办组的人
* @param taskId
* @return
*/

View File

@ -1,5 +1,6 @@
package com.snow.flowable.service;
import com.snow.system.domain.FlowGroupDO;
import com.snow.system.domain.SysRole;
import com.snow.system.domain.SysUser;
import org.flowable.ui.common.model.RemoteGroup;
@ -7,6 +8,7 @@ import org.flowable.ui.common.model.RemoteUser;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author qimingjin
@ -37,7 +39,7 @@ public interface FlowableUserService {
/**
* 根据流程组查询角色
* 根据流程组查询用户
* @param groupId
* @return
*/
@ -49,5 +51,5 @@ public interface FlowableUserService {
* @param userId
* @return
*/
List<SysRole> getFlowGroupByUserId(Long userId);
Set<Long> getFlowGroupByUserId(Long userId);
}

View File

@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.BetweenFormater;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
@ -20,6 +21,7 @@ import com.snow.flowable.enums.FlowFinishedStatusEnum;
import com.snow.flowable.service.FlowableService;
import com.snow.flowable.service.FlowableUserService;
import com.snow.system.domain.ActDeModel;
import com.snow.system.domain.FlowGroupDO;
import com.snow.system.domain.SysRole;
import com.snow.system.domain.SysUser;
import com.snow.system.mapper.SysUserMapper;
@ -330,16 +332,15 @@ public class FlowableServiceImpl implements FlowableService {
@Override
public PageModel<TaskVO> findTasksByUserId(String userId, TaskBaseDTO taskBaseDTO) {
//根据用户ID获取角色
List<SysRole> sysRoles = roleService.selectRolesByUserId(Long.parseLong(userId));
Set<Long> sysRoles = flowableUserService.getFlowGroupByUserId(Long.parseLong(userId));
TaskQuery taskQuery = taskService.createTaskQuery()
.or()
.taskCandidateOrAssigned(userId);
//这个地方查询回去查询系统的用户组表希望的是查询自己的用户表
if(!CollectionUtils.isEmpty(sysRoles)) {
List<String> roleIds = sysRoles.stream().map(t -> {
return String.valueOf(t.getRoleId());
}).collect(Collectors.toList());
List<String> roleIds = sysRoles.stream().map(t ->
String.valueOf(t)
).collect(Collectors.toList());
taskQuery.taskCandidateGroupIn(roleIds);
}
if(!StringUtils.isEmpty(taskBaseDTO.getProcessInstanceId())){
@ -463,7 +464,7 @@ public class FlowableServiceImpl implements FlowableService {
List<FileEntry> files = completeTaskDTO.getFiles();
if(!CollectionUtils.isEmpty(files)){
files.stream().forEach(t->
taskService.createAttachment("url",task.getId(),task.getProcessInstanceId(),t.getKey(),t.getName(),t.getUrl())
taskService.createAttachment("url",task.getId(),task.getProcessInstanceId(),t.getName(),t.getKey(),t.getUrl())
);
}
runtimeService.setVariable(task.getExecutionId(),CompleteTaskDTO.IS_PASS,completeTaskDTO.getIsPass());
@ -625,7 +626,7 @@ public class FlowableServiceImpl implements FlowableService {
private void setHistoricTaskInstanceVos(List<HistoricTaskInstanceVO> list){
list.parallelStream().forEach(t -> {
list.forEach(t -> {
//保存待办人
Set<SysUser> identityLinksForTask = getHistoricIdentityLinksForTask(t.getTaskId());
Optional.ofNullable(identityLinksForTask).ifPresent(m->{
@ -633,7 +634,7 @@ public class FlowableServiceImpl implements FlowableService {
t.setHandleUserList(userNameList);
});
if (!StringUtils.isEmpty(t.getAssignee())) {
if (!StringUtils.isEmpty(t.getAssignee())&&com.snow.common.utils.StringUtils.isNumeric(t.getAssignee())) {
SysUser sysUser = sysUserService.selectUserById(Long.parseLong(t.getAssignee()));
t .setAssigneeName(sysUser.getUserName());
}

View File

@ -1,6 +1,7 @@
package com.snow.flowable.service.impl;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.snow.common.constant.UserConstants;
import com.snow.common.utils.StringUtils;
import com.snow.flowable.service.FlowableUserService;
@ -30,10 +31,7 @@ import java.util.stream.Collectors;
@Slf4j
public class FlowableUserServiceImpl implements FlowableUserService {
//存放所有子几点
private static Set<Long> childFlowGroup= new HashSet<>();
//存放所有的父节点
private static Set<Long> parentFlowGroup= new HashSet<>();
@Autowired
private ISysUserService iSysUserService;
@Autowired
@ -116,33 +114,52 @@ public class FlowableUserServiceImpl implements FlowableUserService {
return remoteGroupList;
}
/**
* 根据角色查询人及其父角色的人
* @param groupId
* @return
*/
@Override
public List<SysUser> getUserByFlowGroupId(Long groupId) {
FlowGroupDO flowGroupDO = flowGroupDOService.selectFlowGroupDOById(groupId);
//先获取所有的子组Id
Set<Long> allSonSysRoleList = getAllSonSysRoleList(groupId);
Set<Long> allSonSysRoleList = getAllParentSysRoleList(groupId);
allSonSysRoleList.add(flowGroupDO.getRoleId());
//根据角色获取所有用户
List<SysUser> userList = iSysUserService.selectUserListByRoleIds( new ArrayList<>(allSonSysRoleList));
return userList;
}
/**
* 根据人查询角色及其子角色
* @param userId
* @return
*/
@Override
public List<SysRole> getFlowGroupByUserId(Long userId) {
List<SysRole> sysRoles = sysRoleService.selectRolesByUserId(userId);
return sysRoles;
public Set<Long> getFlowGroupByUserId(Long userId) {
Set<Long> totalFlowGroupDO=Sets.newHashSet();
List<FlowGroupDO> flowGroupDOS = flowGroupDOService.selectFlowGroupDOByUserId(userId);
if(!CollectionUtils.isEmpty(flowGroupDOS)){
flowGroupDOS.forEach(t->{
Set<Long> allSonSysRoleList = getAllSonSysRoleList(t.getRoleId());
totalFlowGroupDO.addAll(allSonSysRoleList);
});
}
return totalFlowGroupDO;
}
/**
* 获取某个父节点下面的所有子节点
* @param parentId
* 获取某个节点下面的所有子节点
* @param roleId
* @return
*/
public Set<Long> getAllSonSysRoleList(Long parentId){
public Set<Long> getAllSonSysRoleList(Long roleId){
//存放所有子节点
Set<Long> childFlowGroup= new HashSet<>();
FlowGroupDO sysRole=new FlowGroupDO();
sysRole.setParentId(parentId);
sysRole.setParentId(roleId);
sysRole.setRoleType(UserConstants.FLOW_ROLE_TYPE);
List<FlowGroupDO> sysRoleList = flowGroupDOService.selectFlowGroupDOList(sysRole);
if(!CollectionUtils.isEmpty(sysRoleList)){
@ -150,18 +167,20 @@ public class FlowableUserServiceImpl implements FlowableUserService {
childFlowGroup.addAll(collect);
for(FlowGroupDO flowGroupDO: sysRoleList){
// 不为空则递归
getAllSonSysRoleList(flowGroupDO.getRoleId());
childFlowGroup.addAll(getAllSonSysRoleList(flowGroupDO.getRoleId()));
}
}
return childFlowGroup;
}
/**
* 获取某个子节点下面的所有父节点
* 获取某个子节点的所有父节点
* @param roleId
* @return
*/
public Set<Long> getAllParentSysRoleList(Long roleId){
//存放所有的父节点
Set<Long> parentFlowGroup= new HashSet<>();
SysRole sysRole = sysRoleService.selectRoleById(roleId);
if(StringUtils.isNotNull(sysRole)){
FlowGroupDO flowGroupDO=new FlowGroupDO();
@ -170,9 +189,9 @@ public class FlowableUserServiceImpl implements FlowableUserService {
List<FlowGroupDO> sysRoleList = flowGroupDOService.selectFlowGroupDOList(flowGroupDO);
Set<Long> collect = sysRoleList.stream().map(FlowGroupDO::getRoleId).collect(Collectors.toSet());
parentFlowGroup.addAll(collect);
for(Long id: collect){
for(FlowGroupDO roleGroupDO: sysRoleList){
// 不为空则递归
getAllParentSysRoleList(id);
parentFlowGroup.addAll(getAllParentSysRoleList(roleGroupDO.getRoleId()));
}
}
return parentFlowGroup;

View File

@ -19,6 +19,13 @@ public interface FlowGroupDOMapper
*/
public FlowGroupDO selectFlowGroupDOById(Long roleId);
/**
* 根据用户查询流程组
* @param userId
* @return
*/
public List<FlowGroupDO> selectFlowGroupDOByUserId(Long userId);
/**
* 查询流程组信息列表
*

View File

@ -20,6 +20,13 @@ public interface IFlowGroupDOService
*/
public FlowGroupDO selectFlowGroupDOById(Long roleId);
/**
* 根据用户查询流程组
* @param userId
* @return
*/
public List<FlowGroupDO> selectFlowGroupDOByUserId(Long userId);
/**
* 查询流程组信息列表
*

View File

@ -35,6 +35,11 @@ public class FlowGroupDOServiceImpl implements IFlowGroupDOService
return flowGroupDOMapper.selectFlowGroupDOById(roleId);
}
@Override
public List<FlowGroupDO> selectFlowGroupDOByUserId(Long userId) {
return flowGroupDOMapper.selectFlowGroupDOByUserId(userId);
}
/**
* 查询流程组信息列表
*

View File

@ -25,7 +25,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectFlowGroupDOVo">
select role_id, role_name, role_key, role_sort, data_scope, status, del_flag, create_by, create_time, update_by, update_time, remark, parent_id, role_type from sys_role
</sql>
<sql id="selectRoleContactVo">
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope,
r.status, r.del_flag, r.create_time, r.remark,r.parent_id,r.role_type
from sys_role r
left join sys_user_role ur on ur.role_id = r.role_id
left join sys_user u on u.user_id = ur.user_id
</sql>
<select id="selectFlowGroupDOList" parameterType="FlowGroupDO" resultMap="FlowGroupDOResult">
<include refid="selectFlowGroupDOVo"/>
<where>
@ -35,6 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="roleType != null and roleType != ''"> and role_type = #{roleType}</if>
<if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="roleId != null "> and role_id = #{roleId}</if>
</where>
order by role_sort
</select>
@ -45,7 +53,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join sys_role p on p.role_id = t.parent_id
where t.role_id = #{roleId}
</select>
<select id="selectFlowGroupDOByUserId" parameterType="Long" resultMap="FlowGroupDOResult">
<include refid="selectRoleContactVo"/>
WHERE r.del_flag = '0' and role_type=2 and ur.user_id = #{userId}
</select>
<insert id="insertFlowGroupDO" parameterType="FlowGroupDO" useGeneratedKeys="true" keyProperty="roleId">
insert into sys_role
<trim prefix="(" suffix=")" suffixOverrides=",">