czt
2026-02-07 2ebf9333d0a53949ff647444064a4c2b73c52fd3
fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutConfService.java
@@ -4,6 +4,7 @@
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.fzzy.igds.constant.Constant;
import com.fzzy.igds.constant.RedisConst;
import com.fzzy.igds.domain.Dept;
import com.fzzy.igds.mapper.InoutConfMapper;
import com.fzzy.igds.mapper.InoutSysConfMapper;
import com.fzzy.igds.domain.InoutConf;
@@ -16,6 +17,7 @@
import com.ruoyi.system.service.ISysDeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@@ -30,6 +32,8 @@
public class InoutConfService {
    @Resource
    private ISysDeptService iSysDeptService;
    @Resource
    private CoreDeptService deptService;
    @Resource
    private InoutConfMapper inoutConfMapper;
    @Resource
@@ -62,6 +66,22 @@
    }
    /**
     * 根据条件查询流程信息
     *
     * @param deptId
     * @return
     */
    public InoutSysConf getInoutSysConf(String deptId) {
        List<InoutSysConf> list = listInoutSysConf(deptId, null);
        if (null == list || list.isEmpty()) {
            return null;
        }
        return list.get(0);
    }
    /**
     * 查询流程配置
     *
     * @return
@@ -89,7 +109,7 @@
        inoutSysConf.setProgressOut("REGISTER-WEIGHT_EMPTY-HANDLE-WEIGHT_FULL-RECORD");
        this.saveSysConfData(inoutSysConf);
        this.flushInoutSysConfCache(inoutSysConf);
        this.flushInoutSysConfCache();
    }
    /**
@@ -121,17 +141,22 @@
            inoutSysConfMapper.update(data, new UpdateWrapper<InoutSysConf>().eq("dept_id", data.getDeptId()));
        }
        this.flushInoutSysConfCache(data);
        this.flushInoutSysConfCache();
    }
    /**
     * 设置缓存
     *
     * @param data
     */
    public void flushInoutSysConfCache(InoutSysConf data) {
        String key = RedisConst.buildKey(data.getDeptId(), Constant.CACHE_INOUT_SYS_CONF);
        redisCache.setCacheObject(key, data);
    public void flushInoutSysConfCache() {
        List<InoutSysConf> list = listInoutSysConf(null,null);
        if(null == list || list.isEmpty()){
            return;
        }
        for (InoutSysConf conf : list) {
            String key = RedisConst.buildKey(conf.getDeptId(), Constant.CACHE_INOUT_SYS_CONF);
            redisCache.setCacheObject(key, conf);
        }
    }
    /**
@@ -143,7 +168,12 @@
     */
    public InoutSysConf getCacheInoutSysConf(String companyId, String deptId) {
        String key = RedisConst.buildKey(deptId, Constant.CACHE_INOUT_SYS_CONF);
        return (InoutSysConf) redisCache.getCacheObject(key);
        InoutSysConf conf = (InoutSysConf) redisCache.getCacheObject(key);
        if (null == conf) {
            conf = getInoutSysConf(deptId);
            flushInoutSysConfCache();
        }
        return conf;
    }
    /*--------------- 出入库设备 ---------------*/
@@ -154,16 +184,16 @@
     * @return
     */
    public List<InoutConf> getInoutConfList(String companyId, String deptId) {
        QueryWrapper<InoutConf> queryWrapper = new QueryWrapper<>();
        if (StringUtils.isEmpty(companyId)) {
            companyId = ContextUtil.getCompanyId();
        }
        if (StringUtils.isEmpty(deptId)) {
            deptId = ContextUtil.subDeptId(null);
        }
        QueryWrapper<InoutConf> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("dept_id", deptId);
        queryWrapper.eq("company_id", companyId);
        if (StringUtils.isNotEmpty(deptId)) {
            queryWrapper.eq("dept_id", deptId);
        }
        return inoutConfMapper.selectList(queryWrapper);
    }
@@ -194,7 +224,7 @@
            data.setUpdateBy(ContextUtil.getLoginUserName());
            data.setUpdateTime(new Date());
            inoutConfMapper.insert(data);
        }else {
        } else {
            data.setUpdateBy(ContextUtil.getLoginUserName());
            data.setUpdateTime(new Date());
            inoutConfMapper.updateById(data);
@@ -217,12 +247,21 @@
     * 设置缓存
     *
     * @param companyId
     * @param deptId
     */
    public void flushInoutConfCache(String companyId, String deptId) {
        List<InoutConf> list = this.getInoutConfList(companyId, deptId);
        String key = RedisConst.buildKey(companyId, Constant.CACHE_INOUT_CONF_LIST, deptId);
        redisCache.setCacheObject(key, list);
    public void flushInoutConfCache(String companyId) {
        List<Dept> depts = deptService.listDept(null, companyId, null);
        if(null == depts || depts.isEmpty()){
            return;
        }
        List<InoutConf> inoutConfList;
        for (Dept dept : depts) {
            inoutConfList = this.getInoutConfList(companyId, dept.getId());
            if(null == inoutConfList || inoutConfList.isEmpty()){
                continue;
            }
            String key = RedisConst.buildKey(companyId, Constant.CACHE_INOUT_CONF_LIST, dept.getId());
            redisCache.setCacheObject(key, inoutConfList);
        }
    }
    /**