From cb94b914aba77f0fbb0aef4b3677cbb8b9ad4a22 Mon Sep 17 00:00:00 2001 From: liuxiaoxu <1793812695@qq.com> Date: Wed, 17 Jul 2024 17:54:57 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E5=94=AE=E5=90=8E=E7=AE=A1=E7=90=86=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=94=AE=E5=90=8E=E5=8D=95=E7=9A=84=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E6=96=B0=E5=A2=9E=E9=A1=B5=E9=9D=A2=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=94=AE=E5=90=8E=E5=8D=95=E4=BF=AE=E6=94=B9=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=20=E6=96=B0=E5=A2=9E=E5=94=AE=E5=90=8E=E5=8D=95VO?= =?UTF-8?q?=E7=B1=BB=E3=80=82=E5=8A=A0=E4=B8=8A=E6=B5=81=E7=A8=8B=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E5=AD=97=E6=AE=B5=20=E4=BF=AE=E6=94=B9=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E5=94=AE=E5=90=8E=E5=8D=95=E5=88=97=E8=A1=A8=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=8E=A5=E5=8F=A3=20=E4=BF=AE=E6=94=B9=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E5=94=AE=E5=90=8E=E5=8D=95=E5=88=97=E8=A1=A8=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E6=8E=A5=E5=8F=A3=20=E4=BF=AE=E6=94=B9=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E4=BF=9D=E5=AD=98=E5=94=AE=E5=90=8E=E5=8D=95=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=9A=E6=96=B0=E5=A2=9E=E5=BC=80=E5=A7=8B=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8=E6=96=B9=E6=B3=95=E5=92=8C=E5=AE=A1=E6=A0=B8=E7=8A=B6?= =?UTF-8?q?=E6=80=81=20=E6=96=B0=E5=A2=9E=20=E5=8A=A0=E8=BD=BD=E5=AE=A1?= =?UTF-8?q?=E6=89=B9=E5=BC=B9=E7=AA=97=E5=90=8E=E7=AB=AF=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=20=E6=96=B0=E5=A2=9E=20=E8=87=AA=E5=8A=A8=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=AD=97=E6=AE=B5=E5=90=8E=E7=AB=AF=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20=E6=96=B0=E5=A2=9E=20=E5=AE=8C=E6=88=90=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=90=8E=E7=AB=AF=E6=8E=A5=E5=8F=A3=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=9F=A5=E8=AF=A2=E5=94=AE=E5=90=8E=E5=8D=95=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E6=8E=A5=E5=8F=A3=20=E4=BF=AE=E6=94=B9=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=94=AE=E5=90=8E=E7=AB=AF=E9=9B=86=E5=90=88=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20=E4=BF=AE=E6=94=B9=E5=94=AE=E5=90=8E=E5=8D=95?= =?UTF-8?q?=E7=9A=84resultMap=E4=B8=BAvo=E7=B1=BB=E5=9E=8B=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=8F=91=E8=B5=B7=E4=BA=BA=E8=8A=82=E7=82=B9=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E5=90=8E=E7=AB=AF=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E9=9C=80=E8=A6=81=E7=9A=84=E8=A7=92=E8=89=B2=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E4=BA=BA=20=E6=96=B0=E5=A2=9E=E5=94=AE=E5=90=8E?= =?UTF-8?q?=E5=8D=95=E9=A9=B3=E5=9B=9E=E8=B0=83=E6=95=B4=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=20=E6=96=B0=E5=A2=9E=E5=94=AE=E5=90=8E=E5=8D=95=E4=B8=9A?= =?UTF-8?q?=E5=8A=A1=E7=BB=8F=E7=90=86=E5=AE=A1=E6=A0=B8=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=20=E6=96=B0=E5=A2=9E=E5=94=AE=E5=90=8E=E5=8D=95=E4=B8=9A?= =?UTF-8?q?=E5=8A=A1=E4=B8=BB=E7=AE=A1=E5=AE=A1=E6=A0=B8=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AftersalesOrderController.java | 129 ++++++++++++-- .../domain/vo/AftersalesOrderVO.java | 33 ++++ .../mapper/AftersalesOrderMapper.java | 5 +- .../service/IAftersalesOrderService.java | 15 +- .../impl/AftersalesOrderServiceImpl.java | 165 +++++++++++++++++- .../AfterSalesShippingDeviceMapper.xml | 1 + .../aftersales/AftersalesOrderMapper.xml | 9 +- .../aftersales/aftersalesOrder/add.html | 110 +----------- .../aftersalesOrder/aftersalesOrder.html | 132 ++++++++++++-- .../aftersales/aftersalesOrder/edit.html | 2 + .../aftersalesOrder/taskModifyApply.html | 140 +++++++++++++++ .../aftersalesOrder/taskYwjlVerify.html | 147 ++++++++++++++++ .../aftersalesOrder/taskYwzgVerify.html | 147 ++++++++++++++++ 13 files changed, 889 insertions(+), 146 deletions(-) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/aftersales/domain/vo/AftersalesOrderVO.java create mode 100644 ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/taskModifyApply.html create mode 100644 ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/taskYwjlVerify.html create mode 100644 ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/taskYwzgVerify.html diff --git a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/controller/AftersalesOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/controller/AftersalesOrderController.java index d2348894..8bb917cd 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/controller/AftersalesOrderController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/controller/AftersalesOrderController.java @@ -1,20 +1,26 @@ package com.ruoyi.aftersales.controller; +import java.util.HashMap; import java.util.List; +import com.ruoyi.aftersales.domain.vo.AftersalesOrderVO; import com.ruoyi.aftersales.domain.vo.SelectDeviceVO; import com.ruoyi.aftersales.service.IAfterSalesShippingDeviceService; import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.process.general.service.IProcessService; +import com.ruoyi.system.domain.SysMakeorderPick; +import com.ruoyi.system.domain.SysMakeorderPickVo; import com.ruoyi.system.service.ISysUserService; +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; import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.aftersales.domain.AftersalesOrder; @@ -24,6 +30,9 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + /** * 售后单Controller * @@ -46,6 +55,17 @@ public class AftersalesOrderController extends BaseController @Autowired private ISysUserService sysUserService; + + @Autowired + private TaskService taskService; + + @Autowired + private RuntimeService runtimeService; + + @Autowired + private IProcessService processService; + + @RequiresPermissions("aftersales:aftersalesOrder:view") @GetMapping() public String aftersalesOrder() @@ -59,10 +79,10 @@ public class AftersalesOrderController extends BaseController @RequiresPermissions("aftersales:aftersalesOrder:list") @PostMapping("/list") @ResponseBody - public TableDataInfo list(AftersalesOrder aftersalesOrder) + public TableDataInfo list(AftersalesOrderVO aftersalesOrderVO) { startPage(); - List list = aftersalesOrderService.selectAftersalesOrderList(aftersalesOrder); + List list = aftersalesOrderService.selectAftersalesOrderList(aftersalesOrderVO); return getDataTable(list); } @@ -75,10 +95,10 @@ public class AftersalesOrderController extends BaseController @Log(title = "售后单", businessType = BusinessType.EXPORT) @PostMapping("/export") @ResponseBody - public AjaxResult export(AftersalesOrder aftersalesOrder) + public AjaxResult export(AftersalesOrderVO aftersalesOrderVO) { - List list = aftersalesOrderService.selectAftersalesOrderList(aftersalesOrder); - ExcelUtil util = new ExcelUtil(AftersalesOrder.class); + List list = aftersalesOrderService.selectAftersalesOrderList(aftersalesOrderVO); + ExcelUtil util = new ExcelUtil(AftersalesOrderVO.class); return util.exportExcel(list, "售后单数据"); } @@ -100,9 +120,95 @@ public class AftersalesOrderController extends BaseController @ResponseBody public AjaxResult addSave(AftersalesOrder aftersalesOrder) { - return toAjax(aftersalesOrderService.insertAftersalesOrder(aftersalesOrder)); + // 审核状态-待审核 + aftersalesOrder.setAuditStatus("0"); + aftersalesOrderService.submitApply(aftersalesOrder); + return AjaxResult.success(); } + + /** + * 加载审批弹窗 + * @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(); + AftersalesOrderVO aftersalesOrderVO = aftersalesOrderService.selectAftersalesOrderById(new Long(processInstance.getBusinessKey())); + mmap.put("formData", aftersalesOrderVO); + mmap.put("taskId", taskId); + String verifyName = task.getTaskDefinitionKey().substring(0, 1).toUpperCase() + task.getTaskDefinitionKey().substring(1); + return prefix + "/task" + verifyName; + } + + /** + * 自动绑定页面字段 + */ + @ModelAttribute("preloadObj") + public AftersalesOrderVO getObj(@RequestParam(value = "aftersalesOrderId", required = false) Long aftersalesOrderId, HttpSession session) { + if (aftersalesOrderId != null) { + + return aftersalesOrderService.selectAftersalesOrderById(aftersalesOrderId); + } + return new AftersalesOrderVO(); + } + + + /** + * 完成任务 + * + * @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, + @ModelAttribute("preloadObj") AftersalesOrderVO aftersalesOrderVO, HttpServletRequest request) { + boolean saveEntityBoolean = BooleanUtils.toBoolean(saveEntity); + //获取实例id + String instanceId = aftersalesOrderVO.getInstanceId(); + //获取实例类型 + String instanceType = aftersalesOrderVO.getInstanceType(); + boolean approvedFlag = processService.complete(taskId, instanceId, aftersalesOrderVO.getApplyTitle(), aftersalesOrderVO.getAftersalesOrderCode(), "aftersalesOrder", new HashMap(), request); + if(!approvedFlag){ + // 审核状态-审核拒绝 + aftersalesOrderVO.setAuditStatus("2"); + } + // 如果任务已结束更新业务表状态 + boolean processIsFinish = processService.judgeProcessIsFinish(instanceId); + if (processIsFinish) { + // 审核通过 + aftersalesOrderVO.setAuditStatus("1"); + // 提交 + if("submit".equals(instanceType)){ + // 使用状态-是 +// erpBomVo.setUseStatus("1"); + } + // 作废 + else if("cancel".equals(instanceType)){ + // 使用状态-已作废 +// erpBomVo.setUseStatus("2"); + } + // 恢复 + else if("restore".equals(instanceType)){ + // 使用状态-是 +// erpBomVo.setUseStatus("1"); + } + } + aftersalesOrderService.updateAftersalesOrder(aftersalesOrderVO); + // 驳回申请后继续申请,可能修改表单 + if (saveEntityBoolean) { + aftersalesOrderService.updateAftersalesOrder(aftersalesOrderVO); + } + return success("任务已完成"); + } + + + + /** * 修改售后单 */ @@ -189,7 +295,6 @@ public class AftersalesOrderController extends BaseController /** * 查询选择设备列表 */ - @RequiresPermissions("aftersales:aftersalesOrder:list") @PostMapping("/optionDevices") @ResponseBody public TableDataInfo optionDevices(AftersalesOrder aftersalesOrder) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/domain/vo/AftersalesOrderVO.java b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/domain/vo/AftersalesOrderVO.java new file mode 100644 index 00000000..85cf7b51 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/domain/vo/AftersalesOrderVO.java @@ -0,0 +1,33 @@ +package com.ruoyi.aftersales.domain.vo; + +import com.ruoyi.aftersales.domain.AftersalesOrder; +import lombok.Data; + +import java.util.Date; + +@Data +public class AftersalesOrderVO extends AftersalesOrder { + private static final long serialVersionUID = -3627380777050403384L; + + /** 申请人姓名 */ + 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; +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AftersalesOrderMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AftersalesOrderMapper.java index 7861c76f..89cf1fd4 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AftersalesOrderMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/mapper/AftersalesOrderMapper.java @@ -2,6 +2,7 @@ package com.ruoyi.aftersales.mapper; import java.util.List; import com.ruoyi.aftersales.domain.AftersalesOrder; +import com.ruoyi.aftersales.domain.vo.AftersalesOrderVO; /** * 售后单Mapper接口 @@ -17,7 +18,7 @@ public interface AftersalesOrderMapper * @param aftersalesOrderId 售后单ID * @return 售后单 */ - public AftersalesOrder selectAftersalesOrderById(Long aftersalesOrderId); + public AftersalesOrderVO selectAftersalesOrderById(Long aftersalesOrderId); /** @@ -34,7 +35,7 @@ public interface AftersalesOrderMapper * @param aftersalesOrder 售后单 * @return 售后单集合 */ - public List selectAftersalesOrderList(AftersalesOrder aftersalesOrder); + public List selectAftersalesOrderList(AftersalesOrder aftersalesOrder); /** * 新增售后单 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/IAftersalesOrderService.java b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/IAftersalesOrderService.java index a9665d46..4756078e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/IAftersalesOrderService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/IAftersalesOrderService.java @@ -2,6 +2,9 @@ package com.ruoyi.aftersales.service; import java.util.List; import com.ruoyi.aftersales.domain.AftersalesOrder; +import com.ruoyi.aftersales.domain.vo.AftersalesOrderVO; +import com.ruoyi.system.domain.SysMakeorderPick; +import org.activiti.engine.runtime.ProcessInstance; /** * 售后单Service接口 @@ -17,7 +20,7 @@ public interface IAftersalesOrderService * @param aftersalesOrderId 售后单ID * @return 售后单 */ - public AftersalesOrder selectAftersalesOrderById(Long aftersalesOrderId); + public AftersalesOrderVO selectAftersalesOrderById(Long aftersalesOrderId); /** @@ -31,10 +34,10 @@ public interface IAftersalesOrderService /** * 查询售后单列表 * - * @param aftersalesOrder 售后单 + * @param aftersalesOrderVO 售后单 * @return 售后单集合 */ - public List selectAftersalesOrderList(AftersalesOrder aftersalesOrder); + public List selectAftersalesOrderList(AftersalesOrderVO aftersalesOrderVO); /** * 新增售后单 @@ -81,4 +84,10 @@ public interface IAftersalesOrderService * @return */ int restoreAftersalesOrderById(Long aftersalesOrderId); + + + /** + * 审批流程启动 + * */ + ProcessInstance submitApply(AftersalesOrder aftersalesOrder); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesOrderServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesOrderServiceImpl.java index 8e9fd296..a400d58a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesOrderServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/aftersales/service/impl/AftersalesOrderServiceImpl.java @@ -1,16 +1,30 @@ package com.ruoyi.aftersales.service.impl; import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Date; -import java.util.List; +import java.util.*; + +import com.github.pagehelper.Page; +import com.ruoyi.aftersales.domain.vo.AftersalesOrderVO; +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.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.SysAttach; +import com.ruoyi.system.domain.SysMakeorderPick; import com.ruoyi.system.mapper.SysAttachMapper; +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.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.aftersales.mapper.AftersalesOrderMapper; @@ -38,9 +52,28 @@ public class AftersalesOrderServiceImpl implements IAftersalesOrderService private ISysAttachFileService attachFileService; + @Autowired + private IProcessService processService; + @Autowired private SysAttachMapper sysAttachMapper; + @Autowired + private RedisCache redisCache; + + @Autowired + private ISysRoleService roleService; + + + @Autowired + private SysUserMapper userMapper; + + @Autowired + private TaskService taskService; + + @Autowired + private BizTodoItemMapper todoItemMapper; + /** * 查询售后单 * @@ -48,7 +81,7 @@ public class AftersalesOrderServiceImpl implements IAftersalesOrderService * @return 售后单 */ @Override - public AftersalesOrder selectAftersalesOrderById(Long aftersalesOrderId) + public AftersalesOrderVO selectAftersalesOrderById(Long aftersalesOrderId) { return aftersalesOrderMapper.selectAftersalesOrderById(aftersalesOrderId); } @@ -76,9 +109,60 @@ public class AftersalesOrderServiceImpl implements IAftersalesOrderService * @return 售后单 */ @Override - public List selectAftersalesOrderList(AftersalesOrder aftersalesOrder) + public List selectAftersalesOrderList(AftersalesOrderVO aftersalesOrderVO) { - return aftersalesOrderMapper.selectAftersalesOrderList(aftersalesOrder); + PageDomain pageDomain = TableSupport.buildPageRequest(); + Integer pageNum = pageDomain.getPageNum(); + Integer pageSize = pageDomain.getPageSize(); + + // PageHelper 仅对第一个 List 分页 + Page list = (Page) aftersalesOrderMapper.selectAftersalesOrderList(aftersalesOrderVO); + Page returnList = new Page<>(); + for (AftersalesOrderVO tempAftersalesOrderVO: list) { + SysUser sysUser = userMapper.selectUserByLoginName(tempAftersalesOrderVO.getCreateBy()); + if (sysUser != null) { + tempAftersalesOrderVO.setCreateUserName(sysUser.getUserName()); + } + SysUser sysUser2 = userMapper.selectUserByLoginName(tempAftersalesOrderVO.getApplyUser()); + if (sysUser2 != null) { + tempAftersalesOrderVO.setApplyUserName(sysUser2.getUserName()); + } + String instanceId = tempAftersalesOrderVO.getInstanceId(); + // 当前环节 + if (StringUtils.isNotBlank(instanceId)) { + List taskList = taskService.createTaskQuery() + .processInstanceId(instanceId) +// .singleResult(); + .list(); // 例如请假会签,会同时拥有多个任务 + if (!org.springframework.util.CollectionUtils.isEmpty(taskList)) { + TaskEntityImpl task = (TaskEntityImpl) taskList.get(0); + String taskId = task.getId(); + tempAftersalesOrderVO.setTaskId(taskId); + // 设置待办用户 + List todoUserList = todoItemMapper.selectUndealTodoUserList(taskId); + if(!org.springframework.util.CollectionUtils.isEmpty(taskList)){ + tempAftersalesOrderVO.setTodoUserId(String.join(",",todoUserList)); + } + if (task.getSuspensionState() == 2) { + tempAftersalesOrderVO.setTaskName("已挂起"); + tempAftersalesOrderVO.setSuspendState("2"); + } else { + tempAftersalesOrderVO.setTaskName(task.getName()); + tempAftersalesOrderVO.setSuspendState("1"); + } + } else { + // 已办结或者已撤销 + tempAftersalesOrderVO.setTaskName("已结束"); + } + } else { + tempAftersalesOrderVO.setTaskName("未启动"); + } + returnList.add(tempAftersalesOrderVO); + } + returnList.setTotal(org.springframework.util.CollectionUtils.isEmpty(list) ? 0 : list.getTotal()); + returnList.setPageNum(pageNum); + returnList.setPageSize(pageSize); + return returnList; } /** @@ -191,4 +275,73 @@ public class AftersalesOrderServiceImpl implements IAftersalesOrderService { return aftersalesOrderMapper.restoreAftersalesOrderById(aftersalesOrderId); } + + /** + * 审批流程启动 + * */ + @Transactional(rollbackFor = Exception.class) + @Override + public ProcessInstance submitApply(AftersalesOrder aftersalesOrder) { + + SysUser user = ShiroUtils.getSysUser(); + aftersalesOrder.setApplyUser(user.getLoginName()); + aftersalesOrder.setApplyTime(DateUtils.getNowDate()); + aftersalesOrder.setAftersalesOrderCode(redisCache.generateBillNo("SH")); + // 保存 + insertAftersalesOrder(aftersalesOrder); + // 启动流程 + String applyTitle = user.getUserName()+"发起了售后单提交审批-"+DateUtils.dateTimeNow(); + String instanceType = "submit"; + ProcessInstance processInstance = startProcessInstance(applyTitle,instanceType,aftersalesOrder, user); + String processInstanceId = processInstance.getProcessInstanceId(); + // 提交实例id + aftersalesOrder.setSubmitInstanceId(processInstanceId); + // 存在提交完就流程结束的情况 + boolean processIsFinish = processService.judgeProcessIsFinish(processInstanceId); + if(processIsFinish){ + // 审核状态-审核通过 + aftersalesOrder.setAuditStatus("1"); + } + aftersalesOrderMapper.updateAftersalesOrder(aftersalesOrder); + return processInstance; + } + + + /** + * 创建售后单审核流程 + * @param applyTitle + * @param instanceType + * @param user + * @return + */ + private ProcessInstance startProcessInstance(String applyTitle, String instanceType, AftersalesOrder aftersalesOrder, SysUser user) { + Long aftersalesOrderId = aftersalesOrder.getAftersalesOrderId(); + String businessKey = aftersalesOrderId.toString(); // 实体类 ID,作为流程的业务 key + String key = "aftersalesOrder"; + Map variables = new HashMap<>(); + // 构造authority传参 + buildAuthority(user, variables); + aftersalesOrder.setApplyTitle(applyTitle); + // 启动流程 + ProcessInstance processInstance = processService.submitApply(user.getLoginName(), businessKey, applyTitle, aftersalesOrder.getAftersalesOrderCode(), key, variables); + String processInstanceId = processInstance.getId(); + aftersalesOrder.setInstanceId(processInstanceId); // 建立双向关系 + aftersalesOrder.setInstanceType(instanceType); + return processInstance; + } + + /** + * 发起人节点判断 + * */ + private void buildAuthority(SysUser user, Map variables) { + Set roleKeys = roleService.selectRoleKeys(user.getUserId()); + // 角色不同审核人不同 + if(roleKeys.contains("ywyRole")){ + variables.put("authority",1); + }else if(roleKeys.contains("ywjlRole")){ + variables.put("authority",2); + }else if(roleKeys.contains("ywzgRole")){ + variables.put("authority",3); + } + } } diff --git a/ruoyi-admin/src/main/resources/mapper/aftersales/AfterSalesShippingDeviceMapper.xml b/ruoyi-admin/src/main/resources/mapper/aftersales/AfterSalesShippingDeviceMapper.xml index c4468920..4fc8904b 100644 --- a/ruoyi-admin/src/main/resources/mapper/aftersales/AfterSalesShippingDeviceMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/aftersales/AfterSalesShippingDeviceMapper.xml @@ -90,6 +90,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + - + insert into aftersales_order aftersales_order_code, @@ -183,7 +184,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + update aftersales_order aftersales_order_code = #{aftersalesOrderCode}, diff --git a/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/add.html b/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/add.html index 038c5b86..0383ef0d 100644 --- a/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/add.html +++ b/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/add.html @@ -8,12 +8,6 @@
-
- -
- -
-
@@ -32,24 +26,7 @@
-
- -
-
- - -
- 代码生成请选择字典属性 -
-
-
- -
- -
-
+
@@ -107,97 +84,12 @@
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- - 代码生成请选择字典属性 -
-
-
- -
- -
-
-
- -
- -
-
-
- -
-
- - -
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
diff --git a/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/aftersalesOrder.html b/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/aftersalesOrder.html index d294cf99..3161e9dc 100644 --- a/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/aftersalesOrder.html +++ b/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/aftersalesOrder.html @@ -47,21 +47,33 @@ + +
+ + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/taskYwjlVerify.html b/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/taskYwjlVerify.html new file mode 100644 index 00000000..f4347451 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/taskYwjlVerify.html @@ -0,0 +1,147 @@ + + + + + + + + +
+
+ + + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+ + + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/taskYwzgVerify.html b/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/taskYwzgVerify.html new file mode 100644 index 00000000..0c58c9a8 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/aftersales/aftersalesOrder/taskYwzgVerify.html @@ -0,0 +1,147 @@ + + + + + + + + +
+
+ + + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+ + + + + + + \ No newline at end of file