From 80f4ce8b76ad73f826fff2eed82a7acdebceca04 Mon Sep 17 00:00:00 2001 From: cuikaidong <ckd2942379034@163.com> Date: 星期二, 20 五月 2025 17:59:53 +0800 Subject: [PATCH] 借出归还-审批流程增加 --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentLeanOutServiceImpl.java | 54 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 49 insertions(+), 5 deletions(-) diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentLeanOutServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentLeanOutServiceImpl.java index 7f89f3f..1f075cc 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentLeanOutServiceImpl.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentLeanOutServiceImpl.java @@ -17,7 +17,6 @@ import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.eam.constant.AssetStatusEnum; import org.jeecg.modules.eam.constant.EquipmentLeanOutStatusEnum; -import org.jeecg.modules.eam.constant.EquipmentMaintenanceStatus; import org.jeecg.modules.eam.entity.EamEquipment; import org.jeecg.modules.eam.entity.EamEquipmentLeanOut; import org.jeecg.modules.eam.mapper.EamEquipmentLeanOutMapper; @@ -30,7 +29,6 @@ import org.jeecg.modules.flowable.apithird.service.FlowCommonService; import org.jeecg.modules.flowable.service.IFlowDefinitionService; import org.jeecg.modules.flowable.service.IFlowTaskService; -import org.jeecg.modules.system.service.IMdcProductionService; import org.jeecg.modules.system.service.ISysUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -238,10 +236,43 @@ @Override @Transactional(rollbackFor = Exception.class) - public EamEquipmentLeanOut approval(EamEquipmentLeanOut request) { - // TODO - return null; + public EamEquipmentLeanOut approval(EamEquipmentLeanOut eamEquipmentLeanOut) { + try { + // 妫�鏌ヨ姹傚弬鏁� + if (!isValidRequest(eamEquipmentLeanOut)) { + throw new JeecgBootException("闈炴硶鍙傛暟"); + } + if (EquipmentLeanOutStatusEnum.WAIT_APPROVAL.name().equals(eamEquipmentLeanOut.getLeanStatus())) { + eamEquipmentLeanOut.setLeanStatus(EquipmentLeanOutStatusEnum.WAIT_RETURN.name()); + // 寰呭綊杩� + } else if (EquipmentLeanOutStatusEnum.WAIT_RETURN.name().equals(eamEquipmentLeanOut.getLeanStatus())) { + // 寰呯‘璁� + eamEquipmentLeanOut.setLeanStatus(EquipmentLeanOutStatusEnum.WAIT_CONFIRM.name()); + } else if (EquipmentLeanOutStatusEnum.WAIT_CONFIRM.name().equals(eamEquipmentLeanOut.getLeanStatus())) { + // 宸插畬鎴� + eamEquipmentLeanOut.setLeanStatus(EquipmentLeanOutStatusEnum.COMPLETE.name()); + } + // 鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛 + LoginUser sysUser = getCurrentUser(); + if (sysUser == null || StrUtil.isBlank(sysUser.getId())) { + throw new JeecgBootException("璐﹀彿涓嶅瓨鍦�"); + } + // 瀹℃壒浜� + eamEquipmentLeanOut.setApprovalUser(sysUser.getUsername()); + //妫�鏌ヨ澶� + EamEquipment equipment = eamEquipmentService.getById(eamEquipmentLeanOut.getEquipmentId()); + if (equipment == null) { + throw new JeecgBootException("璁惧涓嶅瓨鍦紒"); + } + eamEquipmentLeanOut.setLeanPerson(sysUser.getUsername()); + this.updateById(eamEquipmentLeanOut); + // 鑾峰彇娴佺▼涓氬姟璁板綍 + return eamEquipmentLeanOut; + } catch (Exception e) { + throw new JeecgBootException("鎿嶄綔澶辫触锛�" + e.getMessage()); + } } + @Override public void afterFlowHandle(FlowMyBusiness business) { @@ -250,6 +281,19 @@ business.getActStatus(); } + + private boolean isValidRequest(EamEquipmentLeanOut request) { + return StrUtil.isNotBlank(request.getCode()) && StrUtil.isNotBlank(request.getEquipmentId()); + } + + private LoginUser getCurrentUser() { + try { + return (LoginUser) SecurityUtils.getSubject().getPrincipal(); + } catch (Exception e) { + return null; + } + } + @Override public Object getBusinessDataById(String dataId) { return this.getById(dataId); -- Gitblit v1.9.3