Browse Source

[feat] 添加请购单审核节点,审核功能页面。

dev
zhangsiqi 4 months ago
parent
commit
37e39806a5
  1. 139
      ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseRequisitioningOrderController.java
  2. 4
      ruoyi-admin/src/main/java/com/ruoyi/system/domain/BaseRequisitioningOrder.java
  3. 124
      ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/BaseRequisitioningOrderVo.java
  4. 7
      ruoyi-admin/src/main/java/com/ruoyi/system/mapper/BaseRequisitioningOrderMapper.java
  5. 233
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseRequisitioningOrderServiceImpl.java
  6. 95
      ruoyi-admin/src/main/resources/mapper/system/BaseRequisitioningOrderMapper.xml
  7. 21
      ruoyi-admin/src/main/resources/templates/system/requisitioning/add.html

139
ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseRequisitioningOrderController.java

@ -6,17 +6,25 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSON;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.service.ICommonService;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.financial.service.IFinancialReceivablesService;
import com.ruoyi.process.general.service.IProcessService;
import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper;
import com.ruoyi.purchase.service.IPurchasePlanService;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.mapper.SysPostMapper;
import com.ruoyi.system.mapper.SysUserPostMapper;
import com.ruoyi.system.service.IBaseRequisitioningOrderChildService;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.system.domain.Vo.BaseRequisitioningOrderVo;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.service.*;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -24,13 +32,14 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.IBaseRequisitioningOrderService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import javax.management.relation.Role;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
/**
* 请购单Controller
@ -61,7 +70,27 @@ public class BaseRequisitioningOrderController extends BaseController
@Autowired
private SysDeptMapper sysDeptMapper;
@Autowired
private ISysAttachService attachService;
@Autowired
private ISysAttachFileService attachFileService;
@Autowired
private ISysRoleService roleService;
@Autowired
private TaskService taskService;
@Autowired
private RuntimeService runtimeService;
@Autowired
private IProcessService processService;
@Autowired
private IPurchasePlanService purchasePlanService;
@RequiresPermissions("system:requisitioning:view")
@GetMapping()
@ -76,10 +105,10 @@ public class BaseRequisitioningOrderController extends BaseController
@RequiresPermissions("system:requisitioning:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(BaseRequisitioningOrder baseRequisitioningOrder)
public TableDataInfo list(BaseRequisitioningOrderVo baseRequisitioningOrder)
{
startPage();
List<BaseRequisitioningOrder> list = baseRequisitioningOrderService.selectBaseRequisitioningOrderList(baseRequisitioningOrder);
List<BaseRequisitioningOrderVo> list = baseRequisitioningOrderService.selectBaseRequisitioningOrderList(baseRequisitioningOrder);
return getDataTable(list);
}
@ -90,10 +119,10 @@ public class BaseRequisitioningOrderController extends BaseController
@Log(title = "请购单", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ResponseBody
public AjaxResult export(BaseRequisitioningOrder baseRequisitioningOrder)
public AjaxResult export(BaseRequisitioningOrderVo baseRequisitioningOrder)
{
List<BaseRequisitioningOrder> list = baseRequisitioningOrderService.selectBaseRequisitioningOrderList(baseRequisitioningOrder);
ExcelUtil<BaseRequisitioningOrder> util = new ExcelUtil<BaseRequisitioningOrder>(BaseRequisitioningOrder.class);
List<BaseRequisitioningOrderVo> list = baseRequisitioningOrderService.selectBaseRequisitioningOrderList(baseRequisitioningOrder);
ExcelUtil<BaseRequisitioningOrderVo> util = new ExcelUtil<BaseRequisitioningOrderVo>(BaseRequisitioningOrderVo.class);
return util.exportExcel(list, "请购单数据");
}
/**
@ -202,4 +231,90 @@ public class BaseRequisitioningOrderController extends BaseController
result.put("postName",postName);
return result;
}
/**
* 加载审批弹窗
* @param taskId
* @param mmap
* @return
*/
@GetMapping("/showVerifyDialog/{taskId}")
public String showVerifyDialog(@PathVariable("taskId") String taskId, ModelMap mmap) {
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
String processInstanceId = task.getProcessInstanceId();
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
BaseRequisitioningOrderVo baseRequisitioningOrderVo = baseRequisitioningOrderService.selectBaseRequisitioningOrderById(Long.valueOf(processInstance.getBusinessKey()));
mmap.put("formData", baseRequisitioningOrderVo);
mmap.put("taskId", taskId);
String verifyName = task.getTaskDefinitionKey().substring(0, 1).toUpperCase() + task.getTaskDefinitionKey().substring(1);
return prefix + "/task" + verifyName;
}
/**
* 自动绑定页面字段
*/
@ModelAttribute("/preloadObj")
public BaseRequisitioningOrderVo getObj(@RequestParam(value = "requisitioningId", required = false) Long requisitioningId, HttpSession session) {
if (requisitioningId != null) {
return baseRequisitioningOrderService.selectBaseRequisitioningOrderById(requisitioningId);
}
return new BaseRequisitioningOrderVo();
}
/**
* 完成任务
*
* @return
*/
@RequestMapping(value = "/complete/{taskId}", method = {RequestMethod.POST, RequestMethod.GET})
@ResponseBody
public AjaxResult complete(@PathVariable("taskId") String taskId, @RequestParam(value = "saveEntity", required = false) String saveEntity,
@RequestParam(value = "baseRequisitioningOrderChildList", required = false) String baseRequisitioningOrderChildList,
@ModelAttribute("preloadObj") BaseRequisitioningOrderVo baseRequisitioningOrderVo, HttpServletRequest request){
// System.out.println("taskId = " + taskId + ", saveEntity = " + saveEntity + ", salesOrderChildList = " + salesOrderChildList + ", sysSalesOrderVo = " + sysSalesOrderVo + ", request = " + request);
baseRequisitioningOrderVo.setBaseRequisitioningOrderChildList(JSON.parseArray(baseRequisitioningOrderChildList, BaseRequisitioningOrderChild.class));
boolean saveEntityBoolean = BooleanUtils.toBoolean(saveEntity);
if (saveEntityBoolean) {
baseRequisitioningOrderService.updateBaseRequisitioningOrder(baseRequisitioningOrderVo);
}
String instanceId = baseRequisitioningOrderVo.getInstanceId();
String instanceType = baseRequisitioningOrderVo.getInstanceType();
boolean approvedFlag = processService.complete(taskId, instanceId,
baseRequisitioningOrderVo.getApplyTitle(), baseRequisitioningOrderVo.getRequisitioningCode(),
"requisition", new HashMap<String, Object>(), request);
if(!approvedFlag){
// 审核状态-审核拒绝
baseRequisitioningOrderVo.setAuditStatus("2");
}
// 如果任务已结束更新业务表状态
boolean processIsFinish = processService.judgeProcessIsFinish(instanceId);
if (processIsFinish) {
// 审核通过
baseRequisitioningOrderVo.setAuditStatus("1");
//查通过的审核订单
BaseRequisitioningOrderVo sysSalesOrderVo1 = baseRequisitioningOrderService.selectBaseRequisitioningOrderById(baseRequisitioningOrderVo.getRequisitioningId());
//生产订单生成
//生产采购计划
// 提交
if("submit".equals(instanceType)){
// 使用状态-是
baseRequisitioningOrderVo.setUseStatus("1");
}
// 作废
else if("cancel".equals(instanceType)){
// 使用状态-已作废
baseRequisitioningOrderVo.setUseStatus("2");
}
// 恢复
else if("restore".equals(instanceType)){
// 使用状态-是
baseRequisitioningOrderVo.setUseStatus("1");
}
}
baseRequisitioningOrderService.updateBaseRequisitioningOrder(baseRequisitioningOrderVo);
// 驳回申请后继续申请,可能修改表单
if (saveEntityBoolean) {
baseRequisitioningOrderService.updateBaseRequisitioningOrder(baseRequisitioningOrderVo);
}
return success("任务已完成");
}
}

4
ruoyi-admin/src/main/java/com/ruoyi/system/domain/BaseRequisitioningOrder.java

@ -91,6 +91,8 @@ public class BaseRequisitioningOrder extends BaseEntity
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date applyTime;
private List<BaseRequisitioningOrderChild> baseRequisitioningOrderChildList;
public String getInstanceId() {
return instanceId;
}
@ -171,8 +173,6 @@ public class BaseRequisitioningOrder extends BaseEntity
this.deptName = deptName;
}
private List<BaseRequisitioningOrderChild> baseRequisitioningOrderChildList;
public List<BaseRequisitioningOrderChild> getBaseRequisitioningOrderChildList() {
return baseRequisitioningOrderChildList;

124
ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/BaseRequisitioningOrderVo.java

@ -0,0 +1,124 @@
package com.ruoyi.system.domain.Vo;
import com.ruoyi.erp.domain.ErpBom;
import com.ruoyi.system.domain.BaseRequisitioningOrder;
import java.util.Date;
/**
*
* @Description 请购单信息Vo
*/
public class BaseRequisitioningOrderVo extends BaseRequisitioningOrder {
private static final long serialVersionUID = 1L;
/** 申请人姓名 */
private String applyUserName;
/** 任务ID */
private String taskId;
/** 任务名称 */
private String taskName;
/** 办理时间 */
private Date doneTime;
/** 创建人 */
private String createUserName;
/** 流程实例状态 1 激活 2 挂起 */
private String suspendState;
/** 待办用户id */
private String todoUserId;
/** 流程实例类型名称 */
private String instanceTypeName;
/**
* 关键词
*/
private String keyword;
public String getApplyUserName() {
return applyUserName;
}
public void setApplyUserName(String applyUserName) {
this.applyUserName = applyUserName;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getTaskName() {
return taskName;
}
public void setTaskName(String taskName) {
this.taskName = taskName;
}
public Date getDoneTime() {
return doneTime;
}
public void setDoneTime(Date doneTime) {
this.doneTime = doneTime;
}
public String getCreateUserName() {
return createUserName;
}
public void setCreateUserName(String createUserName) {
this.createUserName = createUserName;
}
public String getSuspendState() {
return suspendState;
}
public void setSuspendState(String suspendState) {
this.suspendState = suspendState;
}
public String getTodoUserId() {
return todoUserId;
}
public void setTodoUserId(String todoUserId) {
this.todoUserId = todoUserId;
}
public String getInstanceTypeName() {
return instanceTypeName;
}
public void setInstanceTypeName(String instanceTypeName) {
this.instanceTypeName = instanceTypeName;
}
public String getKeyword() {
return keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
@Override
public String toString() {
return "ErpMaterialVo{" +
"applyUserName='" + applyUserName + '\'' +
", taskId='" + taskId + '\'' +
", taskName='" + taskName + '\'' +
", doneTime=" + doneTime +
", createUserName='" + createUserName + '\'' +
", suspendState='" + suspendState + '\'' +
", todoUserId='" + todoUserId + '\'' +
", instanceTypeName='" + instanceTypeName + '\'' +
", keyword='" + keyword + '\'' +
"} " + super.toString();
}
}

7
ruoyi-admin/src/main/java/com/ruoyi/system/mapper/BaseRequisitioningOrderMapper.java

@ -2,6 +2,7 @@ package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.BaseRequisitioningOrder;
import com.ruoyi.system.domain.Vo.BaseRequisitioningOrderVo;
/**
* 请购单Mapper接口
@ -11,13 +12,16 @@ import com.ruoyi.system.domain.BaseRequisitioningOrder;
*/
public interface BaseRequisitioningOrderMapper
{
public List<BaseRequisitioningOrderVo> selectBaseRequisitioningOrderList(BaseRequisitioningOrderVo baseRequisitioningOrderVo1) ;
/**
* 查询请购单
*
* @param requisitioningId 请购单ID
* @return 请购单
*/
public BaseRequisitioningOrder selectBaseRequisitioningOrderById(Long requisitioningId);
public BaseRequisitioningOrderVo selectBaseRequisitioningOrderById(Long requisitioningId);
/**
* 查询请购单列表
@ -25,7 +29,6 @@ public interface BaseRequisitioningOrderMapper
* @param baseRequisitioningOrder 请购单
* @return 请购单集合
*/
public List<BaseRequisitioningOrder> selectBaseRequisitioningOrderList(BaseRequisitioningOrder baseRequisitioningOrder);
/**
* 新增请购单

233
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseRequisitioningOrderServiceImpl.java

@ -2,13 +2,34 @@ package com.ruoyi.system.service.impl;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.github.pagehelper.Page;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableSupport;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.service.ICommonService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.process.general.service.IProcessService;
import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper;
import com.ruoyi.system.domain.BaseRequisitioningOrderChild;
import com.ruoyi.system.domain.Vo.BaseRequisitioningOrderVo;
import com.ruoyi.system.mapper.BaseRequisitioningOrderChildMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.ISysAttachFileService;
import com.ruoyi.system.service.ISysAttachService;
import com.ruoyi.system.service.ISysRoleService;
import org.activiti.engine.TaskService;
import org.activiti.engine.impl.persistence.entity.TaskEntityImpl;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.BaseRequisitioningOrderMapper;
@ -16,6 +37,7 @@ import com.ruoyi.system.domain.BaseRequisitioningOrder;
import com.ruoyi.system.service.IBaseRequisitioningOrderService;
import com.ruoyi.common.core.text.Convert;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
/**
* 请购单Service业务层处理
@ -32,9 +54,31 @@ public class BaseRequisitioningOrderServiceImpl implements IBaseRequisitioningOr
@Autowired
private BaseRequisitioningOrderChildMapper baseRequisitioningOrderChildMapper;
@Autowired
private RedisCache redisCache;
private ISysRoleService roleService;
@Autowired
private ISysAttachService attachService;
@Autowired
private ISysAttachFileService attachFileService;
@Autowired
private ICommonService commonService;
@Autowired
private SysUserMapper userMapper;
@Autowired
private TaskService taskService;
@Autowired
private BizTodoItemMapper todoItemMapper;
@Autowired
private IProcessService processService;
/**
* 查询请购单
*
@ -42,21 +86,72 @@ public class BaseRequisitioningOrderServiceImpl implements IBaseRequisitioningOr
* @return 请购单
*/
@Override
public BaseRequisitioningOrder selectBaseRequisitioningOrderById(Long requisitioningId)
public BaseRequisitioningOrderVo selectBaseRequisitioningOrderById(Long requisitioningId)
{
return baseRequisitioningOrderMapper.selectBaseRequisitioningOrderById(requisitioningId);
}
/**
* 查询请购单列表
*
* @param baseRequisitioningOrder 请购单
* @param baseRequisitioningOrderVo1 请购单
* @return 请购单
*/
@Override
public List<BaseRequisitioningOrder> selectBaseRequisitioningOrderList(BaseRequisitioningOrder baseRequisitioningOrder)
public List<BaseRequisitioningOrderVo> selectBaseRequisitioningOrderList(BaseRequisitioningOrderVo baseRequisitioningOrderVo1)
{
return baseRequisitioningOrderMapper.selectBaseRequisitioningOrderList(baseRequisitioningOrder);
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
//PageHelper 仅对第一List分页有效
Page<BaseRequisitioningOrderVo> list = (Page<BaseRequisitioningOrderVo>) baseRequisitioningOrderMapper.selectBaseRequisitioningOrderList(baseRequisitioningOrderVo1);
Page<BaseRequisitioningOrderVo> returnList = new Page<>();
for(BaseRequisitioningOrderVo baseRequisitioningOrderVo : list){
SysUser sysUser = userMapper.selectUserByLoginName(baseRequisitioningOrderVo.getCreateBy());
if (sysUser != null) {
baseRequisitioningOrderVo.setCreateBy(sysUser.getUserName());
}
SysUser sysUser2 = userMapper.selectUserByLoginName(baseRequisitioningOrderVo.getApplyUser());
if (sysUser2!=null){
baseRequisitioningOrderVo.setApplyUserName(sysUser2.getUserName());
}
String instanceId = baseRequisitioningOrderVo.getInstanceId();
// 当前环节
if (StringUtils.isNotBlank(instanceId)) {
List<Task> taskList = taskService.createTaskQuery()
.processInstanceId(instanceId)
// .singleResult();
.list(); // 例如请假会签,会同时拥有多个任务
if (!CollectionUtils.isEmpty(taskList)) {
TaskEntityImpl task = (TaskEntityImpl) taskList.get(0);
String taskId = task.getId();
baseRequisitioningOrderVo.setTaskId(taskId);
// 设置待办用户
List<String> todoUserList = todoItemMapper.selectUndealTodoUserList(taskId);
if(!CollectionUtils.isEmpty(taskList)){
baseRequisitioningOrderVo.setTodoUserId(String.join(",",todoUserList));
}
if (task.getSuspensionState() == 2) {
baseRequisitioningOrderVo.setTaskName("已挂起");
baseRequisitioningOrderVo.setSuspendState("2");
} else {
baseRequisitioningOrderVo.setTaskName(task.getName());
baseRequisitioningOrderVo.setSuspendState("1");
}
} else {
// 已办结或者已撤销
baseRequisitioningOrderVo.setTaskName("已结束");
}
} else {
baseRequisitioningOrderVo.setTaskName("未启动");
}
returnList.add(baseRequisitioningOrderVo);
}
returnList.setTotal(CollectionUtils.isEmpty(list) ? 0 : list.getTotal());
returnList.setPageNum(pageNum);
returnList.setPageSize(pageSize);
return returnList;
}
/**
@ -75,7 +170,6 @@ public class BaseRequisitioningOrderServiceImpl implements IBaseRequisitioningOr
if (baseRequisitioningOrder.getRequisitioningCode() == null) {
baseRequisitioningOrder.setRequisitioningCode(redisCache.generateBillNo("QG"));
}
baseRequisitioningOrder.setRequisitioningCode(redisCache.generateBillNo("QG"));
List<BaseRequisitioningOrderChild> childList = baseRequisitioningOrder.getBaseRequisitioningOrderChildList();
Long materialSum = 0L;
BigDecimal materialRmbSum = new BigDecimal(0);
@ -208,4 +302,131 @@ public class BaseRequisitioningOrderServiceImpl implements IBaseRequisitioningOr
public Object getId(){
return redisCache.generateBillNo("QG");
}
@Override
@Transactional(rollbackFor = Exception.class)
public ProcessInstance cancelSysCustomerById(Long id) {
BaseRequisitioningOrderVo baseRequisitioningOrderVo = baseRequisitioningOrderMapper.selectBaseRequisitioningOrderById(id);
// 审核状态-待审核
baseRequisitioningOrderVo.setAuditStatus("0");
SysUser user = ShiroUtils.getSysUser();
// 启动流程
String applyTitle = user.getUserName()+"发起了请购订单信息作废审批-"+ DateUtils.dateTimeNow();
String instanceType = "cancel";
BaseRequisitioningOrder baseRequisitioningOrder = new BaseRequisitioningOrder();
BeanUtils.copyProperties(baseRequisitioningOrderVo,baseRequisitioningOrder);
ProcessInstance processInstance = startProcessInstance(applyTitle,instanceType,baseRequisitioningOrder, user);
String processInstanceId = processInstance.getProcessInstanceId();
// 作废实例id
baseRequisitioningOrder.setCancelInstanceId(processInstanceId);
// 存在提交完就流程结束的情况
boolean processIsFinish = processService.judgeProcessIsFinish(processInstanceId);
if(processIsFinish){
// 审核状态-审核通过
baseRequisitioningOrder.setAuditStatus("1");
// 使用状态-已作废
baseRequisitioningOrder.setUseStatus("2");
}
baseRequisitioningOrderMapper.updateBaseRequisitioningOrder(baseRequisitioningOrder);
return processInstance;
}
@Override
@Transactional(rollbackFor = Exception.class)
public ProcessInstance restoreSysCustomerById(Long id) {
BaseRequisitioningOrderVo baseRequisitioningOrderVo = baseRequisitioningOrderMapper.selectBaseRequisitioningOrderById(id);
// 审核状态-待审核
baseRequisitioningOrderVo.setAuditStatus("0");
SysUser user = ShiroUtils.getSysUser();
// 启动流程
String applyTitle = user.getUserName()+"发起了请购订单信息恢复审批-"+DateUtils.dateTimeNow();
String instanceType = "restore";
BaseRequisitioningOrder baseRequisitioningOrder = new BaseRequisitioningOrder();
BeanUtils.copyProperties(baseRequisitioningOrderVo,baseRequisitioningOrder);
ProcessInstance processInstance = startProcessInstance(applyTitle,instanceType,baseRequisitioningOrder, user);
String processInstanceId = processInstance.getProcessInstanceId();
// 恢复实例id
baseRequisitioningOrder.setRestoreInstanceId(processInstanceId);
// 存在提交完就流程结束的情况
boolean processIsFinish = processService.judgeProcessIsFinish(processInstanceId);
if(processIsFinish){
// 审核状态-审核通过
baseRequisitioningOrder.setAuditStatus("1");
// 使用状态-是
baseRequisitioningOrder.setUseStatus("1");
}
baseRequisitioningOrderMapper.updateBaseRequisitioningOrder(baseRequisitioningOrder);
return processInstance;
}
/**
* 提交申请
* @param baseRequisitioningOrder
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ProcessInstance submitApply(BaseRequisitioningOrder baseRequisitioningOrder) {
SysUser user = ShiroUtils.getSysUser();
baseRequisitioningOrder.setApplyUser(user.getLoginName());
baseRequisitioningOrder.setApplyTime(DateUtils.getNowDate());
insertBaseRequisitioningOrder(baseRequisitioningOrder);
// 启动流程
String applyTitle = user.getUserName()+"发起了请购订单信息提交审批-"+DateUtils.dateTimeNow();
String instanceType = "submit";
ProcessInstance processInstance = startProcessInstance(applyTitle,instanceType,baseRequisitioningOrder, user);
String processInstanceId = processInstance.getProcessInstanceId();
// 提交实例id
baseRequisitioningOrder.setSubmitInstanceId(processInstanceId);
// 存在提交完就流程结束的情况
boolean processIsFinish = processService.judgeProcessIsFinish(processInstanceId);
if(processIsFinish){
// 审核状态-审核通过
baseRequisitioningOrder.setAuditStatus("1");
// 使用状态-是
baseRequisitioningOrder.setUseStatus("1");
}
baseRequisitioningOrderMapper.updateBaseRequisitioningOrder(baseRequisitioningOrder);
return processInstance;
}
private ProcessInstance startProcessInstance(String applyTitle,String instanceType,BaseRequisitioningOrder baseRequisitioningOrder, SysUser user) {
Long nessKey = baseRequisitioningOrder.getRequisitioningId();
String businessKey = String.valueOf(nessKey); // 实体类 ID,作为流程的业务 key
String key = "requsition";
Map<String,Object> variables = new HashMap<>();
// 构造authority传参
buildAuthority(user, variables);
baseRequisitioningOrder.setApplyTitle(applyTitle);
// 启动流程
ProcessInstance processInstance = processService.submitApply(user.getLoginName(), businessKey, applyTitle, baseRequisitioningOrder.getRequisitioningCode(), key, variables);
String processInstanceId = processInstance.getId();
baseRequisitioningOrder.setInstanceId(processInstanceId); // 建立双向关系
baseRequisitioningOrder.setInstanceType(instanceType);
return processInstance;
}
private void buildAuthority(SysUser user, Map<String, Object> variables) {
Set<String> roleKeys = roleService.selectRoleKeys(user.getUserId());
if(roleKeys.contains("zg")){
// 超级管理员
variables.put("authority",1);
}
if(roleKeys.contains("cg")){
if(roleKeys.contains("cg_zj")){
// 采购主管
variables.put("authority",2);
}else{
// 采购员
variables.put("authority",3);
}
}
// 角色不同审核人不同
variables.put("authority",1);
variables.put("qgje",3000);
}
}

95
ruoyi-admin/src/main/resources/mapper/system/BaseRequisitioningOrderMapper.xml

@ -4,7 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.BaseRequisitioningOrderMapper">
<resultMap type="BaseRequisitioningOrder" id="BaseRequisitioningOrderResult">
<resultMap type="BaseRequisitioningOrderVo" id="BaseRequisitioningOrderResult">
<result property="requisitioningId" column="requisitioning_id" />
<result property="auditStatus" column="audit_status" />
<result property="requisitioningStatus" column="requisitioning_status" />
@ -21,27 +21,58 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="useStatus" column="use_status" />
<result property="instanceId" column="instance_id" />
<result property="instanceType" column="instance_type" />
<result property="instanceTypeName" column="instance_type_name" />
<result property="submitInstanceId" column="submit_instance_id" />
<result property="cancelInstanceId" column="cancel_instance_id" />
<result property="restoreInstanceId" column="restore_instance_id"/>
<result property="applyTitle" column="apply_title" />
<result property="applyUser" column="apply_user" />
<result property="applyTime" column="apply_time" />
</resultMap>
<sql id="selectBaseRequisitioningOrderVo">
select requisitioning_id, audit_status, requisitioning_status, requisitioning_code,
correlation_code, material_amount, materialSum, noRmbSum, rmbSum, apply_user,
create_by, create_time, update_by, update_time, remark, use_status
create_by, create_time, update_by, update_time, remark, use_status,
instance_id, instance_type, instance_type_name, submit_instance_id, cancel_instance_id, restore_instance_id,
apply_title, apply_user, apply_time
from base_requisitioning_order
</sql>
<select id="selectBaseRequisitioningOrderList" parameterType="BaseRequisitioningOrder" resultMap="BaseRequisitioningOrderResult">
<include refid="selectBaseRequisitioningOrderVo"/>
select r.requisitioning_id, r.requisitioning_status, r.requisitioning_code,
r.correlation_code, r.material_amount, r.materialSum, r.noRmbSum, r.rmbSum,
r.update_by, r.update_time, r.remark,r.instance_id, p.dict_value as instance_type_name,
r.instance_type,r.submit_instance_id, r.cancel_instance_id,
r.restore_instance_id, r.apply_title, r.apply_user, r.apply_time,r.apply_user,
r.create_by, r.create_time, r.audit_status, r.use_status
from base_requisitioning_order as r
left join(
select dict_value,dict_label from sys_dict_data
where dict_type = 'processType'
) as p
on r.instance_type = p.dict_value
<where>
<if test="auditStatus != null and auditStatus != ''"> and audit_status = #{auditStatus}</if>
<if test="requisitioningStatus != null and requisitioningStatus != ''"> and requisitioning_status = #{requisitioningStatus}</if>
<if test="requisitioningCode != null and requisitioningCode != ''"> and requisitioning_code = #{requisitioningCode}</if>
<if test="createBy != null and createBy != ''"> and create_by = #{createBy}</if>
<if test="requisitioningStatus != null and requisitioningStatus != ''"> and r.requisitioning_status = #{requisitioningStatus}</if>
<if test="requisitioningCode != null and requisitioningCode != ''"> and r.requisitioning_code = #{requisitioningCode}</if>
<if test="auditStatus!= null and auditStatus != ''"> and r.audit_status = #{auditStatus}</if>
<if test="useStatus!= null and useStatus != ''"> and r.use_status = #{useStatus}</if>
<if test="instanceId != null and instanceId != ''"> and r.instance_id = #{instanceId}</if>
<if test="instanceType != null and instanceType != ''"> and r.instance_type = #{instanceType}</if>
<if test="submitInstanceId != null and submitInstanceId != ''"> and r.submit_instance_id = #{submitInstanceId}</if>
<if test="cancelInstanceId != null and cancelInstanceId != ''"> and r.cancel_instance_id = #{cancelInstanceId}</if>
<if test="restoreInstanceId != null and restoreInstanceId != ''"> and r.restore_instance_id = #{restoreInstanceId}</if>
<if test="applyTitle != null and applyTitle != ''"> and r.apply_title = #{applyTitle}</if>
<if test="applyUser != null and applyUser != ''"> and r.apply_user = #{applyUser}</if>
<if test="applyTime != null "> and r.apply_time = #{applyTime}</if>
<if test="createBy != null and createBy != ''"> and r.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}
and r.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if>
<if test="params.materialCode != null and params.materialCode != '' or params.materialName !=null and params.materialName != ''">
and requisitioning_code in (
and r.requisitioning_code in (
select quote_id from base_requisitioning_order_child
<where>
<if test="params.materialCode != null and params.materialCode != ''">
@ -66,12 +97,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<insert id="insertBaseRequisitioningOrder" parameterType="BaseRequisitioningOrder" useGeneratedKeys="true" keyProperty="requisitioningId">
insert into base_requisitioning_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="auditStatus != null">audit_status,</if>
<if test="requisitioningStatus != null">requisitioning_status,</if>
<if test="requisitioningCode != null">requisitioning_code,</if>
<if test="correlationCode != null">correlation_code,</if>
@ -79,16 +108,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="materialSum != null">materialSum,</if>
<if test="noRmbSum != null">noRmbSum,</if>
<if test="rmbSum != null">rmbSum,</if>
<if test="instanceId != null">instance_id,</if>
<if test="instanceType != null">instance_type,</if>
<if test="submitInstanceId != null">submit_instance_id,</if>
<if test="cancelInstanceId != null">cancel_instance_id,</if>
<if test="restoreInstanceId != null">restore_instance_id,</if>
<if test="applyTitle != null">apply_title,</if>
<if test="applyUser != null">apply_user,</if>
<if test="applyTime != null">apply_time,</if>
<if test="useStatus != null">use_status,</if>
<if test="auditStatus != null">audit_status,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="useStatus != null">use_status,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="auditStatus != null">#{auditStatus},</if>
<if test="requisitioningStatus != null">#{requisitioningStatus},</if>
<if test="requisitioningCode != null">#{requisitioningCode},</if>
<if test="correlationCode != null">#{correlationCode},</if>
@ -96,20 +130,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="materialSum != null">#{materialSum},</if>
<if test="noRmbSum != null">#{noRmbSum},</if>
<if test="rmbSum != null">#{rmbSum},</if>
<if test="applyUser != null">#{applyUser},</if>
<if test="instanceId != null">#{instance_id},</if>
<if test="instanceType != null">#{instance_type},</if>
<if test="submitInstanceId != null">#{submit_instance_id},</if>
<if test="cancelInstanceId != null">#{cancel_instance_id},</if>
<if test="restoreInstanceId != null">#{restore_instance_id},</if>
<if test="applyTitle != null">#{apply_title},</if>
<if test="applyUser != null">#{apply_user},</if>
<if test="applyTime != null">#{apply_time},</if>
<if test="useStatus != null">#{use_status},</if>
<if test="auditStatus != null">#{audit_status},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="useStatus != null">#{useStatus},</if>
</trim>
</insert>
<update id="updateBaseRequisitioningOrder" parameterType="BaseRequisitioningOrder">
update base_requisitioning_order
<trim prefix="SET" suffixOverrides=",">
<if test="auditStatus != null">audit_status = #{auditStatus},</if>
<if test="requisitioningStatus != null">requisitioning_status = #{requisitioningStatus},</if>
<if test="requisitioningCode != null">requisitioning_code = #{requisitioningCode},</if>
<if test="correlationCode != null">correlation_code = #{correlationCode},</if>
@ -117,13 +156,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="materialSum != null">materialSum = #{materialSum},</if>
<if test="noRmbSum != null">noRmbSum = #{noRmbSum},</if>
<if test="rmbSum != null">rmbSum = #{rmbSum},</if>
<if test="applyUser != null">apply_user = #{applyUser},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="instanceId != null">#{instanceId},</if>
<if test="instanceType != null">#{instanceType},</if>
<if test="submitInstanceId != null">#{submitInstanceId},</if>
<if test="cancelInstanceId != null">#{cancelInstanceId},</if>
<if test="restoreInstanceId != null">#{restoreInstanceId},</if>
<if test="applyTitle != null">#{applyTitle},</if>
<if test="applyUser != null">#{applyUser},</if>
<if test="applyTime != null">#{applyTime},</if>
<if test="useStatus != null">#{useStatus},</if>
<if test="auditStatus != null">#{auditStatus},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="useStatus != null">use_status = #{useStatus},</if>
</trim>
where requisitioning_id = #{requisitioningId}
</update>

21
ruoyi-admin/src/main/resources/templates/system/requisitioning/add.html

@ -69,10 +69,9 @@
model: "物料报价信息",
columns: [
{checkbox: true},
{field: 'index',align: 'center', title: "序号",
{field: 'materialIndex',align: 'center', title: "序号",
formatter: function (value, row, index) {
var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
return columnIndex + $.table.serialNumber(index);
return index+1;
}
},
{title: '物料索引id',field: 'materialId',align: 'center',visible: false},
@ -158,7 +157,7 @@
{title: '操作', align: 'center',
formatter: function (value, row, index) {
var actions = [];
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeRow(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeRow(\'' + row.materialIndex + '\')"><i class="fa fa-remove"></i>删除</a> ');
return actions.join('');
}
}
@ -176,6 +175,14 @@
var iframeWin = window[layero.find('iframe')[0]['name']];
var rowData = iframeWin.$('#bootstrap-select-table').bootstrapTable('getSelections')[0];
console.log("rowData: "+rowData);
var rows = $("#bootstrap-sub-table-requisitionChild").bootstrapTable('getData').length;
for(var i=0;i<rows;i++){
var data = $("#bootstrap-sub-table-requisitionChild").bootstrapTable('getData')[i];
if(data.materialCode==rowData.materialNo){
$.modal.alertError("不能选择已添加过的相同料号");
return;
}
}
$("#bootstrap-sub-table-requisitionChild").bootstrapTable('insertRow', {
index:1,
row: {
@ -208,10 +215,10 @@
$.modal.openOptions(options);
}
/* 删除指定表格行 */
function removeRow(id){
function removeRow(materialIndex){
$("#bootstrap-sub-table-requisitionChild").bootstrapTable('remove', {
field: 'id',
values: id
field: 'materialIndex',
values: materialIndex
})
}
function submitHandler() {

Loading…
Cancel
Save