cuikaidong
2025-05-20 80f4ce8b76ad73f826fff2eed82a7acdebceca04
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);