组态添加全局的概念

This commit is contained in:
2025-12-23 14:42:32 +08:00
parent bc6f3dca80
commit c7dce89d36
4 changed files with 46 additions and 37 deletions

View File

@@ -62,6 +62,8 @@ public class CsConfigurationParm {
private String id; private String id;
@ApiModelProperty(value = "当前用户ID") @ApiModelProperty(value = "当前用户ID")
private String currentUserId; private String currentUserId;
@ApiModelProperty(value = "当前用户角色")
private String roleCode;
} }

View File

@@ -31,6 +31,8 @@ public class CsConfigurationVO extends BaseEntity {
private Integer orderBy; private Integer orderBy;
private Integer scope;
private List<String> projectIds; private List<String> projectIds;

View File

@@ -7,14 +7,15 @@
<id column="id" jdbcType="VARCHAR" property="id" /> <id column="id" jdbcType="VARCHAR" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" /> <result column="name" jdbcType="VARCHAR" property="name" />
<result column="status" jdbcType="INTEGER" property="status" /> <result column="status" jdbcType="INTEGER" property="status" />
<result column="scope" jdbcType="INTEGER" property="scope" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" /> <result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" /> <result column="update_by" jdbcType="VARCHAR" property="updateBy" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
<!--@mbg.generated--> <!--@mbg.generated-->
id, `name`, `status`, create_by, create_time, update_by, update_time id, `name`, `status`, `scope`,create_by, create_time, update_by, update_time
</sql> </sql>
<select id="queryPage" resultMap="BaseResultMap"> <select id="queryPage" resultMap="BaseResultMap">
@@ -24,7 +25,11 @@
<foreach collection="list" index="index" item="item" open="(" separator="," close=")"> <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
AND (a.scope = 1 OR (a.scope = 0 AND a.create_by = #{userId})) AND (a.scope = 1
<if test="userId != null and userId != ''">
OR (a.scope = 0 AND a.create_by = #{userId})
</if>
)
<if test="temp!=null and temp.searchValue != null and temp.searchValue !=''"> <if test="temp!=null and temp.searchValue != null and temp.searchValue !=''">
AND a.name like concat(concat("%",#{temp.searchValue}),"%") AND a.name like concat(concat("%",#{temp.searchValue}),"%")
</if> </if>

View File

@@ -33,7 +33,7 @@ import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* *
* Description: * Description:
* Date: 2023/5/31 10:53【需求编号】 * Date: 2023/5/31 10:53【需求编号】
* *
@@ -42,7 +42,7 @@ import java.util.stream.Collectors;
*/ */
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class CsConfigurationServiceImpl extends ServiceImpl<CsConfigurationMapper, CsConfigurationPO> implements CsConfigurationService{ public class CsConfigurationServiceImpl extends ServiceImpl<CsConfigurationMapper, CsConfigurationPO> implements CsConfigurationService {
private final FileStorageUtil fileStorageUtil; private final FileStorageUtil fileStorageUtil;
private final UserFeignClient userFeignClient; private final UserFeignClient userFeignClient;
@@ -53,17 +53,16 @@ public class CsConfigurationServiceImpl extends ServiceImpl<CsConfigurationMappe
public boolean add(CsConfigurationParm csConfigurationParm) { public boolean add(CsConfigurationParm csConfigurationParm) {
CsConfigurationPO csConfigurationPO = new CsConfigurationPO(); CsConfigurationPO csConfigurationPO = new CsConfigurationPO();
BeanUtils.copyProperties(csConfigurationParm,csConfigurationPO); BeanUtils.copyProperties(csConfigurationParm, csConfigurationPO);
List<String> projectIds = csConfigurationParm.getProjectIds(); List<String> projectIds = csConfigurationParm.getProjectIds();
if(CollectionUtils.isEmpty(projectIds)){ String projects = "";
throw new BusinessException("请选择项目"); if (!CollectionUtils.isEmpty(projectIds)) {
projects = String.join(",", projectIds);
} }
String projects = String.join(",", projectIds);
csConfigurationPO.setProjectIds(projects); csConfigurationPO.setProjectIds(projects);
//排序不填给个100往后排 //排序不填给个100往后排
csConfigurationPO.setOrderBy(Objects.isNull(csConfigurationParm.getOrderBy())?100:csConfigurationParm.getOrderBy()); csConfigurationPO.setOrderBy(Objects.isNull(csConfigurationParm.getOrderBy()) ? 100 : csConfigurationParm.getOrderBy());
csConfigurationPO.setImagePath(csConfigurationParm.getFileContent()); csConfigurationPO.setImagePath(csConfigurationParm.getFileContent());
csConfigurationPO.setStatus("1"); csConfigurationPO.setStatus("1");
@@ -71,7 +70,7 @@ public class CsConfigurationServiceImpl extends ServiceImpl<CsConfigurationMappe
String name = csConfigurationPO.getName(); String name = csConfigurationPO.getName();
Integer count = this.lambdaQuery().eq(CsConfigurationPO::getName, name).eq(CsConfigurationPO::getStatus, "1").count(); Integer count = this.lambdaQuery().eq(CsConfigurationPO::getName, name).eq(CsConfigurationPO::getStatus, "1").count();
if(count>1){ if (count > 1) {
throw new BusinessException("存在相同的组态项目名称在其他工程项目中,无法新建"); throw new BusinessException("存在相同的组态项目名称在其他工程项目中,无法新建");
} }
return save; return save;
@@ -80,30 +79,30 @@ public class CsConfigurationServiceImpl extends ServiceImpl<CsConfigurationMappe
@Override @Override
public boolean audit(CsConfigurationParm.CsConfigurationAuditParam auditParm) { public boolean audit(CsConfigurationParm.CsConfigurationAuditParam auditParm) {
CsConfigurationPO csConfigurationPO = new CsConfigurationPO(); CsConfigurationPO csConfigurationPO = new CsConfigurationPO();
if(Objects.equals(auditParm.getStatus(),"0")){ if (Objects.equals(auditParm.getStatus(), "0")) {
csConfigurationPO.setId(auditParm.getId()); csConfigurationPO.setId(auditParm.getId());
csConfigurationPO.setStatus("0"); csConfigurationPO.setStatus("0");
boolean b = this.updateById(csConfigurationPO); boolean b = this.updateById(csConfigurationPO);
return b; return b;
} }
Integer count = this.lambdaQuery().eq(CsConfigurationPO::getName, auditParm.getName()).ne(CsConfigurationPO::getId,auditParm.getId()).eq(CsConfigurationPO::getStatus, "1").count(); Integer count = this.lambdaQuery().eq(CsConfigurationPO::getName, auditParm.getName()).ne(CsConfigurationPO::getId, auditParm.getId()).eq(CsConfigurationPO::getStatus, "1").count();
if(count>0){ if (count > 0) {
throw new BusinessException("修改名称失败,存在相同的组态项目"); throw new BusinessException("修改名称失败,存在相同的组态项目");
} }
BeanUtils.copyProperties(auditParm,csConfigurationPO); BeanUtils.copyProperties(auditParm, csConfigurationPO);
List<String> projectIds = auditParm.getProjectIds(); List<String> projectIds = auditParm.getProjectIds();
if(!CollectionUtils.isEmpty(projectIds)){ if (!CollectionUtils.isEmpty(projectIds)) {
String projects = String.join(",", projectIds); String projects = String.join(",", projectIds);
csConfigurationPO.setProjectIds(projects); csConfigurationPO.setProjectIds(projects);
} }
if(!Objects.isNull(auditParm.getOrderBy())){ if (!Objects.isNull(auditParm.getOrderBy())) {
csConfigurationPO.setOrderBy(auditParm.getOrderBy()==0?100:auditParm.getOrderBy()); csConfigurationPO.setOrderBy(auditParm.getOrderBy() == 0 ? 100 : auditParm.getOrderBy());
} }
if(!Objects.isNull(auditParm.getFileContent())){ if (!Objects.isNull(auditParm.getFileContent())) {
String s = fileStorageUtil.uploadStream(writeJsonStringToInputStream(auditParm.getFileContent()), HarmonicConstant.CONFIGURATIONPATH, HarmonicConstant.CONFIGURATIONNAME); String s = fileStorageUtil.uploadStream(writeJsonStringToInputStream(auditParm.getFileContent()), HarmonicConstant.CONFIGURATIONPATH, HarmonicConstant.CONFIGURATIONNAME);
csConfigurationPO.setImagePath(s); csConfigurationPO.setImagePath(s);
} }
@@ -115,19 +114,21 @@ public class CsConfigurationServiceImpl extends ServiceImpl<CsConfigurationMappe
@Override @Override
public IPage<CsConfigurationVO> queryPage(CsConfigurationParm.CsConfigurationQueryParam csConfigurationQueryParam) { public IPage<CsConfigurationVO> queryPage(CsConfigurationParm.CsConfigurationQueryParam csConfigurationQueryParam) {
Page<CsConfigurationVO> returnpage = new Page<> (csConfigurationQueryParam.getPageNum(), csConfigurationQueryParam.getPageSize ( )); Page<CsConfigurationVO> returnpage = new Page<>(csConfigurationQueryParam.getPageNum(), csConfigurationQueryParam.getPageSize());
Page<CsConfigurationPO> temppage = new Page<> (csConfigurationQueryParam.getPageNum(), csConfigurationQueryParam.getPageSize ( )); Page<CsConfigurationPO> temppage = new Page<>(csConfigurationQueryParam.getPageNum(), csConfigurationQueryParam.getPageSize());
List<String> data1 = roleEngineerDevFeignClient.getRoleProject().getData(); List<String> data1 = roleEngineerDevFeignClient.getRoleProject().getData();
if(CollectionUtils.isEmpty(data1)){ // if (CollectionUtils.isEmpty(data1)) {
return returnpage; // return returnpage;
} // }
//+无线项目id //+无线项目id
data1.add(DataParam.WIRELESS_PROJECT_ID); data1.add(DataParam.WIRELESS_PROJECT_ID);
String userId = csConfigurationQueryParam.getCurrentUserId();
String roleCode = csConfigurationQueryParam.getRoleCode();
if (roleCode.indexOf("operation_manager") > 0) {
Page<CsConfigurationPO> csConfigurationPOPage = this.getBaseMapper().queryPage(temppage,csConfigurationQueryParam,data1,csConfigurationQueryParam.getCurrentUserId()); userId = null;
}
Page<CsConfigurationPO> csConfigurationPOPage = this.getBaseMapper().queryPage(temppage, csConfigurationQueryParam, data1, userId);
// QueryWrapper<CsConfigurationPO> query = new QueryWrapper<>(); // QueryWrapper<CsConfigurationPO> query = new QueryWrapper<>();
// query.like(StringUtils.isNotBlank(csConfigurationQueryParam.getSearchValue()),CsConfigurationPO.COL_NAME,csConfigurationQueryParam.getSearchValue()). // query.like(StringUtils.isNotBlank(csConfigurationQueryParam.getSearchValue()),CsConfigurationPO.COL_NAME,csConfigurationQueryParam.getSearchValue()).
// le (StringUtils.isNotBlank (csConfigurationQueryParam.getSearchEndTime()), CsConfigurationPO.COL_CREATE_TIME, csConfigurationQueryParam.getSearchEndTime ( )). // le (StringUtils.isNotBlank (csConfigurationQueryParam.getSearchEndTime()), CsConfigurationPO.COL_CREATE_TIME, csConfigurationQueryParam.getSearchEndTime ( )).
@@ -136,7 +137,7 @@ public class CsConfigurationServiceImpl extends ServiceImpl<CsConfigurationMappe
// Page<CsConfigurationPO> csConfigurationPOPage = this.getBaseMapper().selectPage(temppage, query); // Page<CsConfigurationPO> csConfigurationPOPage = this.getBaseMapper().selectPage(temppage, query);
List<String> collect1 = csConfigurationPOPage.getRecords().stream().map(CsConfigurationPO::getCreateBy).collect(Collectors.toList()); List<String> collect1 = csConfigurationPOPage.getRecords().stream().map(CsConfigurationPO::getCreateBy).collect(Collectors.toList());
Map<String, String> collect2; Map<String, String> collect2;
if(!CollectionUtils.isEmpty(collect1)){ if (!CollectionUtils.isEmpty(collect1)) {
List<User> data = userFeignClient.appuserByIdList(collect1).getData(); List<User> data = userFeignClient.appuserByIdList(collect1).getData();
collect2 = data.stream().collect(Collectors.toMap(User::getId, User::getName, (e1, e2) -> e1 + "," + e2)); collect2 = data.stream().collect(Collectors.toMap(User::getId, User::getName, (e1, e2) -> e1 + "," + e2));
@@ -148,16 +149,16 @@ public class CsConfigurationServiceImpl extends ServiceImpl<CsConfigurationMappe
CsConfigurationVO csDevModelPageVO = new CsConfigurationVO(); CsConfigurationVO csDevModelPageVO = new CsConfigurationVO();
BeanUtils.copyProperties(page, csDevModelPageVO); BeanUtils.copyProperties(page, csDevModelPageVO);
if(StringUtils.isEmpty(page.getProjectIds())){ if (StringUtils.isEmpty(page.getProjectIds())) {
csDevModelPageVO.setProjectIds(new ArrayList<>()); csDevModelPageVO.setProjectIds(new ArrayList<>());
}else { } else {
csDevModelPageVO.setProjectIds( Arrays.asList(page.getProjectIds().split(","))); csDevModelPageVO.setProjectIds(Arrays.asList(page.getProjectIds().split(",")));
} }
if(Objects.isNull(page.getImagePath())){ if (Objects.isNull(page.getImagePath())) {
csDevModelPageVO.setFileContent(null); csDevModelPageVO.setFileContent(null);
}else { } else {
InputStream fileStream = fileStorageUtil.getFileStream(page.getImagePath()); InputStream fileStream = fileStorageUtil.getFileStream(page.getImagePath());
String text = new BufferedReader( String text = new BufferedReader(
new InputStreamReader(fileStream, StandardCharsets.UTF_8)) new InputStreamReader(fileStream, StandardCharsets.UTF_8))
@@ -174,13 +175,12 @@ public class CsConfigurationServiceImpl extends ServiceImpl<CsConfigurationMappe
returnpage.setTotal(csConfigurationPOPage.getTotal()); returnpage.setTotal(csConfigurationPOPage.getTotal());
return returnpage; return returnpage;
} }
@Override @Override
public String uploadImage(MultipartFile issuesFile) { public String uploadImage(MultipartFile issuesFile) {
return fileStorageUtil.getFileUrl( fileStorageUtil.uploadMultipart(issuesFile, HarmonicConstant.CONFIGURATIONPATH)); return fileStorageUtil.getFileUrl(fileStorageUtil.uploadMultipart(issuesFile, HarmonicConstant.CONFIGURATIONPATH));
} }
/*将strin写入Json文件返回一个InputStream*/ /*将strin写入Json文件返回一个InputStream*/