From 37e39806a537d86d2a0a7b499d6027154579c1e2 Mon Sep 17 00:00:00 2001 From: zhangsiqi <2825463979@qq.com> Date: Mon, 8 Jul 2024 20:36:23 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20=E6=B7=BB=E5=8A=A0=E8=AF=B7=E8=B4=AD?= =?UTF-8?q?=E5=8D=95=E5=AE=A1=E6=A0=B8=E8=8A=82=E7=82=B9=EF=BC=8C=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8=E5=8A=9F=E8=83=BD=E9=A1=B5=E9=9D=A2=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BaseRequisitioningOrderController.java | 139 ++++++++++- .../domain/BaseRequisitioningOrder.java | 4 +- .../domain/Vo/BaseRequisitioningOrderVo.java | 124 +++++++++ .../mapper/BaseRequisitioningOrderMapper.java | 9 +- .../BaseRequisitioningOrderServiceImpl.java | 235 +++++++++++++++++- .../system/BaseRequisitioningOrderMapper.xml | 97 ++++++-- .../templates/system/requisitioning/add.html | 21 +- 7 files changed, 572 insertions(+), 57 deletions(-) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/BaseRequisitioningOrderVo.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseRequisitioningOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseRequisitioningOrderController.java index 6dd6fb42..a419e72f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseRequisitioningOrderController.java +++ b/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 list = baseRequisitioningOrderService.selectBaseRequisitioningOrderList(baseRequisitioningOrder); + List 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 list = baseRequisitioningOrderService.selectBaseRequisitioningOrderList(baseRequisitioningOrder); - ExcelUtil util = new ExcelUtil(BaseRequisitioningOrder.class); + List list = baseRequisitioningOrderService.selectBaseRequisitioningOrderList(baseRequisitioningOrder); + ExcelUtil util = new ExcelUtil(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(), 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("任务已完成"); + } + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/BaseRequisitioningOrder.java b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/BaseRequisitioningOrder.java index 6714b2e5..dc5bea5a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/BaseRequisitioningOrder.java +++ b/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 baseRequisitioningOrderChildList; + public String getInstanceId() { return instanceId; } @@ -171,8 +173,6 @@ public class BaseRequisitioningOrder extends BaseEntity this.deptName = deptName; } - private List baseRequisitioningOrderChildList; - public List getBaseRequisitioningOrderChildList() { return baseRequisitioningOrderChildList; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/BaseRequisitioningOrderVo.java b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/BaseRequisitioningOrderVo.java new file mode 100644 index 00000000..c995e980 --- /dev/null +++ b/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(); + } + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/BaseRequisitioningOrderMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/BaseRequisitioningOrderMapper.java index b620b422..20981bf3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/BaseRequisitioningOrderMapper.java +++ b/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,21 +12,23 @@ import com.ruoyi.system.domain.BaseRequisitioningOrder; */ public interface BaseRequisitioningOrderMapper { + public List selectBaseRequisitioningOrderList(BaseRequisitioningOrderVo baseRequisitioningOrderVo1) ; + + /** * 查询请购单 * * @param requisitioningId 请购单ID * @return 请购单 */ - public BaseRequisitioningOrder selectBaseRequisitioningOrderById(Long requisitioningId); + public BaseRequisitioningOrderVo selectBaseRequisitioningOrderById(Long requisitioningId); /** * 查询请购单列表 - * + * * @param baseRequisitioningOrder 请购单 * @return 请购单集合 */ - public List selectBaseRequisitioningOrderList(BaseRequisitioningOrder baseRequisitioningOrder); /** * 新增请购单 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseRequisitioningOrderServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseRequisitioningOrderServiceImpl.java index 7c2f659f..c49c1a21 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/BaseRequisitioningOrderServiceImpl.java +++ b/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 selectBaseRequisitioningOrderList(BaseRequisitioningOrder baseRequisitioningOrder) + public List selectBaseRequisitioningOrderList(BaseRequisitioningOrderVo baseRequisitioningOrderVo1) { - return baseRequisitioningOrderMapper.selectBaseRequisitioningOrderList(baseRequisitioningOrder); + PageDomain pageDomain = TableSupport.buildPageRequest(); + Integer pageNum = pageDomain.getPageNum(); + Integer pageSize = pageDomain.getPageSize(); + //PageHelper 仅对第一List分页有效 + Page list = (Page) baseRequisitioningOrderMapper.selectBaseRequisitioningOrderList(baseRequisitioningOrderVo1); + Page 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 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 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 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 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 variables) { + Set 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); + } } diff --git a/ruoyi-admin/src/main/resources/mapper/system/BaseRequisitioningOrderMapper.xml b/ruoyi-admin/src/main/resources/mapper/system/BaseRequisitioningOrderMapper.xml index c23c9231..465beb0b 100644 --- a/ruoyi-admin/src/main/resources/mapper/system/BaseRequisitioningOrderMapper.xml +++ b/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"> - + @@ -21,27 +21,58 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + + 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 insert into base_requisitioning_order - audit_status, requisitioning_status, requisitioning_code, correlation_code, @@ -79,16 +108,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" materialSum, noRmbSum, rmbSum, + instance_id, + instance_type, + submit_instance_id, + cancel_instance_id, + restore_instance_id, + apply_title, apply_user, + apply_time, + use_status, + audit_status, create_by, create_time, - update_by, - update_time, remark, - use_status, - #{auditStatus}, #{requisitioningStatus}, #{requisitioningCode}, #{correlationCode}, @@ -96,20 +130,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{materialSum}, #{noRmbSum}, #{rmbSum}, - #{applyUser}, + #{instance_id}, + #{instance_type}, + #{submit_instance_id}, + #{cancel_instance_id}, + #{restore_instance_id}, + #{apply_title}, + #{apply_user}, + #{apply_time}, + #{use_status}, + #{audit_status}, #{createBy}, #{createTime}, - #{updateBy}, - #{updateTime}, #{remark}, - #{useStatus}, update base_requisitioning_order - audit_status = #{auditStatus}, requisitioning_status = #{requisitioningStatus}, requisitioning_code = #{requisitioningCode}, correlation_code = #{correlationCode}, @@ -117,13 +156,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" materialSum = #{materialSum}, noRmbSum = #{noRmbSum}, rmbSum = #{rmbSum}, - apply_user = #{applyUser}, - create_by = #{createBy}, - create_time = #{createTime}, + remark = #{remark}, + #{instanceId}, + #{instanceType}, + #{submitInstanceId}, + #{cancelInstanceId}, + #{restoreInstanceId}, + #{applyTitle}, + #{applyUser}, + #{applyTime}, + #{useStatus}, + #{auditStatus}, update_by = #{updateBy}, update_time = #{updateTime}, - remark = #{remark}, - use_status = #{useStatus}, where requisitioning_id = #{requisitioningId} diff --git a/ruoyi-admin/src/main/resources/templates/system/requisitioning/add.html b/ruoyi-admin/src/main/resources/templates/system/requisitioning/add.html index eb6188cf..acaa98bf 100644 --- a/ruoyi-admin/src/main/resources/templates/system/requisitioning/add.html +++ b/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("", $.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('删除 '); + actions.push('删除 '); 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