Commit 492c0a95 authored by zhengyi's avatar zhengyi

目的仓、目的地、目的国联动树形结构数据返回

parent 28cdd065
......@@ -135,6 +135,32 @@ public interface WarehouseMapper extends BaseMapperX<WarehouseDO> {
})
List<WarehouseTreeRegionVO> getWarehouseTreeRegionList(@Param("tradeType") Integer tradeType);
@ResultType(WarehouseTreeVO.class)
@Select({
"<script>",
"SELECT",
"w.id as warehouseId,",
"w.title_zh as warehouseTitleZh,",
"w.title_en as warehouseTitleEn,",
"r1.id as guojia,",
"r1.title_zh as guojiaName,",
"r1.title_en as guojiaNameEn,",
"r2.id as shi, ",
"r2.title_zh as shiName, ",
"r2.title_en as shiNameEn ",
"FROM ecw_warehouse w ",
"LEFT JOIN ecw_region r1 ",
"ON w.guojia = r1.id ",
"LEFT JOIN ecw_region r2 ",
"ON w.shi = r2.id ",
"WHERE w.deleted = 0 AND w.`status` =0 ",
"<if test= 'tradeType != null'>",
"AND trade_type =#{tradeType}",
"</when>",
"</script>"
})
List<WarehouseTreeVO> getWarehouseTreeList(@Param("tradeType") Integer tradeType);
@ResultType(List.class)
@Select({
"<script>",
......
......@@ -172,4 +172,8 @@ public interface WarehouseService {
List<WarehouseTreeRegionVO> getWarehouseTreeRegionList(Integer tradeType);
List<WarehouseTreeRegionVO> getRegionList(Integer type, String regionId, String destCountryId, String objectiveId, String destWarehouseId);
List<WarehouseTreeVO> getWarehouseTreeList(Integer tradeType);
}
......@@ -27,6 +27,8 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.commons.lang3.StringUtils;
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
......@@ -60,6 +62,7 @@ public class WarehouseServiceImpl implements WarehouseService {
private DictDataApi dictDataApi;
@Override
@CacheEvict(cacheNames = "jd:warehouse:tree", key = "'all'")
public Long createWarehouse(WarehouseCreateReqVO createReqVO) {
// 插入
WarehouseDO warehouse = WarehouseConvert.INSTANCE.convert(createReqVO);
......@@ -70,6 +73,7 @@ public class WarehouseServiceImpl implements WarehouseService {
@Override
@Transactional(rollbackFor = Exception.class)
@CacheEvict(cacheNames = "jd:warehouse:tree", key = "'all'")
public void updateWarehouse(WarehouseUpdateReqVO updateReqVO) {
Long id = updateReqVO.getId();
// 校验存在
......@@ -507,6 +511,42 @@ public class WarehouseServiceImpl implements WarehouseService {
return warehouseLineMapper.getStartInfoAndDestInfoByLineId(lineId);
}
@Override
@Cacheable(cacheNames = "jd:warehouse:tree", key = "'all'")
public List<WarehouseTreeVO> getWarehouseTreeList(Integer tradeType) {
List<WarehouseTreeVO> list = warehouseMapper.getWarehouseTreeList(tradeType);
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();
v.setChildren(warehouseList);
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);
}
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();
v.setChildren(shiWarehouseList);
WarehouseTreeVO warehouseTreeVO = shiWarehouseList.get(0);
v.setGuojiaNameEn(warehouseTreeVO.getGuojiaNameEn());
v.setGuojiaName(warehouseTreeVO.getGuojiaName());
guojiaList.add(v);
}
return guojiaList;
}
@Override
public List<WarehouseTreeRegionVO> getWarehouseTreeRegionList(Integer tradeType) {
List<WarehouseTreeRegionVO> list = warehouseMapper.getWarehouseTreeRegionList(tradeType);
......@@ -529,7 +569,7 @@ public class WarehouseServiceImpl implements WarehouseService {
@Override
public List<WarehouseTreeRegionVO> getRegionList(Integer type, String regionId, String destCountryId, String objectiveId, String destWarehouseId) {
if (regionId.equals("")) {
if (StringUtils.isBlank(regionId)) {
return new ArrayList();
}
List<WarehouseTreeRegionVO> list =
......
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 WarehouseTreeVO {
@ApiModelProperty("国家区域id")
private Long guojia;
@ApiModelProperty("国家中文名称")
private String guojiaName ;
@ApiModelProperty("国家英文名称")
private String guojiaNameEn ;
@ApiModelProperty("城市区域id")
private Long shi;
@ApiModelProperty("城市中文名称")
private String shiName;
@ApiModelProperty("城市英文名称")
private String shiNameEn;
@ApiModelProperty("仓库id")
private Long warehouseId;
@ApiModelProperty("仓库中文名称")
private String warehouseTitleZh;
@ApiModelProperty("仓库英文名称")
private String warehouseTitleEn;
@ApiModelProperty(value = "子元素", example = "true")
private List<WarehouseTreeVO> children;
}
......@@ -100,6 +100,15 @@ public class WarehouseController {
return success(list);
}
@GetMapping("/getWarehouseTreeList")
@ApiModelProperty("获取仓库区域树形列表")
@ApiImplicitParam(name = "tradeType", value = "进出口类型,1-进口,2-出口", required = false, example = "1", dataTypeClass = Integer.class)
public CommonResult<List<WarehouseTreeVO>> getWarehouseTreeLis(Integer tradeType){
List<WarehouseTreeVO> list = warehouseService.getWarehouseTreeList(tradeType);
return success(list);
}
@GetMapping("/getRegionList")
public CommonResult<List<WarehouseTreeRegionVO>> getRegionList(
@RequestParam(value = "type", required = false) Integer type,
......
......@@ -18,6 +18,7 @@ import cn.iocoder.yudao.module.depository.dal.dataobject.warehouse.WarehouseLine
import cn.iocoder.yudao.module.ecw.service.region.RegionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.ApplicationContext;
import org.springframework.validation.annotation.Validated;
......@@ -175,11 +176,18 @@ public class AppWarehouseController {
return success(idList);
}
@GetMapping("/getWarehouseTreeList")
@ApiModelProperty("获取仓库区域树形列表")
@ApiImplicitParam(name = "tradeType", value = "进出口类型,1-进口,2-出口", required = false, example = "1", dataTypeClass = Integer.class)
public CommonResult<List<WarehouseTreeVO>> getWarehouseTreeLis(Integer tradeType){
List<WarehouseTreeVO> list = warehouseService.getWarehouseTreeList(tradeType);
return success(list);
}
@GetMapping("/getRegionList")
public CommonResult<List<WarehouseTreeRegionVO>> getRegionList(
@RequestParam(value = "type", required = false) Integer type,
public CommonResult<List<WarehouseTreeRegionVO>> getRegionList(@RequestParam(value = "type", required = false) Integer type,
String regionId,String destCountryId,
String objectiveId ,String destWarehouseId){
List<WarehouseTreeRegionVO> list =
......
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