无关风月
2024-09-03 56dfe0d4bf81262622a1919cceb2b039fd356209
ruoyi-modules/ruoyi-management/src/main/java/com/ruoyi/management/service/impl/SlAuditRecordServiceImpl.java
@@ -1,7 +1,9 @@
package com.ruoyi.management.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.management.domain.*;
@@ -13,6 +15,7 @@
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.feignClient.SysUserClient;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.Date;
@@ -51,18 +54,51 @@
        wrapper.eq( SlAuditRecord::getDelFlag,0);
        wrapper.orderByAsc(SlAuditRecord::getType);
        List<SlAuditRecord> page1 = this.list(wrapper);
        for (int i = 0; i < page1.size(); i++) {
            page1.get(i).setIsPlatform(0);
            SlAudit slAudit = slAuditMapper.selectById(page1.get(i).getAuditId());
            if (slAudit!=null){
                String shenhId = slAudit.getAuditUserId();
                if (StringUtils.hasLength(shenhId)){
                    String[] split = shenhId.split(",");
                    // 取最后一个
                    shenhId = split[split.length - 1];
                    SysUser data = sysUserClient.getSysUser(Long.valueOf(shenhId)).getData();
                    if (data!=null){
                        // 判断当前审核人是不是平台管理员
                        if (data.getUserType().equals("00")){
                            page1.get(i).setIsPlatform(1);
                        }
                    }
                }
            }
            if (page1.get(i).getState() == 3){
                assert slAudit != null;
                page1.get(i).setRefuseReason(slAudit.getCause());
            }
        }
        return page1;
    }
    @Override
    public void updSlAuditRecord(AuditRecordDTO auditRecordDTO) {
        SlAudit slAudit = slAuditMapper.selectById(auditRecordDTO.getAuditId());
        SlAuditRecord byId = this.getById(auditRecordDTO.getId());
        SlAuditRecord byId = this.getOne(new QueryWrapper<SlAuditRecord>()
                .eq("type", auditRecordDTO.getType())
                .eq("audit_id", auditRecordDTO.getAuditId()));
        String auditUserId = slAudit.getAuditUserId();
        if (StringUtils.hasLength(auditUserId)){
            slAudit.setAuditUserId(slAudit.getAuditUserId()+","+SecurityUtils.getUserId());
        }else{
            slAudit.setAuditUserId(SecurityUtils.getUserId()+"");
        }
        Long userid = SecurityUtils.getUserId();
        SysUser data = sysUserClient.getSysUser(userid).getData();
        if (auditRecordDTO.getState()==2){
            Long userid = SecurityUtils.getUserId();
            SysUser data = sysUserClient.getSysUser(userid).getData();
            byId.setShenhName(data.getNickName());
            byId.setShenhTime(new Date());
            byId.setState(auditRecordDTO.getState());
            this.updateById(byId);
            if (slAudit.getState()==1){
                slAudit.setState(2);
@@ -92,12 +128,12 @@
                    slVolumeProductionZyglMapper.updateById(slVolumeProductionZygl);
                }
            }  if (slAudit.getState()==2){
            } else if (slAudit.getState()==2){
                slAudit.setState(3);
                LambdaQueryWrapper<SlAuditRecord> wrapper= Wrappers.lambdaQuery();
                wrapper.eq(SlAuditRecord::getAuditId,auditRecordDTO.getAuditId());
                wrapper.eq(SlAuditRecord::getType,3);
                wrapper.eq( SlAuditRecord::getDelFlag,0);
                wrapper.eq(SlAuditRecord::getDelFlag,0);
                SlAuditRecord one = this.getOne(wrapper);
                slAudit.setShenhId(one.getShenhId());
                slAuditMapper.updateById(slAudit);
@@ -120,7 +156,7 @@
                    slVolumeProductionZyglMapper.updateById(slVolumeProductionZygl);
                }
            }if (slAudit.getState()==3){
            }else if (slAudit.getState()==3){
                slAudit.setState(4);
                slAuditMapper.updateById(slAudit);
                if (slAudit.getType()==1){
@@ -147,12 +183,20 @@
            }
        }
        if (auditRecordDTO.getState()==3){
        }else if (auditRecordDTO.getState()==3){
            byId.setShenhName(data.getNickName());
            byId.setShenhTime(new Date());
            byId.setState(auditRecordDTO.getState());
            this.updateById(byId);
            LambdaQueryWrapper<SlAuditRecord> wrapper= Wrappers.lambdaQuery();
            wrapper.eq(SlAuditRecord::getAuditId,auditRecordDTO.getAuditId());
            wrapper.eq(SlAuditRecord::getType,3);
            wrapper.eq(SlAuditRecord::getDelFlag,0);
            SlAuditRecord one = this.getOne(wrapper);
            slAudit.setShenhId(one.getShenhId());
            slAudit.setCause(auditRecordDTO.getCause());
            slAudit.setState(5);
            slAuditMapper.updateById(slAudit);
            if (slAudit.getType()==1){
                SlVolumeProductionRkgl slVolumeProductionRkgl = slVolumeProductionRkglMapper.selectById(slAudit.getRkId());
                slVolumeProductionRkgl.setAuditStatus(5);