diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/OutsourceQuoteController.java b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/OutsourceQuoteController.java index 7892798b..13b0722c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/OutsourceQuoteController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/OutsourceQuoteController.java @@ -1,14 +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.OutsourceQuote; import com.ruoyi.system.domain.OutsourceQuoteChild; import com.ruoyi.system.domain.Vo.OutsourceQuoteVO; import com.ruoyi.system.service.IOutsourceProcessService; import com.ruoyi.system.service.IOutsourceQuoteService; +import com.ruoyi.system.service.ISysUserService; +import com.ruoyi.system.service.impl.OutsourceQuoteServiceImpl; +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; @@ -20,6 +29,9 @@ import com.ruoyi.common.core.controller.BaseController; 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 * @@ -38,6 +50,19 @@ public class OutsourceQuoteController extends BaseController @Autowired private IOutsourceProcessService outsourceProcessService; + @Autowired + private ISysUserService sysUserService; + + + @Autowired + private TaskService taskService; + + @Autowired + private RuntimeService runtimeService; + + @Autowired + private IProcessService processService; + @RequiresPermissions("system:outsource_quote:view") @GetMapping() public String outsource_quote() @@ -51,10 +76,10 @@ public class OutsourceQuoteController extends BaseController @RequiresPermissions("system:outsource_quote:list") @PostMapping("/list") @ResponseBody - public TableDataInfo list(OutsourceQuote outsourceQuote) + public TableDataInfo list(OutsourceQuoteVO outsourceQuoteVo) { startPage(); - List list = outsourceQuoteService.selectOutsourceQuoteList(outsourceQuote); + List list = outsourceQuoteService.selectOutsourceQuoteList(outsourceQuoteVo); return getDataTable(list); } @@ -65,10 +90,10 @@ public class OutsourceQuoteController extends BaseController @Log(title = "委外报价", businessType = BusinessType.EXPORT) @PostMapping("/export") @ResponseBody - public AjaxResult export(OutsourceQuote outsourceQuote) + public AjaxResult export(OutsourceQuoteVO outsourceQuoteVo) { - List list = outsourceQuoteService.selectOutsourceQuoteList(outsourceQuote); - ExcelUtil util = new ExcelUtil(OutsourceQuote.class); + List list = outsourceQuoteService.selectOutsourceQuoteList(outsourceQuoteVo); + ExcelUtil util = new ExcelUtil(OutsourceQuoteVO.class); return util.exportExcel(list, "委外报价数据"); } /** @@ -76,7 +101,7 @@ public class OutsourceQuoteController extends BaseController */ @RequiresPermissions("system:outsource_quote:detail") @GetMapping("/detail/{outsourceQuoteId}") - public String detail(@PathVariable("outsourceQuoteId") int outsourceQuoteId, ModelMap mmap) + public String detail(@PathVariable("outsourceQuoteId") Long outsourceQuoteId, ModelMap mmap) { mmap.put("outsourceQuote", outsourceQuoteService.selectOutsourceQuoteByOutsourceQuoteId(outsourceQuoteId)); @@ -106,21 +131,100 @@ public class OutsourceQuoteController extends BaseController @Log(title = "委外报价", businessType = BusinessType.INSERT) @PostMapping("/add") @ResponseBody - public AjaxResult addSave(@RequestBody OutsourceQuoteVO childVO) + public AjaxResult addSave(@RequestBody OutsourceQuoteVO outsourceQuoteVO) { - System.out.println(childVO); - return toAjax(outsourceQuoteService.insertOutsourceQuote(childVO)); +// System.out.println(outsourceQuoteVO); + // 审核状态-待审核 + outsourceQuoteVO.setAuditStatus("0"); + outsourceQuoteService.submitApply(outsourceQuoteVO); + 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(); + OutsourceQuoteVO outsourceQuoteVO = outsourceQuoteService.selectOutsourceQuoteByOutsourceQuoteId(new Long(processInstance.getBusinessKey())); + System.out.println(outsourceQuoteVO); + mmap.put("formData", outsourceQuoteVO); + mmap.put("taskId", taskId); + String verifyName = task.getTaskDefinitionKey().substring(0, 1).toUpperCase() + task.getTaskDefinitionKey().substring(1); + return prefix + "/task" + verifyName; + } + /** + * 自动绑定页面字段 + */ + @ModelAttribute("preloadObj") + public OutsourceQuoteVO getObj(@RequestParam(value = "outsourceQuoteId", required = false) Long outsourceQuoteId, HttpSession session) { + if (outsourceQuoteId != null) { + + return outsourceQuoteService.selectOutsourceQuoteByOutsourceQuoteId(outsourceQuoteId); + } + return new OutsourceQuoteVO(); + } + /** + * 完成任务 + * + * @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") OutsourceQuoteVO outsourceQuoteVO, HttpServletRequest request) { + boolean saveEntityBoolean = BooleanUtils.toBoolean(saveEntity); + //获取实例id + String instanceId = outsourceQuoteVO.getInstanceId(); + //获取实例类型 + String instanceType = outsourceQuoteVO.getInstanceType(); + boolean approvedFlag = processService.complete(taskId, instanceId, outsourceQuoteVO.getApplyTitle(), outsourceQuoteVO.getOutsourceQuoteCode(), "outsourceQuote", new HashMap(), request); + if(!approvedFlag){ + // 审核状态-审核拒绝 + outsourceQuoteVO.setAuditStatus("2"); + } + // 如果任务已结束更新业务表状态 + boolean processIsFinish = processService.judgeProcessIsFinish(instanceId); + if (processIsFinish) { + // 审核通过 + outsourceQuoteVO.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"); + } + } + outsourceQuoteService.updateOutsourceQuote(outsourceQuoteVO); + // 驳回申请后继续申请,可能修改表单 + if (saveEntityBoolean) { + outsourceQuoteService.updateOutsourceQuote(outsourceQuoteVO); + } + return success("任务已完成"); } /** * 修改委外报价 */ @RequiresPermissions("system:outsource_quote:edit") @GetMapping("/edit/{outsourceQuoteId}") - public String edit(@PathVariable("outsourceQuoteId") Integer outsourceQuoteId, ModelMap mmap) + public String edit(@PathVariable("outsourceQuoteId") Long outsourceQuoteId, ModelMap mmap) { - OutsourceQuote outsourceQuote = outsourceQuoteService.selectOutsourceQuoteByOutsourceQuoteId(outsourceQuoteId); - System.out.println(outsourceQuote.toString()); - mmap.put("outsourceQuote", outsourceQuote); + OutsourceQuoteVO outsourceQuoteVO = outsourceQuoteService.selectOutsourceQuoteByOutsourceQuoteId(outsourceQuoteId); + System.out.println(outsourceQuoteVO.toString()); + mmap.put("outsourceQuote", outsourceQuoteVO); return prefix + "/edit"; } @@ -131,17 +235,17 @@ public class OutsourceQuoteController extends BaseController @Log(title = "委外报价", businessType = BusinessType.UPDATE) @PostMapping("/edit") @ResponseBody - public AjaxResult editSave(@RequestBody OutsourceQuote outsourceQuote) + public AjaxResult editSave(@RequestBody OutsourceQuoteVO outsourceQuoteVO) { - List children = outsourceQuote.getOutsourceQuoteChildList(); + List children = outsourceQuoteVO.getOutsourceQuoteChildList(); for (OutsourceQuoteChild child:children) { - child.setOutsourceQuoteCode(outsourceQuote.getOutsourceQuoteCode()); - child.setSupplierCode(outsourceQuote.getSupplierQuoteCode()); - child.setSupplierName(outsourceQuote.getSupplierName()); - child.setTaxRate(outsourceQuote.getTaxRate()); + child.setOutsourceQuoteCode(outsourceQuoteVO.getOutsourceQuoteCode()); + child.setSupplierCode(outsourceQuoteVO.getSupplierQuoteCode()); + child.setSupplierName(outsourceQuoteVO.getSupplierName()); + child.setTaxRate(outsourceQuoteVO.getTaxRate()); } // System.out.println(children); - return toAjax(outsourceQuoteService.updateOutsourceQuote(outsourceQuote)); + return toAjax(outsourceQuoteService.updateOutsourceQuote(outsourceQuoteVO)); } /** @@ -151,9 +255,9 @@ public class OutsourceQuoteController extends BaseController @Log(title = "委外报价", businessType = BusinessType.DELETE) @PostMapping( "/remove") @ResponseBody - public AjaxResult remove(String ids) + public AjaxResult remove(Long id) { - return toAjax(outsourceQuoteService.deleteOutsourceQuoteByOutsourceQuoteIds(ids)); + return toAjax(outsourceQuoteService.deleteOutsourceQuoteByOutsourceQuoteId(id)); } @@ -168,4 +272,27 @@ public class OutsourceQuoteController extends BaseController String result = outsourceQuoteService.generateOutsourceQuoteCode(); return result; } + + /** + * 作废委外报价单 + */ + @RequiresPermissions("system:outsource_quote:cancel") + @Log(title = "委外报价单", businessType = BusinessType.CANCEL) + @GetMapping( "/cancel/{id}") + @ResponseBody + public AjaxResult cancel(@PathVariable("id") Long id){ + return toAjax(outsourceQuoteService.cancelOutsourceQuoteById(id)); + } + + /** + * 恢复委外报价单 + */ +// @RequiresPermissions("system:outsource_quote:restore") +// @Log(title = "委外报价单", businessType = BusinessType.RESTORE) +// @GetMapping( "/restore/{id}") +// @ResponseBody +// public AjaxResult restore(@PathVariable("id")Long id) +// { +// return toAjax(outsourceQuoteService.restoreOutsourceQuoteById(id)); +// } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/OutsourceQuote.java b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/OutsourceQuote.java index 8d4d4b37..ab9cc842 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/OutsourceQuote.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/OutsourceQuote.java @@ -19,7 +19,7 @@ public class OutsourceQuote extends BaseEntity private static final long serialVersionUID = 1L; /** 委外报价ID */ - private Integer outsourceQuoteId; + private Long outsourceQuoteId; /** 委外报价单号 */ @Excel(name = "委外报价单号") @@ -49,16 +49,103 @@ public class OutsourceQuote extends BaseEntity @Excel(name = "审核状态") private String auditStatus; + /** 流程实例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; /** 委外报价工序信息信息 */ private List outsourceQuoteChildList; - public void setOutsourceQuoteId(Integer outsourceQuoteId) + public void setOutsourceQuoteId(Long outsourceQuoteId) { this.outsourceQuoteId = outsourceQuoteId; } - public Integer getOutsourceQuoteId() + 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 Long getOutsourceQuoteId() { return outsourceQuoteId; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/OutsourceQuoteVO.java b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/OutsourceQuoteVO.java index 1dea845c..0a48a844 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/OutsourceQuoteVO.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/OutsourceQuoteVO.java @@ -1,115 +1,36 @@ package com.ruoyi.system.domain.Vo; import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.system.domain.OutsourceQuote; import com.ruoyi.system.domain.OutsourceQuoteChild; +import lombok.Data; import java.math.BigDecimal; import java.util.Date; import java.util.List; -public class OutsourceQuoteVO extends BaseEntity { - - /** 委外报价单号 */ - private String outsourceQuoteCode; - - /** 供应商编号 */ - private String supplierQuoteCode; - - /** 供应商名称 */ - private String supplierName; - - /** 工序合计 */ - private String processAmount; - - /** 税率 */ - private BigDecimal taxRate; - - /** 定价日期 */ - private Date pricingDate; - - /** 审核状态 */ - private String auditStatus; - - - /** 委外报价工序信息 */ - private List outsourceQuoteChildList; - - - public String getOutsourceQuoteCode() { - return outsourceQuoteCode; - } - - public void setOutsourceQuoteCode(String outsourceQuoteCode) { - this.outsourceQuoteCode = outsourceQuoteCode; - } - - public String getSupplierQuoteCode() { - return supplierQuoteCode; - } - - public void setSupplierQuoteCode(String supplierQuoteCode) { - this.supplierQuoteCode = supplierQuoteCode; - } - - public String getSupplierName() { - return supplierName; - } - - public void setSupplierName(String supplierName) { - this.supplierName = supplierName; - } - - public String getProcessAmount() { - return processAmount; - } - - public void setProcessAmount(String processAmount) { - this.processAmount = processAmount; - } - - public BigDecimal getTaxRate() { - return taxRate; - } - - public void setTaxRate(BigDecimal taxRate) { - this.taxRate = taxRate; - } - - public Date getPricingDate() { - return pricingDate; - } - - public void setPricingDate(Date pricingDate) { - this.pricingDate = pricingDate; - } - - public String getAuditStatus() { - return auditStatus; - } - - public void setAuditStatus(String auditStatus) { - this.auditStatus = auditStatus; - } - - public List getOutsourceQuoteChildList() { - return outsourceQuoteChildList; - } - - public void setOutsourceQuoteChildList(List outsourceQuoteChildList) { - this.outsourceQuoteChildList = outsourceQuoteChildList; - } - - @Override - public String toString() { - return "OutsourceQuoteChildVO{" + - "outsourceQuoteCode='" + outsourceQuoteCode + '\'' + - ", supplierQuoteCode='" + supplierQuoteCode + '\'' + - ", supplierName='" + supplierName + '\'' + - ", processAmount='" + processAmount + '\'' + - ", taxRate=" + taxRate + - ", pricingDate='" + pricingDate + '\'' + - ", auditStatus='" + auditStatus + '\'' + - ", outsourceQuoteChildList=" + outsourceQuoteChildList + - '}'; - } +@Data +public class OutsourceQuoteVO extends OutsourceQuote { + + /** 申请人姓名 */ + 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/system/domain/Vo/OutsourceRequisitionVO.java b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/OutsourceRequisitionVO.java new file mode 100644 index 00000000..fd94fd6a --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/Vo/OutsourceRequisitionVO.java @@ -0,0 +1,32 @@ +package com.ruoyi.system.domain.Vo; + +import com.ruoyi.system.domain.OutsourceRequisition; +import lombok.Data; + +import java.util.Date; + +@Data +public class OutsourceRequisitionVO extends OutsourceRequisition { + + /** 申请人姓名 */ + 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/system/mapper/OutsourceQuoteMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/OutsourceQuoteMapper.java index 6a198b65..0eaaf766 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/OutsourceQuoteMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/OutsourceQuoteMapper.java @@ -2,6 +2,7 @@ package com.ruoyi.system.mapper; import com.ruoyi.system.domain.OutsourceQuote; import com.ruoyi.system.domain.OutsourceQuoteChild; +import com.ruoyi.system.domain.Vo.OutsourceQuoteVO; import java.util.List; @@ -20,15 +21,15 @@ public interface OutsourceQuoteMapper * @param outsourceQuoteId 委外报价主键 * @return 委外报价 */ - public OutsourceQuote selectOutsourceQuoteByOutsourceQuoteId(Integer outsourceQuoteId); + public OutsourceQuoteVO selectOutsourceQuoteByOutsourceQuoteId(Long outsourceQuoteId); /** * 查询委外报价列表 * - * @param outsourceQuote 委外报价 + * @param outsourceQuoteVO 委外报价 * @return 委外报价集合 */ - public List selectOutsourceQuoteList(OutsourceQuote outsourceQuote); + public List selectOutsourceQuoteList(OutsourceQuoteVO outsourceQuoteVO); /** * 查询委外报价工序信息列表 * @@ -40,10 +41,10 @@ public interface OutsourceQuoteMapper /** * 新增委外报价 * - * @param outsourceQuote 委外报价 + * @param outsourceQuoteVO 委外报价 * @return 结果 */ - public int insertOutsourceQuote(OutsourceQuote outsourceQuote); + public int insertOutsourceQuote(OutsourceQuoteVO outsourceQuoteVO); /** * 修改委外报价 @@ -59,7 +60,7 @@ public interface OutsourceQuoteMapper * @param outsourceQuoteId 委外报价主键 * @return 结果 */ - public int deleteOutsourceQuoteByOutsourceQuoteId(Integer outsourceQuoteId); + public int deleteOutsourceQuoteByOutsourceQuoteId(Long outsourceQuoteId); /** * 批量删除委外报价 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/IOutsourceQuoteService.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/IOutsourceQuoteService.java index 6072159c..b52c9b74 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/IOutsourceQuoteService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/IOutsourceQuoteService.java @@ -1,7 +1,9 @@ package com.ruoyi.system.service; +import com.ruoyi.aftersales.domain.AftersalesOrder; import com.ruoyi.system.domain.OutsourceQuote; import com.ruoyi.system.domain.Vo.OutsourceQuoteVO; +import org.activiti.engine.runtime.ProcessInstance; import java.util.List; @@ -20,15 +22,15 @@ public interface IOutsourceQuoteService * @param outsourceQuoteId 委外报价主键 * @return 委外报价 */ - public OutsourceQuote selectOutsourceQuoteByOutsourceQuoteId(Integer outsourceQuoteId); + public OutsourceQuoteVO selectOutsourceQuoteByOutsourceQuoteId(Long outsourceQuoteId); /** * 查询委外报价列表 * - * @param outsourceQuote 委外报价 + * @param outsourceQuoteVO 委外报价 * @return 委外报价集合 */ - public List selectOutsourceQuoteList(OutsourceQuote outsourceQuote); + public List selectOutsourceQuoteList(OutsourceQuoteVO outsourceQuoteVO); /** * 新增委外报价 @@ -41,18 +43,10 @@ public interface IOutsourceQuoteService /** * 修改委外报价 * - * @param outsourceQuote 委外报价 + * @param outsourceQuoteVO 委外报价 * @return 结果 */ - public int updateOutsourceQuote(OutsourceQuote outsourceQuote); - - /** - * 批量删除委外报价 - * - * @param outsourceQuoteIds 需要删除的委外报价主键集合 - * @return 结果 - */ - public int deleteOutsourceQuoteByOutsourceQuoteIds(String outsourceQuoteIds); + public int updateOutsourceQuote(OutsourceQuoteVO outsourceQuoteVO); /** * 删除委外报价信息 @@ -60,18 +54,27 @@ public interface IOutsourceQuoteService * @param outsourceQuoteId 委外报价主键 * @return 结果 */ - public int deleteOutsourceQuoteByOutsourceQuoteId(Integer outsourceQuoteId); + public int deleteOutsourceQuoteByOutsourceQuoteId(Long outsourceQuoteId); /** * 新增委外报价工序信息信息 * - * @param outsourceQuote 委外报价对象 + * @param outsourceQuoteVO 委外报价对象 */ - public void insertOutsourceQuoteChild(OutsourceQuote outsourceQuote); + public void insertOutsourceQuoteChild(OutsourceQuoteVO outsourceQuoteVO); /** * 自动生成委外报价编号 * */ String generateOutsourceQuoteCode(); + /** + * 审批流程启动 + * */ + ProcessInstance submitApply(OutsourceQuoteVO outsourceQuoteVO); + + /** + * 作废委外报价单 + * */ + int cancelOutsourceQuoteById(Long id); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/OutsourceQuoteServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/OutsourceQuoteServiceImpl.java index d85da58e..5d74ee4c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/OutsourceQuoteServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/OutsourceQuoteServiceImpl.java @@ -1,22 +1,36 @@ package com.ruoyi.system.service.impl; +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.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.OutsourceQuote; import com.ruoyi.system.domain.OutsourceQuoteChild; import com.ruoyi.system.domain.Vo.OutsourceQuoteVO; import com.ruoyi.system.mapper.OutsourceQuoteMapper; +import com.ruoyi.system.mapper.SysUserMapper; import com.ruoyi.system.service.IOutsourceQuoteService; +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 com.ruoyi.common.utils.StringUtils; import org.springframework.transaction.annotation.Transactional; -import com.ruoyi.common.core.text.Convert; - /** * 委外报价Service业务层处理 * @@ -32,6 +46,23 @@ public class OutsourceQuoteServiceImpl implements IOutsourceQuoteService @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,24 +70,75 @@ public class OutsourceQuoteServiceImpl implements IOutsourceQuoteService * @return 委外报价 */ @Override - public OutsourceQuote selectOutsourceQuoteByOutsourceQuoteId(Integer outsourceQuoteId) + public OutsourceQuoteVO selectOutsourceQuoteByOutsourceQuoteId(Long outsourceQuoteId) { - OutsourceQuote outsourceQuote = outsourceQuoteMapper.selectOutsourceQuoteByOutsourceQuoteId(outsourceQuoteId); - List children = outsourceQuoteMapper.selectOutsourceQuoteChildList(outsourceQuote.getOutsourceQuoteCode()); - outsourceQuote.setOutsourceQuoteChildList(children); - return outsourceQuote; + OutsourceQuoteVO outsourceQuoteVO = outsourceQuoteMapper.selectOutsourceQuoteByOutsourceQuoteId(outsourceQuoteId); + List children = outsourceQuoteMapper.selectOutsourceQuoteChildList(outsourceQuoteVO.getOutsourceQuoteCode()); + outsourceQuoteVO.setOutsourceQuoteChildList(children); + return outsourceQuoteVO; } /** * 查询委外报价列表 * - * @param outsourceQuote 委外报价 + * @param outsourceQuoteVO 委外报价 * @return 委外报价 */ @Override - public List selectOutsourceQuoteList(OutsourceQuote outsourceQuote) + public List selectOutsourceQuoteList(OutsourceQuoteVO outsourceQuoteVO) { - return outsourceQuoteMapper.selectOutsourceQuoteList(outsourceQuote); + PageDomain pageDomain = TableSupport.buildPageRequest(); + Integer pageNum = pageDomain.getPageNum(); + Integer pageSize = pageDomain.getPageSize(); + + // PageHelper 仅对第一个 List 分页 + Page list = (Page) outsourceQuoteMapper.selectOutsourceQuoteList(outsourceQuoteVO); + Page returnList = new Page<>(); + for (OutsourceQuoteVO tempOutsourceQuoteVO: list) { + SysUser sysUser = userMapper.selectUserByLoginName(tempOutsourceQuoteVO.getCreateBy()); + if (sysUser != null) { + tempOutsourceQuoteVO.setCreateUserName(sysUser.getUserName()); + } + SysUser sysUser2 = userMapper.selectUserByLoginName(tempOutsourceQuoteVO.getApplyUser()); + if (sysUser2 != null) { + tempOutsourceQuoteVO.setApplyUserName(sysUser2.getUserName()); + } + String instanceId = tempOutsourceQuoteVO.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(); + tempOutsourceQuoteVO.setTaskId(taskId); + // 设置待办用户 + List todoUserList = todoItemMapper.selectUndealTodoUserList(taskId); + if(!org.springframework.util.CollectionUtils.isEmpty(taskList)){ + tempOutsourceQuoteVO.setTodoUserId(String.join(",",todoUserList)); + } + if (task.getSuspensionState() == 2) { + tempOutsourceQuoteVO.setTaskName("已挂起"); + tempOutsourceQuoteVO.setSuspendState("2"); + } else { + tempOutsourceQuoteVO.setTaskName(task.getName()); + tempOutsourceQuoteVO.setSuspendState("1"); + } + } else { + // 已办结或者已撤销 + tempOutsourceQuoteVO.setTaskName("已结束"); + } + } else { + tempOutsourceQuoteVO.setTaskName("未启动"); + } + returnList.add(tempOutsourceQuoteVO); + } + returnList.setTotal(org.springframework.util.CollectionUtils.isEmpty(list) ? 0 : list.getTotal()); + returnList.setPageNum(pageNum); + returnList.setPageSize(pageSize); + return returnList; } /** @@ -65,12 +147,10 @@ public class OutsourceQuoteServiceImpl implements IOutsourceQuoteService * @param childVO 委外报价 * @return 结果 */ - @Transactional @Override public int insertOutsourceQuote(OutsourceQuoteVO childVO) { -// System.out.println(childVO.toString()); -// System.out.println(childVO.getOutsourceQuoteCode()); + String loginName = ShiroUtils.getLoginName(); List children = childVO.getOutsourceQuoteChildList(); for (OutsourceQuoteChild child:children) { child.setOutsourceQuoteCode(childVO.getOutsourceQuoteCode()); @@ -78,50 +158,31 @@ public class OutsourceQuoteServiceImpl implements IOutsourceQuoteService child.setSupplierName(childVO.getSupplierName()); child.setTaxRate(childVO.getTaxRate()); } - System.out.println(children); - OutsourceQuote outsourceQuote = new OutsourceQuote(); - outsourceQuote.setOutsourceQuoteCode(childVO.getOutsourceQuoteCode()); - outsourceQuote.setPricingDate(DateUtils.parseDate(childVO.getPricingDate())); - outsourceQuote.setProcessAmount(children.size()); - outsourceQuote.setSupplierQuoteCode(childVO.getSupplierQuoteCode()); - outsourceQuote.setSupplierName(childVO.getSupplierName()); - - outsourceQuote.setOutsourceQuoteChildList(children); - outsourceQuote.setCreateTime(DateUtils.getNowDate()); - - int rows = outsourceQuoteMapper.insertOutsourceQuote(outsourceQuote); - insertOutsourceQuoteChild(outsourceQuote); + childVO.setProcessAmount(children.size()); + childVO.setOutsourceQuoteChildList(children); + childVO.setCreateTime(DateUtils.getNowDate()); + childVO.setCreateBy(loginName); + int rows = outsourceQuoteMapper.insertOutsourceQuote(childVO); + insertOutsourceQuoteChild(childVO); return rows; } /** * 修改委外报价 * - * @param outsourceQuote 委外报价 - * @return 结果 - */ - @Transactional - @Override - public int updateOutsourceQuote(OutsourceQuote outsourceQuote) - { - outsourceQuote.setUpdateTime(DateUtils.getNowDate()); - outsourceQuoteMapper.deleteOutsourceQuoteChildByOutsourceQuoteCode(outsourceQuote.getOutsourceQuoteCode()); - insertOutsourceQuoteChild(outsourceQuote); - return outsourceQuoteMapper.updateOutsourceQuote(outsourceQuote); - } - - /** - * 批量删除委外报价 - * - * @param outsourceQuoteIds 需要删除的委外报价主键 + * @param outsourceQuoteVO 委外报价 * @return 结果 */ @Transactional @Override - public int deleteOutsourceQuoteByOutsourceQuoteIds(String outsourceQuoteIds) + public int updateOutsourceQuote(OutsourceQuoteVO outsourceQuoteVO) { - outsourceQuoteMapper.deleteOutsourceQuoteChildByOutsourceProcessCodes(Convert.toStrArray(outsourceQuoteIds)); - return outsourceQuoteMapper.deleteOutsourceQuoteByOutsourceQuoteIds(Convert.toStrArray(outsourceQuoteIds)); + SysUser user = ShiroUtils.getSysUser(); + outsourceQuoteVO.setUpdateTime(DateUtils.getNowDate()); + outsourceQuoteVO.setUpdateBy(user.getLoginName()); + outsourceQuoteMapper.deleteOutsourceQuoteChildByOutsourceQuoteCode(outsourceQuoteVO.getOutsourceQuoteCode()); + insertOutsourceQuoteChild(outsourceQuoteVO); + return outsourceQuoteMapper.updateOutsourceQuote(outsourceQuoteVO); } /** @@ -132,7 +193,7 @@ public class OutsourceQuoteServiceImpl implements IOutsourceQuoteService */ @Transactional @Override - public int deleteOutsourceQuoteByOutsourceQuoteId(Integer outsourceQuoteId) + public int deleteOutsourceQuoteByOutsourceQuoteId(Long outsourceQuoteId) { OutsourceQuote outsourceQuote = outsourceQuoteMapper.selectOutsourceQuoteByOutsourceQuoteId(outsourceQuoteId); outsourceQuoteMapper.deleteOutsourceQuoteChildByOutsourceQuoteCode(outsourceQuote.getOutsourceQuoteCode()); @@ -144,7 +205,7 @@ public class OutsourceQuoteServiceImpl implements IOutsourceQuoteService * * @param outsourceQuote 委外报价对象 */ - public void insertOutsourceQuoteChild(OutsourceQuote outsourceQuote) + public void insertOutsourceQuoteChild(OutsourceQuoteVO outsourceQuote) { List outsourceQuoteChildList = outsourceQuote.getOutsourceQuoteChildList(); if (StringUtils.isNotNull(outsourceQuoteChildList)) @@ -165,5 +226,77 @@ public class OutsourceQuoteServiceImpl implements IOutsourceQuoteService return redisCache.generateBillNo("WWBJ"); } + /** + * 审批流程启动 + * */ + @Transactional(rollbackFor = Exception.class) + @Override + public ProcessInstance submitApply(OutsourceQuoteVO outsourceQuoteVO) { + + SysUser user = ShiroUtils.getSysUser(); + outsourceQuoteVO.setApplyUser(user.getLoginName()); + outsourceQuoteVO.setApplyTime(DateUtils.getNowDate()); + // 保存 + insertOutsourceQuote(outsourceQuoteVO); + // 启动流程 + String applyTitle = user.getUserName()+"发起了委外报价提交审批-"+DateUtils.dateTimeNow(); + String instanceType = "submit"; + ProcessInstance processInstance = startProcessInstance(applyTitle,instanceType,outsourceQuoteVO, user); + String processInstanceId = processInstance.getProcessInstanceId(); + // 提交实例id + outsourceQuoteVO.setSubmitInstanceId(processInstanceId); + // 存在提交完就流程结束的情况 + boolean processIsFinish = processService.judgeProcessIsFinish(processInstanceId); + if(processIsFinish){ + // 审核状态-审核通过 + outsourceQuoteVO.setAuditStatus("1"); + } + outsourceQuoteMapper.updateOutsourceQuote(outsourceQuoteVO); + return processInstance; + } + + @Override + public int cancelOutsourceQuoteById(Long id) { + return 0; + } + + + /** + * 创建委外报价审核流程 + * @param applyTitle + * @param instanceType + * @param user + * @return + */ + private ProcessInstance startProcessInstance(String applyTitle, String instanceType, OutsourceQuoteVO outsourceQuoteVO, SysUser user) { + Long outsourceQuoteId = outsourceQuoteVO.getOutsourceQuoteId(); + String businessKey = outsourceQuoteId.toString(); // 实体类 ID,作为流程的业务 key + String key = "outsourceQuote"; + Map variables = new HashMap<>(); + // 构造authority传参 + buildAuthority(user, variables); + outsourceQuoteVO.setApplyTitle(applyTitle); + // 启动流程 + ProcessInstance processInstance = processService.submitApply(user.getLoginName(), businessKey, applyTitle, outsourceQuoteVO.getOutsourceQuoteCode(), key, variables); + String processInstanceId = processInstance.getId(); + outsourceQuoteVO.setInstanceId(processInstanceId); // 建立双向关系 + outsourceQuoteVO.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); + } + } } diff --git a/ruoyi-admin/src/main/resources/mapper/system/OutsourceQuoteMapper.xml b/ruoyi-admin/src/main/resources/mapper/system/OutsourceQuoteMapper.xml index 3230e695..7a4ae074 100644 --- a/ruoyi-admin/src/main/resources/mapper/system/OutsourceQuoteMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/system/OutsourceQuoteMapper.xml @@ -4,7 +4,7 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -18,9 +18,19 @@ + + + + + + + + + + - + @@ -45,10 +55,10 @@ - select outsource_quote_id, outsource_quote_code, supplier_quote_code, supplier_name, process_amount, tax_rate, pricingDate, create_by, create_time, update_by, update_time, audit_status, remark from outsource_quote + select outsource_quote_id, outsource_quote_code, supplier_quote_code, supplier_name, process_amount, tax_rate, pricingDate, create_by, create_time, update_by, update_time, audit_status, remark,instance_id, instance_type, submit_instance_id, apply_title, apply_time, apply_user, cancel_instance_id, restore_instance_id from outsource_quote - and outsource_quote_code = #{outsourceQuoteCode} @@ -62,9 +72,8 @@ - + where outsource_quote_id = #{outsourceQuoteId} @@ -74,7 +83,7 @@ where outsource_quote_code = #{outsource_quote_code} - + insert into outsource_quote outsource_quote_code, @@ -89,6 +98,14 @@ update_time, audit_status, remark, + instance_id, + instance_type, + submit_instance_id, + apply_title, + apply_time, + apply_user, + cancel_instance_id, + restore_instance_id, #{outsourceQuoteCode}, @@ -103,10 +120,18 @@ #{updateTime}, #{auditStatus}, #{remark}, + #{instanceId}, + #{instanceType}, + #{submitInstanceId}, + #{applyTitle}, + #{applyTime}, + #{applyUser}, + #{cancelInstanceId}, + #{restoreInstanceId}, - + update outsource_quote outsource_quote_code = #{outsourceQuoteCode}, @@ -121,11 +146,19 @@ update_time = #{updateTime}, audit_status = #{auditStatus}, remark = #{remark}, + 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_quote_id = #{outsourceQuoteId} - + delete from outsource_quote where outsource_quote_id = #{outsourceQuoteId} @@ -162,4 +195,11 @@ + + update outsource_quote set del_flag = '1' where outsource_quote_id = #{outsourceQuoteId} + + + + update outsource_quote set del_flag = '0' where outsource_quote_id = #{outsourceQuoteId} + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/outsource_quote/add.html b/ruoyi-admin/src/main/resources/templates/system/outsource_quote/add.html index 73901eaf..b8b0f1da 100644 --- a/ruoyi-admin/src/main/resources/templates/system/outsource_quote/add.html +++ b/ruoyi-admin/src/main/resources/templates/system/outsource_quote/add.html @@ -58,7 +58,8 @@
- + + 添加
diff --git a/ruoyi-admin/src/main/resources/templates/system/outsource_quote/outsource_quote.html b/ruoyi-admin/src/main/resources/templates/system/outsource_quote/outsource_quote.html index c11e7752..edaace6b 100644 --- a/ruoyi-admin/src/main/resources/templates/system/outsource_quote/outsource_quote.html +++ b/ruoyi-admin/src/main/resources/templates/system/outsource_quote/outsource_quote.html @@ -76,13 +76,16 @@
+ \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/outsource_quote/taskWwjlVerify.html b/ruoyi-admin/src/main/resources/templates/system/outsource_quote/taskWwjlVerify.html new file mode 100644 index 00000000..65b58375 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/system/outsource_quote/taskWwjlVerify.html @@ -0,0 +1,160 @@ + + + + + + + + +
+
+ + + + + + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+
+

委外工序信息

+
+
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/outsource_quote/taskWwzgVerify.html b/ruoyi-admin/src/main/resources/templates/system/outsource_quote/taskWwzgVerify.html new file mode 100644 index 00000000..b3f9b781 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/system/outsource_quote/taskWwzgVerify.html @@ -0,0 +1,160 @@ + + + + + + + + +
+
+ + + + + + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+
+

委外工序信息

+
+
+
+
+
+ + + + + + + \ No newline at end of file