|
|
|
@ -19,14 +19,19 @@ package com.logpm.basicdata.feign;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataWarehouseEntity; |
|
|
|
|
import com.logpm.basicdata.service.IBasicdataWarehouseService; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springblade.common.constant.RedisKeyConstant; |
|
|
|
|
import org.springblade.core.mp.support.BladePage; |
|
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
|
import org.springblade.core.redis.cache.BladeRedis; |
|
|
|
|
import org.springblade.core.redis.cache.CacheKey; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
@ -46,10 +51,13 @@ import java.util.Objects;
|
|
|
|
|
@ApiIgnore() |
|
|
|
|
@RestController |
|
|
|
|
@AllArgsConstructor |
|
|
|
|
@Slf4j |
|
|
|
|
public class BasicdataWarehouseClient implements IBasicdataWarehouseClient { |
|
|
|
|
|
|
|
|
|
private final IBasicdataWarehouseService warehouseWarehouseService; |
|
|
|
|
|
|
|
|
|
private final BladeRedis bladeRedis; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@GetMapping(TOP) |
|
|
|
|
public BladePage<BasicdataWarehouseEntity> topWarehouse(Integer current, Integer size) { |
|
|
|
@ -97,18 +105,40 @@ public class BasicdataWarehouseClient implements IBasicdataWarehouseClient {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public BasicdataWarehouseEntity getWarehouseEntityByWarehouseCode(String warehouseCode) { |
|
|
|
|
QueryWrapper<BasicdataWarehouseEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.eq("warehouse_code",warehouseCode) |
|
|
|
|
.eq("is_deleted",0) |
|
|
|
|
.eq("enable_status",2); |
|
|
|
|
|
|
|
|
|
List<BasicdataWarehouseEntity> list = warehouseWarehouseService.list(queryWrapper); |
|
|
|
|
|
|
|
|
|
if(!Objects.isNull(list) && !list.isEmpty()){ |
|
|
|
|
return list.get(0); |
|
|
|
|
}else{ |
|
|
|
|
return null; |
|
|
|
|
String key =RedisKeyConstant.BASIC_DATA_WAREHOUSE_KEY + warehouseCode; |
|
|
|
|
BasicdataWarehouseEntity o = bladeRedis.get(key); |
|
|
|
|
log.info(">>> 获取的仓库的信息 o ={}",o); |
|
|
|
|
if(ObjectUtils.isNull(o)){ |
|
|
|
|
QueryWrapper<BasicdataWarehouseEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.eq("warehouse_code",warehouseCode) |
|
|
|
|
.eq("is_deleted",0) |
|
|
|
|
.eq("enable_status",2); |
|
|
|
|
List<BasicdataWarehouseEntity> list = warehouseWarehouseService.list(queryWrapper); |
|
|
|
|
if(!Objects.isNull(list) && !list.isEmpty()){ |
|
|
|
|
|
|
|
|
|
// 寻找中心仓
|
|
|
|
|
for (BasicdataWarehouseEntity basicdataWarehouseEntity : list) { |
|
|
|
|
if(basicdataWarehouseEntity.getFunctionType().equals("2")){ |
|
|
|
|
o = basicdataWarehouseEntity; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 找不到 就去第一个
|
|
|
|
|
if(ObjectUtils.isNull(o)){ |
|
|
|
|
o= list.get(0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 设定缓存时间 1小时的缓存时间
|
|
|
|
|
bladeRedis.setEx(key,o, 60 * 60L); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return o; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -159,11 +189,19 @@ public class BasicdataWarehouseClient implements IBasicdataWarehouseClient {
|
|
|
|
|
@Override |
|
|
|
|
@GetMapping(WAREHOUSEBYDEPARTMENT) |
|
|
|
|
public BasicdataWarehouseEntity getWarehouseByDepartment(String deptId) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper<BasicdataWarehouseEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.eq("department",deptId) |
|
|
|
|
.eq("is_deleted",0) |
|
|
|
|
.eq("enable_status",2); |
|
|
|
|
return warehouseWarehouseService.getOne(queryWrapper); |
|
|
|
|
List<BasicdataWarehouseEntity> list = warehouseWarehouseService.list(queryWrapper); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return list.get(0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|