Commit 5cc0f983 authored by zhengyi's avatar zhengyi

获取仓库区域并行国家、城市、仓库列表

parent 392d0842
......@@ -176,4 +176,5 @@ public interface WarehouseService {
List<WarehouseTreeVO> getWarehouseTreeList(Integer tradeType);
WarehouseListVO getGuojiaAndShiAndWarehouseList(Integer tradeType);
}
......@@ -29,6 +29,7 @@ import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
......@@ -62,7 +63,10 @@ public class WarehouseServiceImpl implements WarehouseService {
private DictDataApi dictDataApi;
@Override
@CacheEvict(cacheNames = "jd:warehouse:tree", key = "#createReqVO.tradeType")
@Caching(evict = {
@CacheEvict(cacheNames = "jd:warehouse:tree", key = "#createReqVO.tradeType"),
@CacheEvict(cacheNames = "jd:warehouse:list", key = "#createReqVO.tradeType")
})
public Long createWarehouse(WarehouseCreateReqVO createReqVO) {
// 插入
WarehouseDO warehouse = WarehouseConvert.INSTANCE.convert(createReqVO);
......@@ -73,7 +77,11 @@ public class WarehouseServiceImpl implements WarehouseService {
@Override
@Transactional(rollbackFor = Exception.class)
@CacheEvict(cacheNames = "jd:warehouse:tree", key = "#updateReqVO.tradeType")
@Caching(evict = {
@CacheEvict(cacheNames = "jd:warehouse:tree", key = "#updateReqVO.tradeType"),
@CacheEvict(cacheNames = "jd:warehouse:list", key = "#updateReqVO.tradeType")
})
public void updateWarehouse(WarehouseUpdateReqVO updateReqVO) {
Long id = updateReqVO.getId();
// 校验存在
......@@ -547,6 +555,44 @@ public class WarehouseServiceImpl implements WarehouseService {
return guojiaList;
}
@Override
@Cacheable(cacheNames = "jd:warehouse:list", key = "#tradeType")
public WarehouseListVO getGuojiaAndShiAndWarehouseList(Integer tradeType) {
WarehouseListVO vo = new WarehouseListVO();
List<WarehouseTreeVO> list = warehouseMapper.getWarehouseTreeList(tradeType);
vo.setWarehouseList(list);
Map<Long, List<WarehouseTreeVO>> shiMap = list.stream()
.collect(Collectors.groupingBy(WarehouseTreeVO::getShi));
List<WarehouseTreeVO> shiVOList = new ArrayList<>();
for (Map.Entry<Long, List<WarehouseTreeVO>> m : shiMap.entrySet()) {
WarehouseTreeVO v = new WarehouseTreeVO();
v.setShi(m.getKey());
List<WarehouseTreeVO> warehouseList = m.getValue();
WarehouseTreeVO warehouseTreeVO = warehouseList.get(0);
v.setShiName(warehouseTreeVO.getShiName());
v.setShiNameEn(warehouseTreeVO.getShiNameEn());
v.setGuojiaNameEn(warehouseTreeVO.getGuojiaNameEn());
v.setGuojiaName(warehouseTreeVO.getGuojiaName());
v.setGuojia(warehouseTreeVO.getGuojia());
shiVOList.add(v);
}
vo.setShiList(shiVOList);
Map<Long, List<WarehouseTreeVO>> guojiaMap = shiVOList.stream()
.collect(Collectors.groupingBy(WarehouseTreeVO::getGuojia));
List<WarehouseTreeVO> guojiaList = new ArrayList<>();
for (Map.Entry<Long, List<WarehouseTreeVO>> entry : guojiaMap.entrySet()) {
WarehouseTreeVO v = new WarehouseTreeVO();
v.setGuojia(entry.getKey());
List<WarehouseTreeVO> shiWarehouseList = entry.getValue();
WarehouseTreeVO warehouseTreeVO = shiWarehouseList.get(0);
v.setGuojiaNameEn(warehouseTreeVO.getGuojiaNameEn());
v.setGuojiaName(warehouseTreeVO.getGuojiaName());
guojiaList.add(v);
}
vo.setGuojiaList(guojiaList);
return vo;
}
@Override
public List<WarehouseTreeRegionVO> getWarehouseTreeRegionList(Integer tradeType) {
List<WarehouseTreeRegionVO> list = warehouseMapper.getWarehouseTreeRegionList(tradeType);
......
package cn.iocoder.yudao.module.depository.vo.warehouse;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel("仓库区域列表值")
public class WarehouseListVO {
@ApiModelProperty("国家区域列表")
private List<WarehouseTreeVO> guojiaList;
@ApiModelProperty("城市区域列表")
private List<WarehouseTreeVO> shiList;
@ApiModelProperty("仓库列表")
private List<WarehouseTreeVO> warehouseList;
}
......@@ -108,6 +108,14 @@ public class WarehouseController {
return success(list);
}
@GetMapping("/getGuojiaAndShiAndWarehouseList")
@ApiOperation("获取仓库区域并行国家、城市、仓库列表")
@ApiImplicitParam(name = "tradeType", value = "进出口类型,1-进口,2-出口", required = false, example = "1", dataTypeClass = Integer.class)
public CommonResult<WarehouseListVO> getGuojiaAndShiAndWarehouseList(Integer tradeType){
WarehouseListVO warehouseListVO = warehouseService.getGuojiaAndShiAndWarehouseList(tradeType);
return success(warehouseListVO);
}
@GetMapping("/getRegionList")
public CommonResult<List<WarehouseTreeRegionVO>> getRegionList(
......
......@@ -184,6 +184,13 @@ public class AppWarehouseController {
return success(list);
}
@GetMapping("/getGuojiaAndShiAndWarehouseList")
@ApiOperation("获取仓库区域并行国家、城市、仓库列表")
@ApiImplicitParam(name = "tradeType", value = "进出口类型,1-进口,2-出口", required = false, example = "1", dataTypeClass = Integer.class)
public CommonResult<WarehouseListVO> getGuojiaAndShiAndWarehouseList(Integer tradeType){
WarehouseListVO warehouseListVO = warehouseService.getGuojiaAndShiAndWarehouseList(tradeType);
return success(warehouseListVO);
}
@GetMapping("/getRegionList")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment