提交 926b28db 编写于 作者: zhouweidong's avatar zhouweidong

dst代码表

上级 7369779a
......@@ -45,6 +45,9 @@ public class DAGridCoreResource {
@Lazy
private DictOptionServiceImpl dictOptionService;
@Autowired
@Lazy
private DAGridCoreResource proxyService;
@RequestMapping(method = RequestMethod.POST, value = "/ibizutil/reportdatas")
......@@ -101,6 +104,67 @@ public class DAGridCoreResource {
return ResponseEntity.ok().body(result);
}
/**
* 获取代码表指定层级结构;(如:全国代码表,只展示js省市代码值)
* 参数 :
* 1.cid:代码表标识
* 2.optionid:父代码项标识
* @param data
* @return
*/
@RequestMapping(method = RequestMethod.POST, value = "/dst/getCodelist")
public ResponseEntity<JSONArray> getCodelist2(@RequestBody JSONObject data) {
JSONArray result = new JSONArray();
String cid = data.getString("cid");
if (StringUtils.isEmpty(cid)){
log.error("未传入代码表标识");
return ResponseEntity.ok().body(result);
}
String optionId = data.getString("optionid");
if (!StringUtils.isEmpty(optionId)){
return proxyService.getCodelist(data);
}
else{
return proxyService.getCodelist3(data);
}
}
@Cacheable( value="getCodelist",key = "'getCodelist:'+#p0.getString(\"cid\")+'||'+#p0.getString(\"optionid\")")
public ResponseEntity<JSONArray> getCodelist3(@RequestBody JSONObject data) {
JSONArray result = new JSONArray();
String cid = data.getString("cid");
if (StringUtils.isEmpty(cid)){
log.error("未指定字典项过滤条件");
return ResponseEntity.ok().body(result);
}
String optionId = data.getString("optionid");
if (StringUtils.isEmpty(optionId)){
log.error("未能获取字典项");
return ResponseEntity.ok().body(result);
}
QueryWrapper<DictOption> queryWrapper = new QueryWrapper();
queryWrapper.eq("cid",cid);
queryWrapper.and(wrapper -> wrapper.eq("val", optionId).or().likeRight("pval",optionId));
queryWrapper.orderByAsc("val");
List<DictOption> list = dictOptionService.list(queryWrapper);
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = null;
for (DictOption entity: list) {
jsonObject = new JSONObject();
jsonObject.put("id",entity.getValue());
jsonObject.put("value",entity.getValue());
jsonObject.put("text",entity.getLabel());
jsonObject.put("label",entity.getLabel());
jsonObject.put("parentValue",entity.getParent());
jsonObject.put("disabled",entity.getDisabled());
jsonArray.add(jsonObject);
}
result = getTrees(jsonArray,"");
return ResponseEntity.ok().body(result);
}
/**
* 递归创建树结构数据
* @param jsonArray
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册