优化分组树的添加
parent
e96b39935d
commit
abbb5643c5
|
@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.TransactionDefinition;
|
import org.springframework.transaction.TransactionDefinition;
|
||||||
import org.springframework.transaction.TransactionStatus;
|
import org.springframework.transaction.TransactionStatus;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -70,6 +71,16 @@ public class GroupServiceImpl implements IGroupService {
|
||||||
assert group.getCommonGroupDeviceId() != null;
|
assert group.getCommonGroupDeviceId() != null;
|
||||||
group.setCommonGroupCreateTime(DateUtil.getNow());
|
group.setCommonGroupCreateTime(DateUtil.getNow());
|
||||||
group.setCommonGroupUpdateTime(DateUtil.getNow());
|
group.setCommonGroupUpdateTime(DateUtil.getNow());
|
||||||
|
Gb28181CodeType channelIdType = SipUtils.getChannelIdType(group.getCommonGroupParentId());
|
||||||
|
if (ObjectUtils.isEmpty(group.getCommonGroupParentId().trim()) || channelIdType.equals(Gb28181CodeType.BUSINESS_GROUP)) {
|
||||||
|
group.setCommonGroupParentId(null);
|
||||||
|
}
|
||||||
|
if (ObjectUtils.isEmpty(group.getCommonGroupTopId().trim())) {
|
||||||
|
Gb28181CodeType channelIdTypeForItem = SipUtils.getChannelIdType(group.getCommonGroupDeviceId());
|
||||||
|
if (channelIdTypeForItem.equals(Gb28181CodeType.BUSINESS_GROUP)) {
|
||||||
|
group.setCommonGroupTopId(group.getCommonGroupDeviceId());
|
||||||
|
}
|
||||||
|
}
|
||||||
return groupMapper.add(group) > 0;
|
return groupMapper.add(group) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,20 +27,22 @@ public interface GroupMapper {
|
||||||
" WHERE common_group_device_id = #{deviceId} ")
|
" WHERE common_group_device_id = #{deviceId} ")
|
||||||
Group queryByDeviceId(@Param("deviceId") String deviceId);
|
Group queryByDeviceId(@Param("deviceId") String deviceId);
|
||||||
|
|
||||||
@Insert("INSERT INTO wvp_common_group (" +
|
@Insert(value = " <script>" +
|
||||||
|
"INSERT INTO wvp_common_group (" +
|
||||||
"common_group_device_id, " +
|
"common_group_device_id, " +
|
||||||
"common_group_name, " +
|
"common_group_name, " +
|
||||||
"common_group_parent_id, " +
|
"<if test='group.commonGroupParentId != null'>common_group_parent_id, </if>" +
|
||||||
"common_group_top_id, " +
|
"common_group_top_id, " +
|
||||||
"common_group_update_time, " +
|
"common_group_update_time, " +
|
||||||
"common_group_create_time ) " +
|
"common_group_create_time ) " +
|
||||||
"VALUES (" +
|
"VALUES (" +
|
||||||
"#{commonGroupDeviceId}, " +
|
"#{group.commonGroupDeviceId}, " +
|
||||||
"#{commonGroupName}, " +
|
"#{group.commonGroupName}, " +
|
||||||
"#{commonGroupParentId}, " +
|
"<if test='group.commonGroupParentId != null'>#{group.commonGroupParentId}, </if>" +
|
||||||
"#{commonGroupTopId}, " +
|
"#{group.commonGroupTopId}, " +
|
||||||
"#{commonGroupUpdateTime}, " +
|
"#{group.commonGroupUpdateTime}, " +
|
||||||
"#{commonGroupCreateTime})")
|
"#{group.commonGroupCreateTime})" +
|
||||||
|
"</script>")
|
||||||
int add(@Param("group") Group group);
|
int add(@Param("group") Group group);
|
||||||
|
|
||||||
@Delete("delete from wvp_common_group where common_group_id = #{id}")
|
@Delete("delete from wvp_common_group where common_group_id = #{id}")
|
||||||
|
|
Loading…
Reference in New Issue