6 changed files with 174 additions and 39 deletions
@ -0,0 +1,58 @@ |
|||
package com.kms.yxgh.common.controller; |
|||
|
|||
import com.kms.yg.df.domain.BsSgcDfJbxx; |
|||
import com.kms.yg.df.service.BsSgcDfJbxxService; |
|||
import com.kms.yg.sz.domain.BsSgcSzGcda; |
|||
import com.kms.yg.sz.service.BsSgcSzGcdaService; |
|||
import com.kms.yxgh.base.Response; |
|||
import com.kms.yxgh.common.dto.ObjectInfoDto; |
|||
import com.kms.yxgh.common.service.SyDictService; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import lombok.AllArgsConstructor; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* @ClassName: ObjectInfoController |
|||
* @Description: TODO |
|||
* @Date: 2024/3/19 下午5:01 |
|||
* * |
|||
* @author: hxh |
|||
* @version: 1.0 |
|||
*/ |
|||
@RestController |
|||
@AllArgsConstructor |
|||
@RequestMapping("/run/api/object") |
|||
@Api(tags = "大屏对象详细相关") |
|||
public class ObjectInfoController { |
|||
|
|||
private final BsSgcDfJbxxService bsSgcDfJbxxService; |
|||
private final BsSgcSzGcdaService bsSgcSzGcdaService; |
|||
private final SyDictService syDictService; |
|||
|
|||
//通过类型和编码查询对象详细信息
|
|||
@GetMapping("/info/{type}/{code}") |
|||
@ApiOperation("通过类型和编码查询对象详细信息") |
|||
public Response<ObjectInfoDto> info(@PathVariable String type, @PathVariable String code) { |
|||
if ("1".equals(type)) { |
|||
BsSgcDfJbxx bsSgcDfJbxx = bsSgcDfJbxxService.selectByDikeCode(code); |
|||
ObjectInfoDto objectInfoDto = new ObjectInfoDto(); |
|||
objectInfoDto.setCode(bsSgcDfJbxx.getDikeCode()); |
|||
objectInfoDto.setName(bsSgcDfJbxx.getDikeName()); |
|||
objectInfoDto.setAdcd(bsSgcDfJbxx.getAdcd()); |
|||
objectInfoDto.setRiverLocation(bsSgcDfJbxx.getRiverLocation()); |
|||
objectInfoDto.setGrad(syDictService.get("embankment_level", bsSgcDfJbxx.getDikeGrad()).getDictLabel()); |
|||
} else if ("2".equals(type)) { |
|||
BsSgcSzGcda bsSgcSzGcda = bsSgcSzGcdaService.selectByWagaCode(code); |
|||
ObjectInfoDto objectInfoDto = new ObjectInfoDto(); |
|||
objectInfoDto.setCode(bsSgcSzGcda.getWagaCode()); |
|||
objectInfoDto.setName(bsSgcSzGcda.getWagaName()); |
|||
objectInfoDto.setAdcd(bsSgcSzGcda.getAdcd()); |
|||
objectInfoDto.setGrad(syDictService.get("building_level", bsSgcSzGcda.getEngScal()).getDictLabel()); |
|||
} |
|||
return Response.fail(); |
|||
} |
|||
} |
@ -0,0 +1,30 @@ |
|||
package com.kms.yxgh.common.dto; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @ClassName: ObjectInfoDto |
|||
* @Description: TODO |
|||
* @Date: 2024/3/19 下午5:19 |
|||
* * |
|||
* @author: hxh |
|||
* @version: 1.0 |
|||
*/ |
|||
|
|||
@Data |
|||
@ApiModel(value = "对象信息") |
|||
public class ObjectInfoDto { |
|||
|
|||
@ApiModelProperty("编码") |
|||
private String code; |
|||
@ApiModelProperty("名称") |
|||
private String name; |
|||
@ApiModelProperty("行政区划") |
|||
private String adcd; |
|||
@ApiModelProperty("所属河流") |
|||
private String riverLocation; |
|||
@ApiModelProperty("级别") |
|||
private String grad; |
|||
} |
@ -0,0 +1,58 @@ |
|||
package com.kms.yxgh.common.service; |
|||
|
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|||
import com.github.benmanes.caffeine.cache.Caffeine; |
|||
import com.github.benmanes.caffeine.cache.LoadingCache; |
|||
import com.kms.system.mapper.SysDictDataMapper; |
|||
import com.shuili.common.core.domain.entity.SysDictData; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import javax.annotation.PostConstruct; |
|||
import java.io.Serializable; |
|||
import java.util.concurrent.TimeUnit; |
|||
|
|||
/** |
|||
* @ClassName: SyDictService |
|||
* @Description: TODO |
|||
* @Date: 2024/3/19 下午5:23 |
|||
* * |
|||
* @author: hxh |
|||
* @version: 1.0 |
|||
*/ |
|||
|
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class SyDictService { |
|||
|
|||
|
|||
private final SysDictDataMapper dictDataMapper; |
|||
|
|||
private LoadingCache<DictKey, SysDictData> dictDataCache; |
|||
|
|||
@PostConstruct |
|||
private void init() { |
|||
this.dictDataCache = Caffeine.newBuilder() |
|||
.maximumSize(1000) |
|||
.expireAfterWrite(10, TimeUnit.MINUTES) |
|||
.build(key -> dictDataMapper.selectOne(Wrappers.<SysDictData>lambdaQuery() |
|||
.eq(SysDictData::getDictType, key.getDictType()) |
|||
.eq(SysDictData::getDictValue, key.getDictValue()))); |
|||
} |
|||
|
|||
public SysDictData get(String dictType, String dictValue) { |
|||
return dictDataCache.get(new DictKey(dictType, dictValue)); |
|||
} |
|||
|
|||
@Data |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
private static class DictKey implements Serializable { |
|||
private String dictType; |
|||
private String dictValue; |
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue