| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.fzzy.igds.constant.RedisConst; |
| | | import com.fzzy.igds.domain.Depot; |
| | | import com.fzzy.igds.domain.DepotStore; |
| | | import com.fzzy.igds.mapper.DepotMapper; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | |
| | | } |
| | | |
| | | return depotMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | /** |
| | | * 根据库存表信息,更新仓库库存 |
| | | * @param data |
| | | */ |
| | | public void updateByDepotStore(DepotStore data) { |
| | | UpdateWrapper<Depot> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.eq("id", data.getDepotId()).set("storage_real", data.getStorageReal()); |
| | | |
| | | depotMapper.update(null, updateWrapper); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (StringUtils.isEmpty(companyId)) { |
| | | companyId = ContextUtil.getCompanyId(); |
| | | } |
| | | String patten = RedisConst.buildKey(companyId, RedisConst.KEY_DEPOT) + "*"; |
| | | |
| | | Collection<String> keys = redisCache.keys(patten); |
| | | if (null == keys) { |
| | | return null; |
| | | } |
| | | |
| | | List<Depot> list = new ArrayList<>(); |
| | | for (String key : keys) { |
| | | list.add((Depot) redisCache.getCacheObject(key)); |
| | | |
| | | String patten = RedisConst.buildKey(companyId, RedisConst.KEY_DEPOT) + "*"; |
| | | Collection<String> keys = redisCache.keys(patten); |
| | | if (null != keys) { |
| | | for (String key : keys) { |
| | | list.add((Depot) redisCache.getCacheObject(key)); |
| | | } |
| | | } |
| | | |
| | | //缓存获取为空,则查询数据库 |
| | | if (list.size() < 1) { |
| | | if (list.isEmpty()) { |
| | | list = this.getData(companyId,null, false); |
| | | setCacheDepotList(list, companyId); |
| | | } |
| | | |
| | | //重新排序 |
| | | Collections.sort(list, (p1, p2) -> p1.getOrderNum() - p2.getOrderNum()); |
| | | if(!list.isEmpty()){ |
| | | //重新排序 |
| | | Collections.sort(list, (p1, p2) -> p1.getOrderNum() - p2.getOrderNum()); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | |
| | | result.add(depot); |
| | | } |
| | | } |
| | | //重新排序 |
| | | Collections.sort(result, (p1, p2) -> p1.getOrderNum() - p2.getOrderNum()); |
| | | if(!result.isEmpty()){ |
| | | //重新排序 |
| | | Collections.sort(list, (p1, p2) -> p1.getOrderNum() - p2.getOrderNum()); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | |
| | | } |
| | | return depot; |
| | | } |
| | | |
| | | /** |
| | | * 获取仓库信息-根据仓库名称获取仓库ID |
| | | * |
| | | * @param deptId |
| | | * @return |
| | | */ |
| | | public String getDepotId(String deptId, String depotName) { |
| | | if (StringUtils.isEmpty(deptId)) { |
| | | return null; |
| | | } |
| | | if (StringUtils.isEmpty(depotName)) { |
| | | return null; |
| | | } |
| | | |
| | | List<Depot> depotList = getCacheDepotList(ContextUtil.getCompanyId(), deptId); |
| | | if(null == depotList || depotList.isEmpty()){ |
| | | return null; |
| | | } |
| | | for (Depot depot : depotList) { |
| | | if(depotName.equals(depot.getName())){ |
| | | return depot.getId(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |