无关风月
2024-09-03 56dfe0d4bf81262622a1919cceb2b039fd356209
ruoyi-modules/ruoyi-management/src/main/java/com/ruoyi/management/service/impl/SlAuditServiceImpl.java
@@ -1,6 +1,7 @@
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.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.utils.page.PageDTO;
@@ -20,10 +21,7 @@
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -44,6 +42,8 @@
    @Resource
    private SlVolumeProductionRkglMapper slVolumeProductionRkglMapper;
    @Resource
    private SlVolumeProductionRkMapper slVolumeProductionRkMapper;
    @Resource
    private SlVolumeProductionCkglMapper slVolumeProductionCKglMapper;
@@ -57,8 +57,26 @@
    @Override
    public PageDTO<SlAuditVO> getslAuditList(AuditRecordListQuery auditRecordListQuery) {
        List<Long> rkglIds = new ArrayList<>();
        List<Long> ckglIds = new ArrayList<>();
        List<Long> zyglIds = new ArrayList<>();
        List<Long> auditIds = new ArrayList<>();
        Long userid = SecurityUtils.getUserId();
        SysUser data = sysUserClient.getSysUser(userid).getData();
        // 查询当前登陆人管理了哪一些货架
        List<SlStoreManagement> list1 = slStoreManagementService.lambdaQuery().list();
        List<Long> managementIds = new ArrayList<>();
        for (SlStoreManagement slStoreManagement : list1) {
            if (Arrays.asList(slStoreManagement.getAdministratorId().split(",")).contains(userid.toString())
            || Arrays.asList(slStoreManagement.getCompetentId().split(",")).contains(userid.toString())
            || Arrays.asList(slStoreManagement.getDirectorId().split(",")).contains(userid.toString())
            ){
                managementIds.add(slStoreManagement.getId());
            }
        }
        if (managementIds.isEmpty()){
            managementIds.add(0L);
        }
        getVolumeProductionRkQuery getVolumeProductionRkQuer=new getVolumeProductionRkQuery();
        getVolumeProductionRkQuer.setSupplierName(auditRecordListQuery.getSysName());
        getVolumeProductionRkQuer.setSupplierPhone(auditRecordListQuery.getSysPhone());
@@ -69,6 +87,12 @@
        Page<SlAudit> page = new Page<>(auditRecordListQuery.getPageCurr(), auditRecordListQuery.getPageSize());
        LambdaQueryWrapper< SlAudit> wrapper= Wrappers.lambdaQuery();
        wrapper.eq(SlAudit::getDelFlag,0);
        if (auditRecordListQuery.getState()!=null){
            wrapper.eq(SlAudit::getState,auditRecordListQuery.getState());
        }
        if (goodsSkuIdList.size()>0){
            wrapper.in(SlAudit::getSysId,goodsSkuIdList);
        }else{
@@ -76,42 +100,94 @@
            goodsSkuIdList1.add(0L);
            wrapper.in(SlAudit::getSysId,goodsSkuIdList1);
        }
        if (!data.getUserType().equals(00)){
            wrapper.in(SlAudit::getShenhId,userid);
        switch (auditRecordListQuery.getType()){
            case 1:
                rkglIds = slVolumeProductionRkglMapper.selectList(new QueryWrapper<SlVolumeProductionRkgl>()
                        .ne("audit_status", 7)).stream().map(SlVolumeProductionRkgl::getId).collect(Collectors.toList());
                wrapper.in(SlAudit::getRkId,rkglIds);
                if (rkglIds.isEmpty()){
                    rkglIds.add(0L);
                }
                if (!data.getUserType().equals("00")){
                    // 没有管理仓库
                    // 查询相关的审核
                    auditIds = slAuditRecordMapper.selectList(new QueryWrapper<SlAuditRecord>()
                            .like("shenh_id", data.getUserId())).stream().map(SlAuditRecord::getAuditId).collect(Collectors.toList());
                    if (auditIds.isEmpty()){
                        auditIds.add(0L);
                    }
                    List<Long> finalAuditIds = auditIds;
                    wrapper.and(wrapper1 -> wrapper1.in(SlAudit::getManagementId,managementIds).or().in(SlAudit::getId, finalAuditIds));
                }
                break;
            case 2:
                ckglIds = slVolumeProductionCKglMapper.selectList(new QueryWrapper<SlVolumeProductionCkgl>()
                        .ne("audit_status", 8)).stream().map(SlVolumeProductionCkgl::getId).collect(Collectors.toList());
                wrapper.in(SlAudit::getRkId,ckglIds);
                if (ckglIds.isEmpty()){
                    ckglIds.add(0L);
                }
                if (!data.getUserType().equals("00")){
                    // 只查询相关的审核
                    auditIds = slAuditRecordMapper.selectList(new QueryWrapper<SlAuditRecord>()
                            .like("shenh_id", data.getUserId())).stream().map(SlAuditRecord::getAuditId).collect(Collectors.toList());
                    if (auditIds.isEmpty()){
                        auditIds.add(0L);
                    }
                    List<Long> finalAuditIds1 = auditIds;
                    wrapper.and(wrapper1 -> wrapper1.in(SlAudit::getManagementId,managementIds).or().in(SlAudit::getId, finalAuditIds1));
                }
                break;
            case 3:
                zyglIds = slVolumeProductionZyglMapper.selectList(new QueryWrapper<SlVolumeProductionZygl>()
                        .ne("audit_status", 7)).stream().map(SlVolumeProductionZygl::getId).collect(Collectors.toList());
                if (zyglIds.isEmpty()){
                    zyglIds.add(0L);
                }
                wrapper.in(SlAudit::getRkId,zyglIds);
                if (!data.getUserType().equals("00")){
                    // 只查询相关的审核
                    auditIds = slAuditRecordMapper.selectList(new QueryWrapper<SlAuditRecord>()
                            .like("shenh_id", data.getUserId())).stream().map(SlAuditRecord::getAuditId).collect(Collectors.toList());
                    if (auditIds.isEmpty()){
                        auditIds.add(0L);
                    }
                    List<Long> finalAuditIds2 = auditIds;
                    wrapper.and(wrapper1 -> wrapper1.in(SlAudit::getManagementId,managementIds).or().in(SlAudit::getId, finalAuditIds2));
                }
                break;
        }
        List state=new ArrayList<>();
        state.add(1);
        state.add(2);
        state.add(3);
        state.add(4);
        state.add(5);
        wrapper.eq(SlAudit::getState,state);
        wrapper.eq(SlAudit::getType,auditRecordListQuery.getType());
        wrapper.eq( SlAudit::getDelFlag,0);
        wrapper.eq(SlAudit::getDelFlag,0);
        wrapper.orderByDesc(SlAudit::getCreateTime);
        Page<SlAudit> page1 = this.page(page, wrapper);
        PageDTO<SlAuditVO> slEquipmentVOPageDTO = PageDTO.of(page1, SlAuditVO.class);
        List<SlAuditVO> list = slEquipmentVOPageDTO.getList();
        for (SlAuditVO sl:list){
            SlAuditVO slAuditVO=new SlAuditVO();
            SysUser data2 = sysUserClient.getSysUser(sl.getSysId()).getData();
            slAuditVO.setSysPhone(data2.getPhonenumber());
            slAuditVO.setSysName(data2.getNickName());
            sl.setSysPhone(data2.getPhonenumber());
            sl.setSysName(data2.getNickName());
            SlStoreManagement byId = slStoreManagementService.getById(sl.getManagementId());
            slAuditVO.setStoreManagementName(byId.getStoreManagementName());
            slAuditVO.setStoreManagementNo(byId.getStoreManagementNo());
            sl.setStoreManagementName(byId.getStoreManagementName());
            sl.setStoreManagementNo(byId.getStoreManagementNo());
            if (sl.getZymanagementId()!=null){
                SlStoreManagement byId1 = slStoreManagementService.getById(sl.getZymanagementId());
                slAuditVO.setBstoreManagementName(byId1.getStoreManagementName());
                slAuditVO.setBstoreManagementNo(byId1.getStoreManagementNo());
                sl.setBstoreManagementName(byId1.getStoreManagementName());
                sl.setBstoreManagementNo(byId1.getStoreManagementNo());
            }
        }
        return slEquipmentVOPageDTO;
    }
    @Resource
    private SlStoreManagementMapper slStoreManagementMapper;
    @Override
    public void addslAudit(SlAuditDTO slAuditDTO) {
        LambdaQueryWrapper< SlAudit> wrapper= Wrappers.lambdaQuery();
        wrapper.eq(SlAudit::getRkId,slAuditDTO.getRkId());
        wrapper.eq(SlAudit::getType,slAuditDTO.getType());
@@ -127,98 +203,442 @@
            }
            this.removeById(page1);
        }
        SlAudit slAudit=new SlAudit();
        slAudit.setType(slAuditDTO.getType());
        slAudit.setState(1);
        slAudit.setCreateTime(new Date());
        slAudit.setRkId(slAuditDTO.getRkId());
        // 根据发起人
        if (slAudit.getType()==1){
            SlVolumeProductionRkgl slVolumeProductionRkgl = slVolumeProductionRkglMapper.selectById(slAuditDTO.getRkId());
            SlStoreManagement slStoreManagement = slStoreManagementMapper.selectById(slVolumeProductionRkgl.getManagementId());
            String directorId = slStoreManagement.getDirectorId();
            String competentId = slStoreManagement.getCompetentId();
            String administratorId = slStoreManagement.getAdministratorId();
            Long userid = SecurityUtils.getUserId();
            List<String> list1 = Arrays.asList(administratorId.split(","));
            List<String> list2 = Arrays.asList(competentId.split(","));
            List<String> list3 = Arrays.asList(directorId.split(","));
            slAudit.setSysId(slVolumeProductionRkgl.getSysId());
            slAudit.setManagementId(slVolumeProductionRkgl.getManagementId());
            SlStoreManagement byId = slStoreManagementService.getById(slVolumeProductionRkgl.getManagementId());
            slAudit.setShenhId(byId.getAdministratorId());
            this.save(slAudit);
            SlAuditRecord slAuditRecord=new SlAuditRecord();
            slAuditRecord.setAuditId(slAudit.getId());
            slAuditRecord.setShenhId(byId.getAdministratorId());
            slAuditRecord.setType(1);
            slAuditRecord.setState(1);
            slAuditRecordMapper.insert(slAuditRecord);
            if (list3.contains(userid.toString())){
                slVolumeProductionRkgl.setAuditStatus(4);
                slVolumeProductionRkgl.setPresentState(3);
                slVolumeProductionRkglMapper.updateById(slVolumeProductionRkgl);
                slAudit.setState(4);
                this.save(slAudit);
                // 主任发起 主管和管理员默认审核通过
                SlAuditRecord slAuditRecord4=new SlAuditRecord();
                slAuditRecord4.setAuditId(slAudit.getId());
                slAuditRecord4.setShenhId(byId.getDirectorId());
                slAuditRecord4.setType(3);
                slAuditRecord4.setState(2);
                slAuditRecord4.setShenhTime(new Date());
                slAuditRecord4.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord4);
            SlAuditRecord slAuditRecord1=new SlAuditRecord();
            slAuditRecord1.setAuditId(slAudit.getId());
            slAuditRecord1.setShenhId(byId.getCompetentId());
            slAuditRecord1.setType(2);
            slAuditRecord1.setState(1);
            slAuditRecordMapper.insert(slAuditRecord);
                SlAuditRecord slAuditRecord3=new SlAuditRecord();
                slAuditRecord3.setAuditId(slAudit.getId());
                slAuditRecord3.setShenhId(byId.getCompetentId());
                slAuditRecord3.setType(2);
                slAuditRecord3.setState(2);
                slAuditRecord3.setShenhTime(new Date());
                slAuditRecord3.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord3);
            SlAuditRecord slAuditRecord2=new SlAuditRecord();
            slAuditRecord2.setAuditId(slAudit.getId());
            slAuditRecord2.setShenhId(byId.getDirectorId());
            slAuditRecord2.setType(3);
            slAuditRecord2.setState(1);
            slAuditRecordMapper.insert(slAuditRecord);
                SlAuditRecord slAuditRecord2=new SlAuditRecord();
                slAuditRecord2.setAuditId(slAudit.getId());
                slAuditRecord2.setShenhId(byId.getAdministratorId());
                slAuditRecord2.setType(1);
                slAuditRecord2.setState(2);
                slAuditRecord2.setShenhTime(new Date());
                slAuditRecord2.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord2);
            }else if (list2.contains(userid.toString())){
                slAudit.setState(3);
                this.save(slAudit);
                slVolumeProductionRkgl.setAuditStatus(3);
                slVolumeProductionRkgl.setPresentState(1);
                slVolumeProductionRkglMapper.updateById(slVolumeProductionRkgl);
                // 如果是主管
                SlAuditRecord slAuditRecord3=new SlAuditRecord();
                slAuditRecord3.setAuditId(slAudit.getId());
                slAuditRecord3.setShenhId(byId.getCompetentId());
                slAuditRecord3.setType(2);
                slAuditRecord3.setState(2);
                slAuditRecord3.setShenhTime(new Date());
                slAuditRecord3.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord3);
                SlAuditRecord slAuditRecord2=new SlAuditRecord();
                slAuditRecord2.setAuditId(slAudit.getId());
                slAuditRecord2.setShenhId(byId.getAdministratorId());
                slAuditRecord2.setType(1);
                slAuditRecord2.setState(2);
                slAuditRecord2.setShenhTime(new Date());
                slAuditRecord2.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord2);
                SlAuditRecord slAuditRecord4=new SlAuditRecord();
                slAuditRecord4.setAuditId(slAudit.getId());
                slAuditRecord4.setShenhId(byId.getDirectorId());
                slAuditRecord4.setType(3);
                slAuditRecord4.setState(1);
                slAuditRecord4.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord4);
            }else if (list1.contains(userid.toString())){
                // 如果是管理员
                slAudit.setState(2);
                this.save(slAudit);
                slVolumeProductionRkgl.setAuditStatus(2);
                slVolumeProductionRkgl.setPresentState(1);
                slVolumeProductionRkglMapper.updateById(slVolumeProductionRkgl);
                // 如果是主管
                SlAuditRecord slAuditRecord3=new SlAuditRecord();
                slAuditRecord3.setAuditId(slAudit.getId());
                slAuditRecord3.setShenhId(byId.getCompetentId());
                slAuditRecord3.setType(2);
                slAuditRecord3.setState(1);
                slAuditRecord3.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord3);
                SlAuditRecord slAuditRecord2=new SlAuditRecord();
                slAuditRecord2.setAuditId(slAudit.getId());
                slAuditRecord2.setShenhId(byId.getAdministratorId());
                slAuditRecord2.setType(1);
                slAuditRecord2.setState(2);
                slAuditRecord2.setShenhTime(new Date());
                slAuditRecord2.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord2);
                SlAuditRecord slAuditRecord4=new SlAuditRecord();
                slAuditRecord4.setAuditId(slAudit.getId());
                slAuditRecord4.setShenhId(byId.getDirectorId());
                slAuditRecord4.setType(3);
                slAuditRecord4.setState(1);
                slAuditRecord4.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord4);
            }
            if (!list3.contains(userid.toString()) && !list2.contains(userid.toString()) && !list1.contains(userid.toString())){
                this.save(slAudit);
                SlAuditRecord slAuditRecord=new SlAuditRecord();
                slAuditRecord.setAuditId(slAudit.getId());
                slAuditRecord.setShenhId(byId.getAdministratorId());
                slAuditRecord.setType(1);
                slAuditRecord.setState(1);
                slAuditRecord.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord);
                SlAuditRecord slAuditRecord3=new SlAuditRecord();
                slAuditRecord3.setAuditId(slAudit.getId());
                slAuditRecord3.setShenhId(byId.getCompetentId());
                slAuditRecord3.setType(2);
                slAuditRecord3.setState(1);
                slAuditRecord3.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord3);
                SlAuditRecord slAuditRecord4=new SlAuditRecord();
                slAuditRecord4.setAuditId(slAudit.getId());
                slAuditRecord4.setShenhId(byId.getDirectorId());
                slAuditRecord4.setType(3);
                slAuditRecord4.setState(1);
                slAuditRecord4.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord4);
            }
        }
        if (slAudit.getType()==2){
        if (slAudit.getType()==2) {
            SlVolumeProductionCkgl slVolumeProductionCkgl = slVolumeProductionCKglMapper.selectById(slAuditDTO.getRkId());
            SlStoreManagement slStoreManagement = slStoreManagementMapper.selectById(slVolumeProductionCkgl.getManagementId());
            String directorId = slStoreManagement.getDirectorId();
            String competentId = slStoreManagement.getCompetentId();
            String administratorId = slStoreManagement.getAdministratorId();
            Long userid = SecurityUtils.getUserId();
            List<String> list1 = Arrays.asList(administratorId.split(","));
            List<String> list2 = Arrays.asList(competentId.split(","));
            List<String> list3 = Arrays.asList(directorId.split(","));
            slAudit.setSysId(slVolumeProductionCkgl.getSysId());
            slAudit.setManagementId(slVolumeProductionCkgl.getManagementId());
            SlStoreManagement byId = slStoreManagementService.getById(slVolumeProductionCkgl.getManagementId());
            slAudit.setShenhId(byId.getAdministratorId());
            this.save(slAudit);
            SlAuditRecord slAuditRecord=new SlAuditRecord();
            slAuditRecord.setAuditId(slAudit.getId());
            slAuditRecord.setShenhId(byId.getAdministratorId());
            slAuditRecord.setType(1);
            slAuditRecord.setState(1);
            slAuditRecordMapper.insert(slAuditRecord);
            if (list3.contains(userid.toString())){
                slAudit.setState(4);
                this.save(slAudit);
                slVolumeProductionCkgl.setAuditStatus(4);
                slVolumeProductionCkgl.setPresentState(3);
                slVolumeProductionCKglMapper.updateById(slVolumeProductionCkgl);
                // 主任发起 主管和管理员默认审核通过
                SlAuditRecord slAuditRecord4=new SlAuditRecord();
                slAuditRecord4.setAuditId(slAudit.getId());
                slAuditRecord4.setShenhId(byId.getDirectorId());
                slAuditRecord4.setType(3);
                slAuditRecord4.setState(2);
                slAuditRecord4.setShenhTime(new Date());
                slAuditRecord4.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord4);
            SlAuditRecord slAuditRecord1=new SlAuditRecord();
            slAuditRecord1.setAuditId(slAudit.getId());
            slAuditRecord1.setShenhId(byId.getCompetentId());
            slAuditRecord1.setType(2);
            slAuditRecord1.setState(1);
            slAuditRecordMapper.insert(slAuditRecord);
                SlAuditRecord slAuditRecord3=new SlAuditRecord();
                slAuditRecord3.setAuditId(slAudit.getId());
                slAuditRecord3.setShenhId(byId.getCompetentId());
                slAuditRecord3.setType(2);
                slAuditRecord3.setState(2);
                slAuditRecord3.setShenhTime(new Date());
                slAuditRecord3.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord3);
            SlAuditRecord slAuditRecord2=new SlAuditRecord();
            slAuditRecord2.setAuditId(slAudit.getId());
            slAuditRecord2.setShenhId(byId.getDirectorId());
            slAuditRecord2.setType(3);
            slAuditRecord2.setState(1);
            slAuditRecordMapper.insert(slAuditRecord);
                SlAuditRecord slAuditRecord2=new SlAuditRecord();
                slAuditRecord2.setAuditId(slAudit.getId());
                slAuditRecord2.setShenhId(byId.getAdministratorId());
                slAuditRecord2.setType(1);
                slAuditRecord2.setState(2);
                slAuditRecord2.setShenhTime(new Date());
                slAuditRecord2.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord2);
            }else if (list2.contains(userid.toString())){
                slAudit.setState(3);
                this.save(slAudit);
                slVolumeProductionCkgl.setAuditStatus(3);
                slVolumeProductionCkgl.setPresentState(1);
                slVolumeProductionCKglMapper.updateById(slVolumeProductionCkgl);
                // 如果是主管
                SlAuditRecord slAuditRecord3=new SlAuditRecord();
                slAuditRecord3.setAuditId(slAudit.getId());
                slAuditRecord3.setShenhId(byId.getCompetentId());
                slAuditRecord3.setType(2);
                slAuditRecord3.setState(2);
                slAuditRecord3.setShenhTime(new Date());
                slAuditRecord3.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord3);
                SlAuditRecord slAuditRecord2=new SlAuditRecord();
                slAuditRecord2.setAuditId(slAudit.getId());
                slAuditRecord2.setShenhId(byId.getAdministratorId());
                slAuditRecord2.setType(1);
                slAuditRecord2.setState(2);
                slAuditRecord2.setShenhTime(new Date());
                slAuditRecord2.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord2);
                SlAuditRecord slAuditRecord4=new SlAuditRecord();
                slAuditRecord4.setAuditId(slAudit.getId());
                slAuditRecord4.setShenhId(byId.getDirectorId());
                slAuditRecord4.setType(3);
                slAuditRecord4.setState(1);
                slAuditRecord4.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord4);
            }else if (list1.contains(userid.toString())){
                // 如果是管理员
                slAudit.setState(2);
                this.save(slAudit);
                slVolumeProductionCkgl.setAuditStatus(2);
                slVolumeProductionCkgl.setPresentState(1);
                slVolumeProductionCKglMapper.updateById(slVolumeProductionCkgl);
                // 如果是主管
                SlAuditRecord slAuditRecord3=new SlAuditRecord();
                slAuditRecord3.setAuditId(slAudit.getId());
                slAuditRecord3.setShenhId(byId.getCompetentId());
                slAuditRecord3.setType(2);
                slAuditRecord3.setState(1);
                slAuditRecord3.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord3);
                SlAuditRecord slAuditRecord2=new SlAuditRecord();
                slAuditRecord2.setAuditId(slAudit.getId());
                slAuditRecord2.setShenhId(byId.getAdministratorId());
                slAuditRecord2.setType(1);
                slAuditRecord2.setState(2);
                slAuditRecord2.setShenhTime(new Date());
                slAuditRecord2.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord2);
                SlAuditRecord slAuditRecord4=new SlAuditRecord();
                slAuditRecord4.setAuditId(slAudit.getId());
                slAuditRecord4.setShenhId(byId.getDirectorId());
                slAuditRecord4.setType(3);
                slAuditRecord4.setState(1);
                slAuditRecord4.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord4);
            }
            if (!list3.contains(userid.toString()) && !list2.contains(userid.toString()) && !list1.contains(userid.toString())){
                this.save(slAudit);
                SlAuditRecord slAuditRecord=new SlAuditRecord();
                slAuditRecord.setAuditId(slAudit.getId());
                slAuditRecord.setShenhId(byId.getAdministratorId());
                slAuditRecord.setType(1);
                slAuditRecord.setState(1);
                slAuditRecord.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord);
                SlAuditRecord slAuditRecord3=new SlAuditRecord();
                slAuditRecord3.setAuditId(slAudit.getId());
                slAuditRecord3.setShenhId(byId.getCompetentId());
                slAuditRecord3.setType(2);
                slAuditRecord3.setState(1);
                slAuditRecord3.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord3);
                SlAuditRecord slAuditRecord4=new SlAuditRecord();
                slAuditRecord4.setAuditId(slAudit.getId());
                slAuditRecord4.setShenhId(byId.getDirectorId());
                slAuditRecord4.setType(3);
                slAuditRecord4.setState(1);
                slAuditRecord4.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord4);
            }
        }
        if (slAudit.getType()==3){
        if(slAuditDTO.getType() == 3){
            SlVolumeProductionZygl slVolumeProductionZygl = slVolumeProductionZyglMapper.selectById(slAuditDTO.getRkId());
            slAudit.setSysId(slVolumeProductionZygl.getSysId());
            slAudit.setManagementId(slVolumeProductionZygl.getManagementId());
            slAudit.setZymanagementId(slVolumeProductionZygl.getBmanagementId());
            SlStoreManagement slStoreManagement = slStoreManagementMapper.selectById(slVolumeProductionZygl.getManagementId());
            String directorId = slStoreManagement.getDirectorId();
            String competentId = slStoreManagement.getCompetentId();
            String administratorId = slStoreManagement.getAdministratorId();
            Long userid = SecurityUtils.getUserId();
            List<String> list1 = Arrays.asList(administratorId.split(","));
            List<String> list2 = Arrays.asList(competentId.split(","));
            List<String> list3 = Arrays.asList(directorId.split(","));
            slAudit.setSysId(slVolumeProductionZygl.getSysId());
            slAudit.setManagementId(slVolumeProductionZygl.getManagementId());
            slAudit.setZymanagementId(slVolumeProductionZygl.getBmanagementId());
            SlStoreManagement byId = slStoreManagementService.getById(slVolumeProductionZygl.getManagementId());
            slAudit.setShenhId(byId.getAdministratorId());
            this.save(slAudit);
            SlAuditRecord slAuditRecord=new SlAuditRecord();
            slAuditRecord.setAuditId(slAudit.getId());
            slAuditRecord.setShenhId(byId.getAdministratorId());
            slAuditRecord.setType(1);
            slAuditRecord.setState(1);
            slAuditRecordMapper.insert(slAuditRecord);
            if (list3.contains(userid.toString())){
                slAudit.setState(4);
                this.save(slAudit);
                slVolumeProductionZygl.setAuditStatus(4);
                slVolumeProductionZygl.setPresentState(3);
                slVolumeProductionZyglMapper.updateById(slVolumeProductionZygl);
                // 主任发起 主管和管理员默认审核通过
                SlAuditRecord slAuditRecord4=new SlAuditRecord();
                slAuditRecord4.setAuditId(slAudit.getId());
                slAuditRecord4.setShenhId(byId.getDirectorId());
                slAuditRecord4.setType(3);
                slAuditRecord4.setState(2);
                slAuditRecord4.setShenhTime(new Date());
                slAuditRecord4.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord4);
            SlAuditRecord slAuditRecord1=new SlAuditRecord();
            slAuditRecord1.setAuditId(slAudit.getId());
            slAuditRecord1.setShenhId(byId.getCompetentId());
            slAuditRecord1.setType(2);
            slAuditRecord1.setState(1);
            slAuditRecordMapper.insert(slAuditRecord);
                SlAuditRecord slAuditRecord3=new SlAuditRecord();
                slAuditRecord3.setAuditId(slAudit.getId());
                slAuditRecord3.setShenhId(byId.getCompetentId());
                slAuditRecord3.setType(2);
                slAuditRecord3.setState(2);
                slAuditRecord3.setShenhTime(new Date());
                slAuditRecord3.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord3);
            SlAuditRecord slAuditRecord2=new SlAuditRecord();
            slAuditRecord2.setAuditId(slAudit.getId());
            slAuditRecord2.setShenhId(byId.getDirectorId());
            slAuditRecord2.setType(3);
            slAuditRecord2.setState(1);
            slAuditRecordMapper.insert(slAuditRecord);
                SlAuditRecord slAuditRecord2=new SlAuditRecord();
                slAuditRecord2.setAuditId(slAudit.getId());
                slAuditRecord2.setShenhId(byId.getAdministratorId());
                slAuditRecord2.setType(1);
                slAuditRecord2.setState(2);
                slAuditRecord2.setShenhTime(new Date());
                slAuditRecord2.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord2);
            }else if (list2.contains(userid.toString())){
                slAudit.setState(3);
                this.save(slAudit);
                slVolumeProductionZygl.setAuditStatus(3);
                slVolumeProductionZygl.setPresentState(1);
                slVolumeProductionZyglMapper.updateById(slVolumeProductionZygl);
                // 如果是主管
                SlAuditRecord slAuditRecord3=new SlAuditRecord();
                slAuditRecord3.setAuditId(slAudit.getId());
                slAuditRecord3.setShenhId(byId.getCompetentId());
                slAuditRecord3.setType(2);
                slAuditRecord3.setState(2);
                slAuditRecord3.setShenhTime(new Date());
                slAuditRecord3.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord3);
                SlAuditRecord slAuditRecord2=new SlAuditRecord();
                slAuditRecord2.setAuditId(slAudit.getId());
                slAuditRecord2.setShenhId(byId.getAdministratorId());
                slAuditRecord2.setType(1);
                slAuditRecord2.setState(2);
                slAuditRecord2.setShenhTime(new Date());
                slAuditRecord2.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord2);
                SlAuditRecord slAuditRecord4=new SlAuditRecord();
                slAuditRecord4.setAuditId(slAudit.getId());
                slAuditRecord4.setShenhId(byId.getDirectorId());
                slAuditRecord4.setType(3);
                slAuditRecord4.setState(1);
                slAuditRecord4.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord4);
            }else if (list1.contains(userid.toString())){
                // 如果是管理员
                slAudit.setState(2);
                this.save(slAudit);
                slVolumeProductionZygl.setAuditStatus(2);
                slVolumeProductionZygl.setPresentState(1);
                slVolumeProductionZyglMapper.updateById(slVolumeProductionZygl);
                // 如果是主管
                SlAuditRecord slAuditRecord3=new SlAuditRecord();
                slAuditRecord3.setAuditId(slAudit.getId());
                slAuditRecord3.setShenhId(byId.getCompetentId());
                slAuditRecord3.setType(2);
                slAuditRecord3.setState(1);
                slAuditRecord3.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord3);
                SlAuditRecord slAuditRecord2=new SlAuditRecord();
                slAuditRecord2.setAuditId(slAudit.getId());
                slAuditRecord2.setShenhId(byId.getAdministratorId());
                slAuditRecord2.setType(1);
                slAuditRecord2.setState(2);
                slAuditRecord2.setShenhTime(new Date());
                slAuditRecord2.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord2);
                SlAuditRecord slAuditRecord4=new SlAuditRecord();
                slAuditRecord4.setAuditId(slAudit.getId());
                slAuditRecord4.setShenhId(byId.getDirectorId());
                slAuditRecord4.setType(3);
                slAuditRecord4.setState(1);
                slAuditRecord4.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord4);
            }
            if (!list3.contains(userid.toString()) && !list2.contains(userid.toString()) && !list1.contains(userid.toString())){
                this.save(slAudit);
                SlAuditRecord slAuditRecord=new SlAuditRecord();
                slAuditRecord.setAuditId(slAudit.getId());
                slAuditRecord.setShenhId(byId.getAdministratorId());
                slAuditRecord.setType(1);
                slAuditRecord.setState(1);
                slAuditRecord.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord);
                SlAuditRecord slAuditRecord3=new SlAuditRecord();
                slAuditRecord3.setAuditId(slAudit.getId());
                slAuditRecord3.setShenhId(byId.getCompetentId());
                slAuditRecord3.setType(2);
                slAuditRecord3.setState(1);
                slAuditRecord3.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord3);
                SlAuditRecord slAuditRecord4=new SlAuditRecord();
                slAuditRecord4.setAuditId(slAudit.getId());
                slAuditRecord4.setShenhId(byId.getDirectorId());
                slAuditRecord4.setType(3);
                slAuditRecord4.setState(1);
                slAuditRecord4.setCreateTime(new Date());
                slAuditRecordMapper.insert(slAuditRecord4);
            }
        }
    }
}