diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseInventoryCheckController.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseInventoryCheckController.java index b4420e73..32f40ca0 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseInventoryCheckController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseInventoryCheckController.java @@ -1,12 +1,25 @@ package com.ruoyi.warehouse.controller; +import java.util.HashMap; import java.util.List; +import com.alibaba.fastjson.JSON; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.process.general.service.IProcessService; +import com.ruoyi.system.domain.BaseEvectionForm; +import com.ruoyi.system.domain.SysSalesOrderChild; +import com.ruoyi.system.domain.Vo.OutsourceQuoteVO; +import com.ruoyi.warehouse.domain.VO.WarehouseInventoryCheckVO; import com.ruoyi.warehouse.domain.VO.WarehouseMaterialVO; import com.ruoyi.warehouse.domain.WarehouseInventoryCheckDetail; import com.ruoyi.warehouse.domain.WarehouseInventoryReportDamageChild; import com.ruoyi.warehouse.mapper.WarehouseInventoryCheckDetailMapper; import com.ruoyi.warehouse.service.IWarehouseInventoryCheckDetailService; +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; @@ -22,6 +35,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 * @@ -43,6 +59,15 @@ public class WarehouseInventoryCheckController extends BaseController @Autowired private WarehouseInventoryCheckDetailMapper checkDetailMapper; + @Autowired + private TaskService taskService; + + @Autowired + private RuntimeService runtimeService; + + @Autowired + private IProcessService processService; + @RequiresPermissions("warehouse:inventoryCheck:view") @GetMapping() public String inventoryCheck() @@ -59,7 +84,7 @@ public class WarehouseInventoryCheckController extends BaseController public TableDataInfo list(WarehouseInventoryCheck warehouseInventoryCheck) { startPage(); - List list = warehouseInventoryCheckService.selectWarehouseInventoryCheckList(warehouseInventoryCheck); + List list = warehouseInventoryCheckService.selectWarehouseInventoryCheckList(warehouseInventoryCheck); return getDataTable(list); } @@ -76,7 +101,7 @@ public class WarehouseInventoryCheckController extends BaseController WarehouseInventoryCheckDetail checkDetail = new WarehouseInventoryCheckDetail(); List list = checkDetailService.selectWarehouseInventoryCheckDetailList(checkDetail); ExcelUtil util = new ExcelUtil(WarehouseInventoryCheckDetail.class); - return util.exportExcel(list, "仓库库存报损数据"); + return util.exportExcel(list, "仓库库存盘点数据"); }else { String[] checkCodes = ids.split(","); List list = checkDetailMapper.selectWarehouseInventoryCheckDetailByCodes(checkCodes); @@ -101,11 +126,98 @@ public class WarehouseInventoryCheckController extends BaseController @Log(title = "仓库库存盘点", businessType = BusinessType.INSERT) @PostMapping("/add") @ResponseBody - public AjaxResult addSave(@RequestBody WarehouseInventoryCheck warehouseInventoryCheck) + public AjaxResult addSave(@RequestBody WarehouseInventoryCheckVO warehouseInventoryCheckVO) { - return toAjax(warehouseInventoryCheckService.insertWarehouseInventoryCheck(warehouseInventoryCheck)); + warehouseInventoryCheckVO.setAuditStatus("0"); + warehouseInventoryCheckService.submitApply(warehouseInventoryCheckVO); + return AjaxResult.success(); +// return toAjax(warehouseInventoryCheckService.insertWarehouseInventoryCheck(warehouseInventoryCheck)); } + /** + * 加载审批弹窗 + * @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(); + WarehouseInventoryCheckVO warehouseInventoryCheckVO = warehouseInventoryCheckService.selectWarehouseInventoryCheckById(new Long(processInstance.getBusinessKey())); + mmap.put("formData", warehouseInventoryCheckVO); + mmap.put("taskId", taskId); + String verifyName = task.getTaskDefinitionKey().substring(0, 1).toUpperCase() + task.getTaskDefinitionKey().substring(1); + return prefix + "/task" + verifyName; + } + /** + * 自动绑定页面字段 + */ + @ModelAttribute("preloadObj") + public WarehouseInventoryCheckVO getObj(@RequestParam(value = "inventoryCheckId", required = false) Long inventoryCheckId, HttpSession session) { + if (inventoryCheckId != null) { + return warehouseInventoryCheckService.selectWarehouseInventoryCheckById(inventoryCheckId); + } + return new WarehouseInventoryCheckVO(); + } + /** + * 完成任务 + * + * @return + */ + @RequestMapping(value = "/complete/{taskId}", method = {RequestMethod.POST, RequestMethod.GET}) + @ResponseBody + public AjaxResult complete(@PathVariable("taskId") String taskId, @RequestParam(value = "saveEntity", required = false) String saveEntity, + @RequestParam(value = "inventoryCheckDetailList", required = false) String inventoryCheckDetailList, + @ModelAttribute("preloadObj") WarehouseInventoryCheckVO inventoryCheckVO, HttpServletRequest request) { + inventoryCheckVO.setInventoryCheckDetails(JSON.parseArray(inventoryCheckDetailList,WarehouseInventoryCheckDetail.class)); + boolean saveEntityBoolean = BooleanUtils.toBoolean(saveEntity); + //获取实例id + String instanceId = inventoryCheckVO.getInstanceId(); + //获取实例类型 + String instanceType = inventoryCheckVO.getInstanceType(); + Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); + String verifyName = task.getTaskDefinitionKey().substring(0, 1).toUpperCase() + task.getTaskDefinitionKey().substring(1); + if(verifyName.equals("ModifyApply")){ + //驳回调整,设置为待审核 + inventoryCheckVO.setAuditStatus("0"); + inventoryCheckVO.setApplyTime(DateUtils.getNowDate()); + } + boolean approvedFlag = processService.complete(taskId, instanceId, inventoryCheckVO.getApplyTitle(), inventoryCheckVO.getInventoryCheckCode(), + "inventoryCheck", new HashMap(), request); + if(!approvedFlag){ + // 审核状态-审核拒绝 + inventoryCheckVO.setAuditStatus("2"); + } + // 如果任务已结束更新业务表状态 + boolean processIsFinish = processService.judgeProcessIsFinish(instanceId); + if (processIsFinish) { + // 审核通过 + inventoryCheckVO.setAuditStatus("1"); + // 提交 + if("submit".equals(instanceType)){ + // 使用状态-是 + inventoryCheckVO.setUseStatus("1"); + } + // 作废 + else if("cancel".equals(instanceType)){ + // 使用状态-已作废 + inventoryCheckVO.setUseStatus("2"); + } + // 恢复 + else if("restore".equals(instanceType)){ + // 使用状态-是 + inventoryCheckVO.setUseStatus("1"); + } + } + warehouseInventoryCheckService.updateVerify(inventoryCheckVO); + // 驳回申请后继续申请,可能修改表单 + if (saveEntityBoolean) { + warehouseInventoryCheckService.updateWarehouseInventoryCheck(inventoryCheckVO); + } + return success("任务已完成"); + } /** * 修改仓库库存盘点 */ @@ -190,5 +302,36 @@ public class WarehouseInventoryCheckController extends BaseController return getDataTable(list); } + /** + * 加载作废库存盘点信息弹窗 + */ + @GetMapping("/cancel/{id}") + public String cancel(@PathVariable("id") Long id, ModelMap mmap) { + WarehouseInventoryCheckVO warehouseInventoryCheckVO = warehouseInventoryCheckService.selectWarehouseInventoryCheckById(id); + mmap.put("inventoryCheck", warehouseInventoryCheckVO); + return prefix + "/cancel"; + } + + /** + * 作废库存盘点 + */ + @RequiresPermissions("warehouse:inventoryCheck:cancel") + @Log(title = "库存盘点", businessType = BusinessType.CANCEL) + @PostMapping( "/cancel") + @ResponseBody + public AjaxResult cancel(WarehouseInventoryCheckVO inventoryCheckVO){ + return toAjax(warehouseInventoryCheckService.cancelWarehouseInventoryCheckVOByObject(inventoryCheckVO)); + } + /** + * 恢复库存盘点 + */ + @RequiresPermissions("warehouse:inventoryCheck:restore") + @Log(title = "库存盘点", businessType = BusinessType.RESTORE) + @GetMapping( "/restore/{id}") + @ResponseBody + public AjaxResult restore(@PathVariable("id")Long id) + { + return toAjax(warehouseInventoryCheckService.restoreWarehouseInventoryCheckVOById(id)); + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/VO/WarehouseInventoryCheckVO.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/VO/WarehouseInventoryCheckVO.java new file mode 100644 index 00000000..22e005cb --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/VO/WarehouseInventoryCheckVO.java @@ -0,0 +1,34 @@ +package com.ruoyi.warehouse.domain.VO; + +import com.ruoyi.warehouse.domain.WarehouseInventoryCheck; +import lombok.Data; + +import java.util.Date; + +@Data +public class WarehouseInventoryCheckVO extends WarehouseInventoryCheck { + /** 申请人姓名 */ + private String applyUserName; + /** 任务ID */ + private String taskId; + /** 任务名称 */ + private String taskName; + /** 当前状态 */ + private String taskStatus; + /** 办理时间 */ + 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/warehouse/domain/WarehouseInventoryCheck.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseInventoryCheck.java index 978e5f6d..7db72c6a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseInventoryCheck.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseInventoryCheck.java @@ -61,6 +61,43 @@ public class WarehouseInventoryCheck extends BaseEntity private List inventoryCheckDetails; + /** 审核状态 */ + @Excel(name = "审核状态",dictType = "auditStatus") + private String auditStatus; + + /** 使用状态 */ + private String useStatus; + + /** 流程实例ID */ + private String instanceId; + + /** 流程实例类型 */ + private String instanceType; + + /** 流程提交实例ID */ + private String submitInstanceId; + + /** 申请标题 */ + private String applyTitle; + + /** 申请时间 */ +// @Excel(name = "申请时间",dateFormat = "yyyy-MM-dd HH:mm:ss",sort = 7) +// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date applyTime; + + /** 申请人 */ +// @Excel(name = "申请人",sort = 6) + private String applyUser; + + /** 流程作废实例ID */ + private String cancelInstanceId; + + /** 流程恢复实例ID */ + private String restoreInstanceId; + + //作废理由 + private String cancelRemark; + public void setInventoryCheckId(Long inventoryCheckId) { this.inventoryCheckId = inventoryCheckId; @@ -152,6 +189,95 @@ public class WarehouseInventoryCheck extends BaseEntity return numTotal; } + public String getAuditStatus() { + return auditStatus; + } + + public void setAuditStatus(String auditStatus) { + this.auditStatus = auditStatus; + } + + public String getUseStatus() { + return useStatus; + } + + public void setUseStatus(String useStatus) { + this.useStatus = useStatus; + } + + 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; + } + + @Override + public String getCancelRemark() { + return cancelRemark; + } + + @Override + public void setCancelRemark(String cancelRemark) { + this.cancelRemark = cancelRemark; + } public List getInventoryCheckDetails() { return inventoryCheckDetails; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/mapper/WarehouseInventoryCheckMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/mapper/WarehouseInventoryCheckMapper.java index 8cfff5db..8f914297 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/mapper/WarehouseInventoryCheckMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/mapper/WarehouseInventoryCheckMapper.java @@ -1,6 +1,8 @@ package com.ruoyi.warehouse.mapper; import java.util.List; + +import com.ruoyi.warehouse.domain.VO.WarehouseInventoryCheckVO; import com.ruoyi.warehouse.domain.WarehouseInventoryCheck; import org.apache.ibatis.annotations.Param; @@ -18,7 +20,7 @@ public interface WarehouseInventoryCheckMapper * @param inventoryCheckId 仓库库存盘点ID * @return 仓库库存盘点 */ - public WarehouseInventoryCheck selectWarehouseInventoryCheckById(Long inventoryCheckId); + public WarehouseInventoryCheckVO selectWarehouseInventoryCheckById(Long inventoryCheckId); /** * 查询仓库库存盘点列表 @@ -26,7 +28,7 @@ public interface WarehouseInventoryCheckMapper * @param warehouseInventoryCheck 仓库库存盘点 * @return 仓库库存盘点集合 */ - public List selectWarehouseInventoryCheckList(WarehouseInventoryCheck warehouseInventoryCheck); + public List selectWarehouseInventoryCheckList(WarehouseInventoryCheck warehouseInventoryCheck); /** * 新增仓库库存盘点 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseInventoryCheckService.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseInventoryCheckService.java index ff8ebf1b..3ecc94c4 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseInventoryCheckService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseInventoryCheckService.java @@ -1,9 +1,13 @@ package com.ruoyi.warehouse.service; import java.util.List; + +import com.ruoyi.warehouse.domain.VO.WarehouseInventoryCheckVO; import com.ruoyi.warehouse.domain.WarehouseInventoryCheck; import com.ruoyi.warehouse.domain.VO.WarehouseMaterialVO; import com.ruoyi.warehouse.domain.WarehouseInventoryCheckDetail; +import org.activiti.engine.runtime.ProcessInstance; +import org.springframework.transaction.annotation.Transactional; /** * 仓库库存盘点Service接口 @@ -19,7 +23,7 @@ public interface IWarehouseInventoryCheckService * @param inventoryCheckId 仓库库存盘点ID * @return 仓库库存盘点 */ - public WarehouseInventoryCheck selectWarehouseInventoryCheckById(Long inventoryCheckId); + public WarehouseInventoryCheckVO selectWarehouseInventoryCheckById(Long inventoryCheckId); /** * 查询仓库库存盘点列表 @@ -27,7 +31,7 @@ public interface IWarehouseInventoryCheckService * @param warehouseInventoryCheck 仓库库存盘点 * @return 仓库库存盘点集合 */ - public List selectWarehouseInventoryCheckList(WarehouseInventoryCheck warehouseInventoryCheck); + public List selectWarehouseInventoryCheckList(WarehouseInventoryCheck warehouseInventoryCheck); /** * 新增仓库库存盘点 @@ -46,6 +50,18 @@ public interface IWarehouseInventoryCheckService public int updateWarehouseInventoryCheck(WarehouseInventoryCheck warehouseInventoryCheck); + //修改审批后信息 + @Transactional + int updateVerify(WarehouseInventoryCheckVO inventoryCheckVO); + + @Transactional(rollbackFor = Exception.class) + ProcessInstance submitApply(WarehouseInventoryCheckVO inventoryCheckVO); + + int cancelWarehouseInventoryCheckVOByObject(WarehouseInventoryCheckVO warehouseInventoryCheckVO); + + @Transactional(rollbackFor = Exception.class) + int restoreWarehouseInventoryCheckVOById(Long inventoryCheckId); + /** * 查找与库存查询有关的物料信息 * */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseInventoryCheckServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseInventoryCheckServiceImpl.java index 69c95e34..947808ac 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseInventoryCheckServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseInventoryCheckServiceImpl.java @@ -2,21 +2,32 @@ package com.ruoyi.warehouse.service.impl; import java.text.DecimalFormat; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -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.exception.BusinessException; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.erp.domain.ErpMaterialVo; import com.ruoyi.erp.mapper.ErpMaterialMapper; +import com.ruoyi.process.general.service.IProcessService; +import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper; +import com.ruoyi.system.mapper.SysUserMapper; +import com.ruoyi.system.service.impl.SysRoleServiceImpl; +import com.ruoyi.warehouse.domain.VO.WarehouseInventoryCheckVO; import com.ruoyi.warehouse.domain.VO.WarehouseMaterialVO; import com.ruoyi.warehouse.domain.WarehouseInventoryCheckDetail; import com.ruoyi.warehouse.mapper.WarehouseInventoryCheckDetailMapper; import lombok.extern.slf4j.Slf4j; +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.warehouse.mapper.WarehouseInventoryCheckMapper; @@ -43,6 +54,23 @@ public class WarehouseInventoryCheckServiceImpl implements IWarehouseInventoryCh @Autowired private WarehouseInventoryCheckDetailMapper inventoryCheckDetailMapper; + @Autowired + private SysRoleServiceImpl roleService; + + @Autowired + private TaskService taskService; + + @Autowired + private RuntimeService runtimeService; + + @Autowired + private BizTodoItemMapper todoItemMapper; + + @Autowired + private SysUserMapper userMapper; + + @Autowired + private IProcessService processService; /** * 查询仓库库存盘点 * @@ -50,21 +78,85 @@ public class WarehouseInventoryCheckServiceImpl implements IWarehouseInventoryCh * @return 仓库库存盘点 */ @Override - public WarehouseInventoryCheck selectWarehouseInventoryCheckById(Long inventoryCheckId) + public WarehouseInventoryCheckVO selectWarehouseInventoryCheckById(Long inventoryCheckId) { - return warehouseInventoryCheckMapper.selectWarehouseInventoryCheckById(inventoryCheckId); + WarehouseInventoryCheckVO inventoryCheckVO = warehouseInventoryCheckMapper.selectWarehouseInventoryCheckById(inventoryCheckId); + SysUser sysUser = userMapper.selectUserByLoginName(inventoryCheckVO.getApplyUser()); + if (sysUser != null) { + inventoryCheckVO.setApplyUserName(sysUser.getUserName()); + } + return inventoryCheckVO; } /** * 查询仓库库存盘点列表 - * + * * @param warehouseInventoryCheck 仓库库存盘点 * @return 仓库库存盘点 */ @Override - public List selectWarehouseInventoryCheckList(WarehouseInventoryCheck warehouseInventoryCheck) + public List selectWarehouseInventoryCheckList(WarehouseInventoryCheck warehouseInventoryCheck) { - return warehouseInventoryCheckMapper.selectWarehouseInventoryCheckList(warehouseInventoryCheck); + PageDomain pageDomain = TableSupport.buildPageRequest(); + Integer pageNum = pageDomain.getPageNum(); + Integer pageSize = pageDomain.getPageSize(); + + // PageHelper 仅对第一个 List 分页 + Page list = (Page) warehouseInventoryCheckMapper.selectWarehouseInventoryCheckList(warehouseInventoryCheck); + Page returnList = new Page<>(); + for (WarehouseInventoryCheckVO inventoryCheckVO: list) { + SysUser sysUser = userMapper.selectUserByLoginName(inventoryCheckVO.getCreateBy()); + if (sysUser != null) { + inventoryCheckVO.setCreateUserName(sysUser.getUserName()); + } + SysUser sysUser2 = userMapper.selectUserByLoginName(inventoryCheckVO.getApplyUser()); + if (sysUser2 != null) { + inventoryCheckVO.setApplyUserName(sysUser2.getUserName()); + } + String instanceId = inventoryCheckVO.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(); + inventoryCheckVO.setTaskId(taskId); + // 设置待办用户 + List todoUserList = todoItemMapper.selectUndealTodoUserList(taskId); + if(!org.springframework.util.CollectionUtils.isEmpty(taskList)){ + inventoryCheckVO.setTodoUserId(String.join(",",todoUserList)); + } + if (task.getSuspensionState() == 2) { + inventoryCheckVO.setTaskName("已挂起"); + inventoryCheckVO.setSuspendState("2"); + } else { + inventoryCheckVO.setTaskName(task.getName()); + inventoryCheckVO.setSuspendState("1"); + } + } else { + // 已办结或者已撤销 + inventoryCheckVO.setTaskName("已结束"); + } + } else { + inventoryCheckVO.setTaskName("未启动"); + } + inventoryCheckVO.setTaskStatus(inventoryCheckVO.getTaskName()); + if(inventoryCheckVO.getAuditStatus()==null){ + inventoryCheckVO.setTaskStatus("未启动"); + }else if(inventoryCheckVO.getAuditStatus().equals("1")){ + inventoryCheckVO.setTaskStatus("审核通过"); + }else if(inventoryCheckVO.getAuditStatus().equals("2")){ + inventoryCheckVO.setTaskStatus("审核拒绝"); + } + returnList.add(inventoryCheckVO); + } + returnList.setTotal(org.springframework.util.CollectionUtils.isEmpty(list) ? 0 : list.getTotal()); + returnList.setPageNum(pageNum); + returnList.setPageSize(pageSize); + return returnList; } /** @@ -126,7 +218,7 @@ public class WarehouseInventoryCheckServiceImpl implements IWarehouseInventoryCh * @param warehouseInventoryCheck 仓库库存盘点 * @return 结果 */ - @Transactional + @Transactional(rollbackFor = Exception.class) @Override public int updateWarehouseInventoryCheck(WarehouseInventoryCheck warehouseInventoryCheck) { @@ -138,7 +230,7 @@ public class WarehouseInventoryCheckServiceImpl implements IWarehouseInventoryCh List inventoryCheckDetails = warehouseInventoryCheck.getInventoryCheckDetails(); if (StringUtils.isEmpty(inventoryCheckDetails)){ - log.warn("仓库盘点物料相关信息为空:{}",inventoryCheckDetails); + throw new BusinessException("仓库盘点物料相关信息为空!"); }else{ inventoryCheckDetailMapper.deleteWarehouseInventoryCheckDetailByCode(warehouseInventoryCheck.getInventoryCheckCode()); warehouseInventoryCheck.setMaterialTotal(inventoryCheckDetails.size()); @@ -167,7 +259,149 @@ public class WarehouseInventoryCheckServiceImpl implements IWarehouseInventoryCh warehouseInventoryCheck.setNumTotal(numTotal); return warehouseInventoryCheckMapper.updateWarehouseInventoryCheck(warehouseInventoryCheck); } + //修改审批后信息 + @Transactional + @Override + public int updateVerify(WarehouseInventoryCheckVO inventoryCheckVO){ + inventoryCheckVO.setUpdateBy(ShiroUtils.getLoginName()); + inventoryCheckVO.setUpdateTime(DateUtils.getNowDate()); + return warehouseInventoryCheckMapper.updateWarehouseInventoryCheck(inventoryCheckVO); + } + /** + * 审批流程启动 + * */ + @Transactional(rollbackFor = Exception.class) + @Override + public ProcessInstance submitApply(WarehouseInventoryCheckVO inventoryCheckVO) { + + SysUser user = ShiroUtils.getSysUser(); + inventoryCheckVO.setApplyUser(user.getLoginName()); + inventoryCheckVO.setApplyTime(DateUtils.getNowDate()); + // 保存 + insertWarehouseInventoryCheck(inventoryCheckVO); + // 启动流程 + String applyTitle = user.getUserName()+"发起了库存盘点提交审批-"+DateUtils.dateTimeNow(); + String instanceType = "submit"; + ProcessInstance processInstance = startProcessInstance(applyTitle,instanceType,inventoryCheckVO, user); + String processInstanceId = processInstance.getProcessInstanceId(); + // 提交实例id + inventoryCheckVO.setSubmitInstanceId(processInstanceId); + // 存在提交完就流程结束的情况 + boolean processIsFinish = processService.judgeProcessIsFinish(processInstanceId); + if(processIsFinish){ + // 审核状态-审核通过 + inventoryCheckVO.setAuditStatus("1"); + + inventoryCheckVO.setUseStatus("1"); + } + warehouseInventoryCheckMapper.updateWarehouseInventoryCheck(inventoryCheckVO); + return processInstance; + } + + + /** + * 创建库存盘点审核流程 + * @param applyTitle + * @param instanceType + * @param user + * @return + */ + private ProcessInstance startProcessInstance(String applyTitle, String instanceType, WarehouseInventoryCheckVO inventoryCheckVO, SysUser user) { + Long inventoryCheckId = inventoryCheckVO.getInventoryCheckId(); + String businessKey = inventoryCheckId.toString(); // 实体类 ID,作为流程的业务 key + String key = "inventoryCheck"; + Map variables = new HashMap<>(); + // 构造authority传参 + buildAuthority(user, variables); + inventoryCheckVO.setApplyTitle(applyTitle); + // 启动流程 + ProcessInstance processInstance = processService.submitApply(user.getLoginName(), businessKey, applyTitle, inventoryCheckVO.getInventoryCheckCode(), key, variables); + String processInstanceId = processInstance.getId(); + inventoryCheckVO.setInstanceId(processInstanceId); // 建立双向关系 + inventoryCheckVO.setInstanceType(instanceType); + return processInstance; + } + + /** + * 发起人节点判断 + * */ + private void buildAuthority(SysUser user, Map variables) { + Set roleKeys = roleService.selectRoleKeys(user.getUserId()); + // 角色不同审核人不同 + if(roleKeys.contains("cgyyRole")){ + variables.put("authority",1); + }else if(roleKeys.contains("ckzgRole")){ + variables.put("authority",2); + }else if(roleKeys.contains("fzjlRole")||roleKeys.contains("admin")||roleKeys.contains("zjlRole")){ + variables.put("authority",3); + } + } + + /** + * 作废库存盘点 + * + * @param warehouseInventoryCheckVO 库存盘点 + * @return 结果 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int cancelWarehouseInventoryCheckVOByObject(WarehouseInventoryCheckVO warehouseInventoryCheckVO) + { + WarehouseInventoryCheckVO inventoryCheckVO = warehouseInventoryCheckMapper.selectWarehouseInventoryCheckById(warehouseInventoryCheckVO.getInventoryCheckId()); + // 审核状态-待审核 + inventoryCheckVO.setAuditStatus("0"); + SysUser user = ShiroUtils.getSysUser(); + // 启动流程 + String applyTitle = user.getUserName()+"发起了库存盘点作废审批-"+DateUtils.dateTimeNow(); + String instanceType = "cancel"; + ProcessInstance processInstance = startProcessInstance(applyTitle,instanceType,inventoryCheckVO, user); + String processInstanceId = processInstance.getProcessInstanceId(); + // 作废实例id + inventoryCheckVO.setCancelInstanceId(processInstanceId); + // 存在提交完就流程结束的情况 + boolean processIsFinish = processService.judgeProcessIsFinish(processInstanceId); + if(processIsFinish){ + // 审核状态-审核通过 + inventoryCheckVO.setAuditStatus("1"); + // 使用状态-已作废 + inventoryCheckVO.setUseStatus("2"); + } + inventoryCheckVO.setCancelRemark(warehouseInventoryCheckVO.getCancelRemark()); + return warehouseInventoryCheckMapper.updateWarehouseInventoryCheck(inventoryCheckVO); + } + + /** + * 恢复库存盘点信息 + * + * @param inventoryCheckId 库存盘点ID + * @return 结果 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int restoreWarehouseInventoryCheckVOById(Long inventoryCheckId) + { + WarehouseInventoryCheckVO inventoryCheckVO = warehouseInventoryCheckMapper.selectWarehouseInventoryCheckById(inventoryCheckId); + // 审核状态-待审核 + inventoryCheckVO.setAuditStatus("0"); + SysUser user = ShiroUtils.getSysUser(); + // 启动流程 + String applyTitle = user.getUserName()+"发起了库存盘点恢复审批-"+DateUtils.dateTimeNow(); + String instanceType = "restore"; + ProcessInstance processInstance = startProcessInstance(applyTitle,instanceType,inventoryCheckVO, user); + String processInstanceId = processInstance.getProcessInstanceId(); + // 恢复实例id + inventoryCheckVO.setRestoreInstanceId(processInstanceId); + // 存在提交完就流程结束的情况 + boolean processIsFinish = processService.judgeProcessIsFinish(processInstanceId); + if(processIsFinish){ + // 审核状态-审核通过 + inventoryCheckVO.setAuditStatus("1"); + // 使用状态-是 + inventoryCheckVO.setUseStatus("1"); + } + return warehouseInventoryCheckMapper.updateWarehouseInventoryCheck(inventoryCheckVO); + } /** * 查找与库存查询有关的物料信息 * */ diff --git a/ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseInventoryCheckMapper.xml b/ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseInventoryCheckMapper.xml index 8a949089..48208b88 100644 --- a/ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseInventoryCheckMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/warehouse/WarehouseInventoryCheckMapper.xml @@ -4,7 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -20,10 +20,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + + + + - select inventory_check_id, inventory_check_code, inventory_check_name, material_no, material_name, warehouse_code, warehouse_name, inventory_check_date, material_total, num_total, remark, create_time, create_by, update_by, update_time from warehouse_inventory_check + select inventory_check_id, inventory_check_code, inventory_check_name, + material_no, material_name, warehouse_code, warehouse_name, + inventory_check_date, material_total, num_total, remark, + create_time, create_by, update_by, update_time,audit_status, + use_status,instance_id,instance_type,submit_instance_id, + apply_title,apply_time,apply_user,cancel_instance_id, + restore_instance_id,cancel_remark from warehouse_inventory_check +
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/inventoryCheck.html b/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/inventoryCheck.html index 07c23fb6..8f08460c 100644 --- a/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/inventoryCheck.html +++ b/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/inventoryCheck.html @@ -49,7 +49,7 @@ 添加 - + 导出 @@ -59,10 +59,15 @@ + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/taskCkzgVerify.html b/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/taskCkzgVerify.html new file mode 100644 index 00000000..03968336 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/taskCkzgVerify.html @@ -0,0 +1,178 @@ + + + + + + + + +
+
+ + + + + + +
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+ + + +
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+
+
+
+
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/taskFzjlVerify.html b/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/taskFzjlVerify.html new file mode 100644 index 00000000..95473822 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/taskFzjlVerify.html @@ -0,0 +1,178 @@ + + + + + + + + +
+
+ + + + + + +
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+ + + +
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+
+
+
+
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/taskModifyApply.html b/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/taskModifyApply.html new file mode 100644 index 00000000..472a0191 --- /dev/null +++ b/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/taskModifyApply.html @@ -0,0 +1,263 @@ + + + + + + + + +
+
+ + + + + + + + +
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+ + + + + +
+
+
+ 选择物料 + + 选择物料 + +
+
+
+
+
+
+
+
+ +
+ +
+ + + + + + + + + \ No newline at end of file