package com.vci.web.controller;
|
|
import com.vci.pagemodel.OsBtmTypeAttributeVO;
|
import com.vci.pagemodel.OsLinkTypeAttributeVO;
|
import com.vci.pagemodel.OsLinkTypeVO;
|
import com.vci.starter.web.annotation.controller.VciUnCheckRight;
|
import com.vci.starter.web.pagemodel.BaseQueryObject;
|
import com.vci.starter.web.pagemodel.BaseResult;
|
import com.vci.starter.web.pagemodel.DataGrid;
|
import com.vci.starter.web.util.VciBaseUtil;
|
import com.vci.web.service.OsLinkTypeServiceI;
|
import org.apache.commons.lang3.StringUtils;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.util.CollectionUtils;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.util.List;
|
import java.util.stream.Collectors;
|
|
/**
|
* 链接类型的控制器
|
* @author weidy
|
* @date 2022-3-26
|
*/
|
@RequestMapping("/linkTypeController")
|
@RestController
|
public class OsLinkTypeController {
|
|
/**
|
* 链接类型
|
*/
|
@Autowired
|
private OsLinkTypeServiceI linkTypeService;
|
|
/**
|
* 日志
|
*/
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
/**
|
* 链接类型的列表
|
* @param baseQueryObject 查询对象
|
* @return 链接类型的显示对象
|
*/
|
@GetMapping("/gridLinkType")
|
public DataGrid<OsLinkTypeVO> gridLinkType(BaseQueryObject baseQueryObject){
|
return linkTypeService.gridLinkType(baseQueryObject);
|
}
|
|
/**
|
* 查询所有的链接类型名称,可用于属性池的连接类型选择时的对话框
|
* @return 链接类型的显示对象
|
*/
|
@GetMapping("/getAllLtName")
|
@VciUnCheckRight
|
public BaseResult getAllLtName(){
|
try {
|
return BaseResult.dataList(linkTypeService.getAllLtName());
|
}catch (Exception e) {
|
e.printStackTrace();
|
String exceptionMessage = "链接类型列表查询时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e);
|
logger.error(exceptionMessage);
|
return BaseResult.fail(exceptionMessage);
|
}
|
}
|
|
/**
|
* 获取链接类型包含的属性
|
* @param linkTypeOid 链接类型的主键
|
* @param baseQueryObject 查询对象
|
* @return 属性的信息
|
*/
|
@GetMapping("/gridAttributeByLinkTypeOid")
|
public DataGrid<OsLinkTypeAttributeVO> gridAttributeByLinkTypeOid(String linkTypeOid, BaseQueryObject baseQueryObject){
|
if(StringUtils.isBlank(linkTypeOid)){
|
return new DataGrid<OsLinkTypeAttributeVO>();
|
}
|
String attrId = baseQueryObject.getConditionMap().containsKey("name")?baseQueryObject.getConditionMap().get("name").replace("*",""):"";
|
String attrName = baseQueryObject.getConditionMap().containsKey("label") ? baseQueryObject.getConditionMap().get("label").replace("*","") : "";
|
OsLinkTypeVO linkTypeVO = linkTypeService.selectByOid(linkTypeOid);
|
List<OsLinkTypeAttributeVO> boAttrs = linkTypeService.listAttributeByLinkId(linkTypeVO.getId());
|
List<OsLinkTypeAttributeVO> attrList = boAttrs.stream().filter(s->{
|
boolean usedFlag = true;
|
if(StringUtils.isNotBlank(attrId) && !s.getId().contains(attrId)){
|
usedFlag = false;
|
}
|
if(StringUtils.isNotBlank(attrName) && !s.getName().contains(attrName)){
|
usedFlag = false;
|
}
|
return usedFlag;
|
}).collect(Collectors.toList());
|
DataGrid<OsLinkTypeAttributeVO> dataGrid = new DataGrid<OsLinkTypeAttributeVO>();
|
dataGrid.setTotal(attrList.size());;
|
dataGrid.setData(attrList);
|
return dataGrid;
|
}
|
|
/**
|
* 检查链接类型中关联的业务类型的属性有不同的内容
|
* @param linkTypeOid 链接类型的主键
|
* @return 差异的属性
|
*/
|
@PostMapping("/checkAttributeTypeDifferent")
|
public BaseResult<OsBtmTypeAttributeVO> checkAttributeTypeDifferent(String linkTypeOid){
|
if(StringUtils.isBlank(linkTypeOid)){
|
return BaseResult.success();
|
}
|
List<OsBtmTypeAttributeVO> attributeVOList = linkTypeService.checkAttributeTypeDifferent(linkTypeOid);
|
if(!CollectionUtils.isEmpty(attributeVOList)) {
|
BaseResult result = BaseResult.fail("有不同");
|
result.setData(attributeVOList);
|
return result;
|
}else{
|
return BaseResult.success();
|
}
|
}
|
}
|