From aee8dfff0ea8242dd1da808f21c3790c78c3e1f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=99=93=E8=BF=AA?= <2596750866@qq.com> Date: Sat, 20 Jul 2024 09:46:49 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E5=A7=94=E5=A4=96=E5=8A=A0=E5=B7=A5=20?= =?UTF-8?q?=E5=A7=94=E5=A4=96=E9=A2=86=E6=96=99=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=A7=94=E5=A4=96=E9=A2=86=E6=96=99=E5=AE=9E=E4=BD=93=E7=B1=BB?= =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0=E5=AE=A1=E6=89=B9=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E5=BF=85=E9=9C=80=E5=AD=97=E6=AE=B5=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E9=A1=B5=E9=9D=A2=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=AE=A1=E6=89=B9=E7=9B=B8=E5=85=B3=E5=86=85=E5=AE=B9=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9mapper=E6=96=87=E4=BB=B6=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=AE=9E=E4=BD=93=E7=B1=BB=E5=AD=97=E6=AE=B5=EF=BC=8C=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E3=80=81=E6=8F=92=E5=85=A5=E8=AE=B0=E5=BD=95=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E6=B3=95=20=E4=BF=AE=E6=94=B9=E5=A7=94=E5=A4=96?= =?UTF-8?q?=E9=A2=86=E6=96=99=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2=E6=96=B9?= =?UTF-8?q?=E6=B3=95=20=E6=96=B0=E5=A2=9E=E5=90=AF=E5=8A=A8=E5=AE=A1?= =?UTF-8?q?=E6=89=B9=E6=B5=81=E7=A8=8B=E3=80=81=E5=8F=91=E8=B5=B7=E4=BA=BA?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E5=88=A4=E6=96=AD=E6=96=B9=E6=B3=95=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=8E=E7=AB=AF=E6=8E=A5=E5=8F=A3=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8A=A0=E8=BD=BD=E5=AE=A1=E6=89=B9=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E3=80=81=E5=AE=A1=E6=89=B9=E4=BB=BB=E5=8A=A1=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E7=9A=84=E5=A4=84=E7=90=86=E6=B5=81=E7=A8=8B=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [feat] 委外加工 委外领料 新增委外领料委外经理、委外主管审核页面 --- .../OutsourceRequisitionController.java | 130 ++++++++++- .../system/domain/OutsourceRequisition.java | 102 ++++++++- .../mapper/OutsourceRequisitionMapper.java | 27 ++- .../service/IOutsourceRequisitionService.java | 23 +- .../impl/OutsourceRequisitionServiceImpl.java | 209 +++++++++++++++--- .../system/OutsourceRequisitionMapper.xml | 55 ++++- .../outsource_requisition.html | 97 +++++++- .../outsource_requisition/taskWwjlVerify.html | 108 +++++++++ .../outsource_requisition/taskWwzgVerify.html | 108 +++++++++ 9 files changed, 783 insertions(+), 76 deletions(-) create mode 100644 ruoyi-admin/src/main/resources/templates/system/outsource_requisition/taskWwjlVerify.html create mode 100644 ruoyi-admin/src/main/resources/templates/system/outsource_requisition/taskWwzgVerify.html diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/OutsourceRequisitionController.java b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/OutsourceRequisitionController.java index ed34d8bb..b7a93b2a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/OutsourceRequisitionController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/OutsourceRequisitionController.java @@ -1,10 +1,23 @@ package com.ruoyi.system.controller; +import java.util.HashMap; import java.util.List; import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.process.general.service.IProcessService; +import com.ruoyi.system.domain.OutsourceOrder; import com.ruoyi.system.domain.OutsourceRequisition; +import com.ruoyi.system.domain.Vo.OutsourceQuoteVO; +import com.ruoyi.system.domain.Vo.OutsourceRequisitionVO; +import com.ruoyi.system.service.IOutsourceOrderService; import com.ruoyi.system.service.IOutsourceRequisitionService; +import com.ruoyi.system.service.ISysUserService; +import com.ruoyi.system.service.impl.OutsourceRequisitionServiceImpl; +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; @@ -18,6 +31,9 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + /** * 委外领料Controller * @@ -33,6 +49,22 @@ public class OutsourceRequisitionController extends BaseController @Autowired private IOutsourceRequisitionService outsourceRequisitionService; + @Autowired + private IOutsourceOrderService outsourceOrderService; + + @Autowired + private ISysUserService sysUserService; + + + @Autowired + private TaskService taskService; + + @Autowired + private RuntimeService runtimeService; + + @Autowired + private IProcessService processService; + @RequiresPermissions("system:outsource_requisition:view") @GetMapping() public String outsource_requisition() @@ -46,10 +78,10 @@ public class OutsourceRequisitionController extends BaseController @RequiresPermissions("system:outsource_requisition:list") @PostMapping("/list") @ResponseBody - public TableDataInfo list(OutsourceRequisition outsourceRequisition) + public TableDataInfo list(OutsourceRequisitionVO outsourceRequisitionVO) { startPage(); - List list = outsourceRequisitionService.selectOutsourceRequisitionList(outsourceRequisition); + List list = outsourceRequisitionService.selectOutsourceRequisitionList(outsourceRequisitionVO); return getDataTable(list); } @@ -60,10 +92,10 @@ public class OutsourceRequisitionController extends BaseController @Log(title = "委外领料", businessType = BusinessType.EXPORT) @PostMapping("/export") @ResponseBody - public AjaxResult export(OutsourceRequisition outsourceRequisition) + public AjaxResult export(OutsourceRequisitionVO outsourceRequisitionVO) { - List list = outsourceRequisitionService.selectOutsourceRequisitionList(outsourceRequisition); - ExcelUtil util = new ExcelUtil(OutsourceRequisition.class); + List list = outsourceRequisitionService.selectOutsourceRequisitionList(outsourceRequisitionVO); + ExcelUtil util = new ExcelUtil(OutsourceRequisitionVO.class); return util.exportExcel(list, "委外领料数据"); } @@ -83,12 +115,88 @@ public class OutsourceRequisitionController extends BaseController @Log(title = "委外领料", businessType = BusinessType.INSERT) @PostMapping("/addRequisition") @ResponseBody - public AjaxResult addSave(@RequestBody OutsourceRequisition outsourceRequisition) + public AjaxResult addSave(@RequestBody OutsourceRequisitionVO outsourceRequisitionVO) { - System.out.println(outsourceRequisition); - return toAjax(outsourceRequisitionService.insertOutsourceRequisition(outsourceRequisition)); + outsourceRequisitionVO.setAuditStatus("0"); + outsourceRequisitionService.submitApply(outsourceRequisitionVO); + 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(); + OutsourceRequisitionVO outsourceRequisitionVO = outsourceRequisitionService.selectOutsourceRequisitionByOutsourceRequisitionId(new Long(processInstance.getBusinessKey())); + System.out.println(outsourceRequisitionVO); + mmap.put("formData", outsourceRequisitionVO); + mmap.put("taskId", taskId); + String verifyName = task.getTaskDefinitionKey().substring(0, 1).toUpperCase() + task.getTaskDefinitionKey().substring(1); + return prefix + "/task" + verifyName; } + /** + * 自动绑定页面字段 + */ + @ModelAttribute("preloadObj") + public OutsourceRequisitionVO getObj(@RequestParam(value = "outsourceRequisitionId", required = false) Long outsourceRequisitionId, HttpSession session) { + if (outsourceRequisitionId != null) { + return outsourceRequisitionService.selectOutsourceRequisitionByOutsourceRequisitionId(outsourceRequisitionId); + } + return new OutsourceRequisitionVO(); + } + /** + * 完成任务 + * + * @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") OutsourceRequisitionVO outsourceRequisitionVO, HttpServletRequest request) { + boolean saveEntityBoolean = BooleanUtils.toBoolean(saveEntity); + //获取实例id + String instanceId = outsourceRequisitionVO.getInstanceId(); + //获取实例类型 + String instanceType = outsourceRequisitionVO.getInstanceType(); + boolean approvedFlag = processService.complete(taskId, instanceId, outsourceRequisitionVO.getApplyTitle(), outsourceRequisitionVO.getOutsourceRequisitionNo(), "outsourceRequisition", new HashMap(), request); + if(!approvedFlag){ + // 审核状态-审核拒绝 + outsourceRequisitionVO.setAuditStatus("2"); + } + // 如果任务已结束更新业务表状态 + boolean processIsFinish = processService.judgeProcessIsFinish(instanceId); + if (processIsFinish) { + // 审核通过 + outsourceRequisitionVO.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"); + } + } + outsourceRequisitionService.updateOutsourceRequisition(outsourceRequisitionVO); + // 驳回申请后继续申请,可能修改表单 + if (saveEntityBoolean) { + outsourceRequisitionService.updateOutsourceRequisition(outsourceRequisitionVO); + } + return success("任务已完成"); + } /** * 修改委外领料 @@ -98,6 +206,8 @@ public class OutsourceRequisitionController extends BaseController public String edit(@PathVariable("outsourceRequisitionId") Long outsourceRequisitionId, ModelMap mmap) { OutsourceRequisition outsourceRequisition = outsourceRequisitionService.selectOutsourceRequisitionByOutsourceRequisitionId(outsourceRequisitionId); + List outsourceOrder = outsourceOrderService.selectOutsourceOrderByOutsourceOrderNo(outsourceRequisition.getOutsourceOrderNo()); + mmap.put("outsourceOrderList",outsourceOrder); mmap.put("outsourceRequisition", outsourceRequisition); return prefix + "/edit"; } @@ -109,9 +219,9 @@ public class OutsourceRequisitionController extends BaseController @Log(title = "委外领料", businessType = BusinessType.UPDATE) @PostMapping("/edit") @ResponseBody - public AjaxResult editSave(OutsourceRequisition outsourceRequisition) + public AjaxResult editSave(OutsourceRequisitionVO outsourceRequisitionVO) { - return toAjax(outsourceRequisitionService.updateOutsourceRequisition(outsourceRequisition)); + return toAjax(outsourceRequisitionService.updateOutsourceRequisition(outsourceRequisitionVO)); } /** diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/OutsourceRequisition.java b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/OutsourceRequisition.java index ab5dd74e..0d3bde48 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/OutsourceRequisition.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/OutsourceRequisition.java @@ -1,5 +1,6 @@ package com.ruoyi.system.domain; +import java.util.Date; import java.util.List; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -47,13 +48,30 @@ public class OutsourceRequisition extends BaseEntity @Excel(name = "领料状态") private String requisitionStatus; - public String getRequisitionStatus() { - return requisitionStatus; - } + /** 流程实例ID */ + private String instanceId; + + /** 流程实例类型 */ + private String instanceType; + + /** 流程提交实例ID */ + private String submitInstanceId; + + /** 申请标题 */ + private String applyTitle; + + /** 申请时间 */ + private Date applyTime; + + /** 申请人 */ + private String applyUser; + + /** 流程作废实例ID */ + private String cancelInstanceId; + + /** 流程恢复实例ID */ + private String restoreInstanceId; - public void setRequisitionStatus(String requisitionStatus) { - this.requisitionStatus = requisitionStatus; - } /** 委外领料详情信息 */ private List outsourceRequisitionDetailList; @@ -123,6 +141,78 @@ public class OutsourceRequisition extends BaseEntity this.outsourceRequisitionDetailList = outsourceRequisitionDetailList; } + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getInstanceType() { + return instanceType; + } + + public void setInstanceType(String instanceType) { + this.instanceType = instanceType; + } + + public String getSubmitInstanceId() { + return submitInstanceId; + } + + public void setSubmitInstanceId(String submitInstanceId) { + this.submitInstanceId = submitInstanceId; + } + + public String getApplyTitle() { + return applyTitle; + } + + public void setApplyTitle(String applyTitle) { + this.applyTitle = applyTitle; + } + + public Date getApplyTime() { + return applyTime; + } + + public void setApplyTime(Date applyTime) { + this.applyTime = applyTime; + } + + public String getApplyUser() { + return applyUser; + } + + public void setApplyUser(String applyUser) { + this.applyUser = applyUser; + } + + public String getCancelInstanceId() { + return cancelInstanceId; + } + + public void setCancelInstanceId(String cancelInstanceId) { + this.cancelInstanceId = cancelInstanceId; + } + + public String getRestoreInstanceId() { + return restoreInstanceId; + } + + public void setRestoreInstanceId(String restoreInstanceId) { + this.restoreInstanceId = restoreInstanceId; + } + + public String getRequisitionStatus() { + return requisitionStatus; + } + + public void setRequisitionStatus(String requisitionStatus) { + this.requisitionStatus = requisitionStatus; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/OutsourceRequisitionMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/OutsourceRequisitionMapper.java index bb906786..130520af 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/OutsourceRequisitionMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/OutsourceRequisitionMapper.java @@ -2,6 +2,7 @@ package com.ruoyi.system.mapper; import com.ruoyi.system.domain.OutsourceRequisition; import com.ruoyi.system.domain.OutsourceRequisitionDetail; +import com.ruoyi.system.domain.Vo.OutsourceRequisitionVO; import java.util.List; @@ -20,31 +21,39 @@ public interface OutsourceRequisitionMapper * @param outsourceRequisitionId 委外领料主键 * @return 委外领料 */ - public OutsourceRequisition selectOutsourceRequisitionByOutsourceRequisitionId(Long outsourceRequisitionId); + public OutsourceRequisitionVO selectOutsourceRequisitionByOutsourceRequisitionId(Long outsourceRequisitionId); /** * 查询委外领料列表 * - * @param outsourceRequisition 委外领料 + * @param outsourceRequisitionVO 委外领料 * @return 委外领料集合 */ - public List selectOutsourceRequisitionList(OutsourceRequisition outsourceRequisition); + public List selectOutsourceRequisitionList(OutsourceRequisitionVO outsourceRequisitionVO); + + /** + * 查询委外领料详情列表 + * + * @param outsourceRequisitionNo 委外领料编号 + * @return 委外领料详情集合 + */ + public List selectOutsourceRequisitionDetailList(String outsourceRequisitionNo); /** * 新增委外领料 * - * @param outsourceRequisition 委外领料 + * @param outsourceRequisitionVO 委外领料 * @return 结果 */ - public int insertOutsourceRequisition(OutsourceRequisition outsourceRequisition); + public int insertOutsourceRequisition(OutsourceRequisitionVO outsourceRequisitionVO); /** * 修改委外领料 * - * @param outsourceRequisition 委外领料 + * @param outsourceRequisitionVO 委外领料 * @return 结果 */ - public int updateOutsourceRequisition(OutsourceRequisition outsourceRequisition); + public int updateOutsourceRequisition(OutsourceRequisitionVO outsourceRequisitionVO); /** * 删除委外领料 @@ -82,8 +91,8 @@ public interface OutsourceRequisitionMapper /** * 通过委外领料主键删除委外领料详情信息 * - * @param outsourceRequisitionId 委外领料ID + * @param outsourceRequisitionNo 委外领料ID * @return 结果 */ - public int deleteOutsourceRequisitionDetailByOutsourceRequisitionNo(Long outsourceRequisitionId); + public int deleteOutsourceRequisitionDetailByOutsourceRequisitionNo(String outsourceRequisitionNo); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/IOutsourceRequisitionService.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/IOutsourceRequisitionService.java index 036249e5..9ef29795 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/IOutsourceRequisitionService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/IOutsourceRequisitionService.java @@ -1,6 +1,9 @@ package com.ruoyi.system.service; import com.ruoyi.system.domain.OutsourceRequisition; +import com.ruoyi.system.domain.Vo.OutsourceQuoteVO; +import com.ruoyi.system.domain.Vo.OutsourceRequisitionVO; +import org.activiti.engine.runtime.ProcessInstance; import java.util.List; @@ -19,31 +22,31 @@ public interface IOutsourceRequisitionService * @param outsourceRequisitionId 委外领料主键 * @return 委外领料 */ - public OutsourceRequisition selectOutsourceRequisitionByOutsourceRequisitionId(Long outsourceRequisitionId); + public OutsourceRequisitionVO selectOutsourceRequisitionByOutsourceRequisitionId(Long outsourceRequisitionId); /** * 查询委外领料列表 * - * @param outsourceRequisition 委外领料 + * @param outsourceRequisitionVO 委外领料 * @return 委外领料集合 */ - public List selectOutsourceRequisitionList(OutsourceRequisition outsourceRequisition); + public List selectOutsourceRequisitionList(OutsourceRequisitionVO outsourceRequisitionVO); /** * 新增委外领料 * - * @param outsourceRequisition 委外领料 + * @param outsourceRequisitionVO 委外领料 * @return 结果 */ - public int insertOutsourceRequisition(OutsourceRequisition outsourceRequisition); + public int insertOutsourceRequisition(OutsourceRequisitionVO outsourceRequisitionVO); /** * 修改委外领料 * - * @param outsourceRequisition 委外领料 + * @param outsourceRequisitionVO 委外领料 * @return 结果 */ - public int updateOutsourceRequisition(OutsourceRequisition outsourceRequisition); + public int updateOutsourceRequisition(OutsourceRequisitionVO outsourceRequisitionVO); /** * 批量删除委外领料 @@ -60,4 +63,10 @@ public interface IOutsourceRequisitionService * @return 结果 */ public int deleteOutsourceRequisitionByOutsourceRequisitionId(Long outsourceRequisitionId); + + /** + * 审批流程启动 + * */ + ProcessInstance submitApply(OutsourceRequisitionVO outsourceRequisitionVO); + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/OutsourceRequisitionServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/OutsourceRequisitionServiceImpl.java index 921a431a..3e5e80ab 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/OutsourceRequisitionServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/OutsourceRequisitionServiceImpl.java @@ -1,17 +1,30 @@ package com.ruoyi.system.service.impl; -import java.util.List; +import java.util.*; +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.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; +import com.ruoyi.process.general.service.IProcessService; +import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper; import com.ruoyi.system.domain.OutsourceRequisition; import com.ruoyi.system.domain.OutsourceRequisitionDetail; +import com.ruoyi.system.domain.Vo.OutsourceQuoteVO; +import com.ruoyi.system.domain.Vo.OutsourceRequisitionVO; import com.ruoyi.system.mapper.OutsourceRequisitionMapper; +import com.ruoyi.system.mapper.SysUserMapper; import com.ruoyi.system.service.IOutsourceRequisitionService; +import org.activiti.engine.RuntimeService; +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 java.util.ArrayList; import com.ruoyi.common.utils.StringUtils; import org.springframework.transaction.annotation.Transactional; @@ -32,6 +45,24 @@ public class OutsourceRequisitionServiceImpl implements IOutsourceRequisitionSer @Autowired private RedisCache redisCache; + @Autowired + private SysRoleServiceImpl roleService; + + @Autowired + private TaskService taskService; + + @Autowired + private RuntimeService runtimeService; + + @Autowired + private BizTodoItemMapper todoItemMapper; + + @Autowired + private SysUserMapper userMapper; + + @Autowired + private IProcessService processService; + /** * 查询委外领料 * @@ -39,60 +70,119 @@ public class OutsourceRequisitionServiceImpl implements IOutsourceRequisitionSer * @return 委外领料 */ @Override - public OutsourceRequisition selectOutsourceRequisitionByOutsourceRequisitionId(Long outsourceRequisitionId) + public OutsourceRequisitionVO selectOutsourceRequisitionByOutsourceRequisitionId(Long outsourceRequisitionId) { - return outsourceRequisitionMapper.selectOutsourceRequisitionByOutsourceRequisitionId(outsourceRequisitionId); + OutsourceRequisitionVO outsourceRequisitionVO = outsourceRequisitionMapper.selectOutsourceRequisitionByOutsourceRequisitionId(outsourceRequisitionId); + if(outsourceRequisitionMapper.selectOutsourceRequisitionDetailList(outsourceRequisitionVO.getOutsourceRequisitionNo())!=null){ + List details = outsourceRequisitionMapper.selectOutsourceRequisitionDetailList(outsourceRequisitionVO.getOutsourceRequisitionNo()); + outsourceRequisitionVO.setOutsourceRequisitionDetailList(details); + } + return outsourceRequisitionVO; } /** * 查询委外领料列表 * - * @param outsourceRequisition 委外领料 + * @param outsourceRequisitionVO 委外领料 * @return 委外领料 */ @Override - public List selectOutsourceRequisitionList(OutsourceRequisition outsourceRequisition) + public List selectOutsourceRequisitionList(OutsourceRequisitionVO outsourceRequisitionVO) { - return outsourceRequisitionMapper.selectOutsourceRequisitionList(outsourceRequisition); + PageDomain pageDomain = TableSupport.buildPageRequest(); + Integer pageNum = pageDomain.getPageNum(); + Integer pageSize = pageDomain.getPageSize(); + + // PageHelper 仅对第一个 List 分页 + Page list = (Page) outsourceRequisitionMapper.selectOutsourceRequisitionList(outsourceRequisitionVO); + Page returnList = new Page<>(); + for (OutsourceRequisitionVO tempOutsourceRequisitionVO: list) { + SysUser sysUser = userMapper.selectUserByLoginName(tempOutsourceRequisitionVO.getCreateBy()); + if (sysUser != null) { + tempOutsourceRequisitionVO.setCreateUserName(sysUser.getUserName()); + } + SysUser sysUser2 = userMapper.selectUserByLoginName(tempOutsourceRequisitionVO.getApplyUser()); + if (sysUser2 != null) { + tempOutsourceRequisitionVO.setApplyUserName(sysUser2.getUserName()); + } + String instanceId = tempOutsourceRequisitionVO.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(); + tempOutsourceRequisitionVO.setTaskId(taskId); + // 设置待办用户 + List todoUserList = todoItemMapper.selectUndealTodoUserList(taskId); + if(!org.springframework.util.CollectionUtils.isEmpty(taskList)){ + tempOutsourceRequisitionVO.setTodoUserId(String.join(",",todoUserList)); + } + if (task.getSuspensionState() == 2) { + tempOutsourceRequisitionVO.setTaskName("已挂起"); + tempOutsourceRequisitionVO.setSuspendState("2"); + } else { + tempOutsourceRequisitionVO.setTaskName(task.getName()); + tempOutsourceRequisitionVO.setSuspendState("1"); + } + } else { + // 已办结或者已撤销 + tempOutsourceRequisitionVO.setTaskName("已结束"); + } + } else { + tempOutsourceRequisitionVO.setTaskName("未启动"); + } + returnList.add(tempOutsourceRequisitionVO); + } + returnList.setTotal(org.springframework.util.CollectionUtils.isEmpty(list) ? 0 : list.getTotal()); + returnList.setPageNum(pageNum); + returnList.setPageSize(pageSize); + return returnList; } /** * 新增委外领料 * - * @param outsourceRequisition 委外领料 + * @param outsourceRequisitionVO 委外领料 * @return 结果 */ @Transactional @Override - public int insertOutsourceRequisition(OutsourceRequisition outsourceRequisition) + public int insertOutsourceRequisition(OutsourceRequisitionVO outsourceRequisitionVO) { String loginName = ShiroUtils.getLoginName(); - outsourceRequisition.setCreateBy(loginName); - outsourceRequisition.setCreateTime(DateUtils.getNowDate()); - outsourceRequisition.setAuditStatus("0"); - outsourceRequisition.setRequisitionStatus("0"); + outsourceRequisitionVO.setCreateBy(loginName); + outsourceRequisitionVO.setCreateTime(DateUtils.getNowDate()); + outsourceRequisitionVO.setAuditStatus("0"); + outsourceRequisitionVO.setRequisitionStatus("0"); String outsourceRequisitionNo = redisCache.generateBillNo("WWLL"); - outsourceRequisition.setRequisitionPerson(loginName); - outsourceRequisition.setOutsourceRequisitionNo(outsourceRequisitionNo); - int rows = outsourceRequisitionMapper.insertOutsourceRequisition(outsourceRequisition); - insertOutsourceRequisitionDetail(outsourceRequisition); + outsourceRequisitionVO.setRequisitionPerson(loginName); + outsourceRequisitionVO.setOutsourceRequisitionNo(outsourceRequisitionNo); + int rows = outsourceRequisitionMapper.insertOutsourceRequisition(outsourceRequisitionVO); + insertOutsourceRequisitionDetail(outsourceRequisitionVO); return rows; } /** * 修改委外领料 * - * @param outsourceRequisition 委外领料 + * @param outsourceRequisitionVO 委外领料 * @return 结果 */ @Transactional @Override - public int updateOutsourceRequisition(OutsourceRequisition outsourceRequisition) + public int updateOutsourceRequisition(OutsourceRequisitionVO outsourceRequisitionVO) { - outsourceRequisition.setUpdateTime(DateUtils.getNowDate()); - outsourceRequisitionMapper.deleteOutsourceRequisitionDetailByOutsourceRequisitionNo(outsourceRequisition.getOutsourceRequisitionId()); - insertOutsourceRequisitionDetail(outsourceRequisition); - return outsourceRequisitionMapper.updateOutsourceRequisition(outsourceRequisition); + outsourceRequisitionVO.setUpdateTime(DateUtils.getNowDate()); + String loginName = ShiroUtils.getLoginName(); + outsourceRequisitionVO.setUpdateBy(loginName); + int rows = outsourceRequisitionMapper.updateOutsourceRequisition(outsourceRequisitionVO); + outsourceRequisitionMapper.deleteOutsourceRequisitionDetailByOutsourceRequisitionNo(outsourceRequisitionVO.getOutsourceRequisitionNo()); + insertOutsourceRequisitionDetail(outsourceRequisitionVO); + return rows; } /** @@ -119,19 +209,82 @@ public class OutsourceRequisitionServiceImpl implements IOutsourceRequisitionSer @Override public int deleteOutsourceRequisitionByOutsourceRequisitionId(Long outsourceRequisitionId) { - outsourceRequisitionMapper.deleteOutsourceRequisitionDetailByOutsourceRequisitionNo(outsourceRequisitionId); + OutsourceRequisitionVO requisitionVO = selectOutsourceRequisitionByOutsourceRequisitionId(outsourceRequisitionId); + outsourceRequisitionMapper.deleteOutsourceRequisitionDetailByOutsourceRequisitionNo(requisitionVO.getOutsourceRequisitionNo()); return outsourceRequisitionMapper.deleteOutsourceRequisitionByOutsourceRequisitionId(outsourceRequisitionId); } + @Override + public ProcessInstance submitApply(OutsourceRequisitionVO outsourceRequisitionVO) { + SysUser user = ShiroUtils.getSysUser(); + outsourceRequisitionVO.setApplyUser(user.getLoginName()); + outsourceRequisitionVO.setApplyTime(DateUtils.getNowDate()); + // 保存 + insertOutsourceRequisition(outsourceRequisitionVO); + // 启动流程 + String applyTitle = user.getUserName()+"发起了委外报价提交审批-"+DateUtils.dateTimeNow(); + String instanceType = "submit"; + ProcessInstance processInstance = startProcessInstance(applyTitle,instanceType,outsourceRequisitionVO, user); + String processInstanceId = processInstance.getProcessInstanceId(); + // 提交实例id + outsourceRequisitionVO.setSubmitInstanceId(processInstanceId); + // 存在提交完就流程结束的情况 + boolean processIsFinish = processService.judgeProcessIsFinish(processInstanceId); + if(processIsFinish){ + // 审核状态-审核通过 + outsourceRequisitionVO.setAuditStatus("1"); + } + outsourceRequisitionMapper.updateOutsourceRequisition(outsourceRequisitionVO); + return processInstance; + } + + /** + * 创建委外领料审核流程 + * @param applyTitle + * @param instanceType + * @param user + * @return + */ + private ProcessInstance startProcessInstance(String applyTitle, String instanceType, OutsourceRequisitionVO outsourceRequisitionVO, SysUser user) { + Long outsourceRequisitionId = outsourceRequisitionVO.getOutsourceRequisitionId(); + String businessKey = outsourceRequisitionId.toString(); // 实体类 ID,作为流程的业务 key + String key = "outsourceRequisition"; + Map variables = new HashMap<>(); + // 构造authority传参 + buildAuthority(user, variables); + outsourceRequisitionVO.setApplyTitle(applyTitle); + // 启动流程 + ProcessInstance processInstance = processService.submitApply(user.getLoginName(), businessKey, applyTitle, outsourceRequisitionVO.getOutsourceRequisitionNo(), key, variables); + String processInstanceId = processInstance.getId(); + outsourceRequisitionVO.setInstanceId(processInstanceId); // 建立双向关系 + outsourceRequisitionVO.setInstanceType(instanceType); + return processInstance; + } + + /** + * 发起人节点判断 + * */ + private void buildAuthority(SysUser user, Map variables) { + Set roleKeys = roleService.selectRoleKeys(user.getUserId()); + // 角色不同审核人不同 + if(roleKeys.contains("wwyRole")){ + variables.put("authority",1); + }else if(roleKeys.contains("wwjlRole")){ + variables.put("authority",2); + }else if(roleKeys.contains("wwzgRole")){ + variables.put("authority",3); + } + } + /** * 新增委外领料详情信息 * - * @param outsourceRequisition 委外领料对象 + * @param outsourceRequisitionVO 委外领料对象 */ - public void insertOutsourceRequisitionDetail(OutsourceRequisition outsourceRequisition) + public void insertOutsourceRequisitionDetail(OutsourceRequisitionVO outsourceRequisitionVO) { - List outsourceRequisitionDetailList = outsourceRequisition.getOutsourceRequisitionDetailList(); - String outsourceRequisitionNo = outsourceRequisition.getOutsourceRequisitionNo(); + List outsourceRequisitionDetailList = outsourceRequisitionVO.getOutsourceRequisitionDetailList(); + String outsourceRequisitionNo = outsourceRequisitionVO.getOutsourceRequisitionNo(); if (StringUtils.isNotNull(outsourceRequisitionDetailList)) { List list = new ArrayList(); diff --git a/ruoyi-admin/src/main/resources/mapper/system/OutsourceRequisitionMapper.xml b/ruoyi-admin/src/main/resources/mapper/system/OutsourceRequisitionMapper.xml index e6c17f67..fc6a7235 100644 --- a/ruoyi-admin/src/main/resources/mapper/system/OutsourceRequisitionMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/system/OutsourceRequisitionMapper.xml @@ -4,7 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -17,9 +17,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + + + - + @@ -32,10 +42,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select outsource_requisition_id, outsource_requisition_no, outsource_order_no, requisition_person, create_by, create_time, update_by, update_time, material_amount, total_amount, audit_status,requisition_status from outsource_requisition + select outsource_requisition_id, outsource_requisition_no, outsource_order_no, requisition_person, create_by, create_time, update_by, update_time, material_amount, total_amount, audit_status,requisition_status,instance_id, instance_type, submit_instance_id, apply_title, apply_time, apply_user, cancel_instance_id, restore_instance_id from outsource_requisition - and outsource_requisition_no = #{outsourceRequisitionNo} @@ -46,18 +56,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select outsource_requisition_detail_id, outsource_requisition_no, material_no, taken_material, taking_material from outsource_requisition_detail where outsource_requisition_no = #{outsource_requisition_no} - + insert into outsource_requisition outsource_requisition_no, @@ -71,6 +80,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" total_amount, audit_status, requisition_status, + instance_id, + instance_type, + submit_instance_id, + apply_title, + apply_time, + apply_user, + cancel_instance_id, + restore_instance_id, #{outsourceRequisitionNo}, @@ -84,10 +101,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{totalAmount}, #{auditStatus}, #{requisitionStatus}, + #{instanceId}, + #{instanceType}, + #{submitInstanceId}, + #{applyTitle}, + #{applyTime}, + #{applyUser}, + #{cancelInstanceId}, + #{restoreInstanceId}, - + update outsource_requisition outsource_requisition_no = #{outsourceRequisitionNo}, @@ -100,7 +125,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" material_amount = #{materialAmount}, total_amount = #{totalAmount}, audit_status = #{auditStatus}, - requsition_status = #{requisitionStatus}, + requisition_status = #{requisitionStatus}, + instance_id = #{instanceId}, + instance_type = #{instanceType}, + submit_instance_id = #{submitInstanceId}, + apply_title = #{applyTitle}, + apply_time = #{applyTime}, + apply_user = #{applyUser}, + cancel_instance_id = #{cancelInstanceId}, + restore_instance_id = #{restoreInstanceId}, where outsource_requisition_id = #{outsourceRequisitionId} @@ -123,7 +156,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + delete from outsource_requisition_detail where outsource_requisition_no = #{outsourceRequisitionNo} diff --git a/ruoyi-admin/src/main/resources/templates/system/outsource_requisition/outsource_requisition.html b/ruoyi-admin/src/main/resources/templates/system/outsource_requisition/outsource_requisition.html index ff193dee..ea80d847 100644 --- a/ruoyi-admin/src/main/resources/templates/system/outsource_requisition/outsource_requisition.html +++ b/ruoyi-admin/src/main/resources/templates/system/outsource_requisition/outsource_requisition.html @@ -46,12 +46,15 @@ + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/outsource_requisition/taskWwzgVerify.html b/ruoyi-admin/src/main/resources/templates/system/outsource_requisition/taskWwzgVerify.html new file mode 100644 index 00000000..aa5331f6 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/system/outsource_requisition/taskWwzgVerify.html @@ -0,0 +1,108 @@ + + + + + + + + +
+
+ + + + + + +
+ +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+
+ + + + + + + \ No newline at end of file