指标分组调整
This commit is contained in:
@@ -17,7 +17,7 @@ import java.util.List;
|
||||
@Data
|
||||
public class GroupArrParam {
|
||||
|
||||
@ApiModelProperty("setId")
|
||||
@ApiModelProperty("数据集id")
|
||||
@NotBlank(message = ValidMessage.ID_NOT_BLANK)
|
||||
private String setId;
|
||||
|
||||
@@ -28,8 +28,13 @@ public class GroupArrParam {
|
||||
|
||||
@Data
|
||||
public static class ArrItem {
|
||||
@ApiModelProperty("组id")
|
||||
private String id;
|
||||
@ApiModelProperty("组名称")
|
||||
private String name;
|
||||
@ApiModelProperty("组是否展示 0:不展示 1:展示")
|
||||
private Integer isShow;
|
||||
@ApiModelProperty("指标集合")
|
||||
private List<String> children;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.njcn.csdevice.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import java.io.Serializable;
|
||||
@@ -25,6 +27,7 @@ public class CsGroup {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(value = "id",type = IdType.INPUT)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.csdevice.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -21,6 +22,9 @@ public class CsGroupVO {
|
||||
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("是否展示 0:不展示 1:展示")
|
||||
private Integer isShow;
|
||||
|
||||
private List<CsGroupVO> children = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class CsGroupController extends BaseController {
|
||||
@ApiImplicitParam(name = "lineId", value = "监测点id", required = true)
|
||||
})
|
||||
public HttpResult<IPage<DataGroupTemplateVO>> getDeviceRtData(@RequestParam("id") String id, @RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize, @RequestParam(value = "lineId")String lineId){
|
||||
String methodDescribe = getMethodDescribe("getDeviceData");
|
||||
String methodDescribe = getMethodDescribe("getDeviceRtData");
|
||||
IPage<DataGroupTemplateVO> list = csGroupService.getDeviceRtData(id, pageNum, pageSize,lineId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.njcn.csdevice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsGroArr;
|
||||
import com.njcn.csdevice.pojo.vo.CsGroupVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -17,6 +16,6 @@ import java.util.List;
|
||||
*/
|
||||
public interface CsGroArrMapper extends BaseMapper<CsGroArr> {
|
||||
|
||||
List<CsGroupVO> getGroupArrayList(@Param("list") List<String> list);
|
||||
void insertList(@Param("list") List<CsGroArr> list);
|
||||
|
||||
}
|
||||
|
||||
@@ -22,11 +22,7 @@ public interface CsGroupMapper extends BaseMapper<CsGroup> {
|
||||
|
||||
List<CsGroupVO> getGroupData(@Param("dataSet") String dataSet);
|
||||
|
||||
List<CsGroupVO> getGroupData2(@Param("dataSet") String dataSet);
|
||||
|
||||
List<CsGroupVO> getArrayData(@Param("list") List<String> list);
|
||||
|
||||
void insertList(@Param("list") List<CsGroup> list);
|
||||
|
||||
Page<DataGroupTemplateVO> getGroupDataList(IPage<DataGroupTemplateVO> page, @Param("id") String id);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,19 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.csdevice.mapper.CsGroArrMapper">
|
||||
|
||||
<select id="getGroupArrayList" resultType="CsGroupVO">
|
||||
|
||||
</select>
|
||||
<insert id="insertList">
|
||||
insert into cs_gro_arr
|
||||
(
|
||||
group_id,
|
||||
array_id
|
||||
)
|
||||
values
|
||||
<foreach collection="list" item="item" index="index" separator=",">
|
||||
(
|
||||
#{item.groupId},
|
||||
#{item.arrayId}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -6,7 +6,8 @@
|
||||
select
|
||||
id,
|
||||
'0' pid,
|
||||
group_name name
|
||||
group_name name,
|
||||
is_show isShow
|
||||
from
|
||||
cs_group
|
||||
where
|
||||
@@ -14,18 +15,6 @@
|
||||
order by sort
|
||||
</select>
|
||||
|
||||
<select id="getGroupData2" resultType="CsGroupVO">
|
||||
select
|
||||
id,
|
||||
'0' pid,
|
||||
group_name name
|
||||
from
|
||||
cs_group
|
||||
where
|
||||
data_set_id = #{dataSet} and is_show = 1
|
||||
order by sort
|
||||
</select>
|
||||
|
||||
<select id="getArrayData" resultType="CsGroupVO">
|
||||
select
|
||||
t1.id,
|
||||
@@ -45,31 +34,29 @@
|
||||
<foreach collection='list' item='item' index="index" open='(' separator=',' close=')'>
|
||||
#{item}
|
||||
</foreach>
|
||||
and
|
||||
t2.is_show = 1
|
||||
order by t1.sort
|
||||
</select>
|
||||
|
||||
<insert id="insertList">
|
||||
insert into cs_group
|
||||
(
|
||||
id,
|
||||
data_set_id,
|
||||
group_name,
|
||||
sort,
|
||||
is_show
|
||||
)
|
||||
values
|
||||
<foreach collection="list" item="item" index="index" separator=",">
|
||||
(
|
||||
#{item.id},
|
||||
#{item.dataSetId},
|
||||
#{item.groupName},
|
||||
#{item.sort},
|
||||
#{item.isShow}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
<!-- <insert id="insertList">-->
|
||||
<!-- insert into cs_group-->
|
||||
<!-- (-->
|
||||
<!-- id,-->
|
||||
<!-- data_set_id,-->
|
||||
<!-- group_name,-->
|
||||
<!-- sort,-->
|
||||
<!-- is_show-->
|
||||
<!-- )-->
|
||||
<!-- values-->
|
||||
<!-- <foreach collection="list" item="item" index="index" separator=",">-->
|
||||
<!-- (-->
|
||||
<!-- #{item.id},-->
|
||||
<!-- #{item.dataSetId},-->
|
||||
<!-- #{item.groupName},-->
|
||||
<!-- #{item.sort},-->
|
||||
<!-- #{item.isShow}-->
|
||||
<!-- )-->
|
||||
<!-- </foreach>-->
|
||||
<!-- </insert>-->
|
||||
|
||||
|
||||
<select id="getGroupDataList" resultType="DataGroupTemplateVO">
|
||||
|
||||
@@ -4,8 +4,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.param.GroupArrParam;
|
||||
import com.njcn.csdevice.pojo.po.CsGroArr;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 组和指标关系表 服务类
|
||||
@@ -16,12 +14,6 @@ import java.util.List;
|
||||
*/
|
||||
public interface ICsGroArrService extends IService<CsGroArr> {
|
||||
|
||||
/**
|
||||
* 批量新增
|
||||
* @param list 数据集
|
||||
*/
|
||||
void insertList(List<CsGroArr> list);
|
||||
|
||||
/**
|
||||
* 更新组和指标关系
|
||||
* @param groupArrParam 组和指标关系
|
||||
|
||||
@@ -5,17 +5,19 @@ import cn.hutool.core.util.IdUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.mapper.CsGroArrMapper;
|
||||
import com.njcn.csdevice.mapper.CsGroupMapper;
|
||||
import com.njcn.csdevice.pojo.param.GroupArrParam;
|
||||
import com.njcn.csdevice.pojo.po.CsGroArr;
|
||||
import com.njcn.csdevice.pojo.po.CsGroup;
|
||||
import com.njcn.csdevice.service.ICsGroArrService;
|
||||
import com.njcn.csdevice.service.ICsGroupService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -30,48 +32,49 @@ import java.util.stream.Collectors;
|
||||
@AllArgsConstructor
|
||||
public class CsGroArrServiceImpl extends ServiceImpl<CsGroArrMapper, CsGroArr> implements ICsGroArrService {
|
||||
|
||||
private final CsGroupMapper csGroupMapper;
|
||||
|
||||
@Override
|
||||
public void insertList(List<CsGroArr> list) {
|
||||
this.saveBatch(list,1000);
|
||||
}
|
||||
private final ICsGroupService csGroupService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateGroArr(GroupArrParam groupArrParam) {
|
||||
List<GroupArrParam.ArrItem> list = groupArrParam.getData();
|
||||
List<String> groupIdList = list.stream().map(GroupArrParam.ArrItem::getId).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<CsGroArr> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.in(CsGroArr::getGroupId, groupIdList);
|
||||
this.baseMapper.delete(lambdaQueryWrapper);
|
||||
csGroupMapper.deleteBatchIds(groupIdList);
|
||||
//更新组信息
|
||||
if(CollectionUtil.isNotEmpty(list)) {
|
||||
List<CsGroup> listGroup = new ArrayList<>();
|
||||
List<CsGroArr> arrList = new ArrayList<>();
|
||||
List<String> groupIdList = list.stream().map(GroupArrParam.ArrItem::getId).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<CsGroArr> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.in(CsGroArr::getGroupId, groupIdList);
|
||||
this.baseMapper.delete(lambdaQueryWrapper);
|
||||
|
||||
List<CsGroup> listGroup = new ArrayList<>();
|
||||
List<CsGroArr> arrList = new ArrayList<>();
|
||||
|
||||
Integer sort = 0;
|
||||
for (GroupArrParam.ArrItem item : list) {
|
||||
if (CollectionUtil.isNotEmpty(item.getChildren())) {
|
||||
Integer sort = 0;
|
||||
for (GroupArrParam.ArrItem item : list) {
|
||||
CsGroup csGroup = new CsGroup();
|
||||
csGroup.setId(IdUtil.simpleUUID());
|
||||
csGroup.setGroupName(item.getName());
|
||||
String groupId = IdUtil.simpleUUID();
|
||||
if (Objects.isNull(item.getId()) || StringUtils.isBlank(item.getId())){
|
||||
csGroup.setId(groupId);
|
||||
} else {
|
||||
csGroup.setId(item.getId());
|
||||
}
|
||||
csGroup.setDataSetId(groupArrParam.getSetId());
|
||||
csGroup.setGroupName(item.getName());
|
||||
csGroup.setIsShow(item.getIsShow());
|
||||
csGroup.setSort(sort);
|
||||
csGroup.setIsShow(1);
|
||||
sort++;
|
||||
listGroup.add(csGroup);
|
||||
|
||||
for (String idItem : item.getChildren()) {
|
||||
CsGroArr groupArr = new CsGroArr();
|
||||
groupArr.setGroupId(csGroup.getId());
|
||||
groupArr.setArrayId(idItem);
|
||||
arrList.add(groupArr);
|
||||
if (CollectionUtil.isNotEmpty(item.getChildren())) {
|
||||
for (String idItem : item.getChildren()) {
|
||||
CsGroArr groupArr = new CsGroArr();
|
||||
groupArr.setGroupId(csGroup.getId());
|
||||
groupArr.setArrayId(idItem);
|
||||
arrList.add(groupArr);
|
||||
}
|
||||
}
|
||||
}
|
||||
csGroupService.saveOrUpdateBatch(listGroup,1000);
|
||||
this.saveBatch(arrList,1000);
|
||||
}
|
||||
csGroupMapper.insertList(listGroup);
|
||||
this.saveBatch(arrList,1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.mapper.CsDataArrayMapper;
|
||||
import com.njcn.csdevice.mapper.CsGroArrMapper;
|
||||
import com.njcn.csdevice.mapper.CsGroupMapper;
|
||||
import com.njcn.csdevice.pojo.param.EnergyBaseParam;
|
||||
import com.njcn.csdevice.pojo.po.CsDataArray;
|
||||
@@ -46,7 +47,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
|
||||
private final ICsDataArrayService csDataArrayService;
|
||||
|
||||
private final ICsGroArrService csGroArrService;
|
||||
private final CsGroArrMapper csGroArrMapper;
|
||||
|
||||
private final CsGroupMapper csGroupMapper;
|
||||
|
||||
@@ -60,16 +61,13 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public List<CsGroupVO> getGroupData(String dataSet) {
|
||||
List<CsGroupVO> list = this.baseMapper.getGroupData(dataSet);
|
||||
List<CsGroupVO> result = new ArrayList<>();
|
||||
List<CsGroupVO> result;
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
result = insertGroupData(dataSet);
|
||||
} else {
|
||||
List<CsGroupVO> list2 = this.baseMapper.getGroupData2(dataSet);
|
||||
if (CollectionUtil.isNotEmpty(list2)){
|
||||
List<String> groupList = list2.stream().map(CsGroupVO::getId).collect(Collectors.toList());
|
||||
List<CsGroupVO> arrayList = this.baseMapper.getArrayData(groupList);
|
||||
result = list2.stream().peek((item -> item.setChildren(getChildrenes(item.getId(), arrayList)))).collect(Collectors.toList());
|
||||
}
|
||||
List<String> groupList = list.stream().map(CsGroupVO::getId).collect(Collectors.toList());
|
||||
List<CsGroupVO> arrayList = this.baseMapper.getArrayData(groupList);
|
||||
result = list.stream().peek((item -> item.setChildren(getChildrenes(item.getId(), arrayList)))).collect(Collectors.toList());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -199,6 +197,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
csGroupVo.setId(groupId);
|
||||
csGroupVo.setPid("0");
|
||||
csGroupVo.setName(k);
|
||||
csGroupVo.setIsShow(1);
|
||||
v.forEach(item->{
|
||||
CsGroupVO csGroupVo2 = new CsGroupVO();
|
||||
csGroupVo2.setId(item.getDataId());
|
||||
@@ -213,7 +212,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
csGroupVo.setChildren(vo2);
|
||||
result.add(csGroupVo);
|
||||
});
|
||||
csGroArrService.insertList(groArrList);
|
||||
csGroArrMapper.insertList(groArrList);
|
||||
this.saveBatch(ls,1000);
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user