| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.fzzy.igds.constant.Constant; |
| | | import com.fzzy.igds.constant.RedisConst; |
| | | import com.fzzy.igds.mapper.InoutConfMapper; |
| | | import com.fzzy.igds.mapper.InoutSysConfMapper; |
| | | import com.fzzy.igds.domain.Dept; |
| | | import com.fzzy.igds.domain.InoutConf; |
| | | import com.fzzy.igds.domain.InoutSysConf; |
| | | import com.fzzy.igds.mapper.InoutConfMapper; |
| | | import com.fzzy.igds.mapper.InoutSysConfMapper; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | |
| | | public class InoutConfService { |
| | | @Resource |
| | | private ISysDeptService iSysDeptService; |
| | | @Resource |
| | | private CoreDeptService deptService; |
| | | @Resource |
| | | private InoutConfMapper inoutConfMapper; |
| | | @Resource |
| | |
| | | inoutSysConf.setProgressOut("REGISTER-WEIGHT_EMPTY-HANDLE-WEIGHT_FULL-RECORD"); |
| | | this.saveSysConfData(inoutSysConf); |
| | | |
| | | this.flushInoutSysConfCache(inoutSysConf); |
| | | this.flushInoutSysConfCache(); |
| | | } |
| | | |
| | | /** |
| | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | InoutSysConf conf = (InoutSysConf) redisCache.getCacheObject(key); |
| | | if (null == conf) { |
| | | conf = getInoutSysConf(deptId); |
| | | flushInoutSysConfCache(conf); |
| | | flushInoutSysConfCache(); |
| | | } |
| | | return conf; |
| | | } |
| | |
| | | * @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); |
| | | }else { |
| | | queryWrapper.likeRight("dept_id", ContextUtil.subDeptId(null)); |
| | | } |
| | | |
| | | return inoutConfMapper.selectList(queryWrapper); |
| | | } |
| | |
| | | * 设置缓存 |
| | | * |
| | | * @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); |
| | | } |
| | | } |
| | | |
| | | /** |